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 {
|
|
|
|
|
|
|
|
#ifdef PR_LOGGING
|
2013-11-21 07:02:42 +04:00
|
|
|
#define STREAM_LOG(type, msg) PR_LOG(gMediaStreamGraphLog, type, msg)
|
2012-07-31 16:17:21 +04:00
|
|
|
#else
|
2013-11-21 07:02:42 +04:00
|
|
|
#define STREAM_LOG(type, msg)
|
2012-07-31 16:17:21 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See MediaStreamGraph::CreateTrackUnionStream.
|
|
|
|
* This file is only included by MediaStreamGraph.cpp so it's OK to put the
|
|
|
|
* entire implementation in this header file.
|
|
|
|
*/
|
|
|
|
class TrackUnionStream : public ProcessedMediaStream {
|
|
|
|
public:
|
2013-02-15 12:01:58 +04:00
|
|
|
TrackUnionStream(DOMMediaStream* aWrapper) :
|
2012-07-31 16:17:21 +04:00
|
|
|
ProcessedMediaStream(aWrapper),
|
2013-05-21 23:17:47 +04:00
|
|
|
mFilterCallback(nullptr),
|
2012-07-31 16:17:21 +04:00
|
|
|
mMaxTrackID(0) {}
|
|
|
|
|
2013-12-06 00:23:57 +04:00
|
|
|
virtual void RemoveInput(MediaInputPort* aPort) MOZ_OVERRIDE
|
2012-07-31 16:17:21 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
|
2012-07-31 16:17:21 +04:00
|
|
|
if (mTrackMap[i].mInputPort == aPort) {
|
|
|
|
EndTrack(i);
|
|
|
|
mTrackMap.RemoveElementAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcessedMediaStream::RemoveInput(aPort);
|
|
|
|
}
|
2013-12-06 00:23:57 +04:00
|
|
|
virtual void ProduceOutput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) MOZ_OVERRIDE
|
2012-07-31 16:17:21 +04:00
|
|
|
{
|
2013-12-10 04:49:03 +04:00
|
|
|
if (IsFinishedOnGraphThread()) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-31 16:17:21 +04:00
|
|
|
nsAutoTArray<bool,8> mappedTracksFinished;
|
|
|
|
nsAutoTArray<bool,8> mappedTracksWithMatchingInputTracks;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mTrackMap.Length(); ++i) {
|
2012-07-31 16:17:21 +04:00
|
|
|
mappedTracksFinished.AppendElement(true);
|
|
|
|
mappedTracksWithMatchingInputTracks.AppendElement(false);
|
|
|
|
}
|
|
|
|
bool allFinished = true;
|
2013-03-20 15:19:39 +04:00
|
|
|
bool allHaveCurrentData = true;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < mInputs.Length(); ++i) {
|
2012-07-31 16:17:21 +04:00
|
|
|
MediaStream* stream = mInputs[i]->GetSource();
|
|
|
|
if (!stream->IsFinishedOnGraphThread()) {
|
2013-12-06 16:01:33 +04:00
|
|
|
// XXX we really should check whether 'stream' has finished within time aTo,
|
|
|
|
// not just that it's finishing when all its queued data eventually runs
|
|
|
|
// out.
|
2012-07-31 16:17:21 +04:00
|
|
|
allFinished = false;
|
|
|
|
}
|
2013-03-20 15:19:39 +04:00
|
|
|
if (!stream->HasCurrentData()) {
|
|
|
|
allHaveCurrentData = false;
|
|
|
|
}
|
2012-07-31 16:17:21 +04:00
|
|
|
for (StreamBuffer::TrackIter tracks(stream->GetStreamBuffer());
|
|
|
|
!tracks.IsEnded(); tracks.Next()) {
|
|
|
|
bool found = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < mTrackMap.Length(); ++j) {
|
2012-07-31 16:17:21 +04:00
|
|
|
TrackMapEntry* map = &mTrackMap[j];
|
2012-11-02 14:42:59 +04:00
|
|
|
if (map->mInputPort == mInputs[i] && map->mInputTrackID == tracks->GetID()) {
|
2012-07-31 16:17:21 +04:00
|
|
|
bool trackFinished;
|
2012-11-02 14:42:59 +04:00
|
|
|
StreamBuffer::Track* outputTrack = mBuffer.FindTrack(map->mOutputTrackID);
|
|
|
|
if (!outputTrack || outputTrack->IsEnded()) {
|
2012-07-31 16:17:21 +04:00
|
|
|
trackFinished = true;
|
|
|
|
} else {
|
2012-11-02 14:42:59 +04:00
|
|
|
CopyTrackData(tracks.get(), j, aFrom, aTo, &trackFinished);
|
2012-07-31 16:17:21 +04:00
|
|
|
}
|
|
|
|
mappedTracksFinished[j] = trackFinished;
|
|
|
|
mappedTracksWithMatchingInputTracks[j] = true;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-21 23:17:47 +04:00
|
|
|
if (!found && (!mFilterCallback || mFilterCallback(tracks.get()))) {
|
2012-07-31 16:17:21 +04:00
|
|
|
bool trackFinished = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mapIndex = AddTrack(mInputs[i], tracks.get(), aFrom);
|
2012-11-02 14:42:59 +04:00
|
|
|
CopyTrackData(tracks.get(), mapIndex, aFrom, aTo, &trackFinished);
|
2012-07-31 16:17:21 +04:00
|
|
|
mappedTracksFinished.AppendElement(trackFinished);
|
|
|
|
mappedTracksWithMatchingInputTracks.AppendElement(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
|
2012-07-31 16:17:21 +04:00
|
|
|
if (mappedTracksFinished[i]) {
|
|
|
|
EndTrack(i);
|
|
|
|
} else {
|
|
|
|
allFinished = false;
|
|
|
|
}
|
|
|
|
if (!mappedTracksWithMatchingInputTracks[i]) {
|
|
|
|
mTrackMap.RemoveElementAt(i);
|
|
|
|
}
|
|
|
|
}
|
2013-12-06 00:23:57 +04:00
|
|
|
if (allFinished && mAutofinish && (aFlags & ALLOW_FINISH)) {
|
2012-07-31 16:17:21 +04:00
|
|
|
// All streams have finished and won't add any more tracks, and
|
|
|
|
// all our tracks have actually finished and been removed from our map,
|
|
|
|
// so we're finished now.
|
|
|
|
FinishOnGraphThread();
|
|
|
|
}
|
|
|
|
mBuffer.AdvanceKnownTracksTime(GraphTimeToStreamTime(aTo));
|
2013-03-20 15:19:39 +04:00
|
|
|
if (allHaveCurrentData) {
|
|
|
|
// We can make progress if we're not blocked
|
|
|
|
mHasCurrentData = true;
|
|
|
|
}
|
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*);
|
|
|
|
void SetTrackIDFilter(TrackIDFilterCallback aCallback) {
|
|
|
|
mFilterCallback = aCallback;
|
|
|
|
}
|
|
|
|
|
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.
|
2013-12-06 00:23:57 +04:00
|
|
|
virtual void ForwardTrackEnabled(TrackID aOutputID, bool aEnabled) MOZ_OVERRIDE {
|
2013-08-26 10:07:19 +04:00
|
|
|
for (int32_t i = mTrackMap.Length() - 1; i >= 0; --i) {
|
|
|
|
if (mTrackMap[i].mOutputTrackID == aOutputID) {
|
|
|
|
mTrackMap[i].mInputPort->GetSource()->
|
|
|
|
SetTrackEnabled(mTrackMap[i].mInputTrackID, aEnabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
TrackTicks mEndOfConsumedInputTicks;
|
|
|
|
// 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,
|
2012-07-31 16:17:21 +04:00
|
|
|
GraphTime aFrom)
|
|
|
|
{
|
|
|
|
// Use the ID of the source track if we can, otherwise allocate a new
|
|
|
|
// unique ID
|
2013-01-15 16:22:03 +04:00
|
|
|
TrackID id = std::max(mMaxTrackID + 1, aTrack->GetID());
|
2012-07-31 16:17:21 +04:00
|
|
|
mMaxTrackID = id;
|
|
|
|
|
|
|
|
TrackRate rate = aTrack->GetRate();
|
|
|
|
// Round up the track start time so the track, if anything, starts a
|
|
|
|
// little later than the true time. This means we'll have enough
|
|
|
|
// samples in our input stream to go just beyond the destination time.
|
|
|
|
TrackTicks outputStart = TimeToTicksRoundUp(rate, GraphTimeToStreamTime(aFrom));
|
|
|
|
|
|
|
|
nsAutoPtr<MediaSegment> segment;
|
|
|
|
segment = aTrack->GetSegment()->CreateEmptyClone();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
2012-07-31 16:17:21 +04:00
|
|
|
MediaStreamListener* l = mListeners[j];
|
|
|
|
l->NotifyQueuedTrackChanges(Graph(), id, rate, outputStart,
|
|
|
|
MediaStreamListener::TRACK_EVENT_CREATED,
|
|
|
|
*segment);
|
|
|
|
}
|
|
|
|
segment->AppendNullData(outputStart);
|
|
|
|
StreamBuffer::Track* track =
|
|
|
|
&mBuffer.AddTrack(id, rate, outputStart, segment.forget());
|
2013-11-21 07:02:42 +04:00
|
|
|
STREAM_LOG(PR_LOG_DEBUG, ("TrackUnionStream %p adding track %d for input stream %p track %d, start ticks %lld",
|
|
|
|
this, id, aPort->GetSource(), aTrack->GetID(),
|
|
|
|
(long long)outputStart));
|
2012-07-31 16:17:21 +04:00
|
|
|
|
|
|
|
TrackMapEntry* map = mTrackMap.AppendElement();
|
2013-08-01 08:02:49 +04:00
|
|
|
map->mEndOfConsumedInputTicks = 0;
|
|
|
|
map->mEndOfLastInputIntervalInInputStream = -1;
|
|
|
|
map->mEndOfLastInputIntervalInOutputStream = -1;
|
2012-07-31 16:17:21 +04:00
|
|
|
map->mInputPort = aPort;
|
2012-11-02 14:42:59 +04:00
|
|
|
map->mInputTrackID = aTrack->GetID();
|
|
|
|
map->mOutputTrackID = track->GetID();
|
2012-07-31 16:17:21 +04:00
|
|
|
map->mSegment = aTrack->GetSegment()->CreateEmptyClone();
|
|
|
|
return mTrackMap.Length() - 1;
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
void EndTrack(uint32_t aIndex)
|
2012-07-31 16:17:21 +04:00
|
|
|
{
|
2012-11-02 14:42:59 +04:00
|
|
|
StreamBuffer::Track* outputTrack = mBuffer.FindTrack(mTrackMap[aIndex].mOutputTrackID);
|
|
|
|
if (!outputTrack || outputTrack->IsEnded())
|
2012-07-31 16:17:21 +04:00
|
|
|
return;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
2012-07-31 16:17:21 +04:00
|
|
|
MediaStreamListener* l = mListeners[j];
|
|
|
|
TrackTicks offset = outputTrack->GetSegment()->GetDuration();
|
|
|
|
nsAutoPtr<MediaSegment> segment;
|
|
|
|
segment = outputTrack->GetSegment()->CreateEmptyClone();
|
|
|
|
l->NotifyQueuedTrackChanges(Graph(), outputTrack->GetID(),
|
|
|
|
outputTrack->GetRate(), offset,
|
|
|
|
MediaStreamListener::TRACK_EVENT_ENDED,
|
|
|
|
*segment);
|
|
|
|
}
|
|
|
|
outputTrack->SetEnded();
|
|
|
|
}
|
2012-11-02 14:42:59 +04:00
|
|
|
void CopyTrackData(StreamBuffer::Track* aInputTrack,
|
|
|
|
uint32_t aMapIndex, GraphTime aFrom, GraphTime aTo,
|
2012-07-31 16:17:21 +04:00
|
|
|
bool* aOutputTrackFinished)
|
|
|
|
{
|
|
|
|
TrackMapEntry* map = &mTrackMap[aMapIndex];
|
2012-11-02 14:42:59 +04:00
|
|
|
StreamBuffer::Track* outputTrack = mBuffer.FindTrack(map->mOutputTrackID);
|
|
|
|
MOZ_ASSERT(outputTrack && !outputTrack->IsEnded(), "Can't copy to ended track");
|
|
|
|
|
2012-07-31 16:17:21 +04:00
|
|
|
TrackRate rate = outputTrack->GetRate();
|
|
|
|
MediaSegment* segment = map->mSegment;
|
|
|
|
MediaStream* source = map->mInputPort->GetSource();
|
|
|
|
|
|
|
|
GraphTime next;
|
|
|
|
*aOutputTrackFinished = false;
|
|
|
|
for (GraphTime t = aFrom; t < aTo; t = next) {
|
|
|
|
MediaInputPort::InputInterval interval = map->mInputPort->GetNextInputInterval(t);
|
2013-01-15 16:22:03 +04:00
|
|
|
interval.mEnd = std::min(interval.mEnd, aTo);
|
2013-12-04 10:01:59 +04:00
|
|
|
StreamTime inputEnd = source->GraphTimeToStreamTime(interval.mEnd);
|
|
|
|
TrackTicks inputTrackEndPoint = TRACK_TICKS_MAX;
|
|
|
|
|
|
|
|
if (aInputTrack->IsEnded() &&
|
|
|
|
aInputTrack->GetEndTimeRoundDown() <= inputEnd) {
|
|
|
|
inputTrackEndPoint = aInputTrack->GetEnd();
|
|
|
|
*aOutputTrackFinished = true;
|
|
|
|
}
|
|
|
|
|
2012-07-31 16:17:21 +04:00
|
|
|
if (interval.mStart >= interval.mEnd)
|
|
|
|
break;
|
|
|
|
next = interval.mEnd;
|
|
|
|
|
|
|
|
// Ticks >= startTicks and < endTicks are in the interval
|
|
|
|
StreamTime outputEnd = GraphTimeToStreamTime(interval.mEnd);
|
|
|
|
TrackTicks startTicks = outputTrack->GetEnd();
|
|
|
|
StreamTime outputStart = GraphTimeToStreamTime(interval.mStart);
|
2014-02-28 18:11:37 +04:00
|
|
|
NS_WARN_IF_FALSE(startTicks == TimeToTicksRoundUp(rate, outputStart),
|
|
|
|
"Samples missing");
|
2012-07-31 16:17:21 +04:00
|
|
|
TrackTicks endTicks = TimeToTicksRoundUp(rate, outputEnd);
|
|
|
|
TrackTicks ticks = endTicks - startTicks;
|
2013-08-01 08:02:49 +04:00
|
|
|
StreamTime inputStart = source->GraphTimeToStreamTime(interval.mStart);
|
2012-07-31 16:17:21 +04:00
|
|
|
|
|
|
|
if (interval.mInputIsBlocked) {
|
|
|
|
// Maybe the input track ended?
|
|
|
|
segment->AppendNullData(ticks);
|
2013-11-21 07:02:42 +04:00
|
|
|
STREAM_LOG(PR_LOG_DEBUG+1, ("TrackUnionStream %p appending %lld ticks of null data to track %d",
|
|
|
|
this, (long long)ticks, outputTrack->GetID()));
|
2012-07-31 16:17:21 +04:00
|
|
|
} else {
|
|
|
|
// Figuring out which samples to use from the input stream is tricky
|
|
|
|
// because its start time and our start time may differ by a fraction
|
|
|
|
// of a tick. Assuming the input track hasn't ended, we have to ensure
|
|
|
|
// that 'ticks' samples are gathered, even though a tick boundary may
|
|
|
|
// occur between outputStart and outputEnd but not between inputStart
|
|
|
|
// and inputEnd.
|
2013-08-01 08:02:49 +04:00
|
|
|
// These are the properties we need to ensure:
|
|
|
|
// 1) Exactly 'ticks' ticks of output are produced, i.e.
|
|
|
|
// inputEndTicks - inputStartTicks = ticks.
|
|
|
|
// 2) inputEndTicks <= aInputTrack->GetSegment()->GetDuration().
|
|
|
|
// 3) In any sequence of intervals where neither stream is blocked,
|
|
|
|
// the content of the input track we use is a contiguous sequence of
|
|
|
|
// ticks with no gaps or overlaps.
|
|
|
|
if (map->mEndOfLastInputIntervalInInputStream != inputStart ||
|
|
|
|
map->mEndOfLastInputIntervalInOutputStream != outputStart) {
|
|
|
|
// Start of a new series of intervals where neither stream is blocked.
|
|
|
|
map->mEndOfConsumedInputTicks = TimeToTicksRoundDown(rate, inputStart) - 1;
|
|
|
|
}
|
|
|
|
TrackTicks inputStartTicks = map->mEndOfConsumedInputTicks;
|
|
|
|
TrackTicks inputEndTicks = inputStartTicks + ticks;
|
|
|
|
map->mEndOfConsumedInputTicks = inputEndTicks;
|
|
|
|
map->mEndOfLastInputIntervalInInputStream = inputEnd;
|
|
|
|
map->mEndOfLastInputIntervalInOutputStream = outputEnd;
|
|
|
|
// Now we prove that the above properties hold:
|
|
|
|
// Property #1: trivial by construction.
|
|
|
|
// Property #3: trivial by construction. Between every two
|
|
|
|
// intervals where both streams are not blocked, the above if condition
|
|
|
|
// is false and mEndOfConsumedInputTicks advances exactly to match
|
|
|
|
// the ticks that were consumed.
|
|
|
|
// Property #2:
|
|
|
|
// Let originalOutputStart be the value of outputStart and originalInputStart
|
|
|
|
// be the value of inputStart when the body of the "if" block was last
|
|
|
|
// executed.
|
|
|
|
// Let allTicks be the sum of the values of 'ticks' computed since then.
|
|
|
|
// The interval [originalInputStart/rate, inputEnd/rate) is the
|
|
|
|
// same length as the interval [originalOutputStart/rate, outputEnd/rate),
|
|
|
|
// so the latter interval can have at most one more integer in it. Thus
|
|
|
|
// TimeToTicksRoundUp(rate, outputEnd) - TimeToTicksRoundUp(rate, originalOutputStart)
|
|
|
|
// <= TimeToTicksRoundDown(rate, inputEnd) - TimeToTicksRoundDown(rate, originalInputStart) + 1
|
|
|
|
// Then
|
|
|
|
// inputEndTicks = TimeToTicksRoundDown(rate, originalInputStart) - 1 + allTicks
|
|
|
|
// = TimeToTicksRoundDown(rate, originalInputStart) - 1 + TimeToTicksRoundUp(rate, outputEnd) - TimeToTicksRoundUp(rate, originalOutputStart)
|
|
|
|
// <= TimeToTicksRoundDown(rate, originalInputStart) - 1 + TimeToTicksRoundDown(rate, inputEnd) - TimeToTicksRoundDown(rate, originalInputStart) + 1
|
|
|
|
// = TimeToTicksRoundDown(rate, inputEnd)
|
|
|
|
// <= inputEnd/rate
|
|
|
|
// (now using the fact that inputEnd <= track->GetEndTimeRoundDown() for a non-ended track)
|
|
|
|
// <= TicksToTimeRoundDown(rate, aInputTrack->GetSegment()->GetDuration())/rate
|
|
|
|
// <= rate*aInputTrack->GetSegment()->GetDuration()/rate
|
|
|
|
// = aInputTrack->GetSegment()->GetDuration()
|
|
|
|
// as required.
|
|
|
|
|
|
|
|
if (inputStartTicks < 0) {
|
|
|
|
// Data before the start of the track is just null.
|
2013-08-07 07:42:43 +04:00
|
|
|
// We have to add a small amount of delay to ensure that there is
|
|
|
|
// always a sample available if we see an interval that contains a
|
|
|
|
// tick boundary on the output stream's timeline but does not contain
|
|
|
|
// a tick boundary on the input stream's timeline. 1 tick delay is
|
|
|
|
// necessary and sufficient.
|
2013-08-01 08:02:49 +04:00
|
|
|
segment->AppendNullData(-inputStartTicks);
|
|
|
|
inputStartTicks = 0;
|
|
|
|
}
|
|
|
|
if (inputEndTicks > inputStartTicks) {
|
|
|
|
segment->AppendSlice(*aInputTrack->GetSegment(),
|
|
|
|
std::min(inputTrackEndPoint, inputStartTicks),
|
|
|
|
std::min(inputTrackEndPoint, inputEndTicks));
|
|
|
|
}
|
2013-11-21 07:02:42 +04:00
|
|
|
STREAM_LOG(PR_LOG_DEBUG+1, ("TrackUnionStream %p appending %lld ticks of input data to track %d",
|
|
|
|
this, (long long)(std::min(inputTrackEndPoint, inputEndTicks) - std::min(inputTrackEndPoint, inputStartTicks)),
|
|
|
|
outputTrack->GetID()));
|
2012-07-31 16:17:21 +04:00
|
|
|
}
|
2013-05-30 08:44:43 +04:00
|
|
|
ApplyTrackDisabling(outputTrack->GetID(), segment);
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
2012-07-31 16:17:21 +04:00
|
|
|
MediaStreamListener* l = mListeners[j];
|
|
|
|
l->NotifyQueuedTrackChanges(Graph(), outputTrack->GetID(),
|
|
|
|
outputTrack->GetRate(), startTicks, 0,
|
|
|
|
*segment);
|
|
|
|
}
|
|
|
|
outputTrack->GetSegment()->AppendFrom(segment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<TrackMapEntry> mTrackMap;
|
|
|
|
TrackID mMaxTrackID;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* MOZILLA_MEDIASTREAMGRAPH_H_ */
|