Skip to content

Commit 62d0f39

Browse files
committed
Bug 1366415: Unprefix mozAutoGainControl and mozNoiseSuppression w/deprecation warnings. r=jesup,smaug
MozReview-Commit-ID: EdWjSsIhtIM UltraBlame original commit: c5ba9cddd3908e819a415e5c1d9ca3dc506cda2d
1 parent 282fd72 commit 62d0f39

9 files changed

+97
-34
lines changed

dom/locales/en-US/chrome/dom/dom.properties

+4
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ GeolocationInsecureRequestIsForbidden=A Geolocation request can only be fulfille
327327
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.
328328
# LOCALIZATION NOTE: Do not translate URL.createObjectURL(MediaStream).
329329
URLCreateObjectURL_MediaStream=URL.createObjectURL(MediaStream) is deprecated and will be removed soon.
330+
# LOCALIZATION NOTE: Do not translate MozAutoGainControl or autoGainControl.
331+
MozAutoGainControlWarning=mozAutoGainControl is deprecated. Use autoGainControl instead.
332+
# LOCALIZATION NOTE: Do not translate mozNoiseSuppression or noiseSuppression.
333+
MozNoiseSuppressionWarning=mozNoiseSuppression is deprecated. Use noiseSuppression instead.
330334
# LOCALIZATION NOTE: Do not translate xml:base.
331335
XMLBaseAttributeWarning=Use of xml:base attribute is deprecated and will be removed soon. Please remove any use of it.
332336
# LOCALIZATION NOTE: %S is the tag name of the element that starts the loop

dom/media/MediaManager.cpp

+28-9
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,14 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
22342234

22352235
if (c.mAudio.IsMediaTrackConstraints()) {
22362236
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
2237+
MediaConstraintsHelper::ConvertOldWithWarning(ac.mMozAutoGainControl,
2238+
ac.mAutoGainControl,
2239+
"MozAutoGainControlWarning",
2240+
aWindow);
2241+
MediaConstraintsHelper::ConvertOldWithWarning(ac.mMozNoiseSuppression,
2242+
ac.mNoiseSuppression,
2243+
"MozNoiseSuppressionWarning",
2244+
aWindow);
22372245
audioType = StringToEnum(dom::MediaSourceEnumValues::strings,
22382246
ac.mMediaSource,
22392247
MediaSourceEnum::Other);
@@ -3775,10 +3783,11 @@ SourceListener::CapturingBrowser() const
37753783
}
37763784

37773785
already_AddRefed<PledgeVoid>
3778-
SourceListener::ApplyConstraintsToTrack(nsPIDOMWindowInner* aWindow,
3779-
TrackID aTrackID,
3780-
const dom::MediaTrackConstraints& aConstraints,
3781-
dom::CallerType aCallerType)
3786+
SourceListener::ApplyConstraintsToTrack(
3787+
nsPIDOMWindowInner* aWindow,
3788+
TrackID aTrackID,
3789+
const MediaTrackConstraints& aConstraintsPassedIn,
3790+
dom::CallerType aCallerType)
37823791
{
37833792
MOZ_ASSERT(NS_IsMainThread());
37843793
RefPtr<PledgeVoid> p = new PledgeVoid();
@@ -3797,6 +3806,16 @@ SourceListener::ApplyConstraintsToTrack(nsPIDOMWindowInner* aWindow,
37973806
p->Resolve(false);
37983807
return p.forget();
37993808
}
3809+
MediaTrackConstraints c(aConstraintsPassedIn);
3810+
3811+
MediaConstraintsHelper::ConvertOldWithWarning(c.mMozAutoGainControl,
3812+
c.mAutoGainControl,
3813+
"MozAutoGainControlWarning",
3814+
aWindow);
3815+
MediaConstraintsHelper::ConvertOldWithWarning(c.mMozNoiseSuppression,
3816+
c.mNoiseSuppression,
3817+
"MozNoiseSuppressionWarning",
3818+
aWindow);
38003819

38013820
RefPtr<MediaManager> mgr = MediaManager::GetInstance();
38023821
uint32_t id = mgr->mOutstandingVoidPledges.Append(*p);
@@ -3805,27 +3824,27 @@ SourceListener::ApplyConstraintsToTrack(nsPIDOMWindowInner* aWindow,
38053824

38063825
MediaManager::PostTask(NewTaskFrom([id, windowId,
38073826
audioDevice, videoDevice,
3808-
aConstraints, isChrome]() mutable {
3827+
c, isChrome]() mutable {
38093828
MOZ_ASSERT(MediaManager::IsInMediaThread());
38103829
RefPtr<MediaManager> mgr = MediaManager::GetInstance();
38113830
const char* badConstraint = nullptr;
38123831
nsresult rv = NS_OK;
38133832

38143833
if (audioDevice) {
3815-
rv = audioDevice->Restart(aConstraints, mgr->mPrefs, &badConstraint);
3834+
rv = audioDevice->Restart(c, mgr->mPrefs, &badConstraint);
38163835
if (rv == NS_ERROR_NOT_AVAILABLE && !badConstraint) {
38173836
nsTArray<RefPtr<AudioDevice>> audios;
38183837
audios.AppendElement(audioDevice);
38193838
badConstraint = MediaConstraintsHelper::SelectSettings(
3820-
NormalizedConstraints(aConstraints), audios, isChrome);
3839+
NormalizedConstraints(c), audios, isChrome);
38213840
}
38223841
} else {
3823-
rv = videoDevice->Restart(aConstraints, mgr->mPrefs, &badConstraint);
3842+
rv = videoDevice->Restart(c, mgr->mPrefs, &badConstraint);
38243843
if (rv == NS_ERROR_NOT_AVAILABLE && !badConstraint) {
38253844
nsTArray<RefPtr<VideoDevice>> videos;
38263845
videos.AppendElement(videoDevice);
38273846
badConstraint = MediaConstraintsHelper::SelectSettings(
3828-
NormalizedConstraints(aConstraints), videos, isChrome);
3847+
NormalizedConstraints(c), videos, isChrome);
38293848
}
38303849
}
38313850
NS_DispatchToMainThread(NewRunnableFrom([id, windowId, rv,

dom/media/tests/mochitest/test_getUserMedia_constraints.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@
7474

7575
var mustSupport = [
7676
'width', 'height', 'frameRate', 'facingMode', 'deviceId',
77+
'echoCancellation', 'noiseSuppression', 'autoGainControl',
78+
7779
// Yet to add:
78-
// 'aspectRatio', 'frameRate', 'volume', 'sampleRate', 'sampleSize',
79-
// 'latency', 'groupId'
80+
// 'aspectRatio', 'volume', 'sampleRate', 'sampleSize', 'latency', 'groupId'
8081

8182
// http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
8283
// OBE by http://w3c.github.io/mediacapture-screen-share
@@ -85,8 +86,6 @@
8586
// Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
8687
'browserWindow', 'scrollWithPage',
8788
'viewportOffsetX', 'viewportOffsetY', 'viewportWidth', 'viewportHeight',
88-
89-
'echoCancellation', 'mozNoiseSuppression', 'mozAutoGainControl'
9089
];
9190

9291
var mustFailWith = (msg, reason, constraint, f) =>

dom/media/webrtc/MediaEngineWebRTCAudio.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ MediaEngineWebRTCMicrophoneSource::MediaEngineWebRTCMicrophoneSource(
215215
mDeviceUUID.Assign(uuid);
216216
mListener = new mozilla::WebRTCAudioDataListener(this);
217217
mSettings.mEchoCancellation.Construct(0);
218-
mSettings.mMozAutoGainControl.Construct(0);
219-
mSettings.mMozNoiseSuppression.Construct(0);
218+
mSettings.mAutoGainControl.Construct(0);
219+
mSettings.mNoiseSuppression.Construct(0);
220220

221221
}
222222

@@ -286,8 +286,8 @@ MediaEngineWebRTCMicrophoneSource::UpdateSingleSource(
286286

287287
MediaEnginePrefs prefs = aPrefs;
288288
prefs.mAecOn = c.mEchoCancellation.Get(prefs.mAecOn);
289-
prefs.mAgcOn = c.mMozAutoGainControl.Get(prefs.mAgcOn);
290-
prefs.mNoiseOn = c.mMozNoiseSuppression.Get(prefs.mNoiseOn);
289+
prefs.mAgcOn = c.mAutoGainControl.Get(prefs.mAgcOn);
290+
prefs.mNoiseOn = c.mNoiseSuppression.Get(prefs.mNoiseOn);
291291

292292
LOG(("Audio config: aec: %d, agc: %d, noise: %d, delay: %d",
293293
prefs.mAecOn ? prefs.mAec : -1,
@@ -382,8 +382,8 @@ MediaEngineWebRTCMicrophoneSource::SetLastPrefs(
382382

383383
NS_DispatchToMainThread(media::NewRunnableFrom([that, aPrefs]() mutable {
384384
that->mSettings.mEchoCancellation.Value() = aPrefs.mAecOn;
385-
that->mSettings.mMozAutoGainControl.Value() = aPrefs.mAgcOn;
386-
that->mSettings.mMozNoiseSuppression.Value() = aPrefs.mNoiseOn;
385+
that->mSettings.mAutoGainControl.Value() = aPrefs.mAgcOn;
386+
that->mSettings.mNoiseSuppression.Value() = aPrefs.mNoiseOn;
387387
return NS_OK;
388388
}));
389389
}

dom/media/webrtc/MediaTrackConstraints.cpp

+32-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
#include "MediaTrackConstraints.h"
7+
#include "nsIScriptError.h"
78
#include "mozilla/dom/MediaStreamTrackBinding.h"
89

910
#include <limits>
@@ -371,11 +372,11 @@ FlattenedConstraints::FlattenedConstraints(const NormalizedConstraints& aOther)
371372
if (mEchoCancellation.Intersects(set.mEchoCancellation)) {
372373
mEchoCancellation.Intersect(set.mEchoCancellation);
373374
}
374-
if (mMozNoiseSuppression.Intersects(set.mMozNoiseSuppression)) {
375-
mMozNoiseSuppression.Intersect(set.mMozNoiseSuppression);
375+
if (mNoiseSuppression.Intersects(set.mNoiseSuppression)) {
376+
mNoiseSuppression.Intersect(set.mNoiseSuppression);
376377
}
377-
if (mMozAutoGainControl.Intersects(set.mMozAutoGainControl)) {
378-
mMozAutoGainControl.Intersect(set.mMozAutoGainControl);
378+
if (mAutoGainControl.Intersects(set.mAutoGainControl)) {
379+
mAutoGainControl.Intersect(set.mAutoGainControl);
379380
}
380381
}
381382
}
@@ -469,4 +470,31 @@ MediaConstraintsHelper::FindBadConstraint(
469470
return FindBadConstraint(aConstraints, devices);
470471
}
471472

473+
void
474+
MediaConstraintsHelper::ConvertOldWithWarning(
475+
const dom::OwningBooleanOrConstrainBooleanParameters& old,
476+
dom::OwningBooleanOrConstrainBooleanParameters& to,
477+
const char* aMessageName,
478+
nsPIDOMWindowInner* aWindow) {
479+
if ((old.IsBoolean() ||
480+
old.GetAsConstrainBooleanParameters().mExact.WasPassed() ||
481+
old.GetAsConstrainBooleanParameters().mIdeal.WasPassed()) &&
482+
!(to.IsBoolean() ||
483+
to.GetAsConstrainBooleanParameters().mExact.WasPassed() ||
484+
to.GetAsConstrainBooleanParameters().mIdeal.WasPassed())) {
485+
nsCOMPtr<nsIDocument> doc = aWindow->GetDoc();
486+
if (doc) {
487+
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
488+
NS_LITERAL_CSTRING("DOM"), doc,
489+
nsContentUtils::eDOM_PROPERTIES,
490+
aMessageName);
491+
}
492+
if (old.IsBoolean()) {
493+
to.SetAsBoolean() = old.GetAsBoolean();
494+
} else {
495+
to.SetAsConstrainBooleanParameters() = old.GetAsConstrainBooleanParameters();
496+
}
497+
}
498+
}
499+
472500
}

dom/media/webrtc/MediaTrackConstraints.h

+15-6
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class NormalizedConstraintSet
225225
BooleanRange mScrollWithPage;
226226
StringRange mDeviceId;
227227
LongRange mViewportOffsetX, mViewportOffsetY, mViewportWidth, mViewportHeight;
228-
BooleanRange mEchoCancellation, mMozNoiseSuppression, mMozAutoGainControl;
228+
BooleanRange mEchoCancellation, mNoiseSuppression, mAutoGainControl;
229229
private:
230230
typedef NormalizedConstraintSet T;
231231
public:
@@ -254,11 +254,11 @@ class NormalizedConstraintSet
254254
aOther.mViewportHeight, advanced, aList)
255255
, mEchoCancellation(&T::mEchoCancellation, "echoCancellation",
256256
aOther.mEchoCancellation, advanced, aList)
257-
, mMozNoiseSuppression(&T::mMozNoiseSuppression, "mozNoiseSuppression",
258-
aOther.mMozNoiseSuppression,
259-
advanced, aList)
260-
, mMozAutoGainControl(&T::mMozAutoGainControl, "mozAutoGainControl",
261-
aOther.mMozAutoGainControl, advanced, aList) {}
257+
, mNoiseSuppression(&T::mNoiseSuppression, "noiseSuppression",
258+
aOther.mNoiseSuppression,
259+
advanced, aList)
260+
, mAutoGainControl(&T::mAutoGainControl, "autoGainControl",
261+
aOther.mAutoGainControl, advanced, aList) {}
262262
};
263263

264264
template<> bool NormalizedConstraintSet::Range<bool>::Merge(const Range& aOther);
@@ -442,6 +442,15 @@ class MediaConstraintsHelper
442442
FindBadConstraint(const NormalizedConstraints& aConstraints,
443443
const MediaEngineSourceType& aMediaEngineSource,
444444
const nsString& aDeviceId);
445+
446+
447+
448+
static void
449+
ConvertOldWithWarning(
450+
const dom::OwningBooleanOrConstrainBooleanParameters& old,
451+
dom::OwningBooleanOrConstrainBooleanParameters& to,
452+
const char* aMessageName,
453+
nsPIDOMWindowInner* aWindow);
445454
};
446455

447456
}

dom/webidl/MediaStreamTrack.webidl

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ dictionary MediaTrackConstraintSet {
5555
ConstrainLong viewportWidth;
5656
ConstrainLong viewportHeight;
5757
ConstrainBoolean echoCancellation;
58+
ConstrainBoolean noiseSuppression;
59+
ConstrainBoolean autoGainControl;
60+
61+
// Deprecated with warnings:
5862
ConstrainBoolean mozNoiseSuppression;
5963
ConstrainBoolean mozAutoGainControl;
6064
};

dom/webidl/MediaTrackSettings.webidl

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ dictionary MediaTrackSettings {
1414
DOMString facingMode;
1515
DOMString deviceId;
1616
boolean echoCancellation;
17-
boolean mozNoiseSuppression;
18-
boolean mozAutoGainControl;
17+
boolean noiseSuppression;
18+
boolean autoGainControl;
1919

2020
// Mozilla-specific extensions:
2121

@@ -33,4 +33,4 @@ dictionary MediaTrackSettings {
3333
long viewportOffsetY;
3434
long viewportWidth;
3535
long viewportHeight;
36-
};
36+
};

dom/webidl/MediaTrackSupportedConstraints.webidl

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ dictionary MediaTrackSupportedConstraints {
1717
boolean sampleRate; // to be supported
1818
boolean sampleSize; // to be supported
1919
boolean echoCancellation = true;
20-
boolean mozNoiseSuppression = true;
21-
boolean mozAutoGainControl = true;
20+
boolean noiseSuppression = true;
21+
boolean autoGainControl = true;
2222
boolean latency; // to be supported
2323
boolean deviceId = true;
2424
boolean groupId; // to be supported

0 commit comments

Comments
 (0)