зеркало из https://github.com/mozilla/gecko-dev.git
Bug 694814: Patch 6 - Change gUM prefs to media.getusermedia.*, groundwork for in-call changes r=jib
This commit is contained in:
Родитель
41dac5d5ab
Коммит
fcfefc894e
|
@ -379,13 +379,30 @@ class nsDOMUserMediaStream : public DOMLocalMediaStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static already_AddRefed<nsDOMUserMediaStream>
|
static already_AddRefed<nsDOMUserMediaStream>
|
||||||
CreateTrackUnionStream(nsIDOMWindow* aWindow, uint32_t aHintContents)
|
CreateTrackUnionStream(nsIDOMWindow* aWindow,
|
||||||
|
MediaEngineSource *aAudioSource,
|
||||||
|
MediaEngineSource *aVideoSource)
|
||||||
{
|
{
|
||||||
nsRefPtr<nsDOMUserMediaStream> stream = new nsDOMUserMediaStream();
|
DOMMediaStream::TrackTypeHints hints =
|
||||||
stream->InitTrackUnionStream(aWindow, aHintContents);
|
(aAudioSource ? DOMMediaStream::HINT_CONTENTS_AUDIO : 0) |
|
||||||
|
(aVideoSource ? DOMMediaStream::HINT_CONTENTS_VIDEO : 0);
|
||||||
|
|
||||||
|
nsRefPtr<nsDOMUserMediaStream> stream = new nsDOMUserMediaStream(aAudioSource);
|
||||||
|
stream->InitTrackUnionStream(aWindow, hints);
|
||||||
return stream.forget();
|
return stream.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsDOMUserMediaStream(MediaEngineSource *aAudioSource) :
|
||||||
|
mAudioSource(aAudioSource),
|
||||||
|
mEchoOn(true),
|
||||||
|
mAgcOn(false),
|
||||||
|
mNoiseOn(true),
|
||||||
|
mEcho(webrtc::kEcDefault),
|
||||||
|
mAgc(webrtc::kAgcDefault),
|
||||||
|
mNoise(webrtc::kNsDefault),
|
||||||
|
mPlayoutDelay(20)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual ~nsDOMUserMediaStream()
|
virtual ~nsDOMUserMediaStream()
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
@ -415,6 +432,21 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
AudioConfig(bool aEchoOn, uint32_t aEcho,
|
||||||
|
bool aAgcOn, uint32_t aAgc,
|
||||||
|
bool aNoiseOn, uint32_t aNoise,
|
||||||
|
int32_t aPlayoutDelay)
|
||||||
|
{
|
||||||
|
mEchoOn = aEchoOn;
|
||||||
|
mEcho = aEcho;
|
||||||
|
mAgcOn = aAgcOn;
|
||||||
|
mAgc = aAgc;
|
||||||
|
mNoiseOn = aNoiseOn;
|
||||||
|
mNoise = aNoise;
|
||||||
|
mPlayoutDelay = aPlayoutDelay;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void RemoveDirectListener(MediaStreamDirectListener *aListener) MOZ_OVERRIDE
|
virtual void RemoveDirectListener(MediaStreamDirectListener *aListener) MOZ_OVERRIDE
|
||||||
{
|
{
|
||||||
if (mSourceStream) {
|
if (mSourceStream) {
|
||||||
|
@ -437,6 +469,14 @@ public:
|
||||||
// explicitly destroyed too.
|
// explicitly destroyed too.
|
||||||
nsRefPtr<SourceMediaStream> mSourceStream;
|
nsRefPtr<SourceMediaStream> mSourceStream;
|
||||||
nsRefPtr<MediaInputPort> mPort;
|
nsRefPtr<MediaInputPort> mPort;
|
||||||
|
nsRefPtr<MediaEngineSource> mAudioSource; // so we can turn on AEC
|
||||||
|
bool mEchoOn;
|
||||||
|
bool mAgcOn;
|
||||||
|
bool mNoiseOn;
|
||||||
|
uint32_t mEcho;
|
||||||
|
uint32_t mAgc;
|
||||||
|
uint32_t mNoise;
|
||||||
|
uint32_t mPlayoutDelay;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,6 +557,12 @@ public:
|
||||||
NS_IMETHOD
|
NS_IMETHOD
|
||||||
Run()
|
Run()
|
||||||
{
|
{
|
||||||
|
int32_t aec = (int32_t) webrtc::kEcUnchanged;
|
||||||
|
int32_t agc = (int32_t) webrtc::kAgcUnchanged;
|
||||||
|
int32_t noise = (int32_t) webrtc::kNsUnchanged;
|
||||||
|
bool aec_on = false, agc_on = false, noise_on = false;
|
||||||
|
int32_t playout_delay = 0;
|
||||||
|
|
||||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||||
nsPIDOMWindow *window = static_cast<nsPIDOMWindow*>
|
nsPIDOMWindow *window = static_cast<nsPIDOMWindow*>
|
||||||
(nsGlobalWindow::GetInnerWindowWithId(mWindowID));
|
(nsGlobalWindow::GetInnerWindowWithId(mWindowID));
|
||||||
|
@ -529,19 +575,39 @@ public:
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a media stream.
|
#ifdef MOZ_WEBRTC
|
||||||
DOMMediaStream::TrackTypeHints hints =
|
// Right now these configs are only of use if webrtc is available
|
||||||
(mAudioSource ? DOMMediaStream::HINT_CONTENTS_AUDIO : 0) |
|
nsresult rv;
|
||||||
(mVideoSource ? DOMMediaStream::HINT_CONTENTS_VIDEO : 0);
|
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
||||||
|
|
||||||
|
if (branch) {
|
||||||
|
branch->GetBoolPref("media.getusermedia.aec_enabled", &aec_on);
|
||||||
|
branch->GetIntPref("media.getusermedia.aec", &aec);
|
||||||
|
branch->GetBoolPref("media.getusermedia.agc_enabled", &agc_on);
|
||||||
|
branch->GetIntPref("media.getusermedia.agc", &agc);
|
||||||
|
branch->GetBoolPref("media.getusermedia.noise_enabled", &noise_on);
|
||||||
|
branch->GetIntPref("media.getusermedia.noise", &noise);
|
||||||
|
branch->GetIntPref("media.getusermedia.playout_delay", &playout_delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// Create a media stream.
|
||||||
nsRefPtr<nsDOMUserMediaStream> trackunion =
|
nsRefPtr<nsDOMUserMediaStream> trackunion =
|
||||||
nsDOMUserMediaStream::CreateTrackUnionStream(window, hints);
|
nsDOMUserMediaStream::CreateTrackUnionStream(window, mAudioSource,
|
||||||
|
mVideoSource);
|
||||||
if (!trackunion) {
|
if (!trackunion) {
|
||||||
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> error = mError.forget();
|
nsCOMPtr<nsIDOMGetUserMediaErrorCallback> error = mError.forget();
|
||||||
LOG(("Returning error for getUserMedia() - no stream"));
|
LOG(("Returning error for getUserMedia() - no stream"));
|
||||||
error->OnError(NS_LITERAL_STRING("NO_STREAM"));
|
error->OnError(NS_LITERAL_STRING("NO_STREAM"));
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
trackunion->AudioConfig(aec_on, (uint32_t) aec,
|
||||||
|
agc_on, (uint32_t) agc,
|
||||||
|
noise_on, (uint32_t) noise,
|
||||||
|
playout_delay);
|
||||||
|
|
||||||
|
|
||||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||||
nsRefPtr<SourceMediaStream> stream = gm->CreateSourceStream(nullptr);
|
nsRefPtr<SourceMediaStream> stream = gm->CreateSourceStream(nullptr);
|
||||||
|
@ -572,33 +638,10 @@ public:
|
||||||
new TracksAvailableCallback(mManager, mSuccess, mWindowID, trackunion);
|
new TracksAvailableCallback(mManager, mSuccess, mWindowID, trackunion);
|
||||||
|
|
||||||
#ifdef MOZ_WEBRTC
|
#ifdef MOZ_WEBRTC
|
||||||
// Right now these configs are only of use if webrtc is available
|
mListener->AudioConfig(aec_on, (uint32_t) aec,
|
||||||
nsresult rv;
|
agc_on, (uint32_t) agc,
|
||||||
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
|
noise_on, (uint32_t) noise,
|
||||||
if (NS_SUCCEEDED(rv)) {
|
playout_delay);
|
||||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
|
||||||
|
|
||||||
if (branch) {
|
|
||||||
int32_t aec = (int32_t) webrtc::kEcUnchanged;
|
|
||||||
int32_t agc = (int32_t) webrtc::kAgcUnchanged;
|
|
||||||
int32_t noise = (int32_t) webrtc::kNsUnchanged;
|
|
||||||
bool aec_on = false, agc_on = false, noise_on = false;
|
|
||||||
int32_t playout_delay = 0;
|
|
||||||
|
|
||||||
branch->GetBoolPref("media.peerconnection.aec_enabled", &aec_on);
|
|
||||||
branch->GetIntPref("media.peerconnection.aec", &aec);
|
|
||||||
branch->GetBoolPref("media.peerconnection.agc_enabled", &agc_on);
|
|
||||||
branch->GetIntPref("media.peerconnection.agc", &agc);
|
|
||||||
branch->GetBoolPref("media.peerconnection.noise_enabled", &noise_on);
|
|
||||||
branch->GetIntPref("media.peerconnection.noise", &noise);
|
|
||||||
branch->GetIntPref("media.peerconnection.playout_delay", &playout_delay);
|
|
||||||
|
|
||||||
mListener->AudioConfig(aec_on, (uint32_t) aec,
|
|
||||||
agc_on, (uint32_t) agc,
|
|
||||||
noise_on, (uint32_t) noise,
|
|
||||||
playout_delay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Dispatch to the media thread to ask it to start the sources,
|
// Dispatch to the media thread to ask it to start the sources,
|
||||||
|
|
|
@ -264,27 +264,33 @@ pref("media.peerconnection.identity.timeout", 10000);
|
||||||
// kXxxUnchanged = 0, kXxxDefault = 1, and higher values are specific to each
|
// kXxxUnchanged = 0, kXxxDefault = 1, and higher values are specific to each
|
||||||
// setting (for Xxx = Ec, Agc, or Ns). Defaults are all set to kXxxDefault here.
|
// setting (for Xxx = Ec, Agc, or Ns). Defaults are all set to kXxxDefault here.
|
||||||
pref("media.peerconnection.turn.disable", false);
|
pref("media.peerconnection.turn.disable", false);
|
||||||
pref("media.peerconnection.aec_enabled", true);
|
pref("media.getusermedia.aec_enabled", true);
|
||||||
pref("media.peerconnection.aec", 1);
|
pref("media.getusermedia.aec", 1);
|
||||||
pref("media.peerconnection.agc_enabled", false);
|
pref("media.getusermedia.agc_enabled", false);
|
||||||
pref("media.peerconnection.agc", 1);
|
pref("media.getusermedia.agc", 1);
|
||||||
pref("media.peerconnection.noise_enabled", false);
|
pref("media.getusermedia.noise_enabled", true);
|
||||||
pref("media.peerconnection.noise", 1);
|
pref("media.getusermedia.noise", 1);
|
||||||
// Adjustments for OS mediastream+output+OS+input delay (lower bound)
|
// Adjustments for OS-specific input delay (lower bound)
|
||||||
|
// Adjustments for OS-specific AudioStream+cubeb+output delay (lower bound)
|
||||||
#if defined(XP_MACOSX)
|
#if defined(XP_MACOSX)
|
||||||
pref("media.peerconnection.capture_delay", 50);
|
pref("media.peerconnection.capture_delay", 50);
|
||||||
|
pref("media.getusermedia.playout_delay", 10);
|
||||||
#elif defined(XP_WIN)
|
#elif defined(XP_WIN)
|
||||||
pref("media.peerconnection.capture_delay", 50);
|
pref("media.peerconnection.capture_delay", 50);
|
||||||
|
pref("media.getusermedia.playout_delay", 40);
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
pref("media.peerconnection.capture_delay", 100);
|
pref("media.peerconnection.capture_delay", 100);
|
||||||
|
pref("media.getusermedia.playout_delay", 100);
|
||||||
// Whether to enable Webrtc Hardware acceleration support
|
// Whether to enable Webrtc Hardware acceleration support
|
||||||
pref("media.navigator.hardware.vp8_encode.acceleration_enabled", false);
|
pref("media.navigator.hardware.vp8_encode.acceleration_enabled", false);
|
||||||
pref("media.navigator.hardware.vp8_decode.acceleration_enabled", false);
|
pref("media.navigator.hardware.vp8_decode.acceleration_enabled", false);
|
||||||
#elif defined(XP_LINUX)
|
#elif defined(XP_LINUX)
|
||||||
pref("media.peerconnection.capture_delay", 70);
|
pref("media.peerconnection.capture_delay", 70);
|
||||||
|
pref("media.getusermedia.playout_delay", 50);
|
||||||
#else
|
#else
|
||||||
// *BSD, others - merely a guess for now
|
// *BSD, others - merely a guess for now
|
||||||
pref("media.peerconnection.capture_delay", 50);
|
pref("media.peerconnection.capture_delay", 50);
|
||||||
|
pref("media.getusermedia.playout_delay", 50);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
|
|
Загрузка…
Ссылка в новой задаче