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