2012-07-12 11:53:08 +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/. */
|
|
|
|
|
|
|
|
#ifndef MEDIAENGINEWEBRTC_H_
|
|
|
|
#define MEDIAENGINEWEBRTC_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 "AudioPacketizer.h"
|
|
|
|
#include "AudioSegment.h"
|
2018-07-18 08:38:34 +00:00
|
|
|
#include "AudioDeviceInfo.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 "CamerasChild.h"
|
|
|
|
#include "cubeb/cubeb.h"
|
|
|
|
#include "CubebUtils.h"
|
|
|
|
#include "DOMMediaStream.h"
|
|
|
|
#include "ipc/IPCMessageUtils.h"
|
|
|
|
#include "MediaEngine.h"
|
|
|
|
#include "MediaEnginePrefs.h"
|
|
|
|
#include "MediaEngineSource.h"
|
|
|
|
#include "MediaEngineWrapper.h"
|
|
|
|
#include "MediaStreamGraph.h"
|
2014-10-08 16:15:23 +00:00
|
|
|
#include "mozilla/dom/File.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 "mozilla/dom/MediaStreamTrackBinding.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
2012-10-18 18:03:00 +00:00
|
|
|
#include "mozilla/Mutex.h"
|
2016-12-09 20:10:42 +00:00
|
|
|
#include "mozilla/Sprintf.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 "mozilla/StaticMutex.h"
|
2016-02-17 18:19:02 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-06-07 20:10:18 +00:00
|
|
|
#include "nsAutoPtr.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 "nsComponentManagerUtils.h"
|
2012-07-12 11:53:08 +00:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDirectoryServiceDefs.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 "nsIThread.h"
|
|
|
|
#include "nsIRunnable.h"
|
2013-03-26 11:13:17 +00:00
|
|
|
#include "nsRefPtrHashtable.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 "nsThreadUtils.h"
|
|
|
|
#include "NullTransport.h"
|
|
|
|
#include "prcvar.h"
|
|
|
|
#include "prthread.h"
|
2016-01-26 02:49:01 +00:00
|
|
|
#include "StreamTracks.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 "VideoSegment.h"
|
|
|
|
#include "VideoUtils.h"
|
2016-12-28 00:41:02 +00:00
|
|
|
|
2012-07-12 11:53:08 +00:00
|
|
|
// WebRTC library includes follow
|
|
|
|
// Audio Engine
|
2013-08-30 06:08:57 +00:00
|
|
|
#include "webrtc/voice_engine/include/voe_base.h"
|
|
|
|
#include "webrtc/voice_engine/include/voe_codec.h"
|
|
|
|
#include "webrtc/voice_engine/include/voe_network.h"
|
|
|
|
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
|
|
|
#include "webrtc/voice_engine/include/voe_volume_control.h"
|
|
|
|
#include "webrtc/voice_engine/include/voe_external_media.h"
|
|
|
|
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
2017-08-17 17:26:33 +00:00
|
|
|
#include "webrtc/modules/audio_device/include/audio_device.h"
|
2016-04-20 00:20:45 +00:00
|
|
|
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
2012-07-12 11:53:08 +00:00
|
|
|
// Video Engine
|
2014-05-29 21:05:14 +00:00
|
|
|
// conflicts with #include of scoped_ptr.h
|
|
|
|
#undef FF
|
2016-12-28 00:41:02 +00:00
|
|
|
#include "webrtc/modules/video_capture/video_capture_defines.h"
|
2012-07-12 11:53:08 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
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
|
|
|
class MediaEngineWebRTCMicrophoneSource;
|
|
|
|
|
|
|
|
class MediaEngineWebRTCAudioCaptureSource : public MediaEngineSource
|
2015-07-24 12:28:16 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit MediaEngineWebRTCAudioCaptureSource(const char* aUuid)
|
|
|
|
{
|
|
|
|
}
|
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
|
|
|
nsString GetName() const override;
|
|
|
|
nsCString GetUUID() const override;
|
|
|
|
nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
|
|
|
const MediaEnginePrefs &aPrefs,
|
2016-02-17 17:57:26 +00:00
|
|
|
const nsString& aDeviceId,
|
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 ipc::PrincipalInfo& aPrincipalInfo,
|
2016-07-13 03:25:07 +00:00
|
|
|
AllocationHandle** aOutHandle,
|
2016-06-15 23:25:07 +00:00
|
|
|
const char** aOutBadConstraint) override
|
2015-07-24 12:28:16 +00:00
|
|
|
{
|
|
|
|
// Nothing to do here, everything is managed in MediaManager.cpp
|
2016-08-01 20:26:13 +00:00
|
|
|
*aOutHandle = nullptr;
|
2015-07-24 12:28:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
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 Deallocate(const RefPtr<const AllocationHandle>& aHandle) override
|
2015-07-24 12:28:16 +00:00
|
|
|
{
|
|
|
|
// Nothing to do here, everything is managed in MediaManager.cpp
|
2016-06-30 19:43:24 +00:00
|
|
|
MOZ_ASSERT(!aHandle);
|
2015-07-24 12:28:16 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-12-18 15:19:33 +00:00
|
|
|
nsresult SetTrack(const RefPtr<const AllocationHandle>& aHandle,
|
|
|
|
const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
const PrincipalHandle& aPrincipal) override;
|
|
|
|
nsresult Start(const RefPtr<const AllocationHandle>& aHandle) override;
|
|
|
|
nsresult Stop(const RefPtr<const AllocationHandle>& aHandle) override;
|
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 RefPtr<AllocationHandle>& aHandle,
|
|
|
|
const dom::MediaTrackConstraints& aConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const nsString& aDeviceId,
|
|
|
|
const char** aOutBadConstraint) override;
|
|
|
|
|
|
|
|
void Pull(const RefPtr<const AllocationHandle>& aHandle,
|
|
|
|
const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
StreamTime aDesiredTime,
|
|
|
|
const PrincipalHandle& aPrincipalHandle) override
|
2017-12-18 15:19:33 +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
|
|
|
|
2016-01-07 23:43:38 +00:00
|
|
|
dom::MediaSourceEnum GetMediaSource() const override
|
2015-07-24 12:28:16 +00:00
|
|
|
{
|
|
|
|
return dom::MediaSourceEnum::AudioCapture;
|
|
|
|
}
|
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
|
|
|
|
2016-01-05 02:16:21 +00:00
|
|
|
nsresult TakePhoto(MediaEnginePhotoCallback* aCallback) override
|
2015-07-24 12:28:16 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
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
|
|
|
|
2015-07-24 12:28:16 +00:00
|
|
|
uint32_t GetBestFitnessDistance(
|
2016-06-17 19:20:10 +00:00
|
|
|
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
2016-06-21 00:15:39 +00:00
|
|
|
const nsString& aDeviceId) const override;
|
2015-07-24 12:28:16 +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 ~MediaEngineWebRTCAudioCaptureSource() = default;
|
2015-07-24 12:28:16 +00:00
|
|
|
};
|
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
// Small subset of VoEHardware
|
|
|
|
class AudioInput
|
|
|
|
{
|
|
|
|
public:
|
2017-10-31 17:11:48 +00:00
|
|
|
AudioInput() = default;
|
2016-01-21 16:51:36 +00:00
|
|
|
// Threadsafe because it's referenced from an MicrophoneSource, which can
|
|
|
|
// had references to it on other threads.
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AudioInput)
|
2016-01-21 16:51:36 +00:00
|
|
|
|
|
|
|
virtual int GetNumOfRecordingDevices(int& aDevices) = 0;
|
2016-12-09 20:10:42 +00:00
|
|
|
virtual int GetRecordingDeviceName(int aIndex, char (&aStrNameUTF8)[128],
|
2016-01-21 16:51:36 +00:00
|
|
|
char aStrGuidUTF8[128]) = 0;
|
|
|
|
virtual int GetRecordingDeviceStatus(bool& aIsAvailable) = 0;
|
2017-06-30 04:01:17 +00:00
|
|
|
virtual void GetChannelCount(uint32_t& aChannels) = 0;
|
|
|
|
virtual int GetMaxAvailableChannels(uint32_t& aChannels) = 0;
|
2016-02-04 02:12:51 +00:00
|
|
|
virtual void StartRecording(SourceMediaStream *aStream, AudioDataListener *aListener) = 0;
|
|
|
|
virtual void StopRecording(SourceMediaStream *aStream) = 0;
|
2016-01-21 16:51:36 +00:00
|
|
|
virtual int SetRecordingDevice(int aIndex) = 0;
|
2017-06-30 04:01:17 +00:00
|
|
|
virtual void SetUserChannelCount(uint32_t aChannels) = 0;
|
2016-01-21 16:51:36 +00:00
|
|
|
|
|
|
|
protected:
|
2016-01-21 16:51:36 +00:00
|
|
|
// Protected destructor, to discourage deletion outside of Release():
|
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 ~AudioInput() = default;
|
2016-01-21 16:51:36 +00:00
|
|
|
};
|
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
class AudioInputCubeb final : public AudioInput
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-10-31 17:11:48 +00:00
|
|
|
explicit AudioInputCubeb(int aIndex = 0) :
|
|
|
|
AudioInput(), mSelectedDevice(aIndex), mInUseCount(0)
|
2016-01-23 03:36:26 +00:00
|
|
|
{
|
|
|
|
if (!mDeviceIndexes) {
|
|
|
|
mDeviceIndexes = new nsTArray<int>;
|
|
|
|
mDeviceNames = new nsTArray<nsCString>;
|
2016-04-21 05:42:50 +00:00
|
|
|
mDefaultDevice = -1;
|
2016-01-23 03:36:26 +00:00
|
|
|
}
|
|
|
|
}
|
2016-01-21 16:51:36 +00:00
|
|
|
|
|
|
|
static void CleanupGlobalData()
|
|
|
|
{
|
2018-03-19 21:31:40 +00:00
|
|
|
if (mDevices.device) {
|
|
|
|
cubeb_device_collection_destroy(CubebUtils::GetCubebContext(), &mDevices);
|
|
|
|
}
|
2016-01-23 03:36:26 +00:00
|
|
|
delete mDeviceIndexes;
|
|
|
|
mDeviceIndexes = nullptr;
|
|
|
|
delete mDeviceNames;
|
|
|
|
mDeviceNames = nullptr;
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
2016-01-21 16:51:36 +00:00
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
int GetNumOfRecordingDevices(int& aDevices)
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-11-18 16:00:48 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// OpenSL ES does not support enumerate device.
|
|
|
|
aDevices = 1;
|
|
|
|
#else
|
2016-01-23 01:40:26 +00:00
|
|
|
UpdateDeviceList();
|
2016-01-23 03:36:26 +00:00
|
|
|
aDevices = mDeviceIndexes->Length();
|
2016-11-18 16:00:48 +00:00
|
|
|
#endif
|
2016-01-21 16:51:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:11:09 +00:00
|
|
|
static int32_t DeviceIndex(int aIndex)
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-04-21 05:42:50 +00:00
|
|
|
// -1 = system default if any
|
2016-01-21 16:51:36 +00:00
|
|
|
if (aIndex == -1) {
|
2016-04-21 05:42:50 +00:00
|
|
|
if (mDefaultDevice == -1) {
|
|
|
|
aIndex = 0;
|
|
|
|
} else {
|
|
|
|
aIndex = mDefaultDevice;
|
|
|
|
}
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
2017-06-02 06:11:56 +00:00
|
|
|
MOZ_ASSERT(mDeviceIndexes);
|
2016-04-21 05:42:50 +00:00
|
|
|
if (aIndex < 0 || aIndex >= (int) mDeviceIndexes->Length()) {
|
2016-01-21 16:51:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2016-01-23 01:40:26 +00:00
|
|
|
// Note: if the device is gone, this will be -1
|
2016-01-23 03:36:26 +00:00
|
|
|
return (*mDeviceIndexes)[aIndex]; // translate to mDevices index
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
|
|
|
|
2016-04-01 04:18:13 +00:00
|
|
|
static StaticMutex& Mutex()
|
|
|
|
{
|
|
|
|
return sMutex;
|
|
|
|
}
|
|
|
|
|
2016-03-08 17:11:09 +00:00
|
|
|
static bool GetDeviceID(int aDeviceIndex, CubebUtils::AudioDeviceID &aID)
|
|
|
|
{
|
2016-04-01 04:18:13 +00:00
|
|
|
// Assert sMutex is held
|
|
|
|
sMutex.AssertCurrentThreadOwns();
|
2016-11-18 16:00:48 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
aID = nullptr;
|
|
|
|
return true;
|
|
|
|
#else
|
2016-03-08 17:11:09 +00:00
|
|
|
int dev_index = DeviceIndex(aDeviceIndex);
|
|
|
|
if (dev_index != -1) {
|
2017-05-25 05:28:24 +00:00
|
|
|
aID = mDevices.device[dev_index].devid;
|
2016-03-08 17:11:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2016-11-18 16:00:48 +00:00
|
|
|
#endif
|
2016-03-08 17:11:09 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 20:10:42 +00:00
|
|
|
int GetRecordingDeviceName(int aIndex, char (&aStrNameUTF8)[128],
|
2016-01-21 16:51:36 +00:00
|
|
|
char aStrGuidUTF8[128])
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-11-18 16:00:48 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
aStrNameUTF8[0] = '\0';
|
|
|
|
aStrGuidUTF8[0] = '\0';
|
|
|
|
#else
|
2016-01-21 16:51:36 +00:00
|
|
|
int32_t devindex = DeviceIndex(aIndex);
|
2017-05-25 05:28:24 +00:00
|
|
|
if (mDevices.count == 0 || devindex < 0) {
|
2016-01-21 16:51:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2016-12-09 20:10:42 +00:00
|
|
|
SprintfLiteral(aStrNameUTF8, "%s%s", aIndex == -1 ? "default: " : "",
|
2017-05-25 05:28:24 +00:00
|
|
|
mDevices.device[devindex].friendly_name);
|
2016-01-21 16:51:36 +00:00
|
|
|
aStrGuidUTF8[0] = '\0';
|
2016-11-18 16:00:48 +00:00
|
|
|
#endif
|
2016-01-21 16:51:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
int GetRecordingDeviceStatus(bool& aIsAvailable)
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-01-23 01:40:26 +00:00
|
|
|
// With cubeb, we only expose devices of type CUBEB_DEVICE_TYPE_INPUT,
|
|
|
|
// so unless it was removed, say it's available
|
2016-01-21 16:51:36 +00:00
|
|
|
aIsAvailable = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-06-30 04:01:17 +00:00
|
|
|
void GetChannelCount(uint32_t& aChannels)
|
2017-06-02 06:12:21 +00:00
|
|
|
{
|
2017-06-30 04:01:17 +00:00
|
|
|
GetUserChannelCount(mSelectedDevice, aChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void GetUserChannelCount(int aDeviceIndex, uint32_t& aChannels)
|
|
|
|
{
|
|
|
|
aChannels = sUserChannelCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetMaxAvailableChannels(uint32_t& aChannels)
|
|
|
|
{
|
|
|
|
return GetDeviceMaxChannels(mSelectedDevice, aChannels);
|
2017-06-02 06:12:21 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 06:11:56 +00:00
|
|
|
static int GetDeviceMaxChannels(int aDeviceIndex, uint32_t& aChannels)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
aChannels = 1;
|
|
|
|
#else
|
|
|
|
int32_t devindex = DeviceIndex(aDeviceIndex);
|
|
|
|
if (mDevices.count == 0 || devindex < 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
aChannels = mDevices.device[devindex].max_channels;
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-06-30 04:01:17 +00:00
|
|
|
void SetUserChannelCount(uint32_t aChannels)
|
|
|
|
{
|
|
|
|
if (GetDeviceMaxChannels(mSelectedDevice, sUserChannelCount)) {
|
|
|
|
sUserChannelCount = 1; // error capture mono
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aChannels && aChannels < sUserChannelCount) {
|
|
|
|
sUserChannelCount = aChannels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 02:12:51 +00:00
|
|
|
void StartRecording(SourceMediaStream *aStream, AudioDataListener *aListener)
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-11-18 16:00:48 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
// OpenSL ES does not support enumerating devices.
|
2017-05-25 05:28:24 +00:00
|
|
|
MOZ_ASSERT(mDevices.count == 0);
|
2016-11-18 16:00:48 +00:00
|
|
|
#else
|
2017-05-25 05:28:24 +00:00
|
|
|
MOZ_ASSERT(mDevices.count > 0);
|
2016-11-18 16:00:48 +00:00
|
|
|
#endif
|
2016-01-21 16:51:36 +00:00
|
|
|
|
2017-10-31 17:11:48 +00:00
|
|
|
mAnyInUse = true;
|
2016-02-04 02:12:51 +00:00
|
|
|
mInUseCount++;
|
|
|
|
// Always tell the stream we're using it for input
|
2016-03-08 17:11:09 +00:00
|
|
|
aStream->OpenAudioInput(mSelectedDevice, aListener);
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
|
|
|
|
2016-02-04 02:12:51 +00:00
|
|
|
void StopRecording(SourceMediaStream *aStream)
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-02-04 02:12:51 +00:00
|
|
|
aStream->CloseAudioInput();
|
|
|
|
if (--mInUseCount == 0) {
|
|
|
|
mAnyInUse = false;
|
|
|
|
}
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
int SetRecordingDevice(int aIndex)
|
2016-01-21 16:51:36 +00:00
|
|
|
{
|
2016-03-08 17:11:09 +00:00
|
|
|
mSelectedDevice = aIndex;
|
2016-01-21 16:51:36 +00:00
|
|
|
return 0;
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
protected:
|
2016-01-21 16:51:36 +00:00
|
|
|
~AudioInputCubeb() {
|
2016-02-04 02:12:51 +00:00
|
|
|
MOZ_RELEASE_ASSERT(mInUseCount == 0);
|
2016-01-21 16:51:36 +00:00
|
|
|
}
|
2016-01-21 16:51:36 +00:00
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
private:
|
2016-01-23 01:40:26 +00:00
|
|
|
// It would be better to watch for device-change notifications
|
2016-03-08 17:11:09 +00:00
|
|
|
void UpdateDeviceList();
|
2016-01-23 01:40:26 +00:00
|
|
|
|
|
|
|
// We have an array, which consists of indexes to the current mDevices
|
|
|
|
// list. This is updated on mDevices updates. Many devices in mDevices
|
|
|
|
// won't be included in the array (wrong type, etc), or if a device is
|
|
|
|
// removed it will map to -1 (and opens of this device will need to check
|
|
|
|
// for this - and be careful of threading access. The mappings need to
|
|
|
|
// updated on each re-enumeration.
|
2016-01-21 16:51:36 +00:00
|
|
|
int mSelectedDevice;
|
2016-02-04 02:12:51 +00:00
|
|
|
uint32_t mInUseCount;
|
2016-01-23 01:40:26 +00:00
|
|
|
|
2016-01-23 03:36:26 +00:00
|
|
|
// pointers to avoid static constructors
|
|
|
|
static nsTArray<int>* mDeviceIndexes;
|
2016-04-21 05:42:50 +00:00
|
|
|
static int mDefaultDevice; // -1 == not set
|
2016-01-23 03:36:26 +00:00
|
|
|
static nsTArray<nsCString>* mDeviceNames;
|
2017-05-25 05:28:24 +00:00
|
|
|
static cubeb_device_collection mDevices;
|
2016-01-21 16:51:36 +00:00
|
|
|
static bool mAnyInUse;
|
2016-04-01 04:18:13 +00:00
|
|
|
static StaticMutex sMutex;
|
2017-06-30 04:01:17 +00:00
|
|
|
static uint32_t sUserChannelCount;
|
2016-01-21 16:51:36 +00:00
|
|
|
};
|
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
class WebRTCAudioDataListener : public AudioDataListener
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
// Protected destructor, to discourage deletion outside of Release():
|
|
|
|
virtual ~WebRTCAudioDataListener() {}
|
|
|
|
|
|
|
|
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
|
|
|
explicit WebRTCAudioDataListener(MediaEngineWebRTCMicrophoneSource* aAudioSource)
|
|
|
|
: mMutex("WebRTCAudioDataListener::mMutex")
|
2016-03-08 17:11:09 +00:00
|
|
|
, mAudioSource(aAudioSource)
|
2016-01-21 16:51:36 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
// AudioDataListenerInterface methods
|
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 NotifyOutputData(MediaStreamGraph* aGraph,
|
|
|
|
AudioDataValue* aBuffer,
|
|
|
|
size_t aFrames,
|
|
|
|
TrackRate aRate,
|
|
|
|
uint32_t aChannels) override;
|
2016-03-08 17:11:09 +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
|
|
|
void NotifyInputData(MediaStreamGraph* aGraph,
|
|
|
|
const AudioDataValue* aBuffer,
|
|
|
|
size_t aFrames,
|
|
|
|
TrackRate aRate,
|
|
|
|
uint32_t aChannels) override;
|
|
|
|
|
|
|
|
void DeviceChanged() override;
|
|
|
|
|
|
|
|
void Shutdown();
|
2016-01-21 16:51:36 +00:00
|
|
|
|
|
|
|
private:
|
2016-03-08 17:11:09 +00:00
|
|
|
Mutex mMutex;
|
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
|
|
|
RefPtr<MediaEngineWebRTCMicrophoneSource> mAudioSource;
|
2016-01-21 16:51:36 +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
|
|
|
class MediaEngineWebRTCMicrophoneSource : public MediaEngineSource,
|
|
|
|
public AudioDataListenerInterface
|
2015-07-24 12:28:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-10-31 17:11:48 +00:00
|
|
|
MediaEngineWebRTCMicrophoneSource(mozilla::AudioInput* aAudioInput,
|
2015-07-24 12:28:16 +00:00
|
|
|
int aIndex,
|
|
|
|
const char* name,
|
2017-10-17 20:27:20 +00:00
|
|
|
const char* uuid,
|
|
|
|
bool aDelayAgnostic,
|
|
|
|
bool aExtendedFilter);
|
2012-07-12 11:53:08 +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
|
|
|
bool RequiresSharing() const override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString GetName() const override;
|
|
|
|
nsCString GetUUID() const override;
|
|
|
|
|
|
|
|
nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const nsString& aDeviceId,
|
|
|
|
const ipc::PrincipalInfo& aPrincipalInfo,
|
|
|
|
AllocationHandle** aOutHandle,
|
|
|
|
const char** aOutBadConstraint) override;
|
|
|
|
nsresult Deallocate(const RefPtr<const AllocationHandle>& aHandle) override;
|
2017-12-18 15:19:33 +00:00
|
|
|
nsresult SetTrack(const RefPtr<const AllocationHandle>& aHandle,
|
|
|
|
const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
const PrincipalHandle& aPrincipal) override;
|
|
|
|
nsresult Start(const RefPtr<const AllocationHandle>& aHandle) override;
|
|
|
|
nsresult Stop(const RefPtr<const AllocationHandle>& aHandle) override;
|
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 RefPtr<AllocationHandle>& aHandle,
|
|
|
|
const dom::MediaTrackConstraints& aConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const nsString& aDeviceId,
|
|
|
|
const char** aOutBadConstraint) override;
|
|
|
|
|
2018-02-26 08:41:20 +00:00
|
|
|
/**
|
|
|
|
* Assigns the current settings of the capture to aOutSettings.
|
|
|
|
* Main thread only.
|
|
|
|
*/
|
|
|
|
void GetSettings(dom::MediaTrackSettings& aOutSettings) const override;
|
|
|
|
|
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 Pull(const RefPtr<const AllocationHandle>& aHandle,
|
|
|
|
const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
StreamTime aDesiredTime,
|
|
|
|
const PrincipalHandle& aPrincipalHandle) override;
|
2016-01-18 03:25:30 +00:00
|
|
|
|
2016-01-21 16:51:36 +00:00
|
|
|
// AudioDataListenerInterface methods
|
|
|
|
void NotifyOutputData(MediaStreamGraph* aGraph,
|
|
|
|
AudioDataValue* aBuffer, size_t aFrames,
|
2016-02-17 18:19:01 +00:00
|
|
|
TrackRate aRate, uint32_t aChannels) override;
|
2016-01-21 16:51:36 +00:00
|
|
|
void NotifyInputData(MediaStreamGraph* aGraph,
|
2016-01-21 16:51:36 +00:00
|
|
|
const AudioDataValue* aBuffer, size_t aFrames,
|
2016-02-17 18:19:01 +00:00
|
|
|
TrackRate aRate, uint32_t aChannels) override;
|
2016-01-21 16:51:36 +00:00
|
|
|
|
2016-04-22 14:24:17 +00:00
|
|
|
void DeviceChanged() override;
|
|
|
|
|
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
|
|
|
dom::MediaSourceEnum GetMediaSource() const override
|
|
|
|
{
|
2015-01-20 15:31:59 +00:00
|
|
|
return dom::MediaSourceEnum::Microphone;
|
2014-07-18 02:23:00 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 02:16:21 +00:00
|
|
|
nsresult TakePhoto(MediaEnginePhotoCallback* aCallback) override
|
2014-09-08 22:17:00 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2016-01-18 03:25:30 +00:00
|
|
|
uint32_t GetBestFitnessDistance(
|
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 nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
|
|
|
const nsString& aDeviceId) const override;
|
2015-07-02 22:01:52 +00:00
|
|
|
|
2016-01-18 03:25:30 +00:00
|
|
|
void Shutdown() override;
|
2015-05-29 18:28:03 +00:00
|
|
|
|
2014-06-15 18:57:30 +00:00
|
|
|
protected:
|
2016-07-13 20:07:03 +00:00
|
|
|
~MediaEngineWebRTCMicrophoneSource() {}
|
2014-06-24 16:36:43 +00:00
|
|
|
|
2012-07-12 11:53:08 +00:00
|
|
|
private:
|
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
|
|
|
/**
|
|
|
|
* Representation of data tied to an AllocationHandle rather than to the source.
|
|
|
|
*/
|
|
|
|
struct Allocation {
|
|
|
|
Allocation() = delete;
|
|
|
|
explicit Allocation(const RefPtr<AllocationHandle>& aHandle);
|
|
|
|
~Allocation();
|
|
|
|
|
2017-11-22 13:30:00 +00:00
|
|
|
#ifdef DEBUG
|
2018-02-28 21:45:40 +00:00
|
|
|
// The MSGImpl::IterationEnd() of the last time we appended data from an
|
|
|
|
// audio callback.
|
|
|
|
// Guarded by MediaEngineWebRTCMicrophoneSource::mMutex.
|
|
|
|
GraphTime mLastCallbackAppendTime = 0;
|
2017-11-22 13:30:00 +00:00
|
|
|
#endif
|
2018-02-28 21:45:40 +00:00
|
|
|
// Set to false by Start(). Becomes true after the first time we append real
|
|
|
|
// audio frames from the audio callback.
|
|
|
|
// Guarded by MediaEngineWebRTCMicrophoneSource::mMutex.
|
|
|
|
bool mLiveFramesAppended = false;
|
|
|
|
|
|
|
|
// Set to false by Start(). Becomes true after the first time we append
|
|
|
|
// silence *after* the first audio callback has appended real frames.
|
|
|
|
// Guarded by MediaEngineWebRTCMicrophoneSource::mMutex.
|
|
|
|
bool mLiveSilenceAppended = false;
|
2017-11-22 13:30:00 +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
|
|
|
const RefPtr<AllocationHandle> mHandle;
|
|
|
|
RefPtr<SourceMediaStream> mStream;
|
|
|
|
TrackID mTrackID = TRACK_NONE;
|
|
|
|
PrincipalHandle mPrincipal = PRINCIPAL_HANDLE_NONE;
|
2017-12-18 15:19:33 +00:00
|
|
|
bool mEnabled = false;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used with nsTArray<Allocation>::IndexOf to locate an Allocation by a handle.
|
|
|
|
*/
|
|
|
|
class AllocationHandleComparator {
|
|
|
|
public:
|
|
|
|
bool Equals(const Allocation& aAllocation,
|
|
|
|
const RefPtr<const AllocationHandle>& aHandle) const
|
|
|
|
{
|
|
|
|
return aHandle == aAllocation.mHandle;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reevaluates the aggregated constraints of all allocations and restarts the
|
|
|
|
* underlying device if necessary.
|
|
|
|
*
|
|
|
|
* If the given AllocationHandle was already registered, its constraints will
|
|
|
|
* be updated before reevaluation. If not, they will be added before
|
|
|
|
* reevaluation.
|
|
|
|
*/
|
|
|
|
nsresult ReevaluateAllocation(const RefPtr<AllocationHandle>& aHandle,
|
|
|
|
const NormalizedConstraints* aConstraintsUpdate,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const nsString& aDeviceId,
|
|
|
|
const char** aOutBadConstraint);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the underlying (single) device with the aggregated constraints
|
|
|
|
* aNetConstraints. If the chosen settings for the device changes based on
|
|
|
|
* these new constraints, and capture is active, the device will be restarted.
|
|
|
|
*/
|
|
|
|
nsresult UpdateSingleSource(const RefPtr<const AllocationHandle>& aHandle,
|
|
|
|
const NormalizedConstraints& aNetConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const nsString& aDeviceId,
|
|
|
|
const char** aOutBadConstraint);
|
2016-07-15 23:55:59 +00:00
|
|
|
|
2017-11-07 13:28:06 +00:00
|
|
|
|
|
|
|
void UpdateAECSettingsIfNeeded(bool aEnable, webrtc::EcModes aMode);
|
|
|
|
void UpdateAGCSettingsIfNeeded(bool aEnable, webrtc::AgcModes aMode);
|
|
|
|
void UpdateNSSettingsIfNeeded(bool aEnable, webrtc::NsModes aMode);
|
|
|
|
|
2018-03-26 10:18:35 +00:00
|
|
|
void ApplySettings(const MediaEnginePrefs& aPrefs,
|
|
|
|
RefPtr<MediaStreamGraphImpl> aGraph);
|
2016-07-16 19:33:54 +00:00
|
|
|
|
2017-12-18 15:19:33 +00:00
|
|
|
bool HasEnabledTrack() const;
|
|
|
|
|
2016-05-30 13:24:19 +00:00
|
|
|
template<typename T>
|
|
|
|
void InsertInGraph(const T* aBuffer,
|
|
|
|
size_t aFrames,
|
|
|
|
uint32_t aChannels);
|
|
|
|
|
|
|
|
void PacketizeAndProcess(MediaStreamGraph* aGraph,
|
|
|
|
const AudioDataValue* aBuffer,
|
|
|
|
size_t aFrames,
|
|
|
|
TrackRate aRate,
|
|
|
|
uint32_t aChannels);
|
|
|
|
|
2017-11-08 13:10:45 +00:00
|
|
|
|
|
|
|
// This is true when all processing is disabled, we can skip
|
|
|
|
// packetization, resampling and other processing passes.
|
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
|
|
|
// Graph thread only.
|
|
|
|
bool PassThrough() const;
|
|
|
|
|
|
|
|
// Graph thread only.
|
|
|
|
void SetPassThrough(bool aPassThrough);
|
2017-11-08 13:10:45 +00:00
|
|
|
|
2017-12-18 15:19:33 +00:00
|
|
|
// Owning thread only.
|
2016-01-21 16:51:36 +00:00
|
|
|
RefPtr<WebRTCAudioDataListener> mListener;
|
2016-01-21 16:51:36 +00:00
|
|
|
|
2018-02-05 09:50:47 +00:00
|
|
|
// Note: shared across all microphone sources. Owning thread only.
|
2016-05-23 14:22:47 +00:00
|
|
|
static int sChannelsOpen;
|
2012-07-12 11:53:08 +00:00
|
|
|
|
2017-12-18 15:19:33 +00:00
|
|
|
const RefPtr<mozilla::AudioInput> mAudioInput;
|
2017-10-31 17:25:41 +00:00
|
|
|
const UniquePtr<webrtc::AudioProcessing> mAudioProcessing;
|
2017-06-12 15:14:26 +00:00
|
|
|
|
2018-01-05 17:10:23 +00:00
|
|
|
// accessed from the GraphDriver thread except for deletion.
|
2018-01-05 16:19:22 +00:00
|
|
|
nsAutoPtr<AudioPacketizer<AudioDataValue, float>> mPacketizerInput;
|
2018-01-05 17:10:23 +00:00
|
|
|
nsAutoPtr<AudioPacketizer<AudioDataValue, float>> mPacketizerOutput;
|
2016-01-21 16:51:36 +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
|
|
|
// mMutex protects some of our members off the owning thread.
|
|
|
|
Mutex mMutex;
|
|
|
|
|
|
|
|
// We append an allocation in Allocate() and remove it in Deallocate().
|
|
|
|
// Both the array and the Allocation members are modified under mMutex on
|
|
|
|
// the owning thread. Accessed under one of the two.
|
|
|
|
nsTArray<Allocation> mAllocations;
|
|
|
|
|
|
|
|
// Current state of the shared resource for this source.
|
|
|
|
// Set under mMutex on the owning thread. Accessed under one of the two
|
|
|
|
MediaEngineSourceState mState = kReleased;
|
2016-05-23 14:22:47 +00:00
|
|
|
|
2012-07-12 11:53:08 +00:00
|
|
|
int mCapIndex;
|
2017-10-17 20:27:20 +00:00
|
|
|
bool mDelayAgnostic;
|
|
|
|
bool mExtendedFilter;
|
2014-04-02 17:58:19 +00:00
|
|
|
bool mStarted;
|
2012-07-12 11:53:08 +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
|
|
|
const nsString mDeviceName;
|
|
|
|
const nsCString mDeviceUUID;
|
|
|
|
|
|
|
|
// The current settings for the underlying device.
|
|
|
|
// Member access is main thread only after construction.
|
|
|
|
const nsMainThreadPtrHandle<media::Refcountable<dom::MediaTrackSettings>> mSettings;
|
2012-07-12 11:53:08 +00:00
|
|
|
|
2017-03-10 20:22:42 +00:00
|
|
|
uint64_t mTotalFrames;
|
|
|
|
uint64_t mLastLogFrames;
|
2013-01-29 16:55:09 +00:00
|
|
|
|
2016-05-30 13:24:19 +00:00
|
|
|
// mSkipProcessing is true if none of the processing passes are enabled,
|
|
|
|
// because of prefs or constraints. This allows simply copying the audio into
|
|
|
|
// the MSG, skipping resampling and the whole webrtc.org code.
|
2017-11-08 13:10:45 +00:00
|
|
|
// This is read and written to only on the MSG thread.
|
|
|
|
bool mSkipProcessing;
|
2016-07-16 19:33:54 +00:00
|
|
|
|
2018-03-26 10:24:17 +00:00
|
|
|
// To only update microphone when needed, we keep track of the prefs
|
|
|
|
// representing the currently applied settings for this source. This is the
|
|
|
|
// net result of the prefs across all allocations.
|
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
|
|
|
// Owning thread only.
|
2018-03-26 10:24:17 +00:00
|
|
|
MediaEnginePrefs mNetPrefs;
|
2017-09-04 14:26:03 +00:00
|
|
|
|
2018-01-05 17:10:23 +00:00
|
|
|
// Stores the mixed audio output for the reverse-stream of the AEC.
|
|
|
|
AlignedFloatBuffer mOutputBuffer;
|
|
|
|
|
2017-10-31 17:25:41 +00:00
|
|
|
AlignedFloatBuffer mInputBuffer;
|
Bug 1397793 - Move to APM - Part 2 - Actual processing. r=pehrsons
This also is long, but simple.
First, we switch to floats everywhere. This allows to work with any rate, is
more flexible with channel layout, and is a stable API (see audio_processing.h
in webrtc.org).
Then, 10ms worth of audio (already at the graph rate) are poped from the
lock-free queue (fed on the other end by the MSG mixer), and does the following:
- Down mixing to stereo (if needed)
- De-interleaving into planar buffer
- Prepare input and output config
- Actually make the API call
- Free the data
Now, first, we should use a ring buffer, and not have to free any data. Then we
also should not use a lock-free queue, and synchronously process the
reverse-stream, but this is enough code already.
Then, the actual mic data processing:
- Pop a packet from the packetizer (that gives us 10ms worth of audio, note that
we switch from int16_t to float, i.e. we don't do this conversion anymore).
- We convert to planar buffers, deinterleaving
- Prepare input and output config
- Allocate a SharedBuffer of the right size
- Process the data with the processing algorithm selected in UpdateSingleSource
- Append to the a MediaSegment, and append to the right MediaStreamTrack for the
correct SourceMediaStream (the data is already planar and all well).
MozReview-Commit-ID: 2IjgHP0GAmw
--HG--
extra : rebase_source : 1e08c4a781db8778e0532f9ef1a8e369513a2c66
extra : source : 0107b3feb84bbe0e643f505ec58e303dfd94e1a7
2017-12-04 12:34:14 +00:00
|
|
|
AlignedFloatBuffer mDeinterleavedBuffer;
|
2018-01-05 17:10:23 +00:00
|
|
|
AlignedFloatBuffer mInputDownmixBuffer;
|
2012-07-12 11:53:08 +00:00
|
|
|
};
|
|
|
|
|
2014-06-09 01:54:47 +00:00
|
|
|
class MediaEngineWebRTC : public MediaEngine
|
2012-07-12 11:53:08 +00:00
|
|
|
{
|
2016-07-13 20:07:03 +00:00
|
|
|
typedef MediaEngine Super;
|
2012-07-12 11:53:08 +00:00
|
|
|
public:
|
2014-10-13 03:37:37 +00:00
|
|
|
explicit MediaEngineWebRTC(MediaEnginePrefs& aPrefs);
|
2012-07-12 11:53:08 +00:00
|
|
|
|
2016-08-09 08:37:04 +00:00
|
|
|
virtual void SetFakeDeviceChangeEvents() override;
|
|
|
|
|
2012-07-12 11:53:08 +00:00
|
|
|
// Clients should ensure to clean-up sources video/audio sources
|
|
|
|
// before invoking Shutdown on this class.
|
2015-05-29 18:28:03 +00:00
|
|
|
void Shutdown() override;
|
2012-07-12 11:53:08 +00:00
|
|
|
|
2016-03-30 15:21:16 +00:00
|
|
|
// Returns whether the host supports duplex audio stream.
|
|
|
|
bool SupportsDuplex();
|
|
|
|
|
2018-01-31 16:57:59 +00:00
|
|
|
void EnumerateDevices(uint64_t aWindowId,
|
|
|
|
dom::MediaSourceEnum,
|
2018-07-16 09:30:46 +00:00
|
|
|
MediaSinkEnum,
|
2018-07-11 06:59:13 +00:00
|
|
|
nsTArray<RefPtr<MediaDevice>>*) override;
|
2018-01-31 18:02:00 +00:00
|
|
|
void ReleaseResourcesForWindow(uint64_t aWindowId) override;
|
2012-07-12 11:53:08 +00:00
|
|
|
private:
|
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
|
|
|
~MediaEngineWebRTC() = default;
|
2018-05-07 17:33:41 +00:00
|
|
|
void EnumerateVideoDevices(uint64_t aWindowId,
|
|
|
|
dom::MediaSourceEnum,
|
2018-07-11 06:59:13 +00:00
|
|
|
nsTArray<RefPtr<MediaDevice>>*);
|
2018-05-07 17:33:41 +00:00
|
|
|
void EnumerateMicrophoneDevices(uint64_t aWindowId,
|
2018-07-11 06:59:13 +00:00
|
|
|
nsTArray<RefPtr<MediaDevice>>*);
|
2018-07-16 09:30:46 +00:00
|
|
|
void EnumerateSpeakerDevices(uint64_t aWindowId,
|
|
|
|
nsTArray<RefPtr<MediaDevice> >*);
|
2014-04-11 15:35:34 +00:00
|
|
|
|
2014-07-08 19:02:40 +00:00
|
|
|
nsCOMPtr<nsIThread> mThread;
|
|
|
|
|
2015-08-31 12:51:29 +00:00
|
|
|
// gUM runnables can e.g. Enumerate from multiple threads
|
2012-10-18 18:03:00 +00:00
|
|
|
Mutex mMutex;
|
2016-01-21 16:51:36 +00:00
|
|
|
RefPtr<mozilla::AudioInput> mAudioInput;
|
2016-01-21 16:51:36 +00:00
|
|
|
bool mFullDuplex;
|
2017-10-17 20:27:20 +00:00
|
|
|
bool mDelayAgnostic;
|
|
|
|
bool mExtendedFilter;
|
2013-10-17 20:48:30 +00:00
|
|
|
bool mHasTabVideoSource;
|
2012-10-17 00:53:55 +00:00
|
|
|
|
2018-01-31 18:02:00 +00:00
|
|
|
// Maps WindowID to a map of device uuid to their MediaEngineSource,
|
|
|
|
// separately for audio and video.
|
|
|
|
nsClassHashtable<nsUint64HashKey,
|
|
|
|
nsRefPtrHashtable<nsStringHashKey,
|
|
|
|
MediaEngineSource>> mVideoSources;
|
|
|
|
nsClassHashtable<nsUint64HashKey,
|
|
|
|
nsRefPtrHashtable<nsStringHashKey,
|
|
|
|
MediaEngineSource>> mAudioSources;
|
2012-07-12 11:53:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* NSMEDIAENGINEWEBRTC_H_ */
|