ForwardedInputTrack.h (2559B)
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 MOZILLA_FORWARDEDINPUTTRACK_H_ 7 #define MOZILLA_FORWARDEDINPUTTRACK_H_ 8 9 #include "MediaTrackGraph.h" 10 #include "MediaTrackListener.h" 11 12 namespace mozilla { 13 14 /** 15 * See MediaTrackGraph::CreateForwardedInputTrack. 16 */ 17 class ForwardedInputTrack : public ProcessedMediaTrack { 18 public: 19 ForwardedInputTrack(TrackRate aSampleRate, MediaSegment::Type aType); 20 21 virtual ForwardedInputTrack* AsForwardedInputTrack() override { return this; } 22 friend class DOMMediaStream; 23 24 void AddInput(MediaInputPort* aPort) override; 25 void RemoveInput(MediaInputPort* aPort) override; 26 void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) override; 27 28 DisabledTrackMode CombinedDisabledMode() const override; 29 void SetDisabledTrackModeImpl(DisabledTrackMode aMode) override; 30 void OnInputDisabledModeChanged(DisabledTrackMode aInputMode) override; 31 32 uint32_t NumberOfChannels() const override; 33 34 friend class MediaTrackGraphImpl; 35 36 protected: 37 // Set up this track from a specific input. 38 void SetInput(MediaInputPort* aPort); 39 40 // MediaSegment-agnostic ProcessInput. 41 void ProcessInputImpl(MediaTrack* aSource, MediaSegment* aSegment, 42 GraphTime aFrom, GraphTime aTo, uint32_t aFlags); 43 44 void AddDirectListenerImpl( 45 already_AddRefed<DirectMediaTrackListener> aListener) override; 46 void RemoveDirectListenerImpl(DirectMediaTrackListener* aListener) override; 47 void RemoveAllDirectListenersImpl() override; 48 49 // These are direct track listeners that have been added to this 50 // ForwardedInputTrack-track. While an input is set, these are forwarded to 51 // the input track. We will update these when this track's disabled status 52 // changes. 53 nsTArray<RefPtr<DirectMediaTrackListener>> mOwnedDirectListeners; 54 55 // Set if an input has been added, nullptr otherwise. Adding more than one 56 // input is an error. 57 MediaInputPort* mInputPort = nullptr; 58 59 // This track's input's associated disabled mode. ENABLED if there is no 60 // input. This is used with MediaTrackListener::NotifyEnabledStateChanged(), 61 // which affects only video tracks. This is set only on ForwardedInputTracks. 62 DisabledTrackMode mInputDisabledMode = DisabledTrackMode::ENABLED; 63 }; 64 65 } // namespace mozilla 66 67 #endif /* MOZILLA_FORWARDEDINPUTTRACK_H_ */