2012-07-31 12:17:21 +00:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_TRACKUNIONSTREAM_H_
|
|
|
|
#define MOZILLA_TRACKUNIONSTREAM_H_
|
|
|
|
|
|
|
|
#include "MediaStreamGraph.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
2012-07-31 12:17:21 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See MediaStreamGraph::CreateTrackUnionStream.
|
|
|
|
*/
|
|
|
|
class TrackUnionStream : public ProcessedMediaStream {
|
|
|
|
public:
|
2014-10-11 13:02:59 +00:00
|
|
|
explicit TrackUnionStream(DOMMediaStream* aWrapper);
|
2012-07-31 12:17:21 +00:00
|
|
|
|
2016-01-18 03:50:29 +00:00
|
|
|
void RemoveInput(MediaInputPort* aPort) override;
|
|
|
|
void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) override;
|
2012-07-31 12:17:21 +00:00
|
|
|
|
2016-03-18 13:21:51 +00:00
|
|
|
void SetTrackEnabledImpl(TrackID aTrackID, bool aEnabled) override;
|
|
|
|
|
2012-07-31 12:17:21 +00:00
|
|
|
protected:
|
|
|
|
// Only non-ended tracks are allowed to persist in this map.
|
|
|
|
struct TrackMapEntry {
|
2013-08-01 04:02:49 +00:00
|
|
|
// mEndOfConsumedInputTicks is the end of the input ticks that we've consumed.
|
|
|
|
// 0 if we haven't consumed any yet.
|
2014-09-18 05:20:43 +00:00
|
|
|
StreamTime mEndOfConsumedInputTicks;
|
2013-08-01 04:02:49 +00:00
|
|
|
// mEndOfLastInputIntervalInInputStream is the timestamp for the end of the
|
|
|
|
// previous interval which was unblocked for both the input and output
|
|
|
|
// stream, in the input stream's timeline, or -1 if there wasn't one.
|
|
|
|
StreamTime mEndOfLastInputIntervalInInputStream;
|
|
|
|
// mEndOfLastInputIntervalInOutputStream is the timestamp for the end of the
|
|
|
|
// previous interval which was unblocked for both the input and output
|
|
|
|
// stream, in the output stream's timeline, or -1 if there wasn't one.
|
|
|
|
StreamTime mEndOfLastInputIntervalInOutputStream;
|
2012-07-31 12:17:21 +00:00
|
|
|
MediaInputPort* mInputPort;
|
2012-11-02 10:42:59 +00:00
|
|
|
// We keep track IDs instead of track pointers because
|
|
|
|
// tracks can be removed without us being notified (e.g.
|
|
|
|
// when a finished track is forgotten.) When we need a Track*,
|
2016-01-26 02:49:01 +00:00
|
|
|
// we call StreamTracks::FindTrack, which will return null if
|
2012-11-02 10:42:59 +00:00
|
|
|
// the track has been deleted.
|
|
|
|
TrackID mInputTrackID;
|
|
|
|
TrackID mOutputTrackID;
|
2012-07-31 12:17:21 +00:00
|
|
|
nsAutoPtr<MediaSegment> mSegment;
|
2016-03-18 13:21:51 +00:00
|
|
|
// These are direct track listeners that have been added to this
|
|
|
|
// TrackUnionStream-track and forwarded to the input track. We will update
|
|
|
|
// these when this track's disabled status changes.
|
|
|
|
nsTArray<RefPtr<MediaStreamTrackDirectListener>> mOwnedDirectListeners;
|
2012-07-31 12:17:21 +00:00
|
|
|
};
|
|
|
|
|
2015-06-12 10:56:27 +00:00
|
|
|
// Add the track to this stream, retaining its TrackID if it has never
|
|
|
|
// been previously used in this stream, allocating a new TrackID otherwise.
|
2016-01-26 02:49:01 +00:00
|
|
|
uint32_t AddTrack(MediaInputPort* aPort, StreamTracks::Track* aTrack,
|
2014-10-11 13:02:59 +00:00
|
|
|
GraphTime aFrom);
|
|
|
|
void EndTrack(uint32_t aIndex);
|
2016-01-26 02:49:01 +00:00
|
|
|
void CopyTrackData(StreamTracks::Track* aInputTrack,
|
2012-11-02 10:42:59 +00:00
|
|
|
uint32_t aMapIndex, GraphTime aFrom, GraphTime aTo,
|
2014-10-11 13:02:59 +00:00
|
|
|
bool* aOutputTrackFinished);
|
2012-07-31 12:17:21 +00:00
|
|
|
|
2016-03-03 16:28:37 +00:00
|
|
|
void AddDirectTrackListenerImpl(already_AddRefed<MediaStreamTrackDirectListener> aListener,
|
|
|
|
TrackID aTrackID) override;
|
|
|
|
void RemoveDirectTrackListenerImpl(MediaStreamTrackDirectListener* aListener,
|
|
|
|
TrackID aTrackID) override;
|
|
|
|
|
2012-07-31 12:17:21 +00:00
|
|
|
nsTArray<TrackMapEntry> mTrackMap;
|
2015-06-12 10:56:27 +00:00
|
|
|
|
|
|
|
// The next available TrackID, starting at 1 and progressing upwards.
|
|
|
|
// All TrackIDs in [1, mNextAvailableTrackID) have implicitly been used.
|
|
|
|
TrackID mNextAvailableTrackID;
|
|
|
|
|
|
|
|
// Sorted array of used TrackIDs that require manual tracking.
|
|
|
|
nsTArray<TrackID> mUsedTracks;
|
2016-03-03 16:28:37 +00:00
|
|
|
|
|
|
|
// Direct track listeners that have not been forwarded to their input stream
|
|
|
|
// yet. We'll forward these as their inputs become available.
|
|
|
|
nsTArray<TrackBound<MediaStreamTrackDirectListener>> mPendingDirectTrackListeners;
|
2012-07-31 12:17:21 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace mozilla
|
2012-07-31 12:17:21 +00:00
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASTREAMGRAPH_H_ */
|