Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[media] Support progressive playback #4437

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions media/base/decoder_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class MEDIA_EXPORT DecoderBuffer
// If there's no data in this buffer, it represents end of stream.
#if BUILDFLAG(USE_STARBOARD_MEDIA)
bool end_of_stream() const { return !data_; }
void shrink_to(size_t size) { DCHECK_LE(size, size_); size_ = size; }
#else // BUILDFLAG(USE_STARBOARD_MEDIA)
bool end_of_stream() const {
return !read_only_mapping_.IsValid() && !writable_mapping_.IsValid() &&
Expand Down
23 changes: 22 additions & 1 deletion media/filters/demuxer_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "media/filters/manifest_demuxer.h"
#endif // BUILDFLAG(ENABLE_HLS_DEMUXER)

#if BUILDFLAG(USE_STARBOARD_MEDIA)
#include "media/starboard/progressive/progressive_demuxer.h"
#endif // BUILDFLAG(USE_STARBOARD_MEDIA)

namespace media {

namespace {
Expand Down Expand Up @@ -152,6 +156,7 @@ DemuxerManager::DemuxerManager(
enable_instant_source_buffer_gc_(enable_instant_source_buffer_gc),
demuxer_override_(std::move(demuxer_override)) {
DCHECK(client_);
LOG(ERROR) << "Cobalt " << __func__;
}

DemuxerManager::~DemuxerManager() {
Expand Down Expand Up @@ -372,6 +377,7 @@ PipelineStatus DemuxerManager::CreateDemuxer(
DataSource::Preload preload,
bool has_poster,
DemuxerManager::DemuxerCreatedCB on_demuxer_created) {
LOG(ERROR) << "Cobalt " << __func__;
// TODO(crbug/1377053) return a better error
if (!client_) {
return DEMUXER_ERROR_COULD_NOT_OPEN;
Expand Down Expand Up @@ -407,12 +413,18 @@ PipelineStatus DemuxerManager::CreateDemuxer(
// run in the demuxer override case?
SetDemuxer(std::move(demuxer_override_));
} else if (!load_media_source) {
#if BUILDFLAG(ENABLE_FFMPEG)
#if BUILDFLAG(USE_STARBOARD_MEDIA)
LOG(ERROR) << "Cobalt " << __func__;
SetDemuxer(CreateProgressiveDemuxer());
#elif BUILDFLAG(ENABLE_FFMPEG)
LOG(ERROR) << "Cobalt " << __func__;
SetDemuxer(CreateFFmpegDemuxer());
#else
LOG(ERROR) << "Cobalt " << __func__;
return DEMUXER_ERROR_COULD_NOT_OPEN;
#endif
} else {
LOG(ERROR) << "Cobalt " << __func__;
DCHECK(!HasDataSource());
SetDemuxer(CreateChunkDemuxer());
is_static = false;
Expand Down Expand Up @@ -596,6 +608,15 @@ std::unique_ptr<Demuxer> DemuxerManager::CreateMediaUrlDemuxer(
}
#endif // BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(USE_STARBOARD_MEDIA)
std::unique_ptr<Demuxer> DemuxerManager::CreateProgressiveDemuxer() {
DCHECK(data_source_);
return std::make_unique<ProgressiveDemuxer>(
media_task_runner_, data_source_.get(),
media_log_.get());
}
#endif // BUILDFLAG(USE_STARBOARD_MEDIA)

void DemuxerManager::SetDemuxer(std::unique_ptr<Demuxer> demuxer) {
DCHECK(!demuxer_);
CHECK(demuxer);
Expand Down
4 changes: 4 additions & 0 deletions media/filters/demuxer_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class MEDIA_EXPORT DemuxerManager {
std::unique_ptr<media::Demuxer> CreateMediaUrlDemuxer(bool hls_content);
#endif // BUILDFLAG(IS_ANDROID)

#if BUILDFLAG(USE_STARBOARD_MEDIA)
std::unique_ptr<media::Demuxer> CreateProgressiveDemuxer();
#endif // BUILDFLAG(USE_STARBOARD_MEDIA)

void SetDemuxer(std::unique_ptr<Demuxer> demuxer);

// Memory pressure listener specifically for when using ChunkDemuxer.
Expand Down
1 change: 1 addition & 0 deletions media/filters/ffmpeg_demuxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ FFmpegDemuxer::FFmpegDemuxer(
DCHECK(task_runner_.get());
DCHECK(data_source_);
DCHECK(media_tracks_updated_cb_);
LOG(ERROR) << "Cobalt " << __func__;
}

FFmpegDemuxer::~FFmpegDemuxer() {
Expand Down
25 changes: 25 additions & 0 deletions media/starboard/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ source_set("starboard") {
"decoder_buffer_allocator.cc",
"decoder_buffer_allocator.h",
"decoder_buffer_memory_info.h",
"progressive/avc_access_unit.cc",
"progressive/avc_access_unit.h",
"progressive/avc_parser.cc",
"progressive/avc_parser.h",
"progressive/data_source_reader.cc",
"progressive/data_source_reader.h",
"progressive/demuxer_extension_wrapper.cc",
"progressive/demuxer_extension_wrapper.h",
"progressive/mp4_map.cc",
"progressive/mp4_map.h",
"progressive/mp4_parser.cc",
"progressive/mp4_parser.h",
"progressive/progressive_demuxer.cc",
"progressive/progressive_demuxer.h",
"progressive/progressive_parser.cc",
"progressive/progressive_parser.h",
"progressive/rbsp_stream.cc",
"progressive/rbsp_stream.h",
"sbplayer_bridge.cc",
"sbplayer_bridge.h",
"sbplayer_interface.cc",
Expand All @@ -89,6 +107,10 @@ source_set("starboard") {
"//starboard/common",
]

if (use_starboard_media) {
deps += [ "//third_party/abseil-cpp:absl" ]
}

configs += [ "//media:subcomponent_config" ]
}

Expand All @@ -98,6 +120,9 @@ source_set("unit_tests") {
if (use_starboard_media) {
sources += [
"bidirectional_fit_reuse_allocator_test.cc",
"progressive/mock_data_source_reader.h",
"progressive/mp4_map_unittest.cc",
"progressive/rbsp_stream_unittest.cc",
"starboard_utils_test.cc",
]
}
Expand Down
Loading
Loading