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/. */ 5 6 #ifndef AUDIOSTREAMTRACK_H_ 7 #define AUDIOSTREAMTRACK_H_ 8 9 #include "MediaStreamTrack.h" 10 #include "DOMMediaStream.h" 11 #include "CrossGraphPort.h" 12 #include "nsClassHashtable.h" 13 14 namespace mozilla { 15 namespace dom { 16 17 class AudioStreamTrack : public MediaStreamTrack { 18 public: 19 AudioStreamTrack( 20 nsPIDOMWindowInner* aWindow, mozilla::MediaTrack* aInputTrack, 21 MediaStreamTrackSource* aSource, 22 MediaStreamTrackState aReadyState = MediaStreamTrackState::Live, 23 bool aMuted = false, 24 const MediaTrackConstraints& aConstraints = MediaTrackConstraints()) MediaStreamTrack(aWindow,aInputTrack,aSource,aReadyState,aMuted,aConstraints)25 : MediaStreamTrack(aWindow, aInputTrack, aSource, aReadyState, aMuted, 26 aConstraints) {} 27 AsAudioStreamTrack()28 AudioStreamTrack* AsAudioStreamTrack() override { return this; } AsAudioStreamTrack()29 const AudioStreamTrack* AsAudioStreamTrack() const override { return this; } 30 31 void AddAudioOutput(void* aKey); 32 void RemoveAudioOutput(void* aKey); 33 void SetAudioOutputVolume(void* aKey, float aVolume); 34 RefPtr<GenericPromise> SetAudioOutputDevice(void* key, 35 AudioDeviceInfo* aSink); 36 37 // WebIDL GetKind(nsAString & aKind)38 void GetKind(nsAString& aKind) override { aKind.AssignLiteral("audio"); } 39 40 void GetLabel(nsAString& aLabel, CallerType aCallerType) override; 41 42 protected: 43 already_AddRefed<MediaStreamTrack> CloneInternal() override; 44 void SetReadyState(MediaStreamTrackState aState) override; 45 46 private: 47 // Track CrossGraphPort per AudioOutput key. This is required in order to 48 // redirect all AudioOutput requests (add, remove, set volume) to the 49 // receiver track which, belonging to the remote graph. MainThread only. 50 nsClassHashtable<nsPtrHashKey<void>, UniquePtr<CrossGraphPort>> mCrossGraphs; 51 }; 52 53 } // namespace dom 54 } // namespace mozilla 55 56 #endif /* AUDIOSTREAMTRACK_H_ */ 57