no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / media / AudioStreamTrack.cpp
blobd8ca9827b8aab795ec47497fb74e6e3a7b94b306
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "AudioStreamTrack.h"
8 #include "MediaTrackGraph.h"
9 #include "nsContentUtils.h"
11 namespace mozilla::dom {
13 RefPtr<GenericPromise> AudioStreamTrack::AddAudioOutput(
14 void* aKey, AudioDeviceInfo* aSink) {
15 if (Ended()) {
16 return GenericPromise::CreateAndResolve(true, __func__);
19 mTrack->AddAudioOutput(aKey, aSink);
20 return mTrack->Graph()->NotifyWhenDeviceStarted(aSink);
23 void AudioStreamTrack::RemoveAudioOutput(void* aKey) {
24 if (Ended()) {
25 return;
28 mTrack->RemoveAudioOutput(aKey);
31 void AudioStreamTrack::SetAudioOutputVolume(void* aKey, float aVolume) {
32 if (Ended()) {
33 return;
36 mTrack->SetAudioOutputVolume(aKey, aVolume);
39 void AudioStreamTrack::GetLabel(nsAString& aLabel, CallerType aCallerType) {
40 nsIGlobalObject* global =
41 GetParentObject() ? GetParentObject()->AsGlobal() : nullptr;
42 if (nsContentUtils::ShouldResistFingerprinting(aCallerType, global,
43 RFPTarget::StreamTrackLabel)) {
44 aLabel.AssignLiteral("Internal Microphone");
45 return;
47 MediaStreamTrack::GetLabel(aLabel, aCallerType);
50 already_AddRefed<MediaStreamTrack> AudioStreamTrack::CloneInternal() {
51 return do_AddRef(new AudioStreamTrack(mWindow, mInputTrack, mSource,
52 ReadyState(), Muted(), mConstraints));
55 } // namespace mozilla::dom