summaryrefslogtreecommitdiff
path: root/chromium/media/mojo
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-24 11:30:15 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-10-30 12:56:19 +0000
commit6036726eb981b6c4b42047513b9d3f4ac865daac (patch)
tree673593e70678e7789766d1f732eb51f613a2703b /chromium/media/mojo
parent466052c4e7c052268fd931888cd58961da94c586 (diff)
downloadqtwebengine-chromium-6036726eb981b6c4b42047513b9d3f4ac865daac.tar.gz
BASELINE: Update Chromium to 70.0.3538.78
Change-Id: Ie634710bf039e26c1957f4ae45e101bd4c434ae7 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/media/mojo')
-rw-r--r--chromium/media/mojo/clients/BUILD.gn4
-rw-r--r--chromium/media/mojo/clients/mojo_cdm.cc12
-rw-r--r--chromium/media/mojo/clients/mojo_cdm.h4
-rw-r--r--chromium/media/mojo/clients/mojo_video_encode_accelerator.cc14
-rw-r--r--chromium/media/mojo/clients/mojo_video_encode_accelerator.h10
-rw-r--r--chromium/media/mojo/clients/mojo_video_encode_accelerator_unittest.cc38
-rw-r--r--chromium/media/mojo/common/BUILD.gn6
-rw-r--r--chromium/media/mojo/common/mojo_data_pipe_read_write.cc11
-rw-r--r--chromium/media/mojo/common/mojo_decoder_buffer_converter.cc11
-rw-r--r--chromium/media/mojo/common/mojo_pipe_read_write_util.cc17
-rw-r--r--chromium/media/mojo/common/mojo_pipe_read_write_util.h18
-rw-r--r--chromium/media/mojo/common/mojo_shared_buffer_video_frame.cc7
-rw-r--r--chromium/media/mojo/interfaces/OWNERS2
-rw-r--r--chromium/media/mojo/interfaces/audio_logging.mojom4
-rw-r--r--chromium/media/mojo/interfaces/audio_output_stream.mojom8
-rw-r--r--chromium/media/mojo/interfaces/content_decryption_module.mojom4
-rw-r--r--chromium/media/mojo/interfaces/jpeg_decode_accelerator.typemap4
-rw-r--r--chromium/media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.cc (renamed from chromium/media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.cc)2
-rw-r--r--chromium/media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.h (renamed from chromium/media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.h)6
-rw-r--r--chromium/media/mojo/interfaces/jpeg_encode_accelerator.typemap4
-rw-r--r--chromium/media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.cc (renamed from chromium/media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.cc)2
-rw-r--r--chromium/media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.h (renamed from chromium/media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.h)6
-rw-r--r--chromium/media/mojo/interfaces/media_metrics_provider.mojom36
-rw-r--r--chromium/media/mojo/interfaces/media_types.mojom4
-rw-r--r--chromium/media/mojo/interfaces/media_types.typemap2
-rw-r--r--chromium/media/mojo/interfaces/video_encode_accelerator.mojom25
-rw-r--r--chromium/media/mojo/interfaces/video_encode_accelerator.typemap14
-rw-r--r--chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.cc (renamed from chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.cc)70
-rw-r--r--chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.h143
-rw-r--r--chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.h77
-rw-r--r--chromium/media/mojo/services/BUILD.gn5
-rw-r--r--chromium/media/mojo/services/android_mojo_media_client.cc28
-rw-r--r--chromium/media/mojo/services/android_mojo_util.cc32
-rw-r--r--chromium/media/mojo/services/android_mojo_util.h33
-rw-r--r--chromium/media/mojo/services/deferred_destroy_strong_binding_set_unittest.cc2
-rw-r--r--chromium/media/mojo/services/gpu_mojo_media_client.cc30
-rw-r--r--chromium/media/mojo/services/media_metrics_provider.cc55
-rw-r--r--chromium/media/mojo/services/media_metrics_provider.h32
-rw-r--r--chromium/media/mojo/services/media_metrics_provider_unittest.cc35
-rw-r--r--chromium/media/mojo/services/media_service_unittest.cc2
-rw-r--r--chromium/media/mojo/services/mojo_audio_output_stream_provider.cc6
-rw-r--r--chromium/media/mojo/services/mojo_audio_output_stream_provider.h3
-rw-r--r--chromium/media/mojo/services/mojo_audio_output_stream_provider_unittest.cc6
-rw-r--r--chromium/media/mojo/services/mojo_cdm_file_io.cc2
-rw-r--r--chromium/media/mojo/services/mojo_cdm_service.cc5
-rw-r--r--chromium/media/mojo/services/mojo_cdm_service.h5
-rw-r--r--chromium/media/mojo/services/mojo_media_log.cc13
-rw-r--r--chromium/media/mojo/services/mojo_media_log.h4
-rw-r--r--chromium/media/mojo/services/mojo_video_encode_accelerator_service.cc26
-rw-r--r--chromium/media/mojo/services/mojo_video_encode_accelerator_service.h10
-rw-r--r--chromium/media/mojo/services/mojo_video_encode_accelerator_service_unittest.cc23
-rw-r--r--chromium/media/mojo/services/test_mojo_media_client.cc1
-rw-r--r--chromium/media/mojo/services/video_decode_perf_history.cc34
-rw-r--r--chromium/media/mojo/services/video_decode_perf_history.h22
-rw-r--r--chromium/media/mojo/services/video_decode_perf_history_unittest.cc13
-rw-r--r--chromium/media/mojo/services/video_decode_stats_recorder.cc22
-rw-r--r--chromium/media/mojo/services/video_decode_stats_recorder.h10
-rw-r--r--chromium/media/mojo/services/watch_time_recorder.cc10
-rw-r--r--chromium/media/mojo/services/watch_time_recorder.h11
-rw-r--r--chromium/media/mojo/services/watch_time_recorder_unittest.cc20
60 files changed, 669 insertions, 396 deletions
diff --git a/chromium/media/mojo/clients/BUILD.gn b/chromium/media/mojo/clients/BUILD.gn
index 90b391acdd2..92ab5405f08 100644
--- a/chromium/media/mojo/clients/BUILD.gn
+++ b/chromium/media/mojo/clients/BUILD.gn
@@ -2,8 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/jumbo.gni")
+
# Implementations of media C++ interfaces using corresponding mojo services.
-source_set("clients") {
+jumbo_source_set("clients") {
visibility = [
"//chromecast/*",
"//content/renderer:*",
diff --git a/chromium/media/mojo/clients/mojo_cdm.cc b/chromium/media/mojo/clients/mojo_cdm.cc
index 6e4f0c76013..782c342c710 100644
--- a/chromium/media/mojo/clients/mojo_cdm.cc
+++ b/chromium/media/mojo/clients/mojo_cdm.cc
@@ -69,7 +69,6 @@ MojoCdm::MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm,
: remote_cdm_(std::move(remote_cdm)),
interface_factory_(interface_factory),
client_binding_(this),
- task_runner_(base::ThreadTaskRunnerHandle::Get()),
cdm_id_(CdmContext::kInvalidCdmId),
session_message_cb_(session_message_cb),
session_closed_cb_(session_closed_cb),
@@ -82,20 +81,15 @@ MojoCdm::MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm,
DCHECK(!session_keys_change_cb_.is_null());
DCHECK(!session_expiration_update_cb_.is_null());
- mojom::ContentDecryptionModuleClientPtr client;
- client_binding_.Bind(mojo::MakeRequest(&client));
- remote_cdm_->SetClient(std::move(client));
+ mojom::ContentDecryptionModuleClientAssociatedPtrInfo client_ptr_info;
+ client_binding_.Bind(mojo::MakeRequest(&client_ptr_info));
+ remote_cdm_->SetClient(std::move(client_ptr_info));
}
MojoCdm::~MojoCdm() {
DVLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- // TODO(crbug.com/819269): It seems possible that |this| is destructed on the
- // wrong thread. Add this check to help investigation. We cannot CHECK on the
- // |thread_checker_| because it will not check anything in release builds.
- CHECK(task_runner_->BelongsToCurrentThread());
-
base::AutoLock auto_lock(lock_);
// Release |decryptor_| on the correct thread. If GetDecryptor() is never
diff --git a/chromium/media/mojo/clients/mojo_cdm.h b/chromium/media/mojo/clients/mojo_cdm.h
index 21ffd39ad0e..a5fd3cf8c42 100644
--- a/chromium/media/mojo/clients/mojo_cdm.h
+++ b/chromium/media/mojo/clients/mojo_cdm.h
@@ -21,6 +21,7 @@
#include "media/base/cdm_session_tracker.h"
#include "media/base/content_decryption_module.h"
#include "media/mojo/interfaces/content_decryption_module.mojom.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace base {
@@ -139,8 +140,7 @@ class MojoCdm : public ContentDecryptionModule,
mojom::ContentDecryptionModulePtr remote_cdm_;
mojom::InterfaceFactory* interface_factory_;
- mojo::Binding<ContentDecryptionModuleClient> client_binding_;
- scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ mojo::AssociatedBinding<ContentDecryptionModuleClient> client_binding_;
// Protects |cdm_id_|, |decryptor_ptr_|, |decryptor_| and
// |decryptor_task_runner_| which could be accessed from other threads.
diff --git a/chromium/media/mojo/clients/mojo_video_encode_accelerator.cc b/chromium/media/mojo/clients/mojo_video_encode_accelerator.cc
index c211bc7803f..12dfb8fddf9 100644
--- a/chromium/media/mojo/clients/mojo_video_encode_accelerator.cc
+++ b/chromium/media/mojo/clients/mojo_video_encode_accelerator.cc
@@ -98,16 +98,9 @@ MojoVideoEncodeAccelerator::GetSupportedProfiles() {
supported_profiles_);
}
-bool MojoVideoEncodeAccelerator::Initialize(VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
+bool MojoVideoEncodeAccelerator::Initialize(const Config& config,
Client* client) {
- DVLOG(2) << __func__
- << " input_format=" << VideoPixelFormatToString(input_format)
- << ", input_visible_size=" << input_visible_size.ToString()
- << ", output_profile=" << GetProfileName(output_profile)
- << ", initial_bitrate=" << initial_bitrate;
+ DVLOG(2) << __func__ << " " << config.AsHumanReadableString();
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!client)
return false;
@@ -119,8 +112,7 @@ bool MojoVideoEncodeAccelerator::Initialize(VideoPixelFormat input_format,
client, mojo::MakeRequest(&vea_client_ptr));
bool result = false;
- vea_->Initialize(input_format, input_visible_size, output_profile,
- initial_bitrate, std::move(vea_client_ptr), &result);
+ vea_->Initialize(config, std::move(vea_client_ptr), &result);
return result;
}
diff --git a/chromium/media/mojo/clients/mojo_video_encode_accelerator.h b/chromium/media/mojo/clients/mojo_video_encode_accelerator.h
index c39d6cddd2c..f555e0f5985 100644
--- a/chromium/media/mojo/clients/mojo_video_encode_accelerator.h
+++ b/chromium/media/mojo/clients/mojo_video_encode_accelerator.h
@@ -14,10 +14,6 @@
#include "media/mojo/interfaces/video_encode_accelerator.mojom.h"
#include "media/video/video_encode_accelerator.h"
-namespace gfx {
-class Size;
-} // namespace gfx
-
namespace media {
class VideoFrame;
} // namespace media
@@ -38,11 +34,7 @@ class MojoVideoEncodeAccelerator : public VideoEncodeAccelerator {
// VideoEncodeAccelerator implementation.
SupportedProfiles GetSupportedProfiles() override;
- bool Initialize(VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
- Client* client) override;
+ bool Initialize(const Config& config, Client* client) override;
void Encode(const scoped_refptr<VideoFrame>& frame,
bool force_keyframe) override;
void UseOutputBitstreamBuffer(const BitstreamBuffer& buffer) override;
diff --git a/chromium/media/mojo/clients/mojo_video_encode_accelerator_unittest.cc b/chromium/media/mojo/clients/mojo_video_encode_accelerator_unittest.cc
index 6189263bdba..c7b4b55390f 100644
--- a/chromium/media/mojo/clients/mojo_video_encode_accelerator_unittest.cc
+++ b/chromium/media/mojo/clients/mojo_video_encode_accelerator_unittest.cc
@@ -33,30 +33,30 @@ class MockMojoVideoEncodeAccelerator : public mojom::VideoEncodeAccelerator {
MockMojoVideoEncodeAccelerator() = default;
// mojom::VideoEncodeAccelerator impl.
- void Initialize(media::VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- media::VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
+ void Initialize(const media::VideoEncodeAccelerator::Config& config,
mojom::VideoEncodeAcceleratorClientPtr client,
InitializeCallback success_callback) override {
if (initialization_success_) {
ASSERT_TRUE(client);
client_ = std::move(client);
- const size_t allocation_size =
- VideoFrame::AllocationSize(input_format, input_visible_size);
+ const size_t allocation_size = VideoFrame::AllocationSize(
+ config.input_format, config.input_visible_size);
- client_->RequireBitstreamBuffers(1, input_visible_size, allocation_size);
+ client_->RequireBitstreamBuffers(1, config.input_visible_size,
+ allocation_size);
- DoInitialize(input_format, input_visible_size, output_profile,
- initial_bitrate, &client);
+ DoInitialize(config.input_format, config.input_visible_size,
+ config.output_profile, config.initial_bitrate,
+ config.content_type, &client);
}
std::move(success_callback).Run(initialization_success_);
}
- MOCK_METHOD5(DoInitialize,
+ MOCK_METHOD6(DoInitialize,
void(media::VideoPixelFormat,
const gfx::Size&,
media::VideoCodecProfile,
uint32_t,
+ media::VideoEncodeAccelerator::Config::ContentType,
mojom::VideoEncodeAcceleratorClientPtr*));
void Encode(const scoped_refptr<VideoFrame>& frame,
@@ -151,19 +151,22 @@ class MojoVideoEncodeAcceleratorTest : public ::testing::Test {
void Initialize(MockVideoEncodeAcceleratorClient* mock_vea_client) {
const VideoCodecProfile kOutputProfile = VIDEO_CODEC_PROFILE_UNKNOWN;
const uint32_t kInitialBitrate = 100000u;
+ const VideoEncodeAccelerator::Config::ContentType kContentType =
+ VideoEncodeAccelerator::Config::ContentType::kDisplay;
EXPECT_CALL(*mock_mojo_vea(),
DoInitialize(PIXEL_FORMAT_I420, kInputVisibleSize,
- kOutputProfile, kInitialBitrate, _));
+ kOutputProfile, kInitialBitrate, kContentType, _));
EXPECT_CALL(
*mock_vea_client,
RequireBitstreamBuffers(
_, kInputVisibleSize,
VideoFrame::AllocationSize(PIXEL_FORMAT_I420, kInputVisibleSize)));
- EXPECT_TRUE(mojo_vea()->Initialize(PIXEL_FORMAT_I420, kInputVisibleSize,
- kOutputProfile, kInitialBitrate,
- mock_vea_client));
+ const VideoEncodeAccelerator::Config config(
+ PIXEL_FORMAT_I420, kInputVisibleSize, kOutputProfile, kInitialBitrate,
+ base::nullopt, base::nullopt, kContentType);
+ EXPECT_TRUE(mojo_vea()->Initialize(config, mock_vea_client));
base::RunLoop().RunUntilIdle();
}
@@ -285,9 +288,10 @@ TEST_F(MojoVideoEncodeAcceleratorTest, InitializeFailure) {
mock_mojo_vea()->set_initialization_success(false);
- EXPECT_FALSE(mojo_vea()->Initialize(PIXEL_FORMAT_I420, kInputVisibleSize,
- VIDEO_CODEC_PROFILE_UNKNOWN,
- kInitialBitrate, mock_vea_client.get()));
+ const VideoEncodeAccelerator::Config config(
+ PIXEL_FORMAT_I420, kInputVisibleSize, VIDEO_CODEC_PROFILE_UNKNOWN,
+ kInitialBitrate);
+ EXPECT_FALSE(mojo_vea()->Initialize(config, mock_vea_client.get()));
base::RunLoop().RunUntilIdle();
}
diff --git a/chromium/media/mojo/common/BUILD.gn b/chromium/media/mojo/common/BUILD.gn
index 23dfe6c13aa..969a9742cd2 100644
--- a/chromium/media/mojo/common/BUILD.gn
+++ b/chromium/media/mojo/common/BUILD.gn
@@ -2,7 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-source_set("common") {
+import("//build/config/jumbo.gni")
+
+jumbo_source_set("common") {
sources = [
"media_type_converters.cc",
"media_type_converters.h",
@@ -10,6 +12,8 @@ source_set("common") {
"mojo_data_pipe_read_write.h",
"mojo_decoder_buffer_converter.cc",
"mojo_decoder_buffer_converter.h",
+ "mojo_pipe_read_write_util.cc",
+ "mojo_pipe_read_write_util.h",
]
deps = [
diff --git a/chromium/media/mojo/common/mojo_data_pipe_read_write.cc b/chromium/media/mojo/common/mojo_data_pipe_read_write.cc
index 311e167161f..87e5cb22ec2 100644
--- a/chromium/media/mojo/common/mojo_data_pipe_read_write.cc
+++ b/chromium/media/mojo/common/mojo_data_pipe_read_write.cc
@@ -8,16 +8,11 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
+#include "media/mojo/common/mojo_pipe_read_write_util.h"
-namespace media {
-
-namespace {
+using media::mojo_pipe_read_write_util::IsPipeReadWriteError;
-bool IsPipeReadWriteError(MojoResult result) {
- return result != MOJO_RESULT_OK && result != MOJO_RESULT_SHOULD_WAIT;
-}
-
-} // namespace
+namespace media {
// MojoDataPipeReader
diff --git a/chromium/media/mojo/common/mojo_decoder_buffer_converter.cc b/chromium/media/mojo/common/mojo_decoder_buffer_converter.cc
index fb267eb1f43..9ba228f1e6d 100644
--- a/chromium/media/mojo/common/mojo_decoder_buffer_converter.cc
+++ b/chromium/media/mojo/common/mojo_decoder_buffer_converter.cc
@@ -14,16 +14,11 @@
#include "media/base/cdm_context.h"
#include "media/base/decoder_buffer.h"
#include "media/mojo/common/media_type_converters.h"
+#include "media/mojo/common/mojo_pipe_read_write_util.h"
-namespace media {
-
-namespace {
+using media::mojo_pipe_read_write_util::IsPipeReadWriteError;
-bool IsPipeReadWriteError(MojoResult result) {
- return result != MOJO_RESULT_OK && result != MOJO_RESULT_SHOULD_WAIT;
-}
-
-} // namespace
+namespace media {
uint32_t GetDefaultDecoderBufferConverterCapacity(DemuxerStream::Type type) {
uint32_t capacity = 0;
diff --git a/chromium/media/mojo/common/mojo_pipe_read_write_util.cc b/chromium/media/mojo/common/mojo_pipe_read_write_util.cc
new file mode 100644
index 00000000000..85b6fe9440d
--- /dev/null
+++ b/chromium/media/mojo/common/mojo_pipe_read_write_util.cc
@@ -0,0 +1,17 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/mojo/common/mojo_pipe_read_write_util.h"
+
+#include "mojo/public/c/system/types.h"
+
+namespace media {
+namespace mojo_pipe_read_write_util {
+
+bool IsPipeReadWriteError(MojoResult result) {
+ return result != MOJO_RESULT_OK && result != MOJO_RESULT_SHOULD_WAIT;
+}
+
+} // namespace mojo_pipe_read_write_util
+} // namespace media
diff --git a/chromium/media/mojo/common/mojo_pipe_read_write_util.h b/chromium/media/mojo/common/mojo_pipe_read_write_util.h
new file mode 100644
index 00000000000..4d4f8726d0b
--- /dev/null
+++ b/chromium/media/mojo/common/mojo_pipe_read_write_util.h
@@ -0,0 +1,18 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MOJO_COMMON_MOJO_PIPE_READ_WRITE_UTIL_H_
+#define MEDIA_MOJO_COMMON_MOJO_PIPE_READ_WRITE_UTIL_H_
+
+#include "mojo/public/c/system/types.h"
+
+namespace media {
+namespace mojo_pipe_read_write_util {
+
+bool IsPipeReadWriteError(MojoResult result);
+
+} // namespace mojo_pipe_read_write_util
+} // namespace media
+
+#endif // MEDIA_MOJO_COMMON_MOJO_PIPE_READ_WRITE_UTIL_H_
diff --git a/chromium/media/mojo/common/mojo_shared_buffer_video_frame.cc b/chromium/media/mojo/common/mojo_shared_buffer_video_frame.cc
index e53c65ec851..bd7df5f866d 100644
--- a/chromium/media/mojo/common/mojo_shared_buffer_video_frame.cc
+++ b/chromium/media/mojo/common/mojo_shared_buffer_video_frame.cc
@@ -4,6 +4,9 @@
#include "media/mojo/common/mojo_shared_buffer_video_frame.h"
+#include <utility>
+#include <vector>
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
@@ -176,9 +179,7 @@ bool MojoSharedBufferVideoFrame::Init(int32_t y_stride,
if (!shared_buffer_mapping_)
return false;
- set_stride(kYPlane, y_stride);
- set_stride(kUPlane, u_stride);
- set_stride(kVPlane, v_stride);
+ set_strides({y_stride, u_stride, v_stride});
offsets_[kYPlane] = y_offset;
offsets_[kUPlane] = u_offset;
offsets_[kVPlane] = v_offset;
diff --git a/chromium/media/mojo/interfaces/OWNERS b/chromium/media/mojo/interfaces/OWNERS
index 2c44a463856..8e9e507beb2 100644
--- a/chromium/media/mojo/interfaces/OWNERS
+++ b/chromium/media/mojo/interfaces/OWNERS
@@ -1,5 +1,7 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
+per-file *_mojom_traits*.*=set noparent
+per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
per-file *_struct_traits*.*=set noparent
per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
per-file *.typemap=set noparent
diff --git a/chromium/media/mojo/interfaces/audio_logging.mojom b/chromium/media/mojo/interfaces/audio_logging.mojom
index d8484274e61..777fd31852d 100644
--- a/chromium/media/mojo/interfaces/audio_logging.mojom
+++ b/chromium/media/mojo/interfaces/audio_logging.mojom
@@ -33,6 +33,10 @@ interface AudioLog {
// Called when an audio component changes volume. |volume| is the new volume.
OnSetVolume(double volume);
+ // Called with information about audio processing set-up for an audio
+ // component.
+ OnProcessingStateChanged(string message);
+
// Called when an audio component wants to forward a log message.
OnLogMessage(string message);
};
diff --git a/chromium/media/mojo/interfaces/audio_output_stream.mojom b/chromium/media/mojo/interfaces/audio_output_stream.mojom
index 3d901f57edd..9683e762127 100644
--- a/chromium/media/mojo/interfaces/audio_output_stream.mojom
+++ b/chromium/media/mojo/interfaces/audio_output_stream.mojom
@@ -4,6 +4,7 @@
module media.mojom;
+import "mojo/public/mojom/base/unguessable_token.mojom";
import "media/mojo/interfaces/audio_data_pipe.mojom";
import "media/mojo/interfaces/audio_parameters.mojom";
import "media/mojo/interfaces/media_types.mojom";
@@ -68,9 +69,12 @@ interface AudioOutputStreamProvider {
// Creates a new AudioOutputStream using |params|. |client| is notified when
// the stream is ready. The stream lifetime is bound by the lifetime of
// |client|. On error, the |client| will have a disconnect reason among the
- // specified ones in AudioOutputStreamProviderClient.
+ // specified ones in AudioOutputStreamProviderClient. |processing_id|, if
+ // provided, identifies the group of input and output streams that are related
+ // during audio processing.
// Can only be called once.
- Acquire(AudioParameters params, AudioOutputStreamProviderClient client);
+ Acquire(AudioParameters params, AudioOutputStreamProviderClient client,
+ mojo_base.mojom.UnguessableToken? processing_id);
};
interface AudioOutputStreamProviderClient {
diff --git a/chromium/media/mojo/interfaces/content_decryption_module.mojom b/chromium/media/mojo/interfaces/content_decryption_module.mojom
index 5ce72b4a930..612932f9d72 100644
--- a/chromium/media/mojo/interfaces/content_decryption_module.mojom
+++ b/chromium/media/mojo/interfaces/content_decryption_module.mojom
@@ -63,7 +63,9 @@ struct CdmKeyInformation {
interface ContentDecryptionModule {
// Sets ContentDecryptionModuleClient. Must be called before any other calls.
- SetClient(ContentDecryptionModuleClient client);
+ // Use associated interface to ensure ordering, e.g. events on the client
+ // interface and promise fulfillment.
+ SetClient(associated ContentDecryptionModuleClient client);
// Initializes the CDM. If initialization failed (e.g. |key_system| or
// |cdm_config| is not supported), |result.success| will be false and |cdm_id|
diff --git a/chromium/media/mojo/interfaces/jpeg_decode_accelerator.typemap b/chromium/media/mojo/interfaces/jpeg_decode_accelerator.typemap
index b3e3b98981c..9f647c6e9e2 100644
--- a/chromium/media/mojo/interfaces/jpeg_decode_accelerator.typemap
+++ b/chromium/media/mojo/interfaces/jpeg_decode_accelerator.typemap
@@ -10,10 +10,10 @@ public_headers = [
]
traits_headers =
- [ "//media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.h" ]
+ [ "//media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.h" ]
sources = [
- "//media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.cc",
+ "//media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.cc",
]
deps = [
diff --git a/chromium/media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.cc b/chromium/media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.cc
index 3297e8fcb79..85844837526 100644
--- a/chromium/media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.cc
+++ b/chromium/media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.h"
+#include "media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.h"
#include "base/logging.h"
#include "media/base/ipc/media_param_traits_macros.h"
diff --git a/chromium/media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.h b/chromium/media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.h
index 3b5fd31b3d5..eb85f18b086 100644
--- a/chromium/media/mojo/interfaces/jpeg_decode_accelerator_typemap_traits.h
+++ b/chromium/media/mojo/interfaces/jpeg_decode_accelerator_mojom_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_MOJO_INTERFACES_JPEG_DECODE_ACCELERATOR_TYPEMAP_TRAITS_H_
-#define MEDIA_MOJO_INTERFACES_JPEG_DECODE_ACCELERATOR_TYPEMAP_TRAITS_H_
+#ifndef MEDIA_MOJO_INTERFACES_JPEG_DECODE_ACCELERATOR_MOJOM_TRAITS_H_
+#define MEDIA_MOJO_INTERFACES_JPEG_DECODE_ACCELERATOR_MOJOM_TRAITS_H_
#include "base/numerics/safe_conversions.h"
#include "media/base/bitstream_buffer.h"
@@ -61,4 +61,4 @@ struct StructTraits<media::mojom::BitstreamBufferDataView,
} // namespace mojo
-#endif // MEDIA_MOJO_INTERFACES_JPEG_DECODE_ACCELERATOR_TYPEMAP_TRAITS_H_
+#endif // MEDIA_MOJO_INTERFACES_JPEG_DECODE_ACCELERATOR_MOJOM_TRAITS_H_
diff --git a/chromium/media/mojo/interfaces/jpeg_encode_accelerator.typemap b/chromium/media/mojo/interfaces/jpeg_encode_accelerator.typemap
index 04d83a8d528..b5b310be5a7 100644
--- a/chromium/media/mojo/interfaces/jpeg_encode_accelerator.typemap
+++ b/chromium/media/mojo/interfaces/jpeg_encode_accelerator.typemap
@@ -7,10 +7,10 @@ mojom = "//media/mojo/interfaces/jpeg_encode_accelerator.mojom"
public_headers = [ "//media/video/jpeg_encode_accelerator.h" ]
traits_headers =
- [ "//media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.h" ]
+ [ "//media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.h" ]
sources = [
- "//media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.cc",
+ "//media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.cc",
]
deps = [
diff --git a/chromium/media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.cc b/chromium/media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.cc
index ba38fd1a3c3..1e5a6a43eb8 100644
--- a/chromium/media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.cc
+++ b/chromium/media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.h"
+#include "media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.h"
#include "base/logging.h"
diff --git a/chromium/media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.h b/chromium/media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.h
index 6257881d197..19eb26a0841 100644
--- a/chromium/media/mojo/interfaces/jpeg_encode_accelerator_typemap_traits.h
+++ b/chromium/media/mojo/interfaces/jpeg_encode_accelerator_mojom_traits.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MEDIA_MOJO_INTERFACES_JPEG_ENCODE_ACCELERATOR_TYPEMAP_TRAITS_H_
-#define MEDIA_MOJO_INTERFACES_JPEG_ENCODE_ACCELERATOR_TYPEMAP_TRAITS_H_
+#ifndef MEDIA_MOJO_INTERFACES_JPEG_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
+#define MEDIA_MOJO_INTERFACES_JPEG_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
#include "media/mojo/interfaces/jpeg_encode_accelerator.mojom.h"
#include "media/video/jpeg_encode_accelerator.h"
@@ -22,4 +22,4 @@ struct EnumTraits<media::mojom::EncodeStatus,
} // namespace mojo
-#endif // MEDIA_MOJO_INTERFACES_JPEG_ENCODE_ACCELERATOR_TYPEMAP_TRAITS_H_
+#endif // MEDIA_MOJO_INTERFACES_JPEG_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
diff --git a/chromium/media/mojo/interfaces/media_metrics_provider.mojom b/chromium/media/mojo/interfaces/media_metrics_provider.mojom
index 570a58ce341..7326c547686 100644
--- a/chromium/media/mojo/interfaces/media_metrics_provider.mojom
+++ b/chromium/media/mojo/interfaces/media_metrics_provider.mojom
@@ -9,18 +9,33 @@ import "media/mojo/interfaces/video_decode_stats_recorder.mojom";
import "media/mojo/interfaces/watch_time_recorder.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
-import "url/mojom/origin.mojom";
+
+// Used for reporting to UMA and UKM. Represents the URL scheme of the src URL
+// given to an <audio> or <video> tag. Always add new entries to the end.
+enum MediaURLScheme {
+ kUnknown = 0,
+ kMissing,
+ kHttp,
+ kHttps,
+ kFtp,
+ kChromeExtension,
+ kJavascript,
+ kFile,
+ kBlob,
+ kData,
+ kFileSystem,
+ kChrome,
+ kContent,
+ kContentId,
+};
// Provider interface used to avoid having one time setters on each interface.
// Each recorder will be stamped with an ID which can be used for linking UKM.
interface MediaMetricsProvider {
// Assigns a playback ID and sets up this provider instance with information
// needed to make UKM reports. No other methods may be called until after
- // Initialize() has been called.
- //
- // TODO(crbug.com/787209): Stop getting origin from the renderer.
- Initialize(bool is_mse, bool is_top_frame,
- url.mojom.Origin untrusted_top_origin);
+ // Initialize() has been called. |url_scheme| is only used if |!is_mse|.
+ Initialize(bool is_mse, MediaURLScheme url_scheme);
// Called when a playback ends in error. The status is reported to UKM when
// the provider is destructed.
@@ -32,15 +47,14 @@ interface MediaMetricsProvider {
SetTimeToFirstFrame(mojo_base.mojom.TimeDelta elapsed);
SetTimeToPlayReady(mojo_base.mojom.TimeDelta elapsed);
+ // For src= playbacks, this is the container (".mp4", ".webm", etc).
+ SetContainerName(MediaContainerName container_name);
+
// Creates a WatchTimeRecorder instance using |properties|. If any of those
// properties changes, a new recorder should be requested.
AcquireWatchTimeRecorder(PlaybackProperties properties,
WatchTimeRecorder& recorder);
- // Creates a VideoDecodeStatsRecorder instance. Provide the origin of the top
- // frame of the page hosting the video. Privacy team requires we use only the
- // top-frame origin. |is_top_frame| signals whether the video is hosted in the
- // top frame vs some inner frame to help interpret the origin.
- // TODO(crbug.com/787209): Stop getting origin from the renderer.
+ // Creates a VideoDecodeStatsRecorder instance.
AcquireVideoDecodeStatsRecorder(VideoDecodeStatsRecorder& recorder);
};
diff --git a/chromium/media/mojo/interfaces/media_types.mojom b/chromium/media/mojo/interfaces/media_types.mojom
index 66df670a578..48c051516d5 100644
--- a/chromium/media/mojo/interfaces/media_types.mojom
+++ b/chromium/media/mojo/interfaces/media_types.mojom
@@ -69,6 +69,10 @@ enum WatchTimeKey;
[Native]
enum EncryptionMode;
+// See media/base/container_names.h for descriptions.
+[Native]
+enum MediaContainerName;
+
// This defines a mojo transport format for media::EncryptionPattern
// See media/base/encryption_pattern.h for description.
struct EncryptionPattern {
diff --git a/chromium/media/mojo/interfaces/media_types.typemap b/chromium/media/mojo/interfaces/media_types.typemap
index 42b4d2198bb..b6ac3c15acf 100644
--- a/chromium/media/mojo/interfaces/media_types.typemap
+++ b/chromium/media/mojo/interfaces/media_types.typemap
@@ -8,6 +8,7 @@ public_headers = [
"//media/base/audio_codecs.h",
"//media/base/buffering_state.h",
"//media/base/channel_layout.h",
+ "//media/base/container_names.h",
"//media/base/decode_status.h",
"//media/base/decrypt_config.h",
"//media/base/encryption_pattern.h",
@@ -42,6 +43,7 @@ type_mappings = [
"media.mojom.DecodeStatus=media::DecodeStatus",
"media.mojom.EncryptionMode=media::EncryptionMode",
"media.mojom.EncryptionScheme.CipherMode=media::EncryptionScheme::CipherMode",
+ "media.mojom.MediaContainerName=media::container_names::MediaContainerName",
"media.mojom.MediaLogEvent=media::MediaLogEvent",
"media.mojom.OutputDeviceStatus=media::OutputDeviceStatus",
"media.mojom.PipelineStatus=media::PipelineStatus",
diff --git a/chromium/media/mojo/interfaces/video_encode_accelerator.mojom b/chromium/media/mojo/interfaces/video_encode_accelerator.mojom
index a8eb9ec286b..0f44b6f1523 100644
--- a/chromium/media/mojo/interfaces/video_encode_accelerator.mojom
+++ b/chromium/media/mojo/interfaces/video_encode_accelerator.mojom
@@ -42,6 +42,26 @@ struct VideoBitrateAllocation {
array<int32> bitrates;
};
+// This defines a mojo transport format for
+// media::VideoEncodeAccelerator::Config.
+struct VideoEncodeAcceleratorConfig {
+ // See media::VideoEncodeAccelerator::Config::ContentType
+ enum ContentType {
+ kCamera,
+ kDisplay
+ };
+
+ VideoPixelFormat input_format;
+ gfx.mojom.Size input_visible_size;
+ VideoCodecProfile output_profile;
+ uint32 initial_bitrate;
+ uint32 initial_framerate;
+ bool has_initial_framerate; // Whether or not config has initial framerate
+ uint8 h264_output_level;
+ bool has_h264_output_level; // Whether or not config has H264 output level
+ ContentType content_type;
+};
+
interface VideoEncodeAccelerator {
// See media::VideoEncodeAccelerator::Error
enum Error {
@@ -53,10 +73,7 @@ interface VideoEncodeAccelerator {
// Responded by VideoEncodeAcceleratorClient.RequireBitstreamBuffers().
// TODO(mcasas): Update to asynchronous, https://crbug.com/744210.
[Sync]
- Initialize(VideoPixelFormat input_format,
- gfx.mojom.Size input_visible_size,
- VideoCodecProfile output_profile,
- uint32 initial_bitrate,
+ Initialize(VideoEncodeAcceleratorConfig config,
VideoEncodeAcceleratorClient client)
=> (bool result);
diff --git a/chromium/media/mojo/interfaces/video_encode_accelerator.typemap b/chromium/media/mojo/interfaces/video_encode_accelerator.typemap
index 70be7dbfea1..24a7712fcf1 100644
--- a/chromium/media/mojo/interfaces/video_encode_accelerator.typemap
+++ b/chromium/media/mojo/interfaces/video_encode_accelerator.typemap
@@ -7,21 +7,29 @@ mojom = "//media/mojo/interfaces/video_encode_accelerator.mojom"
public_headers = [ "//media/video/video_encode_accelerator.h" ]
traits_headers =
- [ "//media/mojo/interfaces/video_encode_accelerator_typemap_traits.h" ]
+ [ "//media/mojo/interfaces/video_encode_accelerator_mojom_traits.h" ]
sources = [
- "//media/mojo/interfaces/video_encode_accelerator_typemap_traits.cc",
- "//media/mojo/interfaces/video_encode_accelerator_typemap_traits.h",
+ "//media/mojo/interfaces/video_encode_accelerator_mojom_traits.cc",
+ "//media/mojo/interfaces/video_encode_accelerator_mojom_traits.h",
+]
+
+public_deps = [
+ "//base",
+ "//media",
]
deps = [
"//base",
"//media",
+ "//media/base/ipc",
+ "//ui/gfx/geometry/mojo:struct_traits",
]
type_mappings = [
"media.mojom.BitstreamBufferMetadata=media::BitstreamBufferMetadata",
"media.mojom.VideoBitrateAllocation=media::VideoBitrateAllocation",
"media.mojom.VideoEncodeAccelerator.Error=media::VideoEncodeAccelerator::Error",
+ "media.mojom.VideoEncodeAcceleratorConfig=media::VideoEncodeAccelerator::Config",
"media.mojom.Vp8Metadata=media::Vp8Metadata",
]
diff --git a/chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.cc b/chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.cc
index 3deea35e8ef..edfcf3f95d1 100644
--- a/chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.cc
+++ b/chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/mojo/interfaces/video_encode_accelerator_typemap_traits.h"
+#include "media/mojo/interfaces/video_encode_accelerator_mojom_traits.h"
#include "base/logging.h"
+#include "base/optional.h"
#include "media/base/video_bitrate_allocation.h"
#include "mojo/public/cpp/base/time_mojom_traits.h"
@@ -114,4 +115,71 @@ bool StructTraits<media::mojom::Vp8MetadataDataView, media::Vp8Metadata>::Read(
out_metadata->layer_sync = data.layer_sync();
return true;
}
+
+// static
+media::mojom::VideoEncodeAcceleratorConfig::ContentType
+EnumTraits<media::mojom::VideoEncodeAcceleratorConfig::ContentType,
+ media::VideoEncodeAccelerator::Config::ContentType>::
+ ToMojom(media::VideoEncodeAccelerator::Config::ContentType input) {
+ switch (input) {
+ case media::VideoEncodeAccelerator::Config::ContentType::kDisplay:
+ return media::mojom::VideoEncodeAcceleratorConfig::ContentType::kDisplay;
+ case media::VideoEncodeAccelerator::Config::ContentType::kCamera:
+ return media::mojom::VideoEncodeAcceleratorConfig::ContentType::kCamera;
+ }
+ NOTREACHED();
+ return media::mojom::VideoEncodeAcceleratorConfig::ContentType::kCamera;
+}
+// static
+bool EnumTraits<media::mojom::VideoEncodeAcceleratorConfig::ContentType,
+ media::VideoEncodeAccelerator::Config::ContentType>::
+ FromMojom(media::mojom::VideoEncodeAcceleratorConfig::ContentType input,
+ media::VideoEncodeAccelerator::Config::ContentType* output) {
+ switch (input) {
+ case media::mojom::VideoEncodeAcceleratorConfig::ContentType::kCamera:
+ *output = media::VideoEncodeAccelerator::Config::ContentType::kCamera;
+ return true;
+ case media::mojom::VideoEncodeAcceleratorConfig::ContentType::kDisplay:
+ *output = media::VideoEncodeAccelerator::Config::ContentType::kDisplay;
+ return true;
+ }
+ NOTREACHED();
+ return false;
+}
+
+// static
+bool StructTraits<media::mojom::VideoEncodeAcceleratorConfigDataView,
+ media::VideoEncodeAccelerator::Config>::
+ Read(media::mojom::VideoEncodeAcceleratorConfigDataView input,
+ media::VideoEncodeAccelerator::Config* output) {
+ media::VideoPixelFormat input_format;
+ if (!input.ReadInputFormat(&input_format))
+ return false;
+
+ gfx::Size input_visible_size;
+ if (!input.ReadInputVisibleSize(&input_visible_size))
+ return false;
+
+ media::VideoCodecProfile output_profile;
+ if (!input.ReadOutputProfile(&output_profile))
+ return false;
+
+ base::Optional<uint32_t> initial_framerate;
+ if (input.has_initial_framerate())
+ initial_framerate = input.initial_framerate();
+
+ base::Optional<uint8_t> h264_output_level;
+ if (input.has_h264_output_level())
+ h264_output_level = input.h264_output_level();
+
+ media::VideoEncodeAccelerator::Config::ContentType content_type;
+ if (!input.ReadContentType(&content_type))
+ return false;
+
+ *output = media::VideoEncodeAccelerator::Config(
+ input_format, input_visible_size, output_profile, input.initial_bitrate(),
+ initial_framerate, h264_output_level, content_type);
+ return true;
+}
+
} // namespace mojo
diff --git a/chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.h b/chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.h
new file mode 100644
index 00000000000..78787dcf461
--- /dev/null
+++ b/chromium/media/mojo/interfaces/video_encode_accelerator_mojom_traits.h
@@ -0,0 +1,143 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MOJO_INTERFACES_VIDEO_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
+#define MEDIA_MOJO_INTERFACES_VIDEO_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
+
+#include "media/base/ipc/media_param_traits.h"
+#include "media/mojo/interfaces/media_types.mojom.h"
+#include "media/mojo/interfaces/video_encode_accelerator.mojom.h"
+#include "media/video/video_encode_accelerator.h"
+#include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
+
+namespace mojo {
+
+template <>
+struct EnumTraits<media::mojom::VideoEncodeAccelerator::Error,
+ media::VideoEncodeAccelerator::Error> {
+ static media::mojom::VideoEncodeAccelerator::Error ToMojom(
+ media::VideoEncodeAccelerator::Error error);
+
+ static bool FromMojom(media::mojom::VideoEncodeAccelerator::Error input,
+ media::VideoEncodeAccelerator::Error* out);
+};
+
+template <>
+class StructTraits<media::mojom::VideoBitrateAllocationDataView,
+ media::VideoBitrateAllocation> {
+ public:
+ static std::vector<int32_t> bitrates(
+ const media::VideoBitrateAllocation& bitrate_allocation);
+
+ static bool Read(media::mojom::VideoBitrateAllocationDataView data,
+ media::VideoBitrateAllocation* out_bitrate_allocation);
+};
+
+template <>
+class StructTraits<media::mojom::BitstreamBufferMetadataDataView,
+ media::BitstreamBufferMetadata> {
+ public:
+ static size_t payload_size_bytes(const media::BitstreamBufferMetadata& bbm) {
+ return bbm.payload_size_bytes;
+ }
+ static bool key_frame(const media::BitstreamBufferMetadata& bbm) {
+ return bbm.key_frame;
+ }
+ static base::TimeDelta timestamp(const media::BitstreamBufferMetadata& bbm) {
+ return bbm.timestamp;
+ }
+ static const base::Optional<media::Vp8Metadata>& vp8(
+ const media::BitstreamBufferMetadata& bbm) {
+ return bbm.vp8;
+ }
+
+ static bool Read(media::mojom::BitstreamBufferMetadataDataView data,
+ media::BitstreamBufferMetadata* out_metadata);
+};
+
+template <>
+class StructTraits<media::mojom::Vp8MetadataDataView, media::Vp8Metadata> {
+ public:
+ static bool non_reference(const media::Vp8Metadata& vp8) {
+ return vp8.non_reference;
+ }
+
+ static uint8_t temporal_idx(const media::Vp8Metadata& vp8) {
+ return vp8.temporal_idx;
+ }
+
+ static bool layer_sync(const media::Vp8Metadata& vp8) {
+ return vp8.layer_sync;
+ }
+
+ static bool Read(media::mojom::Vp8MetadataDataView data,
+ media::Vp8Metadata* out_metadata);
+};
+
+template <>
+struct EnumTraits<media::mojom::VideoEncodeAcceleratorConfig::ContentType,
+ media::VideoEncodeAccelerator::Config::ContentType> {
+ static media::mojom::VideoEncodeAcceleratorConfig::ContentType ToMojom(
+ media::VideoEncodeAccelerator::Config::ContentType input);
+
+ static bool FromMojom(
+ media::mojom::VideoEncodeAcceleratorConfig::ContentType,
+ media::VideoEncodeAccelerator::Config::ContentType* output);
+};
+
+template <>
+struct StructTraits<media::mojom::VideoEncodeAcceleratorConfigDataView,
+ media::VideoEncodeAccelerator::Config> {
+ static media::VideoPixelFormat input_format(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.input_format;
+ }
+
+ static const gfx::Size& input_visible_size(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.input_visible_size;
+ }
+
+ static media::VideoCodecProfile output_profile(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.output_profile;
+ }
+
+ static uint32_t initial_bitrate(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.initial_bitrate;
+ }
+
+ static uint32_t initial_framerate(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.initial_framerate.value_or(0);
+ }
+
+ static bool has_initial_framerate(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.initial_framerate.has_value();
+ }
+
+ static uint8_t h264_output_level(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.h264_output_level.value_or(0);
+ }
+
+ static bool has_h264_output_level(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.h264_output_level.has_value();
+ }
+
+ static media::VideoEncodeAccelerator::Config::ContentType content_type(
+ const media::VideoEncodeAccelerator::Config& input) {
+ return input.content_type;
+ }
+
+ static bool Read(media::mojom::VideoEncodeAcceleratorConfigDataView input,
+ media::VideoEncodeAccelerator::Config* output);
+};
+
+} // namespace mojo
+
+#endif // MEDIA_MOJO_INTERFACES_VIDEO_ENCODE_ACCELERATOR_MOJOM_TRAITS_H_
diff --git a/chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.h b/chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.h
deleted file mode 100644
index 96af90c60a4..00000000000
--- a/chromium/media/mojo/interfaces/video_encode_accelerator_typemap_traits.h
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MEDIA_MOJO_INTERFACES_VIDEO_ENCODE_ACCELERATOR_TYPEMAP_TRAITS_H_
-#define MEDIA_MOJO_INTERFACES_VIDEO_ENCODE_ACCELERATOR_TYPEMAP_TRAITS_H_
-
-#include "media/mojo/interfaces/video_encode_accelerator.mojom.h"
-#include "media/video/video_encode_accelerator.h"
-
-namespace mojo {
-
-template <>
-struct EnumTraits<media::mojom::VideoEncodeAccelerator::Error,
- media::VideoEncodeAccelerator::Error> {
- static media::mojom::VideoEncodeAccelerator::Error ToMojom(
- media::VideoEncodeAccelerator::Error error);
-
- static bool FromMojom(media::mojom::VideoEncodeAccelerator::Error input,
- media::VideoEncodeAccelerator::Error* out);
-};
-
-template <>
-class StructTraits<media::mojom::VideoBitrateAllocationDataView,
- media::VideoBitrateAllocation> {
- public:
- static std::vector<int32_t> bitrates(
- const media::VideoBitrateAllocation& bitrate_allocation);
-
- static bool Read(media::mojom::VideoBitrateAllocationDataView data,
- media::VideoBitrateAllocation* out_bitrate_allocation);
-};
-
-template <>
-class StructTraits<media::mojom::BitstreamBufferMetadataDataView,
- media::BitstreamBufferMetadata> {
- public:
- static size_t payload_size_bytes(const media::BitstreamBufferMetadata& bbm) {
- return bbm.payload_size_bytes;
- }
- static bool key_frame(const media::BitstreamBufferMetadata& bbm) {
- return bbm.key_frame;
- }
- static base::TimeDelta timestamp(const media::BitstreamBufferMetadata& bbm) {
- return bbm.timestamp;
- }
- static const base::Optional<media::Vp8Metadata>& vp8(
- const media::BitstreamBufferMetadata& bbm) {
- return bbm.vp8;
- }
-
- static bool Read(media::mojom::BitstreamBufferMetadataDataView data,
- media::BitstreamBufferMetadata* out_metadata);
-};
-
-template <>
-class StructTraits<media::mojom::Vp8MetadataDataView, media::Vp8Metadata> {
- public:
- static bool non_reference(const media::Vp8Metadata& vp8) {
- return vp8.non_reference;
- }
-
- static uint8_t temporal_idx(const media::Vp8Metadata& vp8) {
- return vp8.temporal_idx;
- }
-
- static bool layer_sync(const media::Vp8Metadata& vp8) {
- return vp8.layer_sync;
- }
-
- static bool Read(media::mojom::Vp8MetadataDataView data,
- media::Vp8Metadata* out_metadata);
-};
-
-} // namespace mojo
-
-#endif // MEDIA_MOJO_INTERFACES_VIDEO_ENCODE_ACCELERATOR_TYPEMAP_TRAITS_H_
diff --git a/chromium/media/mojo/services/BUILD.gn b/chromium/media/mojo/services/BUILD.gn
index 99bbf748eea..fad29c2caed 100644
--- a/chromium/media/mojo/services/BUILD.gn
+++ b/chromium/media/mojo/services/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/jumbo.gni")
import("//media/media_options.gni")
import("//services/catalog/public/tools/catalog.gni")
import("//services/service_manager/public/cpp/service.gni")
@@ -9,7 +10,7 @@ import("//services/service_manager/public/service_manifest.gni")
import("//services/service_manager/public/tools/test/service_test.gni")
import("//testing/test.gni")
-component("services") {
+jumbo_component("services") {
output_name = "media_mojo_services"
sources = [
"deferred_destroy_strong_binding_set.h",
@@ -110,6 +111,8 @@ component("services") {
sources += [
"android_mojo_media_client.cc",
"android_mojo_media_client.h",
+ "android_mojo_util.cc",
+ "android_mojo_util.h",
"mojo_media_drm_storage.cc",
"mojo_media_drm_storage.h",
]
diff --git a/chromium/media/mojo/services/android_mojo_media_client.cc b/chromium/media/mojo/services/android_mojo_media_client.cc
index 78489cb08c7..7fd230d1b9b 100644
--- a/chromium/media/mojo/services/android_mojo_media_client.cc
+++ b/chromium/media/mojo/services/android_mojo_media_client.cc
@@ -14,33 +14,13 @@
#include "media/filters/android/media_codec_audio_decoder.h"
#include "media/mojo/interfaces/media_drm_storage.mojom.h"
#include "media/mojo/interfaces/provision_fetcher.mojom.h"
-#include "media/mojo/services/mojo_media_drm_storage.h"
-#include "media/mojo/services/mojo_provision_fetcher.h"
+#include "media/mojo/services/android_mojo_util.h"
#include "services/service_manager/public/cpp/connect.h"
-namespace media {
-
-namespace {
-
-std::unique_ptr<ProvisionFetcher> CreateProvisionFetcher(
- service_manager::mojom::InterfaceProvider* host_interfaces) {
- DCHECK(host_interfaces);
- mojom::ProvisionFetcherPtr provision_fetcher_ptr;
- service_manager::GetInterface(host_interfaces, &provision_fetcher_ptr);
- return std::make_unique<MojoProvisionFetcher>(
- std::move(provision_fetcher_ptr));
-}
+using media::android_mojo_util::CreateProvisionFetcher;
+using media::android_mojo_util::CreateMediaDrmStorage;
-std::unique_ptr<MediaDrmStorage> CreateMediaDrmStorage(
- service_manager::mojom::InterfaceProvider* host_interfaces) {
- DCHECK(host_interfaces);
- mojom::MediaDrmStoragePtr media_drm_storage_ptr;
- service_manager::GetInterface(host_interfaces, &media_drm_storage_ptr);
- return std::make_unique<MojoMediaDrmStorage>(
- std::move(media_drm_storage_ptr));
-}
-
-} // namespace
+namespace media {
AndroidMojoMediaClient::AndroidMojoMediaClient() {}
diff --git a/chromium/media/mojo/services/android_mojo_util.cc b/chromium/media/mojo/services/android_mojo_util.cc
new file mode 100644
index 00000000000..ee2b722b87b
--- /dev/null
+++ b/chromium/media/mojo/services/android_mojo_util.cc
@@ -0,0 +1,32 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/mojo/services/android_mojo_util.h"
+
+#include "media/mojo/services/mojo_media_drm_storage.h"
+#include "services/service_manager/public/cpp/connect.h"
+
+namespace media {
+namespace android_mojo_util {
+
+std::unique_ptr<ProvisionFetcher> CreateProvisionFetcher(
+ service_manager::mojom::InterfaceProvider* host_interfaces) {
+ DCHECK(host_interfaces);
+ mojom::ProvisionFetcherPtr provision_fetcher_ptr;
+ service_manager::GetInterface(host_interfaces, &provision_fetcher_ptr);
+ return std::make_unique<MojoProvisionFetcher>(
+ std::move(provision_fetcher_ptr));
+}
+
+std::unique_ptr<MediaDrmStorage> CreateMediaDrmStorage(
+ service_manager::mojom::InterfaceProvider* host_interfaces) {
+ DCHECK(host_interfaces);
+ mojom::MediaDrmStoragePtr media_drm_storage_ptr;
+ service_manager::GetInterface(host_interfaces, &media_drm_storage_ptr);
+ return std::make_unique<MojoMediaDrmStorage>(
+ std::move(media_drm_storage_ptr));
+}
+
+} // namespace android_mojo_util
+} // namespace media
diff --git a/chromium/media/mojo/services/android_mojo_util.h b/chromium/media/mojo/services/android_mojo_util.h
new file mode 100644
index 00000000000..62f17839c18
--- /dev/null
+++ b/chromium/media/mojo/services/android_mojo_util.h
@@ -0,0 +1,33 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MOJO_SERVICES_ANDROID_MOJO_UTIL_H_
+#define MEDIA_MOJO_SERVICES_ANDROID_MOJO_UTIL_H_
+
+#include <memory>
+
+#include "media/mojo/services/mojo_media_drm_storage.h"
+#include "media/mojo/services/mojo_provision_fetcher.h"
+
+namespace service_manager {
+namespace mojom {
+
+class InterfaceProvider;
+
+} // namespace mojom
+} // namespace service_manager
+
+namespace media {
+namespace android_mojo_util {
+
+std::unique_ptr<ProvisionFetcher> CreateProvisionFetcher(
+ service_manager::mojom::InterfaceProvider* host_interfaces);
+
+std::unique_ptr<MediaDrmStorage> CreateMediaDrmStorage(
+ service_manager::mojom::InterfaceProvider* host_interfaces);
+
+} // namespace android_mojo_util
+} // namespace media
+
+#endif // MEDIA_MOJO_SERVICES_ANDROID_MOJO_UTIL_H_
diff --git a/chromium/media/mojo/services/deferred_destroy_strong_binding_set_unittest.cc b/chromium/media/mojo/services/deferred_destroy_strong_binding_set_unittest.cc
index a749ac3e598..7794340157c 100644
--- a/chromium/media/mojo/services/deferred_destroy_strong_binding_set_unittest.cc
+++ b/chromium/media/mojo/services/deferred_destroy_strong_binding_set_unittest.cc
@@ -23,7 +23,7 @@ class DeferredDestroyPingImpl : public DeferredDestroy<PingService> {
~DeferredDestroyPingImpl() override { --instance_count; }
// DeferredDestroy<PingService> implementation.
- void Ping(const PingCallback& callback) override {}
+ void Ping(PingCallback callback) override {}
void OnDestroyPending(base::OnceClosure destroy_cb) override {
destroy_cb_ = std::move(destroy_cb);
if (can_destroy_)
diff --git a/chromium/media/mojo/services/gpu_mojo_media_client.cc b/chromium/media/mojo/services/gpu_mojo_media_client.cc
index dd6d7ba0912..fab176b2955 100644
--- a/chromium/media/mojo/services/gpu_mojo_media_client.cc
+++ b/chromium/media/mojo/services/gpu_mojo_media_client.cc
@@ -38,32 +38,16 @@
#include "media/gpu/windows/d3d11_video_decoder.h"
#endif // defined(OS_WIN)
+#if defined(OS_ANDROID)
+#include "media/mojo/services/android_mojo_util.h"
+using media::android_mojo_util::CreateProvisionFetcher;
+using media::android_mojo_util::CreateMediaDrmStorage;
+#endif // defined(OS_ANDROID)
+
namespace media {
namespace {
-// TODO(xhwang): Remove the duplicate code between GpuMojoMediaClient and
-// AndroidMojoMediaClient.
-
-#if defined(OS_ANDROID)
-std::unique_ptr<ProvisionFetcher> CreateProvisionFetcher(
- service_manager::mojom::InterfaceProvider* interface_provider) {
- mojom::ProvisionFetcherPtr provision_fetcher_ptr;
- service_manager::GetInterface(interface_provider, &provision_fetcher_ptr);
- return std::make_unique<MojoProvisionFetcher>(
- std::move(provision_fetcher_ptr));
-}
-
-std::unique_ptr<MediaDrmStorage> CreateMediaDrmStorage(
- service_manager::mojom::InterfaceProvider* host_interfaces) {
- DCHECK(host_interfaces);
- mojom::MediaDrmStoragePtr media_drm_storage_ptr;
- service_manager::GetInterface(host_interfaces, &media_drm_storage_ptr);
- return std::make_unique<MojoMediaDrmStorage>(
- std::move(media_drm_storage_ptr));
-}
-#endif // defined(OS_ANDROID)
-
#if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
gpu::CommandBufferStub* GetCommandBufferStub(
base::WeakPtr<MediaGpuChannelManager> media_gpu_channel_manager,
@@ -143,7 +127,7 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
}
#endif // defined(OS_WIN)
return VdaVideoDecoder::Create(
- task_runner, gpu_task_runner_, media_log, target_color_space,
+ task_runner, gpu_task_runner_, media_log->Clone(), target_color_space,
gpu_preferences_, gpu_workarounds_,
base::BindRepeating(&GetCommandBufferStub, media_gpu_channel_manager_,
command_buffer_id->channel_token,
diff --git a/chromium/media/mojo/services/media_metrics_provider.cc b/chromium/media/mojo/services/media_metrics_provider.cc
index 68b61055398..074e7ad532b 100644
--- a/chromium/media/mojo/services/media_metrics_provider.cc
+++ b/chromium/media/mojo/services/media_metrics_provider.cc
@@ -18,8 +18,13 @@ constexpr char kInvalidInitialize[] = "Initialize() was not called correctly.";
static uint64_t g_player_id = 0;
MediaMetricsProvider::MediaMetricsProvider(
+ bool is_top_frame,
+ ukm::SourceId source_id,
VideoDecodePerfHistory::SaveCallback save_cb)
- : player_id_(g_player_id++), save_cb_(save_cb) {}
+ : player_id_(g_player_id++),
+ is_top_frame_(is_top_frame),
+ source_id_(source_id),
+ save_cb_(std::move(save_cb)) {}
MediaMetricsProvider::~MediaMetricsProvider() {
// UKM may be unavailable in content_shell or other non-chrome/ builds; it
@@ -29,16 +34,17 @@ MediaMetricsProvider::~MediaMetricsProvider() {
if (!ukm_recorder || !initialized_)
return;
- const int32_t source_id = ukm_recorder->GetNewSourceID();
-
- // TODO(crbug.com/787209): Stop getting origin from the renderer.
- ukm_recorder->UpdateSourceURL(source_id, untrusted_top_origin_.GetURL());
- ukm::builders::Media_WebMediaPlayerState builder(source_id);
+ ukm::builders::Media_WebMediaPlayerState builder(source_id_);
builder.SetPlayerID(player_id_);
builder.SetIsTopFrame(is_top_frame_);
builder.SetIsEME(is_eme_);
builder.SetIsMSE(is_mse_);
builder.SetFinalPipelineStatus(pipeline_status_);
+ if (!is_mse_) {
+ builder.SetURLScheme(static_cast<int64_t>(url_scheme_));
+ if (container_name_)
+ builder.SetContainerName(*container_name_);
+ }
if (time_to_metadata_ != kNoTimestamp)
builder.SetTimeToMetadata(time_to_metadata_.InMilliseconds());
@@ -51,25 +57,26 @@ MediaMetricsProvider::~MediaMetricsProvider() {
}
// static
-void MediaMetricsProvider::Create(VideoDecodePerfHistory::SaveCallback save_cb,
+void MediaMetricsProvider::Create(bool is_top_frame,
+ GetSourceIdCallback get_source_id_cb,
+ VideoDecodePerfHistory::SaveCallback save_cb,
mojom::MediaMetricsProviderRequest request) {
mojo::MakeStrongBinding(
- std::make_unique<MediaMetricsProvider>(std::move(save_cb)),
+ std::make_unique<MediaMetricsProvider>(
+ is_top_frame, get_source_id_cb.Run(), std::move(save_cb)),
std::move(request));
}
void MediaMetricsProvider::Initialize(bool is_mse,
- bool is_top_frame,
- const url::Origin& untrusted_top_origin) {
+ mojom::MediaURLScheme url_scheme) {
if (initialized_) {
mojo::ReportBadMessage(kInvalidInitialize);
return;
}
is_mse_ = is_mse;
- is_top_frame_ = is_top_frame;
- untrusted_top_origin_ = untrusted_top_origin;
initialized_ = true;
+ url_scheme_ = url_scheme;
}
void MediaMetricsProvider::OnError(PipelineStatus status) {
@@ -100,6 +107,13 @@ void MediaMetricsProvider::SetTimeToPlayReady(base::TimeDelta elapsed) {
time_to_play_ready_ = elapsed;
}
+void MediaMetricsProvider::SetContainerName(
+ container_names::MediaContainerName container_name) {
+ DCHECK(initialized_);
+ DCHECK(!container_name_.has_value());
+ container_name_ = container_name;
+}
+
void MediaMetricsProvider::AcquireWatchTimeRecorder(
mojom::PlaybackPropertiesPtr properties,
mojom::WatchTimeRecorderRequest request) {
@@ -108,10 +122,10 @@ void MediaMetricsProvider::AcquireWatchTimeRecorder(
return;
}
- mojo::MakeStrongBinding(std::make_unique<WatchTimeRecorder>(
- std::move(properties), untrusted_top_origin_,
- is_top_frame_, player_id_),
- std::move(request));
+ mojo::MakeStrongBinding(
+ std::make_unique<WatchTimeRecorder>(std::move(properties), source_id_,
+ is_top_frame_, player_id_),
+ std::move(request));
}
void MediaMetricsProvider::AcquireVideoDecodeStatsRecorder(
@@ -121,15 +135,14 @@ void MediaMetricsProvider::AcquireVideoDecodeStatsRecorder(
return;
}
- if (save_cb_.is_null()) {
+ if (!save_cb_) {
DVLOG(3) << __func__ << " Ignoring request, SaveCallback is null";
return;
}
- mojo::MakeStrongBinding(
- std::make_unique<VideoDecodeStatsRecorder>(
- untrusted_top_origin_, is_top_frame_, player_id_, save_cb_),
- std::move(request));
+ mojo::MakeStrongBinding(std::make_unique<VideoDecodeStatsRecorder>(
+ save_cb_, source_id_, is_top_frame_, player_id_),
+ std::move(request));
}
} // namespace media
diff --git a/chromium/media/mojo/services/media_metrics_provider.h b/chromium/media/mojo/services/media_metrics_provider.h
index a870c583c45..169bf969e63 100644
--- a/chromium/media/mojo/services/media_metrics_provider.h
+++ b/chromium/media/mojo/services/media_metrics_provider.h
@@ -7,12 +7,13 @@
#include <stdint.h>
+#include "media/base/container_names.h"
#include "media/base/pipeline_status.h"
#include "media/base/timestamp_constants.h"
#include "media/mojo/interfaces/media_metrics_provider.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "media/mojo/services/video_decode_perf_history.h"
-#include "url/origin.h"
+#include "services/metrics/public/cpp/ukm_source_id.h"
namespace media {
class VideoDecodePerfHistory;
@@ -21,24 +22,31 @@ class VideoDecodePerfHistory;
class MEDIA_MOJO_EXPORT MediaMetricsProvider
: public mojom::MediaMetricsProvider {
public:
- explicit MediaMetricsProvider(VideoDecodePerfHistory::SaveCallback save_cb);
+ MediaMetricsProvider(bool is_top_frame,
+ ukm::SourceId source_id,
+ VideoDecodePerfHistory::SaveCallback save_cb);
~MediaMetricsProvider() override;
+ // Callback for retrieving a ukm::SourceId.
+ using GetSourceIdCallback = base::RepeatingCallback<ukm::SourceId(void)>;
+
// Creates a MediaMetricsProvider, |perf_history| may be nullptr if perf
// history database recording is disabled.
- static void Create(VideoDecodePerfHistory::SaveCallback save_cb,
+ static void Create(bool is_top_frame,
+ GetSourceIdCallback get_source_id_cb,
+ VideoDecodePerfHistory::SaveCallback save_cb,
mojom::MediaMetricsProviderRequest request);
private:
// mojom::MediaMetricsProvider implementation:
- void Initialize(bool is_mse,
- bool is_top_frame,
- const url::Origin& untrusted_top_origin) override;
+ void Initialize(bool is_mse, mojom::MediaURLScheme url_scheme) override;
void OnError(PipelineStatus status) override;
void SetIsEME() override;
void SetTimeToMetadata(base::TimeDelta elapsed) override;
void SetTimeToFirstFrame(base::TimeDelta elapsed) override;
void SetTimeToPlayReady(base::TimeDelta elapsed) override;
+ void SetContainerName(
+ container_names::MediaContainerName container_name) override;
void AcquireWatchTimeRecorder(
mojom::PlaybackPropertiesPtr properties,
mojom::WatchTimeRecorderRequest request) override;
@@ -49,6 +57,13 @@ class MEDIA_MOJO_EXPORT MediaMetricsProvider
// to coordinate multiply logged events with a singly logged metric.
const uint64_t player_id_;
+ // Are UKM reports for the main frame or for a subframe?
+ const bool is_top_frame_;
+
+ const ukm::SourceId source_id_;
+
+ const VideoDecodePerfHistory::SaveCallback save_cb_;
+
// These values are not always sent but have known defaults.
PipelineStatus pipeline_status_ = PIPELINE_OK;
bool is_eme_ = false;
@@ -56,14 +71,13 @@ class MEDIA_MOJO_EXPORT MediaMetricsProvider
// The values below are only set if |initialized_| is true.
bool initialized_ = false;
bool is_mse_;
- bool is_top_frame_;
- url::Origin untrusted_top_origin_;
+ mojom::MediaURLScheme url_scheme_;
base::TimeDelta time_to_metadata_ = kNoTimestamp;
base::TimeDelta time_to_first_frame_ = kNoTimestamp;
base::TimeDelta time_to_play_ready_ = kNoTimestamp;
- const VideoDecodePerfHistory::SaveCallback save_cb_;
+ base::Optional<container_names::MediaContainerName> container_name_;
DISALLOW_COPY_AND_ASSIGN(MediaMetricsProvider);
};
diff --git a/chromium/media/mojo/services/media_metrics_provider_unittest.cc b/chromium/media/mojo/services/media_metrics_provider_unittest.cc
index 62e43286386..1c277beab1d 100644
--- a/chromium/media/mojo/services/media_metrics_provider_unittest.cc
+++ b/chromium/media/mojo/services/media_metrics_provider_unittest.cc
@@ -29,13 +29,23 @@ class MediaMetricsProviderTest : public testing::Test {
~MediaMetricsProviderTest() override { base::RunLoop().RunUntilIdle(); }
- void Initialize(bool is_mse, bool is_top_frame, const std::string& origin) {
- MediaMetricsProvider::Create(VideoDecodePerfHistory::SaveCallback(),
- mojo::MakeRequest(&provider_));
- provider_->Initialize(is_mse, is_top_frame,
- url::Origin::Create(GURL(origin)));
+ void Initialize(bool is_mse,
+ bool is_top_frame,
+ const std::string& origin,
+ mojom::MediaURLScheme scheme) {
+ source_id_ = test_recorder_->GetNewSourceID();
+ test_recorder_->UpdateSourceURL(source_id_, GURL(origin));
+
+ MediaMetricsProvider::Create(
+ is_top_frame,
+ base::BindRepeating(&MediaMetricsProviderTest::GetSourceId,
+ base::Unretained(this)),
+ VideoDecodePerfHistory::SaveCallback(), mojo::MakeRequest(&provider_));
+ provider_->Initialize(is_mse, scheme);
}
+ ukm::SourceId GetSourceId() { return source_id_; }
+
void ResetMetricRecorders() {
// Ensure cleared global before attempting to create a new TestUkmReporter.
test_recorder_.reset();
@@ -45,6 +55,7 @@ class MediaMetricsProviderTest : public testing::Test {
protected:
base::TestMessageLoop message_loop_;
std::unique_ptr<ukm::TestAutoSetUkmRecorder> test_recorder_;
+ ukm::SourceId source_id_;
mojom::MediaMetricsProviderPtr provider_;
DISALLOW_COPY_AND_ASSIGN(MediaMetricsProviderTest);
@@ -58,7 +69,7 @@ class MediaMetricsProviderTest : public testing::Test {
EXPECT_TRUE(test_recorder_->EntryHasMetric(entry, name));
TEST_F(MediaMetricsProviderTest, TestUkm) {
- Initialize(true, true, kTestOrigin);
+ Initialize(true, true, kTestOrigin, mojom::MediaURLScheme::kHttp);
provider_.reset();
base::RunLoop().RunUntilIdle();
@@ -74,6 +85,12 @@ TEST_F(MediaMetricsProviderTest, TestUkm) {
EXPECT_UKM(UkmEntry::kIsMSEName, true);
EXPECT_UKM(UkmEntry::kFinalPipelineStatusName, PIPELINE_OK);
+ // This is an MSE playback so the URL scheme should not be set.
+ EXPECT_NO_UKM(UkmEntry::kURLSchemeName);
+
+ // This is an MSE playback so no container is available.
+ EXPECT_NO_UKM(UkmEntry::kContainerNameName);
+
EXPECT_NO_UKM(UkmEntry::kTimeToMetadataName);
EXPECT_NO_UKM(UkmEntry::kTimeToFirstFrameName);
EXPECT_NO_UKM(UkmEntry::kTimeToPlayReadyName);
@@ -87,11 +104,12 @@ TEST_F(MediaMetricsProviderTest, TestUkm) {
const base::TimeDelta kPlayReadyTime = base::TimeDelta::FromSeconds(3);
ResetMetricRecorders();
- Initialize(false, false, kTestOrigin2);
+ Initialize(false, false, kTestOrigin2, mojom::MediaURLScheme::kHttps);
provider_->SetIsEME();
provider_->SetTimeToMetadata(kMetadataTime);
provider_->SetTimeToFirstFrame(kFirstFrameTime);
provider_->SetTimeToPlayReady(kPlayReadyTime);
+ provider_->SetContainerName(container_names::CONTAINER_MOV);
provider_->OnError(PIPELINE_ERROR_DECODE);
provider_.reset();
base::RunLoop().RunUntilIdle();
@@ -106,12 +124,15 @@ TEST_F(MediaMetricsProviderTest, TestUkm) {
EXPECT_UKM(UkmEntry::kIsTopFrameName, false);
EXPECT_UKM(UkmEntry::kIsEMEName, true);
EXPECT_UKM(UkmEntry::kIsMSEName, false);
+ EXPECT_UKM(UkmEntry::kURLSchemeName,
+ static_cast<int64_t>(mojom::MediaURLScheme::kHttps));
EXPECT_UKM(UkmEntry::kFinalPipelineStatusName, PIPELINE_ERROR_DECODE);
EXPECT_UKM(UkmEntry::kTimeToMetadataName, kMetadataTime.InMilliseconds());
EXPECT_UKM(UkmEntry::kTimeToFirstFrameName,
kFirstFrameTime.InMilliseconds());
EXPECT_UKM(UkmEntry::kTimeToPlayReadyName,
kPlayReadyTime.InMilliseconds());
+ EXPECT_UKM(UkmEntry::kContainerNameName, container_names::CONTAINER_MOV);
}
}
}
diff --git a/chromium/media/mojo/services/media_service_unittest.cc b/chromium/media/mojo/services/media_service_unittest.cc
index 4897ac8790c..fd341a42e9e 100644
--- a/chromium/media/mojo/services/media_service_unittest.cc
+++ b/chromium/media/mojo/services/media_service_unittest.cc
@@ -11,7 +11,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/run_loop.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "build/build_config.h"
#include "media/base/cdm_config.h"
#include "media/base/mock_filters.h"
diff --git a/chromium/media/mojo/services/mojo_audio_output_stream_provider.cc b/chromium/media/mojo/services/mojo_audio_output_stream_provider.cc
index 1a661e8099b..fb15f4cca46 100644
--- a/chromium/media/mojo/services/mojo_audio_output_stream_provider.cc
+++ b/chromium/media/mojo/services/mojo_audio_output_stream_provider.cc
@@ -36,8 +36,12 @@ MojoAudioOutputStreamProvider::~MojoAudioOutputStreamProvider() {
void MojoAudioOutputStreamProvider::Acquire(
const AudioParameters& params,
- mojom::AudioOutputStreamProviderClientPtr provider_client) {
+ mojom::AudioOutputStreamProviderClientPtr provider_client,
+ const base::Optional<base::UnguessableToken>& processing_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+// |processing_id| gets dropped here. It's not supported outside of the audio
+// service. As this class is slated for removal, it will not be updated to
+// support audio processing.
#if !defined(OS_ANDROID)
if (params.IsBitstreamFormat()) {
// Bitstream streams are only supported on Android.
diff --git a/chromium/media/mojo/services/mojo_audio_output_stream_provider.h b/chromium/media/mojo/services/mojo_audio_output_stream_provider.h
index 0d580f31b98..f3053bbc62e 100644
--- a/chromium/media/mojo/services/mojo_audio_output_stream_provider.h
+++ b/chromium/media/mojo/services/mojo_audio_output_stream_provider.h
@@ -44,7 +44,8 @@ class MEDIA_MOJO_EXPORT MojoAudioOutputStreamProvider
// mojom::AudioOutputStreamProvider implementation.
void Acquire(
const AudioParameters& params,
- mojom::AudioOutputStreamProviderClientPtr provider_client) override;
+ mojom::AudioOutputStreamProviderClientPtr provider_client,
+ const base::Optional<base::UnguessableToken>& processing_id) override;
// Called when |audio_output_| had an error.
void CleanUp(bool had_error);
diff --git a/chromium/media/mojo/services/mojo_audio_output_stream_provider_unittest.cc b/chromium/media/mojo/services/mojo_audio_output_stream_provider_unittest.cc
index c0e1dfe0f85..58e43c37620 100644
--- a/chromium/media/mojo/services/mojo_audio_output_stream_provider_unittest.cc
+++ b/chromium/media/mojo/services/mojo_audio_output_stream_provider_unittest.cc
@@ -84,12 +84,12 @@ TEST(MojoAudioOutputStreamProviderTest, AcquireTwice_BadMessage) {
mojom::AudioOutputStreamProviderClientPtr client_1;
mojo::MakeRequest(&client_1);
provider_ptr->Acquire(media::AudioParameters::UnavailableDeviceParams(),
- std::move(client_1));
+ std::move(client_1), base::nullopt);
mojom::AudioOutputStreamProviderClientPtr client_2;
mojo::MakeRequest(&client_2);
provider_ptr->Acquire(media::AudioParameters::UnavailableDeviceParams(),
- std::move(client_2));
+ std::move(client_2), base::nullopt);
EXPECT_CALL(deleter, Run(provider)).WillOnce(DeleteArg<0>());
base::RunLoop().RunUntilIdle();
@@ -121,7 +121,7 @@ TEST(MojoAudioOutputStreamProviderTest,
mojom::AudioOutputStreamProviderClientPtr client;
mojo::MakeRequest(&client);
- provider_ptr->Acquire(params, std::move(client));
+ provider_ptr->Acquire(params, std::move(client), base::nullopt);
#if defined(OS_ANDROID)
base::RunLoop().RunUntilIdle();
diff --git a/chromium/media/mojo/services/mojo_cdm_file_io.cc b/chromium/media/mojo/services/mojo_cdm_file_io.cc
index b3a845d3f6a..d5df66083ce 100644
--- a/chromium/media/mojo/services/mojo_cdm_file_io.cc
+++ b/chromium/media/mojo/services/mojo_cdm_file_io.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/metrics/histogram_macros.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
diff --git a/chromium/media/mojo/services/mojo_cdm_service.cc b/chromium/media/mojo/services/mojo_cdm_service.cc
index 31bb3e7fa5e..e7095d2a6c2 100644
--- a/chromium/media/mojo/services/mojo_cdm_service.cc
+++ b/chromium/media/mojo/services/mojo_cdm_service.cc
@@ -53,8 +53,9 @@ MojoCdmService::~MojoCdmService() {
context_->UnregisterCdm(cdm_id_);
}
-void MojoCdmService::SetClient(mojom::ContentDecryptionModuleClientPtr client) {
- client_ = std::move(client);
+void MojoCdmService::SetClient(
+ mojom::ContentDecryptionModuleClientAssociatedPtrInfo client) {
+ client_.Bind(std::move(client));
}
void MojoCdmService::Initialize(const std::string& key_system,
diff --git a/chromium/media/mojo/services/mojo_cdm_service.h b/chromium/media/mojo/services/mojo_cdm_service.h
index 716620b9e6c..b8308cc92b7 100644
--- a/chromium/media/mojo/services/mojo_cdm_service.h
+++ b/chromium/media/mojo/services/mojo_cdm_service.h
@@ -52,7 +52,8 @@ class MEDIA_MOJO_EXPORT MojoCdmService : public mojom::ContentDecryptionModule {
~MojoCdmService() final;
// mojom::ContentDecryptionModule implementation.
- void SetClient(mojom::ContentDecryptionModuleClientPtr client) final;
+ void SetClient(
+ mojom::ContentDecryptionModuleClientAssociatedPtrInfo client) final;
void Initialize(const std::string& key_system,
const url::Origin& security_origin,
const CdmConfig& cdm_config,
@@ -112,7 +113,7 @@ class MEDIA_MOJO_EXPORT MojoCdmService : public mojom::ContentDecryptionModule {
// Set to a valid CDM ID if the |cdm_| is successfully created.
int cdm_id_;
- mojom::ContentDecryptionModuleClientPtr client_;
+ mojom::ContentDecryptionModuleClientAssociatedPtr client_;
base::WeakPtr<MojoCdmService> weak_this_;
base::WeakPtrFactory<MojoCdmService> weak_factory_;
diff --git a/chromium/media/mojo/services/mojo_media_log.cc b/chromium/media/mojo/services/mojo_media_log.cc
index 3d14f274928..2593f137509 100644
--- a/chromium/media/mojo/services/mojo_media_log.cc
+++ b/chromium/media/mojo/services/mojo_media_log.cc
@@ -20,9 +20,13 @@ MojoMediaLog::MojoMediaLog(mojom::MediaLogAssociatedPtrInfo remote_media_log,
MojoMediaLog::~MojoMediaLog() {
DVLOG(1) << __func__;
+ // Note that we're not invalidating the remote side. We're only invalidating
+ // anything that was cloned from us. Effectively, we're a log that just
+ // happens to operate via mojo.
+ InvalidateLog();
}
-void MojoMediaLog::AddEvent(std::unique_ptr<MediaLogEvent> event) {
+void MojoMediaLog::AddEventLocked(std::unique_ptr<MediaLogEvent> event) {
DVLOG(1) << __func__;
DCHECK(event);
@@ -37,12 +41,7 @@ void MojoMediaLog::AddEvent(std::unique_ptr<MediaLogEvent> event) {
return;
}
- // From other threads, it's okay to post without worrying about losing a
- // message. This is because any message that's causally related to the object
- // (and thus MediaLog) being destroyed hopefully posts the result back to the
- // same sequence as |task_runner_| after we do. Of course, async destruction
- // (e.g., the renderer destroys a MojoVideoDecoder) can still lose messages,
- // but that's really a race.
+ // From other threads, we have little choice.
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&MojoMediaLog::AddEvent, weak_this_, std::move(event)));
diff --git a/chromium/media/mojo/services/mojo_media_log.h b/chromium/media/mojo/services/mojo_media_log.h
index ee9347bbd3c..4fd13a6f625 100644
--- a/chromium/media/mojo/services/mojo_media_log.h
+++ b/chromium/media/mojo/services/mojo_media_log.h
@@ -16,6 +16,7 @@
namespace media {
+// Client side for a MediaLog via mojo.
class MojoMediaLog final : public MediaLog {
public:
// TODO(sandersd): Template on Ptr type to support non-associated.
@@ -23,9 +24,10 @@ class MojoMediaLog final : public MediaLog {
scoped_refptr<base::SequencedTaskRunner> task_runner);
~MojoMediaLog() final;
+ protected:
// MediaLog implementation. May be called from any thread, but will only
// use |remote_media_log_| on |task_runner_|.
- void AddEvent(std::unique_ptr<MediaLogEvent> event) override;
+ void AddEventLocked(std::unique_ptr<MediaLogEvent> event) override;
private:
mojom::MediaLogAssociatedPtr remote_media_log_;
diff --git a/chromium/media/mojo/services/mojo_video_encode_accelerator_service.cc b/chromium/media/mojo/services/mojo_video_encode_accelerator_service.cc
index ba9174585e0..edc143e46be 100644
--- a/chromium/media/mojo/services/mojo_video_encode_accelerator_service.cc
+++ b/chromium/media/mojo/services/mojo_video_encode_accelerator_service.cc
@@ -44,20 +44,14 @@ MojoVideoEncodeAcceleratorService::~MojoVideoEncodeAcceleratorService() {
}
void MojoVideoEncodeAcceleratorService::Initialize(
- VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
+ const media::VideoEncodeAccelerator::Config& config,
mojom::VideoEncodeAcceleratorClientPtr client,
InitializeCallback success_callback) {
- DVLOG(1) << __func__
- << " input_format=" << VideoPixelFormatToString(input_format)
- << ", input_visible_size=" << input_visible_size.ToString()
- << ", output_profile=" << GetProfileName(output_profile)
- << ", initial_bitrate=" << initial_bitrate;
+ DVLOG(1) << __func__ << " " << config.AsHumanReadableString();
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!encoder_);
- DCHECK_EQ(PIXEL_FORMAT_I420, input_format) << "Only I420 format supported";
+ DCHECK_EQ(PIXEL_FORMAT_I420, config.input_format)
+ << "Only I420 format supported";
if (!client) {
DLOG(ERROR) << __func__ << "null |client|";
@@ -66,18 +60,16 @@ void MojoVideoEncodeAcceleratorService::Initialize(
}
vea_client_ = std::move(client);
- if (input_visible_size.width() > limits::kMaxDimension ||
- input_visible_size.height() > limits::kMaxDimension ||
- input_visible_size.GetArea() > limits::kMaxCanvas) {
+ if (config.input_visible_size.width() > limits::kMaxDimension ||
+ config.input_visible_size.height() > limits::kMaxDimension ||
+ config.input_visible_size.GetArea() > limits::kMaxCanvas) {
DLOG(ERROR) << __func__ << "too large input_visible_size "
- << input_visible_size.ToString();
+ << config.input_visible_size.ToString();
std::move(success_callback).Run(false);
return;
}
- encoder_ =
- create_vea_callback_.Run(input_format, input_visible_size, output_profile,
- initial_bitrate, this, gpu_preferences_);
+ encoder_ = create_vea_callback_.Run(config, this, gpu_preferences_);
if (!encoder_) {
DLOG(ERROR) << __func__ << " Error creating or initializing VEA";
std::move(success_callback).Run(false);
diff --git a/chromium/media/mojo/services/mojo_video_encode_accelerator_service.h b/chromium/media/mojo/services/mojo_video_encode_accelerator_service.h
index 0efdae6eee3..97342d01553 100644
--- a/chromium/media/mojo/services/mojo_video_encode_accelerator_service.h
+++ b/chromium/media/mojo/services/mojo_video_encode_accelerator_service.h
@@ -33,10 +33,7 @@ class MEDIA_MOJO_EXPORT MojoVideoEncodeAcceleratorService
// Create and initialize a VEA. Returns nullptr if either part fails.
using CreateAndInitializeVideoEncodeAcceleratorCallback =
base::Callback<std::unique_ptr<::media::VideoEncodeAccelerator>(
- VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
+ const ::media::VideoEncodeAccelerator::Config& config,
Client* client,
const gpu::GpuPreferences& gpu_preferences)>;
@@ -52,10 +49,7 @@ class MEDIA_MOJO_EXPORT MojoVideoEncodeAcceleratorService
~MojoVideoEncodeAcceleratorService() override;
// mojom::VideoEncodeAccelerator impl.
- void Initialize(VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
+ void Initialize(const media::VideoEncodeAccelerator::Config& config,
mojom::VideoEncodeAcceleratorClientPtr client,
InitializeCallback callback) override;
void Encode(const scoped_refptr<VideoFrame>& frame,
diff --git a/chromium/media/mojo/services/mojo_video_encode_accelerator_service_unittest.cc b/chromium/media/mojo/services/mojo_video_encode_accelerator_service_unittest.cc
index ffd09434753..54979aa6eeb 100644
--- a/chromium/media/mojo/services/mojo_video_encode_accelerator_service_unittest.cc
+++ b/chromium/media/mojo/services/mojo_video_encode_accelerator_service_unittest.cc
@@ -27,18 +27,14 @@ static const gfx::Size kInputVisibleSize(64, 48);
std::unique_ptr<VideoEncodeAccelerator> CreateAndInitializeFakeVEA(
bool will_initialization_succeed,
- VideoPixelFormat input_format,
- const gfx::Size& input_visible_size,
- VideoCodecProfile output_profile,
- uint32_t initial_bitrate,
+ const VideoEncodeAccelerator::Config& config,
VideoEncodeAccelerator::Client* client,
const gpu::GpuPreferences& gpu_preferences) {
// Use FakeVEA as scoped_ptr to guarantee proper destruction via Destroy().
auto vea = std::make_unique<FakeVideoEncodeAccelerator>(
base::ThreadTaskRunnerHandle::Get());
vea->SetWillInitializationSucceed(will_initialization_succeed);
- const bool result = vea->Initialize(input_format, input_visible_size,
- output_profile, initial_bitrate, client);
+ const bool result = vea->Initialize(config, client);
// Mimic the behaviour of GpuVideoEncodeAcceleratorFactory::CreateVEA().
return result ? base::WrapUnique<VideoEncodeAccelerator>(vea.release())
@@ -99,9 +95,10 @@ class MojoVideoEncodeAcceleratorServiceTest : public ::testing::Test {
RequireBitstreamBuffers(_, kInputVisibleSize, _));
const uint32_t kInitialBitrate = 100000u;
+ const media::VideoEncodeAccelerator::Config config(
+ PIXEL_FORMAT_I420, kInputVisibleSize, H264PROFILE_MIN, kInitialBitrate);
mojo_vea_service()->Initialize(
- PIXEL_FORMAT_I420, kInputVisibleSize, H264PROFILE_MIN, kInitialBitrate,
- std::move(mojo_vea_client),
+ config, std::move(mojo_vea_client),
base::Bind([](bool success) { ASSERT_TRUE(success); }));
base::RunLoop().RunUntilIdle();
}
@@ -225,9 +222,10 @@ TEST_F(MojoVideoEncodeAcceleratorServiceTest,
mojom::VideoEncodeAcceleratorClientPtr invalid_mojo_vea_client = nullptr;
const uint32_t kInitialBitrate = 100000u;
+ const media::VideoEncodeAccelerator::Config config(
+ PIXEL_FORMAT_I420, kInputVisibleSize, H264PROFILE_MIN, kInitialBitrate);
mojo_vea_service()->Initialize(
- PIXEL_FORMAT_I420, kInputVisibleSize, H264PROFILE_MIN, kInitialBitrate,
- std::move(invalid_mojo_vea_client),
+ config, std::move(invalid_mojo_vea_client),
base::Bind([](bool success) { ASSERT_FALSE(success); }));
base::RunLoop().RunUntilIdle();
}
@@ -244,9 +242,10 @@ TEST_F(MojoVideoEncodeAcceleratorServiceTest, InitializeFailure) {
mojo::MakeRequest(&mojo_vea_client));
const uint32_t kInitialBitrate = 100000u;
+ const media::VideoEncodeAccelerator::Config config(
+ PIXEL_FORMAT_I420, kInputVisibleSize, H264PROFILE_MIN, kInitialBitrate);
mojo_vea_service()->Initialize(
- PIXEL_FORMAT_I420, kInputVisibleSize, H264PROFILE_MIN, kInitialBitrate,
- std::move(mojo_vea_client),
+ config, std::move(mojo_vea_client),
base::Bind([](bool success) { ASSERT_FALSE(success); }));
base::RunLoop().RunUntilIdle();
diff --git a/chromium/media/mojo/services/test_mojo_media_client.cc b/chromium/media/mojo/services/test_mojo_media_client.cc
index 144c0b2d67d..eb52ec0130e 100644
--- a/chromium/media/mojo/services/test_mojo_media_client.cc
+++ b/chromium/media/mojo/services/test_mojo_media_client.cc
@@ -20,7 +20,6 @@
#include "media/cdm/default_cdm_factory.h"
#include "media/renderers/default_decoder_factory.h"
#include "media/renderers/default_renderer_factory.h"
-#include "media/video/gpu_video_accelerator_factories.h"
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
#include "media/cdm/cdm_paths.h" // nogncheck
diff --git a/chromium/media/mojo/services/video_decode_perf_history.cc b/chromium/media/mojo/services/video_decode_perf_history.cc
index 3ee0ae8d1f2..37807f02907 100644
--- a/chromium/media/mojo/services/video_decode_perf_history.cc
+++ b/chromium/media/mojo/services/video_decode_perf_history.cc
@@ -175,13 +175,12 @@ VideoDecodePerfHistory::SaveCallback VideoDecodePerfHistory::GetSaveCallback() {
weak_ptr_factory_.GetWeakPtr());
}
-void VideoDecodePerfHistory::SavePerfRecord(
- const url::Origin& untrusted_top_frame_origin,
- bool is_top_frame,
- mojom::PredictionFeatures features,
- mojom::PredictionTargets targets,
- uint64_t player_id,
- base::OnceClosure save_done_cb) {
+void VideoDecodePerfHistory::SavePerfRecord(ukm::SourceId source_id,
+ bool is_top_frame,
+ mojom::PredictionFeatures features,
+ mojom::PredictionTargets targets,
+ uint64_t player_id,
+ base::OnceClosure save_done_cb) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DVLOG(3) << __func__
<< base::StringPrintf(
@@ -200,8 +199,8 @@ void VideoDecodePerfHistory::SavePerfRecord(
if (db_init_status_ != COMPLETE) {
init_deferred_api_calls_.push_back(base::BindOnce(
&VideoDecodePerfHistory::SavePerfRecord, weak_ptr_factory_.GetWeakPtr(),
- untrusted_top_frame_origin, is_top_frame, std::move(features),
- std::move(targets), player_id, std::move(save_done_cb)));
+ source_id, is_top_frame, std::move(features), std::move(targets),
+ player_id, std::move(save_done_cb)));
InitDatabase();
return;
}
@@ -217,13 +216,12 @@ void VideoDecodePerfHistory::SavePerfRecord(
db_->GetDecodeStats(
video_key,
base::BindOnce(&VideoDecodePerfHistory::OnGotStatsForSave,
- weak_ptr_factory_.GetWeakPtr(), untrusted_top_frame_origin,
- is_top_frame, player_id, video_key, new_stats,
- std::move(save_done_cb)));
+ weak_ptr_factory_.GetWeakPtr(), source_id, is_top_frame,
+ player_id, video_key, new_stats, std::move(save_done_cb)));
}
void VideoDecodePerfHistory::OnGotStatsForSave(
- const url::Origin& untrusted_top_frame_origin,
+ ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id,
const VideoDecodeStatsDB::VideoDescKey& video_key,
@@ -240,8 +238,8 @@ void VideoDecodePerfHistory::OnGotStatsForSave(
return;
}
- ReportUkmMetrics(untrusted_top_frame_origin, is_top_frame, player_id,
- video_key, new_stats, past_stats.get());
+ ReportUkmMetrics(source_id, is_top_frame, player_id, video_key, new_stats,
+ past_stats.get());
// TODO(dalecurtis): Abort stats recording if db_ is in read-only mode.
@@ -267,7 +265,7 @@ void VideoDecodePerfHistory::OnSaveDone(base::OnceClosure save_done_cb,
}
void VideoDecodePerfHistory::ReportUkmMetrics(
- const url::Origin& untrusted_top_frame_origin,
+ ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id,
const VideoDecodeStatsDB::VideoDescKey& video_key,
@@ -282,11 +280,7 @@ void VideoDecodePerfHistory::ReportUkmMetrics(
if (!ukm_recorder)
return;
- const int32_t source_id = ukm_recorder->GetNewSourceID();
ukm::builders::Media_VideoDecodePerfRecord builder(source_id);
-
- // TODO(crbug.com/787209): Stop getting origin from the renderer.
- ukm_recorder->UpdateSourceURL(source_id, untrusted_top_frame_origin.GetURL());
builder.SetVideo_InTopFrame(is_top_frame);
builder.SetVideo_PlayerID(player_id);
diff --git a/chromium/media/mojo/services/video_decode_perf_history.h b/chromium/media/mojo/services/video_decode_perf_history.h
index 5ec8691dce4..565989ea347 100644
--- a/chromium/media/mojo/services/video_decode_perf_history.h
+++ b/chromium/media/mojo/services/video_decode_perf_history.h
@@ -19,8 +19,8 @@
#include "media/mojo/interfaces/video_decode_perf_history.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/bindings/binding_set.h"
+#include "services/metrics/public/cpp/ukm_source_id.h"
#include "ui/gfx/geometry/size.h"
-#include "url/origin.h"
namespace media {
@@ -65,13 +65,13 @@ class MEDIA_MOJO_EXPORT VideoDecodePerfHistory
// This callback will silently fail if called after |this| is destroyed.
// Saving is generally fire-and-forget, but |save_done_cb| may be provided
// for tests to know the save is complete.
- using SaveCallback = base::RepeatingCallback<void(
- const url::Origin& untrusted_top_frame_origin,
- bool is_top_frame,
- mojom::PredictionFeatures features,
- mojom::PredictionTargets targets,
- uint64_t player_id,
- base::OnceClosure save_done_cb)>;
+ using SaveCallback =
+ base::RepeatingCallback<void(ukm::SourceId source_id,
+ bool is_top_frame,
+ mojom::PredictionFeatures features,
+ mojom::PredictionTargets targets,
+ uint64_t player_id,
+ base::OnceClosure save_done_cb)>;
SaveCallback GetSaveCallback();
// Clear all history from the underlying database. Run |clear_done_cb| when
@@ -111,7 +111,7 @@ class MEDIA_MOJO_EXPORT VideoDecodePerfHistory
void OnDatabaseInit(bool success);
// Initiate saving of the provided record. See GetSaveCallback().
- void SavePerfRecord(const url::Origin& untrusted_top_frame_origin,
+ void SavePerfRecord(ukm::SourceId source_id,
bool is_top_frame,
mojom::PredictionFeatures features,
mojom::PredictionTargets targets,
@@ -132,7 +132,7 @@ class MEDIA_MOJO_EXPORT VideoDecodePerfHistory
// of the GetPerfInfo() API. Comparison is recorded via UKM. Then saves the
// |new_*| performance stats to the database.
void OnGotStatsForSave(
- const url::Origin& top_frame_origin,
+ ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id,
const VideoDecodeStatsDB::VideoDescKey& video_key,
@@ -147,7 +147,7 @@ class MEDIA_MOJO_EXPORT VideoDecodePerfHistory
// Report UKM metrics to grade the claims of the API by evaluating how well
// |past_stats| predicts |new_stats|.
- void ReportUkmMetrics(const url::Origin& top_frame_origin,
+ void ReportUkmMetrics(ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id,
const VideoDecodeStatsDB::VideoDescKey& video_key,
diff --git a/chromium/media/mojo/services/video_decode_perf_history_unittest.cc b/chromium/media/mojo/services/video_decode_perf_history_unittest.cc
index f0b7f728c2d..b4a6f3ec006 100644
--- a/chromium/media/mojo/services/video_decode_perf_history_unittest.cc
+++ b/chromium/media/mojo/services/video_decode_perf_history_unittest.cc
@@ -8,7 +8,7 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
-#include "base/task_scheduler/post_task.h"
+#include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_task_environment.h"
#include "components/ukm/test_ukm_recorder.h"
@@ -193,7 +193,7 @@ class VideoDecodePerfHistoryTest : public testing::Test {
return targets;
}
- void SavePerfRecord(const url::Origin& untrusted_top_frame_origin,
+ void SavePerfRecord(const url::Origin& origin,
bool is_top_frame,
mojom::PredictionFeatures features,
mojom::PredictionTargets targets,
@@ -202,9 +202,12 @@ class VideoDecodePerfHistoryTest : public testing::Test {
// save completes.
base::OnceClosure save_done_cb;
- perf_history_->GetSaveCallback().Run(untrusted_top_frame_origin,
- is_top_frame, features, targets,
- player_id, std::move(save_done_cb));
+ const ukm::SourceId source_id = test_recorder_->GetNewSourceID();
+ test_recorder_->UpdateSourceURL(source_id, origin.GetURL());
+
+ perf_history_->GetSaveCallback().Run(source_id, is_top_frame, features,
+ targets, player_id,
+ std::move(save_done_cb));
}
protected:
diff --git a/chromium/media/mojo/services/video_decode_stats_recorder.cc b/chromium/media/mojo/services/video_decode_stats_recorder.cc
index 46f12e729c5..ca1348f4cc2 100644
--- a/chromium/media/mojo/services/video_decode_stats_recorder.cc
+++ b/chromium/media/mojo/services/video_decode_stats_recorder.cc
@@ -12,21 +12,15 @@
namespace media {
VideoDecodeStatsRecorder::VideoDecodeStatsRecorder(
- const url::Origin& untrusted_top_frame_origin,
+ VideoDecodePerfHistory::SaveCallback save_cb,
+ ukm::SourceId source_id,
bool is_top_frame,
- uint64_t player_id,
- VideoDecodePerfHistory::SaveCallback save_cb)
- : untrusted_top_frame_origin_(untrusted_top_frame_origin),
+ uint64_t player_id)
+ : save_cb_(std::move(save_cb)),
+ source_id_(source_id),
is_top_frame_(is_top_frame),
- save_cb_(std::move(save_cb)),
player_id_(player_id) {
- // Only bother to make the recorder when able to save stats. Checking here
- // instead of silently failing below.
- CHECK(!save_cb_.is_null());
-
- DVLOG(2) << __func__
- << " untrusted_top_frame_origin:" << untrusted_top_frame_origin
- << " is_top_frame:" << is_top_frame;
+ DCHECK(save_cb_);
}
VideoDecodeStatsRecorder::~VideoDecodeStatsRecorder() {
@@ -85,8 +79,8 @@ void VideoDecodeStatsRecorder::FinalizeRecord() {
// Final argument is an empty save-done-callback. No action to take if save
// fails (DB already records UMAs on failure). Callback mainly used by tests.
- save_cb_.Run(untrusted_top_frame_origin_, is_top_frame_, features_, targets_,
- player_id_, base::OnceClosure());
+ save_cb_.Run(source_id_, is_top_frame_, features_, targets_, player_id_,
+ base::OnceClosure());
}
} // namespace media
diff --git a/chromium/media/mojo/services/video_decode_stats_recorder.h b/chromium/media/mojo/services/video_decode_stats_recorder.h
index e432d4cb48c..149c19029da 100644
--- a/chromium/media/mojo/services/video_decode_stats_recorder.h
+++ b/chromium/media/mojo/services/video_decode_stats_recorder.h
@@ -25,10 +25,10 @@ class MEDIA_MOJO_EXPORT VideoDecodeStatsRecorder
// |perf_history| required to save decode stats to local database and report
// metrics. Callers must ensure that |perf_history| outlives this object; may
// be nullptr if database recording is currently disabled.
- VideoDecodeStatsRecorder(const url::Origin& untrusted_top_frame_origin,
+ VideoDecodeStatsRecorder(VideoDecodePerfHistory::SaveCallback save_cb,
+ ukm::SourceId source_id,
bool is_top_frame,
- uint64_t player_id,
- VideoDecodePerfHistory::SaveCallback save_cb);
+ uint64_t player_id);
~VideoDecodeStatsRecorder() override;
// mojom::VideoDecodeStatsRecorder implementation:
@@ -40,9 +40,9 @@ class MEDIA_MOJO_EXPORT VideoDecodeStatsRecorder
// starting a new record.
void FinalizeRecord();
- const url::Origin untrusted_top_frame_origin_;
- const bool is_top_frame_;
const VideoDecodePerfHistory::SaveCallback save_cb_;
+ const ukm::SourceId source_id_;
+ const bool is_top_frame_;
const uint64_t player_id_;
mojom::PredictionFeatures features_;
diff --git a/chromium/media/mojo/services/watch_time_recorder.cc b/chromium/media/mojo/services/watch_time_recorder.cc
index de615f91cfa..6f35e9fb196 100644
--- a/chromium/media/mojo/services/watch_time_recorder.cc
+++ b/chromium/media/mojo/services/watch_time_recorder.cc
@@ -126,11 +126,11 @@ WatchTimeRecorder::WatchTimeUkmRecord::WatchTimeUkmRecord(
WatchTimeRecorder::WatchTimeUkmRecord::~WatchTimeUkmRecord() = default;
WatchTimeRecorder::WatchTimeRecorder(mojom::PlaybackPropertiesPtr properties,
- const url::Origin& untrusted_top_origin,
+ ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id)
: properties_(std::move(properties)),
- untrusted_top_origin_(untrusted_top_origin),
+ source_id_(source_id),
is_top_frame_(is_top_frame),
player_id_(player_id),
extended_metrics_keys_(
@@ -344,11 +344,7 @@ void WatchTimeRecorder::RecordUkmPlaybackData() {
}
for (auto& ukm_record : ukm_records_) {
- const int32_t source_id = ukm_recorder->GetNewSourceID();
-
- // TODO(crbug.com/787209): Stop getting origin from the renderer.
- ukm_recorder->UpdateSourceURL(source_id, untrusted_top_origin_.GetURL());
- ukm::builders::Media_BasicPlayback builder(source_id);
+ ukm::builders::Media_BasicPlayback builder(source_id_);
builder.SetIsTopFrame(is_top_frame_);
builder.SetIsBackground(properties_->is_background);
diff --git a/chromium/media/mojo/services/watch_time_recorder.h b/chromium/media/mojo/services/watch_time_recorder.h
index 95d7f067c23..7d72beaeaee 100644
--- a/chromium/media/mojo/services/watch_time_recorder.h
+++ b/chromium/media/mojo/services/watch_time_recorder.h
@@ -16,7 +16,7 @@
#include "media/base/video_codecs.h"
#include "media/mojo/interfaces/watch_time_recorder.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
-#include "url/origin.h"
+#include "services/metrics/public/cpp/ukm_source_id.h"
namespace media {
@@ -24,7 +24,7 @@ namespace media {
class MEDIA_MOJO_EXPORT WatchTimeRecorder : public mojom::WatchTimeRecorder {
public:
WatchTimeRecorder(mojom::PlaybackPropertiesPtr properties,
- const url::Origin& untrusted_top_origin,
+ ukm::SourceId source_id,
bool is_top_frame,
uint64_t player_id);
~WatchTimeRecorder() override;
@@ -48,10 +48,9 @@ class MEDIA_MOJO_EXPORT WatchTimeRecorder : public mojom::WatchTimeRecorder {
const mojom::PlaybackPropertiesPtr properties_;
- // For privacy, only record the top origin. "Untrusted" signals that this
- // value comes from the renderer and should not be used for security checks.
- // TODO(crbug.com/787209): Stop getting origin from the renderer.
- const url::Origin untrusted_top_origin_;
+ const ukm::SourceId source_id_;
+
+ // Are UKM reports for the main frame or for a subframe?
const bool is_top_frame_;
// The provider ID which constructed this recorder. Used to record a UKM entry
diff --git a/chromium/media/mojo/services/watch_time_recorder_unittest.cc b/chromium/media/mojo/services/watch_time_recorder_unittest.cc
index 560e47db194..796505d9b08 100644
--- a/chromium/media/mojo/services/watch_time_recorder_unittest.cc
+++ b/chromium/media/mojo/services/watch_time_recorder_unittest.cc
@@ -51,16 +51,21 @@ class WatchTimeRecorderTest : public testing::Test {
kDiscardedWatchTimeAudioVideoSrc,
kDiscardedWatchTimeAudioVideoMse,
kDiscardedWatchTimeAudioVideoEme}) {
+ source_id_ = test_recorder_->GetNewSourceID();
ResetMetricRecorders();
- MediaMetricsProvider::Create(VideoDecodePerfHistory::SaveCallback(),
- mojo::MakeRequest(&provider_));
+ MediaMetricsProvider::Create(
+ true /* is_top_frame */,
+ base::BindRepeating(&WatchTimeRecorderTest::GetSourceId,
+ base::Unretained(this)),
+ VideoDecodePerfHistory::SaveCallback(), mojo::MakeRequest(&provider_));
}
~WatchTimeRecorderTest() override { base::RunLoop().RunUntilIdle(); }
void Initialize(mojom::PlaybackPropertiesPtr properties) {
- provider_->Initialize(properties->is_mse, true /* is_top_frame */,
- url::Origin::Create(GURL(kTestOrigin)));
+ provider_->Initialize(properties->is_mse,
+ properties->is_mse ? mojom::MediaURLScheme::kUnknown
+ : mojom::MediaURLScheme::kHttp);
provider_->AcquireWatchTimeRecorder(std::move(properties),
mojo::MakeRequest(&wtr_));
}
@@ -117,7 +122,8 @@ class WatchTimeRecorderTest : public testing::Test {
}
void ExpectNoUkmWatchTime() {
- ASSERT_EQ(0u, test_recorder_->sources_count());
+ // We always add a source in testing.
+ ASSERT_EQ(1u, test_recorder_->sources_count());
ASSERT_EQ(0u, test_recorder_->entries_count());
}
@@ -140,8 +146,11 @@ class WatchTimeRecorderTest : public testing::Test {
// Ensure cleared global before attempting to create a new TestUkmReporter.
test_recorder_.reset();
test_recorder_.reset(new ukm::TestAutoSetUkmRecorder());
+ test_recorder_->UpdateSourceURL(source_id_, GURL(kTestOrigin));
}
+ ukm::SourceId GetSourceId() { return source_id_; }
+
MOCK_METHOD0(GetCurrentMediaTime, base::TimeDelta());
protected:
@@ -149,6 +158,7 @@ class WatchTimeRecorderTest : public testing::Test {
mojom::MediaMetricsProviderPtr provider_;
std::unique_ptr<base::HistogramTester> histogram_tester_;
std::unique_ptr<ukm::TestAutoSetUkmRecorder> test_recorder_;
+ ukm::SourceId source_id_;
mojom::WatchTimeRecorderPtr wtr_;
const std::vector<WatchTimeKey> computation_keys_;
const std::vector<base::StringPiece> mtbr_keys_;