зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1208373 - Implement MediaStreamTrack.readyState. r=smaug,jib
MozReview-Commit-ID: EoMaG0R3Dpp --HG-- extra : rebase_source : 47d0fedfc4701d2e629ba43b30b0a7fb95322660 extra : intermediate-source : 8cffa26910a860fafe49fd2c43e86ab4020e6cea extra : source : eb945c96027405effd2138a069eabd68f192f15c
This commit is contained in:
Родитель
eabd9f9fe1
Коммит
b69ab58f85
|
@ -1035,6 +1035,15 @@ DOMMediaStream::CloneDOMTrack(MediaStreamTrack& aTrack,
|
|||
NotifyTrackAdded(newTrack);
|
||||
|
||||
newTrack->SetEnabled(aTrack.Enabled());
|
||||
newTrack->SetReadyState(aTrack.ReadyState());
|
||||
|
||||
if (aTrack.Ended()) {
|
||||
// For extra suspenders, make sure that we don't forward data by mistake
|
||||
// to the clone when the original has already ended.
|
||||
RefPtr<Pledge<bool, nsresult>> blockingPledge =
|
||||
inputPort->BlockSourceTrackId(inputTrackID);
|
||||
Unused << blockingPledge;
|
||||
}
|
||||
|
||||
return newTrack.forget();
|
||||
}
|
||||
|
|
|
@ -115,7 +115,8 @@ MediaStreamTrack::MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID,
|
|||
: mOwningStream(aStream), mTrackID(aTrackID),
|
||||
mInputTrackID(aInputTrackID), mSource(aSource),
|
||||
mPrincipal(aSource->GetPrincipal()),
|
||||
mEnded(false), mEnabled(true), mRemote(aSource->IsRemote()), mStopped(false)
|
||||
mReadyState(MediaStreamTrackState::Live),
|
||||
mEnabled(true), mRemote(aSource->IsRemote())
|
||||
{
|
||||
|
||||
if (!gMediaStreamTrackLog) {
|
||||
|
@ -216,8 +217,8 @@ MediaStreamTrack::Stop()
|
|||
{
|
||||
LOG(LogLevel::Info, ("MediaStreamTrack %p Stop()", this));
|
||||
|
||||
if (mStopped) {
|
||||
LOG(LogLevel::Warning, ("MediaStreamTrack %p Already stopped", this));
|
||||
if (Ended()) {
|
||||
LOG(LogLevel::Warning, ("MediaStreamTrack %p Already ended", this));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -239,7 +240,7 @@ MediaStreamTrack::Stop()
|
|||
RefPtr<Pledge<bool>> p = port->BlockSourceTrackId(mInputTrackID);
|
||||
Unused << p;
|
||||
|
||||
mStopped = true;
|
||||
mReadyState = MediaStreamTrackState::Ended;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise>
|
||||
|
@ -355,13 +356,13 @@ MediaStreamTrack::NotifyEnded()
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mEnded) {
|
||||
if (Ended()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(LogLevel::Info, ("MediaStreamTrack %p ended", this));
|
||||
|
||||
mEnded = true;
|
||||
mReadyState = MediaStreamTrackState::Ended;
|
||||
|
||||
DispatchTrustedEvent(NS_LITERAL_STRING("ended"));
|
||||
}
|
||||
|
|
|
@ -266,10 +266,20 @@ public:
|
|||
already_AddRefed<Promise>
|
||||
ApplyConstraints(const dom::MediaTrackConstraints& aConstraints, ErrorResult &aRv);
|
||||
already_AddRefed<MediaStreamTrack> Clone();
|
||||
MediaStreamTrackState ReadyState() { return mReadyState; }
|
||||
|
||||
IMPL_EVENT_HANDLER(ended)
|
||||
|
||||
bool Ended() const { return mEnded; }
|
||||
/**
|
||||
* Convenience (and legacy) method for when ready state is "ended".
|
||||
*/
|
||||
bool Ended() const { return mReadyState == MediaStreamTrackState::Ended; }
|
||||
|
||||
/**
|
||||
* Forces the ready state to a particular value, for instance when we're
|
||||
* cloning an already ended track.
|
||||
*/
|
||||
void SetReadyState(MediaStreamTrackState aState) { mReadyState = aState; }
|
||||
|
||||
/**
|
||||
* Notified by the MediaStreamGraph, through our owning MediaStream on the
|
||||
|
@ -407,10 +417,9 @@ protected:
|
|||
nsCOMPtr<nsIPrincipal> mPendingPrincipal;
|
||||
RefPtr<PrincipalHandleListener> mPrincipalHandleListener;
|
||||
nsString mID;
|
||||
bool mEnded;
|
||||
MediaStreamTrackState mReadyState;
|
||||
bool mEnabled;
|
||||
const bool mRemote;
|
||||
bool mStopped;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -63,6 +63,11 @@ dictionary MediaTrackConstraints : MediaTrackConstraintSet {
|
|||
sequence<MediaTrackConstraintSet> advanced;
|
||||
};
|
||||
|
||||
enum MediaStreamTrackState {
|
||||
"live",
|
||||
"ended"
|
||||
};
|
||||
|
||||
[Exposed=Window]
|
||||
interface MediaStreamTrack : EventTarget {
|
||||
readonly attribute DOMString kind;
|
||||
|
@ -74,7 +79,7 @@ interface MediaStreamTrack : EventTarget {
|
|||
// attribute EventHandler onunmute;
|
||||
// readonly attribute boolean _readonly;
|
||||
// readonly attribute boolean remote;
|
||||
// readonly attribute MediaStreamTrackState readyState;
|
||||
readonly attribute MediaStreamTrackState readyState;
|
||||
attribute EventHandler onended;
|
||||
MediaStreamTrack clone ();
|
||||
void stop ();
|
||||
|
|
Загрузка…
Ссылка в новой задаче