2012-07-31 16:17:21 +04: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 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2012-07-31 16:17:21 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See MediaStreamGraph::CreateTrackUnionStream.
|
|
|
|
*/
|
|
|
|
class TrackUnionStream : public ProcessedMediaStream {
|
|
|
|
public:
|
2014-10-11 17:02:59 +04:00
|
|
|
explicit TrackUnionStream(DOMMediaStream* aWrapper);
|
2012-07-31 16:17:21 +04:00
|
|
|
|
2014-10-11 17:02:59 +04:00
|
|
|
virtual void RemoveInput(MediaInputPort* aPort) MOZ_OVERRIDE;
|
|
|
|
virtual void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) MOZ_OVERRIDE;
|
2012-07-31 16:17:21 +04:00
|
|
|
|
2013-05-21 23:17:47 +04:00
|
|
|
// Consumers may specify a filtering callback to apply to every input track.
|
|
|
|
// Returns true to allow the track to act as an input; false to reject it entirely.
|
|
|
|
typedef bool (*TrackIDFilterCallback)(StreamBuffer::Track*);
|
2014-10-11 17:02:59 +04:00
|
|
|
|
|
|
|
void SetTrackIDFilter(TrackIDFilterCallback aCallback);
|
2013-05-21 23:17:47 +04:00
|
|
|
|
2013-08-26 10:07:19 +04:00
|
|
|
// Forward SetTrackEnabled(output_track_id, enabled) to the Source MediaStream,
|
|
|
|
// translating the output track ID into the correct ID in the source.
|
2014-10-11 17:02:59 +04:00
|
|
|
virtual void ForwardTrackEnabled(TrackID aOutputID, bool aEnabled) MOZ_OVERRIDE;
|
2013-08-26 10:07:19 +04:00
|
|
|
|
2012-07-31 16:17:21 +04:00
|
|
|
protected:
|
2013-05-21 23:17:47 +04:00
|
|
|
TrackIDFilterCallback mFilterCallback;
|
|
|
|
|
2012-07-31 16:17:21 +04:00
|
|
|
// Only non-ended tracks are allowed to persist in this map.
|
|
|
|
struct TrackMapEntry {
|
2013-08-01 08:02:49 +04:00
|
|
|
// mEndOfConsumedInputTicks is the end of the input ticks that we've consumed.
|
|
|
|
// 0 if we haven't consumed any yet.
|
2014-09-18 09:20:43 +04:00
|
|
|
StreamTime mEndOfConsumedInputTicks;
|
2013-08-01 08:02:49 +04: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 16:17:21 +04:00
|
|
|
MediaInputPort* mInputPort;
|
2012-11-02 14:42:59 +04: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*,
|
|
|
|
// we call StreamBuffer::FindTrack, which will return null if
|
|
|
|
// the track has been deleted.
|
|
|
|
TrackID mInputTrackID;
|
|
|
|
TrackID mOutputTrackID;
|
2012-07-31 16:17:21 +04:00
|
|
|
nsAutoPtr<MediaSegment> mSegment;
|
|
|
|
};
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t AddTrack(MediaInputPort* aPort, StreamBuffer::Track* aTrack,
|
2014-10-11 17:02:59 +04:00
|
|
|
GraphTime aFrom);
|
|
|
|
void EndTrack(uint32_t aIndex);
|
2012-11-02 14:42:59 +04:00
|
|
|
void CopyTrackData(StreamBuffer::Track* aInputTrack,
|
|
|
|
uint32_t aMapIndex, GraphTime aFrom, GraphTime aTo,
|
2014-10-11 17:02:59 +04:00
|
|
|
bool* aOutputTrackFinished);
|
2012-07-31 16:17:21 +04:00
|
|
|
|
|
|
|
nsTArray<TrackMapEntry> mTrackMap;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASTREAMGRAPH_H_ */
|