summaryrefslogtreecommitdiffstats
path: root/dom/media/MediaManager.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /dom/media/MediaManager.cpp
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz
firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/MediaManager.cpp')
-rw-r--r--dom/media/MediaManager.cpp75
1 files changed, 28 insertions, 47 deletions
diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp
index 25eeb876d4..422769587a 100644
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -872,8 +872,7 @@ MediaDevice::MediaDevice(MediaEngine* aEngine, MediaSourceEnum aMediaSource,
mCanRequestOsLevelPrompt(canRequestOsLevelPrompt == OsPromptable::Yes),
mIsFake(mEngine->IsFake()),
mIsPlaceholder(aIsPlaceholder == IsPlaceholder::Yes),
- mType(
- NS_ConvertASCIItoUTF16(dom::MediaDeviceKindValues::GetString(mKind))),
+ mType(NS_ConvertASCIItoUTF16(dom::GetEnumString(mKind))),
mRawID(aRawID),
mRawGroupID(aRawGroupID),
mRawName(aRawName) {
@@ -895,8 +894,7 @@ MediaDevice::MediaDevice(MediaEngine* aEngine,
mCanRequestOsLevelPrompt(false),
mIsFake(false),
mIsPlaceholder(false),
- mType(
- NS_ConvertASCIItoUTF16(dom::MediaDeviceKindValues::GetString(mKind))),
+ mType(NS_ConvertASCIItoUTF16(dom::GetEnumString(mKind))),
mRawID(aRawID),
mRawGroupID(mAudioDeviceInfo->GroupID()),
mRawName(mAudioDeviceInfo->Name()) {}
@@ -1064,8 +1062,7 @@ LocalMediaDevice::GetMediaSource(nsAString& aMediaSource) {
if (Kind() == MediaDeviceKind::Audiooutput) {
aMediaSource.Truncate();
} else {
- aMediaSource.AssignASCII(
- dom::MediaSourceEnumValues::GetString(GetMediaSource()));
+ aMediaSource.AssignASCII(dom::GetEnumString(GetMediaSource()));
}
return NS_OK;
}
@@ -2249,14 +2246,6 @@ MediaManager::MediaManager(already_AddRefed<TaskQueue> aMediaThread)
GetPrefs(branch, nullptr);
}
}
- LOG("%s: default prefs: %dx%d @%dfps, %dHz test tones, aec: %s,"
- "agc: %s, hpf: %s, noise: %s, agc level: %d, agc version: %s, noise "
- "level: %d, transient: %s, channels %d",
- __FUNCTION__, mPrefs.mWidth, mPrefs.mHeight, mPrefs.mFPS, mPrefs.mFreq,
- mPrefs.mAecOn ? "on" : "off", mPrefs.mAgcOn ? "on" : "off",
- mPrefs.mHPFOn ? "on" : "off", mPrefs.mNoiseOn ? "on" : "off", mPrefs.mAgc,
- mPrefs.mAgc2Forced ? "2" : "1", mPrefs.mNoise,
- mPrefs.mTransientOn ? "on" : "off", mPrefs.mChannels);
}
NS_IMPL_ISUPPORTS(MediaManager, nsIMediaManagerService, nsIMemoryReporter,
@@ -2755,10 +2744,10 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
auto& vc = c.mVideo.GetAsMediaTrackConstraints();
if (!vc.mMediaSource.WasPassed()) {
vc.mMediaSource.Construct().AssignASCII(
- dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Camera));
+ dom::GetEnumString(MediaSourceEnum::Camera));
}
- videoType = StringToEnum(dom::MediaSourceEnumValues::strings,
- vc.mMediaSource.Value(), MediaSourceEnum::Other);
+ videoType = dom::StringToEnum<MediaSourceEnum>(vc.mMediaSource.Value())
+ .valueOr(MediaSourceEnum::Other);
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
(uint32_t)videoType);
switch (videoType) {
@@ -2823,8 +2812,7 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
if (videoType == MediaSourceEnum::Screen ||
videoType == MediaSourceEnum::Browser) {
videoType = MediaSourceEnum::Window;
- vc.mMediaSource.Value().AssignASCII(
- dom::MediaSourceEnumValues::GetString(videoType));
+ vc.mMediaSource.Value().AssignASCII(dom::GetEnumString(videoType));
}
// only allow privileged content to set the window id
if (vc.mBrowserWindow.WasPassed()) {
@@ -2848,10 +2836,10 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
auto& ac = c.mAudio.GetAsMediaTrackConstraints();
if (!ac.mMediaSource.WasPassed()) {
ac.mMediaSource.Construct(NS_ConvertASCIItoUTF16(
- dom::MediaSourceEnumValues::GetString(MediaSourceEnum::Microphone)));
+ dom::GetEnumString(MediaSourceEnum::Microphone)));
}
- audioType = StringToEnum(dom::MediaSourceEnumValues::strings,
- ac.mMediaSource.Value(), MediaSourceEnum::Other);
+ audioType = dom::StringToEnum<MediaSourceEnum>(ac.mMediaSource.Value())
+ .valueOr(MediaSourceEnum::Other);
Telemetry::Accumulate(Telemetry::WEBRTC_GET_USER_MEDIA_TYPE,
(uint32_t)audioType);
@@ -3498,6 +3486,14 @@ void MediaManager::GetPrefs(nsIPrefBranch* aBranch, const char* aData) {
GetPref(aBranch, "media.getusermedia.noise", aData, &mPrefs.mNoise);
GetPref(aBranch, "media.getusermedia.channels", aData, &mPrefs.mChannels);
#endif
+ LOG("%s: default prefs: %dx%d @%dfps, %dHz test tones, aec: %s, "
+ "agc: %s, hpf: %s, noise: %s, agc level: %d, agc version: %s, noise "
+ "level: %d, transient: %s, channels %d",
+ __FUNCTION__, mPrefs.mWidth, mPrefs.mHeight, mPrefs.mFPS, mPrefs.mFreq,
+ mPrefs.mAecOn ? "on" : "off", mPrefs.mAgcOn ? "on" : "off",
+ mPrefs.mHPFOn ? "on" : "off", mPrefs.mNoiseOn ? "on" : "off", mPrefs.mAgc,
+ mPrefs.mAgc2Forced ? "2" : "1", mPrefs.mNoise,
+ mPrefs.mTransientOn ? "on" : "off", mPrefs.mChannels);
}
void MediaManager::Shutdown() {
@@ -3650,8 +3646,6 @@ nsresult MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
nsCOMPtr<nsIPrefBranch> branch(do_QueryInterface(aSubject));
if (branch) {
GetPrefs(branch, NS_ConvertUTF16toUTF8(aData).get());
- LOG("%s: %dx%d @%dfps", __FUNCTION__, mPrefs.mWidth, mPrefs.mHeight,
- mPrefs.mFPS);
DeviceListChanged();
}
} else if (!strcmp(aTopic, "last-pb-context-exited")) {
@@ -4006,8 +4000,7 @@ void DeviceListener::Activate(RefPtr<LocalMediaDevice> aDevice,
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
LOG("DeviceListener %p activating %s device %p", this,
- nsCString(dom::MediaDeviceKindValues::GetString(aDevice->Kind())).get(),
- aDevice.get());
+ dom::GetEnumString(aDevice->Kind()).get(), aDevice.get());
MOZ_ASSERT(!mStopped, "Cannot activate stopped device listener");
MOZ_ASSERT(!Activated(), "Already activated");
@@ -4063,18 +4056,15 @@ DeviceListener::InitializeAsync() {
}
if (NS_FAILED(rv)) {
nsCString log;
- log.AppendPrintf(
- "Starting %s failed",
- nsCString(dom::MediaDeviceKindValues::GetString(kind))
- .get());
+ log.AppendPrintf("Starting %s failed",
+ dom::GetEnumString(kind).get());
aHolder.Reject(
MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError,
std::move(log)),
__func__);
return;
}
- LOG("started %s device %p",
- nsCString(dom::MediaDeviceKindValues::GetString(kind)).get(),
+ LOG("started %s device %p", dom::GetEnumString(kind).get(),
device.get());
aHolder.Resolve(true, __func__);
})
@@ -4182,9 +4172,7 @@ auto DeviceListener::UpdateDevice(bool aOn) -> RefPtr<DeviceOperationPromise> {
}
LOG("DeviceListener %p turning %s %s input device %s", this,
aOn ? "on" : "off",
- nsCString(
- dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
- .get(),
+ dom::GetEnumString(GetDevice()->Kind()).get(),
NS_SUCCEEDED(aResult) ? "succeeded" : "failed");
if (NS_FAILED(aResult) && aResult != NS_ERROR_ABORT) {
@@ -4217,8 +4205,7 @@ void DeviceListener::SetDeviceEnabled(bool aEnable) {
LOG("DeviceListener %p %s %s device", this,
aEnable ? "enabling" : "disabling",
- nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
- .get());
+ dom::GetEnumString(GetDevice()->Kind()).get());
state.mTrackEnabled = aEnable;
@@ -4274,9 +4261,7 @@ void DeviceListener::SetDeviceEnabled(bool aEnable) {
LOG("DeviceListener %p %s %s device - starting device operation",
this, aEnable ? "enabling" : "disabling",
- nsCString(
- dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
- .get());
+ dom::GetEnumString(GetDevice()->Kind()).get());
if (state.mStopped) {
// Source was stopped between timer resolving and this runnable.
@@ -4345,8 +4330,7 @@ void DeviceListener::SetDeviceMuted(bool aMute) {
DeviceState& state = *mDeviceState;
LOG("DeviceListener %p %s %s device", this, aMute ? "muting" : "unmuting",
- nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
- .get());
+ dom::GetEnumString(GetDevice()->Kind()).get());
if (state.mStopped) {
// Device terminally stopped. Updating device state is pointless.
@@ -4360,8 +4344,7 @@ void DeviceListener::SetDeviceMuted(bool aMute) {
LOG("DeviceListener %p %s %s device - starting device operation", this,
aMute ? "muting" : "unmuting",
- nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
- .get());
+ dom::GetEnumString(GetDevice()->Kind()).get());
state.mDeviceMuted = aMute;
@@ -4467,9 +4450,7 @@ RefPtr<DeviceListener::DeviceListenerPromise> DeviceListener::ApplyConstraints(
if (mStopped || mDeviceState->mStopped) {
LOG("DeviceListener %p %s device applyConstraints, but device is stopped",
- this,
- nsCString(dom::MediaDeviceKindValues::GetString(GetDevice()->Kind()))
- .get());
+ this, dom::GetEnumString(GetDevice()->Kind()).get());
return DeviceListenerPromise::CreateAndResolve(false, __func__);
}