mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 907352 - Part 5: Wiring for width/height/frameRate gUM constraints. r=mt
This commit is contained in:
parent
27c5ae175d
commit
398687e6de
@ -12,6 +12,9 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class VideoTrackConstraintsN;
|
||||
class AudioTrackConstraintsN;
|
||||
|
||||
/**
|
||||
* Abstract interface for managing audio and video devices. Each platform
|
||||
* must implement a concrete class that will map these classes and methods
|
||||
@ -73,9 +76,6 @@ public:
|
||||
/* Populate the UUID of this device in the nsAString */
|
||||
virtual void GetUUID(nsAString&) = 0;
|
||||
|
||||
/* This call reserves but does not start the device. */
|
||||
virtual nsresult Allocate(const MediaEnginePrefs &aPrefs) = 0;
|
||||
|
||||
/* Release the device back to the system. */
|
||||
virtual nsresult Deallocate() = 0;
|
||||
|
||||
@ -141,6 +141,10 @@ class MediaEngineVideoSource : public MediaEngineSource
|
||||
{
|
||||
public:
|
||||
virtual ~MediaEngineVideoSource() {}
|
||||
|
||||
/* This call reserves but does not start the device. */
|
||||
virtual nsresult Allocate(const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -150,6 +154,11 @@ class MediaEngineAudioSource : public MediaEngineSource
|
||||
{
|
||||
public:
|
||||
virtual ~MediaEngineAudioSource() {}
|
||||
|
||||
/* This call reserves but does not start the device. */
|
||||
virtual nsresult Allocate(const AudioTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs) = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -61,7 +61,8 @@ MediaEngineDefaultVideoSource::GetUUID(nsAString& aUUID)
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaEngineDefaultVideoSource::Allocate(const MediaEnginePrefs &aPrefs)
|
||||
MediaEngineDefaultVideoSource::Allocate(const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs)
|
||||
{
|
||||
if (mState != kReleased) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -367,7 +368,8 @@ MediaEngineDefaultAudioSource::GetUUID(nsAString& aUUID)
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaEngineDefaultAudioSource::Allocate(const MediaEnginePrefs &aPrefs)
|
||||
MediaEngineDefaultAudioSource::Allocate(const AudioTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs)
|
||||
{
|
||||
if (mState != kReleased) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
virtual void GetName(nsAString&);
|
||||
virtual void GetUUID(nsAString&);
|
||||
|
||||
virtual nsresult Allocate(const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Allocate(const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Deallocate();
|
||||
virtual nsresult Start(SourceMediaStream*, TrackID);
|
||||
virtual nsresult Stop(SourceMediaStream*, TrackID);
|
||||
@ -94,7 +95,8 @@ public:
|
||||
virtual void GetName(nsAString&);
|
||||
virtual void GetUUID(nsAString&);
|
||||
|
||||
virtual nsresult Allocate(const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Allocate(const AudioTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Deallocate();
|
||||
virtual nsresult Start(SourceMediaStream*, TrackID);
|
||||
virtual nsresult Stop(SourceMediaStream*, TrackID);
|
||||
|
@ -119,7 +119,8 @@ MediaEngineTabVideoSource::GetUUID(nsAString_internal& aUuid)
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaEngineTabVideoSource::Allocate(const mozilla::MediaEnginePrefs&)
|
||||
MediaEngineTabVideoSource::Allocate(const VideoTrackConstraintsN&,
|
||||
const MediaEnginePrefs&)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
||||
|
||||
virtual void GetName(nsAString_internal&);
|
||||
virtual void GetUUID(nsAString_internal&);
|
||||
virtual nsresult Allocate(const mozilla::MediaEnginePrefs&);
|
||||
virtual nsresult Allocate(const VideoTrackConstraintsN &,
|
||||
const mozilla::MediaEnginePrefs&);
|
||||
virtual nsresult Deallocate();
|
||||
virtual nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID);
|
||||
virtual nsresult Snapshot(uint32_t, nsIDOMFile**);
|
||||
|
@ -32,6 +32,7 @@ GetUserMediaLog()
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "MediaEngineTabVideoSource.h"
|
||||
#include "nsITabSource.h"
|
||||
#include "MediaTrackConstraints.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidJNIWrapper.h"
|
||||
|
@ -142,7 +142,8 @@ public:
|
||||
|
||||
virtual void GetName(nsAString&);
|
||||
virtual void GetUUID(nsAString&);
|
||||
virtual nsresult Allocate(const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Allocate(const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Deallocate();
|
||||
virtual nsresult Start(SourceMediaStream*, TrackID);
|
||||
virtual nsresult Stop(SourceMediaStream*, TrackID);
|
||||
@ -247,7 +248,8 @@ private:
|
||||
nsString mDeviceName;
|
||||
nsString mUniqueId;
|
||||
|
||||
void ChooseCapability(const MediaEnginePrefs &aPrefs);
|
||||
void ChooseCapability(const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs);
|
||||
};
|
||||
|
||||
class MediaEngineWebRTCAudioSource : public MediaEngineAudioSource,
|
||||
@ -280,7 +282,8 @@ public:
|
||||
virtual void GetName(nsAString&);
|
||||
virtual void GetUUID(nsAString&);
|
||||
|
||||
virtual nsresult Allocate(const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Allocate(const AudioTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs);
|
||||
virtual nsresult Deallocate();
|
||||
virtual nsresult Start(SourceMediaStream*, TrackID);
|
||||
virtual nsresult Stop(SourceMediaStream*, TrackID);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "MediaTrackConstraints.h"
|
||||
|
||||
// scoped_ptr.h uses FF
|
||||
#ifdef FF
|
||||
@ -242,7 +243,8 @@ MediaEngineWebRTCAudioSource::Config(bool aEchoOn, uint32_t aEcho,
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaEngineWebRTCAudioSource::Allocate(const MediaEnginePrefs &aPrefs)
|
||||
MediaEngineWebRTCAudioSource::Allocate(const AudioTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs)
|
||||
{
|
||||
if (mState == kReleased) {
|
||||
if (mInitDone) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/layers/GrallocTextureClient.h"
|
||||
#include "nsMemory.h"
|
||||
#include "mtransport/runnable_utils.h"
|
||||
#include "MediaTrackConstraints.h"
|
||||
|
||||
#ifdef MOZ_B2G_CAMERA
|
||||
#include "GrallocImages.h"
|
||||
@ -167,7 +168,9 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTCVideoSource::ChooseCapability(const MediaEnginePrefs &aPrefs)
|
||||
MediaEngineWebRTCVideoSource::ChooseCapability(
|
||||
const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs)
|
||||
{
|
||||
#ifdef MOZ_B2G_CAMERA
|
||||
mCapability.width = aPrefs.mWidth;
|
||||
@ -234,13 +237,14 @@ MediaEngineWebRTCVideoSource::GetUUID(nsAString& aUUID)
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaEngineWebRTCVideoSource::Allocate(const MediaEnginePrefs &aPrefs)
|
||||
MediaEngineWebRTCVideoSource::Allocate(const VideoTrackConstraintsN &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs)
|
||||
{
|
||||
LOG((__FUNCTION__));
|
||||
#ifdef MOZ_B2G_CAMERA
|
||||
ReentrantMonitorAutoEnter sync(mCallbackMonitor);
|
||||
if (mState == kReleased && mInitDone) {
|
||||
ChooseCapability(aPrefs);
|
||||
ChooseCapability(aConstraints, aPrefs);
|
||||
NS_DispatchToMainThread(WrapRunnable(this,
|
||||
&MediaEngineWebRTCVideoSource::AllocImpl));
|
||||
mCallbackMonitor.Wait();
|
||||
@ -253,7 +257,7 @@ MediaEngineWebRTCVideoSource::Allocate(const MediaEnginePrefs &aPrefs)
|
||||
// Note: if shared, we don't allow a later opener to affect the resolution.
|
||||
// (This may change depending on spec changes for Constraints/settings)
|
||||
|
||||
ChooseCapability(aPrefs);
|
||||
ChooseCapability(aConstraints, aPrefs);
|
||||
|
||||
if (mViECapture->AllocateCaptureDevice(NS_ConvertUTF16toUTF8(mUniqueId).get(),
|
||||
KMaxUniqueIdLength, mCaptureIndex)) {
|
||||
|
@ -262,13 +262,23 @@ protected:
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(MediaDevice, nsIMediaDevice)
|
||||
|
||||
MediaDevice::MediaDevice(MediaEngineVideoSource* aSource)
|
||||
MediaDevice* MediaDevice::Create(MediaEngineVideoSource* source) {
|
||||
return new VideoDevice(source);
|
||||
}
|
||||
|
||||
MediaDevice* MediaDevice::Create(MediaEngineAudioSource* source) {
|
||||
return new AudioDevice(source);
|
||||
}
|
||||
|
||||
MediaDevice::MediaDevice(MediaEngineSource* aSource)
|
||||
: mHasFacingMode(false)
|
||||
, mSource(aSource) {
|
||||
mType.Assign(NS_LITERAL_STRING("video"));
|
||||
mSource->GetName(mName);
|
||||
mSource->GetUUID(mID);
|
||||
}
|
||||
|
||||
VideoDevice::VideoDevice(MediaEngineVideoSource* aSource)
|
||||
: MediaDevice(aSource) {
|
||||
#ifdef MOZ_B2G_CAMERA
|
||||
if (mName.EqualsLiteral("back")) {
|
||||
mHasFacingMode = true;
|
||||
@ -286,13 +296,8 @@ MediaDevice::MediaDevice(MediaEngineVideoSource* aSource)
|
||||
}
|
||||
}
|
||||
|
||||
MediaDevice::MediaDevice(MediaEngineAudioSource* aSource)
|
||||
: mHasFacingMode(false)
|
||||
, mSource(aSource) {
|
||||
mType.Assign(NS_LITERAL_STRING("audio"));
|
||||
mSource->GetName(mName);
|
||||
mSource->GetUUID(mID);
|
||||
}
|
||||
AudioDevice::AudioDevice(MediaEngineAudioSource* aSource)
|
||||
: MediaDevice(aSource) {}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaDevice::GetName(nsAString& aName)
|
||||
@ -304,7 +309,20 @@ MediaDevice::GetName(nsAString& aName)
|
||||
NS_IMETHODIMP
|
||||
MediaDevice::GetType(nsAString& aType)
|
||||
{
|
||||
aType.Assign(mType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
VideoDevice::GetType(nsAString& aType)
|
||||
{
|
||||
aType.Assign(NS_LITERAL_STRING("video"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioDevice::GetType(nsAString& aType)
|
||||
{
|
||||
aType.Assign(NS_LITERAL_STRING("audio"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -327,10 +345,16 @@ MediaDevice::GetFacingMode(nsAString& aFacingMode)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MediaEngineSource*
|
||||
MediaDevice::GetSource()
|
||||
MediaEngineVideoSource*
|
||||
VideoDevice::GetSource()
|
||||
{
|
||||
return mSource;
|
||||
return static_cast<MediaEngineVideoSource*>(&*mSource);
|
||||
}
|
||||
|
||||
MediaEngineAudioSource*
|
||||
AudioDevice::GetSource()
|
||||
{
|
||||
return static_cast<MediaEngineAudioSource*>(&*mSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -715,12 +739,12 @@ static SourceSet *
|
||||
sources[i]->GetName(deviceName);
|
||||
if (media_device_name && strlen(media_device_name) > 0) {
|
||||
if (deviceName.EqualsASCII(media_device_name)) {
|
||||
candidateSet.AppendElement(new MediaDevice(sources[i]));
|
||||
candidateSet.AppendElement(MediaDevice::Create(sources[i]));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
candidateSet.AppendElement(new MediaDevice(sources[i]));
|
||||
candidateSet.AppendElement(MediaDevice::Create(sources[i]));
|
||||
#ifdef DEBUG
|
||||
}
|
||||
#endif
|
||||
@ -950,7 +974,7 @@ public:
|
||||
}
|
||||
|
||||
nsresult
|
||||
SetAudioDevice(MediaDevice* aAudioDevice)
|
||||
SetAudioDevice(AudioDevice* aAudioDevice)
|
||||
{
|
||||
mAudioDevice = aAudioDevice;
|
||||
mDeviceChosen = true;
|
||||
@ -958,7 +982,7 @@ public:
|
||||
}
|
||||
|
||||
nsresult
|
||||
SetVideoDevice(MediaDevice* aVideoDevice)
|
||||
SetVideoDevice(VideoDevice* aVideoDevice)
|
||||
{
|
||||
mVideoDevice = aVideoDevice;
|
||||
mDeviceChosen = true;
|
||||
@ -1006,13 +1030,14 @@ public:
|
||||
* a GetUserMediaStreamRunnable. Runs off the main thread.
|
||||
*/
|
||||
void
|
||||
ProcessGetUserMedia(MediaEngineSource* aAudioSource, MediaEngineSource* aVideoSource)
|
||||
ProcessGetUserMedia(MediaEngineAudioSource* aAudioSource,
|
||||
MediaEngineVideoSource* aVideoSource)
|
||||
{
|
||||
MOZ_ASSERT(mSuccess);
|
||||
MOZ_ASSERT(mError);
|
||||
nsresult rv;
|
||||
if (aAudioSource) {
|
||||
rv = aAudioSource->Allocate(mPrefs);
|
||||
rv = aAudioSource->Allocate(GetInvariant(mConstraints.mAudio), mPrefs);
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG(("Failed to allocate audiosource %d",rv));
|
||||
Fail(NS_LITERAL_STRING("HARDWARE_UNAVAILABLE"));
|
||||
@ -1020,7 +1045,7 @@ public:
|
||||
}
|
||||
}
|
||||
if (aVideoSource) {
|
||||
rv = aVideoSource->Allocate(mPrefs);
|
||||
rv = aVideoSource->Allocate(GetInvariant(mConstraints.mVideo), mPrefs);
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG(("Failed to allocate videosource %d\n",rv));
|
||||
if (aAudioSource) {
|
||||
@ -1046,11 +1071,11 @@ public:
|
||||
* a SuccessRunnable or an error via the ErrorRunnable. Off the main thread.
|
||||
*/
|
||||
void
|
||||
ProcessGetUserMediaSnapshot(MediaEngineSource* aSource, int aDuration)
|
||||
ProcessGetUserMediaSnapshot(MediaEngineVideoSource* aSource, int aDuration)
|
||||
{
|
||||
MOZ_ASSERT(mSuccess);
|
||||
MOZ_ASSERT(mError);
|
||||
nsresult rv = aSource->Allocate(mPrefs);
|
||||
nsresult rv = aSource->Allocate(GetInvariant(mConstraints.mVideo), mPrefs);
|
||||
if (NS_FAILED(rv)) {
|
||||
Fail(NS_LITERAL_STRING("HARDWARE_UNAVAILABLE"));
|
||||
return;
|
||||
@ -1080,8 +1105,8 @@ private:
|
||||
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> mError;
|
||||
uint64_t mWindowID;
|
||||
nsRefPtr<GetUserMediaCallbackMediaStreamListener> mListener;
|
||||
nsRefPtr<MediaDevice> mAudioDevice;
|
||||
nsRefPtr<MediaDevice> mVideoDevice;
|
||||
nsRefPtr<AudioDevice> mAudioDevice;
|
||||
nsRefPtr<VideoDevice> mVideoDevice;
|
||||
MediaEnginePrefs mPrefs;
|
||||
|
||||
bool mDeviceChosen;
|
||||
@ -1770,9 +1795,9 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
nsString type;
|
||||
device->GetType(type);
|
||||
if (type.EqualsLiteral("video")) {
|
||||
runnable->SetVideoDevice(static_cast<MediaDevice*>(device.get()));
|
||||
runnable->SetVideoDevice(static_cast<VideoDevice*>(device.get()));
|
||||
} else if (type.EqualsLiteral("audio")) {
|
||||
runnable->SetAudioDevice(static_cast<MediaDevice*>(device.get()));
|
||||
runnable->SetAudioDevice(static_cast<AudioDevice*>(device.get()));
|
||||
} else {
|
||||
NS_WARNING("Unknown device type in getUserMedia");
|
||||
}
|
||||
|
@ -441,20 +441,35 @@ public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIMEDIADEVICE
|
||||
|
||||
MediaDevice(MediaEngineVideoSource* aSource);
|
||||
MediaDevice(MediaEngineAudioSource* aSource);
|
||||
virtual ~MediaDevice() {}
|
||||
static MediaDevice* Create(MediaEngineVideoSource* source);
|
||||
static MediaDevice* Create(MediaEngineAudioSource* source);
|
||||
|
||||
MediaEngineSource* GetSource();
|
||||
private:
|
||||
virtual ~MediaDevice() {}
|
||||
protected:
|
||||
MediaDevice(MediaEngineSource* aSource);
|
||||
nsString mName;
|
||||
nsString mType;
|
||||
nsString mID;
|
||||
bool mHasFacingMode;
|
||||
dom::VideoFacingModeEnum mFacingMode;
|
||||
nsRefPtr<MediaEngineSource> mSource;
|
||||
};
|
||||
|
||||
class VideoDevice : public MediaDevice
|
||||
{
|
||||
public:
|
||||
VideoDevice(MediaEngineVideoSource* aSource);
|
||||
NS_IMETHOD GetType(nsAString& aType);
|
||||
MediaEngineVideoSource* GetSource();
|
||||
};
|
||||
|
||||
class AudioDevice : public MediaDevice
|
||||
{
|
||||
public:
|
||||
AudioDevice(MediaEngineAudioSource* aSource);
|
||||
NS_IMETHOD GetType(nsAString& aType);
|
||||
MediaEngineAudioSource* GetSource();
|
||||
};
|
||||
|
||||
class MediaManager MOZ_FINAL : public nsIMediaManagerService,
|
||||
public nsIObserver
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user