зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset abf811706099 (bug 1213517)
This commit is contained in:
Родитель
c221a00e38
Коммит
e4b92aada9
|
@ -114,10 +114,10 @@ public:
|
|||
virtual void Shutdown() = 0;
|
||||
|
||||
/* Populate the human readable name of this device in the nsAString */
|
||||
virtual void GetName(nsAString&) const = 0;
|
||||
virtual void GetName(nsAString&) = 0;
|
||||
|
||||
/* Populate the UUID of this device in the nsACString */
|
||||
virtual void GetUUID(nsACString&) const = 0;
|
||||
virtual void GetUUID(nsACString&) = 0;
|
||||
|
||||
class BaseAllocationHandle
|
||||
{
|
||||
|
@ -195,7 +195,7 @@ public:
|
|||
|
||||
virtual uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const = 0;
|
||||
const nsString& aDeviceId) = 0;
|
||||
|
||||
protected:
|
||||
// Only class' own members can be initialized in constructor initializer list.
|
||||
|
|
|
@ -39,14 +39,14 @@ bool MediaEngineCameraVideoSource::AppendToTrack(SourceMediaStream* aSource,
|
|||
// Sub-classes (B2G or desktop) should overload one of both of these two methods
|
||||
// to provide capabilities
|
||||
size_t
|
||||
MediaEngineCameraVideoSource::NumCapabilities() const
|
||||
MediaEngineCameraVideoSource::NumCapabilities()
|
||||
{
|
||||
return mHardcodedCapabilities.Length();
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineCameraVideoSource::GetCapability(size_t aIndex,
|
||||
webrtc::CaptureCapability& aOut) const
|
||||
webrtc::CaptureCapability& aOut)
|
||||
{
|
||||
MOZ_ASSERT(aIndex < mHardcodedCapabilities.Length());
|
||||
aOut = mHardcodedCapabilities[aIndex];
|
||||
|
@ -56,7 +56,7 @@ uint32_t
|
|||
MediaEngineCameraVideoSource::GetFitnessDistance(
|
||||
const webrtc::CaptureCapability& aCandidate,
|
||||
const NormalizedConstraintSet &aConstraints,
|
||||
const nsString& aDeviceId) const
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
// Treat width|height|frameRate == 0 on capability as "can do any".
|
||||
// This allows for orthogonal capabilities that are not in discrete steps.
|
||||
|
@ -104,7 +104,7 @@ MediaEngineCameraVideoSource::TrimLessFitCandidates(CapabilitySet& set) {
|
|||
uint32_t
|
||||
MediaEngineCameraVideoSource::GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
size_t num = NumCapabilities();
|
||||
|
||||
|
@ -364,7 +364,7 @@ MediaEngineCameraVideoSource::SetName(nsString aName)
|
|||
}
|
||||
|
||||
void
|
||||
MediaEngineCameraVideoSource::GetName(nsAString& aName) const
|
||||
MediaEngineCameraVideoSource::GetName(nsAString& aName)
|
||||
{
|
||||
aName = mDeviceName;
|
||||
}
|
||||
|
@ -376,13 +376,13 @@ MediaEngineCameraVideoSource::SetUUID(const char* aUUID)
|
|||
}
|
||||
|
||||
void
|
||||
MediaEngineCameraVideoSource::GetUUID(nsACString& aUUID) const
|
||||
MediaEngineCameraVideoSource::GetUUID(nsACString& aUUID)
|
||||
{
|
||||
aUUID = mUniqueId;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
MediaEngineCameraVideoSource::GetUUID() const
|
||||
MediaEngineCameraVideoSource::GetUUID()
|
||||
{
|
||||
return mUniqueId;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace mozilla {
|
||||
|
||||
class MediaEngineCameraVideoSource : public MediaEngineVideoSource,
|
||||
protected MediaConstraintsHelper
|
||||
private MediaConstraintsHelper
|
||||
{
|
||||
public:
|
||||
explicit MediaEngineCameraVideoSource(int aIndex,
|
||||
|
@ -34,8 +34,8 @@ public:
|
|||
{}
|
||||
|
||||
|
||||
void GetName(nsAString& aName) const override;
|
||||
void GetUUID(nsACString& aUUID) const override;
|
||||
void GetName(nsAString& aName) override;
|
||||
void GetUUID(nsACString& aUUID) override;
|
||||
void SetDirectListeners(bool aHasListeners) override;
|
||||
|
||||
bool IsFake() override
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const override;
|
||||
const nsString& aDeviceId) override;
|
||||
|
||||
void Shutdown() override {};
|
||||
|
||||
|
@ -74,20 +74,20 @@ protected:
|
|||
const PrincipalHandle& aPrincipalHandle);
|
||||
uint32_t GetFitnessDistance(const webrtc::CaptureCapability& aCandidate,
|
||||
const NormalizedConstraintSet &aConstraints,
|
||||
const nsString& aDeviceId) const;
|
||||
const nsString& aDeviceId);
|
||||
static void TrimLessFitCandidates(CapabilitySet& set);
|
||||
static void LogConstraints(const NormalizedConstraintSet& aConstraints);
|
||||
static void LogCapability(const char* aHeader,
|
||||
const webrtc::CaptureCapability &aCapability,
|
||||
uint32_t aDistance);
|
||||
virtual size_t NumCapabilities() const;
|
||||
virtual void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut) const;
|
||||
virtual size_t NumCapabilities();
|
||||
virtual void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut);
|
||||
virtual bool ChooseCapability(const NormalizedConstraints &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs,
|
||||
const nsString& aDeviceId);
|
||||
void SetName(nsString aName);
|
||||
void SetUUID(const char* aUUID);
|
||||
const nsCString& GetUUID() const; // protected access
|
||||
const nsCString& GetUUID(); // protected access
|
||||
|
||||
// Engine variables.
|
||||
|
||||
|
@ -115,7 +115,7 @@ protected:
|
|||
|
||||
webrtc::CaptureCapability mCapability;
|
||||
|
||||
mutable nsTArray<webrtc::CaptureCapability> mHardcodedCapabilities;
|
||||
nsTArray<webrtc::CaptureCapability> mHardcodedCapabilities; // For OSX & B2G
|
||||
private:
|
||||
nsString mDeviceName;
|
||||
nsCString mUniqueId;
|
||||
|
|
|
@ -57,14 +57,14 @@ MediaEngineDefaultVideoSource::~MediaEngineDefaultVideoSource()
|
|||
{}
|
||||
|
||||
void
|
||||
MediaEngineDefaultVideoSource::GetName(nsAString& aName) const
|
||||
MediaEngineDefaultVideoSource::GetName(nsAString& aName)
|
||||
{
|
||||
aName.AssignLiteral(MOZ_UTF16("Default Video Device"));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineDefaultVideoSource::GetUUID(nsACString& aUUID) const
|
||||
MediaEngineDefaultVideoSource::GetUUID(nsACString& aUUID)
|
||||
{
|
||||
aUUID.AssignLiteral("1041FCBD-3F12-4F7B-9E9B-1EC556DD5676");
|
||||
return;
|
||||
|
@ -73,7 +73,7 @@ MediaEngineDefaultVideoSource::GetUUID(nsACString& aUUID) const
|
|||
uint32_t
|
||||
MediaEngineDefaultVideoSource::GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
uint32_t distance = 0;
|
||||
#ifdef MOZ_WEBRTC
|
||||
|
@ -385,14 +385,14 @@ MediaEngineDefaultAudioSource::~MediaEngineDefaultAudioSource()
|
|||
{}
|
||||
|
||||
void
|
||||
MediaEngineDefaultAudioSource::GetName(nsAString& aName) const
|
||||
MediaEngineDefaultAudioSource::GetName(nsAString& aName)
|
||||
{
|
||||
aName.AssignLiteral(MOZ_UTF16("Default Audio Device"));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineDefaultAudioSource::GetUUID(nsACString& aUUID) const
|
||||
MediaEngineDefaultAudioSource::GetUUID(nsACString& aUUID)
|
||||
{
|
||||
aUUID.AssignLiteral("B7CBD7C1-53EF-42F9-8353-73F61C70C092");
|
||||
return;
|
||||
|
@ -401,7 +401,7 @@ MediaEngineDefaultAudioSource::GetUUID(nsACString& aUUID) const
|
|||
uint32_t
|
||||
MediaEngineDefaultAudioSource::GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
uint32_t distance = 0;
|
||||
#ifdef MOZ_WEBRTC
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
|
||||
void Shutdown() override {};
|
||||
|
||||
void GetName(nsAString&) const override;
|
||||
void GetUUID(nsACString&) const override;
|
||||
void GetName(nsAString&) override;
|
||||
void GetUUID(nsACString&) override;
|
||||
|
||||
nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs,
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
const PrincipalHandle& aPrincipalHandle) override;
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const override;
|
||||
const nsString& aDeviceId) override;
|
||||
|
||||
bool IsFake() override {
|
||||
return true;
|
||||
|
@ -116,8 +116,8 @@ public:
|
|||
|
||||
void Shutdown() override {};
|
||||
|
||||
void GetName(nsAString&) const override;
|
||||
void GetUUID(nsACString&) const override;
|
||||
void GetName(nsAString&) override;
|
||||
void GetUUID(nsACString&) override;
|
||||
|
||||
nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
||||
const MediaEnginePrefs &aPrefs,
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const override;
|
||||
const nsString& aDeviceId) override;
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSITIMERCALLBACK
|
||||
|
|
|
@ -128,7 +128,6 @@ MediaEngineRemoteVideoSource::Allocate(
|
|||
}
|
||||
|
||||
if (!ChooseCapability(netConstraints, aPrefs, aDeviceId)) {
|
||||
*aOutBadConstraint = FindBadConstraint(netConstraints, *this, aDeviceId);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -315,7 +314,6 @@ MediaEngineRemoteVideoSource::Restart(BaseAllocationHandle* aHandle,
|
|||
}
|
||||
|
||||
if (!ChooseCapability(netConstraints, aPrefs, aDeviceId)) {
|
||||
*aOutBadConstraint = FindBadConstraint(netConstraints, *this, aDeviceId);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (mState != kStarted) {
|
||||
|
@ -428,7 +426,7 @@ MediaEngineRemoteVideoSource::DeliverFrame(unsigned char* buffer,
|
|||
}
|
||||
|
||||
size_t
|
||||
MediaEngineRemoteVideoSource::NumCapabilities() const
|
||||
MediaEngineRemoteVideoSource::NumCapabilities()
|
||||
{
|
||||
int num = mozilla::camera::GetChildAndCall(
|
||||
&mozilla::camera::CamerasChild::NumberOfCapabilities,
|
||||
|
@ -511,7 +509,7 @@ MediaEngineRemoteVideoSource::ChooseCapability(
|
|||
|
||||
void
|
||||
MediaEngineRemoteVideoSource::GetCapability(size_t aIndex,
|
||||
webrtc::CaptureCapability& aOut) const
|
||||
webrtc::CaptureCapability& aOut)
|
||||
{
|
||||
if (!mHardcodedCapabilities.IsEmpty()) {
|
||||
MediaEngineCameraVideoSource::GetCapability(aIndex, aOut);
|
||||
|
|
|
@ -119,8 +119,8 @@ protected:
|
|||
private:
|
||||
// Initialize the needed Video engine interfaces.
|
||||
void Init();
|
||||
size_t NumCapabilities() const override;
|
||||
void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut) const override;
|
||||
size_t NumCapabilities() override;
|
||||
void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut) override;
|
||||
|
||||
dom::MediaSourceEnum mMediaSource; // source of media (camera | application | screen)
|
||||
mozilla::camera::CaptureEngine mCapEngine;
|
||||
|
|
|
@ -120,13 +120,13 @@ MediaEngineTabVideoSource::InitRunnable::Run()
|
|||
}
|
||||
|
||||
void
|
||||
MediaEngineTabVideoSource::GetName(nsAString_internal& aName) const
|
||||
MediaEngineTabVideoSource::GetName(nsAString_internal& aName)
|
||||
{
|
||||
aName.AssignLiteral(MOZ_UTF16("&getUserMedia.videoSource.tabShare;"));
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineTabVideoSource::GetUUID(nsACString_internal& aUuid) const
|
||||
MediaEngineTabVideoSource::GetUUID(nsACString_internal& aUuid)
|
||||
{
|
||||
aUuid.AssignLiteral("tab");
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
|||
MediaEngineTabVideoSource();
|
||||
|
||||
void Shutdown() override {};
|
||||
void GetName(nsAString_internal&) const override;
|
||||
void GetUUID(nsACString_internal&) const override;
|
||||
void GetName(nsAString_internal&) override;
|
||||
void GetUUID(nsACString_internal&) override;
|
||||
nsresult Allocate(const dom::MediaTrackConstraints &,
|
||||
const mozilla::MediaEnginePrefs&,
|
||||
const nsString& aDeviceId,
|
||||
|
@ -44,7 +44,7 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
|||
}
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const override
|
||||
const nsString& aDeviceId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ public:
|
|||
: MediaEngineAudioSource(kReleased)
|
||||
{
|
||||
}
|
||||
void GetName(nsAString& aName) const override;
|
||||
void GetUUID(nsACString& aUUID) const override;
|
||||
void GetName(nsAString& aName) override;
|
||||
void GetUUID(nsACString& aUUID) override;
|
||||
nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
|
||||
const MediaEnginePrefs& aPrefs,
|
||||
const nsString& aDeviceId,
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
}
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const override;
|
||||
const nsString& aDeviceId) override;
|
||||
|
||||
protected:
|
||||
virtual ~MediaEngineWebRTCAudioCaptureSource() { Shutdown(); }
|
||||
|
@ -451,8 +451,8 @@ public:
|
|||
// We'll init lazily as needed
|
||||
}
|
||||
|
||||
void GetName(nsAString& aName) const override;
|
||||
void GetUUID(nsACString& aUUID) const override;
|
||||
void GetName(nsAString& aName) override;
|
||||
void GetUUID(nsACString& aUUID) override;
|
||||
|
||||
nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
|
||||
const MediaEnginePrefs& aPrefs,
|
||||
|
@ -503,7 +503,7 @@ public:
|
|||
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const override;
|
||||
const nsString& aDeviceId) override;
|
||||
|
||||
// VoEMediaProcess.
|
||||
void Process(int channel, webrtc::ProcessingTypes type,
|
||||
|
|
|
@ -184,14 +184,14 @@ AudioOutputObserver::InsertFarEnd(const AudioDataValue *aBuffer, uint32_t aFrame
|
|||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTCMicrophoneSource::GetName(nsAString& aName) const
|
||||
MediaEngineWebRTCMicrophoneSource::GetName(nsAString& aName)
|
||||
{
|
||||
aName.Assign(mDeviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTCMicrophoneSource::GetUUID(nsACString& aUUID) const
|
||||
MediaEngineWebRTCMicrophoneSource::GetUUID(nsACString& aUUID)
|
||||
{
|
||||
aUUID.Assign(mDeviceUUID);
|
||||
return;
|
||||
|
@ -207,7 +207,7 @@ MediaEngineWebRTCMicrophoneSource::GetUUID(nsACString& aUUID) const
|
|||
|
||||
uint32_t MediaEngineWebRTCMicrophoneSource::GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
uint32_t distance = 0;
|
||||
|
||||
|
@ -799,13 +799,13 @@ MediaEngineWebRTCMicrophoneSource::Process(int channel,
|
|||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTCAudioCaptureSource::GetName(nsAString &aName) const
|
||||
MediaEngineWebRTCAudioCaptureSource::GetName(nsAString &aName)
|
||||
{
|
||||
aName.AssignLiteral("AudioCapture");
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTCAudioCaptureSource::GetUUID(nsACString &aUUID) const
|
||||
MediaEngineWebRTCAudioCaptureSource::GetUUID(nsACString &aUUID)
|
||||
{
|
||||
nsID uuid;
|
||||
char uuidBuffer[NSID_LENGTH];
|
||||
|
@ -860,7 +860,7 @@ MediaEngineWebRTCAudioCaptureSource::Restart(
|
|||
uint32_t
|
||||
MediaEngineWebRTCAudioCaptureSource::GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
const nsString& aDeviceId) const
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
// There is only one way of capturing audio for now, and it's always adequate.
|
||||
return 0;
|
||||
|
|
|
@ -392,43 +392,4 @@ MediaConstraintsHelper::FitnessDistance(
|
|||
return 0;
|
||||
}
|
||||
|
||||
template<class MediaEngineSourceType>
|
||||
const char*
|
||||
MediaConstraintsHelper::FindBadConstraint(
|
||||
const NormalizedConstraints& aConstraints,
|
||||
const MediaEngineSourceType& aMediaEngineSource,
|
||||
const nsString& aDeviceId)
|
||||
{
|
||||
class MockDevice
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MockDevice);
|
||||
|
||||
explicit MockDevice(const MediaEngineSourceType* aMediaEngineSource,
|
||||
const nsString& aDeviceId)
|
||||
: mMediaEngineSource(aMediaEngineSource),
|
||||
// The following dud code exists to avoid 'unused typedef' error on linux.
|
||||
mDeviceId(MockDevice::HasThreadSafeRefCnt::value ? aDeviceId : nsString()) {}
|
||||
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets)
|
||||
{
|
||||
return mMediaEngineSource->GetBestFitnessDistance(aConstraintSets,
|
||||
mDeviceId);
|
||||
}
|
||||
|
||||
private:
|
||||
~MockDevice() {}
|
||||
|
||||
const MediaEngineSourceType* mMediaEngineSource;
|
||||
nsString mDeviceId;
|
||||
};
|
||||
|
||||
Unused << typename MockDevice::HasThreadSafeRefCnt();
|
||||
|
||||
nsTArray<RefPtr<MockDevice>> devices;
|
||||
devices.AppendElement(new MockDevice(&aMediaEngineSource, aDeviceId));
|
||||
return FindBadConstraint(aConstraints, devices);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -288,14 +288,14 @@ protected:
|
|||
template<class DeviceType>
|
||||
static bool
|
||||
SomeSettingsFit(const NormalizedConstraints &aConstraints,
|
||||
nsTArray<RefPtr<DeviceType>>& aDevices)
|
||||
nsTArray<RefPtr<DeviceType>>& aSources)
|
||||
{
|
||||
nsTArray<const NormalizedConstraintSet*> sets;
|
||||
sets.AppendElement(&aConstraints);
|
||||
|
||||
MOZ_ASSERT(aDevices.Length());
|
||||
for (auto& device : aDevices) {
|
||||
if (device->GetBestFitnessDistance(sets) != UINT32_MAX) {
|
||||
MOZ_ASSERT(aSources.Length());
|
||||
for (auto& source : aSources) {
|
||||
if (source->GetBestFitnessDistance(sets) != UINT32_MAX) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -303,12 +303,12 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
// Apply constrains to a supplied list of devices (removes items from the list)
|
||||
// Apply constrains to a supplied list of sources (removes items from the list)
|
||||
|
||||
template<class DeviceType>
|
||||
static const char*
|
||||
SelectSettings(const NormalizedConstraints &aConstraints,
|
||||
nsTArray<RefPtr<DeviceType>>& aDevices)
|
||||
nsTArray<RefPtr<DeviceType>>& aSources)
|
||||
{
|
||||
auto& c = aConstraints;
|
||||
|
||||
|
@ -323,25 +323,25 @@ public:
|
|||
|
||||
std::multimap<uint32_t, RefPtr<DeviceType>> ordered;
|
||||
|
||||
for (uint32_t i = 0; i < aDevices.Length();) {
|
||||
uint32_t distance = aDevices[i]->GetBestFitnessDistance(aggregateConstraints);
|
||||
for (uint32_t i = 0; i < aSources.Length();) {
|
||||
uint32_t distance = aSources[i]->GetBestFitnessDistance(aggregateConstraints);
|
||||
if (distance == UINT32_MAX) {
|
||||
unsatisfactory.AppendElement(aDevices[i]);
|
||||
aDevices.RemoveElementAt(i);
|
||||
unsatisfactory.AppendElement(aSources[i]);
|
||||
aSources.RemoveElementAt(i);
|
||||
} else {
|
||||
ordered.insert(std::pair<uint32_t, RefPtr<DeviceType>>(distance,
|
||||
aDevices[i]));
|
||||
aSources[i]));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
if (!aDevices.Length()) {
|
||||
if (!aSources.Length()) {
|
||||
return FindBadConstraint(c, unsatisfactory);
|
||||
}
|
||||
|
||||
// Order devices by shortest distance
|
||||
for (auto& ordinal : ordered) {
|
||||
aDevices.RemoveElement(ordinal.second);
|
||||
aDevices.AppendElement(ordinal.second);
|
||||
aSources.RemoveElement(ordinal.second);
|
||||
aSources.AppendElement(ordinal.second);
|
||||
}
|
||||
|
||||
// Then apply advanced constraints.
|
||||
|
@ -349,16 +349,16 @@ public:
|
|||
for (int i = 0; i < int(c.mAdvanced.Length()); i++) {
|
||||
aggregateConstraints.AppendElement(&c.mAdvanced[i]);
|
||||
nsTArray<RefPtr<DeviceType>> rejects;
|
||||
for (uint32_t j = 0; j < aDevices.Length();) {
|
||||
if (aDevices[j]->GetBestFitnessDistance(aggregateConstraints) == UINT32_MAX) {
|
||||
rejects.AppendElement(aDevices[j]);
|
||||
aDevices.RemoveElementAt(j);
|
||||
for (uint32_t j = 0; j < aSources.Length();) {
|
||||
if (aSources[j]->GetBestFitnessDistance(aggregateConstraints) == UINT32_MAX) {
|
||||
rejects.AppendElement(aSources[j]);
|
||||
aSources.RemoveElementAt(j);
|
||||
} else {
|
||||
++j;
|
||||
}
|
||||
}
|
||||
if (!aDevices.Length()) {
|
||||
aDevices.AppendElements(Move(rejects));
|
||||
if (!aSources.Length()) {
|
||||
aSources.AppendElements(Move(rejects));
|
||||
aggregateConstraints.RemoveElementAt(aggregateConstraints.Length() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ public:
|
|||
template<class DeviceType>
|
||||
static const char*
|
||||
FindBadConstraint(const NormalizedConstraints& aConstraints,
|
||||
nsTArray<RefPtr<DeviceType>>& aDevices)
|
||||
nsTArray<RefPtr<DeviceType>>& aSources)
|
||||
{
|
||||
// The spec says to report a constraint that satisfies NONE
|
||||
// of the sources. Unfortunately, this is a bit laborious to find out, and
|
||||
|
@ -376,53 +376,47 @@ public:
|
|||
auto& c = aConstraints;
|
||||
dom::MediaTrackConstraints empty;
|
||||
|
||||
if (!aDevices.Length() ||
|
||||
!SomeSettingsFit(NormalizedConstraints(empty), aDevices)) {
|
||||
if (!aSources.Length() ||
|
||||
!SomeSettingsFit(NormalizedConstraints(empty), aSources)) {
|
||||
return "";
|
||||
}
|
||||
{
|
||||
NormalizedConstraints fresh(empty);
|
||||
fresh.mDeviceId = c.mDeviceId;
|
||||
if (!SomeSettingsFit(fresh, aDevices)) {
|
||||
if (!SomeSettingsFit(fresh, aSources)) {
|
||||
return "deviceId";
|
||||
}
|
||||
}
|
||||
{
|
||||
NormalizedConstraints fresh(empty);
|
||||
fresh.mWidth = c.mWidth;
|
||||
if (!SomeSettingsFit(fresh, aDevices)) {
|
||||
if (!SomeSettingsFit(fresh, aSources)) {
|
||||
return "width";
|
||||
}
|
||||
}
|
||||
{
|
||||
NormalizedConstraints fresh(empty);
|
||||
fresh.mHeight = c.mHeight;
|
||||
if (!SomeSettingsFit(fresh, aDevices)) {
|
||||
if (!SomeSettingsFit(fresh, aSources)) {
|
||||
return "height";
|
||||
}
|
||||
}
|
||||
{
|
||||
NormalizedConstraints fresh(empty);
|
||||
fresh.mFrameRate = c.mFrameRate;
|
||||
if (!SomeSettingsFit(fresh, aDevices)) {
|
||||
if (!SomeSettingsFit(fresh, aSources)) {
|
||||
return "frameRate";
|
||||
}
|
||||
}
|
||||
{
|
||||
NormalizedConstraints fresh(empty);
|
||||
fresh.mFacingMode = c.mFacingMode;
|
||||
if (!SomeSettingsFit(fresh, aDevices)) {
|
||||
if (!SomeSettingsFit(fresh, aSources)) {
|
||||
return "facingMode";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
template<class MediaEngineSourceType>
|
||||
static const char*
|
||||
FindBadConstraint(const NormalizedConstraints& aConstraints,
|
||||
const MediaEngineSourceType& aMediaEngineSource,
|
||||
const nsString& aDeviceId);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче