diff options
Diffstat (limited to 'chromium/components/mirroring/service')
9 files changed, 28 insertions, 45 deletions
diff --git a/chromium/components/mirroring/service/fake_video_capture_host.cc b/chromium/components/mirroring/service/fake_video_capture_host.cc index 856b52da03e..b86e7f70d0b 100644 --- a/chromium/components/mirroring/service/fake_video_capture_host.cc +++ b/chromium/components/mirroring/service/fake_video_capture_host.cc @@ -45,14 +45,12 @@ void FakeVideoCaptureHost::SendOneFrame(const gfx::Size& size, 0, media::mojom::VideoBufferHandle::NewReadOnlyShmemRegion( std::move(shmem.region))); media::VideoFrameMetadata metadata; - metadata.SetDouble(media::VideoFrameMetadata::FRAME_RATE, 30); - metadata.SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, - capture_time); + metadata.frame_rate = 30; + metadata.reference_time = capture_time; observer_->OnBufferReady( 0, media::mojom::VideoFrameInfo::New( - base::TimeDelta(), metadata.GetInternalValues().Clone(), - media::PIXEL_FORMAT_I420, size, gfx::Rect(size), - gfx::ColorSpace::CreateREC709(), nullptr)); + base::TimeDelta(), metadata, media::PIXEL_FORMAT_I420, size, + gfx::Rect(size), gfx::ColorSpace::CreateREC709(), nullptr)); } } // namespace mirroring diff --git a/chromium/components/mirroring/service/mirror_settings.cc b/chromium/components/mirroring/service/mirror_settings.cc index 5e3df8a9af3..c5b289f8c70 100644 --- a/chromium/components/mirroring/service/mirror_settings.cc +++ b/chromium/components/mirroring/service/mirror_settings.cc @@ -8,6 +8,7 @@ #include <string> #include "base/environment.h" +#include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "media/base/audio_parameters.h" @@ -125,7 +126,7 @@ FrameSenderConfig MirrorSettings::GetDefaultVideoConfig( return config; } -void MirrorSettings::SetResolutionContraints(int max_width, int max_height) { +void MirrorSettings::SetResolutionConstraints(int max_width, int max_height) { max_width_ = std::max(max_width, min_width_); max_height_ = std::max(max_height, min_height_); } diff --git a/chromium/components/mirroring/service/mirror_settings.h b/chromium/components/mirroring/service/mirror_settings.h index 598a6b0115f..1532efd57ea 100644 --- a/chromium/components/mirroring/service/mirror_settings.h +++ b/chromium/components/mirroring/service/mirror_settings.h @@ -20,10 +20,8 @@ namespace mirroring { // Holds the default settings for a mirroring session. This class provides the // audio/video configs that this sender supports. And also provides the // audio/video constraints used for capturing. -// TODO(crbug.com/1015458): Add the function to generate the audio capture -// contraints. -// TODO(crbug.com/1015458): Add setters to the settings that might be overriden -// by integration tests. +// TODO(issuetracker.google.com/158032164): as part of migration to libcast's +// OFFER/ANSWER exchange, expose constraints here from the OFFER message. class COMPONENT_EXPORT(MIRRORING_SERVICE) MirrorSettings { public: MirrorSettings(); @@ -38,7 +36,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) MirrorSettings { media::cast::Codec codec); // Call to override the default resolution settings. - void SetResolutionContraints(int max_width, int max_height); + void SetResolutionConstraints(int max_width, int max_height); // Get video capture constraints with the current settings. media::VideoCaptureParams GetVideoCaptureParams(); @@ -58,8 +56,9 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) MirrorSettings { int max_width_; int max_height_; - // TODO(crbug.com/1002603): Disable sender-side letterboxing for Chromecast - // devices that support arbitrary aspect ratios. + // TODO(crbug.com/1002603, issuetracker.google.com/issues/158032164): provide + // this field from the aspect ratio constraint in libcast's OFFER/ANSWER + // exchange. bool enable_sender_side_letterboxing_ = true; DISALLOW_COPY_AND_ASSIGN(MirrorSettings); diff --git a/chromium/components/mirroring/service/rtp_stream.cc b/chromium/components/mirroring/service/rtp_stream.cc index b3ca6b5d754..3cf91e3338f 100644 --- a/chromium/components/mirroring/service/rtp_stream.cc +++ b/chromium/components/mirroring/service/rtp_stream.cc @@ -51,12 +51,12 @@ VideoRtpStream::~VideoRtpStream() {} void VideoRtpStream::InsertVideoFrame( scoped_refptr<media::VideoFrame> video_frame) { DCHECK(client_); - base::TimeTicks reference_time; - if (!video_frame->metadata()->GetTimeTicks( - media::VideoFrameMetadata::REFERENCE_TIME, &reference_time)) { + if (!video_frame->metadata()->reference_time.has_value()) { client_->OnError("Missing REFERENCE_TIME."); return; } + + base::TimeTicks reference_time = *video_frame->metadata()->reference_time; DCHECK(!reference_time.is_null()); if (expecting_a_refresh_frame_) { // There is uncertainty as to whether the video frame was in response to a diff --git a/chromium/components/mirroring/service/rtp_stream_unittest.cc b/chromium/components/mirroring/service/rtp_stream_unittest.cc index d8321aa78d9..739559772da 100644 --- a/chromium/components/mirroring/service/rtp_stream_unittest.cc +++ b/chromium/components/mirroring/service/rtp_stream_unittest.cc @@ -87,8 +87,7 @@ TEST_F(RtpStreamTest, VideoStreaming) { scoped_refptr<media::VideoFrame> video_frame = media::VideoFrame::CreateFrame( media::PIXEL_FORMAT_I420, size, gfx::Rect(size), size, base::TimeDelta()); media::cast::PopulateVideoFrame(video_frame.get(), 1); - video_frame->metadata()->SetTimeTicks( - media::VideoFrameMetadata::REFERENCE_TIME, testing_clock_.NowTicks()); + video_frame->metadata()->reference_time = testing_clock_.NowTicks(); auto video_sender = std::make_unique<media::cast::VideoSender>( cast_environment_, media::cast::GetDefaultVideoSenderConfig(), diff --git a/chromium/components/mirroring/service/session.cc b/chromium/components/mirroring/service/session.cc index e03493dc8c5..9d7de574c2f 100644 --- a/chromium/components/mirroring/service/session.cc +++ b/chromium/components/mirroring/service/session.cc @@ -396,8 +396,8 @@ Session::Session( base::Unretained(this))), gpu_channel_host_(nullptr) { DCHECK(resource_provider_); - mirror_settings_.SetResolutionContraints(max_resolution.width(), - max_resolution.height()); + mirror_settings_.SetResolutionConstraints(max_resolution.width(), + max_resolution.height()); resource_provider_->GetNetworkContext( network_context_.BindNewPipeAndPassReceiver()); @@ -725,7 +725,8 @@ void Session::OnAnswer(const std::vector<FrameSenderConfig>& audio_configs, audio_input_device_ = new media::AudioInputDevice( std::make_unique<CapturedAudioInput>(base::BindRepeating( &Session::CreateAudioStream, base::Unretained(this))), - media::AudioInputDevice::Purpose::kLoopback); + media::AudioInputDevice::Purpose::kLoopback, + media::AudioInputDevice::DeadStreamDetection::kEnabled); audio_input_device_->Initialize(mirror_settings_.GetAudioCaptureParams(), audio_capturing_callback_.get()); audio_input_device_->Start(); diff --git a/chromium/components/mirroring/service/udp_socket_client.h b/chromium/components/mirroring/service/udp_socket_client.h index 7248050ad44..f97b6fc902b 100644 --- a/chromium/components/mirroring/service/udp_socket_client.h +++ b/chromium/components/mirroring/service/udp_socket_client.h @@ -69,8 +69,6 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) UdpSocketClient final // Set by SendPacket() when the sending is not allowed. Once set, SendPacket() // can only be called again when a previous sending completes successfully. - // TODO(crbug.com/1015479): Change the callback to a base::OnceClosure as well - // as in the cast::PacketTransport SendPacket(). base::OnceClosure resume_send_callback_; // Total numbe of bytes written to the data pipe. diff --git a/chromium/components/mirroring/service/video_capture_client.cc b/chromium/components/mirroring/service/video_capture_client.cc index 7309064497f..738583900d5 100644 --- a/chromium/components/mirroring/service/video_capture_client.cc +++ b/chromium/components/mirroring/service/video_capture_client.cc @@ -148,12 +148,7 @@ void VideoCaptureClient::OnBufferReady(int32_t buffer_id, return; } - base::TimeTicks reference_time; - media::VideoFrameMetadata frame_metadata; - frame_metadata.MergeInternalValuesFrom(info->metadata); - const bool success = frame_metadata.GetTimeTicks( - media::VideoFrameMetadata::REFERENCE_TIME, &reference_time); - DCHECK(success); + base::TimeTicks reference_time = *info->metadata.reference_time; if (first_frame_ref_time_.is_null()) first_frame_ref_time_ = reference_time; @@ -239,7 +234,7 @@ void VideoCaptureClient::OnBufferReady(int32_t buffer_id, base::BindOnce(&VideoCaptureClient::DidFinishConsumingFrame, frame->metadata(), std::move(buffer_finished_callback))); - frame->metadata()->MergeInternalValuesFrom(info->metadata); + frame->set_metadata(info->metadata); if (info->color_space.has_value()) frame->set_color_space(info->color_space.value()); @@ -281,13 +276,8 @@ void VideoCaptureClient::DidFinishConsumingFrame( BufferFinishedCallback callback) { // Note: This function may be called on any thread by the VideoFrame // destructor. |metadata| is still valid for read-access at this point. - double consumer_resource_utilization = -1.0; - if (!metadata->GetDouble(media::VideoFrameMetadata::RESOURCE_UTILIZATION, - &consumer_resource_utilization)) { - consumer_resource_utilization = -1.0; - } DCHECK(!callback.is_null()); - std::move(callback).Run(consumer_resource_utilization); + std::move(callback).Run(metadata->resource_utilization.value_or(-1.0)); } } // namespace mirroring diff --git a/chromium/components/mirroring/service/video_capture_client_unittest.cc b/chromium/components/mirroring/service/video_capture_client_unittest.cc index 694385a4b92..2d024656f8b 100644 --- a/chromium/components/mirroring/service/video_capture_client_unittest.cc +++ b/chromium/components/mirroring/service/video_capture_client_unittest.cc @@ -28,13 +28,11 @@ constexpr double kUtilization = 0.6; media::mojom::VideoFrameInfoPtr GetVideoFrameInfo(const gfx::Size& size) { media::VideoFrameMetadata metadata; - metadata.SetDouble(media::VideoFrameMetadata::FRAME_RATE, 30); - metadata.SetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, - base::TimeTicks()); + metadata.frame_rate = 30; + metadata.reference_time = base::TimeTicks(); return media::mojom::VideoFrameInfo::New( - base::TimeDelta(), metadata.GetInternalValues().Clone(), - media::PIXEL_FORMAT_I420, size, gfx::Rect(size), - gfx::ColorSpace::CreateREC709(), nullptr); + base::TimeDelta(), metadata, media::PIXEL_FORMAT_I420, size, + gfx::Rect(size), gfx::ColorSpace::CreateREC709(), nullptr); } } // namespace @@ -63,8 +61,7 @@ class VideoCaptureClientTest : public ::testing::Test, MOCK_METHOD1(OnFrameReceived, void(const gfx::Size&)); void OnFrameReady(scoped_refptr<media::VideoFrame> video_frame) { - video_frame->metadata()->SetDouble( - media::VideoFrameMetadata::RESOURCE_UTILIZATION, kUtilization); + video_frame->metadata()->resource_utilization = kUtilization; OnFrameReceived(video_frame->coded_size()); } |