Bug 1309886 - End received tracks when MediaPipelineReceive is detached. r?drno
MozReview-Commit-ID: 86kqjtMhulR
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -1902,16 +1902,21 @@ class GenericReceiveListener : public Me
virtual ~GenericReceiveListener() {}
void AddSelf()
{
AddListener(source_, this);
}
+ void EndTrack()
+ {
+ source_->EndTrack(track_id_);
+ }
+
#ifndef USE_FAKE_MEDIA_STREAMS
// Must be called on the main thread
void SetPrincipalHandle_m(const PrincipalHandle& principal_handle)
{
class Message : public ControlMessage
{
public:
Message(GenericReceiveListener* listener,
@@ -1937,17 +1942,17 @@ class GenericReceiveListener : public Me
void SetPrincipalHandle_msg(const PrincipalHandle& principal_handle)
{
principal_handle_ = principal_handle;
}
#endif // USE_FAKE_MEDIA_STREAMS
protected:
SourceMediaStream *source_;
- TrackID track_id_;
+ const TrackID track_id_;
TrackTicks played_ticks_;
PrincipalHandle principal_handle_;
};
MediaPipelineReceive::MediaPipelineReceive(
const std::string& pc,
nsCOMPtr<nsIEventTarget> main_thread,
nsCOMPtr<nsIEventTarget> sts_thread,
@@ -2099,17 +2104,18 @@ MediaPipelineReceiveAudio::MediaPipeline
stream, media_stream_track_id, level, conduit,
rtp_transport, rtcp_transport, filter),
listener_(new PipelineListener(stream, numeric_track_id, conduit))
{}
void MediaPipelineReceiveAudio::DetachMedia()
{
ASSERT_ON_THREAD(main_thread_);
- if (stream_) {
+ if (stream_ && listener_) {
+ listener_->EndTrack();
stream_->RemoveListener(listener_);
stream_ = nullptr;
}
}
nsresult MediaPipelineReceiveAudio::Init() {
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(ML_DEBUG, __FUNCTION__);
@@ -2330,17 +2336,18 @@ void MediaPipelineReceiveVideo::DetachMe
{
ASSERT_ON_THREAD(main_thread_);
// stop generating video and thus stop invoking the PipelineRenderer
// and PipelineListener - the renderer has a raw ptr to the Pipeline to
// avoid cycles, and the render callbacks are invoked from a different
// thread so simple null-checks would cause TSAN bugs without locks.
static_cast<VideoSessionConduit*>(conduit_.get())->DetachRenderer();
- if (stream_) {
+ if (stream_ && listener_) {
+ listener_->EndTrack();
stream_->RemoveListener(listener_);
stream_ = nullptr;
}
}
nsresult MediaPipelineReceiveVideo::Init() {
ASSERT_ON_THREAD(main_thread_);
MOZ_MTLOG(ML_DEBUG, __FUNCTION__);