diff --git a/pc/video_track.cc b/pc/video_track.cc index 27274dc095..4559181ce7 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -57,18 +57,18 @@ void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface* sink, VideoSourceBaseGuarded::AddOrUpdateSink(sink, wants); rtc::VideoSinkWants modified_wants = wants; modified_wants.black_frames = !enabled_w_; - video_source_->AddOrUpdateSink(sink, modified_wants); + video_source_->internal()->AddOrUpdateSink(sink, modified_wants); } void VideoTrack::RemoveSink(rtc::VideoSinkInterface* sink) { RTC_DCHECK_RUN_ON(worker_thread_); VideoSourceBaseGuarded::RemoveSink(sink); - video_source_->RemoveSink(sink); + video_source_->internal()->RemoveSink(sink); } void VideoTrack::RequestRefreshFrame() { RTC_DCHECK_RUN_ON(worker_thread_); - video_source_->RequestRefreshFrame(); + video_source_->internal()->RequestRefreshFrame(); } VideoTrackSourceInterface* VideoTrack::GetSource() const { @@ -76,6 +76,10 @@ VideoTrackSourceInterface* VideoTrack::GetSource() const { return video_source_.get(); } +VideoTrackSourceInterface* VideoTrack::GetSourceInternal() const { + return video_source_->internal(); +} + VideoTrackInterface::ContentHint VideoTrack::content_hint() const { RTC_DCHECK_RUN_ON(&signaling_thread_); return content_hint_; diff --git a/pc/video_track.h b/pc/video_track.h index 2bf7f31741..66262d22d1 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -54,6 +54,9 @@ class VideoTrack : public MediaStreamTrack, MediaStreamTrackInterface::TrackState state() const override; std::string kind() const override; + // Direct access to the non-proxied source object for internal implementation. + VideoTrackSourceInterface* GetSourceInternal() const; + protected: VideoTrack( const std::string& id, diff --git a/pc/video_track_unittest.cc b/pc/video_track_unittest.cc index 6342b608f1..e6dcce7939 100644 --- a/pc/video_track_unittest.cc +++ b/pc/video_track_unittest.cc @@ -40,10 +40,19 @@ class VideoTrackTest : public ::testing::Test { protected: rtc::scoped_refptr video_track_source_; - rtc::scoped_refptr video_track_; + rtc::scoped_refptr video_track_; cricket::FakeFrameSource frame_source_; }; +// VideoTrack::Create will create an API proxy around the source object. +// The `GetSource` method provides access to the proxy object intented for API +// use while the GetSourceInternal() provides direct access to the source object +// as provided to the `VideoTrack::Create` factory function. +TEST_F(VideoTrackTest, CheckApiProxyAndInternalSource) { + EXPECT_NE(video_track_->GetSource(), video_track_source_.get()); + EXPECT_EQ(video_track_->GetSourceInternal(), video_track_source_.get()); +} + // Test changing the source state also changes the track state. TEST_F(VideoTrackTest, SourceStateChangeTrackState) { EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state());