2012-06-03 07:35:15 +00: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-09-30 23:17:53 +00:00
|
|
|
#ifndef MOZILLA_MEDIAMANAGER_H
|
|
|
|
#define MOZILLA_MEDIAMANAGER_H
|
|
|
|
|
2012-06-03 07:35:15 +00: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 15:49:13 +00:00
|
|
|
#include "MediaEnginePrefs.h"
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 13:01:43 +00:00
|
|
|
#include "MediaEventSource.h"
|
2017-05-12 03:32:14 +00:00
|
|
|
#include "mozilla/dom/GetUserMediaRequest.h"
|
2016-08-23 04:09:32 +00:00
|
|
|
#include "mozilla/Unused.h"
|
2012-12-22 08:09:36 +00:00
|
|
|
#include "nsIMediaManager.h"
|
2012-06-03 07:35:15 +00:00
|
|
|
|
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsClassHashtable.h"
|
2012-10-06 00:20:47 +00:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2014-04-14 19:04:27 +00:00
|
|
|
#include "nsIObserver.h"
|
2012-06-03 07:35:15 +00:00
|
|
|
|
|
|
|
#include "nsIDOMNavigatorUserMedia.h"
|
2013-01-25 02:45:36 +00:00
|
|
|
#include "nsXULAppAPI.h"
|
2012-06-15 02:31:55 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2014-02-25 11:50:42 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2019-10-29 13:01:24 +00:00
|
|
|
#include "mozilla/StaticMutex.h"
|
2012-12-22 08:09:36 +00:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2014-04-04 09:54:25 +00:00
|
|
|
#include "mozilla/dom/MediaStreamBinding.h"
|
2013-09-16 06:34:57 +00:00
|
|
|
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
2014-10-27 19:42:56 +00:00
|
|
|
#include "mozilla/dom/MediaStreamError.h"
|
2018-07-28 04:40:26 +00:00
|
|
|
#include "mozilla/dom/NavigatorBinding.h"
|
2015-06-18 15:46:36 +00:00
|
|
|
#include "mozilla/media/MediaChild.h"
|
|
|
|
#include "mozilla/media/MediaParent.h"
|
2015-05-19 18:15:34 +00:00
|
|
|
#include "mozilla/Logging.h"
|
2016-02-26 19:21:05 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2013-05-03 05:07:37 +00:00
|
|
|
#include "DOMMediaStream.h"
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2013-01-29 16:55:09 +00:00
|
|
|
#ifdef MOZ_WEBRTC
|
|
|
|
# include "mtransport/runnable_utils.h"
|
|
|
|
#endif
|
|
|
|
|
2014-09-12 14:49:39 +00:00
|
|
|
// Note, these suck in Windows headers, unfortunately.
|
|
|
|
#include "base/thread.h"
|
|
|
|
#include "base/task.h"
|
|
|
|
|
2019-12-06 09:24:56 +00:00
|
|
|
class nsIPrefBranch;
|
|
|
|
|
2012-06-03 07:35:15 +00:00
|
|
|
namespace mozilla {
|
2013-09-16 06:34:57 +00:00
|
|
|
namespace dom {
|
2014-06-19 00:57:51 +00:00
|
|
|
struct MediaStreamConstraints;
|
2015-09-20 22:45:57 +00:00
|
|
|
struct MediaTrackConstraints;
|
2014-09-24 15:17:33 +00:00
|
|
|
struct MediaTrackConstraintSet;
|
2017-02-01 20:43:38 +00:00
|
|
|
enum class CallerType : uint32_t;
|
2018-07-16 09:29:12 +00:00
|
|
|
enum class MediaDeviceKind : uint8_t;
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace dom
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2017-01-28 17:29:13 +00:00
|
|
|
namespace ipc {
|
|
|
|
class PrincipalInfo;
|
|
|
|
}
|
|
|
|
|
2017-05-03 11:14:18 +00:00
|
|
|
class GetUserMediaTask;
|
2017-04-26 09:13:40 +00:00
|
|
|
class GetUserMediaWindowListener;
|
|
|
|
class MediaManager;
|
|
|
|
class SourceListener;
|
2017-04-26 22:21:54 +00:00
|
|
|
|
2015-09-19 04:49:07 +00:00
|
|
|
class MediaDevice : public nsIMediaDevice {
|
|
|
|
public:
|
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
|
|
NS_DECL_NSIMEDIADEVICE
|
|
|
|
|
2019-03-08 11:51:45 +00:00
|
|
|
MediaDevice(const RefPtr<MediaEngineSource>& aSource, const nsString& aName,
|
|
|
|
const nsString& aID, const nsString& aGroupID,
|
|
|
|
const nsString& aRawID);
|
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 15:49:13 +00:00
|
|
|
|
2019-03-08 11:51:45 +00:00
|
|
|
MediaDevice(const RefPtr<AudioDeviceInfo>& aAudioDeviceInfo,
|
|
|
|
const nsString& aID, const nsString& aGroupID,
|
|
|
|
const nsString& aRawID = NS_LITERAL_STRING(""));
|
2018-07-16 09:29:12 +00:00
|
|
|
|
2019-03-08 11:51:45 +00:00
|
|
|
MediaDevice(const RefPtr<MediaDevice>& aOther, const nsString& aID,
|
2020-03-27 18:40:57 +00:00
|
|
|
const nsString& aGroupID, const nsString& aRawID,
|
|
|
|
const nsString& aRawGroupID);
|
2018-07-16 09:29:12 +00:00
|
|
|
|
2020-02-24 16:51:48 +00:00
|
|
|
MediaDevice(const RefPtr<MediaDevice>& aOther, const nsString& aID,
|
|
|
|
const nsString& aGroupID, const nsString& aRawID,
|
2020-03-27 18:40:57 +00:00
|
|
|
const nsString& aRawGroupID, const nsString& aName);
|
2020-02-24 16:51:48 +00: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 15:49:13 +00:00
|
|
|
uint32_t GetBestFitnessDistance(
|
2016-08-19 20:39:54 +00: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 15:49:13 +00:00
|
|
|
|
|
|
|
nsresult Allocate(const dom::MediaTrackConstraints& aConstraints,
|
2019-12-04 15:39:41 +00:00
|
|
|
const MediaEnginePrefs& aPrefs, uint64_t aWindowId,
|
2016-06-15 23:25:07 +00:00
|
|
|
const char** aOutBadConstraint);
|
2019-10-02 10:23:02 +00:00
|
|
|
void SetTrack(const RefPtr<SourceMediaTrack>& aTrack,
|
2019-01-04 06:39:40 +00:00
|
|
|
const PrincipalHandle& aPrincipal);
|
2017-12-18 15:19:33 +00:00
|
|
|
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 15:49:13 +00:00
|
|
|
nsresult Reconfigure(const dom::MediaTrackConstraints& aConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const char** aOutBadConstraint);
|
2018-05-08 19:55:36 +00:00
|
|
|
nsresult FocusOnSelectedSource();
|
2017-12-18 15:19:33 +00:00
|
|
|
nsresult Stop();
|
2016-06-30 19:43:24 +00: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 15:49:13 +00:00
|
|
|
|
|
|
|
void GetSettings(dom::MediaTrackSettings& aOutSettings) const;
|
|
|
|
|
|
|
|
dom::MediaSourceEnum GetMediaSource() const;
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2015-09-19 04:49:07 +00: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 15:49:13 +00:00
|
|
|
virtual ~MediaDevice() = default;
|
2016-06-30 19:43:24 +00:00
|
|
|
|
2015-09-19 04:49:07 +00:00
|
|
|
static uint32_t FitnessDistance(
|
|
|
|
nsString aN,
|
|
|
|
const dom::OwningStringOrStringSequenceOrConstrainDOMStringParameters&
|
|
|
|
aConstraint);
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2015-09-19 04:49:07 +00:00
|
|
|
private:
|
|
|
|
static bool StringsContain(const dom::OwningStringOrStringSequence& aStrings,
|
|
|
|
nsString aN);
|
|
|
|
static uint32_t FitnessDistance(
|
|
|
|
nsString aN, const dom::ConstrainDOMStringParameters& aParams);
|
|
|
|
|
|
|
|
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 15:49:13 +00:00
|
|
|
const RefPtr<MediaEngineSource> mSource;
|
2018-10-12 08:48:22 +00:00
|
|
|
const RefPtr<AudioDeviceInfo> mSinkInfo;
|
2018-07-16 09:29:12 +00:00
|
|
|
const dom::MediaDeviceKind mKind;
|
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 15:49:13 +00:00
|
|
|
const bool mScary;
|
2019-08-28 08:39:57 +00:00
|
|
|
const bool mIsFake;
|
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 15:49:13 +00:00
|
|
|
const nsString mType;
|
|
|
|
const nsString mName;
|
|
|
|
const nsString mID;
|
2019-03-08 11:51:45 +00:00
|
|
|
const nsString mGroupID;
|
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 15:49:13 +00:00
|
|
|
const nsString mRawID;
|
2020-03-27 18:40:57 +00:00
|
|
|
const nsString mRawGroupID;
|
2020-02-24 17:09:13 +00:00
|
|
|
const nsString mRawName;
|
2015-09-19 04:49:07 +00:00
|
|
|
};
|
|
|
|
|
2017-04-26 09:13:40 +00:00
|
|
|
typedef nsRefPtrHashtable<nsUint64HashKey, GetUserMediaWindowListener>
|
|
|
|
WindowTable;
|
2018-10-12 08:44:23 +00:00
|
|
|
typedef MozPromise<RefPtr<AudioDeviceInfo>, nsresult, true> SinkInfoPromise;
|
2012-06-03 07:35:15 +00:00
|
|
|
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 13:01:43 +00:00
|
|
|
class MediaManager final : public nsIMediaManagerService, public nsIObserver {
|
2017-04-26 09:13:40 +00:00
|
|
|
friend SourceListener;
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2012-06-03 07:35:15 +00:00
|
|
|
public:
|
2012-12-22 08:09:36 +00:00
|
|
|
static already_AddRefed<MediaManager> GetInstance();
|
|
|
|
|
2013-02-14 19:59:27 +00: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-04 21:02:17 +00:00
|
|
|
static MediaManager* Get();
|
2015-03-19 22:43:25 +00:00
|
|
|
static MediaManager* GetIfExists();
|
2016-01-07 19:57:42 +00:00
|
|
|
static void StartupInit();
|
2016-04-28 00:06:05 +00:00
|
|
|
static void PostTask(already_AddRefed<Runnable> task);
|
2018-02-15 14:18:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Posts an async operation to the media manager thread.
|
|
|
|
* FunctionType must be a function that takes a `MozPromiseHolder&`.
|
|
|
|
*
|
|
|
|
* The returned promise is resolved or rejected by aFunction on the media
|
|
|
|
* manager thread.
|
|
|
|
*/
|
|
|
|
template <typename MozPromiseType, typename FunctionType>
|
|
|
|
static RefPtr<MozPromiseType> PostTask(const char* aName,
|
|
|
|
FunctionType&& aFunction);
|
|
|
|
|
2015-03-03 14:51:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static bool IsInMediaThread();
|
|
|
|
#endif
|
2013-03-04 21:02:17 +00:00
|
|
|
|
2019-10-29 13:01:24 +00:00
|
|
|
static bool Exists() { return !!GetIfExists(); }
|
2014-09-05 20:02:54 +00:00
|
|
|
|
2017-11-14 10:50:07 +00:00
|
|
|
static nsresult NotifyRecordingStatusChange(nsPIDOMWindowInner* aWindow);
|
2013-11-26 06:22:16 +00:00
|
|
|
|
2013-07-19 02:21:20 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2012-06-03 07:35:15 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2012-12-22 08:09:36 +00:00
|
|
|
NS_DECL_NSIMEDIAMANAGERSERVICE
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2015-06-18 15:46:36 +00:00
|
|
|
media::Parent<media::NonE10s>* GetNonE10sParent();
|
2019-01-03 05:18:09 +00:00
|
|
|
MediaEngine* GetBackend();
|
2017-04-26 09:13:40 +00:00
|
|
|
|
|
|
|
WindowTable* GetActiveWindows() {
|
2017-04-26 09:13:40 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2017-04-26 09:13:40 +00:00
|
|
|
return &mActiveWindows;
|
2017-04-26 09:13:40 +00:00
|
|
|
}
|
2017-04-26 09:13:40 +00:00
|
|
|
GetUserMediaWindowListener* GetWindowListener(uint64_t aWindowId) {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
return mActiveWindows.GetWeak(aWindowId);
|
|
|
|
}
|
2019-04-16 07:37:48 +00:00
|
|
|
void AddWindowID(uint64_t aWindowId,
|
|
|
|
RefPtr<GetUserMediaWindowListener> aListener);
|
2014-08-22 10:21:48 +00:00
|
|
|
void RemoveWindowID(uint64_t aWindowId);
|
2017-05-12 03:32:14 +00:00
|
|
|
void SendPendingGUMRequest();
|
2012-11-13 21:55:02 +00:00
|
|
|
bool IsWindowStillActive(uint64_t aWindowId) {
|
2017-04-26 09:13:40 +00:00
|
|
|
return !!GetWindowListener(aWindowId);
|
2012-10-26 00:14:47 +00:00
|
|
|
}
|
2019-04-16 07:37:48 +00:00
|
|
|
bool IsWindowListenerStillActive(
|
|
|
|
const RefPtr<GetUserMediaWindowListener>& aListener);
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2019-03-19 04:36:46 +00:00
|
|
|
typedef dom::NavigatorUserMediaSuccessCallback GetUserMediaSuccessCallback;
|
|
|
|
typedef dom::NavigatorUserMediaErrorCallback GetUserMediaErrorCallback;
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
static void CallOnError(GetUserMediaErrorCallback& aCallback,
|
2018-11-30 05:13:58 +00:00
|
|
|
dom::MediaStreamError& aError);
|
2019-03-19 04:36:46 +00:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
|
|
|
static void CallOnSuccess(GetUserMediaSuccessCallback& aCallback,
|
2019-10-02 10:23:02 +00:00
|
|
|
DOMMediaStream& aTrack);
|
2018-11-30 05:13:58 +00:00
|
|
|
|
2018-11-30 05:14:05 +00:00
|
|
|
typedef nsTArray<RefPtr<MediaDevice>> MediaDeviceSet;
|
2018-11-30 05:15:34 +00:00
|
|
|
typedef media::Refcountable<MediaDeviceSet> MediaDeviceSetRefCnt;
|
2018-11-30 05:14:05 +00:00
|
|
|
|
2018-11-30 05:15:54 +00:00
|
|
|
typedef MozPromise<RefPtr<DOMMediaStream>, RefPtr<MediaMgrError>, true>
|
2018-11-30 05:13:58 +00:00
|
|
|
StreamPromise;
|
2018-11-30 05:15:54 +00:00
|
|
|
typedef MozPromise<RefPtr<MediaDeviceSetRefCnt>, RefPtr<MediaMgrError>, true>
|
2018-12-12 20:43:23 +00:00
|
|
|
DevicesPromise;
|
|
|
|
typedef MozPromise<bool, RefPtr<MediaMgrError>, true> MgrPromise;
|
2018-12-12 20:42:54 +00:00
|
|
|
typedef MozPromise<const char*, RefPtr<MediaMgrError>, true>
|
|
|
|
BadConstraintsPromise;
|
2018-11-30 05:13:58 +00:00
|
|
|
|
|
|
|
RefPtr<StreamPromise> GetUserMedia(
|
|
|
|
nsPIDOMWindowInner* aWindow,
|
|
|
|
const dom::MediaStreamConstraints& aConstraints,
|
|
|
|
dom::CallerType aCallerType);
|
2013-09-16 06:34:57 +00:00
|
|
|
|
2019-03-19 04:36:46 +00:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-01-30 17:05:36 +00:00
|
|
|
nsresult GetUserMediaDevices(
|
|
|
|
nsPIDOMWindowInner* aWindow,
|
2015-06-18 15:46:36 +00:00
|
|
|
const dom::MediaStreamConstraints& aConstraints,
|
2018-07-28 04:40:29 +00:00
|
|
|
dom::MozGetUserMediaDevicesSuccessCallback& aOnSuccess,
|
2016-01-07 22:30:10 +00:00
|
|
|
uint64_t aInnerWindowID = 0, const nsAString& aCallID = nsString());
|
2018-12-12 20:43:23 +00:00
|
|
|
RefPtr<DevicesPromise> EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
|
|
|
dom::CallerType aCallerType);
|
2015-03-03 14:51:05 +00:00
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsresult EnumerateDevices(nsPIDOMWindowInner* aWindow,
|
|
|
|
dom::Promise& aPromise);
|
2018-10-12 08:44:23 +00:00
|
|
|
|
2018-12-28 03:12:57 +00:00
|
|
|
RefPtr<StreamPromise> GetDisplayMedia(
|
|
|
|
nsPIDOMWindowInner* aWindow,
|
|
|
|
const dom::DisplayMediaStreamConstraints& aConstraintsPassedIn,
|
|
|
|
dom::CallerType aCallerType);
|
|
|
|
|
2018-10-12 08:44:23 +00:00
|
|
|
// Get the sink that corresponds to the given device id.
|
|
|
|
// It is resposible to check if an application is
|
|
|
|
// authorized to play audio through the requested device.
|
|
|
|
// The returned promise will be resolved with the device
|
|
|
|
// information if the device id matches one and operation is
|
|
|
|
// allowed. The default device is always allowed. Non default
|
|
|
|
// devices are allowed only in secure context. It is pending to
|
|
|
|
// implement an user authorization model. The promise will be
|
|
|
|
// rejected in the following cases:
|
|
|
|
// NS_ERROR_NOT_AVAILABLE: Device id does not exist.
|
|
|
|
// NS_ERROR_DOM_MEDIA_NOT_ALLOWED_ERR:
|
|
|
|
// The requested device exists but it is not allowed to be used.
|
|
|
|
// Currently, this happens only on non-default default devices
|
|
|
|
// and non https connections. TODO, authorization model to allow
|
|
|
|
// an application to play audio through the device (Bug 1493982).
|
|
|
|
// NS_ERROR_ABORT: General error.
|
|
|
|
RefPtr<SinkInfoPromise> GetSinkDevice(nsPIDOMWindowInner* aWindow,
|
|
|
|
const nsString& aDeviceId);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void OnNavigation(uint64_t aWindowID);
|
2015-07-10 03:07:42 +00:00
|
|
|
bool IsActivelyCapturingOrHasAPermission(uint64_t aWindowId);
|
2012-06-03 07:35:15 +00:00
|
|
|
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 13:01:43 +00:00
|
|
|
MediaEventSource<void>& DeviceListChangeEvent() {
|
|
|
|
return mDeviceListChangeEvent;
|
|
|
|
}
|
2013-03-04 21:02:17 +00:00
|
|
|
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 13:01:43 +00:00
|
|
|
MediaEnginePrefs mPrefs;
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2015-07-02 22:01:52 +00:00
|
|
|
private:
|
|
|
|
static nsresult GenerateUUID(nsAString& aResult);
|
2015-06-18 15:46:36 +00:00
|
|
|
static nsresult AnonymizeId(nsAString& aId, const nsACString& aOriginKey);
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2015-06-18 15:46:36 +00:00
|
|
|
public: // TODO: make private once we upgrade to GCC 4.8+ on linux.
|
2018-07-16 09:30:46 +00:00
|
|
|
static void AnonymizeDevices(MediaDeviceSet& aDevices,
|
2019-03-08 11:52:06 +00:00
|
|
|
const nsACString& aOriginKey,
|
|
|
|
const uint64_t aWindowId);
|
2018-07-16 09:30:46 +00:00
|
|
|
static already_AddRefed<nsIWritableVariant> ToJSArray(
|
|
|
|
MediaDeviceSet& aDevices);
|
2019-07-30 16:28:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function tries to guess the group id for a video device in aDevices
|
|
|
|
* based on the device name. If the name of only one audio device in aAudios
|
|
|
|
* contains the name of the video device, then, this video device will take
|
|
|
|
* the group id of the audio device. Since this is a guess we try to minimize
|
|
|
|
* the probability of false positive. If we fail to find a correlation we
|
|
|
|
* leave the video group id untouched. In that case the group id will be the
|
|
|
|
* video device name.
|
|
|
|
*/
|
|
|
|
static void GuessVideoDeviceGroupIDs(MediaDeviceSet& aDevices,
|
|
|
|
const MediaDeviceSet& aAudios);
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2015-06-18 15:46:36 +00:00
|
|
|
private:
|
2018-03-16 19:09:26 +00:00
|
|
|
enum class DeviceEnumerationType : uint8_t {
|
2018-02-12 21:55:45 +00:00
|
|
|
Normal, // Enumeration should not return loopback or fake devices
|
|
|
|
Fake, // Enumeration should return fake device(s)
|
|
|
|
Loopback /* Enumeration should return loopback device(s) (possibly in
|
|
|
|
addition to normal devices) */
|
|
|
|
};
|
2018-09-25 17:03:50 +00:00
|
|
|
|
2018-12-12 20:43:23 +00:00
|
|
|
RefPtr<MgrPromise> EnumerateRawDevices(
|
2018-07-16 09:30:46 +00:00
|
|
|
uint64_t aWindowId, dom::MediaSourceEnum aVideoInputType,
|
|
|
|
dom::MediaSourceEnum aAudioInputType, MediaSinkEnum aAudioOutputType,
|
2018-12-12 20:42:54 +00:00
|
|
|
DeviceEnumerationType aVideoInputEnumType,
|
2019-01-02 16:44:35 +00:00
|
|
|
DeviceEnumerationType aAudioInputEnumType, bool aForceNoPermRequest,
|
2018-12-12 20:42:54 +00:00
|
|
|
const RefPtr<MediaDeviceSetRefCnt>& aOutDevices);
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2018-12-12 20:43:23 +00:00
|
|
|
RefPtr<MgrPromise> EnumerateDevicesImpl(
|
2018-07-16 09:30:46 +00:00
|
|
|
uint64_t aWindowId, dom::MediaSourceEnum aVideoInputType,
|
|
|
|
dom::MediaSourceEnum aAudioInputType, MediaSinkEnum aAudioOutputType,
|
|
|
|
DeviceEnumerationType aVideoInputEnumType,
|
2019-01-02 16:44:35 +00:00
|
|
|
DeviceEnumerationType aAudioInputEnumType, bool aForceNoPermRequest,
|
2018-12-12 20:42:54 +00:00
|
|
|
const RefPtr<MediaDeviceSetRefCnt>& aOutDevices);
|
2018-11-19 13:25:37 +00:00
|
|
|
|
2018-09-25 17:03:50 +00:00
|
|
|
RefPtr<BadConstraintsPromise> SelectSettings(
|
2018-11-30 05:13:58 +00:00
|
|
|
const dom::MediaStreamConstraints& aConstraints, bool aIsChrome,
|
2018-09-25 17:03:50 +00:00
|
|
|
const RefPtr<MediaDeviceSetRefCnt>& aSources);
|
2015-06-18 15:46:36 +00:00
|
|
|
|
2013-03-04 21:02:17 +00:00
|
|
|
void GetPref(nsIPrefBranch* aBranch, const char* aPref, const char* aData,
|
|
|
|
int32_t* aVal);
|
2013-12-06 19:34:40 +00:00
|
|
|
void GetPrefBool(nsIPrefBranch* aBranch, const char* aPref, const char* aData,
|
|
|
|
bool* aVal);
|
2013-03-04 21:02:17 +00:00
|
|
|
void GetPrefs(nsIPrefBranch* aBranch, const char* aData);
|
|
|
|
|
2012-06-03 07:35:15 +00:00
|
|
|
// Make private because we want only one instance of this class
|
2019-10-29 13:01:26 +00:00
|
|
|
explicit MediaManager(UniquePtr<base::Thread> aMediaThread);
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2020-03-04 15:39:20 +00:00
|
|
|
~MediaManager() = default;
|
2015-10-15 03:54:39 +00:00
|
|
|
void Shutdown();
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2014-08-22 09:27:16 +00:00
|
|
|
void StopScreensharing(uint64_t aWindowID);
|
2018-02-23 14:50:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls aCallback with a GetUserMediaWindowListener argument once for
|
|
|
|
* each window listener associated with aWindow and its child windows.
|
|
|
|
*/
|
|
|
|
template <typename FunctionType>
|
2016-01-30 17:05:36 +00:00
|
|
|
void IterateWindowListeners(nsPIDOMWindowInner* aWindow,
|
2018-02-23 14:50:57 +00:00
|
|
|
const FunctionType& aCallback);
|
2014-08-22 09:27:16 +00:00
|
|
|
|
2016-08-11 17:04:49 +00:00
|
|
|
void RemoveMediaDevicesCallback(uint64_t aWindowID);
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 13:01:43 +00:00
|
|
|
void DeviceListChanged();
|
2013-09-13 08:51:48 +00:00
|
|
|
|
2012-10-26 00:14:47 +00:00
|
|
|
// ONLY access from MainThread so we don't need to lock
|
|
|
|
WindowTable mActiveWindows;
|
2016-04-28 00:06:05 +00:00
|
|
|
nsRefPtrHashtable<nsStringHashKey, GetUserMediaTask> mActiveCallbacks;
|
2014-01-08 21:51:33 +00:00
|
|
|
nsClassHashtable<nsUint64HashKey, nsTArray<nsString>> mCallIds;
|
2017-05-12 03:32:14 +00:00
|
|
|
nsTArray<RefPtr<dom::GetUserMediaRequest>> mPendingGUMRequest;
|
2015-02-23 16:50:48 +00:00
|
|
|
|
2012-10-26 00:14:47 +00:00
|
|
|
// Always exists
|
2019-10-29 13:01:26 +00:00
|
|
|
const UniquePtr<base::Thread> mMediaThread;
|
2015-10-15 03:54:39 +00:00
|
|
|
nsCOMPtr<nsIAsyncShutdownBlocker> mShutdownBlocker;
|
2012-10-26 00:14:47 +00:00
|
|
|
|
2015-11-18 20:03:13 +00:00
|
|
|
// ONLY accessed from MediaManagerThread
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<MediaEngine> mBackend;
|
2012-06-03 07:35:15 +00:00
|
|
|
|
2012-12-22 08:09:36 +00:00
|
|
|
static StaticRefPtr<MediaManager> sSingleton;
|
2019-10-29 13:01:24 +00:00
|
|
|
static StaticMutex sSingletonMutex;
|
2013-05-02 12:00:12 +00:00
|
|
|
|
2017-07-27 08:51:24 +00:00
|
|
|
nsTArray<nsString> mDeviceIDs;
|
2018-11-19 13:25:37 +00:00
|
|
|
|
Bug 1582637 - Move internal DeviceChange events to higher order functions. r=jib,achronop
This does three major things:
1) Moves the DeviceChange events from manual callbacks/listeners to
MediaEventSource/MediaEventListener. This is the reason this patch is so
large, as it traverses a lot of files.
There are four layers (from low to high):
- CamerasChild for camera device list changes, and CubebDeviceEnumerator for
microphone and speaker device list changes
- MediaEngineWebRTC, which gathers these into a single listener
- MediaManager, which owns the MediaEngineWebRTC backend
- MediaDevices, where the events from MediaManager are exposed to js
2) Changes the fake event triggering from starting a 30-event burst on setting
the js event listener, to a toggle, so that while the pref is on the events
keep coming.
3) Moves the fake event generation from CamerasChild to MediaEngineWebRTC, since
that's the lowest level where we are aware of both video and audio events.
The fake event generation is also greatly simplified. From being a dedicated
thread with periodic runnables, it is now a periodic timer on main thread
that fires while fake events are enabled. MediaEventProducer gracefully
handles thread safety.
Differential Revision: https://phabricator.services.mozilla.com/D48516
--HG--
extra : moz-landing-system : lando
2019-10-29 13:01:43 +00:00
|
|
|
// Connect/Disconnect on media thread only
|
|
|
|
MediaEventListener mDeviceListChangeListener;
|
|
|
|
|
|
|
|
MediaEventProducer<void> mDeviceListChangeEvent;
|
|
|
|
|
2015-06-18 15:46:36 +00:00
|
|
|
public:
|
2016-11-01 11:44:02 +00:00
|
|
|
RefPtr<media::Parent<media::NonE10s>> mNonE10sParent;
|
2012-06-03 07:35:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
2014-09-30 23:17:53 +00:00
|
|
|
|
|
|
|
#endif // MOZILLA_MEDIAMANAGER_H
|