2012-04-30 03:11:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef NSDOMMEDIASTREAM_H_
|
|
|
|
#define NSDOMMEDIASTREAM_H_
|
|
|
|
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-02-15 08:04:11 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2013-09-05 17:29:38 +00:00
|
|
|
#include "StreamBuffer.h"
|
2013-09-05 20:25:17 +00:00
|
|
|
#include "nsIDOMWindow.h"
|
2014-05-01 10:50:00 +00:00
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "mozilla/PeerIdentity.h"
|
2014-10-03 08:18:00 +00:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2014-12-17 17:03:34 +00:00
|
|
|
#include "mozilla/CORSMode.h"
|
2012-04-30 03:11:34 +00:00
|
|
|
|
2012-07-19 09:58:48 +00:00
|
|
|
// GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
|
|
|
|
// GetTickCount() and conflicts with NS_DECL_NSIDOMMEDIASTREAM, containing
|
|
|
|
// currentTime getter.
|
|
|
|
#ifdef GetCurrentTime
|
|
|
|
#undef GetCurrentTime
|
|
|
|
#endif
|
2013-02-15 08:04:11 +00:00
|
|
|
// X11 has a #define for CurrentTime. Unbelievable :-(.
|
2014-10-25 17:24:36 +00:00
|
|
|
// See dom/media/webaudio/AudioContext.h for more fun!
|
2013-02-15 08:04:11 +00:00
|
|
|
#ifdef CurrentTime
|
|
|
|
#undef CurrentTime
|
|
|
|
#endif
|
2012-07-19 09:58:48 +00:00
|
|
|
|
2013-02-15 08:01:58 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-09-08 22:17:00 +00:00
|
|
|
class DOMLocalMediaStream;
|
2013-02-15 08:04:11 +00:00
|
|
|
class MediaStream;
|
2014-09-08 22:17:00 +00:00
|
|
|
class MediaEngineSource;
|
2015-03-31 02:14:00 +00:00
|
|
|
class MediaStreamGraph;
|
2013-02-15 08:04:11 +00:00
|
|
|
|
2013-04-17 05:18:24 +00:00
|
|
|
namespace dom {
|
2013-05-21 19:17:47 +00:00
|
|
|
class AudioNode;
|
2013-04-17 05:18:24 +00:00
|
|
|
class MediaStreamTrack;
|
2013-04-17 05:18:37 +00:00
|
|
|
class AudioStreamTrack;
|
|
|
|
class VideoStreamTrack;
|
2014-05-23 09:34:14 +00:00
|
|
|
class AudioTrack;
|
|
|
|
class VideoTrack;
|
|
|
|
class AudioTrackList;
|
|
|
|
class VideoTrackList;
|
|
|
|
class MediaTrackListListener;
|
2013-04-17 05:18:24 +00:00
|
|
|
}
|
|
|
|
|
2013-08-24 13:53:11 +00:00
|
|
|
class MediaStreamDirectListener;
|
|
|
|
|
2014-10-03 08:18:00 +00:00
|
|
|
#define NS_DOMMEDIASTREAM_IID \
|
|
|
|
{ 0x8cb65468, 0x66c0, 0x444e, \
|
|
|
|
{ 0x89, 0x9f, 0x89, 0x1d, 0x9e, 0xd2, 0xbe, 0x7c } }
|
|
|
|
|
2012-04-30 03:11:34 +00:00
|
|
|
/**
|
|
|
|
* DOM wrapper for MediaStreams.
|
|
|
|
*/
|
2014-10-03 08:18:00 +00:00
|
|
|
class DOMMediaStream : public DOMEventTargetHelper
|
2012-04-30 03:11:34 +00:00
|
|
|
{
|
2013-02-15 08:01:58 +00:00
|
|
|
friend class DOMLocalMediaStream;
|
2013-04-17 05:18:24 +00:00
|
|
|
typedef dom::MediaStreamTrack MediaStreamTrack;
|
2013-04-17 05:18:37 +00:00
|
|
|
typedef dom::AudioStreamTrack AudioStreamTrack;
|
|
|
|
typedef dom::VideoStreamTrack VideoStreamTrack;
|
2014-05-23 09:34:14 +00:00
|
|
|
typedef dom::AudioTrack AudioTrack;
|
|
|
|
typedef dom::VideoTrack VideoTrack;
|
|
|
|
typedef dom::AudioTrackList AudioTrackList;
|
|
|
|
typedef dom::VideoTrackList VideoTrackList;
|
|
|
|
typedef dom::MediaTrackListListener MediaTrackListListener;
|
2012-04-30 03:11:34 +00:00
|
|
|
|
|
|
|
public:
|
2013-05-03 05:02:55 +00:00
|
|
|
typedef uint8_t TrackTypeHints;
|
|
|
|
|
2013-04-17 05:18:24 +00:00
|
|
|
DOMMediaStream();
|
2012-04-30 03:11:34 +00:00
|
|
|
|
2014-10-03 08:18:00 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMMediaStream,
|
|
|
|
DOMEventTargetHelper)
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOMMEDIASTREAM_IID)
|
2012-04-30 03:11:34 +00:00
|
|
|
|
2013-02-15 08:04:11 +00:00
|
|
|
nsIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mWindow;
|
|
|
|
}
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2012-04-30 03:11:34 +00:00
|
|
|
|
2013-04-17 05:18:37 +00:00
|
|
|
// WebIDL
|
2013-02-15 08:04:11 +00:00
|
|
|
double CurrentTime();
|
2013-07-24 10:11:35 +00:00
|
|
|
|
2015-02-05 16:03:00 +00:00
|
|
|
void GetId(nsAString& aID) const;
|
|
|
|
|
2013-04-17 05:18:37 +00:00
|
|
|
void GetAudioTracks(nsTArray<nsRefPtr<AudioStreamTrack> >& aTracks);
|
|
|
|
void GetVideoTracks(nsTArray<nsRefPtr<VideoStreamTrack> >& aTracks);
|
2014-08-14 01:40:54 +00:00
|
|
|
void GetTracks(nsTArray<nsRefPtr<MediaStreamTrack> >& aTracks);
|
|
|
|
bool HasTrack(const MediaStreamTrack& aTrack) const;
|
2013-04-17 05:18:37 +00:00
|
|
|
|
2013-07-24 10:11:35 +00:00
|
|
|
MediaStream* GetStream() const { return mStream; }
|
|
|
|
|
2013-08-24 13:53:11 +00:00
|
|
|
/**
|
|
|
|
* Overridden in DOMLocalMediaStreams to allow getUserMedia to pass
|
|
|
|
* data directly to RTCPeerConnection without going through graph queuing.
|
|
|
|
* Returns a bool to let us know if direct data will be delivered.
|
|
|
|
*/
|
|
|
|
virtual bool AddDirectListener(MediaStreamDirectListener *aListener) { return false; }
|
|
|
|
virtual void RemoveDirectListener(MediaStreamDirectListener *aListener) {}
|
|
|
|
|
2013-08-26 06:07:19 +00:00
|
|
|
/**
|
|
|
|
* Overridden in DOMLocalMediaStreams to allow getUserMedia to disable
|
|
|
|
* media at the SourceMediaStream.
|
|
|
|
*/
|
|
|
|
virtual void SetTrackEnabled(TrackID aTrackID, bool aEnabled);
|
|
|
|
|
2014-08-27 05:03:49 +00:00
|
|
|
virtual void StopTrack(TrackID aTrackID);
|
|
|
|
|
2014-09-08 22:17:00 +00:00
|
|
|
virtual DOMLocalMediaStream* AsDOMLocalMediaStream() { return nullptr; }
|
|
|
|
|
2013-02-15 08:04:11 +00:00
|
|
|
bool IsFinished();
|
2012-04-30 03:11:34 +00:00
|
|
|
/**
|
|
|
|
* Returns a principal indicating who may access this stream. The stream contents
|
|
|
|
* can only be accessed by principals subsuming this principal.
|
|
|
|
*/
|
|
|
|
nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
2014-12-17 17:03:34 +00:00
|
|
|
mozilla::CORSMode GetCORSMode();
|
|
|
|
void SetCORSMode(mozilla::CORSMode aCORSMode);
|
2012-04-30 03:11:34 +00:00
|
|
|
|
2014-05-01 10:50:00 +00:00
|
|
|
/**
|
|
|
|
* These are used in WebRTC. A peerIdentity constrained MediaStream cannot be sent
|
|
|
|
* across the network to anything other than a peer with the provided identity.
|
|
|
|
* If this is set, then mPrincipal should be an instance of nsNullPrincipal.
|
|
|
|
*/
|
|
|
|
PeerIdentity* GetPeerIdentity() const { return mPeerIdentity; }
|
|
|
|
void SetPeerIdentity(PeerIdentity* aPeerIdentity)
|
|
|
|
{
|
|
|
|
mPeerIdentity = aPeerIdentity;
|
|
|
|
}
|
|
|
|
|
2012-04-30 03:11:34 +00:00
|
|
|
/**
|
|
|
|
* Indicate that data will be contributed to this stream from origin aPrincipal.
|
|
|
|
* If aPrincipal is null, this is ignored. Otherwise, from now on the contents
|
|
|
|
* of this stream can only be accessed by principals that subsume aPrincipal.
|
|
|
|
* Returns true if the stream's principal changed.
|
|
|
|
*/
|
|
|
|
bool CombineWithPrincipal(nsIPrincipal* aPrincipal);
|
|
|
|
|
2014-05-01 10:50:00 +00:00
|
|
|
/**
|
|
|
|
* This is used in WebRTC to move from a protected state (nsNullPrincipal) to
|
|
|
|
* one where the stream is accessible to script. Don't call this.
|
|
|
|
* CombineWithPrincipal is almost certainly more appropriate.
|
|
|
|
*/
|
2014-04-25 14:30:00 +00:00
|
|
|
void SetPrincipal(nsIPrincipal* aPrincipal);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to learn about dynamic changes in principal occur.
|
|
|
|
* Operations relating to these observers must be confined to the main thread.
|
|
|
|
*/
|
|
|
|
class PrincipalChangeObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void PrincipalChanged(DOMMediaStream* aMediaStream) = 0;
|
|
|
|
};
|
|
|
|
bool AddPrincipalChangeObserver(PrincipalChangeObserver* aObserver);
|
|
|
|
bool RemovePrincipalChangeObserver(PrincipalChangeObserver* aObserver);
|
2014-05-01 10:50:00 +00:00
|
|
|
|
2012-04-30 03:11:40 +00:00
|
|
|
/**
|
2013-05-03 05:02:55 +00:00
|
|
|
* Called when this stream's MediaStreamGraph has been shut down. Normally
|
|
|
|
* MSGs are only shut down when all streams have been removed, so this
|
|
|
|
* will only be called during a forced shutdown due to application exit.
|
2012-04-30 03:11:40 +00:00
|
|
|
*/
|
2013-05-03 05:02:55 +00:00
|
|
|
void NotifyMediaStreamGraphShutdown();
|
2013-07-25 02:07:34 +00:00
|
|
|
/**
|
2015-05-11 14:07:24 +00:00
|
|
|
* Called when the main-thread state of the MediaStream goes to finished.
|
2013-07-25 02:07:34 +00:00
|
|
|
*/
|
2015-05-11 14:07:24 +00:00
|
|
|
void NotifyStreamFinished();
|
2012-10-07 05:34:30 +00:00
|
|
|
|
2015-02-19 17:59:00 +00:00
|
|
|
// Webrtc allows the remote side to name a stream whatever it wants, and we
|
|
|
|
// need to surface this to content.
|
|
|
|
void AssignId(const nsAString& aID) { mID = aID; }
|
|
|
|
|
2013-05-03 05:02:55 +00:00
|
|
|
/**
|
|
|
|
* Create an nsDOMMediaStream whose underlying stream is a SourceMediaStream.
|
|
|
|
*/
|
2015-03-31 02:14:00 +00:00
|
|
|
static already_AddRefed<DOMMediaStream> CreateSourceStream(nsIDOMWindow* aWindow,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
2012-04-30 03:11:40 +00:00
|
|
|
|
2012-07-31 12:17:22 +00:00
|
|
|
/**
|
|
|
|
* Create an nsDOMMediaStream whose underlying stream is a TrackUnionStream.
|
|
|
|
*/
|
2015-03-31 02:14:00 +00:00
|
|
|
static already_AddRefed<DOMMediaStream> CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
2012-07-31 12:17:22 +00:00
|
|
|
|
2013-05-03 05:07:37 +00:00
|
|
|
void SetLogicalStreamStartTime(StreamTime aTime)
|
|
|
|
{
|
|
|
|
mLogicalStreamStartTime = aTime;
|
|
|
|
}
|
|
|
|
|
2013-05-03 05:02:55 +00:00
|
|
|
// Notifications from StreamListener.
|
2014-10-13 03:13:36 +00:00
|
|
|
// BindDOMTrack should only be called when it's safe to run script.
|
|
|
|
MediaStreamTrack* BindDOMTrack(TrackID aTrackID, MediaSegment::Type aType);
|
2013-04-17 05:18:24 +00:00
|
|
|
MediaStreamTrack* CreateDOMTrack(TrackID aTrackID, MediaSegment::Type aType);
|
|
|
|
MediaStreamTrack* GetDOMTrackFor(TrackID aTrackID);
|
|
|
|
|
2013-05-03 05:02:55 +00:00
|
|
|
class OnTracksAvailableCallback {
|
|
|
|
public:
|
|
|
|
virtual ~OnTracksAvailableCallback() {}
|
|
|
|
virtual void NotifyTracksAvailable(DOMMediaStream* aStream) = 0;
|
|
|
|
};
|
2015-04-17 09:56:00 +00:00
|
|
|
// When the initial set of tracks has been added, run
|
|
|
|
// aCallback->NotifyTracksAvailable.
|
2013-05-03 05:02:55 +00:00
|
|
|
// It is allowed to do anything, including run script.
|
|
|
|
// aCallback may run immediately during this call if tracks are already
|
|
|
|
// available!
|
|
|
|
// We only care about track additions, we'll fire the notification even if
|
|
|
|
// some of the tracks have been removed.
|
|
|
|
// Takes ownership of aCallback.
|
|
|
|
void OnTracksAvailable(OnTracksAvailableCallback* aCallback);
|
|
|
|
|
2013-07-25 02:07:34 +00:00
|
|
|
/**
|
|
|
|
* Add an nsISupports object that this stream will keep alive as long as
|
|
|
|
* the stream is not finished.
|
|
|
|
*/
|
|
|
|
void AddConsumerToKeepAlive(nsISupports* aConsumer)
|
|
|
|
{
|
|
|
|
if (!IsFinished() && !mNotifiedOfMediaStreamGraphShutdown) {
|
|
|
|
mConsumersToKeepAlive.AppendElement(aConsumer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-23 09:34:14 +00:00
|
|
|
/**
|
|
|
|
* If loading and playing a MediaStream in a media element, for each
|
|
|
|
* MediaStreamTrack in the MediaStream, create a corresponding AudioTrack or
|
|
|
|
* VideoTrack during the phase of resource fetching.
|
|
|
|
*/
|
|
|
|
void ConstructMediaTracks(AudioTrackList* aAudioTrackList,
|
|
|
|
VideoTrackList* aVideoTrackList);
|
|
|
|
|
2014-10-03 21:29:29 +00:00
|
|
|
/**
|
|
|
|
* MUST call this before the AudioTrackList or VideoTrackList go away
|
|
|
|
*/
|
|
|
|
void DisconnectTrackListListeners(const AudioTrackList* aAudioTrackList,
|
|
|
|
const VideoTrackList* aVideoTrackList);
|
|
|
|
|
2014-08-27 05:03:50 +00:00
|
|
|
virtual void NotifyMediaStreamTrackCreated(MediaStreamTrack* aTrack);
|
2014-05-23 09:34:14 +00:00
|
|
|
|
2014-08-27 05:03:50 +00:00
|
|
|
virtual void NotifyMediaStreamTrackEnded(MediaStreamTrack* aTrack);
|
2014-05-23 09:34:14 +00:00
|
|
|
|
2012-04-30 03:11:34 +00:00
|
|
|
protected:
|
2014-06-24 16:36:43 +00:00
|
|
|
virtual ~DOMMediaStream();
|
|
|
|
|
2013-05-01 11:24:16 +00:00
|
|
|
void Destroy();
|
2015-03-31 02:14:00 +00:00
|
|
|
void InitSourceStream(nsIDOMWindow* aWindow,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
|
|
|
void InitTrackUnionStream(nsIDOMWindow* aWindow,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
2013-04-17 05:18:24 +00:00
|
|
|
void InitStreamCommon(MediaStream* aStream);
|
2014-05-23 09:34:14 +00:00
|
|
|
already_AddRefed<AudioTrack> CreateAudioTrack(AudioStreamTrack* aStreamTrack);
|
|
|
|
already_AddRefed<VideoTrack> CreateVideoTrack(VideoStreamTrack* aStreamTrack);
|
2013-11-22 20:14:29 +00:00
|
|
|
|
2015-02-06 09:38:11 +00:00
|
|
|
// Called when MediaStreamGraph has finished an iteration where tracks were
|
|
|
|
// created.
|
|
|
|
void TracksCreated();
|
|
|
|
|
2013-05-03 05:02:55 +00:00
|
|
|
void CheckTracksAvailable();
|
2013-04-17 05:18:24 +00:00
|
|
|
|
|
|
|
class StreamListener;
|
|
|
|
friend class StreamListener;
|
2013-02-15 08:04:11 +00:00
|
|
|
|
2013-05-03 05:07:37 +00:00
|
|
|
// StreamTime at which the currentTime attribute would return 0.
|
|
|
|
StreamTime mLogicalStreamStartTime;
|
|
|
|
|
2013-02-15 08:04:11 +00:00
|
|
|
// We need this to track our parent object.
|
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
2013-01-04 17:16:32 +00:00
|
|
|
|
2012-04-30 03:11:34 +00:00
|
|
|
// MediaStream is owned by the graph, but we tell it when to die, and it won't
|
|
|
|
// die until we let it.
|
|
|
|
MediaStream* mStream;
|
2012-10-07 05:34:30 +00:00
|
|
|
|
2013-04-17 05:18:24 +00:00
|
|
|
nsAutoTArray<nsRefPtr<MediaStreamTrack>,2> mTracks;
|
|
|
|
nsRefPtr<StreamListener> mListener;
|
|
|
|
|
2013-05-03 05:02:55 +00:00
|
|
|
nsTArray<nsAutoPtr<OnTracksAvailableCallback> > mRunOnTracksAvailable;
|
|
|
|
|
2015-02-06 09:38:11 +00:00
|
|
|
// Set to true after MediaStreamGraph has created tracks for mStream.
|
|
|
|
bool mTracksCreated;
|
|
|
|
|
2015-02-05 16:03:00 +00:00
|
|
|
nsString mID;
|
|
|
|
|
2013-07-25 02:07:34 +00:00
|
|
|
// Keep these alive until the stream finishes
|
|
|
|
nsTArray<nsCOMPtr<nsISupports> > mConsumersToKeepAlive;
|
|
|
|
|
2013-05-03 05:02:55 +00:00
|
|
|
bool mNotifiedOfMediaStreamGraphShutdown;
|
2014-04-25 14:30:00 +00:00
|
|
|
|
2014-05-23 09:34:14 +00:00
|
|
|
// Send notifications to AudioTrackList or VideoTrackList, if this MediaStream
|
|
|
|
// is consumed by a HTMLMediaElement.
|
|
|
|
nsTArray<MediaTrackListListener> mMediaTrackListListeners;
|
|
|
|
|
2014-04-25 14:30:00 +00:00
|
|
|
private:
|
|
|
|
void NotifyPrincipalChanged();
|
|
|
|
|
|
|
|
// Principal identifying who may access the contents of this stream.
|
|
|
|
// If null, this stream can be used by anyone because it has no content yet.
|
|
|
|
nsCOMPtr<nsIPrincipal> mPrincipal;
|
|
|
|
nsTArray<PrincipalChangeObserver*> mPrincipalChangeObservers;
|
|
|
|
// this is used in gUM and WebRTC to identify peers that this stream
|
|
|
|
// is allowed to be sent to
|
|
|
|
nsAutoPtr<PeerIdentity> mPeerIdentity;
|
2014-12-17 17:03:34 +00:00
|
|
|
CORSMode mCORSMode;
|
2012-04-30 03:11:34 +00:00
|
|
|
};
|
|
|
|
|
2014-10-03 08:18:00 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(DOMMediaStream,
|
|
|
|
NS_DOMMEDIASTREAM_IID)
|
|
|
|
|
|
|
|
#define NS_DOMLOCALMEDIASTREAM_IID \
|
|
|
|
{ 0xb1437260, 0xec61, 0x4dfa, \
|
|
|
|
{ 0x92, 0x54, 0x04, 0x44, 0xe2, 0xb5, 0x94, 0x9c } }
|
|
|
|
|
|
|
|
class DOMLocalMediaStream : public DOMMediaStream
|
2012-10-24 23:21:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-02-15 08:01:58 +00:00
|
|
|
DOMLocalMediaStream() {}
|
2012-10-24 23:21:32 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-10-03 08:18:00 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOMLOCALMEDIASTREAM_IID)
|
2012-10-24 23:21:32 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-15 08:04:11 +00:00
|
|
|
|
|
|
|
virtual void Stop();
|
2012-10-24 23:21:32 +00:00
|
|
|
|
2014-09-08 22:17:00 +00:00
|
|
|
virtual MediaEngineSource* GetMediaEngine(TrackID aTrackID) { return nullptr; }
|
|
|
|
|
2012-10-24 23:21:32 +00:00
|
|
|
/**
|
|
|
|
* Create an nsDOMLocalMediaStream whose underlying stream is a SourceMediaStream.
|
|
|
|
*/
|
2013-02-15 08:04:11 +00:00
|
|
|
static already_AddRefed<DOMLocalMediaStream>
|
2015-03-31 02:14:00 +00:00
|
|
|
CreateSourceStream(nsIDOMWindow* aWindow,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
2012-10-24 23:21:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an nsDOMLocalMediaStream whose underlying stream is a TrackUnionStream.
|
|
|
|
*/
|
2013-02-15 08:04:11 +00:00
|
|
|
static already_AddRefed<DOMLocalMediaStream>
|
2015-03-31 02:14:00 +00:00
|
|
|
CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
2014-07-08 21:23:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~DOMLocalMediaStream();
|
2012-10-24 23:21:32 +00:00
|
|
|
};
|
|
|
|
|
2014-10-03 08:18:00 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(DOMLocalMediaStream,
|
|
|
|
NS_DOMLOCALMEDIASTREAM_IID)
|
|
|
|
|
2013-05-21 19:17:47 +00:00
|
|
|
class DOMAudioNodeMediaStream : public DOMMediaStream
|
|
|
|
{
|
|
|
|
typedef dom::AudioNode AudioNode;
|
|
|
|
public:
|
2014-09-01 03:50:23 +00:00
|
|
|
explicit DOMAudioNodeMediaStream(AudioNode* aNode);
|
2013-05-21 19:17:47 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMAudioNodeMediaStream, DOMMediaStream)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a DOMAudioNodeMediaStream whose underlying stream is a TrackUnionStream.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<DOMAudioNodeMediaStream>
|
|
|
|
CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
2015-03-31 02:14:00 +00:00
|
|
|
AudioNode* aNode,
|
|
|
|
MediaStreamGraph* aGraph = nullptr);
|
2013-05-21 19:17:47 +00:00
|
|
|
|
2014-07-08 21:23:16 +00:00
|
|
|
protected:
|
|
|
|
~DOMAudioNodeMediaStream();
|
|
|
|
|
2013-05-21 19:17:47 +00:00
|
|
|
private:
|
|
|
|
// If this object wraps a stream owned by an AudioNode, we need to ensure that
|
|
|
|
// the node isn't cycle-collected too early.
|
|
|
|
nsRefPtr<AudioNode> mStreamNode;
|
|
|
|
};
|
|
|
|
|
2013-02-15 08:01:58 +00:00
|
|
|
}
|
|
|
|
|
2012-04-30 03:11:34 +00:00
|
|
|
#endif /* NSDOMMEDIASTREAM_H_ */
|