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

MozReview-Commit-ID: DtqzY5nIdPI

--HG--
extra : rebase_source : 2f8f2b5b141e4384555abd21de7fa823a9b34cf9
extra : source : f6a237afe9a83a8389a8e0a4f7435da3c4d0ca54
This commit is contained in:
Andreas Pehrson 2016-05-10 17:03:29 +02:00
Родитель 747b3ba5ed
Коммит df1fe74fee
3 изменённых файлов: 36 добавлений и 3 удалений

Просмотреть файл

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

Просмотреть файл

@ -265,9 +265,21 @@ 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; }
private:
/**
* The async runnable impl of NotifyEnded().
*/
void NotifyEndedImpl();
public:
/**
* Notified by the MediaStreamGraph, through our owning MediaStream on the
* main thread.
*/
void NotifyEnded();
/**
* Get this track's principal.

Просмотреть файл

@ -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 ();