mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1006707 - add microphone to mediaSource and remove redundant enum in c++. r=rjesup
This commit is contained in:
parent
566a2b022d
commit
9382757709
@ -522,9 +522,9 @@ MediaDevice::GetFacingMode(nsAString& aFacingMode)
|
||||
NS_IMETHODIMP
|
||||
MediaDevice::GetMediaSource(nsAString& aMediaSource)
|
||||
{
|
||||
if (mMediaSource == MediaSourceType::Microphone) {
|
||||
if (mMediaSource == dom::MediaSourceEnum::Microphone) {
|
||||
aMediaSource.Assign(NS_LITERAL_STRING("microphone"));
|
||||
} else if (mMediaSource == MediaSourceType::Window) { // this will go away
|
||||
} else if (mMediaSource == dom::MediaSourceEnum::Window) { // this will go away
|
||||
aMediaSource.Assign(NS_LITERAL_STRING("window"));
|
||||
} else { // all the rest are shared
|
||||
aMediaSource.Assign(NS_ConvertUTF8toUTF16(
|
||||
@ -948,7 +948,7 @@ template<class DeviceType, class ConstraintsType>
|
||||
static void
|
||||
GetSources(MediaEngine *engine,
|
||||
ConstraintsType &aConstraints,
|
||||
void (MediaEngine::* aEnumerate)(MediaSourceType,
|
||||
void (MediaEngine::* aEnumerate)(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<typename DeviceType::Source> >*),
|
||||
nsTArray<nsRefPtr<DeviceType>>& aResult,
|
||||
const char* media_device_name = nullptr)
|
||||
@ -960,10 +960,8 @@ static void
|
||||
SourceSet candidateSet;
|
||||
{
|
||||
nsTArray<nsRefPtr<typename DeviceType::Source> > sources;
|
||||
// all MediaSourceEnums are contained in MediaSourceType
|
||||
|
||||
(engine->*aEnumerate)((MediaSourceType)(aConstraints.mMediaSourceEnumValue),
|
||||
&sources);
|
||||
(engine->*aEnumerate)(aConstraints.mMediaSourceEnumValue, &sources);
|
||||
/**
|
||||
* We're allowing multiple tabs to access the same camera for parity
|
||||
* with Chrome. See bug 811757 for some of the issues surrounding
|
||||
@ -2403,9 +2401,9 @@ GetUserMediaCallbackMediaStreamListener::StopScreenWindowSharing()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
if (mVideoSource && !mStopped &&
|
||||
(mVideoSource->GetMediaSource() == MediaSourceType::Screen ||
|
||||
mVideoSource->GetMediaSource() == MediaSourceType::Application ||
|
||||
mVideoSource->GetMediaSource() == MediaSourceType::Window)) {
|
||||
(mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Screen ||
|
||||
mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Application ||
|
||||
mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Window)) {
|
||||
// Stop the whole stream if there's no audio; just the video track if we have both
|
||||
MediaManager::GetMessageLoop()->PostTask(FROM_HERE,
|
||||
new MediaOperationTask(mAudioSource ? MEDIA_STOP_TRACK : MEDIA_STOP,
|
||||
|
@ -116,7 +116,7 @@ public:
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
return mVideoSource && !mStopped &&
|
||||
mVideoSource->GetMediaSource() == MediaSourceType::Camera &&
|
||||
mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Camera &&
|
||||
(!mVideoSource->IsFake() ||
|
||||
Preferences::GetBool("media.navigator.permission.fake"));
|
||||
}
|
||||
@ -131,19 +131,19 @@ public:
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
return mVideoSource && !mStopped && !mVideoSource->IsAvailable() &&
|
||||
mVideoSource->GetMediaSource() == MediaSourceType::Screen;
|
||||
mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Screen;
|
||||
}
|
||||
bool CapturingWindow()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
return mVideoSource && !mStopped && !mVideoSource->IsAvailable() &&
|
||||
mVideoSource->GetMediaSource() == MediaSourceType::Window;
|
||||
mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Window;
|
||||
}
|
||||
bool CapturingApplication()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
return mVideoSource && !mStopped && !mVideoSource->IsAvailable() &&
|
||||
mVideoSource->GetMediaSource() == MediaSourceType::Application;
|
||||
mVideoSource->GetMediaSource() == dom::MediaSourceEnum::Application;
|
||||
}
|
||||
|
||||
void SetStopped()
|
||||
@ -508,7 +508,7 @@ protected:
|
||||
nsString mID;
|
||||
bool mHasFacingMode;
|
||||
dom::VideoFacingModeEnum mFacingMode;
|
||||
MediaSourceType mMediaSource;
|
||||
dom::MediaSourceEnum mMediaSource;
|
||||
nsRefPtr<MediaEngineSource> mSource;
|
||||
};
|
||||
|
||||
|
@ -39,16 +39,6 @@ enum MediaEngineState {
|
||||
kReleased
|
||||
};
|
||||
|
||||
// includes everything from dom::MediaSourceEnum (really video sources), plus audio sources
|
||||
enum MediaSourceType {
|
||||
Camera = (int) dom::MediaSourceEnum::Camera,
|
||||
Screen = (int) dom::MediaSourceEnum::Screen,
|
||||
Application = (int) dom::MediaSourceEnum::Application,
|
||||
Window, // = (int) dom::MediaSourceEnum::Window, // XXX bug 1038926
|
||||
Browser = (int) dom::MediaSourceEnum::Browser, // proposed in WG, unclear if it's useful
|
||||
Microphone
|
||||
};
|
||||
|
||||
class MediaEngine
|
||||
{
|
||||
public:
|
||||
@ -64,12 +54,12 @@ public:
|
||||
|
||||
/* Populate an array of video sources in the nsTArray. Also include devices
|
||||
* that are currently unavailable. */
|
||||
virtual void EnumerateVideoDevices(MediaSourceType,
|
||||
virtual void EnumerateVideoDevices(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<MediaEngineVideoSource> >*) = 0;
|
||||
|
||||
/* Populate an array of audio sources in the nsTArray. Also include devices
|
||||
* that are currently unavailable. */
|
||||
virtual void EnumerateAudioDevices(MediaSourceType,
|
||||
virtual void EnumerateAudioDevices(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<MediaEngineAudioSource> >*) = 0;
|
||||
|
||||
protected:
|
||||
@ -127,7 +117,7 @@ public:
|
||||
virtual bool IsFake() = 0;
|
||||
|
||||
/* Returns the type of media source (camera, microphone, screen, window, etc) */
|
||||
virtual const MediaSourceType GetMediaSource() = 0;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() = 0;
|
||||
|
||||
// Callback interface for TakePhoto(). Either PhotoComplete() or PhotoError()
|
||||
// should be called.
|
||||
|
@ -49,8 +49,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const MediaSourceType GetMediaSource() MOZ_OVERRIDE {
|
||||
return MediaSourceType::Camera;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() MOZ_OVERRIDE {
|
||||
return dom::MediaSourceEnum::Camera;
|
||||
}
|
||||
|
||||
virtual nsresult TakePhoto(PhotoCallback* aCallback) MOZ_OVERRIDE
|
||||
|
@ -469,12 +469,12 @@ MediaEngineDefaultAudioSource::Notify(nsITimer* aTimer)
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineDefault::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
MediaEngineDefault::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
||||
nsTArray<nsRefPtr<MediaEngineVideoSource> >* aVSources) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
// only supports camera sources (for now). See Bug 1038241
|
||||
if (aMediaSource != MediaSourceType::Camera) {
|
||||
if (aMediaSource != dom::MediaSourceEnum::Camera) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -490,7 +490,7 @@ MediaEngineDefault::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineDefault::EnumerateAudioDevices(MediaSourceType aMediaSource,
|
||||
MediaEngineDefault::EnumerateAudioDevices(dom::MediaSourceEnum aMediaSource,
|
||||
nsTArray<nsRefPtr<MediaEngineAudioSource> >* aASources) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
int32_t len = mASources.Length();
|
||||
|
@ -64,8 +64,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual const MediaSourceType GetMediaSource() MOZ_OVERRIDE {
|
||||
return MediaSourceType::Camera;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() MOZ_OVERRIDE {
|
||||
return dom::MediaSourceEnum::Camera;
|
||||
}
|
||||
|
||||
virtual nsresult TakePhoto(PhotoCallback* aCallback) MOZ_OVERRIDE
|
||||
@ -127,8 +127,8 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual const MediaSourceType GetMediaSource() MOZ_OVERRIDE {
|
||||
return MediaSourceType::Microphone;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() MOZ_OVERRIDE {
|
||||
return dom::MediaSourceEnum::Microphone;
|
||||
}
|
||||
|
||||
virtual nsresult TakePhoto(PhotoCallback* aCallback) MOZ_OVERRIDE
|
||||
@ -158,9 +158,9 @@ public:
|
||||
, mMutex("mozilla::MediaEngineDefault")
|
||||
{}
|
||||
|
||||
virtual void EnumerateVideoDevices(MediaSourceType,
|
||||
virtual void EnumerateVideoDevices(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<MediaEngineVideoSource> >*);
|
||||
virtual void EnumerateAudioDevices(MediaSourceType,
|
||||
virtual void EnumerateAudioDevices(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
|
||||
|
||||
protected:
|
||||
|
@ -29,8 +29,8 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
||||
virtual nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID) MOZ_OVERRIDE;
|
||||
virtual nsresult Config(bool, uint32_t, bool, uint32_t, bool, uint32_t, int32_t) MOZ_OVERRIDE;
|
||||
virtual bool IsFake() MOZ_OVERRIDE;
|
||||
virtual const MediaSourceType GetMediaSource() MOZ_OVERRIDE {
|
||||
return MediaSourceType::Browser;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() MOZ_OVERRIDE {
|
||||
return dom::MediaSourceEnum::Browser;
|
||||
}
|
||||
virtual bool SatisfiesConstraintSets(
|
||||
const nsTArray<const dom::MediaTrackConstraintSet*>& aConstraintSets) MOZ_OVERRIDE
|
||||
|
@ -72,14 +72,14 @@ MediaEngineWebRTC::MediaEngineWebRTC(MediaEnginePrefs &aPrefs)
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
MediaEngineWebRTC::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
|
||||
nsTArray<nsRefPtr<MediaEngineVideoSource> >* aVSources)
|
||||
{
|
||||
// We spawn threads to handle gUM runnables, so we must protect the member vars
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
#ifdef MOZ_B2G_CAMERA
|
||||
if (aMediaSource != MediaSourceType::Camera) {
|
||||
if (aMediaSource != dom::MediaSourceEnum::Camera) {
|
||||
// only supports camera sources
|
||||
return;
|
||||
}
|
||||
@ -137,7 +137,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
#endif
|
||||
|
||||
switch (aMediaSource) {
|
||||
case MediaSourceType::Window:
|
||||
case dom::MediaSourceEnum::Window:
|
||||
mWinEngineConfig.Set<webrtc::CaptureDeviceInfo>(
|
||||
new webrtc::CaptureDeviceInfo(webrtc::CaptureDeviceType::Window));
|
||||
if (!mWinEngine) {
|
||||
@ -148,7 +148,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
videoEngine = mWinEngine;
|
||||
videoEngineInit = &mWinEngineInit;
|
||||
break;
|
||||
case MediaSourceType::Application:
|
||||
case dom::MediaSourceEnum::Application:
|
||||
mAppEngineConfig.Set<webrtc::CaptureDeviceInfo>(
|
||||
new webrtc::CaptureDeviceInfo(webrtc::CaptureDeviceType::Application));
|
||||
if (!mAppEngine) {
|
||||
@ -159,7 +159,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
videoEngine = mAppEngine;
|
||||
videoEngineInit = &mAppEngineInit;
|
||||
break;
|
||||
case MediaSourceType::Screen:
|
||||
case dom::MediaSourceEnum::Screen:
|
||||
mScreenEngineConfig.Set<webrtc::CaptureDeviceInfo>(
|
||||
new webrtc::CaptureDeviceInfo(webrtc::CaptureDeviceType::Screen));
|
||||
if (!mScreenEngine) {
|
||||
@ -170,7 +170,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
videoEngine = mScreenEngine;
|
||||
videoEngineInit = &mScreenEngineInit;
|
||||
break;
|
||||
case MediaSourceType::Browser:
|
||||
case dom::MediaSourceEnum::Browser:
|
||||
mBrowserEngineConfig.Set<webrtc::CaptureDeviceInfo>(
|
||||
new webrtc::CaptureDeviceInfo(webrtc::CaptureDeviceType::Browser));
|
||||
if (!mBrowserEngine) {
|
||||
@ -181,7 +181,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
videoEngine = mBrowserEngine;
|
||||
videoEngineInit = &mBrowserEngineInit;
|
||||
break;
|
||||
case MediaSourceType::Camera:
|
||||
case dom::MediaSourceEnum::Camera:
|
||||
// fall through
|
||||
default:
|
||||
if (!mVideoEngine) {
|
||||
@ -274,7 +274,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
}
|
||||
}
|
||||
|
||||
if (mHasTabVideoSource || MediaSourceType::Browser == aMediaSource)
|
||||
if (mHasTabVideoSource || dom::MediaSourceEnum::Browser == aMediaSource)
|
||||
aVSources->AppendElement(new MediaEngineTabVideoSource());
|
||||
|
||||
return;
|
||||
@ -282,7 +282,7 @@ MediaEngineWebRTC::EnumerateVideoDevices(MediaSourceType aMediaSource,
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineWebRTC::EnumerateAudioDevices(MediaSourceType aMediaSource,
|
||||
MediaEngineWebRTC::EnumerateAudioDevices(dom::MediaSourceEnum aMediaSource,
|
||||
nsTArray<nsRefPtr<MediaEngineAudioSource> >* aASources)
|
||||
{
|
||||
ScopedCustomReleasePtr<webrtc::VoEBase> ptrVoEBase;
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
virtual bool IsTextureSupported() MOZ_OVERRIDE { return false; }
|
||||
|
||||
MediaEngineWebRTCVideoSource(webrtc::VideoEngine* aVideoEnginePtr, int aIndex,
|
||||
MediaSourceType aMediaSource = MediaSourceType::Camera)
|
||||
dom::MediaSourceEnum aMediaSource = dom::MediaSourceEnum::Camera)
|
||||
: MediaEngineCameraVideoSource(aIndex, "WebRTCCamera.Monitor")
|
||||
, mVideoEngine(aVideoEnginePtr)
|
||||
, mMinFps(-1)
|
||||
@ -99,7 +99,7 @@ public:
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime) MOZ_OVERRIDE;
|
||||
|
||||
virtual const MediaSourceType GetMediaSource() MOZ_OVERRIDE {
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() MOZ_OVERRIDE {
|
||||
return mMediaSource;
|
||||
}
|
||||
virtual nsresult TakePhoto(PhotoCallback* aCallback) MOZ_OVERRIDE
|
||||
@ -127,7 +127,7 @@ private:
|
||||
webrtc::ViERender* mViERender;
|
||||
|
||||
int mMinFps; // Min rate we want to accept
|
||||
MediaSourceType mMediaSource; // source of media (camera | application | screen)
|
||||
dom::MediaSourceEnum mMediaSource; // source of media (camera | application | screen)
|
||||
|
||||
static bool SatisfiesConstraintSet(const dom::MediaTrackConstraintSet& aConstraints,
|
||||
const webrtc::CaptureCapability& aCandidate);
|
||||
@ -185,8 +185,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const MediaSourceType GetMediaSource() MOZ_OVERRIDE {
|
||||
return MediaSourceType::Microphone;
|
||||
virtual const dom::MediaSourceEnum GetMediaSource() MOZ_OVERRIDE {
|
||||
return dom::MediaSourceEnum::Microphone;
|
||||
}
|
||||
|
||||
virtual nsresult TakePhoto(PhotoCallback* aCallback) MOZ_OVERRIDE
|
||||
@ -254,9 +254,9 @@ public:
|
||||
// before invoking Shutdown on this class.
|
||||
void Shutdown();
|
||||
|
||||
virtual void EnumerateVideoDevices(MediaSourceType,
|
||||
virtual void EnumerateVideoDevices(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<MediaEngineVideoSource> >*);
|
||||
virtual void EnumerateAudioDevices(MediaSourceType,
|
||||
virtual void EnumerateAudioDevices(dom::MediaSourceEnum,
|
||||
nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
|
||||
private:
|
||||
~MediaEngineWebRTC() {
|
||||
|
Loading…
Reference in New Issue
Block a user