Bug 933384: Fix fake:true in mozGetUserMedia r=anant

This commit is contained in:
Randell Jesup 2013-10-31 22:56:43 -04:00
parent b85a5cc2bf
commit fe27b88820
2 changed files with 12 additions and 12 deletions

View File

@ -810,6 +810,7 @@ public:
, mListener(aListener)
, mPrefs(aPrefs)
, mDeviceChosen(false)
, mBackend(nullptr)
, mManager(MediaManager::GetInstance())
{}
@ -843,7 +844,10 @@ public:
{
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
mBackend = mManager->GetBackend(mWindowID);
// Was a backend provided?
if (!mBackend) {
mBackend = mManager->GetBackend(mWindowID);
}
// Was a device provided?
if (!mDeviceChosen) {
@ -1302,7 +1306,7 @@ MediaManager::GetUserMedia(JSContext* aCx, bool aPrivileged,
if (c.mFake) {
// Fake stream from default backend.
gUMRunnable = new GetUserMediaRunnable(c, onSuccess.forget(),
onError.forget(), windowID, listener, mPrefs, GetBackend(windowID, true));
onError.forget(), windowID, listener, mPrefs, new MediaEngineDefault());
} else {
// Stream from default device from WebRTC backend.
gUMRunnable = new GetUserMediaRunnable(c, onSuccess.forget(),
@ -1383,26 +1387,22 @@ MediaManager::GetUserMediaDevices(nsPIDOMWindow* aWindow,
}
MediaEngine*
MediaManager::GetBackend(uint64_t aWindowId, bool aFake)
MediaManager::GetBackend(uint64_t aWindowId)
{
// Plugin backends as appropriate. The default engine also currently
// includes picture support for Android.
// This IS called off main-thread.
MutexAutoLock lock(mMutex);
if (!mBackend) {
if (aFake) {
mBackend = new MediaEngineDefault();
} else {
if (!mBackend) {
#if defined(MOZ_WEBRTC)
#ifndef MOZ_B2G_CAMERA
mBackend = new MediaEngineWebRTC();
mBackend = new MediaEngineWebRTC();
#else
mBackend = new MediaEngineWebRTC(mCameraManager, aWindowId);
mBackend = new MediaEngineWebRTC(mCameraManager, aWindowId);
#endif
#else
mBackend = new MediaEngineDefault();
mBackend = new MediaEngineDefault();
#endif
}
}
return mBackend;
}

View File

@ -405,7 +405,7 @@ public:
NS_DECL_NSIOBSERVER
NS_DECL_NSIMEDIAMANAGERSERVICE
MediaEngine* GetBackend(uint64_t aWindowId = 0, bool aFake = false);
MediaEngine* GetBackend(uint64_t aWindowId = 0);
StreamListeners *GetWindowListeners(uint64_t aWindowId) {
NS_ASSERTION(NS_IsMainThread(), "Only access windowlist on main thread");