2012-06-03 11:35:15 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-10-01 03:17:53 +04:00
|
|
|
#ifndef MOZILLA_MEDIAMANAGER_H
|
|
|
|
#define MOZILLA_MEDIAMANAGER_H
|
|
|
|
|
2012-06-03 11:35:15 +04:00
|
|
|
#include "MediaEngine.h"
|
2016-08-22 13:16:28 +03:00
|
|
|
#include "mozilla/media/DeviceChangeCallback.h"
|
2017-05-12 06:32:14 +03:00
|
|
|
#include "mozilla/dom/GetUserMediaRequest.h"
|
2012-06-03 11:35:15 +04:00
|
|
|
#include "mozilla/Services.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2016-06-07 23:10:18 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2012-12-22 12:09:36 +04:00
|
|
|
#include "nsIMediaManager.h"
|
2012-06-03 11:35:15 +04:00
|
|
|
|
|
|
|
#include "nsHashKeys.h"
|
2012-07-12 15:53:48 +04:00
|
|
|
#include "nsGlobalWindow.h"
|
2012-06-03 11:35:15 +04:00
|
|
|
#include "nsClassHashtable.h"
|
2012-10-06 04:20:47 +04:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2014-04-14 23:04:27 +04:00
|
|
|
#include "nsIObserver.h"
|
2013-03-05 01:02:17 +04:00
|
|
|
#include "nsIPrefService.h"
|
|
|
|
#include "nsIPrefBranch.h"
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2012-06-11 03:44:50 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2012-06-03 11:35:15 +04:00
|
|
|
#include "nsIDOMNavigatorUserMedia.h"
|
2013-01-25 06:45:36 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2012-06-15 06:31:55 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-02-25 15:50:42 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-12-22 12:09:36 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2014-04-04 13:54:25 +04:00
|
|
|
#include "mozilla/dom/MediaStreamBinding.h"
|
2013-09-16 10:34:57 +04:00
|
|
|
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
2014-10-27 22:42:56 +03:00
|
|
|
#include "mozilla/dom/MediaStreamError.h"
|
2015-06-18 18:46:36 +03:00
|
|
|
#include "mozilla/media/MediaChild.h"
|
|
|
|
#include "mozilla/media/MediaParent.h"
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2016-02-26 22:21:05 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2013-05-03 09:07:37 +04:00
|
|
|
#include "DOMMediaStream.h"
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2013-01-29 20:55:09 +04:00
|
|
|
#ifdef MOZ_WEBRTC
|
|
|
|
#include "mtransport/runnable_utils.h"
|
|
|
|
#endif
|
|
|
|
|
2014-09-12 18:49:39 +04:00
|
|
|
// Note, these suck in Windows headers, unfortunately.
|
|
|
|
#include "base/thread.h"
|
|
|
|
#include "base/task.h"
|
|
|
|
|
2012-06-03 11:35:15 +04:00
|
|
|
namespace mozilla {
|
2013-09-16 10:34:57 +04:00
|
|
|
namespace dom {
|
2014-06-19 04:57:51 +04:00
|
|
|
struct MediaStreamConstraints;
|
2015-09-21 01:45:57 +03:00
|
|
|
struct MediaTrackConstraints;
|
2014-09-24 19:17:33 +04:00
|
|
|
struct MediaTrackConstraintSet;
|
2017-02-01 23:43:38 +03:00
|
|
|
enum class CallerType : uint32_t;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2017-01-28 20:29:13 +03:00
|
|
|
namespace ipc {
|
|
|
|
class PrincipalInfo;
|
|
|
|
}
|
|
|
|
|
2017-05-03 14:14:18 +03:00
|
|
|
class GetUserMediaTask;
|
2017-04-26 12:13:40 +03:00
|
|
|
class GetUserMediaWindowListener;
|
|
|
|
class MediaManager;
|
|
|
|
class SourceListener;
|
2017-04-27 01:21:54 +03:00
|
|
|
|
2015-09-19 07:49:07 +03:00
|
|
|
class MediaDevice : public nsIMediaDevice
|
|
|
|
{
|
|
|
|
public:
|
2016-06-30 22:43:24 +03:00
|
|
|
typedef MediaEngineSource Source;
|
|
|
|
|
2015-09-19 07:49:07 +03:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIMEDIADEVICE
|
|
|
|
|
|
|
|
void SetId(const nsAString& aID);
|
2016-08-18 07:01:00 +03:00
|
|
|
void SetRawId(const nsAString& aID);
|
2015-09-19 07:49:07 +03:00
|
|
|
virtual uint32_t GetBestFitnessDistance(
|
2016-08-19 23:39:54 +03:00
|
|
|
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
|
|
|
bool aIsChrome);
|
2016-06-30 22:43:24 +03:00
|
|
|
virtual Source* GetSource() = 0;
|
|
|
|
nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
|
|
|
const MediaEnginePrefs &aPrefs,
|
2017-01-28 20:29:13 +03:00
|
|
|
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
|
2016-06-16 02:25:07 +03:00
|
|
|
const char** aOutBadConstraint);
|
2016-06-30 22:43:24 +03:00
|
|
|
nsresult Restart(const dom::MediaTrackConstraints &aConstraints,
|
2016-06-16 02:25:07 +03:00
|
|
|
const MediaEnginePrefs &aPrefs,
|
|
|
|
const char** aOutBadConstraint);
|
2016-06-30 22:43:24 +03:00
|
|
|
nsresult Deallocate();
|
2015-09-19 07:49:07 +03:00
|
|
|
protected:
|
|
|
|
virtual ~MediaDevice() {}
|
|
|
|
explicit MediaDevice(MediaEngineSource* aSource, bool aIsVideo);
|
2016-06-30 22:43:24 +03:00
|
|
|
|
2015-09-19 07:49:07 +03:00
|
|
|
static uint32_t FitnessDistance(nsString aN,
|
|
|
|
const dom::OwningStringOrStringSequenceOrConstrainDOMStringParameters& aConstraint);
|
|
|
|
private:
|
|
|
|
static bool StringsContain(const dom::OwningStringOrStringSequence& aStrings,
|
|
|
|
nsString aN);
|
|
|
|
static uint32_t FitnessDistance(nsString aN,
|
|
|
|
const dom::ConstrainDOMStringParameters& aParams);
|
|
|
|
protected:
|
|
|
|
nsString mName;
|
|
|
|
nsString mID;
|
2016-08-18 07:01:00 +03:00
|
|
|
nsString mRawID;
|
2016-09-29 22:37:25 +03:00
|
|
|
bool mScary;
|
2015-09-19 07:49:07 +03:00
|
|
|
dom::MediaSourceEnum mMediaSource;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaEngineSource> mSource;
|
2016-07-13 06:25:07 +03:00
|
|
|
RefPtr<MediaEngineSource::AllocationHandle> mAllocationHandle;
|
2015-09-19 07:49:07 +03:00
|
|
|
public:
|
|
|
|
dom::MediaSourceEnum GetMediaSource() {
|
|
|
|
return mMediaSource;
|
|
|
|
}
|
|
|
|
bool mIsVideo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class VideoDevice : public MediaDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef MediaEngineVideoSource Source;
|
|
|
|
|
|
|
|
explicit VideoDevice(Source* aSource);
|
2016-06-30 22:43:24 +03:00
|
|
|
NS_IMETHOD GetType(nsAString& aType) override;
|
|
|
|
Source* GetSource() override;
|
2015-09-19 07:49:07 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
class AudioDevice : public MediaDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef MediaEngineAudioSource Source;
|
|
|
|
|
|
|
|
explicit AudioDevice(Source* aSource);
|
2016-06-30 22:43:24 +03:00
|
|
|
NS_IMETHOD GetType(nsAString& aType) override;
|
|
|
|
Source* GetSource() override;
|
2015-09-19 07:49:07 +03:00
|
|
|
};
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class GetUserMediaNotificationEvent: public Runnable
|
2013-03-03 06:49:29 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum GetUserMediaStatus {
|
|
|
|
STARTING,
|
2014-08-22 13:27:16 +04:00
|
|
|
STOPPING,
|
2013-03-03 06:49:29 +04:00
|
|
|
};
|
2017-04-26 12:13:40 +03:00
|
|
|
GetUserMediaNotificationEvent(GetUserMediaStatus aStatus,
|
|
|
|
uint64_t aWindowID);
|
2013-03-03 06:49:29 +04:00
|
|
|
|
2013-05-03 09:07:37 +04:00
|
|
|
GetUserMediaNotificationEvent(GetUserMediaStatus aStatus,
|
|
|
|
already_AddRefed<DOMMediaStream> aStream,
|
2017-04-26 12:13:40 +03:00
|
|
|
already_AddRefed<media::Refcountable<UniquePtr<OnTracksAvailableCallback>>> aOnTracksAvailableCallback,
|
|
|
|
uint64_t aWindowID,
|
2016-06-30 10:07:48 +03:00
|
|
|
already_AddRefed<nsIDOMGetUserMediaErrorCallback> aError);
|
|
|
|
virtual ~GetUserMediaNotificationEvent();
|
2013-03-03 06:49:29 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Run() override;
|
2013-03-03 06:49:29 +04:00
|
|
|
|
|
|
|
protected:
|
2017-04-26 12:13:40 +03:00
|
|
|
RefPtr<GetUserMediaWindowListener> mListener; // threadsafe
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMMediaStream> mStream;
|
2017-04-26 12:13:40 +03:00
|
|
|
RefPtr<media::Refcountable<UniquePtr<OnTracksAvailableCallback>>> mOnTracksAvailableCallback;
|
2013-03-03 06:49:29 +04:00
|
|
|
GetUserMediaStatus mStatus;
|
2013-10-23 15:10:42 +04:00
|
|
|
uint64_t mWindowID;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsIDOMGetUserMediaErrorCallback> mOnFailure;
|
2013-03-03 06:49:29 +04:00
|
|
|
};
|
|
|
|
|
2012-10-25 03:21:15 +04:00
|
|
|
typedef enum {
|
2014-07-14 09:48:02 +04:00
|
|
|
MEDIA_STOP,
|
2014-08-22 13:27:16 +04:00
|
|
|
MEDIA_STOP_TRACK,
|
2015-09-21 01:45:57 +03:00
|
|
|
MEDIA_DIRECT_LISTENERS,
|
2012-10-25 03:21:15 +04:00
|
|
|
} MediaOperation;
|
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class ReleaseMediaOperationResource : public Runnable
|
2013-12-05 18:29:07 +04:00
|
|
|
{
|
|
|
|
public:
|
2017-04-26 12:13:40 +03:00
|
|
|
ReleaseMediaOperationResource(
|
|
|
|
already_AddRefed<DOMMediaStream> aStream,
|
2017-06-12 22:34:10 +03:00
|
|
|
already_AddRefed<media::Refcountable<UniquePtr<OnTracksAvailableCallback>>>
|
|
|
|
aOnTracksAvailableCallback)
|
|
|
|
: Runnable("ReleaseMediaOperationResource")
|
|
|
|
, mStream(aStream)
|
|
|
|
, mOnTracksAvailableCallback(aOnTracksAvailableCallback)
|
|
|
|
{
|
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Run() override {return NS_OK;}
|
2013-12-05 18:29:07 +04:00
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMMediaStream> mStream;
|
2017-04-26 12:13:40 +03:00
|
|
|
RefPtr<media::Refcountable<UniquePtr<OnTracksAvailableCallback>>> mOnTracksAvailableCallback;
|
2013-12-05 18:29:07 +04:00
|
|
|
};
|
|
|
|
|
2017-04-26 12:13:40 +03:00
|
|
|
typedef nsRefPtrHashtable<nsUint64HashKey, GetUserMediaWindowListener> WindowTable;
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2014-09-20 01:24:28 +04:00
|
|
|
// we could add MediaManager if needed
|
|
|
|
typedef void (*WindowListenerCallback)(MediaManager *aThis,
|
|
|
|
uint64_t aWindowID,
|
2017-04-26 12:13:40 +03:00
|
|
|
GetUserMediaWindowListener *aListener,
|
2014-09-20 01:24:28 +04:00
|
|
|
void *aData);
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class MediaManager final : public nsIMediaManagerService,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIObserver
|
2016-08-11 20:04:49 +03:00
|
|
|
,public DeviceChangeCallback
|
2012-09-20 23:54:00 +04:00
|
|
|
{
|
2017-04-26 12:13:40 +03:00
|
|
|
friend SourceListener;
|
2012-06-03 11:35:15 +04:00
|
|
|
public:
|
2012-12-22 12:09:36 +04:00
|
|
|
static already_AddRefed<MediaManager> GetInstance();
|
|
|
|
|
2013-02-14 23:59:27 +04:00
|
|
|
// NOTE: never Dispatch(....,NS_DISPATCH_SYNC) to the MediaManager
|
|
|
|
// thread from the MainThread, as we NS_DISPATCH_SYNC to MainThread
|
|
|
|
// from MediaManager thread.
|
2013-03-05 01:02:17 +04:00
|
|
|
static MediaManager* Get();
|
2015-03-20 01:43:25 +03:00
|
|
|
static MediaManager* GetIfExists();
|
2016-01-07 22:57:42 +03:00
|
|
|
static void StartupInit();
|
2016-04-28 03:06:05 +03:00
|
|
|
static void PostTask(already_AddRefed<Runnable> task);
|
2015-03-03 17:51:05 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
static bool IsInMediaThread();
|
|
|
|
#endif
|
2013-03-05 01:02:17 +04:00
|
|
|
|
2014-09-06 00:02:54 +04:00
|
|
|
static bool Exists()
|
|
|
|
{
|
|
|
|
return !!sSingleton;
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
static nsresult NotifyRecordingStatusChange(nsPIDOMWindowInner* aWindow,
|
2017-04-26 12:13:40 +03:00
|
|
|
const nsString& aMsg);
|
2013-11-26 10:22:16 +04:00
|
|
|
|
2013-07-19 06:21:20 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-06-03 11:35:15 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2012-12-22 12:09:36 +04:00
|
|
|
NS_DECL_NSIMEDIAMANAGERSERVICE
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2015-06-18 18:46:36 +03:00
|
|
|
media::Parent<media::NonE10s>* GetNonE10sParent();
|
2013-11-06 07:32:42 +04:00
|
|
|
MediaEngine* GetBackend(uint64_t aWindowId = 0);
|
2017-04-26 12:13:40 +03:00
|
|
|
|
|
|
|
WindowTable *GetActiveWindows() {
|
2017-04-26 12:13:40 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-04-26 12:13:40 +03:00
|
|
|
return &mActiveWindows;
|
2017-04-26 12:13:40 +03:00
|
|
|
}
|
2017-04-26 12:13:40 +03:00
|
|
|
GetUserMediaWindowListener *GetWindowListener(uint64_t aWindowId) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return mActiveWindows.GetWeak(aWindowId);
|
|
|
|
}
|
|
|
|
void AddWindowID(uint64_t aWindowId, GetUserMediaWindowListener *aListener);
|
2014-08-22 14:21:48 +04:00
|
|
|
void RemoveWindowID(uint64_t aWindowId);
|
2017-05-12 06:32:14 +03:00
|
|
|
void SendPendingGUMRequest();
|
2012-11-14 01:55:02 +04:00
|
|
|
bool IsWindowStillActive(uint64_t aWindowId) {
|
2017-04-26 12:13:40 +03:00
|
|
|
return !!GetWindowListener(aWindowId);
|
2012-10-26 04:14:47 +04:00
|
|
|
}
|
2013-01-07 06:31:32 +04:00
|
|
|
// Note: also calls aListener->Remove(), even if inactive
|
|
|
|
void RemoveFromWindowList(uint64_t aWindowID,
|
2017-04-26 12:13:40 +03:00
|
|
|
GetUserMediaWindowListener *aListener);
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2014-10-01 03:17:53 +04:00
|
|
|
nsresult GetUserMedia(
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* aWindow,
|
2014-10-01 03:17:53 +04:00
|
|
|
const dom::MediaStreamConstraints& aConstraints,
|
2012-06-03 11:35:15 +04:00
|
|
|
nsIDOMGetUserMediaSuccessCallback* onSuccess,
|
2017-02-01 23:43:38 +03:00
|
|
|
nsIDOMGetUserMediaErrorCallback* onError,
|
|
|
|
dom::CallerType aCallerType);
|
2013-09-16 10:34:57 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsresult GetUserMediaDevices(nsPIDOMWindowInner* aWindow,
|
2015-06-18 18:46:36 +03:00
|
|
|
const dom::MediaStreamConstraints& aConstraints,
|
|
|
|
nsIGetUserMediaDevicesSuccessCallback* onSuccess,
|
|
|
|
nsIDOMGetUserMediaErrorCallback* onError,
|
2016-01-08 01:30:10 +03:00
|
|
|
uint64_t aInnerWindowID = 0,
|
|
|
|
const nsAString& aCallID = nsString());
|
2015-03-03 17:51:05 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
2015-03-03 17:51:05 +03:00
|
|
|
nsIGetUserMediaDevicesSuccessCallback* aOnSuccess,
|
|
|
|
nsIDOMGetUserMediaErrorCallback* aOnFailure);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow, dom::Promise& aPromise);
|
2012-08-22 19:56:38 +04:00
|
|
|
void OnNavigation(uint64_t aWindowID);
|
2015-07-10 06:07:42 +03:00
|
|
|
bool IsActivelyCapturingOrHasAPermission(uint64_t aWindowId);
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2013-03-05 01:02:17 +04:00
|
|
|
MediaEnginePrefs mPrefs;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
typedef nsTArray<RefPtr<MediaDevice>> SourceSet;
|
2016-08-11 20:04:49 +03:00
|
|
|
|
|
|
|
virtual int AddDeviceChangeCallback(DeviceChangeCallback* aCallback) override;
|
|
|
|
virtual void OnDeviceChange() override;
|
2015-07-03 01:01:52 +03:00
|
|
|
private:
|
2015-09-20 09:26:41 +03:00
|
|
|
typedef media::Pledge<SourceSet*, dom::MediaStreamError*> PledgeSourceSet;
|
2015-10-04 03:42:26 +03:00
|
|
|
typedef media::Pledge<const char*, dom::MediaStreamError*> PledgeChar;
|
2015-11-19 06:17:09 +03:00
|
|
|
typedef media::Pledge<bool, dom::MediaStreamError*> PledgeVoid;
|
2015-06-18 18:46:36 +03:00
|
|
|
|
2015-07-03 01:01:52 +03:00
|
|
|
static nsresult GenerateUUID(nsAString& aResult);
|
2015-06-18 18:46:36 +03:00
|
|
|
static nsresult AnonymizeId(nsAString& aId, const nsACString& aOriginKey);
|
|
|
|
public: // TODO: make private once we upgrade to GCC 4.8+ on linux.
|
|
|
|
static void AnonymizeDevices(SourceSet& aDevices, const nsACString& aOriginKey);
|
|
|
|
static already_AddRefed<nsIWritableVariant> ToJSArray(SourceSet& aDevices);
|
|
|
|
private:
|
|
|
|
already_AddRefed<PledgeSourceSet>
|
2015-07-24 15:28:17 +03:00
|
|
|
EnumerateRawDevices(uint64_t aWindowId,
|
|
|
|
dom::MediaSourceEnum aVideoType,
|
|
|
|
dom::MediaSourceEnum aAudioType,
|
2016-07-12 02:27:43 +03:00
|
|
|
bool aFake);
|
2015-06-18 18:46:36 +03:00
|
|
|
already_AddRefed<PledgeSourceSet>
|
2015-07-24 15:28:17 +03:00
|
|
|
EnumerateDevicesImpl(uint64_t aWindowId,
|
|
|
|
dom::MediaSourceEnum aVideoSrcType,
|
|
|
|
dom::MediaSourceEnum aAudioSrcType,
|
2016-07-12 02:27:43 +03:00
|
|
|
bool aFake = false);
|
2015-10-04 03:42:26 +03:00
|
|
|
already_AddRefed<PledgeChar>
|
|
|
|
SelectSettings(
|
|
|
|
dom::MediaStreamConstraints& aConstraints,
|
2016-08-19 23:39:54 +03:00
|
|
|
bool aIsChrome,
|
2016-02-26 22:21:05 +03:00
|
|
|
RefPtr<media::Refcountable<UniquePtr<SourceSet>>>& aSources);
|
2015-06-18 18:46:36 +03:00
|
|
|
|
2013-03-05 01:02:17 +04:00
|
|
|
void GetPref(nsIPrefBranch *aBranch, const char *aPref,
|
|
|
|
const char *aData, int32_t *aVal);
|
2013-12-06 23:34:40 +04:00
|
|
|
void GetPrefBool(nsIPrefBranch *aBranch, const char *aPref,
|
|
|
|
const char *aData, bool *aVal);
|
2013-03-05 01:02:17 +04:00
|
|
|
void GetPrefs(nsIPrefBranch *aBranch, const char *aData);
|
|
|
|
|
2012-06-03 11:35:15 +04:00
|
|
|
// Make private because we want only one instance of this class
|
2013-03-05 01:02:17 +04:00
|
|
|
MediaManager();
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2014-02-10 00:34:40 +04:00
|
|
|
~MediaManager() {}
|
2015-10-15 06:54:39 +03:00
|
|
|
void Shutdown();
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2014-08-22 13:27:16 +04:00
|
|
|
void StopScreensharing(uint64_t aWindowID);
|
2016-01-30 20:05:36 +03:00
|
|
|
void IterateWindowListeners(nsPIDOMWindowInner *aWindow,
|
2014-09-20 01:24:28 +04:00
|
|
|
WindowListenerCallback aCallback,
|
|
|
|
void *aData);
|
2014-08-22 13:27:16 +04:00
|
|
|
|
2013-09-13 12:51:48 +04:00
|
|
|
void StopMediaStreams();
|
2016-08-11 20:04:49 +03:00
|
|
|
void RemoveMediaDevicesCallback(uint64_t aWindowID);
|
2013-09-13 12:51:48 +04:00
|
|
|
|
2012-10-26 04:14:47 +04:00
|
|
|
// ONLY access from MainThread so we don't need to lock
|
|
|
|
WindowTable mActiveWindows;
|
2016-04-28 03:06:05 +03:00
|
|
|
nsRefPtrHashtable<nsStringHashKey, GetUserMediaTask> mActiveCallbacks;
|
2014-01-09 01:51:33 +04:00
|
|
|
nsClassHashtable<nsUint64HashKey, nsTArray<nsString>> mCallIds;
|
2017-05-12 06:32:14 +03:00
|
|
|
nsTArray<RefPtr<dom::GetUserMediaRequest>> mPendingGUMRequest;
|
2015-02-23 19:50:48 +03:00
|
|
|
|
2012-10-26 04:14:47 +04:00
|
|
|
// Always exists
|
2014-09-12 18:49:39 +04:00
|
|
|
nsAutoPtr<base::Thread> mMediaThread;
|
2015-10-15 06:54:39 +03:00
|
|
|
nsCOMPtr<nsIAsyncShutdownBlocker> mShutdownBlocker;
|
2012-10-26 04:14:47 +04:00
|
|
|
|
2015-11-18 23:03:13 +03:00
|
|
|
// ONLY accessed from MediaManagerThread
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MediaEngine> mBackend;
|
2012-06-03 11:35:15 +04:00
|
|
|
|
2012-12-22 12:09:36 +04:00
|
|
|
static StaticRefPtr<MediaManager> sSingleton;
|
2013-05-02 16:00:12 +04:00
|
|
|
|
2015-06-18 18:46:36 +03:00
|
|
|
media::CoatCheck<PledgeSourceSet> mOutstandingPledges;
|
2015-10-04 03:42:26 +03:00
|
|
|
media::CoatCheck<PledgeChar> mOutstandingCharPledges;
|
2015-11-19 06:17:09 +03:00
|
|
|
media::CoatCheck<PledgeVoid> mOutstandingVoidPledges;
|
2015-06-18 18:46:36 +03:00
|
|
|
public:
|
2017-01-28 20:29:13 +03:00
|
|
|
media::CoatCheck<media::Pledge<nsCString>> mGetPrincipalKeyPledges;
|
2016-11-01 14:44:02 +03:00
|
|
|
RefPtr<media::Parent<media::NonE10s>> mNonE10sParent;
|
2012-06-03 11:35:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2014-10-01 03:17:53 +04:00
|
|
|
|
|
|
|
#endif // MOZILLA_MEDIAMANAGER_H
|