зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 9 changesets (bug 1152401) for android gv-junit failures org.mozilla.geckoview.test.PermissionDelegateTest.media on a CLOSED TREE
Backed out changeset 987f2e0b2cb1 (bug 1152401) Backed out changeset e45630a7c7b1 (bug 1152401) Backed out changeset 95661c6cd914 (bug 1152401) Backed out changeset d68ab111809f (bug 1152401) Backed out changeset 10b039210911 (bug 1152401) Backed out changeset aebabaa96ad3 (bug 1152401) Backed out changeset 93457990e40f (bug 1152401) Backed out changeset 1630f67ac197 (bug 1152401) Backed out changeset aef64bf5b024 (bug 1152401)
This commit is contained in:
Родитель
636e7285e3
Коммит
0cf58ddcab
|
@ -171,7 +171,7 @@ function prompt(aContentWindow, aWindowID, aCallID, aConstraints, aDevices, aSec
|
|||
for (let device of aDevices) {
|
||||
device = device.QueryInterface(Ci.nsIMediaDevice);
|
||||
switch (device.type) {
|
||||
case "audioinput":
|
||||
case "audio":
|
||||
// Check that if we got a microphone, we have not requested an audio
|
||||
// capture, and if we have requested an audio capture, we are not
|
||||
// getting a microphone instead.
|
||||
|
@ -181,7 +181,7 @@ function prompt(aContentWindow, aWindowID, aCallID, aConstraints, aDevices, aSec
|
|||
devices.push(device);
|
||||
}
|
||||
break;
|
||||
case "videoinput":
|
||||
case "video":
|
||||
// Verify that if we got a camera, we haven't requested a screen share,
|
||||
// or that if we requested a screen share we aren't getting a camera.
|
||||
if (video && (device.mediaSource == "camera") != sharingScreen) {
|
||||
|
|
|
@ -7,31 +7,7 @@
|
|||
|
||||
NS_IMPL_ISUPPORTS(AudioDeviceInfo, nsIAudioDeviceInfo)
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::CubebUtils;
|
||||
|
||||
AudioDeviceInfo::AudioDeviceInfo(cubeb_device_info* aInfo)
|
||||
:AudioDeviceInfo(aInfo->devid,
|
||||
NS_ConvertUTF8toUTF16(aInfo->friendly_name),
|
||||
NS_ConvertUTF8toUTF16(aInfo->group_id),
|
||||
NS_ConvertUTF8toUTF16(aInfo->vendor_name),
|
||||
aInfo->type,
|
||||
aInfo->state,
|
||||
aInfo->preferred,
|
||||
aInfo->format,
|
||||
aInfo->default_format,
|
||||
aInfo->max_channels,
|
||||
aInfo->default_rate,
|
||||
aInfo->max_rate,
|
||||
aInfo->min_rate,
|
||||
aInfo->latency_lo,
|
||||
aInfo->latency_hi)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AudioDeviceInfo::AudioDeviceInfo(AudioDeviceID aID,
|
||||
const nsAString& aName,
|
||||
AudioDeviceInfo::AudioDeviceInfo(const nsAString& aName,
|
||||
const nsAString& aGroupId,
|
||||
const nsAString& aVendor,
|
||||
uint16_t aType,
|
||||
|
@ -44,9 +20,8 @@ AudioDeviceInfo::AudioDeviceInfo(AudioDeviceID aID,
|
|||
uint32_t aMaxRate,
|
||||
uint32_t aMinRate,
|
||||
uint32_t aMaxLatency,
|
||||
uint32_t aMinLatency)
|
||||
: mDeviceId(aID)
|
||||
, mName(aName)
|
||||
uint32_t aMinLatency)
|
||||
: mName(aName)
|
||||
, mGroupId(aGroupId)
|
||||
, mVendor(aVendor)
|
||||
, mType(aType)
|
||||
|
@ -79,32 +54,6 @@ AudioDeviceInfo::AudioDeviceInfo(AudioDeviceID aID,
|
|||
mDefaultFormat == FMT_F32BE, "Wrong default format");
|
||||
}
|
||||
|
||||
Maybe<AudioDeviceID>
|
||||
AudioDeviceInfo::GetDeviceID()
|
||||
{
|
||||
if (mDeviceId) {
|
||||
return Some(mDeviceId);
|
||||
}
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
const nsString& AudioDeviceInfo::FriendlyName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
uint32_t AudioDeviceInfo::MaxChannels()
|
||||
{
|
||||
return mMaxChannels;
|
||||
}
|
||||
uint32_t AudioDeviceInfo::Type()
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
uint32_t AudioDeviceInfo::State()
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
/* readonly attribute DOMString name; */
|
||||
NS_IMETHODIMP
|
||||
AudioDeviceInfo::GetName(nsAString& aName)
|
||||
|
|
|
@ -7,61 +7,47 @@
|
|||
#define MOZILLA_AudioDeviceInfo_H
|
||||
|
||||
#include "nsIAudioDeviceInfo.h"
|
||||
#include "CubebUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
// This is mapped to the cubeb_device_info.
|
||||
class AudioDeviceInfo final : public nsIAudioDeviceInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIAUDIODEVICEINFO
|
||||
|
||||
using AudioDeviceID = mozilla::CubebUtils::AudioDeviceID;
|
||||
explicit AudioDeviceInfo(const nsAString& aName,
|
||||
const nsAString& aGroupId,
|
||||
const nsAString& aVendor,
|
||||
uint16_t aType,
|
||||
uint16_t aState,
|
||||
uint16_t aPreferred,
|
||||
uint16_t aSupportedFormat,
|
||||
uint16_t aDefaultFormat,
|
||||
uint32_t aMaxChannels,
|
||||
uint32_t aDefaultRate,
|
||||
uint32_t aMaxRate,
|
||||
uint32_t aMinRate,
|
||||
uint32_t aMaxLatency,
|
||||
uint32_t aMinLatency);
|
||||
|
||||
AudioDeviceInfo(const AudioDeviceID aID,
|
||||
const nsAString& aName,
|
||||
const nsAString& aGroupId,
|
||||
const nsAString& aVendor,
|
||||
uint16_t aType,
|
||||
uint16_t aState,
|
||||
uint16_t aPreferred,
|
||||
uint16_t aSupportedFormat,
|
||||
uint16_t aDefaultFormat,
|
||||
uint32_t aMaxChannels,
|
||||
uint32_t aDefaultRate,
|
||||
uint32_t aMaxRate,
|
||||
uint32_t aMinRate,
|
||||
uint32_t aMaxLatency,
|
||||
uint32_t aMinLatency);
|
||||
|
||||
explicit AudioDeviceInfo(cubeb_device_info* aInfo);
|
||||
// It is possible to not know the device identifier here. It depends on which
|
||||
// ctor this instance has been constructed with.
|
||||
mozilla::Maybe<AudioDeviceID> GetDeviceID();
|
||||
const nsString& FriendlyName();
|
||||
uint32_t MaxChannels();
|
||||
uint32_t Type();
|
||||
uint32_t State();
|
||||
private:
|
||||
virtual ~AudioDeviceInfo() = default;
|
||||
|
||||
const AudioDeviceID mDeviceId;
|
||||
const nsString mName;
|
||||
const nsString mGroupId;
|
||||
const nsString mVendor;
|
||||
const uint16_t mType;
|
||||
const uint16_t mState;
|
||||
const uint16_t mPreferred;
|
||||
const uint16_t mSupportedFormat;
|
||||
const uint16_t mDefaultFormat;
|
||||
const uint32_t mMaxChannels;
|
||||
const uint32_t mDefaultRate;
|
||||
const uint32_t mMaxRate;
|
||||
const uint32_t mMinRate;
|
||||
const uint32_t mMaxLatency;
|
||||
const uint32_t mMinLatency;
|
||||
nsString mName;
|
||||
nsString mGroupId;
|
||||
nsString mVendor;
|
||||
uint16_t mType;
|
||||
uint16_t mState;
|
||||
uint16_t mPreferred;
|
||||
uint16_t mSupportedFormat;
|
||||
uint16_t mDefaultFormat;
|
||||
uint32_t mMaxChannels;
|
||||
uint32_t mDefaultRate;
|
||||
uint32_t mMaxRate;
|
||||
uint32_t mMinRate;
|
||||
uint32_t mMaxLatency;
|
||||
uint32_t mMinLatency;
|
||||
};
|
||||
|
||||
#endif // MOZILLA_AudioDeviceInfo_H
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "MediaInfo.h"
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/AudioDeviceInfo.h"
|
||||
#include "mozilla/ipc/FileDescriptor.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
@ -685,8 +684,7 @@ void GetDeviceCollection(nsTArray<RefPtr<AudioDeviceInfo>>& aDeviceInfos,
|
|||
for (unsigned int i = 0; i < collection.count; ++i) {
|
||||
auto device = collection.device[i];
|
||||
RefPtr<AudioDeviceInfo> info =
|
||||
new AudioDeviceInfo(device.devid,
|
||||
NS_ConvertUTF8toUTF16(device.friendly_name),
|
||||
new AudioDeviceInfo(NS_ConvertUTF8toUTF16(device.friendly_name),
|
||||
NS_ConvertUTF8toUTF16(device.group_id),
|
||||
NS_ConvertUTF8toUTF16(device.vendor_name),
|
||||
ConvertCubebType(device.type),
|
||||
|
|
|
@ -8,12 +8,9 @@
|
|||
#define CubebUtils_h_
|
||||
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/dom/AudioDeviceInfo.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
class AudioDeviceInfo;
|
||||
|
||||
namespace mozilla {
|
||||
namespace CubebUtils {
|
||||
|
||||
|
|
|
@ -113,21 +113,25 @@ public:
|
|||
}
|
||||
nsTArray<RefPtr<MediaDeviceInfo>> infos;
|
||||
for (auto& device : devices) {
|
||||
MediaDeviceKind kind = static_cast<MediaDevice*>(device.get())->mKind;
|
||||
MOZ_ASSERT(kind == dom::MediaDeviceKind::Audioinput
|
||||
|| kind == dom::MediaDeviceKind::Videoinput
|
||||
|| kind == dom::MediaDeviceKind::Audiooutput);
|
||||
nsString id;
|
||||
nsString name;
|
||||
device->GetId(id);
|
||||
// Include name only if page currently has a gUM stream active or
|
||||
// persistent permissions (audio or video) have been granted
|
||||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(mWindowId) ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled", false)) {
|
||||
device->GetName(name);
|
||||
nsString type;
|
||||
device->GetType(type);
|
||||
bool isVideo = type.EqualsLiteral("video");
|
||||
bool isAudio = type.EqualsLiteral("audio");
|
||||
if (isVideo || isAudio) {
|
||||
MediaDeviceKind kind = isVideo ?
|
||||
MediaDeviceKind::Videoinput : MediaDeviceKind::Audioinput;
|
||||
nsString id;
|
||||
nsString name;
|
||||
device->GetId(id);
|
||||
// Include name only if page currently has a gUM stream active or
|
||||
// persistent permissions (audio or video) have been granted
|
||||
if (MediaManager::Get()->IsActivelyCapturingOrHasAPermission(mWindowId) ||
|
||||
Preferences::GetBool("media.navigator.permission.disabled", false)) {
|
||||
device->GetName(name);
|
||||
}
|
||||
RefPtr<MediaDeviceInfo> info = new MediaDeviceInfo(id, kind, name);
|
||||
infos.AppendElement(info);
|
||||
}
|
||||
RefPtr<MediaDeviceInfo> info = new MediaDeviceInfo(id, kind, name);
|
||||
infos.AppendElement(info);
|
||||
}
|
||||
mPromise->MaybeResolve(infos);
|
||||
return NS_OK;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "MediaStreamGraph.h"
|
||||
#include "MediaTimer.h"
|
||||
#include "mozilla/dom/MediaStreamTrack.h"
|
||||
#include "mozilla/dom/MediaDeviceInfo.h"
|
||||
#include "MediaStreamListener.h"
|
||||
#include "nsArray.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -824,48 +823,13 @@ MediaDevice::MediaDevice(MediaEngineSource* aSource,
|
|||
const nsString& aID,
|
||||
const nsString& aRawID)
|
||||
: mSource(aSource)
|
||||
, mKind((mSource && MediaEngineSource::IsVideo(mSource->GetMediaSource())) ?
|
||||
dom::MediaDeviceKind::Videoinput : dom::MediaDeviceKind::Audioinput)
|
||||
, mIsVideo(MediaEngineSource::IsVideo(mSource->GetMediaSource()))
|
||||
, mScary(mSource->GetScary())
|
||||
, mType(NS_ConvertUTF8toUTF16(dom::MediaDeviceKindValues::strings[uint32_t(mKind)].value))
|
||||
, mType(mIsVideo ? NS_LITERAL_STRING("video") : NS_LITERAL_STRING("audio"))
|
||||
, mName(aName)
|
||||
, mID(aID)
|
||||
, mRawID(aRawID)
|
||||
{
|
||||
MOZ_ASSERT(mSource);
|
||||
}
|
||||
|
||||
MediaDevice::MediaDevice(const nsString& aName,
|
||||
const dom::MediaDeviceKind aKind,
|
||||
const nsString& aID,
|
||||
const nsString& aRawID)
|
||||
: mSource(nullptr)
|
||||
, mKind(aKind)
|
||||
, mScary(false)
|
||||
, mType(NS_ConvertUTF8toUTF16(dom::MediaDeviceKindValues::strings[uint32_t(mKind)].value))
|
||||
, mName(aName)
|
||||
, mID(aID)
|
||||
, mRawID(aRawID)
|
||||
{
|
||||
// For now this ctor is used only for Audiooutput.
|
||||
// It could be used for Audioinput and Videoinput
|
||||
// when we do not instantiate a MediaEngineSource
|
||||
// during EnumerateDevices.
|
||||
MOZ_ASSERT(mKind == dom::MediaDeviceKind::Audiooutput);
|
||||
}
|
||||
|
||||
MediaDevice::MediaDevice(const MediaDevice* aOther,
|
||||
const nsString& aID,
|
||||
const nsString& aRawID)
|
||||
: mSource(aOther->mSource)
|
||||
, mKind(aOther->mKind)
|
||||
, mScary(aOther->mScary)
|
||||
, mType(aOther->mType)
|
||||
, mName(aOther->mName)
|
||||
, mID(aID)
|
||||
, mRawID(aRawID)
|
||||
{
|
||||
MOZ_ASSERT(aOther);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -921,7 +885,6 @@ MediaDevice::GetBestFitnessDistance(
|
|||
bool aIsChrome)
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
|
||||
nsString mediaSource;
|
||||
GetMediaSource(mediaSource);
|
||||
|
@ -986,7 +949,6 @@ void
|
|||
MediaDevice::GetSettings(dom::MediaTrackSettings& aOutSettings) const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
mSource->GetSettings(aOutSettings);
|
||||
}
|
||||
|
||||
|
@ -1006,7 +968,6 @@ MediaDevice::Allocate(const dom::MediaTrackConstraints &aConstraints,
|
|||
const char** aOutBadConstraint)
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->Allocate(aConstraints,
|
||||
aPrefs,
|
||||
mID,
|
||||
|
@ -1021,7 +982,6 @@ MediaDevice::SetTrack(const RefPtr<SourceMediaStream>& aStream,
|
|||
const PrincipalHandle& aPrincipalHandle)
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->SetTrack(mAllocationHandle, aStream, aTrackID, aPrincipalHandle);
|
||||
}
|
||||
|
||||
|
@ -1029,7 +989,6 @@ nsresult
|
|||
MediaDevice::Start()
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->Start(mAllocationHandle);
|
||||
}
|
||||
|
||||
|
@ -1039,7 +998,6 @@ MediaDevice::Reconfigure(const dom::MediaTrackConstraints &aConstraints,
|
|||
const char** aOutBadConstraint)
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->Reconfigure(mAllocationHandle,
|
||||
aConstraints,
|
||||
aPrefs,
|
||||
|
@ -1051,7 +1009,6 @@ nsresult
|
|||
MediaDevice::FocusOnSelectedSource()
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->FocusOnSelectedSource(mAllocationHandle);
|
||||
}
|
||||
|
||||
|
@ -1059,7 +1016,6 @@ nsresult
|
|||
MediaDevice::Stop()
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->Stop(mAllocationHandle);
|
||||
}
|
||||
|
||||
|
@ -1067,7 +1023,6 @@ nsresult
|
|||
MediaDevice::Deallocate()
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->Deallocate(mAllocationHandle);
|
||||
}
|
||||
|
||||
|
@ -1080,7 +1035,6 @@ MediaDevice::Pull(const RefPtr<SourceMediaStream>& aStream,
|
|||
// This is on the graph thread, but mAllocationHandle is safe since we never
|
||||
// change it after it's been set, which is guaranteed to happen before
|
||||
// registering the listener for pulls.
|
||||
MOZ_ASSERT(mSource);
|
||||
mSource->Pull(mAllocationHandle, aStream, aTrackID, aDesiredTime, aPrincipal);
|
||||
}
|
||||
|
||||
|
@ -1089,7 +1043,6 @@ MediaDevice::GetMediaSource() const
|
|||
{
|
||||
// Threadsafe because mSource is const. GetMediaSource() might have other
|
||||
// requirements.
|
||||
MOZ_ASSERT(mSource);
|
||||
return mSource->GetMediaSource();
|
||||
}
|
||||
|
||||
|
@ -1541,19 +1494,19 @@ private:
|
|||
// Source getter returning full list
|
||||
|
||||
static void
|
||||
GetMediaDevices(MediaEngine *aEngine,
|
||||
uint64_t aWindowId,
|
||||
MediaSourceEnum aSrcType,
|
||||
nsTArray<RefPtr<MediaDevice>>& aResult,
|
||||
const char* aMediaDeviceName = nullptr)
|
||||
GetSources(MediaEngine *aEngine,
|
||||
uint64_t aWindowId,
|
||||
MediaSourceEnum aSrcType,
|
||||
nsTArray<RefPtr<MediaDevice>>& aResult,
|
||||
const char* aMediaDeviceName = nullptr)
|
||||
{
|
||||
MOZ_ASSERT(MediaManager::IsInMediaThread());
|
||||
|
||||
LOG(("%s: aEngine=%p, aWindowId=%" PRIu64 ", aSrcType=%" PRIu8 ", aMediaDeviceName=%s",
|
||||
__func__, aEngine, aWindowId, static_cast<uint8_t>(aSrcType),
|
||||
aMediaDeviceName ? aMediaDeviceName : "null"));
|
||||
nsTArray<RefPtr<MediaDevice>> devices;
|
||||
aEngine->EnumerateDevices(aWindowId, aSrcType, MediaSinkEnum::Other, &devices);
|
||||
nsTArray<RefPtr<MediaEngineSource>> sources;
|
||||
aEngine->EnumerateDevices(aWindowId, aSrcType, &sources);
|
||||
|
||||
/*
|
||||
* We're allowing multiple tabs to access the same camera for parity
|
||||
|
@ -1562,20 +1515,25 @@ GetMediaDevices(MediaEngine *aEngine,
|
|||
* to.
|
||||
*/
|
||||
if (aMediaDeviceName && *aMediaDeviceName) {
|
||||
for (auto& device : devices) {
|
||||
if (device->mName.EqualsASCII(aMediaDeviceName)) {
|
||||
aResult.AppendElement(device);
|
||||
for (auto& source : sources) {
|
||||
nsString deviceName = source->GetName();
|
||||
if (deviceName.EqualsASCII(aMediaDeviceName)) {
|
||||
aResult.AppendElement(MakeRefPtr<MediaDevice>(
|
||||
source,
|
||||
source->GetName(),
|
||||
NS_ConvertUTF8toUTF16(source->GetUUID())));
|
||||
LOG(("%s: found aMediaDeviceName=%s", __func__, aMediaDeviceName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
aResult = devices;
|
||||
if (MOZ_LOG_TEST(GetMediaManagerLog(), mozilla::LogLevel::Debug)) {
|
||||
for (auto& device : devices) {
|
||||
LOG(("%s: appending device=%s", __func__,
|
||||
NS_ConvertUTF16toUTF8(device->mName).get()));
|
||||
}
|
||||
for (auto& source : sources) {
|
||||
aResult.AppendElement(MakeRefPtr<MediaDevice>(
|
||||
source,
|
||||
source->GetName(),
|
||||
NS_ConvertUTF8toUTF16(source->GetUUID())));
|
||||
LOG(("%s: appending device=%s", __func__,
|
||||
NS_ConvertUTF16toUTF8(source->GetName()).get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1590,7 +1548,7 @@ already_AddRefed<MediaManager::PledgeChar>
|
|||
MediaManager::SelectSettings(
|
||||
MediaStreamConstraints& aConstraints,
|
||||
bool aIsChrome,
|
||||
RefPtr<Refcountable<UniquePtr<MediaDeviceSet>>>& aSources)
|
||||
RefPtr<Refcountable<UniquePtr<SourceSet>>>& aSources)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<PledgeChar> p = new PledgeChar();
|
||||
|
@ -1611,11 +1569,9 @@ MediaManager::SelectSettings(
|
|||
nsTArray<RefPtr<MediaDevice>> audios;
|
||||
|
||||
for (auto& source : sources) {
|
||||
MOZ_ASSERT(source->mKind == dom::MediaDeviceKind::Videoinput ||
|
||||
source->mKind == dom::MediaDeviceKind::Audioinput);
|
||||
if (source->mKind == dom::MediaDeviceKind::Videoinput) {
|
||||
if (source->mIsVideo) {
|
||||
videos.AppendElement(source);
|
||||
} else if (source->mKind == dom::MediaDeviceKind::Audioinput) {
|
||||
} else {
|
||||
audios.AppendElement(source);
|
||||
}
|
||||
}
|
||||
|
@ -1680,7 +1636,7 @@ public:
|
|||
MediaEnginePrefs& aPrefs,
|
||||
const ipc::PrincipalInfo& aPrincipalInfo,
|
||||
bool aIsChrome,
|
||||
MediaManager::MediaDeviceSet* aMediaDeviceSet,
|
||||
MediaManager::SourceSet* aSourceSet,
|
||||
bool aShouldFocusSource)
|
||||
: Runnable("GetUserMediaTask")
|
||||
, mConstraints(aConstraints)
|
||||
|
@ -1694,7 +1650,7 @@ public:
|
|||
, mIsChrome(aIsChrome)
|
||||
, mShouldFocusSource(aShouldFocusSource)
|
||||
, mDeviceChosen(false)
|
||||
, mMediaDeviceSet(aMediaDeviceSet)
|
||||
, mSourceSet(aSourceSet)
|
||||
, mManager(MediaManager::GetInstance())
|
||||
{}
|
||||
|
||||
|
@ -1886,7 +1842,7 @@ private:
|
|||
|
||||
bool mDeviceChosen;
|
||||
public:
|
||||
nsAutoPtr<MediaManager::MediaDeviceSet> mMediaDeviceSet;
|
||||
nsAutoPtr<MediaManager::SourceSet> mSourceSet;
|
||||
private:
|
||||
RefPtr<MediaManager> mManager; // get ref to this when creating the runnable
|
||||
};
|
||||
|
@ -1919,70 +1875,65 @@ private:
|
|||
* satisfy passed-in constraints. List contains raw id's.
|
||||
*/
|
||||
|
||||
already_AddRefed<MediaManager::PledgeMediaDeviceSet>
|
||||
already_AddRefed<MediaManager::PledgeSourceSet>
|
||||
MediaManager::EnumerateRawDevices(uint64_t aWindowId,
|
||||
MediaSourceEnum aVideoInputType,
|
||||
MediaSourceEnum aAudioInputType,
|
||||
MediaSinkEnum aAudioOutputType,
|
||||
DeviceEnumerationType aVideoInputEnumType /* = DeviceEnumerationType::Normal */,
|
||||
DeviceEnumerationType aAudioInputEnumType /* = DeviceEnumerationType::Normal */)
|
||||
MediaSourceEnum aVideoType,
|
||||
MediaSourceEnum aAudioType,
|
||||
DeviceEnumerationType aVideoEnumType /* = DeviceEnumerationType::Normal */,
|
||||
DeviceEnumerationType aAudioEnumType /* = DeviceEnumerationType::Normal */)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aVideoInputType != MediaSourceEnum::Other ||
|
||||
aAudioInputType != MediaSourceEnum::Other ||
|
||||
aAudioOutputType != MediaSinkEnum::Other);
|
||||
MOZ_ASSERT(aVideoType != MediaSourceEnum::Other ||
|
||||
aAudioType != MediaSourceEnum::Other);
|
||||
// Since the enums can take one of several values, the following asserts rely
|
||||
// on short circuting behavior. E.g. aVideoInputEnumType != Fake will be true if
|
||||
// on short circuting behavior. E.g. aVideoEnumType != Fake will be true if
|
||||
// the requested device is not fake and thus the assert will pass. However,
|
||||
// if the device is fake, aVideoInputType == MediaSourceEnum::Camera will be
|
||||
// if the device is fake, aVideoType == MediaSourceEnum::Camera will be
|
||||
// checked as well, ensuring that fake devices are of the camera type.
|
||||
MOZ_ASSERT(aVideoInputEnumType != DeviceEnumerationType::Fake ||
|
||||
aVideoInputType == MediaSourceEnum::Camera,
|
||||
MOZ_ASSERT(aVideoEnumType != DeviceEnumerationType::Fake ||
|
||||
aVideoType == MediaSourceEnum::Camera,
|
||||
"If fake cams are requested video type should be camera!");
|
||||
MOZ_ASSERT(aVideoInputEnumType != DeviceEnumerationType::Loopback ||
|
||||
aVideoInputType == MediaSourceEnum::Camera,
|
||||
MOZ_ASSERT(aVideoEnumType != DeviceEnumerationType::Loopback ||
|
||||
aVideoType == MediaSourceEnum::Camera,
|
||||
"If loopback video is requested video type should be camera!");
|
||||
MOZ_ASSERT(aAudioInputEnumType != DeviceEnumerationType::Fake ||
|
||||
aAudioInputType == MediaSourceEnum::Microphone,
|
||||
MOZ_ASSERT(aAudioEnumType != DeviceEnumerationType::Fake ||
|
||||
aAudioType == MediaSourceEnum::Microphone,
|
||||
"If fake mics are requested audio type should be microphone!");
|
||||
MOZ_ASSERT(aAudioInputEnumType != DeviceEnumerationType::Loopback ||
|
||||
aAudioInputType == MediaSourceEnum::Microphone,
|
||||
MOZ_ASSERT(aAudioEnumType != DeviceEnumerationType::Loopback ||
|
||||
aAudioType == MediaSourceEnum::Microphone,
|
||||
"If loopback audio is requested audio type should be microphone!");
|
||||
|
||||
LOG(("%s: aWindowId=%" PRIu64 ", aVideoInputType=%" PRIu8 ", aAudioInputType=%" PRIu8
|
||||
", aVideoInputEnumType=%" PRIu8 ", aAudioInputEnumType=%" PRIu8,
|
||||
LOG(("%s: aWindowId=%" PRIu64 ", aVideoType=%" PRIu8 ", aAudioType=%" PRIu8
|
||||
", aVideoEnumType=%" PRIu8 ", aAudioEnumType=%" PRIu8,
|
||||
__func__, aWindowId,
|
||||
static_cast<uint8_t>(aVideoInputType), static_cast<uint8_t>(aAudioInputType),
|
||||
static_cast<uint8_t>(aVideoInputEnumType), static_cast<uint8_t>(aAudioInputEnumType)));
|
||||
RefPtr<PledgeMediaDeviceSet> p = new PledgeMediaDeviceSet();
|
||||
static_cast<uint8_t>(aVideoType), static_cast<uint8_t>(aAudioType),
|
||||
static_cast<uint8_t>(aVideoEnumType), static_cast<uint8_t>(aAudioEnumType)));
|
||||
RefPtr<PledgeSourceSet> p = new PledgeSourceSet();
|
||||
uint32_t id = mOutstandingPledges.Append(*p);
|
||||
|
||||
bool hasVideo = aVideoInputType != MediaSourceEnum::Other;
|
||||
bool hasAudio = aAudioInputType != MediaSourceEnum::Other;
|
||||
bool hasAudioOutput = aAudioOutputType == MediaSinkEnum::Speaker;
|
||||
bool hasVideo = aVideoType != MediaSourceEnum::Other;
|
||||
bool hasAudio = aAudioType != MediaSourceEnum::Other;
|
||||
|
||||
// True of at least one of video input or audio input is a fake device
|
||||
bool fakeDeviceRequested = (aVideoInputEnumType == DeviceEnumerationType::Fake && hasVideo) ||
|
||||
(aAudioInputEnumType == DeviceEnumerationType::Fake && hasAudio);
|
||||
// True if at least one of video input or audio input is a real device
|
||||
// or there is audio output.
|
||||
bool realDeviceRequested = (aVideoInputEnumType != DeviceEnumerationType::Fake && hasVideo) ||
|
||||
(aAudioInputEnumType != DeviceEnumerationType::Fake && hasAudio) ||
|
||||
hasAudioOutput;
|
||||
// True of at least one of video or audio is a fake device
|
||||
bool fakeDeviceRequested = (aVideoEnumType == DeviceEnumerationType::Fake && hasVideo) ||
|
||||
(aAudioEnumType == DeviceEnumerationType::Fake && hasAudio);
|
||||
// True if at least one of video or audio is a real device
|
||||
bool realDeviceRequested = (aVideoEnumType != DeviceEnumerationType::Fake && hasVideo) ||
|
||||
(aAudioEnumType != DeviceEnumerationType::Fake && hasAudio);
|
||||
|
||||
nsAutoCString videoLoopDev, audioLoopDev;
|
||||
if (hasVideo && aVideoInputEnumType == DeviceEnumerationType::Loopback) {
|
||||
if (hasVideo && aVideoEnumType == DeviceEnumerationType::Loopback) {
|
||||
Preferences::GetCString("media.video_loopback_dev", videoLoopDev);
|
||||
}
|
||||
if (hasAudio && aAudioInputEnumType == DeviceEnumerationType::Loopback) {
|
||||
if (hasAudio && aAudioEnumType == DeviceEnumerationType::Loopback) {
|
||||
Preferences::GetCString("media.audio_loopback_dev", audioLoopDev);
|
||||
}
|
||||
|
||||
RefPtr<Runnable> task = NewTaskFrom([id, aWindowId, aVideoInputType, aAudioInputType,
|
||||
aVideoInputEnumType, aAudioInputEnumType,
|
||||
RefPtr<Runnable> task = NewTaskFrom([id, aWindowId, aVideoType, aAudioType,
|
||||
aVideoEnumType, aAudioEnumType,
|
||||
videoLoopDev, audioLoopDev,
|
||||
hasVideo, hasAudio, hasAudioOutput,
|
||||
fakeDeviceRequested, realDeviceRequested]() {
|
||||
hasVideo, hasAudio, fakeDeviceRequested,
|
||||
realDeviceRequested]() {
|
||||
// Only enumerate what's asked for, and only fake cams and mics.
|
||||
RefPtr<MediaEngine> fakeBackend, realBackend;
|
||||
if (fakeDeviceRequested) {
|
||||
|
@ -1994,40 +1945,34 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
|
|||
realBackend = manager->GetBackend(aWindowId);
|
||||
}
|
||||
|
||||
auto result = MakeUnique<MediaDeviceSet>();
|
||||
auto result = MakeUnique<SourceSet>();
|
||||
|
||||
if (hasVideo) {
|
||||
MediaDeviceSet videos;
|
||||
SourceSet videos;
|
||||
LOG(("EnumerateRawDevices Task: Getting video sources with %s backend",
|
||||
aVideoInputEnumType == DeviceEnumerationType::Fake ? "fake" : "real"));
|
||||
GetMediaDevices(aVideoInputEnumType == DeviceEnumerationType::Fake ? fakeBackend : realBackend,
|
||||
aWindowId, aVideoInputType, videos, videoLoopDev.get());
|
||||
result->AppendElements(videos);
|
||||
aVideoEnumType == DeviceEnumerationType::Fake ? "fake" : "real"));
|
||||
GetSources(aVideoEnumType == DeviceEnumerationType::Fake ? fakeBackend : realBackend,
|
||||
aWindowId, aVideoType, videos, videoLoopDev.get());
|
||||
for (auto& source : videos) {
|
||||
result->AppendElement(source);
|
||||
}
|
||||
}
|
||||
if (hasAudio) {
|
||||
MediaDeviceSet audios;
|
||||
SourceSet audios;
|
||||
LOG(("EnumerateRawDevices Task: Getting audio sources with %s backend",
|
||||
aAudioInputEnumType == DeviceEnumerationType::Fake ? "fake" : "real"));
|
||||
GetMediaDevices(aAudioInputEnumType == DeviceEnumerationType::Fake ? fakeBackend : realBackend,
|
||||
aWindowId, aAudioInputType, audios, audioLoopDev.get());
|
||||
result->AppendElements(audios);
|
||||
aVideoEnumType == DeviceEnumerationType::Fake ? "fake" : "real"));
|
||||
GetSources(aAudioEnumType == DeviceEnumerationType::Fake ? fakeBackend : realBackend,
|
||||
aWindowId, aAudioType, audios, audioLoopDev.get());
|
||||
for (auto& source : audios) {
|
||||
result->AppendElement(source);
|
||||
}
|
||||
}
|
||||
if (hasAudioOutput) {
|
||||
MediaDeviceSet outputs;
|
||||
MOZ_ASSERT(realBackend);
|
||||
realBackend->EnumerateDevices(aWindowId,
|
||||
MediaSourceEnum::Other,
|
||||
MediaSinkEnum::Speaker,
|
||||
&outputs);
|
||||
result->AppendElements(outputs);
|
||||
}
|
||||
|
||||
NS_DispatchToMainThread(NewRunnableFrom([id, result = std::move(result)]() mutable {
|
||||
MediaManager* mgr = MediaManager::GetIfExists();
|
||||
if (!mgr) {
|
||||
return NS_OK;
|
||||
}
|
||||
RefPtr<PledgeMediaDeviceSet> p = mgr->mOutstandingPledges.Remove(id);
|
||||
RefPtr<PledgeSourceSet> p = mgr->mOutstandingPledges.Remove(id);
|
||||
if (p) {
|
||||
p->Resolve(result.release());
|
||||
}
|
||||
|
@ -2040,9 +1985,9 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
|
|||
// Need to ask permission to retrieve list of all devices;
|
||||
// notify frontend observer and wait for callback notification to post task.
|
||||
const char16_t* const type =
|
||||
(aVideoInputType != MediaSourceEnum::Camera) ? u"audio" :
|
||||
(aAudioInputType != MediaSourceEnum::Microphone) ? u"video" :
|
||||
u"all";
|
||||
(aVideoType != MediaSourceEnum::Camera) ? u"audio" :
|
||||
(aAudioType != MediaSourceEnum::Microphone) ? u"video" :
|
||||
u"all";
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
obs->NotifyObservers(static_cast<nsIRunnable*>(task),
|
||||
"getUserMedia:ask-device-permission",
|
||||
|
@ -2361,15 +2306,14 @@ void MediaManager::OnDeviceChange() {
|
|||
}
|
||||
self->DeviceChangeCallback::OnDeviceChange();
|
||||
|
||||
// On some Windows machine, if we call EnumerateRawDevices immediately after receiving
|
||||
// On some Windows machine, if we call EnumertaeRawDevices immediately after receiving
|
||||
// devicechange event, sometimes we would get outdated devices list.
|
||||
PR_Sleep(PR_MillisecondsToInterval(100));
|
||||
RefPtr<PledgeMediaDeviceSet> p = self->EnumerateRawDevices(0,
|
||||
MediaSourceEnum::Camera,
|
||||
MediaSourceEnum::Microphone,
|
||||
MediaSinkEnum::Speaker);
|
||||
p->Then([self](MediaDeviceSet*& aDevices) mutable {
|
||||
UniquePtr<MediaDeviceSet> devices(aDevices);
|
||||
RefPtr<PledgeSourceSet> p = self->EnumerateRawDevices(0,
|
||||
MediaSourceEnum::Camera,
|
||||
MediaSourceEnum::Microphone);
|
||||
p->Then([self](SourceSet*& aDevices) mutable {
|
||||
UniquePtr<SourceSet> devices(aDevices);
|
||||
nsTArray<nsString> deviceIDs;
|
||||
|
||||
for (auto& device : *devices) {
|
||||
|
@ -2875,19 +2819,17 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
|
|||
static_cast<uint8_t>(videoEnumerationType), static_cast<uint8_t>(audioEnumerationType),
|
||||
askPermission ? "true" : "false"));
|
||||
|
||||
RefPtr<PledgeMediaDeviceSet> p = EnumerateDevicesImpl(windowID,
|
||||
videoType,
|
||||
audioType,
|
||||
MediaSinkEnum::Other,
|
||||
videoEnumerationType,
|
||||
audioEnumerationType);
|
||||
RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowID, videoType,
|
||||
audioType,
|
||||
videoEnumerationType,
|
||||
audioEnumerationType);
|
||||
RefPtr<MediaManager> self = this;
|
||||
p->Then([self, onSuccess, onFailure, windowID, c, windowListener,
|
||||
sourceListener, askPermission, prefs, isHTTPS, isHandlingUserInput,
|
||||
callID, principalInfo, isChrome, resistFingerprinting](MediaDeviceSet*& aDevices) mutable {
|
||||
callID, principalInfo, isChrome, resistFingerprinting](SourceSet*& aDevices) mutable {
|
||||
LOG(("GetUserMedia: post enumeration pledge success callback starting"));
|
||||
// grab result
|
||||
auto devices = MakeRefPtr<Refcountable<UniquePtr<MediaDeviceSet>>>(aDevices);
|
||||
auto devices = MakeRefPtr<Refcountable<UniquePtr<SourceSet>>>(aDevices);
|
||||
|
||||
// Ensure that our windowID is still good.
|
||||
if (!nsGlobalWindowInner::GetInnerWindowWithId(windowID)) {
|
||||
|
@ -3010,7 +2952,7 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
|
|||
}
|
||||
|
||||
/* static */ void
|
||||
MediaManager::AnonymizeDevices(MediaDeviceSet& aDevices, const nsACString& aOriginKey)
|
||||
MediaManager::AnonymizeDevices(SourceSet& aDevices, const nsACString& aOriginKey)
|
||||
{
|
||||
if (!aOriginKey.IsEmpty()) {
|
||||
for (RefPtr<MediaDevice>& device : aDevices) {
|
||||
|
@ -3018,7 +2960,10 @@ MediaManager::AnonymizeDevices(MediaDeviceSet& aDevices, const nsACString& aOrig
|
|||
device->GetId(id);
|
||||
nsString rawId(id);
|
||||
AnonymizeId(id, aOriginKey);
|
||||
device = new MediaDevice(device, id, rawId);
|
||||
device = new MediaDevice(device->mSource,
|
||||
device->mName,
|
||||
id,
|
||||
rawId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3071,7 +3016,7 @@ MediaManager::AnonymizeId(nsAString& aId, const nsACString& aOriginKey)
|
|||
|
||||
/* static */
|
||||
already_AddRefed<nsIWritableVariant>
|
||||
MediaManager::ToJSArray(MediaDeviceSet& aDevices)
|
||||
MediaManager::ToJSArray(SourceSet& aDevices)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RefPtr<nsVariantCC> var = new nsVariantCC();
|
||||
|
@ -3094,26 +3039,25 @@ MediaManager::ToJSArray(MediaDeviceSet& aDevices)
|
|||
return var.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<MediaManager::PledgeMediaDeviceSet>
|
||||
already_AddRefed<MediaManager::PledgeSourceSet>
|
||||
MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
|
||||
MediaSourceEnum aVideoInputType,
|
||||
MediaSourceEnum aAudioInputType,
|
||||
MediaSinkEnum aAudioOutputType,
|
||||
DeviceEnumerationType aVideoInputEnumType,
|
||||
DeviceEnumerationType aAudioInputEnumType)
|
||||
MediaSourceEnum aVideoType,
|
||||
MediaSourceEnum aAudioType,
|
||||
DeviceEnumerationType aVideoEnumType /* = DeviceEnumerationType::Normal */,
|
||||
DeviceEnumerationType aAudioEnumType /* = DeviceEnumerationType::Normal */)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
LOG(("%s: aWindowId=%" PRIu64 ", aVideoInputType=%" PRIu8 ", aAudioInputType=%" PRIu8
|
||||
", aVideoInputEnumType=%" PRIu8 ", aAudioInputEnumType=%" PRIu8,
|
||||
LOG(("%s: aWindowId=%" PRIu64 ", aVideoType=%" PRIu8 ", aAudioType=%" PRIu8
|
||||
", aVideoEnumType=%" PRIu8 ", aAudioEnumType=%" PRIu8,
|
||||
__func__, aWindowId,
|
||||
static_cast<uint8_t>(aVideoInputType), static_cast<uint8_t>(aAudioInputType),
|
||||
static_cast<uint8_t>(aVideoInputEnumType), static_cast<uint8_t>(aAudioInputEnumType)));
|
||||
static_cast<uint8_t>(aVideoType), static_cast<uint8_t>(aAudioType),
|
||||
static_cast<uint8_t>(aVideoEnumType), static_cast<uint8_t>(aAudioEnumType)));
|
||||
nsPIDOMWindowInner* window =
|
||||
nsGlobalWindowInner::GetInnerWindowWithId(aWindowId)->AsInner();
|
||||
|
||||
// This function returns a pledge, a promise-like object with the future result
|
||||
RefPtr<PledgeMediaDeviceSet> pledge = new PledgeMediaDeviceSet();
|
||||
RefPtr<PledgeSourceSet> pledge = new PledgeSourceSet();
|
||||
uint32_t id = mOutstandingPledges.Append(*pledge);
|
||||
|
||||
// To get a device list anonymized for a particular origin, we must:
|
||||
|
@ -3128,7 +3072,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
|
|||
ipc::PrincipalInfo principalInfo;
|
||||
nsresult rv = PrincipalToPrincipalInfo(principal, &principalInfo);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
RefPtr<PledgeMediaDeviceSet> p = new PledgeMediaDeviceSet();
|
||||
RefPtr<PledgeSourceSet> p = new PledgeSourceSet();
|
||||
RefPtr<MediaStreamError> error =
|
||||
new MediaStreamError(window, MediaStreamError::Name::NotAllowedError);
|
||||
p->Reject(error);
|
||||
|
@ -3143,28 +3087,27 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
|
|||
// (passed by value) safely into the lambda.
|
||||
|
||||
RefPtr<Pledge<nsCString>> p = media::GetPrincipalKey(principalInfo, persist);
|
||||
p->Then([id, aWindowId, aVideoInputType, aAudioInputType,
|
||||
aVideoInputEnumType, aAudioInputEnumType, aAudioOutputType](const nsCString& aOriginKey) mutable {
|
||||
p->Then([id, aWindowId, aVideoType, aAudioType,
|
||||
aVideoEnumType, aAudioEnumType](const nsCString& aOriginKey) mutable {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MediaManager* mgr = MediaManager::GetIfExists();
|
||||
if (!mgr) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<PledgeMediaDeviceSet> p = mgr->EnumerateRawDevices(aWindowId,
|
||||
aVideoInputType,
|
||||
aAudioInputType,
|
||||
aAudioOutputType,
|
||||
aVideoInputEnumType,
|
||||
aAudioInputEnumType);
|
||||
RefPtr<PledgeSourceSet> p = mgr->EnumerateRawDevices(aWindowId,
|
||||
aVideoType,
|
||||
aAudioType,
|
||||
aVideoEnumType,
|
||||
aAudioEnumType);
|
||||
p->Then([id,
|
||||
aWindowId,
|
||||
aOriginKey,
|
||||
aVideoInputEnumType,
|
||||
aAudioInputEnumType,
|
||||
aVideoInputType,
|
||||
aAudioInputType](MediaDeviceSet*& aDevices) mutable {
|
||||
UniquePtr<MediaDeviceSet> devices(aDevices); // secondary result
|
||||
aVideoEnumType,
|
||||
aAudioEnumType,
|
||||
aVideoType,
|
||||
aAudioType](SourceSet*& aDevices) mutable {
|
||||
UniquePtr<SourceSet> devices(aDevices); // secondary result
|
||||
|
||||
// Only run if window is still on our active list.
|
||||
MediaManager* mgr = MediaManager::GetIfExists();
|
||||
|
@ -3174,10 +3117,10 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
|
|||
|
||||
// If we fetched any real cameras or mics, remove the "default" part of
|
||||
// their IDs.
|
||||
if (aVideoInputType == MediaSourceEnum::Camera &&
|
||||
aAudioInputType == MediaSourceEnum::Microphone &&
|
||||
(aVideoInputEnumType != DeviceEnumerationType::Fake ||
|
||||
aAudioInputEnumType != DeviceEnumerationType::Fake)) {
|
||||
if (aVideoType == MediaSourceEnum::Camera &&
|
||||
aAudioType == MediaSourceEnum::Microphone &&
|
||||
(aVideoEnumType != DeviceEnumerationType::Fake ||
|
||||
aAudioEnumType != DeviceEnumerationType::Fake)) {
|
||||
mgr->mDeviceIDs.Clear();
|
||||
for (auto& device : *devices) {
|
||||
nsString id;
|
||||
|
@ -3189,7 +3132,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<PledgeMediaDeviceSet> p = mgr->mOutstandingPledges.Remove(id);
|
||||
RefPtr<PledgeSourceSet> p = mgr->mOutstandingPledges.Remove(id);
|
||||
if (!p || !mgr->IsWindowStillActive(aWindowId)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3262,18 +3205,13 @@ MediaManager::EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
|||
}
|
||||
}
|
||||
|
||||
MediaSinkEnum audioOutputType = MediaSinkEnum::Other;
|
||||
if (Preferences::GetBool("media.setsinkid.enabled")) {
|
||||
audioOutputType = MediaSinkEnum::Speaker;
|
||||
}
|
||||
RefPtr<PledgeMediaDeviceSet> p = EnumerateDevicesImpl(windowId,
|
||||
MediaSourceEnum::Camera,
|
||||
MediaSourceEnum::Microphone,
|
||||
audioOutputType,
|
||||
videoEnumerationType,
|
||||
audioEnumerationType);
|
||||
p->Then([onSuccess, windowListener, sourceListener](MediaDeviceSet*& aDevices) mutable {
|
||||
UniquePtr<MediaDeviceSet> devices(aDevices); // grab result
|
||||
RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowId,
|
||||
MediaSourceEnum::Camera,
|
||||
MediaSourceEnum::Microphone,
|
||||
videoEnumerationType,
|
||||
audioEnumerationType);
|
||||
p->Then([onSuccess, windowListener, sourceListener](SourceSet*& aDevices) mutable {
|
||||
UniquePtr<SourceSet> devices(aDevices); // grab result
|
||||
DebugOnly<bool> rv = windowListener->Remove(sourceListener);
|
||||
MOZ_ASSERT(rv);
|
||||
nsCOMPtr<nsIWritableVariant> array = MediaManager_ToJSArray(*devices);
|
||||
|
@ -3316,7 +3254,7 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindowInner* aWindow,
|
|||
RefPtr<GetUserMediaTask> task;
|
||||
if (!aCallID.Length() || aCallID == callID) {
|
||||
if (mActiveCallbacks.Get(callID, getter_AddRefs(task))) {
|
||||
nsCOMPtr<nsIWritableVariant> array = MediaManager_ToJSArray(*task->mMediaDeviceSet);
|
||||
nsCOMPtr<nsIWritableVariant> array = MediaManager_ToJSArray(*task->mSourceSet);
|
||||
onSuccess->OnSuccess(array);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3716,17 +3654,16 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
continue;
|
||||
}
|
||||
|
||||
// Casting here is safe because a MediaDevice is created
|
||||
// only in Gecko side, JS can only query for an instance.
|
||||
MediaDevice* dev = static_cast<MediaDevice*>(device.get());
|
||||
if (dev->mKind == dom::MediaDeviceKind::Videoinput) {
|
||||
nsString type;
|
||||
device->GetType(type);
|
||||
if (type.EqualsLiteral("video")) {
|
||||
if (!videoFound) {
|
||||
task->SetVideoDevice(dev);
|
||||
task->SetVideoDevice(static_cast<MediaDevice*>(device.get()));
|
||||
videoFound = true;
|
||||
}
|
||||
} else if (dev->mKind == dom::MediaDeviceKind::Audioinput) {
|
||||
} else if (type.EqualsLiteral("audio")) {
|
||||
if (!audioFound) {
|
||||
task->SetAudioDevice(dev);
|
||||
task->SetAudioDevice(static_cast<MediaDevice*>(device.get()));
|
||||
audioFound = true;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -49,7 +49,6 @@ struct MediaStreamConstraints;
|
|||
struct MediaTrackConstraints;
|
||||
struct MediaTrackConstraintSet;
|
||||
enum class CallerType : uint32_t;
|
||||
enum class MediaDeviceKind : uint8_t;
|
||||
} // namespace dom
|
||||
|
||||
namespace ipc {
|
||||
|
@ -75,15 +74,6 @@ public:
|
|||
const nsString& aID,
|
||||
const nsString& aRawID = NS_LITERAL_STRING(""));
|
||||
|
||||
explicit MediaDevice(const nsString& aName,
|
||||
const dom::MediaDeviceKind aKind,
|
||||
const nsString& aID,
|
||||
const nsString& aRawID = NS_LITERAL_STRING(""));
|
||||
|
||||
explicit MediaDevice(const MediaDevice* aOther,
|
||||
const nsString& aID,
|
||||
const nsString& aRawID);
|
||||
|
||||
uint32_t GetBestFitnessDistance(
|
||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||
bool aIsChrome);
|
||||
|
@ -128,7 +118,7 @@ private:
|
|||
|
||||
public:
|
||||
const RefPtr<MediaEngineSource> mSource;
|
||||
const dom::MediaDeviceKind mKind;
|
||||
const bool mIsVideo;
|
||||
const bool mScary;
|
||||
const nsString mType;
|
||||
const nsString mName;
|
||||
|
@ -227,20 +217,20 @@ public:
|
|||
|
||||
MediaEnginePrefs mPrefs;
|
||||
|
||||
typedef nsTArray<RefPtr<MediaDevice>> MediaDeviceSet;
|
||||
typedef nsTArray<RefPtr<MediaDevice>> SourceSet;
|
||||
|
||||
virtual int AddDeviceChangeCallback(DeviceChangeCallback* aCallback) override;
|
||||
virtual void OnDeviceChange() override;
|
||||
private:
|
||||
typedef media::Pledge<MediaDeviceSet*, dom::MediaStreamError*> PledgeMediaDeviceSet;
|
||||
typedef media::Pledge<SourceSet*, dom::MediaStreamError*> PledgeSourceSet;
|
||||
typedef media::Pledge<const char*, dom::MediaStreamError*> PledgeChar;
|
||||
typedef media::Pledge<bool, dom::MediaStreamError*> PledgeVoid;
|
||||
|
||||
static nsresult GenerateUUID(nsAString& aResult);
|
||||
static nsresult AnonymizeId(nsAString& aId, const nsACString& aOriginKey);
|
||||
public: // TODO: make private once we upgrade to GCC 4.8+ on linux.
|
||||
static void AnonymizeDevices(MediaDeviceSet& aDevices, const nsACString& aOriginKey);
|
||||
static already_AddRefed<nsIWritableVariant> ToJSArray(MediaDeviceSet& aDevices);
|
||||
static void AnonymizeDevices(SourceSet& aDevices, const nsACString& aOriginKey);
|
||||
static already_AddRefed<nsIWritableVariant> ToJSArray(SourceSet& aDevices);
|
||||
private:
|
||||
enum class DeviceEnumerationType :uint8_t {
|
||||
Normal, // Enumeration should not return loopback or fake devices
|
||||
|
@ -248,25 +238,23 @@ private:
|
|||
Loopback /* Enumeration should return loopback device(s) (possibly in
|
||||
addition to normal devices) */
|
||||
};
|
||||
already_AddRefed<PledgeMediaDeviceSet>
|
||||
already_AddRefed<PledgeSourceSet>
|
||||
EnumerateRawDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum aVideoInputType,
|
||||
dom::MediaSourceEnum aAudioInputType,
|
||||
MediaSinkEnum aAudioOutputType,
|
||||
DeviceEnumerationType aVideoInputEnumType = DeviceEnumerationType::Normal,
|
||||
DeviceEnumerationType aAudioInputEnumType = DeviceEnumerationType::Normal);
|
||||
already_AddRefed<PledgeMediaDeviceSet>
|
||||
dom::MediaSourceEnum aVideoType,
|
||||
dom::MediaSourceEnum aAudioType,
|
||||
DeviceEnumerationType aVideoEnumType = DeviceEnumerationType::Normal,
|
||||
DeviceEnumerationType aAudioEnumType = DeviceEnumerationType::Normal);
|
||||
already_AddRefed<PledgeSourceSet>
|
||||
EnumerateDevicesImpl(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum aVideoInputType,
|
||||
dom::MediaSourceEnum aAudioInputType,
|
||||
MediaSinkEnum aAudioOutputType,
|
||||
DeviceEnumerationType aVideoInputEnumType,
|
||||
DeviceEnumerationType aAudioInputEnumType);
|
||||
dom::MediaSourceEnum aVideoType,
|
||||
dom::MediaSourceEnum aAudioType,
|
||||
DeviceEnumerationType aVideoEnumType = DeviceEnumerationType::Normal,
|
||||
DeviceEnumerationType aAudioEnumType = DeviceEnumerationType::Normal);
|
||||
already_AddRefed<PledgeChar>
|
||||
SelectSettings(
|
||||
dom::MediaStreamConstraints& aConstraints,
|
||||
bool aIsChrome,
|
||||
RefPtr<media::Refcountable<UniquePtr<MediaDeviceSet>>>& aSources);
|
||||
RefPtr<media::Refcountable<UniquePtr<SourceSet>>>& aSources);
|
||||
|
||||
void GetPref(nsIPrefBranch *aBranch, const char *aPref,
|
||||
const char *aData, int32_t *aVal);
|
||||
|
@ -308,7 +296,7 @@ private:
|
|||
|
||||
static StaticRefPtr<MediaManager> sSingleton;
|
||||
|
||||
media::CoatCheck<PledgeMediaDeviceSet> mOutstandingPledges;
|
||||
media::CoatCheck<PledgeSourceSet> mOutstandingPledges;
|
||||
media::CoatCheck<PledgeChar> mOutstandingCharPledges;
|
||||
nsTArray<nsString> mDeviceIDs;
|
||||
public:
|
||||
|
|
|
@ -23,11 +23,6 @@ class Blob;
|
|||
class AllocationHandle;
|
||||
class MediaEngineSource;
|
||||
|
||||
enum MediaSinkEnum {
|
||||
Speaker,
|
||||
Other,
|
||||
};
|
||||
|
||||
enum {
|
||||
kVideoTrack = 1,
|
||||
kAudioTrack = 2,
|
||||
|
@ -51,8 +46,7 @@ public:
|
|||
*/
|
||||
virtual void EnumerateDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum,
|
||||
MediaSinkEnum,
|
||||
nsTArray<RefPtr<MediaDevice>>*) = 0;
|
||||
nsTArray<RefPtr<MediaEngineSource>>*) = 0;
|
||||
|
||||
virtual void ReleaseResourcesForWindow(uint64_t aWindowId) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
|
|
@ -559,8 +559,7 @@ MediaEngineDefaultAudioSource::Pull(const RefPtr<const AllocationHandle>& aHandl
|
|||
void
|
||||
MediaEngineDefault::EnumerateDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum aMediaSource,
|
||||
MediaSinkEnum aMediaSink,
|
||||
nsTArray<RefPtr<MediaDevice>>* aDevices)
|
||||
nsTArray<RefPtr<MediaEngineSource>>* aSources)
|
||||
{
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
|
@ -576,10 +575,7 @@ MediaEngineDefault::EnumerateDevices(uint64_t aWindowId,
|
|||
devicesForThisWindow = mVSources.LookupOrAdd(aWindowId);
|
||||
auto newSource = MakeRefPtr<MediaEngineDefaultVideoSource>();
|
||||
devicesForThisWindow->AppendElement(newSource);
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
newSource,
|
||||
newSource->GetName(),
|
||||
NS_ConvertUTF8toUTF16(newSource->GetUUID())));
|
||||
aSources->AppendElement(newSource);
|
||||
return;
|
||||
}
|
||||
case dom::MediaSourceEnum::Microphone: {
|
||||
|
@ -587,21 +583,15 @@ MediaEngineDefault::EnumerateDevices(uint64_t aWindowId,
|
|||
devicesForThisWindow = mASources.LookupOrAdd(aWindowId);
|
||||
for (const RefPtr<MediaEngineDefaultAudioSource>& source : *devicesForThisWindow) {
|
||||
if (source->IsAvailable()) {
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
source,
|
||||
source->GetName(),
|
||||
NS_ConvertUTF8toUTF16(source->GetUUID())));
|
||||
aSources->AppendElement(source);
|
||||
}
|
||||
}
|
||||
|
||||
if (aDevices->IsEmpty()) {
|
||||
if (aSources->IsEmpty()) {
|
||||
// All streams are currently busy, just make a new one.
|
||||
auto newSource = MakeRefPtr<MediaEngineDefaultAudioSource>();
|
||||
devicesForThisWindow->AppendElement(newSource);
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
newSource,
|
||||
newSource->GetName(),
|
||||
NS_ConvertUTF8toUTF16(newSource->GetUUID())));
|
||||
aSources->AppendElement(newSource);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -609,10 +599,6 @@ MediaEngineDefault::EnumerateDevices(uint64_t aWindowId,
|
|||
MOZ_ASSERT_UNREACHABLE("Unsupported source type");
|
||||
return;
|
||||
}
|
||||
|
||||
if (aMediaSink == MediaSinkEnum::Speaker) {
|
||||
NS_WARNING("No default implementation for MediaSinkEnum::Speaker");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -189,8 +189,7 @@ public:
|
|||
|
||||
void EnumerateDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum,
|
||||
MediaSinkEnum,
|
||||
nsTArray<RefPtr<MediaDevice>>*) override;
|
||||
nsTArray<RefPtr<MediaEngineSource>>*) override;
|
||||
void Shutdown() override;
|
||||
void ReleaseResourcesForWindow(uint64_t aWindowId) override;
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ MediaEngineSource::IsVideo(MediaSourceEnum aSource)
|
|||
return true;
|
||||
case MediaSourceEnum::Microphone:
|
||||
case MediaSourceEnum::AudioCapture:
|
||||
case MediaSourceEnum::Other:
|
||||
return false;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown type");
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "MediaEngineTabVideoSource.h"
|
||||
#include "MediaEngineRemoteVideoSource.h"
|
||||
#include "MediaTrackConstraints.h"
|
||||
#include "mozilla/dom/MediaDeviceInfo.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
@ -126,7 +125,7 @@ MediaEngineWebRTC::SetFakeDeviceChangeEvents()
|
|||
void
|
||||
MediaEngineWebRTC::EnumerateVideoDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum aMediaSource,
|
||||
nsTArray<RefPtr<MediaDevice> >* aDevices)
|
||||
nsTArray<RefPtr<MediaEngineSource> >* aSources)
|
||||
{
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
|
||||
|
@ -229,29 +228,23 @@ MediaEngineWebRTC::EnumerateVideoDevices(uint64_t aWindowId,
|
|||
vSource->RequiresSharing()) {
|
||||
// We've already seen this shared device, just refresh and append.
|
||||
static_cast<MediaEngineRemoteVideoSource*>(vSource.get())->Refresh(i);
|
||||
aSources->AppendElement(vSource.get());
|
||||
} else {
|
||||
vSource = new MediaEngineRemoteVideoSource(i, capEngine, aMediaSource,
|
||||
scaryKind || scarySource);
|
||||
devicesForThisWindow->Put(uuid, vSource);
|
||||
aSources->AppendElement(vSource);
|
||||
}
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
vSource,
|
||||
vSource->GetName(),
|
||||
NS_ConvertUTF8toUTF16(vSource->GetUUID())));
|
||||
}
|
||||
|
||||
if (mHasTabVideoSource || dom::MediaSourceEnum::Browser == aMediaSource) {
|
||||
RefPtr<MediaEngineSource> tabVideoSource = new MediaEngineTabVideoSource();
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
tabVideoSource,
|
||||
tabVideoSource->GetName(),
|
||||
NS_ConvertUTF8toUTF16(tabVideoSource->GetUUID())));
|
||||
aSources->AppendElement(new MediaEngineTabVideoSource());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTC::EnumerateMicrophoneDevices(uint64_t aWindowId,
|
||||
nsTArray<RefPtr<MediaDevice> >* aDevices)
|
||||
nsTArray<RefPtr<MediaEngineSource> >* aSources)
|
||||
{
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
|
||||
|
@ -291,47 +284,23 @@ MediaEngineWebRTC::EnumerateMicrophoneDevices(uint64_t aWindowId,
|
|||
}
|
||||
|
||||
|
||||
RefPtr<MediaEngineSource> micSource;
|
||||
RefPtr<MediaEngineSource> aSource;
|
||||
NS_ConvertUTF8toUTF16 uuid(uniqueId);
|
||||
|
||||
nsRefPtrHashtable<nsStringHashKey, MediaEngineSource>*
|
||||
devicesForThisWindow = mAudioSources.LookupOrAdd(aWindowId);
|
||||
|
||||
bool alreadySeenThisDeviceBefore = devicesForThisWindow->Get(uuid, getter_AddRefs(micSource)) &&
|
||||
micSource->RequiresSharing();
|
||||
if (!alreadySeenThisDeviceBefore) {
|
||||
micSource = new MediaEngineWebRTCMicrophoneSource(
|
||||
if (devicesForThisWindow->Get(uuid, getter_AddRefs(aSource)) &&
|
||||
aSource->RequiresSharing()) {
|
||||
// We've already seen this device, just append.
|
||||
aSources->AppendElement(aSource.get());
|
||||
} else {
|
||||
aSource = new MediaEngineWebRTCMicrophoneSource(
|
||||
new mozilla::AudioInputCubeb(i),
|
||||
i, deviceName, uniqueId,
|
||||
mDelayAgnostic, mExtendedFilter);
|
||||
devicesForThisWindow->Put(uuid, micSource);
|
||||
}
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
micSource,
|
||||
micSource->GetName(),
|
||||
NS_ConvertUTF8toUTF16(micSource->GetUUID())));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTC::EnumerateSpeakerDevices(uint64_t aWindowId,
|
||||
nsTArray<RefPtr<MediaDevice> >* aDevices)
|
||||
{
|
||||
nsTArray<RefPtr<AudioDeviceInfo>> devices;
|
||||
CubebUtils::GetDeviceCollection(devices, CubebUtils::Output);
|
||||
for (auto& device : devices) {
|
||||
MOZ_ASSERT(device->GetDeviceID().isSome());
|
||||
if (device->State() == CUBEB_DEVICE_STATE_ENABLED) {
|
||||
MOZ_ASSERT(device->Type() == CUBEB_DEVICE_TYPE_OUTPUT);
|
||||
nsString uuid(device->FriendlyName());
|
||||
// If, for example, input and output are in the same device, uuid
|
||||
// would be the same for both which ends up to create the same
|
||||
// deviceIDs (in JS).
|
||||
uuid.Append(NS_LITERAL_STRING("_Speaker"));
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
device->FriendlyName(),
|
||||
dom::MediaDeviceKind::Audiooutput,
|
||||
uuid));
|
||||
devicesForThisWindow->Put(uuid, aSource);
|
||||
aSources->AppendElement(aSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -339,29 +308,19 @@ MediaEngineWebRTC::EnumerateSpeakerDevices(uint64_t aWindowId,
|
|||
void
|
||||
MediaEngineWebRTC::EnumerateDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum aMediaSource,
|
||||
MediaSinkEnum aMediaSink,
|
||||
nsTArray<RefPtr<MediaDevice> >* aDevices)
|
||||
nsTArray<RefPtr<MediaEngineSource> >* aSources)
|
||||
{
|
||||
MOZ_ASSERT(aMediaSource != dom::MediaSourceEnum::Other ||
|
||||
aMediaSink != MediaSinkEnum::Other);
|
||||
// We spawn threads to handle gUM runnables, so we must protect the member vars
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (MediaEngineSource::IsVideo(aMediaSource)) {
|
||||
EnumerateVideoDevices(aWindowId, aMediaSource, aDevices);
|
||||
EnumerateVideoDevices(aWindowId, aMediaSource, aSources);
|
||||
} else if (aMediaSource == dom::MediaSourceEnum::AudioCapture) {
|
||||
RefPtr<MediaEngineWebRTCAudioCaptureSource> audioCaptureSource =
|
||||
new MediaEngineWebRTCAudioCaptureSource(nullptr);
|
||||
aDevices->AppendElement(MakeRefPtr<MediaDevice>(
|
||||
audioCaptureSource,
|
||||
audioCaptureSource->GetName(),
|
||||
NS_ConvertUTF8toUTF16(audioCaptureSource->GetUUID())));
|
||||
} else if (aMediaSource == dom::MediaSourceEnum::Microphone) {
|
||||
aSources->AppendElement(audioCaptureSource);
|
||||
} else {
|
||||
MOZ_ASSERT(aMediaSource == dom::MediaSourceEnum::Microphone);
|
||||
EnumerateMicrophoneDevices(aWindowId, aDevices);
|
||||
}
|
||||
|
||||
if (aMediaSink == MediaSinkEnum::Speaker) {
|
||||
EnumerateSpeakerDevices(aWindowId, aDevices);
|
||||
EnumerateMicrophoneDevices(aWindowId, aSources);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "AudioPacketizer.h"
|
||||
#include "AudioSegment.h"
|
||||
#include "AudioDeviceInfo.h"
|
||||
#include "CamerasChild.h"
|
||||
#include "cubeb/cubeb.h"
|
||||
#include "CubebUtils.h"
|
||||
|
@ -636,18 +635,15 @@ public:
|
|||
|
||||
void EnumerateDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum,
|
||||
MediaSinkEnum,
|
||||
nsTArray<RefPtr<MediaDevice>>*) override;
|
||||
nsTArray<RefPtr<MediaEngineSource>>*) override;
|
||||
void ReleaseResourcesForWindow(uint64_t aWindowId) override;
|
||||
private:
|
||||
~MediaEngineWebRTC() = default;
|
||||
void EnumerateVideoDevices(uint64_t aWindowId,
|
||||
dom::MediaSourceEnum,
|
||||
nsTArray<RefPtr<MediaDevice>>*);
|
||||
nsTArray<RefPtr<MediaEngineSource>>*);
|
||||
void EnumerateMicrophoneDevices(uint64_t aWindowId,
|
||||
nsTArray<RefPtr<MediaDevice>>*);
|
||||
void EnumerateSpeakerDevices(uint64_t aWindowId,
|
||||
nsTArray<RefPtr<MediaDevice> >*);
|
||||
nsTArray<RefPtr<MediaEngineSource>>*);
|
||||
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
|
||||
|
|
|
@ -117,9 +117,9 @@ GeckoViewPermission.prototype = {
|
|||
};
|
||||
});
|
||||
|
||||
if (constraints.video && !sources.some(source => source.type === "videoinput")) {
|
||||
if (constraints.video && !sources.some(source => source.type === "video")) {
|
||||
throw "no video source";
|
||||
} else if (constraints.audio && !sources.some(source => source.type === "audioinput")) {
|
||||
} else if (constraints.audio && !sources.some(source => source.type === "audio")) {
|
||||
throw "no audio source";
|
||||
}
|
||||
|
||||
|
@ -128,8 +128,8 @@ GeckoViewPermission.prototype = {
|
|||
return dispatcher.sendRequestForResult({
|
||||
type: "GeckoView:MediaPermission",
|
||||
uri: uri.displaySpec,
|
||||
video: constraints.video ? sources.filter(source => source.type === "videoinput") : null,
|
||||
audio: constraints.audio ? sources.filter(source => source.type === "audioinput") : null,
|
||||
video: constraints.video ? sources.filter(source => source.type === "video") : null,
|
||||
audio: constraints.audio ? sources.filter(source => source.type === "audio") : null,
|
||||
}).then(response => {
|
||||
if (!response) {
|
||||
// Rejected.
|
||||
|
|
|
@ -263,9 +263,9 @@ var WebrtcUI = {
|
|||
|
||||
for (let device of aDevices) {
|
||||
device = device.QueryInterface(Ci.nsIMediaDevice);
|
||||
if (device.type == "audioinput") {
|
||||
if (device.type == "audio") {
|
||||
microphone = true;
|
||||
} else if (device.type == "videoinput") {
|
||||
} else if (device.type == "video") {
|
||||
camera = true;
|
||||
}
|
||||
}
|
||||
|
@ -300,11 +300,11 @@ var WebrtcUI = {
|
|||
for (let device of aDevices) {
|
||||
device = device.QueryInterface(Ci.nsIMediaDevice);
|
||||
switch (device.type) {
|
||||
case "audioinput":
|
||||
case "audio":
|
||||
if (aAudioRequested)
|
||||
audioDevices.push(device);
|
||||
break;
|
||||
case "videoinput":
|
||||
case "video":
|
||||
if (aVideoRequested)
|
||||
videoDevices.push(device);
|
||||
break;
|
||||
|
|
|
@ -602,10 +602,6 @@ pref("media.cubeb.sandbox", false);
|
|||
|
||||
pref("media.webaudio.audiocontextoptions-samplerate.enabled", true);
|
||||
|
||||
// setSinkId expected to be unconditionally enabled in 63. Till then the
|
||||
// implementation will remain hidden behind this pref (Bug 1152401, Bug 934425).
|
||||
pref("media.setsinkid.enabled", false);
|
||||
|
||||
// Weather we allow AMD switchable graphics
|
||||
pref("layers.amd-switchable-gfx.enabled", true);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче