mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 1286096 - Move AllocationHandle used for cameras to MediaEngineSource base class to reuse for microphones. r=padenot
MozReview-Commit-ID: BcmlKnHhe0o --HG-- extra : rebase_source : 45342801548033ddbb2c0e060a6c6685bcb910b9
This commit is contained in:
parent
2982c3ee86
commit
9f23bcc615
@ -96,7 +96,7 @@ protected:
|
|||||||
nsString mID;
|
nsString mID;
|
||||||
dom::MediaSourceEnum mMediaSource;
|
dom::MediaSourceEnum mMediaSource;
|
||||||
RefPtr<MediaEngineSource> mSource;
|
RefPtr<MediaEngineSource> mSource;
|
||||||
RefPtr<MediaEngineSource::BaseAllocationHandle> mAllocationHandle;
|
RefPtr<MediaEngineSource::AllocationHandle> mAllocationHandle;
|
||||||
public:
|
public:
|
||||||
dom::MediaSourceEnum GetMediaSource() {
|
dom::MediaSourceEnum GetMediaSource() {
|
||||||
return mMediaSource;
|
return mMediaSource;
|
||||||
|
@ -32,7 +32,6 @@ enum {
|
|||||||
*/
|
*/
|
||||||
class MediaEngineVideoSource;
|
class MediaEngineVideoSource;
|
||||||
class MediaEngineAudioSource;
|
class MediaEngineAudioSource;
|
||||||
class MediaEnginePrefs;
|
|
||||||
|
|
||||||
enum MediaEngineState {
|
enum MediaEngineState {
|
||||||
kAllocated,
|
kAllocated,
|
||||||
@ -79,148 +78,6 @@ protected:
|
|||||||
virtual ~MediaEngine() {}
|
virtual ~MediaEngine() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback interface for TakePhoto(). Either PhotoComplete() or PhotoError()
|
|
||||||
* should be called.
|
|
||||||
*/
|
|
||||||
class MediaEnginePhotoCallback {
|
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaEnginePhotoCallback)
|
|
||||||
|
|
||||||
// aBlob is the image captured by MediaEngineSource. It is
|
|
||||||
// called on main thread.
|
|
||||||
virtual nsresult PhotoComplete(already_AddRefed<dom::Blob> aBlob) = 0;
|
|
||||||
|
|
||||||
// It is called on main thread. aRv is the error code.
|
|
||||||
virtual nsresult PhotoError(nsresult aRv) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual ~MediaEnginePhotoCallback() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Common abstract base class for audio and video sources.
|
|
||||||
*/
|
|
||||||
class MediaEngineSource : public nsISupports
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// code inside webrtc.org assumes these sizes; don't use anything smaller
|
|
||||||
// without verifying it's ok
|
|
||||||
static const unsigned int kMaxDeviceNameLength = 128;
|
|
||||||
static const unsigned int kMaxUniqueIdLength = 256;
|
|
||||||
|
|
||||||
virtual ~MediaEngineSource() {}
|
|
||||||
|
|
||||||
virtual void Shutdown() = 0;
|
|
||||||
|
|
||||||
/* Populate the human readable name of this device in the nsAString */
|
|
||||||
virtual void GetName(nsAString&) const = 0;
|
|
||||||
|
|
||||||
/* Populate the UUID of this device in the nsACString */
|
|
||||||
virtual void GetUUID(nsACString&) const = 0;
|
|
||||||
|
|
||||||
class BaseAllocationHandle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(BaseAllocationHandle);
|
|
||||||
protected:
|
|
||||||
virtual ~BaseAllocationHandle() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Release the device back to the system. */
|
|
||||||
virtual nsresult Deallocate(BaseAllocationHandle* aHandle) = 0;
|
|
||||||
|
|
||||||
/* Start the device and add the track to the provided SourceMediaStream, with
|
|
||||||
* the provided TrackID. You may start appending data to the track
|
|
||||||
* immediately after. */
|
|
||||||
virtual nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) = 0;
|
|
||||||
|
|
||||||
/* tell the source if there are any direct listeners attached */
|
|
||||||
virtual void SetDirectListeners(bool) = 0;
|
|
||||||
|
|
||||||
/* Called when the stream wants more data */
|
|
||||||
virtual void NotifyPull(MediaStreamGraph* aGraph,
|
|
||||||
SourceMediaStream *aSource,
|
|
||||||
TrackID aId,
|
|
||||||
StreamTime aDesiredTime,
|
|
||||||
const PrincipalHandle& aPrincipalHandle) = 0;
|
|
||||||
|
|
||||||
/* Stop the device and release the corresponding MediaStream */
|
|
||||||
virtual nsresult Stop(SourceMediaStream *aSource, TrackID aID) = 0;
|
|
||||||
|
|
||||||
/* Restart with new capability */
|
|
||||||
virtual nsresult Restart(BaseAllocationHandle* aHandle,
|
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
|
||||||
const MediaEnginePrefs &aPrefs,
|
|
||||||
const nsString& aDeviceId,
|
|
||||||
const char** aOutBadConstraint) = 0;
|
|
||||||
|
|
||||||
/* Returns true if a source represents a fake capture device and
|
|
||||||
* false otherwise
|
|
||||||
*/
|
|
||||||
virtual bool IsFake() = 0;
|
|
||||||
|
|
||||||
/* Returns the type of media source (camera, microphone, screen, window, etc) */
|
|
||||||
virtual dom::MediaSourceEnum GetMediaSource() const = 0;
|
|
||||||
|
|
||||||
/* If implementation of MediaEngineSource supports TakePhoto(), the picture
|
|
||||||
* should be return via aCallback object. Otherwise, it returns NS_ERROR_NOT_IMPLEMENTED.
|
|
||||||
* Currently, only Gonk MediaEngineSource implementation supports it.
|
|
||||||
*/
|
|
||||||
virtual nsresult TakePhoto(MediaEnginePhotoCallback* aCallback) = 0;
|
|
||||||
|
|
||||||
/* Return false if device is currently allocated or started */
|
|
||||||
bool IsAvailable() {
|
|
||||||
if (mState == kAllocated || mState == kStarted) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* It is an error to call Start() before an Allocate(), and Stop() before
|
|
||||||
* a Start(). Only Allocate() may be called after a Deallocate(). */
|
|
||||||
|
|
||||||
/* This call reserves but does not start the device. */
|
|
||||||
virtual nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
|
||||||
const MediaEnginePrefs &aPrefs,
|
|
||||||
const nsString& aDeviceId,
|
|
||||||
const nsACString& aOrigin,
|
|
||||||
BaseAllocationHandle** aOutHandle,
|
|
||||||
const char** aOutBadConstraint) = 0;
|
|
||||||
|
|
||||||
virtual uint32_t GetBestFitnessDistance(
|
|
||||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
|
||||||
const nsString& aDeviceId) const = 0;
|
|
||||||
|
|
||||||
void GetSettings(dom::MediaTrackSettings& aOutSettings)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
|
||||||
aOutSettings = mSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Only class' own members can be initialized in constructor initializer list.
|
|
||||||
explicit MediaEngineSource(MediaEngineState aState)
|
|
||||||
: mState(aState)
|
|
||||||
#ifdef DEBUG
|
|
||||||
, mOwningThread(PR_GetCurrentThread())
|
|
||||||
#endif
|
|
||||||
{}
|
|
||||||
|
|
||||||
void AssertIsOnOwningThread()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
MediaEngineState mState;
|
|
||||||
#ifdef DEBUG
|
|
||||||
PRThread* mOwningThread;
|
|
||||||
#endif
|
|
||||||
// Main-thread only:
|
|
||||||
dom::MediaTrackSettings mSettings;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Video source and friends.
|
* Video source and friends.
|
||||||
*/
|
*/
|
||||||
@ -295,6 +152,162 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback interface for TakePhoto(). Either PhotoComplete() or PhotoError()
|
||||||
|
* should be called.
|
||||||
|
*/
|
||||||
|
class MediaEnginePhotoCallback {
|
||||||
|
public:
|
||||||
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaEnginePhotoCallback)
|
||||||
|
|
||||||
|
// aBlob is the image captured by MediaEngineSource. It is
|
||||||
|
// called on main thread.
|
||||||
|
virtual nsresult PhotoComplete(already_AddRefed<dom::Blob> aBlob) = 0;
|
||||||
|
|
||||||
|
// It is called on main thread. aRv is the error code.
|
||||||
|
virtual nsresult PhotoError(nsresult aRv) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual ~MediaEnginePhotoCallback() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common abstract base class for audio and video sources.
|
||||||
|
*/
|
||||||
|
class MediaEngineSource : public nsISupports
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// code inside webrtc.org assumes these sizes; don't use anything smaller
|
||||||
|
// without verifying it's ok
|
||||||
|
static const unsigned int kMaxDeviceNameLength = 128;
|
||||||
|
static const unsigned int kMaxUniqueIdLength = 256;
|
||||||
|
|
||||||
|
virtual ~MediaEngineSource() {}
|
||||||
|
|
||||||
|
virtual void Shutdown() = 0;
|
||||||
|
|
||||||
|
/* Populate the human readable name of this device in the nsAString */
|
||||||
|
virtual void GetName(nsAString&) const = 0;
|
||||||
|
|
||||||
|
/* Populate the UUID of this device in the nsACString */
|
||||||
|
virtual void GetUUID(nsACString&) const = 0;
|
||||||
|
|
||||||
|
class AllocationHandle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AllocationHandle);
|
||||||
|
protected:
|
||||||
|
~AllocationHandle() {}
|
||||||
|
public:
|
||||||
|
AllocationHandle(const dom::MediaTrackConstraints& aConstraints,
|
||||||
|
const nsACString& aOrigin,
|
||||||
|
const MediaEnginePrefs& aPrefs,
|
||||||
|
const nsString& aDeviceId)
|
||||||
|
: mConstraints(aConstraints),
|
||||||
|
mOrigin(aOrigin),
|
||||||
|
mPrefs(aPrefs),
|
||||||
|
mDeviceId(aDeviceId) {}
|
||||||
|
public:
|
||||||
|
NormalizedConstraints mConstraints;
|
||||||
|
nsCString mOrigin;
|
||||||
|
MediaEnginePrefs mPrefs;
|
||||||
|
nsString mDeviceId;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Release the device back to the system. */
|
||||||
|
virtual nsresult Deallocate(AllocationHandle* aHandle) = 0;
|
||||||
|
|
||||||
|
/* Start the device and add the track to the provided SourceMediaStream, with
|
||||||
|
* the provided TrackID. You may start appending data to the track
|
||||||
|
* immediately after. */
|
||||||
|
virtual nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) = 0;
|
||||||
|
|
||||||
|
/* tell the source if there are any direct listeners attached */
|
||||||
|
virtual void SetDirectListeners(bool) = 0;
|
||||||
|
|
||||||
|
/* Called when the stream wants more data */
|
||||||
|
virtual void NotifyPull(MediaStreamGraph* aGraph,
|
||||||
|
SourceMediaStream *aSource,
|
||||||
|
TrackID aId,
|
||||||
|
StreamTime aDesiredTime,
|
||||||
|
const PrincipalHandle& aPrincipalHandle) = 0;
|
||||||
|
|
||||||
|
/* Stop the device and release the corresponding MediaStream */
|
||||||
|
virtual nsresult Stop(SourceMediaStream *aSource, TrackID aID) = 0;
|
||||||
|
|
||||||
|
/* Restart with new capability */
|
||||||
|
virtual nsresult Restart(AllocationHandle* aHandle,
|
||||||
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
|
const MediaEnginePrefs &aPrefs,
|
||||||
|
const nsString& aDeviceId,
|
||||||
|
const char** aOutBadConstraint) = 0;
|
||||||
|
|
||||||
|
/* Returns true if a source represents a fake capture device and
|
||||||
|
* false otherwise
|
||||||
|
*/
|
||||||
|
virtual bool IsFake() = 0;
|
||||||
|
|
||||||
|
/* Returns the type of media source (camera, microphone, screen, window, etc) */
|
||||||
|
virtual dom::MediaSourceEnum GetMediaSource() const = 0;
|
||||||
|
|
||||||
|
/* If implementation of MediaEngineSource supports TakePhoto(), the picture
|
||||||
|
* should be return via aCallback object. Otherwise, it returns NS_ERROR_NOT_IMPLEMENTED.
|
||||||
|
* Currently, only Gonk MediaEngineSource implementation supports it.
|
||||||
|
*/
|
||||||
|
virtual nsresult TakePhoto(MediaEnginePhotoCallback* aCallback) = 0;
|
||||||
|
|
||||||
|
/* Return false if device is currently allocated or started */
|
||||||
|
bool IsAvailable() {
|
||||||
|
if (mState == kAllocated || mState == kStarted) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* It is an error to call Start() before an Allocate(), and Stop() before
|
||||||
|
* a Start(). Only Allocate() may be called after a Deallocate(). */
|
||||||
|
|
||||||
|
/* This call reserves but does not start the device. */
|
||||||
|
virtual nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
||||||
|
const MediaEnginePrefs &aPrefs,
|
||||||
|
const nsString& aDeviceId,
|
||||||
|
const nsACString& aOrigin,
|
||||||
|
AllocationHandle** aOutHandle,
|
||||||
|
const char** aOutBadConstraint) = 0;
|
||||||
|
|
||||||
|
virtual uint32_t GetBestFitnessDistance(
|
||||||
|
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||||
|
const nsString& aDeviceId) const = 0;
|
||||||
|
|
||||||
|
void GetSettings(dom::MediaTrackSettings& aOutSettings)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
aOutSettings = mSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Only class' own members can be initialized in constructor initializer list.
|
||||||
|
explicit MediaEngineSource(MediaEngineState aState)
|
||||||
|
: mState(aState)
|
||||||
|
#ifdef DEBUG
|
||||||
|
, mOwningThread(PR_GetCurrentThread())
|
||||||
|
#endif
|
||||||
|
{}
|
||||||
|
|
||||||
|
void AssertIsOnOwningThread()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(PR_GetCurrentThread() == mOwningThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaEngineState mState;
|
||||||
|
#ifdef DEBUG
|
||||||
|
PRThread* mOwningThread;
|
||||||
|
#endif
|
||||||
|
// Main-thread only:
|
||||||
|
dom::MediaTrackSettings mSettings;
|
||||||
|
};
|
||||||
|
|
||||||
class MediaEngineVideoSource : public MediaEngineSource
|
class MediaEngineVideoSource : public MediaEngineSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -84,7 +84,7 @@ MediaEngineDefaultVideoSource::Allocate(const dom::MediaTrackConstraints &aConst
|
|||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint)
|
const char** aOutBadConstraint)
|
||||||
{
|
{
|
||||||
if (mState != kReleased) {
|
if (mState != kReleased) {
|
||||||
@ -111,7 +111,7 @@ MediaEngineDefaultVideoSource::Allocate(const dom::MediaTrackConstraints &aConst
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineDefaultVideoSource::Deallocate(BaseAllocationHandle* aHandle)
|
MediaEngineDefaultVideoSource::Deallocate(AllocationHandle* aHandle)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!aHandle);
|
MOZ_ASSERT(!aHandle);
|
||||||
if (mState != kStopped && mState != kAllocated) {
|
if (mState != kStopped && mState != kAllocated) {
|
||||||
@ -207,7 +207,7 @@ MediaEngineDefaultVideoSource::Stop(SourceMediaStream *aSource, TrackID aID)
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineDefaultVideoSource::Restart(
|
MediaEngineDefaultVideoSource::Restart(
|
||||||
BaseAllocationHandle* aHandle,
|
AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
@ -398,7 +398,7 @@ MediaEngineDefaultAudioSource::Allocate(const dom::MediaTrackConstraints &aConst
|
|||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint)
|
const char** aOutBadConstraint)
|
||||||
{
|
{
|
||||||
if (mState != kReleased) {
|
if (mState != kReleased) {
|
||||||
@ -420,7 +420,7 @@ MediaEngineDefaultAudioSource::Allocate(const dom::MediaTrackConstraints &aConst
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineDefaultAudioSource::Deallocate(BaseAllocationHandle* aHandle)
|
MediaEngineDefaultAudioSource::Deallocate(AllocationHandle* aHandle)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!aHandle);
|
MOZ_ASSERT(!aHandle);
|
||||||
if (mState != kStopped && mState != kAllocated) {
|
if (mState != kStopped && mState != kAllocated) {
|
||||||
@ -496,7 +496,7 @@ MediaEngineDefaultAudioSource::Stop(SourceMediaStream *aSource, TrackID aID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineDefaultAudioSource::Restart(BaseAllocationHandle* aHandle,
|
MediaEngineDefaultAudioSource::Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
|
@ -48,12 +48,12 @@ public:
|
|||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint) override;
|
const char** aOutBadConstraint) override;
|
||||||
nsresult Deallocate(BaseAllocationHandle* aHandle) override;
|
nsresult Deallocate(AllocationHandle* aHandle) override;
|
||||||
nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) override;
|
nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) override;
|
||||||
nsresult Stop(SourceMediaStream*, TrackID) override;
|
nsresult Stop(SourceMediaStream*, TrackID) override;
|
||||||
nsresult Restart(BaseAllocationHandle* aHandle,
|
nsresult Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
@ -123,12 +123,12 @@ public:
|
|||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint) override;
|
const char** aOutBadConstraint) override;
|
||||||
nsresult Deallocate(BaseAllocationHandle* aHandle) override;
|
nsresult Deallocate(AllocationHandle* aHandle) override;
|
||||||
nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) override;
|
nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) override;
|
||||||
nsresult Stop(SourceMediaStream*, TrackID) override;
|
nsresult Stop(SourceMediaStream*, TrackID) override;
|
||||||
nsresult Restart(BaseAllocationHandle* aHandle,
|
nsresult Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
|
@ -108,7 +108,7 @@ MediaEngineRemoteVideoSource::Allocate(
|
|||||||
const MediaEnginePrefs& aPrefs,
|
const MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint)
|
const char** aOutBadConstraint)
|
||||||
{
|
{
|
||||||
LOG((__PRETTY_FUNCTION__));
|
LOG((__PRETTY_FUNCTION__));
|
||||||
@ -143,12 +143,12 @@ MediaEngineRemoteVideoSource::Allocate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineRemoteVideoSource::Deallocate(BaseAllocationHandle* aHandle)
|
MediaEngineRemoteVideoSource::Deallocate(AllocationHandle* aHandle)
|
||||||
{
|
{
|
||||||
LOG((__PRETTY_FUNCTION__));
|
LOG((__PRETTY_FUNCTION__));
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
MOZ_ASSERT(aHandle);
|
MOZ_ASSERT(aHandle);
|
||||||
RefPtr<AllocationHandle> handle = static_cast<AllocationHandle*>(aHandle);
|
RefPtr<AllocationHandle> handle = aHandle;
|
||||||
|
|
||||||
class Comparator {
|
class Comparator {
|
||||||
public:
|
public:
|
||||||
@ -267,7 +267,7 @@ MediaEngineRemoteVideoSource::Stop(mozilla::SourceMediaStream* aSource,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineRemoteVideoSource::Restart(BaseAllocationHandle* aHandle,
|
MediaEngineRemoteVideoSource::Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs& aPrefs,
|
const MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
@ -280,8 +280,7 @@ MediaEngineRemoteVideoSource::Restart(BaseAllocationHandle* aHandle,
|
|||||||
}
|
}
|
||||||
MOZ_ASSERT(aHandle);
|
MOZ_ASSERT(aHandle);
|
||||||
NormalizedConstraints constraints(aConstraints);
|
NormalizedConstraints constraints(aConstraints);
|
||||||
return UpdateExisting(static_cast<AllocationHandle*>(aHandle), &constraints,
|
return UpdateExisting(aHandle, &constraints, aPrefs, aDeviceId, aOutBadConstraint);
|
||||||
aPrefs, aDeviceId, aOutBadConstraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -71,36 +71,16 @@ public:
|
|||||||
dom::MediaSourceEnum aMediaSource,
|
dom::MediaSourceEnum aMediaSource,
|
||||||
const char* aMonitorName = "RemoteVideo.Monitor");
|
const char* aMonitorName = "RemoteVideo.Monitor");
|
||||||
|
|
||||||
class AllocationHandle : public BaseAllocationHandle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AllocationHandle(const dom::MediaTrackConstraints& aConstraints,
|
|
||||||
const nsACString& aOrigin,
|
|
||||||
const MediaEnginePrefs& aPrefs,
|
|
||||||
const nsString& aDeviceId)
|
|
||||||
: mConstraints(aConstraints),
|
|
||||||
mOrigin(aOrigin),
|
|
||||||
mPrefs(aPrefs),
|
|
||||||
mDeviceId(aDeviceId) {}
|
|
||||||
private:
|
|
||||||
~AllocationHandle() override {}
|
|
||||||
public:
|
|
||||||
NormalizedConstraints mConstraints;
|
|
||||||
nsCString mOrigin;
|
|
||||||
MediaEnginePrefs mPrefs;
|
|
||||||
nsString mDeviceId;
|
|
||||||
};
|
|
||||||
|
|
||||||
nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
|
nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs& aPrefs,
|
const MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint) override;
|
const char** aOutBadConstraint) override;
|
||||||
nsresult Deallocate(BaseAllocationHandle* aHandle) override;
|
nsresult Deallocate(AllocationHandle* aHandle) override;
|
||||||
nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) override;
|
nsresult Start(SourceMediaStream*, TrackID, const PrincipalHandle&) override;
|
||||||
nsresult Stop(SourceMediaStream*, TrackID) override;
|
nsresult Stop(SourceMediaStream*, TrackID) override;
|
||||||
nsresult Restart(BaseAllocationHandle* aHandle,
|
nsresult Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
|
@ -140,7 +140,7 @@ MediaEngineTabVideoSource::Allocate(const dom::MediaTrackConstraints& aConstrain
|
|||||||
const MediaEnginePrefs& aPrefs,
|
const MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint)
|
const char** aOutBadConstraint)
|
||||||
{
|
{
|
||||||
// windowId is not a proper constraint, so just read it.
|
// windowId is not a proper constraint, so just read it.
|
||||||
@ -153,7 +153,7 @@ MediaEngineTabVideoSource::Allocate(const dom::MediaTrackConstraints& aConstrain
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineTabVideoSource::Restart(BaseAllocationHandle* aHandle,
|
MediaEngineTabVideoSource::Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const mozilla::MediaEnginePrefs& aPrefs,
|
const mozilla::MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
@ -184,7 +184,7 @@ MediaEngineTabVideoSource::Restart(BaseAllocationHandle* aHandle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineTabVideoSource::Deallocate(BaseAllocationHandle* aHandle)
|
MediaEngineTabVideoSource::Deallocate(AllocationHandle* aHandle)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!aHandle);
|
MOZ_ASSERT(!aHandle);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -26,14 +26,14 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
|||||||
const mozilla::MediaEnginePrefs&,
|
const mozilla::MediaEnginePrefs&,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint) override;
|
const char** aOutBadConstraint) override;
|
||||||
nsresult Deallocate(BaseAllocationHandle* aHandle) override;
|
nsresult Deallocate(AllocationHandle* aHandle) override;
|
||||||
nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID, const mozilla::PrincipalHandle&) override;
|
nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID, const mozilla::PrincipalHandle&) override;
|
||||||
void SetDirectListeners(bool aHasDirectListeners) override {};
|
void SetDirectListeners(bool aHasDirectListeners) override {};
|
||||||
void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, const mozilla::PrincipalHandle& aPrincipalHandle) override;
|
void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, const mozilla::PrincipalHandle& aPrincipalHandle) override;
|
||||||
nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID) override;
|
nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID) override;
|
||||||
nsresult Restart(BaseAllocationHandle* aHandle,
|
nsresult Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const mozilla::MediaEnginePrefs& aPrefs,
|
const mozilla::MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
|
@ -78,14 +78,14 @@ public:
|
|||||||
const MediaEnginePrefs& aPrefs,
|
const MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint) override
|
const char** aOutBadConstraint) override
|
||||||
{
|
{
|
||||||
// Nothing to do here, everything is managed in MediaManager.cpp
|
// Nothing to do here, everything is managed in MediaManager.cpp
|
||||||
aOutHandle = nullptr;
|
aOutHandle = nullptr;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
nsresult Deallocate(BaseAllocationHandle* aHandle) override
|
nsresult Deallocate(AllocationHandle* aHandle) override
|
||||||
{
|
{
|
||||||
// Nothing to do here, everything is managed in MediaManager.cpp
|
// Nothing to do here, everything is managed in MediaManager.cpp
|
||||||
MOZ_ASSERT(!aHandle);
|
MOZ_ASSERT(!aHandle);
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
TrackID aId,
|
TrackID aId,
|
||||||
const PrincipalHandle& aPrincipalHandle) override;
|
const PrincipalHandle& aPrincipalHandle) override;
|
||||||
nsresult Stop(SourceMediaStream* aMediaStream, TrackID aId) override;
|
nsresult Stop(SourceMediaStream* aMediaStream, TrackID aId) override;
|
||||||
nsresult Restart(BaseAllocationHandle* aHandle,
|
nsresult Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
@ -458,14 +458,14 @@ public:
|
|||||||
const MediaEnginePrefs& aPrefs,
|
const MediaEnginePrefs& aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint) override;
|
const char** aOutBadConstraint) override;
|
||||||
nsresult Deallocate(BaseAllocationHandle* aHandle) override;
|
nsresult Deallocate(AllocationHandle* aHandle) override;
|
||||||
nsresult Start(SourceMediaStream* aStream,
|
nsresult Start(SourceMediaStream* aStream,
|
||||||
TrackID aID,
|
TrackID aID,
|
||||||
const PrincipalHandle& aPrincipalHandle) override;
|
const PrincipalHandle& aPrincipalHandle) override;
|
||||||
nsresult Stop(SourceMediaStream* aSource, TrackID aID) override;
|
nsresult Stop(SourceMediaStream* aSource, TrackID aID) override;
|
||||||
nsresult Restart(BaseAllocationHandle* aHandle,
|
nsresult Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
|
@ -223,7 +223,7 @@ MediaEngineWebRTCMicrophoneSource::Allocate(const dom::MediaTrackConstraints &aC
|
|||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
const nsACString& aOrigin,
|
const nsACString& aOrigin,
|
||||||
BaseAllocationHandle** aOutHandle,
|
AllocationHandle** aOutHandle,
|
||||||
const char** aOutBadConstraint)
|
const char** aOutBadConstraint)
|
||||||
{
|
{
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
@ -265,7 +265,7 @@ MediaEngineWebRTCMicrophoneSource::Allocate(const dom::MediaTrackConstraints &aC
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineWebRTCMicrophoneSource::Restart(BaseAllocationHandle* aHandle,
|
MediaEngineWebRTCMicrophoneSource::Restart(AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
@ -315,7 +315,7 @@ MediaEngineWebRTCMicrophoneSource::Restart(BaseAllocationHandle* aHandle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineWebRTCMicrophoneSource::Deallocate(BaseAllocationHandle* aHandle)
|
MediaEngineWebRTCMicrophoneSource::Deallocate(AllocationHandle* aHandle)
|
||||||
{
|
{
|
||||||
AssertIsOnOwningThread();
|
AssertIsOnOwningThread();
|
||||||
MOZ_ASSERT(!aHandle);
|
MOZ_ASSERT(!aHandle);
|
||||||
@ -847,7 +847,7 @@ MediaEngineWebRTCAudioCaptureSource::Stop(SourceMediaStream *aMediaStream,
|
|||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaEngineWebRTCAudioCaptureSource::Restart(
|
MediaEngineWebRTCAudioCaptureSource::Restart(
|
||||||
BaseAllocationHandle* aHandle,
|
AllocationHandle* aHandle,
|
||||||
const dom::MediaTrackConstraints& aConstraints,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const MediaEnginePrefs &aPrefs,
|
const MediaEnginePrefs &aPrefs,
|
||||||
const nsString& aDeviceId,
|
const nsString& aDeviceId,
|
||||||
|
Loading…
Reference in New Issue
Block a user