gecko-dev/dom/media/AudioStreamTrack.cpp
Andreas Pehrson 4b3fa9c67e Bug 1493613 - Move MediaStream control from DOMMediaStream to MediaStreamTrack. r=padenot
This is inherently large, because modifying these bits of DOMMediaStream and
MediaStreamTrack affects all consumers and producers of all DOMMediaStreams and
MediaStreamTracks.

Things are generally much simpler now.

Producers of tracks now create a MediaStream in the graph, add it to a
MediaStreamTrackSource subclass that takes ownership of it, and add the source
to a MediaStreamTrack. Should the producer need a DOMMediaStream it is now much
simpler to create as the only thing needed is the current window. The stream is
a rather simple wrapper around an array of MediaStreamTracks.

HTMLMediaElement is still not as straight forward as other consumers since it
consumes the DOMMediaStream directly, as opposed to a set of tracks.
The new MediaStreamRenderer helper class helps bridge the gap between this fact
and the new track-based MediaStreamGraph interface, as it needs to juggle
registering multiple audio tracks for audio output. This hooks into existing
HTMLMediaElement logic and brings a welcome simplification to all the glue
previously needed there.

Differential Revision: https://phabricator.services.mozilla.com/D37934

--HG--
extra : moz-landing-system : lando
2019-07-31 07:58:17 +00:00

45 lines
1.1 KiB
C++

/* -*- 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 "AudioStreamTrack.h"
#include "MediaStreamGraph.h"
#include "nsContentUtils.h"
namespace mozilla {
namespace dom {
void AudioStreamTrack::AddAudioOutput(void* aKey) {
if (Ended()) {
return;
}
mStream->AddAudioOutput(aKey);
}
void AudioStreamTrack::RemoveAudioOutput(void* aKey) {
if (Ended()) {
return;
}
mStream->RemoveAudioOutput(aKey);
}
void AudioStreamTrack::SetAudioOutputVolume(void* aKey, float aVolume) {
if (Ended()) {
return;
}
mStream->SetAudioOutputVolume(aKey, aVolume);
}
void AudioStreamTrack::GetLabel(nsAString& aLabel, CallerType aCallerType) {
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
aLabel.AssignLiteral("Internal Microphone");
return;
}
MediaStreamTrack::GetLabel(aLabel, aCallerType);
}
} // namespace dom
} // namespace mozilla