diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/peerconnection')
21 files changed, 181 insertions, 150 deletions
diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_answer_options_platform.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_answer_options_platform.h index d88a917ed73..291cecfc644 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_answer_options_platform.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_answer_options_platform.h @@ -18,7 +18,7 @@ class RTCAnswerOptionsPlatform final bool VoiceActivityDetection() const { return voice_activity_detection_; } - void Trace(Visitor* visitor) {} + void Trace(Visitor* visitor) const {} private: bool voice_activity_detection_; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_dtmf_sender_handler.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_dtmf_sender_handler.h index dd0ff33cf06..98d58c4a31b 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_dtmf_sender_handler.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_dtmf_sender_handler.h @@ -39,7 +39,7 @@ class PLATFORM_EXPORT RtcDtmfSenderHandler final { virtual ~Client() = default; virtual void DidPlayTone(const String& tone) = 0; - void Trace(Visitor* visitor) override {} + void Trace(Visitor* visitor) const override {} }; RtcDtmfSenderHandler(scoped_refptr<base::SingleThreadTaskRunner> main_thread, diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer_test.cc b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer_test.cc index 01f1af1a521..aa08e8a5772 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer_test.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_encoded_video_stream_transformer_test.cc @@ -20,8 +20,12 @@ #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/webrtc/api/frame_transformer_interface.h" +#include "third_party/webrtc/api/test/mock_transformable_video_frame.h" #include "third_party/webrtc/rtc_base/ref_counted_object.h" +using ::testing::NiceMock; +using ::testing::Return; + namespace blink { namespace { @@ -42,29 +46,11 @@ class MockTransformerCallbackHolder { void(std::unique_ptr<webrtc::TransformableVideoFrameInterface>)); }; -class FakeVideoFrame : public webrtc::TransformableVideoFrameInterface { - public: - explicit FakeVideoFrame(uint32_t ssrc) : ssrc_(ssrc) {} - - rtc::ArrayView<const uint8_t> GetData() const override { - return rtc::ArrayView<const uint8_t>(); - } - - // Copies |data| into the owned frame payload data. - void SetData(rtc::ArrayView<const uint8_t> data) override {} - uint32_t GetTimestamp() const override { return 0; } - uint32_t GetSsrc() const override { return ssrc_; } - bool IsKeyFrame() const override { return true; } - std::vector<uint8_t> GetAdditionalData() const override { - return std::vector<uint8_t>(); - } - - private: - uint32_t ssrc_; -}; - -std::unique_ptr<webrtc::TransformableVideoFrameInterface> CreateFakeFrame() { - return std::make_unique<FakeVideoFrame>(kSSRC); +std::unique_ptr<webrtc::TransformableVideoFrameInterface> CreateMockFrame() { + auto mock_frame = + std::make_unique<NiceMock<webrtc::MockTransformableVideoFrame>>(); + ON_CALL(*mock_frame.get(), GetSsrc).WillByDefault(Return(kSSRC)); + return mock_frame; } } // namespace @@ -127,13 +113,13 @@ TEST_F(RTCEncodedVideoStreamTransformerTest, *webrtc_task_runner_, FROM_HERE, CrossThreadBindOnce(&webrtc::FrameTransformerInterface::Transform, encoded_video_stream_transformer_.Delegate(), - CreateFakeFrame())); + CreateMockFrame())); task_environment_.RunUntilIdle(); } TEST_F(RTCEncodedVideoStreamTransformerTest, TransformerForwardsFrameToWebRTC) { EXPECT_CALL(*webrtc_callback_, OnTransformedFrame); - encoded_video_stream_transformer_.SendFrameToSink(CreateFakeFrame()); + encoded_video_stream_transformer_.SendFrameToSink(CreateMockFrame()); task_environment_.RunUntilIdle(); } diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_ice_candidate_platform.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_ice_candidate_platform.h index 2751f57f056..7c021d74322 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_ice_candidate_platform.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_ice_candidate_platform.h @@ -73,7 +73,7 @@ class PLATFORM_EXPORT RTCIceCandidatePlatform final const base::Optional<uint16_t>& RelatedPort() const { return related_port_; } const String& UsernameFragment() const { return username_fragment_; } - void Trace(Visitor*) {} + void Trace(Visitor*) const {} private: void PopulateFields(bool use_username_from_candidate); diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h index 9e8e23a538a..d529316c074 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_offer_options_platform.h @@ -26,7 +26,7 @@ class RTCOfferOptionsPlatform final bool VoiceActivityDetection() const { return voice_activity_detection_; } bool IceRestart() const { return ice_restart_; } - void Trace(Visitor* visitor) {} + void Trace(Visitor* visitor) const {} private: int32_t offer_to_receive_video_; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_receiver_platform.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_receiver_platform.h index 882a6893b69..47e063d842d 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_receiver_platform.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_receiver_platform.h @@ -21,7 +21,7 @@ namespace blink { class RTCEncodedAudioStreamTransformer; class RTCEncodedVideoStreamTransformer; class RTCRtpSource; -class WebMediaStreamTrack; +class MediaStreamComponent; // Implementations of this interface keep the corresponding WebRTC-layer // receiver alive through reference counting. Multiple |RTCRtpReceiverPlatform|s @@ -40,7 +40,7 @@ class PLATFORM_EXPORT RTCRtpReceiverPlatform { // Note: For convenience, DtlsTransportInformation always returns a value. // The information is only interesting if DtlsTransport() is non-null. virtual webrtc::DtlsTransportInformation DtlsTransportInformation() = 0; - virtual const WebMediaStreamTrack& Track() const = 0; + virtual MediaStreamComponent* Track() const = 0; virtual Vector<String> StreamIds() const = 0; virtual Vector<std::unique_ptr<RTCRtpSource>> GetSources() = 0; virtual void GetStats(RTCStatsReportCallback, diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_sender_platform.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_sender_platform.h index b39bca799ea..a8fbc418c9e 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_sender_platform.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_rtp_sender_platform.h @@ -21,7 +21,7 @@ class RtcDtmfSenderHandler; class RTCEncodedAudioStreamTransformer; class RTCEncodedVideoStreamTransformer; class RTCVoidRequest; -class WebMediaStreamTrack; +class MediaStreamComponent; // Implementations of this interface keep the corresponding WebRTC-layer sender // alive through reference counting. Multiple |RTCRtpSenderPlatform|s could @@ -41,12 +41,12 @@ class PLATFORM_EXPORT RTCRtpSenderPlatform { // Note: For convenience, DtlsTransportInformation always returns a value. // The information is only interesting if DtlsTransport() is non-null. virtual webrtc::DtlsTransportInformation DtlsTransportInformation() = 0; - virtual WebMediaStreamTrack Track() const = 0; + virtual MediaStreamComponent* Track() const = 0; virtual Vector<String> StreamIds() const = 0; // TODO(hbos): Replace RTCVoidRequest by something resolving promises based // on RTCError, as to surface both exception type and error message. // https://crbug.com/790007 - virtual void ReplaceTrack(WebMediaStreamTrack, RTCVoidRequest*) = 0; + virtual void ReplaceTrack(MediaStreamComponent*, RTCVoidRequest*) = 0; virtual std::unique_ptr<RtcDtmfSenderHandler> GetDtmfSender() const = 0; virtual std::unique_ptr<webrtc::RtpParameters> GetParameters() const = 0; virtual void SetParameters(Vector<webrtc::RtpEncodingParameters>, diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h index 69ea1e6b320..cac5d13028c 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_platform.h @@ -23,7 +23,7 @@ class PLATFORM_EXPORT RTCSessionDescriptionPlatform final String Sdp() { return sdp_; } void SetSdp(const String& sdp) { sdp_ = sdp; } - void Trace(Visitor* visitor) {} + void Trace(Visitor* visitor) const {} private: String type_; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_request.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_request.h index 6bc18622c67..34b7d77315b 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_request.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_session_description_request.h @@ -49,7 +49,7 @@ class RTCSessionDescriptionRequest virtual void RequestSucceeded(RTCSessionDescriptionPlatform*) = 0; virtual void RequestFailed(const webrtc::RTCError&) = 0; - virtual void Trace(Visitor* visitor) {} + virtual void Trace(Visitor* visitor) const {} protected: RTCSessionDescriptionRequest() = default; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.cc b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.cc index 083e9c33525..b2a3543b933 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.cc @@ -22,50 +22,50 @@ namespace blink { namespace { -class RTCStatsWhitelist { +class RTCStatsAllowlist { public: - RTCStatsWhitelist() { - whitelisted_stats_types_.insert(webrtc::RTCCertificateStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCCodecStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCDataChannelStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCIceCandidatePairStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCIceCandidateStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCLocalIceCandidateStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCRemoteIceCandidateStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCMediaStreamStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCMediaStreamTrackStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCPeerConnectionStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCRTPStreamStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCInboundRTPStreamStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCOutboundRTPStreamStats::kType); - whitelisted_stats_types_.insert( + RTCStatsAllowlist() { + allowlisted_stats_types_.insert(webrtc::RTCCertificateStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCCodecStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCDataChannelStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCIceCandidatePairStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCIceCandidateStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCLocalIceCandidateStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCRemoteIceCandidateStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCMediaStreamStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCMediaStreamTrackStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCPeerConnectionStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCRTPStreamStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCInboundRTPStreamStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCOutboundRTPStreamStats::kType); + allowlisted_stats_types_.insert( webrtc::RTCRemoteInboundRtpStreamStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCMediaSourceStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCAudioSourceStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCVideoSourceStats::kType); - whitelisted_stats_types_.insert(webrtc::RTCTransportStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCMediaSourceStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCAudioSourceStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCVideoSourceStats::kType); + allowlisted_stats_types_.insert(webrtc::RTCTransportStats::kType); } - bool IsWhitelisted(const webrtc::RTCStats& stats) { - return whitelisted_stats_types_.find(stats.type()) != - whitelisted_stats_types_.end(); + bool IsAllowlisted(const webrtc::RTCStats& stats) { + return allowlisted_stats_types_.find(stats.type()) != + allowlisted_stats_types_.end(); } - void WhitelistStatsForTesting(const char* type) { - whitelisted_stats_types_.insert(type); + void AllowStatsForTesting(const char* type) { + allowlisted_stats_types_.insert(type); } private: - std::set<std::string> whitelisted_stats_types_; + std::set<std::string> allowlisted_stats_types_; }; -RTCStatsWhitelist* GetStatsWhitelist() { - static RTCStatsWhitelist* whitelist = new RTCStatsWhitelist(); - return whitelist; +RTCStatsAllowlist* GetStatsAllowlist() { + static RTCStatsAllowlist* list = new RTCStatsAllowlist(); + return list; } -bool IsWhitelistedStats(const webrtc::RTCStats& stats) { - return GetStatsWhitelist()->IsWhitelisted(stats); +bool IsAllowlistedStats(const webrtc::RTCStats& stats) { + return GetStatsAllowlist()->IsAllowlisted(stats); } // Filters stats that should be surfaced to JS. Stats are surfaced if they're @@ -74,9 +74,9 @@ bool IsWhitelistedStats(const webrtc::RTCStats& stats) { std::vector<const webrtc::RTCStatsMemberInterface*> FilterMembers( std::vector<const webrtc::RTCStatsMemberInterface*> stats_members, const Vector<webrtc::NonStandardGroupId>& exposed_group_ids) { - // Note that using "is_standarized" avoids having to maintain a whitelist of + // Note that using "is_standarized" avoids having to maintain an allowlist of // every single standardized member, as we do at the "stats object" level - // with "RTCStatsWhitelist". + // with "RTCStatsAllowlist". base::EraseIf( stats_members, [&exposed_group_ids](const webrtc::RTCStatsMemberInterface* member) { @@ -96,11 +96,11 @@ std::vector<const webrtc::RTCStatsMemberInterface*> FilterMembers( return stats_members; } -size_t CountWhitelistedStats( +size_t CountAllowlistedStats( const scoped_refptr<const webrtc::RTCStatsReport>& stats_report) { size_t size = 0; for (const auto& stats : *stats_report) { - if (IsWhitelistedStats(stats)) { + if (IsAllowlistedStats(stats)) { ++size; } } @@ -123,7 +123,7 @@ RTCStatsReportPlatform::RTCStatsReportPlatform( it_(stats_report_->begin()), end_(stats_report_->end()), exposed_group_ids_(exposed_group_ids), - size_(CountWhitelistedStats(stats_report)) { + size_(CountAllowlistedStats(stats_report)) { DCHECK(stats_report_); } @@ -138,7 +138,7 @@ std::unique_ptr<RTCStatsReportPlatform> RTCStatsReportPlatform::CopyHandle() std::unique_ptr<RTCStats> RTCStatsReportPlatform::GetStats( const String& id) const { const webrtc::RTCStats* stats = stats_report_->Get(id.Utf8()); - if (!stats || !IsWhitelistedStats(*stats)) + if (!stats || !IsAllowlistedStats(*stats)) return std::unique_ptr<RTCStats>(); return std::make_unique<RTCStats>(stats_report_, stats, exposed_group_ids_); } @@ -147,7 +147,7 @@ std::unique_ptr<RTCStats> RTCStatsReportPlatform::Next() { while (it_ != end_) { const webrtc::RTCStats& next = *it_; ++it_; - if (IsWhitelistedStats(next)) { + if (IsAllowlistedStats(next)) { return std::make_unique<RTCStats>(stats_report_, &next, exposed_group_ids_); } @@ -346,8 +346,8 @@ void RTCStatsCollectorCallbackImpl::OnStatsDeliveredOnMainThread( base::WrapRefCounted(report.get()), exposed_group_ids_)); } -void WhitelistStatsForTesting(const char* type) { - GetStatsWhitelist()->WhitelistStatsForTesting(type); +void AllowStatsForTesting(const char* type) { + GetStatsAllowlist()->AllowStatsForTesting(type); } } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.h index e6e85007988..532ad85a4dd 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats.h @@ -31,9 +31,9 @@ class RTCStats; class RTCStatsMember; // Wrapper around a webrtc::RTCStatsReport. Filters out any stats objects that -// aren't whitelisted. |filter| controls whether to include only standard -// members (RTCStatsMemberInterface::is_standardized return true) or not -// (RTCStatsMemberInterface::is_standardized return false). +// aren't listed in the allow list. |filter| controls whether to include only +// standard members (RTCStatsMemberInterface::is_standardized return true) or +// not (RTCStatsMemberInterface::is_standardized return false). // // Note: This class is named |RTCStatsReportPlatform| not to collide with class // |RTCStatsReport|, from renderer/modules/peerconnection/rtc_stats_report.cc|h. @@ -62,7 +62,7 @@ class PLATFORM_EXPORT RTCStatsReportPlatform { webrtc::RTCStatsReport::ConstIterator it_; const webrtc::RTCStatsReport::ConstIterator end_; Vector<webrtc::NonStandardGroupId> exposed_group_ids_; - // Number of whitelisted webrtc::RTCStats in |stats_report_|. + // Number of allowlisted webrtc::RTCStats in |stats_report_|. const size_t size_; }; @@ -156,7 +156,7 @@ class PLATFORM_EXPORT RTCStatsCollectorCallbackImpl Vector<webrtc::NonStandardGroupId> exposed_group_ids_; }; -PLATFORM_EXPORT void WhitelistStatsForTesting(const char* type); +PLATFORM_EXPORT void AllowStatsForTesting(const char* type); } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h index e013c6b151d..c5e52fb6aca 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_request.h @@ -74,7 +74,7 @@ class RTCStatsRequest : public GarbageCollected<RTCStatsRequest> { virtual MediaStreamComponent* Component() = 0; virtual void RequestSucceeded(RTCStatsResponseBase*) = 0; - virtual void Trace(Visitor* visitor) {} + virtual void Trace(Visitor* visitor) const {} protected: RTCStatsRequest() = default; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_test.cc b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_test.cc index 98ec0d03b41..61fce2d9fc5 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_test.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_stats_test.cc @@ -14,40 +14,40 @@ namespace blink { -TEST(RTCStatsTest, OnlyIncludeWhitelistedStats_GetStats) { - const char* not_whitelisted_id = "NotWhitelistedId"; - const char* whitelisted_id = "WhitelistedId"; +TEST(RTCStatsTest, OnlyIncludeAllowlistedStats_GetStats) { + const char* not_allowlisted_id = "NotAllowlistedId"; + const char* allowlisted_id = "AllowlistedId"; rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report = webrtc::RTCStatsReport::Create(42); webrtc_report->AddStats(std::unique_ptr<webrtc::RTCTestStats>( - new webrtc::RTCTestStats(not_whitelisted_id, 42))); + new webrtc::RTCTestStats(not_allowlisted_id, 42))); webrtc_report->AddStats(std::unique_ptr<webrtc::RTCPeerConnectionStats>( - new webrtc::RTCPeerConnectionStats(whitelisted_id, 42))); + new webrtc::RTCPeerConnectionStats(allowlisted_id, 42))); RTCStatsReportPlatform report(webrtc_report.get(), {}); - EXPECT_FALSE(report.GetStats(not_whitelisted_id)); - EXPECT_TRUE(report.GetStats(whitelisted_id)); + EXPECT_FALSE(report.GetStats(not_allowlisted_id)); + EXPECT_TRUE(report.GetStats(allowlisted_id)); } -TEST(RTCStatsTest, OnlyIncludeWhitelistedStats_Iteration) { - const char* not_whitelisted_id = "NotWhitelistedId"; - const char* whitelisted_id = "WhitelistedId"; +TEST(RTCStatsTest, OnlyIncludeAllowlistedStats_Iteration) { + const char* not_allowlisted_id = "NotAllowlistedId"; + const char* allowlisted_id = "AllowlistedId"; rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report = webrtc::RTCStatsReport::Create(42); webrtc_report->AddStats(std::unique_ptr<webrtc::RTCTestStats>( - new webrtc::RTCTestStats(not_whitelisted_id, 42))); + new webrtc::RTCTestStats(not_allowlisted_id, 42))); webrtc_report->AddStats(std::unique_ptr<webrtc::RTCPeerConnectionStats>( - new webrtc::RTCPeerConnectionStats(whitelisted_id, 42))); + new webrtc::RTCPeerConnectionStats(allowlisted_id, 42))); RTCStatsReportPlatform report(webrtc_report.get(), {}); - // Only whitelisted stats are counted. + // Only allowlisted stats are counted. EXPECT_EQ(report.Size(), 1u); std::unique_ptr<RTCStats> stats = report.Next(); EXPECT_TRUE(stats); - EXPECT_EQ(stats->Id(), whitelisted_id); + EXPECT_EQ(stats->Id(), allowlisted_id); EXPECT_FALSE(report.Next()); } @@ -78,12 +78,12 @@ TestStats::TestStats(const std::string& id, int64_t timestamp_us) {webrtc::NonStandardGroupId::kGroupIdForTesting}) {} } // namespace -// Similar to how only whitelisted stats objects should be surfaced, only -// standardized members of the whitelisted objects should be surfaced. +// Similar to how only allowlisted stats objects should be surfaced, only +// standardized members of the allowlisted objects should be surfaced. TEST(RTCStatsTest, OnlyIncludeStandarizedMembers) { rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report = webrtc::RTCStatsReport::Create(42); - WhitelistStatsForTesting(TestStats::kType); + AllowStatsForTesting(TestStats::kType); webrtc_report->AddStats(std::make_unique<TestStats>("id", 0)); // TestStats has two members, but the non-standard member should be filtered @@ -98,7 +98,7 @@ TEST(RTCStatsTest, OnlyIncludeStandarizedMembers) { TEST(RTCStatsTest, IncludeAllMembers) { rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report = webrtc::RTCStatsReport::Create(7); - WhitelistStatsForTesting(TestStats::kType); + AllowStatsForTesting(TestStats::kType); webrtc_report->AddStats(std::make_unique<TestStats>("id", 0)); // Include both standard and non-standard member. @@ -115,7 +115,7 @@ TEST(RTCStatsTest, IncludeAllMembers) { TEST(RTCStatsTest, CopyHandle) { rtc::scoped_refptr<webrtc::RTCStatsReport> webrtc_report = webrtc::RTCStatsReport::Create(17); - WhitelistStatsForTesting(TestStats::kType); + AllowStatsForTesting(TestStats::kType); webrtc_report->AddStats(std::make_unique<TestStats>("id", 0)); // Check that filtering options are preserved during copy. diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.cc b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.cc index 5e835676e73..2794082db61 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.cc @@ -13,6 +13,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/ptr_util.h" +#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" @@ -99,6 +100,8 @@ media::VideoCodecProfile GuessVideoCodecProfile( switch (vp9_profile) { case webrtc::VP9Profile::kProfile2: return media::VP9PROFILE_PROFILE2; + case webrtc::VP9Profile::kProfile1: + return media::VP9PROFILE_PROFILE1; case webrtc::VP9Profile::kProfile0: default: return media::VP9PROFILE_PROFILE0; @@ -125,9 +128,32 @@ void OnRequestOverlayInfo(bool decoder_requires_restart_for_overlay, std::move(overlay_info_cb).Run(media::OverlayInfo()); } +void RecordInitializationLatency(base::TimeDelta latency) { + base::UmaHistogramTimes("Media.RTCVideoDecoderInitializationLatencyMs", + latency); +} + +void RecordReinitializationLatency(base::TimeDelta latency) { + base::UmaHistogramTimes("Media.RTCVideoDecoderReinitializationLatencyMs", + latency); +} + } // namespace // static +std::vector<media::VideoDecoderImplementation> +RTCVideoDecoderAdapter::SupportedImplementations() { +#if defined(OS_WIN) + if (base::FeatureList::IsEnabled(media::kD3D11VideoDecoder)) { + // Push alternate ahead of default to prefer D3D11 decoders over DXVA. + return {media::VideoDecoderImplementation::kAlternate, + media::VideoDecoderImplementation::kDefault}; + } +#endif + return {media::VideoDecoderImplementation::kDefault}; +} + +// static std::unique_ptr<RTCVideoDecoderAdapter> RTCVideoDecoderAdapter::Create( media::GpuVideoAcceleratorFactories* gpu_factories, const webrtc::SdpVideoFormat& format) { @@ -152,31 +178,36 @@ std::unique_ptr<RTCVideoDecoderAdapter> RTCVideoDecoderAdapter::Create( media::kNoTransformation, kDefaultSize, gfx::Rect(kDefaultSize), kDefaultSize, media::EmptyExtraData(), media::EncryptionScheme::kUnencrypted); - if (gpu_factories->IsDecoderConfigSupported(kImplementation, config) == - media::GpuVideoAcceleratorFactories::Supported::kFalse) { - return nullptr; - } - // Synchronously verify that the decoder can be initialized. - std::unique_ptr<RTCVideoDecoderAdapter> rtc_video_decoder_adapter = - base::WrapUnique( - new RTCVideoDecoderAdapter(gpu_factories, config, format)); - if (!rtc_video_decoder_adapter->InitializeSync(config)) { - gpu_factories->GetTaskRunner()->DeleteSoon( - FROM_HERE, std::move(rtc_video_decoder_adapter)); - return nullptr; + for (auto impl : SupportedImplementations()) { + std::unique_ptr<RTCVideoDecoderAdapter> rtc_video_decoder_adapter; + if (gpu_factories->IsDecoderConfigSupported(impl, config) != + media::GpuVideoAcceleratorFactories::Supported::kFalse) { + // Synchronously verify that the decoder can be initialized. + rtc_video_decoder_adapter = base::WrapUnique( + new RTCVideoDecoderAdapter(gpu_factories, config, format, impl)); + if (rtc_video_decoder_adapter->InitializeSync(config)) { + return rtc_video_decoder_adapter; + } + // Initialization failed - post delete task and try next supported + // implementation, if any. + gpu_factories->GetTaskRunner()->DeleteSoon( + FROM_HERE, std::move(rtc_video_decoder_adapter)); + } } - return rtc_video_decoder_adapter; + return nullptr; } RTCVideoDecoderAdapter::RTCVideoDecoderAdapter( media::GpuVideoAcceleratorFactories* gpu_factories, const media::VideoDecoderConfig& config, - const webrtc::SdpVideoFormat& format) + const webrtc::SdpVideoFormat& format, + media::VideoDecoderImplementation implementation) : media_task_runner_(gpu_factories->GetTaskRunner()), gpu_factories_(gpu_factories), format_(format), + implementation_(implementation), config_(config) { DVLOG(1) << __func__; DETACH_FROM_SEQUENCE(decoding_sequence_checker_); @@ -193,6 +224,7 @@ bool RTCVideoDecoderAdapter::InitializeSync( DVLOG(3) << __func__; // Can be called on |worker_thread_| or |decoding_thread_|. DCHECK(!media_task_runner_->BelongsToCurrentThread()); + base::TimeTicks start_time = base::TimeTicks::Now(); base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait; bool result = false; @@ -207,8 +239,12 @@ bool RTCVideoDecoderAdapter::InitializeSync( CrossThreadUnretained(this), config, std::move(init_cb)))) { // TODO(crbug.com/1076817) Remove if a root cause is found. - if (!waiter.TimedWait(base::TimeDelta::FromSeconds(10))) + if (!waiter.TimedWait(base::TimeDelta::FromSeconds(10))) { + RecordInitializationLatency(base::TimeTicks::Now() - start_time); return false; + } + + RecordInitializationLatency(base::TimeTicks::Now() - start_time); } return result; } @@ -374,7 +410,7 @@ void RTCVideoDecoderAdapter::InitializeOnMediaThread( media_log_ = std::make_unique<media::NullMediaLog>(); video_decoder_ = gpu_factories_->CreateVideoDecoder( - media_log_.get(), kImplementation, + media_log_.get(), implementation_, WTF::BindRepeating(&OnRequestOverlayInfo)); if (!video_decoder_) { @@ -507,6 +543,7 @@ bool RTCVideoDecoderAdapter::ReinitializeSync( const media::VideoDecoderConfig& config) { DCHECK_CALLED_ON_VALID_SEQUENCE(decoding_sequence_checker_); + base::TimeTicks start_time = base::TimeTicks::Now(); base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait; bool result = false; base::WaitableEvent waiter(base::WaitableEvent::ResetPolicy::MANUAL, @@ -526,6 +563,7 @@ bool RTCVideoDecoderAdapter::ReinitializeSync( weak_this_, std::move(flush_success_cb), std::move(flush_fail_cb)))) { waiter.Wait(); + RecordReinitializationLatency(base::TimeTicks::Now() - start_time); } return result; } diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.h index 9d67fb60e8b..ded3110791a 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_adapter.h @@ -6,6 +6,7 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_PEERCONNECTION_RTC_VIDEO_DECODER_ADAPTER_H_ #include <memory> +#include <vector> #include "base/callback_forward.h" #include "base/macros.h" @@ -53,12 +54,11 @@ namespace blink { // way to synchronize this correctly. class PLATFORM_EXPORT RTCVideoDecoderAdapter : public webrtc::VideoDecoder { public: - // Currently, RTCVideoDecoderAdapter only tries one - // VideoDecoderImplementation. - // Since we use it in multiple places, memorize it here to make it clear that - // they must be changed together. - static constexpr media::VideoDecoderImplementation kImplementation = - media::VideoDecoderImplementation::kDefault; + // Lists which implementations can be queried, this can vary based on platform + // and enabled features. + static std::vector<media::VideoDecoderImplementation> + SupportedImplementations(); + // Creates and initializes an RTCVideoDecoderAdapter. Returns nullptr if // |format| cannot be supported. // Called on the worker thread. @@ -95,7 +95,8 @@ class PLATFORM_EXPORT RTCVideoDecoderAdapter : public webrtc::VideoDecoder { // Called on the worker thread. RTCVideoDecoderAdapter(media::GpuVideoAcceleratorFactories* gpu_factories, const media::VideoDecoderConfig& config, - const webrtc::SdpVideoFormat& format); + const webrtc::SdpVideoFormat& format, + media::VideoDecoderImplementation implementation); bool InitializeSync(const media::VideoDecoderConfig& config); void InitializeOnMediaThread(const media::VideoDecoderConfig& config, @@ -113,9 +114,10 @@ class PLATFORM_EXPORT RTCVideoDecoderAdapter : public webrtc::VideoDecoder { FlushDoneCB flush_fail_cb); // Construction parameters. - scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; - media::GpuVideoAcceleratorFactories* gpu_factories_; - webrtc::SdpVideoFormat format_; + const scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; + media::GpuVideoAcceleratorFactories* const gpu_factories_; + const webrtc::SdpVideoFormat format_; + const media::VideoDecoderImplementation implementation_; media::VideoDecoderConfig config_; // Media thread members. diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_factory.cc b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_factory.cc index cb12d36124c..70ff644a016 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_factory.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_decoder_factory.cc @@ -32,9 +32,10 @@ struct CodecConfig { media::VideoCodecProfile profile; }; -constexpr std::array<CodecConfig, 6> kCodecConfigs = {{ +constexpr std::array<CodecConfig, 7> kCodecConfigs = {{ {media::kCodecVP8, media::VP8PROFILE_ANY}, {media::kCodecVP9, media::VP9PROFILE_PROFILE0}, + {media::kCodecVP9, media::VP9PROFILE_PROFILE1}, {media::kCodecVP9, media::VP9PROFILE_PROFILE2}, {media::kCodecH264, media::H264PROFILE_BASELINE}, {media::kCodecH264, media::H264PROFILE_MAIN}, @@ -54,6 +55,9 @@ base::Optional<webrtc::SdpVideoFormat> VdcToWebRtcFormat( case media::VP9PROFILE_PROFILE0: vp9_profile = webrtc::VP9Profile::kProfile0; break; + case media::VP9PROFILE_PROFILE1: + vp9_profile = webrtc::VP9Profile::kProfile1; + break; case media::VP9PROFILE_PROFILE2: vp9_profile = webrtc::VP9Profile::kProfile2; break; @@ -185,12 +189,15 @@ RTCVideoDecoderFactory::GetSupportedFormats() const { media::VideoColorSpace(), media::kNoTransformation, kDefaultSize, gfx::Rect(kDefaultSize), kDefaultSize, media::EmptyExtraData(), media::EncryptionScheme::kUnencrypted); - if (gpu_factories_->IsDecoderConfigSupported( - RTCVideoDecoderAdapter::kImplementation, config) == - media::GpuVideoAcceleratorFactories::Supported::kTrue) { - base::Optional<webrtc::SdpVideoFormat> format = VdcToWebRtcFormat(config); - if (format) { - supported_formats.push_back(*format); + for (auto impl : RTCVideoDecoderAdapter::SupportedImplementations()) { + if (gpu_factories_->IsDecoderConfigSupported(impl, config) == + media::GpuVideoAcceleratorFactories::Supported::kTrue) { + base::Optional<webrtc::SdpVideoFormat> format = + VdcToWebRtcFormat(config); + if (format) { + supported_formats.push_back(*format); + } + break; } } } diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder_test.cc b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder_test.cc index 4be94202c58..df4f1272c0a 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder_test.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder_test.cc @@ -5,6 +5,7 @@ #include <stdint.h> #include "base/bind.h" +#include "base/logging.h" #include "base/single_thread_task_runner.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_void_request.h b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_void_request.h index 9376feb9ced..e773bec36d4 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/rtc_void_request.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/rtc_void_request.h @@ -44,7 +44,7 @@ class RTCVoidRequest : public GarbageCollected<RTCVoidRequest> { virtual void RequestSucceeded() = 0; virtual void RequestFailed(const webrtc::RTCError&) = 0; - virtual void Trace(Visitor* visitor) {} + virtual void Trace(Visitor* visitor) const {} protected: RTCVoidRequest() = default; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/two_keys_adapter_map.h b/chromium/third_party/blink/renderer/platform/peerconnection/two_keys_adapter_map.h index 75e3561bd2b..40601e6ef57 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/two_keys_adapter_map.h +++ b/chromium/third_party/blink/renderer/platform/peerconnection/two_keys_adapter_map.h @@ -8,7 +8,7 @@ #include <memory> #include <utility> -#include "base/logging.h" +#include "base/check.h" #include "base/optional.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h" diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc b/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc index 3ed4b1a517a..a9923b0eaee 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc @@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/logging.h" #include "base/trace_event/trace_event.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/renderer/platform/webrtc/webrtc_video_frame_adapter.h" @@ -129,24 +130,22 @@ void WebRtcVideoTrackSource::OnFrameCaptured( // rtc::AdaptedVideoTrackSource::OnFrame(). This region is going to be // relative to the coded frame data, i.e. // [0, 0, frame->coded_size().width(), frame->coded_size().height()]. - gfx::Rect update_rect; - int capture_counter = 0; - bool has_capture_counter = frame->metadata()->GetInteger( - media::VideoFrameMetadata::CAPTURE_COUNTER, &capture_counter); - bool has_update_rect = frame->metadata()->GetRect( - media::VideoFrameMetadata::CAPTURE_UPDATE_RECT, &update_rect); + base::Optional<int> capture_counter = frame->metadata()->capture_counter; + base::Optional<gfx::Rect> update_rect = + frame->metadata()->capture_update_rect; + const bool has_valid_update_rect = - has_update_rect && has_capture_counter && + update_rect.has_value() && capture_counter.has_value() && previous_capture_counter_.has_value() && - (capture_counter == (previous_capture_counter_.value() + 1)); + (*capture_counter == (*previous_capture_counter_ + 1)); DVLOG(3) << "has_valid_update_rect = " << has_valid_update_rect; - if (has_capture_counter) + if (capture_counter) previous_capture_counter_ = capture_counter; if (has_valid_update_rect) { if (!accumulated_update_rect_) { accumulated_update_rect_ = update_rect; } else { - accumulated_update_rect_->Union(update_rect); + accumulated_update_rect_->Union(*update_rect); } } else { accumulated_update_rect_ = base::nullopt; diff --git a/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source_test.cc b/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source_test.cc index bd1958dee5b..585da18ffce 100644 --- a/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source_test.cc +++ b/chromium/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source_test.cc @@ -65,10 +65,8 @@ class WebRtcVideoTrackSourceTest media::VideoFrame::StorageType storage_type) { scoped_refptr<media::VideoFrame> frame = CreateTestFrame(coded_size, visible_rect, natural_size, storage_type); - frame->metadata()->SetInteger(media::VideoFrameMetadata::CAPTURE_COUNTER, - capture_counter); - frame->metadata()->SetRect(media::VideoFrameMetadata::CAPTURE_UPDATE_RECT, - update_rect); + frame->metadata()->capture_counter = capture_counter; + frame->metadata()->capture_update_rect = update_rect; track_source_->OnFrameCaptured(frame); } |