зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1604746 - Recreate the send track in the MTG of the provided track if they belong to different MTGs. r=padenot
In `MediaPipelineTransmit::SetTrack()` the provided `MediaStreamTrack` connects to the existing send-track. This step crashes if the two tracks belong to different MTGs. With this change, when the two tracks belong to different MTGs, the existing send-track is stopped and deleted and a new send-track is created in the same MTG with the provided `MediaStreamTrack`. Differential Revision: https://phabricator.services.mozilla.com/D57627 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cb4d2b4c0d
Коммит
59fb3dc5da
|
@ -1003,13 +1003,24 @@ nsresult MediaPipelineTransmit::SetTrack(RefPtr<MediaStreamTrack> aDomTrack) {
|
|||
mSendPort = nullptr;
|
||||
}
|
||||
|
||||
bool wasTransmitting = false;
|
||||
if (aDomTrack && mDomTrack && !aDomTrack->Ended() && !mDomTrack->Ended() &&
|
||||
aDomTrack->Graph() != mDomTrack->Graph() && mSendTrack) {
|
||||
// Recreate the send track if the new stream resides in different MTG.
|
||||
wasTransmitting = mTransmitting;
|
||||
Stop();
|
||||
mSendTrack->Destroy();
|
||||
mSendTrack = nullptr;
|
||||
}
|
||||
|
||||
mDomTrack = std::move(aDomTrack);
|
||||
SetDescription();
|
||||
|
||||
if (mDomTrack) {
|
||||
if (!mDomTrack->Ended()) {
|
||||
if (!mSendTrack) {
|
||||
// Create the send track only once; when the first live track is set.
|
||||
// Create the send track when the first live track is set or when the
|
||||
// new track resides in different MTG.
|
||||
SetSendTrack(mDomTrack->Graph()->CreateForwardedInputTrack(
|
||||
mDomTrack->GetTrack()->mType));
|
||||
}
|
||||
|
@ -1020,6 +1031,9 @@ nsresult MediaPipelineTransmit::SetTrack(RefPtr<MediaStreamTrack> aDomTrack) {
|
|||
mConverter->SetTrackEnabled(mDomTrack->Enabled());
|
||||
}
|
||||
}
|
||||
if (wasTransmitting) {
|
||||
Start();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче