зеркало из https://github.com/mozilla/gecko-dev.git
Bug 759908. Create MediaStreamListener::NotifyConsumptionChanged. r=jesup
--HG-- extra : rebase_source : f9479b836ec92170782eb01ea8b97004b057ceb7
This commit is contained in:
Родитель
45ed5414b5
Коммит
09176f2085
|
@ -205,6 +205,11 @@ public:
|
||||||
* will take effect.
|
* will take effect.
|
||||||
*/
|
*/
|
||||||
void ChooseActionTime();
|
void ChooseActionTime();
|
||||||
|
/**
|
||||||
|
* Update the consumption state of aStream to reflect whether its data
|
||||||
|
* is needed or not.
|
||||||
|
*/
|
||||||
|
void UpdateConsumptionState(SourceMediaStream* aStream);
|
||||||
/**
|
/**
|
||||||
* Extract any state updates pending in aStream, and apply them.
|
* Extract any state updates pending in aStream, and apply them.
|
||||||
*/
|
*/
|
||||||
|
@ -612,6 +617,22 @@ MediaStreamGraphImpl::ChooseActionTime()
|
||||||
mLastActionTime = GetEarliestActionTime();
|
mLastActionTime = GetEarliestActionTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaStreamGraphImpl::UpdateConsumptionState(SourceMediaStream* aStream)
|
||||||
|
{
|
||||||
|
bool isConsumed = !aStream->mAudioOutputs.IsEmpty() ||
|
||||||
|
!aStream->mVideoOutputs.IsEmpty();
|
||||||
|
MediaStreamListener::Consumption state = isConsumed ? MediaStreamListener::CONSUMED
|
||||||
|
: MediaStreamListener::NOT_CONSUMED;
|
||||||
|
if (state != aStream->mLastConsumptionState) {
|
||||||
|
aStream->mLastConsumptionState = state;
|
||||||
|
for (PRUint32 j = 0; j < aStream->mListeners.Length(); ++j) {
|
||||||
|
MediaStreamListener* l = aStream->mListeners[j];
|
||||||
|
l->NotifyConsumptionChanged(this, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream)
|
MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream)
|
||||||
{
|
{
|
||||||
|
@ -1267,6 +1288,7 @@ MediaStreamGraphImpl::RunThread()
|
||||||
for (PRUint32 i = 0; i < mStreams.Length(); ++i) {
|
for (PRUint32 i = 0; i < mStreams.Length(); ++i) {
|
||||||
SourceMediaStream* is = mStreams[i]->AsSourceStream();
|
SourceMediaStream* is = mStreams[i]->AsSourceStream();
|
||||||
if (is) {
|
if (is) {
|
||||||
|
UpdateConsumptionState(is);
|
||||||
ExtractPendingInput(is);
|
ExtractPendingInput(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,12 +94,24 @@ public:
|
||||||
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStreamListener)
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaStreamListener)
|
||||||
|
|
||||||
|
enum Consumption {
|
||||||
|
CONSUMED,
|
||||||
|
NOT_CONSUMED
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Notify that the stream is hooked up and we'd like to start or stop receiving
|
||||||
|
* data on it. Only fires on SourceMediaStreams.
|
||||||
|
* The initial state is assumed to be NOT_CONSUMED.
|
||||||
|
*/
|
||||||
|
virtual void NotifyConsumptionChanged(MediaStreamGraph* aGraph, Consumption aConsuming) {}
|
||||||
|
|
||||||
enum Blocking {
|
enum Blocking {
|
||||||
BLOCKED,
|
BLOCKED,
|
||||||
UNBLOCKED
|
UNBLOCKED
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Notify that the blocking status of the stream changed.
|
* Notify that the blocking status of the stream changed. The initial state
|
||||||
|
* is assumed to be BLOCKED.
|
||||||
*/
|
*/
|
||||||
virtual void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) {}
|
virtual void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) {}
|
||||||
|
|
||||||
|
@ -371,8 +383,11 @@ protected:
|
||||||
class SourceMediaStream : public MediaStream {
|
class SourceMediaStream : public MediaStream {
|
||||||
public:
|
public:
|
||||||
SourceMediaStream(nsDOMMediaStream* aWrapper) :
|
SourceMediaStream(nsDOMMediaStream* aWrapper) :
|
||||||
MediaStream(aWrapper), mMutex("mozilla::media::SourceMediaStream"),
|
MediaStream(aWrapper),
|
||||||
mUpdateKnownTracksTime(0), mUpdateFinished(false), mDestroyed(false)
|
mLastConsumptionState(MediaStreamListener::NOT_CONSUMED),
|
||||||
|
mMutex("mozilla::media::SourceMediaStream"),
|
||||||
|
mUpdateKnownTracksTime(0),
|
||||||
|
mUpdateFinished(false), mDestroyed(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual SourceMediaStream* AsSourceStream() { return this; }
|
virtual SourceMediaStream* AsSourceStream() { return this; }
|
||||||
|
@ -471,6 +486,9 @@ protected:
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Media stream graph thread only
|
||||||
|
MediaStreamListener::Consumption mLastConsumptionState;
|
||||||
|
|
||||||
// This must be acquired *before* MediaStreamGraphImpl's lock, if they are
|
// This must be acquired *before* MediaStreamGraphImpl's lock, if they are
|
||||||
// held together.
|
// held together.
|
||||||
Mutex mMutex;
|
Mutex mMutex;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче