Bug 1208373 - Implement MediaStreamTrack's "ended" event and onended EventHandler. r=smaug,jib

MozReview-Commit-ID: DtqzY5nIdPI

--HG--
extra : rebase_source : f6d4a868a22a86862a97da615dea1ca644a36cfd
extra : intermediate-source : 9a8c5a9bb9d5be0a1c3d27b3e4f99853188110f1
extra : source : f6a237afe9a83a8389a8e0a4f7435da3c4d0ca54
This commit is contained in:
Andreas Pehrson 2016-05-10 17:03:29 +02:00
parent a8541d33e1
commit eabd9f9fe1
3 changed files with 28 additions and 3 deletions

View File

@ -350,6 +350,22 @@ MediaStreamTrack::Clone()
return newStream->CloneDOMTrack(*this, mTrackID);
}
void
MediaStreamTrack::NotifyEnded()
{
MOZ_ASSERT(NS_IsMainThread());
if (mEnded) {
return;
}
LOG(LogLevel::Info, ("MediaStreamTrack %p ended", this));
mEnded = true;
DispatchTrustedEvent(NS_LITERAL_STRING("ended"));
}
DOMMediaStream*
MediaStreamTrack::GetInputDOMStream()
{

View File

@ -267,9 +267,18 @@ public:
ApplyConstraints(const dom::MediaTrackConstraints& aConstraints, ErrorResult &aRv);
already_AddRefed<MediaStreamTrack> Clone();
IMPL_EVENT_HANDLER(ended)
bool Ended() const { return mEnded; }
// Notifications from the MediaStreamGraph
void NotifyEnded() { mEnded = true; }
/**
* Notified by the MediaStreamGraph, through our owning MediaStream on the
* main thread.
*
* Note that this sets the track to ended and raises the "ended" event
* synchronously.
*/
void NotifyEnded();
/**
* Get this track's principal.

View File

@ -75,7 +75,7 @@ interface MediaStreamTrack : EventTarget {
// readonly attribute boolean _readonly;
// readonly attribute boolean remote;
// readonly attribute MediaStreamTrackState readyState;
// attribute EventHandler onended;
attribute EventHandler onended;
MediaStreamTrack clone ();
void stop ();
// MediaTrackCapabilities getCapabilities ();