Bug 1156472 - Part 11 - Unbitrot MediaManager.cpp over jib's changes. r=jib

This commit is contained in:
Paul Adenot 2015-07-24 14:28:17 +02:00
Родитель ba5297b5a3
Коммит da9b49eced
4 изменённых файлов: 42 добавлений и 10 удалений

Просмотреть файл

@ -1257,7 +1257,9 @@ static auto& MediaManager_AnonymizeDevices = MediaManager::AnonymizeDevices;
*/
already_AddRefed<MediaManager::PledgeSourceSet>
MediaManager::EnumerateRawDevices(uint64_t aWindowId, MediaSourceEnum aVideoType,
MediaManager::EnumerateRawDevices(uint64_t aWindowId,
MediaSourceEnum aVideoType,
MediaSourceEnum aAudioType,
bool aFake, bool aFakeTracks)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1287,7 +1289,8 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, MediaSourceEnum aVideoType
MediaManager::PostTask(FROM_HERE, NewTaskFrom([id, aWindowId, audioLoopDev,
videoLoopDev, aVideoType,
aFake, aFakeTracks]() mutable {
aAudioType, aFake,
aFakeTracks]() mutable {
nsRefPtr<MediaEngine> backend;
if (aFake) {
backend = new MediaEngineDefault(aFakeTracks);
@ -1306,7 +1309,7 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, MediaSourceEnum aVideoType
}
nsTArray<nsRefPtr<AudioDevice>> audios;
GetSources(backend, dom::MediaSourceEnum::Microphone,
GetSources(backend, aAudioType,
&MediaEngine::EnumerateAudioDevices, audios, audioLoopDev);
for (auto& source : audios) {
result->AppendElement(source);
@ -1628,6 +1631,7 @@ MediaManager::GetUserMedia(nsPIDOMWindow* aWindow,
}
MediaSourceEnum videoType = dom::MediaSourceEnum::Camera;
MediaSourceEnum audioType = dom::MediaSourceEnum::Microphone;
if (c.mVideo.IsMediaTrackConstraints()) {
auto& vc = c.mVideo.GetAsMediaTrackConstraints();
@ -1716,6 +1720,23 @@ MediaManager::GetUserMedia(nsPIDOMWindow* aWindow,
privileged = false;
}
}
if (c.mAudio.IsMediaTrackConstraints()) {
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
audioType = StringToEnum(dom::MediaSourceEnumValues::strings,
ac.mMediaSource,
audioType);
// Only enable AudioCapture if the pref is enabled. If it's not, we can deny
// right away.
if (audioType == dom::MediaSourceEnum::AudioCapture &&
!Preferences::GetBool("media.getusermedia.audiocapture.enabled")) {
nsRefPtr<MediaStreamError> error =
new MediaStreamError(aWindow,
NS_LITERAL_STRING("PermissionDeniedError"));
onFailure->OnError(error);
return NS_OK;
}
}
StreamListeners* listeners = AddWindowID(windowID);
// Create a disabled listener to act as a placeholder
@ -1778,7 +1799,8 @@ MediaManager::GetUserMedia(nsPIDOMWindow* aWindow,
(!fake || Preferences::GetBool("media.navigator.permission.fake"));
nsRefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowID, videoType,
fake, fakeTracks);
audioType, fake,
fakeTracks);
p->Then([this, onSuccess, onFailure, windowID, c, listener, askPermission,
prefs, isHTTPS, callID, origin](SourceSet*& aDevices) mutable {
ScopedDeletePtr<SourceSet> devices(aDevices); // grab result
@ -1934,7 +1956,9 @@ MediaManager::ToJSArray(SourceSet& aDevices)
}
already_AddRefed<MediaManager::PledgeSourceSet>
MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, MediaSourceEnum aVideoType,
MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
MediaSourceEnum aVideoType,
MediaSourceEnum aAudioType,
bool aFake, bool aFakeTracks)
{
MOZ_ASSERT(NS_IsMainThread());
@ -1963,12 +1987,13 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId, MediaSourceEnum aVideoTyp
nsRefPtr<Pledge<nsCString>> p = media::GetOriginKey(origin, privateBrowsing,
persist);
p->Then([id, aWindowId, aVideoType,
p->Then([id, aWindowId, aVideoType, aAudioType,
aFake, aFakeTracks](const nsCString& aOriginKey) mutable {
MOZ_ASSERT(NS_IsMainThread());
nsRefPtr<MediaManager> mgr = MediaManager_GetInstance();
nsRefPtr<PledgeSourceSet> p = mgr->EnumerateRawDevices(aWindowId, aVideoType,
nsRefPtr<PledgeSourceSet> p = mgr->EnumerateRawDevices(aWindowId,
aVideoType, aAudioType,
aFake, aFakeTracks);
p->Then([id, aWindowId, aOriginKey](SourceSet*& aDevices) mutable {
ScopedDeletePtr<SourceSet> devices(aDevices); // secondary result
@ -2007,6 +2032,7 @@ MediaManager::EnumerateDevices(nsPIDOMWindow* aWindow,
nsRefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowId,
dom::MediaSourceEnum::Camera,
dom::MediaSourceEnum::Microphone,
fake);
p->Then([onSuccess](SourceSet*& aDevices) mutable {
ScopedDeletePtr<SourceSet> devices(aDevices); // grab result

Просмотреть файл

@ -597,10 +597,14 @@ public: // TODO: make private once we upgrade to GCC 4.8+ on linux.
static already_AddRefed<nsIWritableVariant> ToJSArray(SourceSet& aDevices);
private:
already_AddRefed<PledgeSourceSet>
EnumerateRawDevices(uint64_t aWindowId, dom::MediaSourceEnum aSrcType,
EnumerateRawDevices(uint64_t aWindowId,
dom::MediaSourceEnum aVideoType,
dom::MediaSourceEnum aAudioType,
bool aFake, bool aFakeTracks);
already_AddRefed<PledgeSourceSet>
EnumerateDevicesImpl(uint64_t aWindowId, dom::MediaSourceEnum aSrcType,
EnumerateDevicesImpl(uint64_t aWindowId,
dom::MediaSourceEnum aVideoSrcType,
dom::MediaSourceEnum aAudioSrcType,
bool aFake = false, bool aFakeTracks = false);
StreamListeners* AddWindowID(uint64_t aWindowId);

Просмотреть файл

@ -268,7 +268,7 @@ MediaEngineWebRTCMicrophoneSource::Config(bool aEchoOn, uint32_t aEcho,
// Infinity = UINT32_MAX e.g. device cannot satisfy accumulated ConstraintSets.
// A finite result may be used to calculate this device's ranking as a choice.
uint32_t MediaEngineWebRTCAudioSource::GetBestFitnessDistance(
uint32_t MediaEngineWebRTCMicrophoneSource::GetBestFitnessDistance(
const nsTArray<const dom::MediaTrackConstraintSet*>& aConstraintSets,
const nsString& aDeviceId)
{

Просмотреть файл

@ -445,6 +445,8 @@ pref("media.getusermedia.screensharing.allowed_domains", "mozilla.github.io,webe
// OS/X 10.6 and XP have screen/window sharing off by default due to various issues - Caveat emptor
pref("media.getusermedia.screensharing.allow_on_old_platforms", false);
pref("media.getusermedia.audiocapture.enabled", false);
// TextTrack support
pref("media.webvtt.enabled", true);
pref("media.webvtt.regions.enabled", false);