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"
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
#include "MediaEnginePrefs.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"
|
|
|
|
#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
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
class AllocationHandle;
|
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
|
|
|
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
LogModule* GetMediaManagerLog();
|
|
|
|
|
2015-09-19 07:49:07 +03:00
|
|
|
class MediaDevice : public nsIMediaDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIMEDIADEVICE
|
|
|
|
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
explicit MediaDevice(MediaEngineSource* aSource,
|
|
|
|
const nsString& aName,
|
|
|
|
const nsString& aID,
|
|
|
|
const nsString& aRawID = NS_LITERAL_STRING(""));
|
|
|
|
|
|
|
|
uint32_t GetBestFitnessDistance(
|
2016-08-19 23:39:54 +03:00
|
|
|
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
|
|
|
bool aIsChrome);
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
|
|
|
|
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);
|
2017-12-18 18:19:33 +03:00
|
|
|
nsresult SetTrack(const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
const PrincipalHandle& aPrincipal);
|
|
|
|
nsresult Start();
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
nsresult Reconfigure(const dom::MediaTrackConstraints& aConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const char** aOutBadConstraint);
|
2017-12-18 18:19:33 +03:00
|
|
|
nsresult Stop();
|
2016-06-30 22:43:24 +03:00
|
|
|
nsresult Deallocate();
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
|
|
|
|
void Pull(const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
StreamTime aDesiredTime,
|
|
|
|
const PrincipalHandle& aPrincipal);
|
|
|
|
|
|
|
|
void GetSettings(dom::MediaTrackSettings& aOutSettings) const;
|
|
|
|
|
|
|
|
dom::MediaSourceEnum GetMediaSource() const;
|
2015-09-19 07:49:07 +03:00
|
|
|
protected:
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
virtual ~MediaDevice() = default;
|
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);
|
|
|
|
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
// Assigned on allocation on media thread, then read on the media thread and
|
|
|
|
// graph thread
|
|
|
|
RefPtr<AllocationHandle> mAllocationHandle;
|
2015-09-19 07:49:07 +03:00
|
|
|
|
|
|
|
public:
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
const RefPtr<MediaEngineSource> mSource;
|
|
|
|
const bool mIsVideo;
|
|
|
|
const bool mScary;
|
|
|
|
const nsString mType;
|
|
|
|
const nsString mName;
|
|
|
|
const nsString mID;
|
|
|
|
const nsString mRawID;
|
2015-09-19 07:49:07 +03: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;
|
|
|
|
}
|
|
|
|
|
2017-11-14 13:50:07 +03:00
|
|
|
static nsresult NotifyRecordingStatusChange(nsPIDOMWindowInner* aWindow);
|
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,
|
2017-09-18 04:52:06 +03:00
|
|
|
nsIDOMGetUserMediaErrorCallback* aOnFailure,
|
|
|
|
dom::CallerType aCallerType);
|
2015-03-03 17:51:05 +03:00
|
|
|
|
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;
|
2017-07-27 11:51:24 +03:00
|
|
|
nsTArray<nsString> mDeviceIDs;
|
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
|