2012-05-11 21:35:36 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
2012-04-30 07:11:34 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-02-15 12:01:58 +04:00
|
|
|
#include "DOMMediaStream.h"
|
2012-04-30 07:11:34 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-02-15 12:04:11 +04:00
|
|
|
#include "mozilla/dom/MediaStreamBinding.h"
|
|
|
|
#include "mozilla/dom/LocalMediaStreamBinding.h"
|
2013-05-21 23:17:47 +04:00
|
|
|
#include "mozilla/dom/AudioNode.h"
|
2013-02-15 12:04:11 +04:00
|
|
|
#include "MediaStreamGraph.h"
|
2013-04-17 09:18:24 +04:00
|
|
|
#include "AudioStreamTrack.h"
|
|
|
|
#include "VideoStreamTrack.h"
|
2012-04-30 07:11:34 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2013-04-17 09:18:24 +04:00
|
|
|
using namespace mozilla::dom;
|
2012-04-30 07:11:34 +04:00
|
|
|
|
2013-02-15 12:01:58 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMMediaStream)
|
2013-02-15 12:04:11 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2012-04-30 07:11:34 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMMediaStream)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-02-15 12:01:58 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMMediaStream)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMMediaStream)
|
2013-08-02 05:29:05 +04:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMediaStream)
|
|
|
|
|
2013-05-01 15:24:16 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMMediaStream)
|
|
|
|
tmp->Destroy();
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTracks)
|
2013-07-25 06:07:34 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mConsumersToKeepAlive)
|
2013-05-01 15:24:16 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMMediaStream)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTracks)
|
2013-07-25 06:07:34 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConsumersToKeepAlive)
|
2013-05-01 15:24:16 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(DOMMediaStream)
|
2012-10-25 03:21:32 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(DOMLocalMediaStream, DOMMediaStream,
|
|
|
|
nsIDOMLocalMediaStream)
|
2012-10-25 03:21:32 +04:00
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(DOMAudioNodeMediaStream, DOMMediaStream,
|
|
|
|
mStreamNode)
|
2013-05-21 23:17:47 +04:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(DOMAudioNodeMediaStream, DOMMediaStream)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(DOMAudioNodeMediaStream, DOMMediaStream)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMAudioNodeMediaStream)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream)
|
|
|
|
|
2013-04-17 09:18:24 +04:00
|
|
|
class DOMMediaStream::StreamListener : public MediaStreamListener {
|
|
|
|
public:
|
|
|
|
StreamListener(DOMMediaStream* aStream)
|
|
|
|
: mStream(aStream)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// Main thread only
|
|
|
|
void Forget() { mStream = nullptr; }
|
|
|
|
DOMMediaStream* GetStream() { return mStream; }
|
|
|
|
|
|
|
|
class TrackChange : public nsRunnable {
|
|
|
|
public:
|
|
|
|
TrackChange(StreamListener* aListener,
|
|
|
|
TrackID aID, TrackTicks aTrackOffset,
|
|
|
|
uint32_t aEvents, MediaSegment::Type aType)
|
|
|
|
: mListener(aListener), mID(aID), mEvents(aEvents), mType(aType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "main thread only");
|
|
|
|
|
|
|
|
DOMMediaStream* stream = mListener->GetStream();
|
|
|
|
if (!stream) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<MediaStreamTrack> track;
|
|
|
|
if (mEvents & MediaStreamListener::TRACK_EVENT_CREATED) {
|
|
|
|
track = stream->CreateDOMTrack(mID, mType);
|
|
|
|
} else {
|
|
|
|
track = stream->GetDOMTrackFor(mID);
|
|
|
|
}
|
|
|
|
if (mEvents & MediaStreamListener::TRACK_EVENT_ENDED) {
|
|
|
|
track->NotifyEnded();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
StreamTime mEndTime;
|
|
|
|
nsRefPtr<StreamListener> mListener;
|
|
|
|
TrackID mID;
|
|
|
|
uint32_t mEvents;
|
|
|
|
MediaSegment::Type mType;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify that changes to one of the stream tracks have been queued.
|
|
|
|
* aTrackEvents can be any combination of TRACK_EVENT_CREATED and
|
|
|
|
* TRACK_EVENT_ENDED. aQueuedMedia is the data being added to the track
|
|
|
|
* at aTrackOffset (relative to the start of the stream).
|
|
|
|
* aQueuedMedia can be null if there is no output.
|
|
|
|
*/
|
|
|
|
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
|
|
|
TrackRate aTrackRate,
|
|
|
|
TrackTicks aTrackOffset,
|
|
|
|
uint32_t aTrackEvents,
|
2013-05-30 08:44:40 +04:00
|
|
|
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE
|
2013-04-17 09:18:24 +04:00
|
|
|
{
|
|
|
|
if (aTrackEvents & (TRACK_EVENT_CREATED | TRACK_EVENT_ENDED)) {
|
|
|
|
nsRefPtr<TrackChange> runnable =
|
|
|
|
new TrackChange(this, aID, aTrackOffset, aTrackEvents,
|
|
|
|
aQueuedMedia.GetType());
|
|
|
|
NS_DispatchToMainThread(runnable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// These fields may only be accessed on the main thread
|
|
|
|
DOMMediaStream* mStream;
|
|
|
|
};
|
|
|
|
|
|
|
|
DOMMediaStream::DOMMediaStream()
|
2013-05-03 09:07:37 +04:00
|
|
|
: mLogicalStreamStartTime(0),
|
|
|
|
mStream(nullptr), mHintContents(0), mTrackTypesAvailable(0),
|
2013-05-03 09:02:55 +04:00
|
|
|
mNotifiedOfMediaStreamGraphShutdown(false)
|
2013-04-17 09:18:24 +04:00
|
|
|
{
|
|
|
|
SetIsDOMBinding();
|
|
|
|
}
|
|
|
|
|
2013-02-15 12:01:58 +04:00
|
|
|
DOMMediaStream::~DOMMediaStream()
|
2013-05-01 15:24:16 +04:00
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::Destroy()
|
2012-04-30 07:11:34 +04:00
|
|
|
{
|
2013-04-17 09:18:24 +04:00
|
|
|
if (mListener) {
|
|
|
|
mListener->Forget();
|
2013-05-01 15:24:16 +04:00
|
|
|
mListener = nullptr;
|
2013-04-17 09:18:24 +04:00
|
|
|
}
|
2012-04-30 07:11:34 +04:00
|
|
|
if (mStream) {
|
|
|
|
mStream->Destroy();
|
2013-05-01 15:24:16 +04:00
|
|
|
mStream = nullptr;
|
2012-04-30 07:11:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
DOMMediaStream::WrapObject(JSContext* aCx)
|
2012-04-30 07:11:34 +04:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-09 02:27:17 +04:00
|
|
|
return dom::MediaStreamBinding::Wrap(aCx, this);
|
2012-04-30 07:11:34 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
double
|
|
|
|
DOMMediaStream::CurrentTime()
|
2013-01-07 06:31:34 +04:00
|
|
|
{
|
2013-05-03 09:07:37 +04:00
|
|
|
if (!mStream) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
return MediaTimeToSeconds(mStream->GetCurrentTime() - mLogicalStreamStartTime);
|
2013-01-07 06:31:34 +04:00
|
|
|
}
|
|
|
|
|
2013-04-17 09:18:37 +04:00
|
|
|
void
|
|
|
|
DOMMediaStream::GetAudioTracks(nsTArray<nsRefPtr<AudioStreamTrack> >& aTracks)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
|
|
|
|
AudioStreamTrack* t = mTracks[i]->AsAudioStreamTrack();
|
|
|
|
if (t) {
|
|
|
|
aTracks.AppendElement(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::GetVideoTracks(nsTArray<nsRefPtr<VideoStreamTrack> >& aTracks)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
|
|
|
|
VideoStreamTrack* t = mTracks[i]->AsVideoStreamTrack();
|
|
|
|
if (t) {
|
|
|
|
aTracks.AppendElement(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
bool
|
|
|
|
DOMMediaStream::IsFinished()
|
2012-10-25 03:21:32 +04:00
|
|
|
{
|
2013-02-15 12:04:11 +04:00
|
|
|
return !mStream || mStream->IsFinished();
|
2012-10-25 03:21:32 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
void
|
2013-05-03 09:02:55 +04:00
|
|
|
DOMMediaStream::InitSourceStream(nsIDOMWindow* aWindow, TrackTypeHints aHintContents)
|
2012-04-30 07:11:40 +04:00
|
|
|
{
|
2013-02-15 12:04:11 +04:00
|
|
|
mWindow = aWindow;
|
|
|
|
SetHintContents(aHintContents);
|
|
|
|
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
2013-04-17 09:18:24 +04:00
|
|
|
InitStreamCommon(gm->CreateSourceStream(this));
|
2012-04-30 07:11:40 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
void
|
2013-05-03 09:02:55 +04:00
|
|
|
DOMMediaStream::InitTrackUnionStream(nsIDOMWindow* aWindow, TrackTypeHints aHintContents)
|
2012-10-25 03:21:32 +04:00
|
|
|
{
|
2013-02-15 12:04:11 +04:00
|
|
|
mWindow = aWindow;
|
|
|
|
SetHintContents(aHintContents);
|
|
|
|
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
2013-04-17 09:18:24 +04:00
|
|
|
InitStreamCommon(gm->CreateTrackUnionStream(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::InitStreamCommon(MediaStream* aStream)
|
|
|
|
{
|
|
|
|
mStream = aStream;
|
|
|
|
|
|
|
|
// Setup track listener
|
|
|
|
mListener = new StreamListener(this);
|
|
|
|
aStream->AddListener(mListener);
|
2012-10-25 03:21:32 +04:00
|
|
|
}
|
|
|
|
|
2013-02-15 12:01:58 +04:00
|
|
|
already_AddRefed<DOMMediaStream>
|
2013-05-03 09:02:55 +04:00
|
|
|
DOMMediaStream::CreateSourceStream(nsIDOMWindow* aWindow, TrackTypeHints aHintContents)
|
2012-07-31 16:17:22 +04:00
|
|
|
{
|
2013-02-15 12:01:58 +04:00
|
|
|
nsRefPtr<DOMMediaStream> stream = new DOMMediaStream();
|
2013-02-15 12:04:11 +04:00
|
|
|
stream->InitSourceStream(aWindow, aHintContents);
|
2012-07-31 16:17:22 +04:00
|
|
|
return stream.forget();
|
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
already_AddRefed<DOMMediaStream>
|
2013-05-03 09:02:55 +04:00
|
|
|
DOMMediaStream::CreateTrackUnionStream(nsIDOMWindow* aWindow, TrackTypeHints aHintContents)
|
2012-10-25 03:21:32 +04:00
|
|
|
{
|
2013-02-15 12:04:11 +04:00
|
|
|
nsRefPtr<DOMMediaStream> stream = new DOMMediaStream();
|
|
|
|
stream->InitTrackUnionStream(aWindow, aHintContents);
|
2012-10-25 03:21:32 +04:00
|
|
|
return stream.forget();
|
|
|
|
}
|
|
|
|
|
2013-08-26 10:07:19 +04:00
|
|
|
void
|
|
|
|
DOMMediaStream::SetTrackEnabled(TrackID aTrackID, bool aEnabled)
|
|
|
|
{
|
|
|
|
if (mStream) {
|
|
|
|
mStream->SetTrackEnabled(aTrackID, aEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-30 07:11:34 +04:00
|
|
|
bool
|
2013-02-15 12:01:58 +04:00
|
|
|
DOMMediaStream::CombineWithPrincipal(nsIPrincipal* aPrincipal)
|
2012-04-30 07:11:34 +04:00
|
|
|
{
|
2014-04-25 18:30:00 +04:00
|
|
|
bool changed =
|
|
|
|
nsContentUtils::CombineResourcePrincipals(&mPrincipal, aPrincipal);
|
|
|
|
if (changed) {
|
|
|
|
NotifyPrincipalChanged();
|
|
|
|
}
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::SetPrincipal(nsIPrincipal* aPrincipal)
|
|
|
|
{
|
|
|
|
mPrincipal = aPrincipal;
|
|
|
|
NotifyPrincipalChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::NotifyPrincipalChanged()
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mPrincipalChangeObservers.Length(); ++i) {
|
|
|
|
mPrincipalChangeObservers[i]->PrincipalChanged(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
DOMMediaStream::AddPrincipalChangeObserver(PrincipalChangeObserver* aObserver)
|
|
|
|
{
|
|
|
|
return mPrincipalChangeObservers.AppendElement(aObserver) != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
DOMMediaStream::RemovePrincipalChangeObserver(PrincipalChangeObserver* aObserver)
|
|
|
|
{
|
|
|
|
return mPrincipalChangeObservers.RemoveElement(aObserver);
|
2012-04-30 07:11:34 +04:00
|
|
|
}
|
2013-02-15 12:04:11 +04:00
|
|
|
|
2013-04-17 09:18:24 +04:00
|
|
|
MediaStreamTrack*
|
|
|
|
DOMMediaStream::CreateDOMTrack(TrackID aTrackID, MediaSegment::Type aType)
|
|
|
|
{
|
|
|
|
MediaStreamTrack* track;
|
|
|
|
switch (aType) {
|
|
|
|
case MediaSegment::AUDIO:
|
|
|
|
track = new AudioStreamTrack(this, aTrackID);
|
2013-05-03 09:02:55 +04:00
|
|
|
mTrackTypesAvailable |= HINT_CONTENTS_AUDIO;
|
2013-04-17 09:18:24 +04:00
|
|
|
break;
|
|
|
|
case MediaSegment::VIDEO:
|
|
|
|
track = new VideoStreamTrack(this, aTrackID);
|
2013-05-03 09:02:55 +04:00
|
|
|
mTrackTypesAvailable |= HINT_CONTENTS_VIDEO;
|
2013-04-17 09:18:24 +04:00
|
|
|
break;
|
|
|
|
default:
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("Unhandled track type");
|
2013-04-17 09:18:24 +04:00
|
|
|
}
|
2013-05-05 13:51:47 +04:00
|
|
|
mTracks.AppendElement(track);
|
2013-05-03 09:02:55 +04:00
|
|
|
|
|
|
|
CheckTracksAvailable();
|
|
|
|
|
2013-04-17 09:18:24 +04:00
|
|
|
return track;
|
|
|
|
}
|
|
|
|
|
|
|
|
MediaStreamTrack*
|
|
|
|
DOMMediaStream::GetDOMTrackFor(TrackID aTrackID)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < mTracks.Length(); ++i) {
|
|
|
|
MediaStreamTrack* t = mTracks[i];
|
|
|
|
// We may add streams to our track list that are actually owned by
|
|
|
|
// a different DOMMediaStream. Ignore those.
|
|
|
|
if (t->GetTrackID() == aTrackID && t->GetStream() == this) {
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-05-03 09:02:55 +04:00
|
|
|
void
|
|
|
|
DOMMediaStream::NotifyMediaStreamGraphShutdown()
|
|
|
|
{
|
|
|
|
// No more tracks will ever be added, so just clear these callbacks now
|
|
|
|
// to prevent leaks.
|
|
|
|
mNotifiedOfMediaStreamGraphShutdown = true;
|
|
|
|
mRunOnTracksAvailable.Clear();
|
2013-07-25 06:07:34 +04:00
|
|
|
|
|
|
|
mConsumersToKeepAlive.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::NotifyStreamStateChanged()
|
|
|
|
{
|
|
|
|
if (IsFinished()) {
|
|
|
|
mConsumersToKeepAlive.Clear();
|
|
|
|
}
|
2013-05-03 09:02:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::OnTracksAvailable(OnTracksAvailableCallback* aRunnable)
|
|
|
|
{
|
|
|
|
if (mNotifiedOfMediaStreamGraphShutdown) {
|
|
|
|
// No more tracks will ever be added, so just delete the callback now.
|
|
|
|
delete aRunnable;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mRunOnTracksAvailable.AppendElement(aRunnable);
|
|
|
|
CheckTracksAvailable();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMMediaStream::CheckTracksAvailable()
|
|
|
|
{
|
2013-11-23 00:14:29 +04:00
|
|
|
if (mTrackTypesAvailable == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2013-05-03 09:02:55 +04:00
|
|
|
nsTArray<nsAutoPtr<OnTracksAvailableCallback> > callbacks;
|
|
|
|
callbacks.SwapElements(mRunOnTracksAvailable);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < callbacks.Length(); ++i) {
|
|
|
|
OnTracksAvailableCallback* cb = callbacks[i];
|
|
|
|
if (~mTrackTypesAvailable & cb->GetExpectedTracks()) {
|
|
|
|
// Some expected tracks not available yet. Try this callback again later.
|
|
|
|
*mRunOnTracksAvailable.AppendElement() = callbacks[i].forget();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cb->NotifyTracksAvailable(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-15 12:04:11 +04:00
|
|
|
DOMLocalMediaStream::~DOMLocalMediaStream()
|
|
|
|
{
|
|
|
|
if (mStream) {
|
|
|
|
// Make sure Listeners of this stream know it's going away
|
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-09 02:27:18 +04:00
|
|
|
DOMLocalMediaStream::WrapObject(JSContext* aCx)
|
2013-02-15 12:04:11 +04:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-09 02:27:17 +04:00
|
|
|
return dom::LocalMediaStreamBinding::Wrap(aCx, this);
|
2013-02-15 12:04:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DOMLocalMediaStream::Stop()
|
|
|
|
{
|
|
|
|
if (mStream && mStream->AsSourceStream()) {
|
|
|
|
mStream->AsSourceStream()->EndAllTrackAndFinish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMLocalMediaStream>
|
2013-05-03 09:02:55 +04:00
|
|
|
DOMLocalMediaStream::CreateSourceStream(nsIDOMWindow* aWindow,
|
|
|
|
TrackTypeHints aHintContents)
|
2013-02-15 12:04:11 +04:00
|
|
|
{
|
|
|
|
nsRefPtr<DOMLocalMediaStream> stream = new DOMLocalMediaStream();
|
|
|
|
stream->InitSourceStream(aWindow, aHintContents);
|
|
|
|
return stream.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMLocalMediaStream>
|
2013-05-03 09:02:55 +04:00
|
|
|
DOMLocalMediaStream::CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
|
|
|
TrackTypeHints aHintContents)
|
2013-02-15 12:04:11 +04:00
|
|
|
{
|
|
|
|
nsRefPtr<DOMLocalMediaStream> stream = new DOMLocalMediaStream();
|
|
|
|
stream->InitTrackUnionStream(aWindow, aHintContents);
|
|
|
|
return stream.forget();
|
|
|
|
}
|
2013-05-21 23:17:47 +04:00
|
|
|
|
|
|
|
DOMAudioNodeMediaStream::DOMAudioNodeMediaStream(AudioNode* aNode)
|
|
|
|
: mStreamNode(aNode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMAudioNodeMediaStream>
|
|
|
|
DOMAudioNodeMediaStream::CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
|
|
|
AudioNode* aNode,
|
|
|
|
TrackTypeHints aHintContents)
|
|
|
|
{
|
|
|
|
nsRefPtr<DOMAudioNodeMediaStream> stream = new DOMAudioNodeMediaStream(aNode);
|
|
|
|
stream->InitTrackUnionStream(aWindow, aHintContents);
|
|
|
|
return stream.forget();
|
|
|
|
}
|