mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1140089: Call SetPullEnabled on all streams in PCMedia when offer/answer concludes. r=jesup
--HG-- extra : rebase_source : 4fce2dc54b67a04b3d9836bfc05baeb000257f8b
This commit is contained in:
parent
dbdd24d84d
commit
662eee2c7e
@ -427,7 +427,7 @@ MediaPipelineFactory::CreateMediaPipelineReceiving(
|
||||
TrackID numericTrackId = stream->GetNumericTrackId(aTrack.GetTrackId());
|
||||
MOZ_ASSERT(numericTrackId != TRACK_INVALID);
|
||||
|
||||
bool queue_track = stream->QueueTracks();
|
||||
bool queue_track = stream->ShouldQueueTracks();
|
||||
|
||||
MOZ_MTLOG(ML_DEBUG, __FUNCTION__ << ": Creating pipeline for "
|
||||
<< numericTrackId << " -> " << aTrack.GetTrackId());
|
||||
@ -482,9 +482,6 @@ MediaPipelineFactory::CreateMediaPipelineReceiving(
|
||||
|
||||
stream->SyncPipeline(pipeline);
|
||||
|
||||
if (queue_track) {
|
||||
stream->TrackQueued(aTrack.GetTrackId());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -354,6 +354,10 @@ nsresult PeerConnectionMedia::UpdateMediaPipelines(
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& stream : mRemoteSourceStreams) {
|
||||
stream->StartReceiving();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1111,33 +1115,24 @@ RemoteSourceStreamInfo::SyncPipeline(
|
||||
}
|
||||
|
||||
void
|
||||
RemoteSourceStreamInfo::TrackQueued(const std::string& trackId)
|
||||
RemoteSourceStreamInfo::StartReceiving()
|
||||
{
|
||||
// When tracks start being queued we know the pipelines have been created.
|
||||
mPipelinesCreated = true;
|
||||
|
||||
MOZ_ASSERT(mTracksToQueue.count(trackId) > 0);
|
||||
mTracksToQueue.erase(trackId);
|
||||
|
||||
CSFLogDebug(logTag, "Queued adding of track id %d to MediaStream %p. "
|
||||
"%zu more tracks to queue.",
|
||||
GetNumericTrackId(trackId),
|
||||
GetMediaStream()->GetStream(),
|
||||
mTracksToQueue.size());
|
||||
|
||||
// If all tracks have been queued for this stream, finish adding them.
|
||||
if (mTracksToQueue.empty()) {
|
||||
SourceMediaStream* source = GetMediaStream()->GetStream()->AsSourceStream();
|
||||
source->FinishAddTracks();
|
||||
source->SetPullEnabled(true);
|
||||
// AdvanceKnownTracksTicksTime(HEAT_DEATH_OF_UNIVERSE) means that in
|
||||
// theory per the API, we can't add more tracks before that
|
||||
// time. However, the impl actually allows it, and it avoids a whole
|
||||
// bunch of locking that would be required (and potential blocking)
|
||||
// if we used smaller values and updated them on each NotifyPull.
|
||||
source->AdvanceKnownTracksTime(STREAM_TIME_MAX);
|
||||
CSFLogDebug(logTag, "Finished adding tracks to MediaStream %p", source);
|
||||
if (mReceiving || mPipelines.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mReceiving = true;
|
||||
|
||||
SourceMediaStream* source = GetMediaStream()->GetStream()->AsSourceStream();
|
||||
source->FinishAddTracks();
|
||||
source->SetPullEnabled(true);
|
||||
// AdvanceKnownTracksTicksTime(HEAT_DEATH_OF_UNIVERSE) means that in
|
||||
// theory per the API, we can't add more tracks before that
|
||||
// time. However, the impl actually allows it, and it avoids a whole
|
||||
// bunch of locking that would be required (and potential blocking)
|
||||
// if we used smaller values and updated them on each NotifyPull.
|
||||
source->AdvanceKnownTracksTime(STREAM_TIME_MAX);
|
||||
CSFLogDebug(logTag, "Finished adding tracks to MediaStream %p", source);
|
||||
}
|
||||
|
||||
RefPtr<MediaPipeline> SourceStreamInfo::GetPipelineByTrackId_m(
|
||||
|
@ -148,7 +148,7 @@ class RemoteSourceStreamInfo : public SourceStreamInfo {
|
||||
PeerConnectionMedia *aParent,
|
||||
const std::string& aId)
|
||||
: SourceStreamInfo(aMediaStream, aParent, aId),
|
||||
mPipelinesCreated(false)
|
||||
mReceiving(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -163,11 +163,6 @@ class RemoteSourceStreamInfo : public SourceStreamInfo {
|
||||
virtual void AddTrack(const std::string& track) MOZ_OVERRIDE
|
||||
{
|
||||
mTrackIdMap.push_back(track);
|
||||
MOZ_ASSERT(!mPipelinesCreated || mTracksToQueue.empty(),
|
||||
"Track added while waiting for existing tracks to be queued.");
|
||||
if (!mPipelinesCreated) {
|
||||
mTracksToQueue.insert(track);
|
||||
}
|
||||
SourceStreamInfo::AddTrack(track);
|
||||
}
|
||||
|
||||
@ -192,17 +187,17 @@ class RemoteSourceStreamInfo : public SourceStreamInfo {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void StartReceiving();
|
||||
|
||||
/**
|
||||
* Returns true if a |MediaPipeline| should be queueing its track instead of
|
||||
* adding it to the |SourceMediaStream| directly.
|
||||
*/
|
||||
bool QueueTracks() const
|
||||
bool ShouldQueueTracks() const
|
||||
{
|
||||
return !mPipelinesCreated || !mTracksToQueue.empty();
|
||||
return !mReceiving;
|
||||
}
|
||||
|
||||
void TrackQueued(const std::string& trackId);
|
||||
|
||||
private:
|
||||
// For remote streams, the MediaStreamGraph API forces us to select a
|
||||
// numeric track id before creation of the MediaStreamTrack, and does not
|
||||
@ -213,13 +208,9 @@ class RemoteSourceStreamInfo : public SourceStreamInfo {
|
||||
// and its dependencies can go away.
|
||||
std::vector<std::string> mTrackIdMap;
|
||||
|
||||
// When a remote stream gets created we need to add its initial set of tracks
|
||||
// atomically. Here we track which tracks we have created Pipelines for and
|
||||
// that will be queued later on.
|
||||
std::set<std::string> mTracksToQueue;
|
||||
|
||||
// True if we have finished creating the initial set of pipelines
|
||||
bool mPipelinesCreated;
|
||||
// True iff SetPullEnabled(true) has been called on the DOMMediaStream. This
|
||||
// happens when offer/answer concludes.
|
||||
bool mReceiving;
|
||||
};
|
||||
|
||||
class PeerConnectionMedia : public sigslot::has_slots<> {
|
||||
|
Loading…
Reference in New Issue
Block a user