--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -322,16 +322,20 @@ LargeAllocationNonGetRequest=A Large-All
LargeAllocationNotOnlyToplevelInTabGroup=A Large-Allocation header was ignored due to the presence of windows which have a reference to this browsing context through the frame hierarchy or window.opener.
# LOCALIZATION NOTE: Do not translate "Large-Allocation", as it is a literal header name
LargeAllocationNonE10S=A Large-Allocation header was ignored due to the document not being loaded out of process.
GeolocationInsecureRequestIsForbidden=A Geolocation request can only be fulfilled in a secure context.
# LOCALIZATION NOTE: Do not translate "Large-Allocation", as it is a literal header name.
LargeAllocationNonWin32=This page would be loaded in a new process due to a Large-Allocation header, however Large-Allocation process creation is disabled on non-Win32 platforms.
# LOCALIZATION NOTE: Do not translate URL.createObjectURL(MediaStream).
URLCreateObjectURL_MediaStream=URL.createObjectURL(MediaStream) is deprecated and will be removed soon.
+# LOCALIZATION NOTE: Do not translate MozAutoGainControl or autoGainControl.
+MozAutoGainControlWarning=mozAutoGainControl is deprecated. Use autoGainControl instead.
+# LOCALIZATION NOTE: Do not translate mozNoiseSuppression or noiseSuppression.
+MozNoiseSuppressionWarning=mozNoiseSuppression is deprecated. Use noiseSuppression instead.
# LOCALIZATION NOTE: Do not translate xml:base.
XMLBaseAttributeWarning=Use of xml:base attribute is deprecated and will be removed soon. Please remove any use of it.
# LOCALIZATION NOTE: %S is the tag name of the element that starts the loop
SVGReferenceLoopWarning=There is an SVG <%S> reference loop in this document, which will prevent the document rendering correctly.
# LOCALIZATION NOTE: %S is the tag name of the element that starts the chain
SVGReferenceChainLengthExceededWarning=There is an SVG <%S> reference chain which is too long in this document, which will prevent the document rendering correctly.
# LOCALIZATION NOTE: Do not translate "<script>".
ScriptSourceEmpty=ā%Sā attribute of <script> element is empty.
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -2229,16 +2229,24 @@ MediaManager::GetUserMedia(nsPIDOMWindow
}
}
} else if (IsOn(c.mVideo)) {
videoType = MediaSourceEnum::Camera;
}
if (c.mAudio.IsMediaTrackConstraints()) {
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
+ MediaConstraintsHelper::ConvertOldWithWarning(ac.mMozAutoGainControl,
+ ac.mAutoGainControl,
+ "MozAutoGainControlWarning",
+ aWindow);
+ MediaConstraintsHelper::ConvertOldWithWarning(ac.mMozNoiseSuppression,
+ ac.mNoiseSuppression,
+ "MozNoiseSuppressionWarning",
+ aWindow);
audioType = StringToEnum(dom::MediaSourceEnumValues::strings,
ac.mMediaSource,
MediaSourceEnum::Other);
// Work around WebIDL default since spec uses same dictionary w/audio & video.
if (audioType == MediaSourceEnum::Camera) {
audioType = MediaSourceEnum::Microphone;
ac.mMediaSource.AssignASCII(EnumToASCII(dom::MediaSourceEnumValues::strings,
audioType));
@@ -3770,20 +3778,21 @@ SourceListener::CapturingBrowser() const
{
MOZ_ASSERT(NS_IsMainThread());
return mActivated && mVideoDevice && !mVideoStopped &&
!mVideoDevice->GetSource()->IsAvailable() &&
mVideoDevice->GetMediaSource() == dom::MediaSourceEnum::Browser;
}
already_AddRefed<PledgeVoid>
-SourceListener::ApplyConstraintsToTrack(nsPIDOMWindowInner* aWindow,
- TrackID aTrackID,
- const dom::MediaTrackConstraints& aConstraints,
- dom::CallerType aCallerType)
+SourceListener::ApplyConstraintsToTrack(
+ nsPIDOMWindowInner* aWindow,
+ TrackID aTrackID,
+ const MediaTrackConstraints& aConstraintsPassedIn,
+ dom::CallerType aCallerType)
{
MOZ_ASSERT(NS_IsMainThread());
RefPtr<PledgeVoid> p = new PledgeVoid();
// XXX to support multiple tracks of a type in a stream, this should key off
// the TrackID and not just the type
RefPtr<AudioDevice> audioDevice =
aTrackID == kAudioTrack ? mAudioDevice.get() : nullptr;
@@ -3792,45 +3801,55 @@ SourceListener::ApplyConstraintsToTrack(
if (mStopped || (!audioDevice && !videoDevice))
{
LOG(("gUM track %d applyConstraints, but we don't have type %s",
aTrackID, aTrackID == kAudioTrack ? "audio" : "video"));
p->Resolve(false);
return p.forget();
}
+ MediaTrackConstraints c(aConstraintsPassedIn); // use a modifiable copy
+
+ MediaConstraintsHelper::ConvertOldWithWarning(c.mMozAutoGainControl,
+ c.mAutoGainControl,
+ "MozAutoGainControlWarning",
+ aWindow);
+ MediaConstraintsHelper::ConvertOldWithWarning(c.mMozNoiseSuppression,
+ c.mNoiseSuppression,
+ "MozNoiseSuppressionWarning",
+ aWindow);
RefPtr<MediaManager> mgr = MediaManager::GetInstance();
uint32_t id = mgr->mOutstandingVoidPledges.Append(*p);
uint64_t windowId = aWindow->WindowID();
bool isChrome = (aCallerType == dom::CallerType::System);
MediaManager::PostTask(NewTaskFrom([id, windowId,
audioDevice, videoDevice,
- aConstraints, isChrome]() mutable {
+ c, isChrome]() mutable {
MOZ_ASSERT(MediaManager::IsInMediaThread());
RefPtr<MediaManager> mgr = MediaManager::GetInstance();
const char* badConstraint = nullptr;
nsresult rv = NS_OK;
if (audioDevice) {
- rv = audioDevice->Restart(aConstraints, mgr->mPrefs, &badConstraint);
+ rv = audioDevice->Restart(c, mgr->mPrefs, &badConstraint);
if (rv == NS_ERROR_NOT_AVAILABLE && !badConstraint) {
nsTArray<RefPtr<AudioDevice>> audios;
audios.AppendElement(audioDevice);
badConstraint = MediaConstraintsHelper::SelectSettings(
- NormalizedConstraints(aConstraints), audios, isChrome);
+ NormalizedConstraints(c), audios, isChrome);
}
} else {
- rv = videoDevice->Restart(aConstraints, mgr->mPrefs, &badConstraint);
+ rv = videoDevice->Restart(c, mgr->mPrefs, &badConstraint);
if (rv == NS_ERROR_NOT_AVAILABLE && !badConstraint) {
nsTArray<RefPtr<VideoDevice>> videos;
videos.AppendElement(videoDevice);
badConstraint = MediaConstraintsHelper::SelectSettings(
- NormalizedConstraints(aConstraints), videos, isChrome);
+ NormalizedConstraints(c), videos, isChrome);
}
}
NS_DispatchToMainThread(NewRunnableFrom([id, windowId, rv,
badConstraint]() mutable {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<MediaManager> mgr = MediaManager_GetInstance();
if (!mgr) {
return NS_OK;
--- a/dom/media/tests/mochitest/test_getUserMedia_constraints.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_constraints.html
@@ -69,29 +69,28 @@ var tests = [
error: null },
{ message: "legacy facingMode ignored",
constraints: { video: { mandatory: { facingMode: 'left' } } },
error: null },
];
var mustSupport = [
'width', 'height', 'frameRate', 'facingMode', 'deviceId',
+ 'echoCancellation', 'noiseSuppression', 'autoGainControl',
+
// Yet to add:
- // 'aspectRatio', 'frameRate', 'volume', 'sampleRate', 'sampleSize',
- // 'latency', 'groupId'
+ // 'aspectRatio', 'volume', 'sampleRate', 'sampleSize', 'latency', 'groupId'
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
// OBE by http://w3c.github.io/mediacapture-screen-share
'mediaSource',
// Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
'browserWindow', 'scrollWithPage',
'viewportOffsetX', 'viewportOffsetY', 'viewportWidth', 'viewportHeight',
-
- 'echoCancellation', 'mozNoiseSuppression', 'mozAutoGainControl'
];
var mustFailWith = (msg, reason, constraint, f) =>
f().then(() => ok(false, msg + " must fail"), e => {
is(e.name, reason, msg + " must fail: " + e.message);
if (constraint !== undefined) {
is(e.constraint, constraint, msg + " must fail w/correct constraint.");
}
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -210,18 +210,18 @@ MediaEngineWebRTCMicrophoneSource::Media
, mSkipProcessing(false)
{
MOZ_ASSERT(aVoiceEnginePtr);
MOZ_ASSERT(aAudioInput);
mDeviceName.Assign(NS_ConvertUTF8toUTF16(name));
mDeviceUUID.Assign(uuid);
mListener = new mozilla::WebRTCAudioDataListener(this);
mSettings.mEchoCancellation.Construct(0);
- mSettings.mMozAutoGainControl.Construct(0);
- mSettings.mMozNoiseSuppression.Construct(0);
+ mSettings.mAutoGainControl.Construct(0);
+ mSettings.mNoiseSuppression.Construct(0);
// We'll init lazily as needed
}
void
MediaEngineWebRTCMicrophoneSource::GetName(nsAString& aName) const
{
aName.Assign(mDeviceName);
return;
@@ -281,18 +281,18 @@ MediaEngineWebRTCMicrophoneSource::Updat
const MediaEnginePrefs& aPrefs,
const nsString& aDeviceId,
const char** aOutBadConstraint)
{
FlattenedConstraints c(aNetConstraints);
MediaEnginePrefs prefs = aPrefs;
prefs.mAecOn = c.mEchoCancellation.Get(prefs.mAecOn);
- prefs.mAgcOn = c.mMozAutoGainControl.Get(prefs.mAgcOn);
- prefs.mNoiseOn = c.mMozNoiseSuppression.Get(prefs.mNoiseOn);
+ prefs.mAgcOn = c.mAutoGainControl.Get(prefs.mAgcOn);
+ prefs.mNoiseOn = c.mNoiseSuppression.Get(prefs.mNoiseOn);
LOG(("Audio config: aec: %d, agc: %d, noise: %d, delay: %d",
prefs.mAecOn ? prefs.mAec : -1,
prefs.mAgcOn ? prefs.mAgc : -1,
prefs.mNoiseOn ? prefs.mNoise : -1,
prefs.mPlayoutDelay));
mPlayoutDelay = prefs.mPlayoutDelay;
@@ -377,18 +377,18 @@ MediaEngineWebRTCMicrophoneSource::SetLa
const MediaEnginePrefs& aPrefs)
{
mLastPrefs = aPrefs;
RefPtr<MediaEngineWebRTCMicrophoneSource> that = this;
NS_DispatchToMainThread(media::NewRunnableFrom([that, aPrefs]() mutable {
that->mSettings.mEchoCancellation.Value() = aPrefs.mAecOn;
- that->mSettings.mMozAutoGainControl.Value() = aPrefs.mAgcOn;
- that->mSettings.mMozNoiseSuppression.Value() = aPrefs.mNoiseOn;
+ that->mSettings.mAutoGainControl.Value() = aPrefs.mAgcOn;
+ that->mSettings.mNoiseSuppression.Value() = aPrefs.mNoiseOn;
return NS_OK;
}));
}
nsresult
MediaEngineWebRTCMicrophoneSource::Deallocate(AllocationHandle* aHandle)
{
--- a/dom/media/webrtc/MediaTrackConstraints.cpp
+++ b/dom/media/webrtc/MediaTrackConstraints.cpp
@@ -1,14 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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 "MediaTrackConstraints.h"
+#include "nsIScriptError.h"
#include "mozilla/dom/MediaStreamTrackBinding.h"
#include <limits>
#include <algorithm>
#include <iterator>
namespace mozilla {
@@ -366,21 +367,21 @@ FlattenedConstraints::FlattenedConstrain
mFrameRate.Intersects(set.mFrameRate)) {
mWidth.Intersect(set.mWidth);
mHeight.Intersect(set.mHeight);
mFrameRate.Intersect(set.mFrameRate);
}
if (mEchoCancellation.Intersects(set.mEchoCancellation)) {
mEchoCancellation.Intersect(set.mEchoCancellation);
}
- if (mMozNoiseSuppression.Intersects(set.mMozNoiseSuppression)) {
- mMozNoiseSuppression.Intersect(set.mMozNoiseSuppression);
+ if (mNoiseSuppression.Intersects(set.mNoiseSuppression)) {
+ mNoiseSuppression.Intersect(set.mNoiseSuppression);
}
- if (mMozAutoGainControl.Intersects(set.mMozAutoGainControl)) {
- mMozAutoGainControl.Intersect(set.mMozAutoGainControl);
+ if (mAutoGainControl.Intersects(set.mAutoGainControl)) {
+ mAutoGainControl.Intersect(set.mAutoGainControl);
}
}
}
// MediaEngine helper
//
// The full algorithm for all devices. Sources that don't list capabilities
// need to fake it and hardcode some by populating mHardcodedCapabilities above.
@@ -464,9 +465,36 @@ MediaConstraintsHelper::FindBadConstrain
Unused << typename MockDevice::HasThreadSafeRefCnt();
nsTArray<RefPtr<MockDevice>> devices;
devices.AppendElement(new MockDevice(&aMediaEngineSource, aDeviceId));
return FindBadConstraint(aConstraints, devices);
}
+void
+MediaConstraintsHelper::ConvertOldWithWarning(
+ const dom::OwningBooleanOrConstrainBooleanParameters& old,
+ dom::OwningBooleanOrConstrainBooleanParameters& to,
+ const char* aMessageName,
+ nsPIDOMWindowInner* aWindow) {
+ if ((old.IsBoolean() ||
+ old.GetAsConstrainBooleanParameters().mExact.WasPassed() ||
+ old.GetAsConstrainBooleanParameters().mIdeal.WasPassed()) &&
+ !(to.IsBoolean() ||
+ to.GetAsConstrainBooleanParameters().mExact.WasPassed() ||
+ to.GetAsConstrainBooleanParameters().mIdeal.WasPassed())) {
+ nsCOMPtr<nsIDocument> doc = aWindow->GetDoc();
+ if (doc) {
+ nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
+ NS_LITERAL_CSTRING("DOM"), doc,
+ nsContentUtils::eDOM_PROPERTIES,
+ aMessageName);
+ }
+ if (old.IsBoolean()) {
+ to.SetAsBoolean() = old.GetAsBoolean();
+ } else {
+ to.SetAsConstrainBooleanParameters() = old.GetAsConstrainBooleanParameters();
+ }
+ }
}
+
+}
--- a/dom/media/webrtc/MediaTrackConstraints.h
+++ b/dom/media/webrtc/MediaTrackConstraints.h
@@ -220,17 +220,17 @@ public:
LongRange mWidth, mHeight;
DoubleRange mFrameRate;
StringRange mFacingMode;
StringRange mMediaSource;
LongLongRange mBrowserWindow;
BooleanRange mScrollWithPage;
StringRange mDeviceId;
LongRange mViewportOffsetX, mViewportOffsetY, mViewportWidth, mViewportHeight;
- BooleanRange mEchoCancellation, mMozNoiseSuppression, mMozAutoGainControl;
+ BooleanRange mEchoCancellation, mNoiseSuppression, mAutoGainControl;
private:
typedef NormalizedConstraintSet T;
public:
NormalizedConstraintSet(const dom::MediaTrackConstraintSet& aOther,
bool advanced,
nsTArray<MemberPtrType>* aList = nullptr)
: mWidth(&T::mWidth, "width", aOther.mWidth, advanced, aList)
, mHeight(&T::mHeight, "height", aOther.mHeight, advanced, aList)
@@ -249,21 +249,21 @@ public:
, mViewportOffsetY(&T::mViewportOffsetY, "viewportOffsetY",
aOther.mViewportOffsetY, advanced, aList)
, mViewportWidth(&T::mViewportWidth, "viewportWidth",
aOther.mViewportWidth, advanced, aList)
, mViewportHeight(&T::mViewportHeight, "viewportHeight",
aOther.mViewportHeight, advanced, aList)
, mEchoCancellation(&T::mEchoCancellation, "echoCancellation",
aOther.mEchoCancellation, advanced, aList)
- , mMozNoiseSuppression(&T::mMozNoiseSuppression, "mozNoiseSuppression",
- aOther.mMozNoiseSuppression,
- advanced, aList)
- , mMozAutoGainControl(&T::mMozAutoGainControl, "mozAutoGainControl",
- aOther.mMozAutoGainControl, advanced, aList) {}
+ , mNoiseSuppression(&T::mNoiseSuppression, "noiseSuppression",
+ aOther.mNoiseSuppression,
+ advanced, aList)
+ , mAutoGainControl(&T::mAutoGainControl, "autoGainControl",
+ aOther.mAutoGainControl, advanced, aList) {}
};
template<> bool NormalizedConstraintSet::Range<bool>::Merge(const Range& aOther);
template<> void NormalizedConstraintSet::Range<bool>::FinalizeMerge();
// Used instead of MediaTrackConstraints in lower-level code.
struct NormalizedConstraints : public NormalizedConstraintSet
{
@@ -437,13 +437,22 @@ public:
return "";
}
template<class MediaEngineSourceType>
static const char*
FindBadConstraint(const NormalizedConstraints& aConstraints,
const MediaEngineSourceType& aMediaEngineSource,
const nsString& aDeviceId);
+
+ // Warn on and convert use of deprecated constraints to new ones
+
+ static void
+ ConvertOldWithWarning(
+ const dom::OwningBooleanOrConstrainBooleanParameters& old,
+ dom::OwningBooleanOrConstrainBooleanParameters& to,
+ const char* aMessageName,
+ nsPIDOMWindowInner* aWindow);
};
} // namespace mozilla
#endif /* MEDIATRACKCONSTRAINTS_H_ */
--- a/dom/webidl/MediaStreamTrack.webidl
+++ b/dom/webidl/MediaStreamTrack.webidl
@@ -50,16 +50,20 @@ dictionary MediaTrackConstraintSet {
long long browserWindow;
boolean scrollWithPage;
ConstrainDOMString deviceId;
ConstrainLong viewportOffsetX;
ConstrainLong viewportOffsetY;
ConstrainLong viewportWidth;
ConstrainLong viewportHeight;
ConstrainBoolean echoCancellation;
+ ConstrainBoolean noiseSuppression;
+ ConstrainBoolean autoGainControl;
+
+ // Deprecated with warnings:
ConstrainBoolean mozNoiseSuppression;
ConstrainBoolean mozAutoGainControl;
};
dictionary MediaTrackConstraints : MediaTrackConstraintSet {
sequence<MediaTrackConstraintSet> advanced;
};
--- a/dom/webidl/MediaTrackSettings.webidl
+++ b/dom/webidl/MediaTrackSettings.webidl
@@ -9,18 +9,18 @@
dictionary MediaTrackSettings {
long width;
long height;
double frameRate;
DOMString facingMode;
DOMString deviceId;
boolean echoCancellation;
- boolean mozNoiseSuppression;
- boolean mozAutoGainControl;
+ boolean noiseSuppression;
+ boolean autoGainControl;
// Mozilla-specific extensions:
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
// OBE by http://w3c.github.io/mediacapture-screen-share
DOMString mediaSource;
@@ -28,9 +28,9 @@ dictionary MediaTrackSettings {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1193075
long long browserWindow;
boolean scrollWithPage;
long viewportOffsetX;
long viewportOffsetY;
long viewportWidth;
long viewportHeight;
-};
\ No newline at end of file
+};
--- a/dom/webidl/MediaTrackSupportedConstraints.webidl
+++ b/dom/webidl/MediaTrackSupportedConstraints.webidl
@@ -12,18 +12,18 @@ dictionary MediaTrackSupportedConstraint
boolean height = true;
boolean aspectRatio; // to be supported
boolean frameRate = true;
boolean facingMode = true;
boolean volume; // to be supported
boolean sampleRate; // to be supported
boolean sampleSize; // to be supported
boolean echoCancellation = true;
- boolean mozNoiseSuppression = true;
- boolean mozAutoGainControl = true;
+ boolean noiseSuppression = true;
+ boolean autoGainControl = true;
boolean latency; // to be supported
boolean deviceId = true;
boolean groupId; // to be supported
// Mozilla-specific extensions:
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
// OBE by http://w3c.github.io/mediacapture-screen-share