From 11a514f0d479e5257f98fe4a17187959d2e277b2 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Thu, 9 Feb 2023 15:32:59 +0000 Subject: [PATCH] Bug 1813468 - Remove RemoteTrackSource from MediaPipeline. r=bwc Differential Revision: https://phabricator.services.mozilla.com/D168722 --- dom/media/webrtc/jsapi/RTCRtpReceiver.cpp | 6 +- .../webrtc/transportbridge/MediaPipeline.cpp | 58 +++++++++---------- .../webrtc/transportbridge/MediaPipeline.h | 10 ++-- .../gtest/mediapipeline_unittest.cpp | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp b/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp index bf1fcbfc55b5..d74fa76104fa 100644 --- a/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp +++ b/dom/media/webrtc/jsapi/RTCRtpReceiver.cpp @@ -104,7 +104,8 @@ RTCRtpReceiver::RTCRtpReceiver( mTrack = MakeAndAddRef(aWindow, source, mTrackSource); mPipeline = MakeAndAddRef( mPc->GetHandle(), aTransportHandler, aCallThread, mStsThread.get(), - *aConduit->AsAudioSessionConduit(), mTrack, principalHandle, aPrivacy); + *aConduit->AsAudioSessionConduit(), mTrackSource->Stream(), aTrackingId, + principalHandle, aPrivacy); } else { auto* source = graph->CreateSourceTrack(MediaSegment::VIDEO); mTrackSource = MakeAndAddRef( @@ -112,7 +113,8 @@ RTCRtpReceiver::RTCRtpReceiver( mTrack = MakeAndAddRef(aWindow, source, mTrackSource); mPipeline = MakeAndAddRef( mPc->GetHandle(), aTransportHandler, aCallThread, mStsThread.get(), - *aConduit->AsVideoSessionConduit(), mTrack, principalHandle, aPrivacy); + *aConduit->AsVideoSessionConduit(), mTrackSource->Stream(), aTrackingId, + principalHandle, aPrivacy); } // Spec says remote tracks start out muted. diff --git a/dom/media/webrtc/transportbridge/MediaPipeline.cpp b/dom/media/webrtc/transportbridge/MediaPipeline.cpp index 34a11f3f782a..47d5b5453537 100644 --- a/dom/media/webrtc/transportbridge/MediaPipeline.cpp +++ b/dom/media/webrtc/transportbridge/MediaPipeline.cpp @@ -21,7 +21,6 @@ #include "MediaTrackGraphImpl.h" #include "MediaTrackListener.h" #include "MediaStreamTrack.h" -#include "jsapi/RemoteTrackSource.h" #include "RtpLogger.h" #include "VideoFrameConverter.h" #include "VideoSegment.h" @@ -1173,13 +1172,11 @@ void MediaPipelineTransmit::PipelineListener::NewData( class GenericReceiveListener : public MediaTrackListener { public: - explicit GenericReceiveListener(const RefPtr& aTrack) - : mTrackSource(new nsMainThreadPtrHolder( - "GenericReceiveListener::mTrackSource", - &static_cast(aTrack->GetSource()))), - mSource(mTrackSource->Stream()), - mTrackingId(mTrackSource->mTrackingId), - mIsAudio(aTrack->AsAudioStreamTrack()), + GenericReceiveListener(RefPtr aSource, + TrackingId aTrackingId) + : mSource(std::move(aSource)), + mTrackingId(std::move(aTrackingId)), + mIsAudio(mSource->mType == MediaSegment::AUDIO), mEnabled(false) { MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread()); MOZ_DIAGNOSTIC_ASSERT(mSource, "Must be used with a SourceMediaTrack"); @@ -1201,7 +1198,6 @@ class GenericReceiveListener : public MediaTrackListener { } protected: - const nsMainThreadPtrHandle mTrackSource; const RefPtr mSource; const TrackingId mTrackingId; const bool mIsAudio; @@ -1248,11 +1244,10 @@ void MediaPipelineReceive::OnRtpPacketReceived() { class MediaPipelineReceiveAudio::PipelineListener : public GenericReceiveListener { public: - PipelineListener(const RefPtr& aTrack, + PipelineListener(RefPtr aSource, TrackingId aTrackingId, RefPtr aConduit, - const PrincipalHandle& aPrincipalHandle, - PrincipalPrivacy aPrivacy) - : GenericReceiveListener(aTrack), + PrincipalHandle aPrincipalHandle, PrincipalPrivacy aPrivacy) + : GenericReceiveListener(std::move(aSource), std::move(aTrackingId)), mConduit(std::move(aConduit)), // AudioSession conduit only supports 16, 32, 44.1 and 48kHz // This is an artificial limitation, it would however require more @@ -1267,7 +1262,7 @@ class MediaPipelineReceiveAudio::PipelineListener "AudioPipelineListener")), mPlayedTicks(0), mAudioFrame(std::make_unique()), - mPrincipalHandle(aPrincipalHandle), + mPrincipalHandle(std::move(aPrincipalHandle)), mPrivacy(aPrivacy), mForceSilence(false) {} @@ -1430,15 +1425,16 @@ class MediaPipelineReceiveAudio::PipelineListener MediaPipelineReceiveAudio::MediaPipelineReceiveAudio( const std::string& aPc, RefPtr aTransportHandler, RefPtr aCallThread, RefPtr aStsThread, - RefPtr aConduit, - const RefPtr& aTrack, - const PrincipalHandle& aPrincipalHandle, PrincipalPrivacy aPrivacy) + RefPtr aConduit, RefPtr aSource, + TrackingId aTrackingId, PrincipalHandle aPrincipalHandle, + PrincipalPrivacy aPrivacy) : MediaPipelineReceive(aPc, std::move(aTransportHandler), std::move(aCallThread), std::move(aStsThread), std::move(aConduit)), - mListener(aTrack ? new PipelineListener(aTrack, mConduit, - aPrincipalHandle, aPrivacy) - : nullptr) { + mListener(aSource ? new PipelineListener( + std::move(aSource), std::move(aTrackingId), + mConduit, std::move(aPrincipalHandle), aPrivacy) + : nullptr) { mDescription = mPc + "| Receive audio"; if (mListener) { mListener->Init(); @@ -1477,14 +1473,13 @@ void MediaPipelineReceiveAudio::UpdateListener() { class MediaPipelineReceiveVideo::PipelineListener : public GenericReceiveListener { public: - PipelineListener(const RefPtr& aTrack, - const PrincipalHandle& aPrincipalHandle, - PrincipalPrivacy aPrivacy) - : GenericReceiveListener(aTrack), + PipelineListener(RefPtr aSource, TrackingId aTrackingId, + PrincipalHandle aPrincipalHandle, PrincipalPrivacy aPrivacy) + : GenericReceiveListener(std::move(aSource), std::move(aTrackingId)), mImageContainer( MakeAndAddRef(ImageContainer::ASYNCHRONOUS)), mMutex("MediaPipelineReceiveVideo::PipelineListener::mMutex"), - mPrincipalHandle(aPrincipalHandle), + mPrincipalHandle(std::move(aPrincipalHandle)), mPrivacy(aPrivacy) {} void OnPrivacyRequested_s() { MutexAutoLock lock(mMutex); @@ -1598,16 +1593,17 @@ class MediaPipelineReceiveVideo::PipelineRenderer MediaPipelineReceiveVideo::MediaPipelineReceiveVideo( const std::string& aPc, RefPtr aTransportHandler, RefPtr aCallThread, RefPtr aStsThread, - RefPtr aConduit, - const RefPtr& aTrack, - const PrincipalHandle& aPrincipalHandle, PrincipalPrivacy aPrivacy) + RefPtr aConduit, RefPtr aSource, + TrackingId aTrackingId, PrincipalHandle aPrincipalHandle, + PrincipalPrivacy aPrivacy) : MediaPipelineReceive(aPc, std::move(aTransportHandler), std::move(aCallThread), std::move(aStsThread), std::move(aConduit)), mRenderer(new PipelineRenderer(this)), - mListener(aTrack - ? new PipelineListener(aTrack, aPrincipalHandle, aPrivacy) - : nullptr) { + mListener(aSource ? new PipelineListener( + std::move(aSource), std::move(aTrackingId), + std::move(aPrincipalHandle), aPrivacy) + : nullptr) { mDescription = mPc + "| Receive video"; if (mListener) { mListener->Init(); diff --git a/dom/media/webrtc/transportbridge/MediaPipeline.h b/dom/media/webrtc/transportbridge/MediaPipeline.h index 668accf88931..cbc101effa6c 100644 --- a/dom/media/webrtc/transportbridge/MediaPipeline.h +++ b/dom/media/webrtc/transportbridge/MediaPipeline.h @@ -384,8 +384,9 @@ class MediaPipelineReceiveAudio : public MediaPipelineReceive { RefPtr aCallThread, RefPtr aStsThread, RefPtr aConduit, - const RefPtr& aTrack, - const PrincipalHandle& aPrincipalHandle, + RefPtr aSource, + TrackingId aTrackingId, + PrincipalHandle aPrincipalHandle, PrincipalPrivacy aPrivacy); void Shutdown() override; @@ -413,8 +414,9 @@ class MediaPipelineReceiveVideo : public MediaPipelineReceive { RefPtr aCallThread, RefPtr aStsThread, RefPtr aConduit, - const RefPtr& aTrack, - const PrincipalHandle& aPrincipalHandle, + RefPtr aSource, + TrackingId aTrackingId, + PrincipalHandle aPrincipalHandle, PrincipalPrivacy aPrivacy); void Shutdown() override; diff --git a/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp b/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp index c2566fa9adf7..ca5132494dd5 100644 --- a/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp +++ b/media/webrtc/signaling/gtest/mediapipeline_unittest.cpp @@ -396,7 +396,7 @@ class TestAgentReceive : public TestAgent { test_pc, transport_, AbstractThread::MainThread(), test_utils->sts_target(), static_cast(audio_conduit_.get()), nullptr, - PRINCIPAL_HANDLE_NONE, PrincipalPrivacy::NonPrivate); + TrackingId(), PRINCIPAL_HANDLE_NONE, PrincipalPrivacy::NonPrivate); audio_pipeline_->Start(); conduit_control_.Update([](auto& aControl) { aControl.mReceiving = true; });