Skip to content

Commit

Permalink
Merge 'feature/media-upstream-update' into 'main' (#3000)
Browse files Browse the repository at this point in the history
Merges the feature/media-upstream-update branch to main.

See the major commits to feature/media-upstream-update:

- Import `//skia` from Chromium m114:
#2816
- Update `//ui/gfx` to match Chromium m114:
#2844
- Update `//media` to match Chromium m114:
#2960
- Apply customizations to updated dependencies to build with Cobalt:
#2854

b/319697087
  • Loading branch information
osagie98 committed Apr 18, 2024
2 parents 46cf41b + 5efd46e commit f19055a
Show file tree
Hide file tree
Showing 4,473 changed files with 204,096 additions and 80,092 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions base/process/memory_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ bool UncheckedMalloc(size_t size, void** result) {
return *result != nullptr;
}

void UncheckedFree(void* ptr) {
free(ptr);
}

} // namespace base
5 changes: 4 additions & 1 deletion cobalt/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ target(final_executable_type, "cobalt") {
##############################

config("bindings_includes") {
include_dirs = [ _generated_source_output_dir ]
include_dirs = [
"//third_party/skia",
_generated_source_output_dir,
]
}

source_set("browser_switches") {
Expand Down
15 changes: 12 additions & 3 deletions cobalt/dom/source_buffer_algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

namespace cobalt {
namespace dom {
namespace {
using ::media::StreamParser;
} // namespace

SourceBufferAppendAlgorithm::SourceBufferAppendAlgorithm(
MediaSource* media_source, ::media::ChunkDemuxer* chunk_demuxer,
Expand Down Expand Up @@ -69,9 +72,15 @@ void SourceBufferAppendAlgorithm::Process(bool* finished) {
"append_size", append_size);

metrics_->StartTracking(SourceBufferMetricsAction::APPEND_BUFFER);
succeeded_ = chunk_demuxer_->AppendData(
id_, buffer_, append_size, append_window_start_, append_window_end_,
&timestamp_offset_);
succeeded_ = chunk_demuxer_->AppendToParseBuffer(id_, buffer_, append_size);
StreamParser::ParseStatus result =
StreamParser::ParseStatus::kSuccessHasMoreData;
while (succeeded_ &&
result == StreamParser::ParseStatus::kSuccessHasMoreData) {
result = chunk_demuxer_->RunSegmentParserLoop(
id_, append_window_start_, append_window_end_, &timestamp_offset_);
}
succeeded_ &= result == StreamParser::ParseStatus::kSuccess;
update_timestamp_offset_cb_.Run(timestamp_offset_);
metrics_->EndTracking(SourceBufferMetricsAction::APPEND_BUFFER,
succeeded_ ? append_size : 0);
Expand Down
2 changes: 2 additions & 0 deletions cobalt/media/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ component("media") {
"//net",
"//starboard:starboard_group",
"//third_party/protobuf:protobuf_lite",
"//ui/gfx:gfx",
"//url",
]
}
Expand Down Expand Up @@ -143,6 +144,7 @@ target(gtest_target_type, "media_test") {
"//media",
"//testing/gmock",
"//testing/gtest",
"//ui/gfx:gfx",
]

data_deps = [ "//cobalt/media/testing:cobalt_media_download_test_data" ]
Expand Down
29 changes: 16 additions & 13 deletions cobalt/media/base/metrics_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using starboard::ScopedLock;

MediaMetricsProvider::~MediaMetricsProvider() { ReportPipelineUMA(); }

void MediaMetricsProvider::OnError(const ::media::PipelineStatus status) {
void MediaMetricsProvider::OnError(const PipelineStatus status) {
ScopedLock scoped_lock(mutex_);
uma_info_.last_pipeline_status = status;
}
Expand Down Expand Up @@ -61,24 +61,27 @@ void MediaMetricsProvider::SetIsEME() {
void MediaMetricsProvider::ReportPipelineUMA() {
ScopedLock scoped_lock(mutex_);
if (uma_info_.has_video && uma_info_.has_audio) {
base::UmaHistogramExactLinear(GetUMANameForAVStream(uma_info_),
uma_info_.last_pipeline_status,
PipelineStatus::PIPELINE_STATUS_MAX + 1);
base::UmaHistogramExactLinear(
GetUMANameForAVStream(uma_info_), uma_info_.last_pipeline_status.code(),
PipelineStatus::Codes::PIPELINE_STATUS_MAX + 1);
} else if (uma_info_.has_audio) {
base::UmaHistogramExactLinear("Cobalt.Media.PipelineStatus.AudioOnly",
uma_info_.last_pipeline_status,
PipelineStatus::PIPELINE_STATUS_MAX + 1);
base::UmaHistogramExactLinear(
"Cobalt.Media.PipelineStatus.AudioOnly",
uma_info_.last_pipeline_status.code(),
PipelineStatus::Codes::PIPELINE_STATUS_MAX + 1);
} else if (uma_info_.has_video) {
base::UmaHistogramExactLinear("Cobalt.Media.PipelineStatus.VideoOnly",
uma_info_.last_pipeline_status,
PipelineStatus::PIPELINE_STATUS_MAX + 1);
base::UmaHistogramExactLinear(
"Cobalt.Media.PipelineStatus.VideoOnly",
uma_info_.last_pipeline_status.code(),
PipelineStatus::Codes::PIPELINE_STATUS_MAX + 1);
} else {
// Note: This metric can be recorded as a result of normal operation with
// Media Source Extensions. If a site creates a MediaSource object but never
// creates a source buffer or appends data, PIPELINE_OK will be recorded.
base::UmaHistogramExactLinear("Cobalt.Media.PipelineStatus.Unsupported",
uma_info_.last_pipeline_status,
PipelineStatus::PIPELINE_STATUS_MAX + 1);
base::UmaHistogramExactLinear(
"Cobalt.Media.PipelineStatus.Unsupported",
uma_info_.last_pipeline_status.code(),
PipelineStatus::Codes::PIPELINE_STATUS_MAX + 1);
}

// Report whether this player ever saw a playback event. Used to measure the
Expand Down
14 changes: 7 additions & 7 deletions cobalt/media/base/metrics_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ class MediaMetricsProvider {
bool has_video = false;
bool is_eme = false;
bool video_decoder_changed = false;
::media::AudioCodec audio_codec;
::media::VideoCodec video_codec;
::media::PipelineStatus last_pipeline_status =
::media::PipelineStatus::PIPELINE_OK;
AudioCodec audio_codec;
VideoCodec video_codec;
PipelineStatus last_pipeline_status =
PipelineStatus(PipelineStatus::Codes::PIPELINE_OK);
};

public:
// based on mojom::MediaMetricsProvider
void OnError(const ::media::PipelineStatus status);
void SetHasAudio(::media::AudioCodec audio_codec);
void SetHasVideo(::media::VideoCodec video_codec);
void OnError(const PipelineStatus status);
void SetHasAudio(AudioCodec audio_codec);
void SetHasVideo(VideoCodec video_codec);
void SetHasPlayed();
void SetHaveEnough();
void SetIsEME();
Expand Down
10 changes: 5 additions & 5 deletions cobalt/media/base/sbplayer_pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/task/bind_post_task.h"
#include "base/trace_event/trace_event.h"
#include "cobalt/base/c_val.h"
#include "cobalt/base/startup_timer.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/channel_layout.h"
#include "starboard/common/media.h"
#include "starboard/common/string.h"
Expand Down Expand Up @@ -398,7 +398,7 @@ void SbPlayerPipeline::Seek(TimeDelta time, const SeekCB& seek_cb) {
return;
}
#endif // SB_HAS(PLAYER_WITH_URL)
demuxer_->Seek(time, BindToCurrentLoop(base::Bind(
demuxer_->Seek(time, BindPostTaskToCurrentDefault(base::Bind(
&SbPlayerPipeline::OnDemuxerSeeked, this)));
}

Expand Down Expand Up @@ -651,7 +651,7 @@ void SbPlayerPipeline::StartTask(StartTaskParameters parameters) {
}
#endif // SB_HAS(PLAYER_WITH_URL)
demuxer_->Initialize(
this, BindToCurrentLoop(
this, BindPostTaskToCurrentDefault(
base::Bind(&SbPlayerPipeline::OnDemuxerInitialized, this)));

started_ = true;
Expand Down Expand Up @@ -966,7 +966,7 @@ void SbPlayerPipeline::OnDemuxerInitialized(PipelineStatus status) {
content_size_change_cb_.Run();
}
if (is_encrypted) {
RunSetDrmSystemReadyCB(::media::BindToCurrentLoop(
RunSetDrmSystemReadyCB(BindPostTaskToCurrentDefault(
base::Bind(&SbPlayerPipeline::CreatePlayer, this)));
return;
}
Expand Down Expand Up @@ -998,7 +998,7 @@ void SbPlayerPipeline::OnDemuxerStopped() {
void SbPlayerPipeline::OnDemuxerStreamRead(
DemuxerStream::Type type, int max_number_buffers_to_read,
DemuxerStream::Status status,
const std::vector<scoped_refptr<DecoderBuffer>>& buffers) {
const std::vector<scoped_refptr<DecoderBuffer>> buffers) {
#if SB_HAS(PLAYER_WITH_URL)
DCHECK(!is_url_based_);
#endif // SB_HAS(PLAYER_WITH_URL)
Expand Down
2 changes: 1 addition & 1 deletion cobalt/media/base/sbplayer_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class MEDIA_EXPORT SbPlayerPipeline : public Pipeline,
void OnDemuxerStreamRead(
::media::DemuxerStream::Type type, int max_number_buffers_to_read,
::media::DemuxerStream::Status status,
const std::vector<scoped_refptr<::media::DecoderBuffer>>& buffers);
const std::vector<scoped_refptr<::media::DecoderBuffer>> buffers);
// SbPlayerBridge::Host implementation.
void OnNeedData(::media::DemuxerStream::Type type,
int max_number_of_buffers_to_write) override;
Expand Down
1 change: 1 addition & 0 deletions cobalt/media/base/sbplayer_set_bounds_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef COBALT_MEDIA_BASE_SBPLAYER_SET_BOUNDS_HELPER_H_
#define COBALT_MEDIA_BASE_SBPLAYER_SET_BOUNDS_HELPER_H_

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "base/synchronization/lock.h"
Expand Down
1 change: 1 addition & 0 deletions cobalt/media/decoder_buffer_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <vector>

#include "base/logging.h"
#include "cobalt/math/size.h"
#include "media/base/starboard_utils.h"
#include "starboard/common/allocator.h"
Expand Down
12 changes: 6 additions & 6 deletions cobalt/media/player/web_media_player_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "cobalt/base/instance_counter.h"
Expand All @@ -28,7 +29,6 @@
#include "cobalt/media/progressive/data_source_reader.h"
#include "cobalt/media/progressive/demuxer_extension_wrapper.h"
#include "cobalt/media/progressive/progressive_demuxer.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/limits.h"
#include "media/base/timestamp_constants.h"
#include "media/filters/chunk_demuxer.h"
Expand Down Expand Up @@ -93,10 +93,10 @@ base::TimeDelta ConvertSecondsToTimestamp(double seconds) {
} // namespace

#define BIND_TO_RENDER_LOOP(function) \
::media::BindToCurrentLoop(base::Bind(function, AsWeakPtr()))
BindPostTaskToCurrentDefault(base::Bind(function, AsWeakPtr()))

#define BIND_TO_RENDER_LOOP_2(function, arg1, arg2) \
::media::BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1, arg2))
BindPostTaskToCurrentDefault(base::Bind(function, AsWeakPtr(), arg1, arg2))

// TODO(acolwell): Investigate whether the key_system & session_id parameters
// are really necessary.
Expand Down Expand Up @@ -666,15 +666,15 @@ void WebMediaPlayerImpl::OnPipelineError(::media::PipelineStatus error,
WebMediaPlayer::kNetworkStateFormatError,
message.empty()
? base::StringPrintf("Ready state have nothing. Error: (%d)",
static_cast<int>(error))
static_cast<int>(error.code()))
: base::StringPrintf(
"Ready state have nothing: Error: (%d), Message: %s",
static_cast<int>(error), message.c_str()));
static_cast<int>(error.code()), message.c_str()));
return;
}

std::string default_message;
switch (error) {
switch (error.code()) {
case ::media::PIPELINE_OK:
NOTREACHED() << "PIPELINE_OK isn't an error!";
break;
Expand Down
3 changes: 2 additions & 1 deletion cobalt/media/progressive/avc_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@ void AVCParser::ParseAudioSpecificConfig(uint8 b0, uint8 b1) {
aac_config[1] = b1;
audio_prepend_.clear();

int adts_header_size;
if (!aac.Parse(aac_config, media_log_) ||
!aac.ConvertEsdsToADTS(&audio_prepend_)) {
!aac.ConvertEsdsToADTS(&audio_prepend_, &adts_header_size)) {
DLOG(WARNING) << "Error in parsing AudioSpecificConfig.";
return;
}
Expand Down
9 changes: 4 additions & 5 deletions cobalt/media/progressive/demuxer_extension_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <string>
#include <utility>

#include "base/task/bind_post_task.h"
#include "base/time/time.h"
#include "media/base/audio_codecs.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/encryption_scheme.h"
#include "media/base/sample_format.h"
#include "media/base/starboard_utils.h"
Expand Down Expand Up @@ -188,8 +188,7 @@ DemuxerExtensionStream::DemuxerExtensionStream(
<< "Audio config is not valid!";
}

void DemuxerExtensionStream::Read(int max_number_of_buffers_to_read,
ReadCB read_cb) {
void DemuxerExtensionStream::Read(uint32_t count, ReadCB read_cb) {
DCHECK(!read_cb.is_null());
base::AutoLock auto_lock(lock_);
if (stopped_) {
Expand Down Expand Up @@ -542,7 +541,7 @@ void DemuxerExtensionWrapper::OnInitializeDone(
} else {
LOG(ERROR) << "Initialization failed with status " << status;
}
std::move(status_cb).Run(static_cast<PipelineStatus>(status));
std::move(status_cb).Run(static_cast<PipelineStatus::Codes>(status));
}

void DemuxerExtensionWrapper::AbortPendingReads() {}
Expand All @@ -558,7 +557,7 @@ void DemuxerExtensionWrapper::Seek(base::TimeDelta time,
blocking_thread_.task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&DemuxerExtensionWrapper::SeekTask, base::Unretained(this),
time, BindToCurrentLoop(std::move(status_cb))));
time, BindPostTaskToCurrentDefault(std::move(status_cb))));
}

// TODO(b/232984963): Determine whether it's OK to have reads and seeks on the
Expand Down
8 changes: 7 additions & 1 deletion cobalt/media/progressive/demuxer_extension_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class DemuxerExtensionStream : public ::media::DemuxerStream {
size_t GetTotalBufferSize() const;

// DemuxerStream implementation:
void Read(int max_number_of_buffers_to_read, ReadCB read_cb) override;
void Read(uint32_t count, ReadCB read_cb) override;
::media::AudioDecoderConfig audio_decoder_config() override;
::media::VideoDecoderConfig video_decoder_config() override;
Type type() const override;
Expand Down Expand Up @@ -165,13 +165,18 @@ class DemuxerExtensionWrapper : public ::media::Demuxer {
// Demuxer implementation:
std::vector<::media::DemuxerStream*> GetAllStreams() override;
std::string GetDisplayName() const override;
::media::DemuxerType GetDemuxerType() const override {
// kFFmpegDemuxer is used in Chromium media for progressive demuxing.
return ::media::DemuxerType::kFFmpegDemuxer;
}
void Initialize(::media::DemuxerHost* host,
::media::PipelineStatusCallback status_cb) override;
void AbortPendingReads() override;
void StartWaitingForSeek(base::TimeDelta seek_time) override;
void CancelPendingSeek(base::TimeDelta seek_time) override;
void Seek(base::TimeDelta time,
::media::PipelineStatusCallback status_cb) override;
bool IsSeekable() const override { return true; }
void Stop() override;
base::TimeDelta GetStartTime() const override;
base::Time GetTimelineOffset() const override;
Expand All @@ -182,6 +187,7 @@ class DemuxerExtensionWrapper : public ::media::Demuxer {
void OnSelectedVideoTrackChanged(
const std::vector<::media::MediaTrack::Id>& track_ids,
base::TimeDelta curr_time, TrackChangeCB change_completed_cb) override;
void SetPlaybackRate(double rate) override { NOTREACHED(); }

absl::optional<::media::container_names::MediaContainerName>
GetContainerForMetrics() const override {
Expand Down
Loading

0 comments on commit f19055a

Please sign in to comment.