2013-10-18 00:48:30 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "MediaEngine.h"
|
|
|
|
#include "ImageContainer.h"
|
|
|
|
#include "nsITimer.h"
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
#include "mozilla/Mutex.h"
|
2016-02-29 18:20:01 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2014-03-18 23:05:46 +04:00
|
|
|
#include "nsITabSource.h"
|
2013-10-18 00:48:30 +04: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 18:49:13 +03:00
|
|
|
class MediaEngineTabVideoSource : public MediaEngineSource
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MediaEngineTabVideoSource();
|
|
|
|
|
|
|
|
nsString GetName() const override;
|
|
|
|
nsCString GetUUID() const override;
|
|
|
|
|
|
|
|
bool GetScary() const override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
dom::MediaSourceEnum GetMediaSource() const override
|
|
|
|
{
|
|
|
|
return dom::MediaSourceEnum::Browser;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 18:19:33 +03: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;
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
nsresult Reconfigure(const RefPtr<AllocationHandle>& aHandle,
|
|
|
|
const dom::MediaTrackConstraints& aConstraints,
|
|
|
|
const MediaEnginePrefs& aPrefs,
|
|
|
|
const nsString& aDeviceId,
|
|
|
|
const char** aOutBadConstraint) override;
|
2018-05-08 22:55:36 +03:00
|
|
|
nsresult FocusOnSelectedSource(const RefPtr<const AllocationHandle>& aHandle) override;
|
2017-12-18 18:19:33 +03:00
|
|
|
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 18:49:13 +03:00
|
|
|
|
|
|
|
void Pull(const RefPtr<const AllocationHandle>& aHandle,
|
|
|
|
const RefPtr<SourceMediaStream>& aStream,
|
|
|
|
TrackID aTrackID,
|
|
|
|
StreamTime aDesiredTime,
|
|
|
|
const PrincipalHandle& aPrincipalHandle) override;
|
|
|
|
|
|
|
|
uint32_t GetBestFitnessDistance(
|
|
|
|
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
|
|
|
const nsString& aDeviceId) const override
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Draw();
|
|
|
|
|
|
|
|
class StartRunnable : public Runnable {
|
2013-10-18 00:48:30 +04:00
|
|
|
public:
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
explicit StartRunnable(MediaEngineTabVideoSource *videoSource)
|
|
|
|
: Runnable("MediaEngineTabVideoSource::StartRunnable")
|
|
|
|
, mVideoSource(videoSource)
|
|
|
|
{}
|
|
|
|
NS_IMETHOD Run() override;
|
|
|
|
RefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StopRunnable : public Runnable {
|
|
|
|
public:
|
|
|
|
explicit StopRunnable(MediaEngineTabVideoSource *videoSource)
|
|
|
|
: Runnable("MediaEngineTabVideoSource::StopRunnable")
|
|
|
|
, mVideoSource(videoSource)
|
|
|
|
{}
|
|
|
|
NS_IMETHOD Run() override;
|
|
|
|
RefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InitRunnable : public Runnable {
|
|
|
|
public:
|
|
|
|
explicit InitRunnable(MediaEngineTabVideoSource *videoSource)
|
|
|
|
: Runnable("MediaEngineTabVideoSource::InitRunnable")
|
|
|
|
, mVideoSource(videoSource)
|
|
|
|
{}
|
|
|
|
NS_IMETHOD Run() override;
|
|
|
|
RefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DestroyRunnable : public Runnable {
|
|
|
|
public:
|
|
|
|
explicit DestroyRunnable(MediaEngineTabVideoSource* videoSource)
|
|
|
|
: Runnable("MediaEngineTabVideoSource::DestroyRunnable")
|
|
|
|
, mVideoSource(videoSource)
|
|
|
|
{}
|
|
|
|
NS_IMETHOD Run() override;
|
|
|
|
RefPtr<MediaEngineTabVideoSource> mVideoSource;
|
|
|
|
};
|
2016-08-30 15:17:59 +03:00
|
|
|
|
2014-06-24 20:36:43 +04:00
|
|
|
protected:
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
~MediaEngineTabVideoSource() {}
|
2014-06-24 20:36:43 +04:00
|
|
|
|
2013-10-18 00:48:30 +04: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 18:49:13 +03:00
|
|
|
int32_t mBufWidthMax = 0;
|
|
|
|
int32_t mBufHeightMax = 0;
|
|
|
|
int64_t mWindowId = 0;
|
|
|
|
bool mScrollWithPage = 0;
|
|
|
|
int32_t mViewportOffsetX = 0;
|
|
|
|
int32_t mViewportOffsetY = 0;
|
|
|
|
int32_t mViewportWidth = 0;
|
|
|
|
int32_t mViewportHeight = 0;
|
|
|
|
int32_t mTimePerFrame = 0;
|
|
|
|
UniquePtr<unsigned char[]> mData;
|
|
|
|
size_t mDataSize = 0;
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> mWindow;
|
|
|
|
// If this is set, we will run despite mWindow == nullptr.
|
|
|
|
bool mBlackedoutWindow = false;
|
|
|
|
// Current state of this source.
|
|
|
|
// Written on owning thread *and* under mMutex.
|
|
|
|
// Can be read on owning thread *or* under mMutex.
|
|
|
|
MediaEngineSourceState mState = kReleased;
|
2017-12-18 18:19:33 +03:00
|
|
|
// mStream and mTrackID are set in SetTrack() to keep track of what to end
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
// in Deallocate().
|
|
|
|
// Owning thread only.
|
|
|
|
RefPtr<SourceMediaStream> mStream;
|
|
|
|
TrackID mTrackID = TRACK_NONE;
|
2017-12-18 18:19:33 +03:00
|
|
|
// mImage and mImageSize is Protected by 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 18:49:13 +03:00
|
|
|
RefPtr<layers::SourceSurfaceImage> mImage;
|
2017-12-18 18:19:33 +03:00
|
|
|
gfx::IntSize mImageSize;
|
Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
support scaling in this source and CamerasChild can act as a broker of frames.
This greatly simplifies it. The only shared source is now
MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
been moved to that source.
MozReview-Commit-ID: KeVZQo6gLm2
--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 18:49:13 +03:00
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
Mutex mMutex;
|
|
|
|
nsCOMPtr<nsITabSource> mTabSource;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|