зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1061046. Part 19: Eliminate TrackTicks in favour of StreamTime. r=karlt
This commit is contained in:
Родитель
4385e0bf9e
Коммит
407c1d5331
|
@ -84,7 +84,7 @@ struct AudioChunk {
|
|||
typedef mozilla::AudioSampleFormat SampleFormat;
|
||||
|
||||
// Generic methods
|
||||
void SliceTo(TrackTicks aStart, TrackTicks aEnd)
|
||||
void SliceTo(StreamTime aStart, StreamTime aEnd)
|
||||
{
|
||||
MOZ_ASSERT(aStart >= 0 && aStart < aEnd && aEnd <= mDuration,
|
||||
"Slice out of bounds");
|
||||
|
@ -97,7 +97,7 @@ struct AudioChunk {
|
|||
}
|
||||
mDuration = aEnd - aStart;
|
||||
}
|
||||
TrackTicks GetDuration() const { return mDuration; }
|
||||
StreamTime GetDuration() const { return mDuration; }
|
||||
bool CanCombineWithFollowing(const AudioChunk& aOther) const
|
||||
{
|
||||
if (aOther.mBuffer != mBuffer) {
|
||||
|
@ -121,7 +121,7 @@ struct AudioChunk {
|
|||
return true;
|
||||
}
|
||||
bool IsNull() const { return mBuffer == nullptr; }
|
||||
void SetNull(TrackTicks aDuration)
|
||||
void SetNull(StreamTime aDuration)
|
||||
{
|
||||
mBuffer = nullptr;
|
||||
mChannelData.Clear();
|
||||
|
@ -154,7 +154,7 @@ struct AudioChunk {
|
|||
return amount;
|
||||
}
|
||||
|
||||
TrackTicks mDuration; // in frames within the buffer
|
||||
StreamTime mDuration; // in frames within the buffer
|
||||
nsRefPtr<ThreadSharedObject> mBuffer; // the buffer object whose lifetime is managed; null means data is all zeroes
|
||||
nsTArray<const void*> mChannelData; // one pointer per channel; empty if and only if mBuffer is null
|
||||
float mVolume; // volume multiplier to apply (1.0f if mBuffer is nonnull)
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
class TrackChange : public nsRunnable {
|
||||
public:
|
||||
TrackChange(StreamListener* aListener,
|
||||
TrackID aID, TrackTicks aTrackOffset,
|
||||
TrackID aID, StreamTime aTrackOffset,
|
||||
uint32_t aEvents, MediaSegment::Type aType)
|
||||
: mListener(aListener), mID(aID), mEvents(aEvents), mType(aType)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
* aQueuedMedia can be null if there is no output.
|
||||
*/
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE
|
||||
{
|
||||
|
|
|
@ -239,8 +239,8 @@ private:
|
|||
nsRefPtr<MediaEngineSource> mAudioSource; // threadsafe refcnt
|
||||
nsRefPtr<MediaEngineSource> mVideoSource; // threadsafe refcnt
|
||||
nsRefPtr<SourceMediaStream> mStream; // threadsafe refcnt
|
||||
TrackTicks mLastEndTimeAudio;
|
||||
TrackTicks mLastEndTimeVideo;
|
||||
StreamTime mLastEndTimeAudio;
|
||||
StreamTime mLastEndTimeVideo;
|
||||
bool mFinished;
|
||||
|
||||
// Accessed from MainThread and MSG thread
|
||||
|
|
|
@ -28,6 +28,9 @@ const TrackRate TRACK_RATE_MAX = 1 << TRACK_RATE_MAX_BITS;
|
|||
* A number of ticks at a rate determined by some underlying track (e.g.
|
||||
* audio sample rate). We want to make sure that multiplying TrackTicks by
|
||||
* a TrackRate doesn't overflow, so we set its max accordingly.
|
||||
* StreamTime should be used instead when we're working with MediaStreamGraph's
|
||||
* rate, but TrackTicks can be used outside MediaStreams when we have data
|
||||
* at a different rate.
|
||||
*/
|
||||
typedef int64_t TrackTicks;
|
||||
const int64_t TRACK_TICKS_MAX = INT64_MAX >> TRACK_RATE_MAX_BITS;
|
||||
|
@ -39,11 +42,17 @@ const int64_t TRACK_TICKS_MAX = INT64_MAX >> TRACK_RATE_MAX_BITS;
|
|||
typedef int64_t MediaTime;
|
||||
const int64_t MEDIA_TIME_MAX = TRACK_TICKS_MAX;
|
||||
|
||||
/**
|
||||
* Media time relative to the start of a StreamBuffer.
|
||||
*/
|
||||
typedef MediaTime StreamTime;
|
||||
const StreamTime STREAM_TIME_MAX = MEDIA_TIME_MAX;
|
||||
|
||||
/**
|
||||
* A MediaSegment is a chunk of media data sequential in time. Different
|
||||
* types of data have different subclasses of MediaSegment, all inheriting
|
||||
* from MediaSegmentBase.
|
||||
* All MediaSegment data is timed using TrackTicks. The actual tick rate
|
||||
* All MediaSegment data is timed using StreamTime. The actual tick rate
|
||||
* is defined on a per-track basis. For some track types, this can be
|
||||
* a fixed constant for all tracks of that type (e.g. 1MHz for video).
|
||||
*
|
||||
|
@ -67,7 +76,7 @@ public:
|
|||
/**
|
||||
* Gets the total duration of the segment.
|
||||
*/
|
||||
TrackTicks GetDuration() const { return mDuration; }
|
||||
StreamTime GetDuration() const { return mDuration; }
|
||||
Type GetType() const { return mType; }
|
||||
|
||||
/**
|
||||
|
@ -82,23 +91,23 @@ public:
|
|||
* Append a slice of aSource to this segment.
|
||||
*/
|
||||
virtual void AppendSlice(const MediaSegment& aSource,
|
||||
TrackTicks aStart, TrackTicks aEnd) = 0;
|
||||
StreamTime aStart, StreamTime aEnd) = 0;
|
||||
/**
|
||||
* Replace all contents up to aDuration with null data.
|
||||
*/
|
||||
virtual void ForgetUpTo(TrackTicks aDuration) = 0;
|
||||
virtual void ForgetUpTo(StreamTime aDuration) = 0;
|
||||
/**
|
||||
* Forget all data buffered after a given point
|
||||
*/
|
||||
virtual void FlushAfter(TrackTicks aNewEnd) = 0;
|
||||
virtual void FlushAfter(StreamTime aNewEnd) = 0;
|
||||
/**
|
||||
* Insert aDuration of null data at the start of the segment.
|
||||
*/
|
||||
virtual void InsertNullDataAtStart(TrackTicks aDuration) = 0;
|
||||
virtual void InsertNullDataAtStart(StreamTime aDuration) = 0;
|
||||
/**
|
||||
* Insert aDuration of null data at the end of the segment.
|
||||
*/
|
||||
virtual void AppendNullData(TrackTicks aDuration) = 0;
|
||||
virtual void AppendNullData(StreamTime aDuration) = 0;
|
||||
/**
|
||||
* Replace contents with disabled data of the same duration
|
||||
*/
|
||||
|
@ -124,7 +133,7 @@ protected:
|
|||
MOZ_COUNT_CTOR(MediaSegment);
|
||||
}
|
||||
|
||||
TrackTicks mDuration; // total of mDurations of all chunks
|
||||
StreamTime mDuration; // total of mDurations of all chunks
|
||||
Type mType;
|
||||
};
|
||||
|
||||
|
@ -148,12 +157,12 @@ public:
|
|||
AppendFromInternal(aSource);
|
||||
}
|
||||
virtual void AppendSlice(const MediaSegment& aSource,
|
||||
TrackTicks aStart, TrackTicks aEnd)
|
||||
StreamTime aStart, StreamTime aEnd)
|
||||
{
|
||||
NS_ASSERTION(aSource.GetType() == C::StaticType(), "Wrong type");
|
||||
AppendSliceInternal(static_cast<const C&>(aSource), aStart, aEnd);
|
||||
}
|
||||
void AppendSlice(const C& aOther, TrackTicks aStart, TrackTicks aEnd)
|
||||
void AppendSlice(const C& aOther, StreamTime aStart, StreamTime aEnd)
|
||||
{
|
||||
AppendSliceInternal(aOther, aStart, aEnd);
|
||||
}
|
||||
|
@ -161,13 +170,13 @@ public:
|
|||
* Replace the first aDuration ticks with null media data, because the data
|
||||
* will not be required again.
|
||||
*/
|
||||
virtual void ForgetUpTo(TrackTicks aDuration)
|
||||
virtual void ForgetUpTo(StreamTime aDuration)
|
||||
{
|
||||
if (mChunks.IsEmpty() || aDuration <= 0) {
|
||||
return;
|
||||
}
|
||||
if (mChunks[0].IsNull()) {
|
||||
TrackTicks extraToForget = std::min(aDuration, mDuration) - mChunks[0].GetDuration();
|
||||
StreamTime extraToForget = std::min(aDuration, mDuration) - mChunks[0].GetDuration();
|
||||
if (extraToForget > 0) {
|
||||
RemoveLeading(extraToForget, 1);
|
||||
mChunks[0].mDuration += extraToForget;
|
||||
|
@ -179,14 +188,14 @@ public:
|
|||
mChunks.InsertElementAt(0)->SetNull(aDuration);
|
||||
mDuration += aDuration;
|
||||
}
|
||||
virtual void FlushAfter(TrackTicks aNewEnd)
|
||||
virtual void FlushAfter(StreamTime aNewEnd)
|
||||
{
|
||||
if (mChunks.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mChunks[0].IsNull()) {
|
||||
TrackTicks extraToKeep = aNewEnd - mChunks[0].GetDuration();
|
||||
StreamTime extraToKeep = aNewEnd - mChunks[0].GetDuration();
|
||||
if (extraToKeep < 0) {
|
||||
// reduce the size of the Null, get rid of everthing else
|
||||
mChunks[0].SetNull(aNewEnd);
|
||||
|
@ -202,7 +211,7 @@ public:
|
|||
}
|
||||
mDuration = aNewEnd;
|
||||
}
|
||||
virtual void InsertNullDataAtStart(TrackTicks aDuration)
|
||||
virtual void InsertNullDataAtStart(StreamTime aDuration)
|
||||
{
|
||||
if (aDuration <= 0) {
|
||||
return;
|
||||
|
@ -217,7 +226,7 @@ public:
|
|||
#endif
|
||||
mDuration += aDuration;
|
||||
}
|
||||
virtual void AppendNullData(TrackTicks aDuration)
|
||||
virtual void AppendNullData(StreamTime aDuration)
|
||||
{
|
||||
if (aDuration <= 0) {
|
||||
return;
|
||||
|
@ -234,7 +243,7 @@ public:
|
|||
if (GetType() != AUDIO) {
|
||||
MOZ_CRASH("Disabling unknown segment type");
|
||||
}
|
||||
TrackTicks duration = GetDuration();
|
||||
StreamTime duration = GetDuration();
|
||||
Clear();
|
||||
AppendNullData(duration);
|
||||
}
|
||||
|
@ -257,7 +266,7 @@ public:
|
|||
uint32_t mIndex;
|
||||
};
|
||||
|
||||
void RemoveLeading(TrackTicks aDuration)
|
||||
void RemoveLeading(StreamTime aDuration)
|
||||
{
|
||||
RemoveLeading(aDuration, 0);
|
||||
}
|
||||
|
@ -302,17 +311,17 @@ protected:
|
|||
}
|
||||
|
||||
void AppendSliceInternal(const MediaSegmentBase<C, Chunk>& aSource,
|
||||
TrackTicks aStart, TrackTicks aEnd)
|
||||
StreamTime aStart, StreamTime aEnd)
|
||||
{
|
||||
MOZ_ASSERT(aStart <= aEnd, "Endpoints inverted");
|
||||
NS_WARN_IF_FALSE(aStart >= 0 && aEnd <= aSource.mDuration, "Slice out of range");
|
||||
mDuration += aEnd - aStart;
|
||||
TrackTicks offset = 0;
|
||||
StreamTime offset = 0;
|
||||
for (uint32_t i = 0; i < aSource.mChunks.Length() && offset < aEnd; ++i) {
|
||||
const Chunk& c = aSource.mChunks[i];
|
||||
TrackTicks start = std::max(aStart, offset);
|
||||
TrackTicks nextOffset = offset + c.GetDuration();
|
||||
TrackTicks end = std::min(aEnd, nextOffset);
|
||||
StreamTime start = std::max(aStart, offset);
|
||||
StreamTime nextOffset = offset + c.GetDuration();
|
||||
StreamTime end = std::min(aEnd, nextOffset);
|
||||
if (start < end) {
|
||||
mChunks.AppendElement(c)->SliceTo(start - offset, end - offset);
|
||||
}
|
||||
|
@ -320,7 +329,7 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
Chunk* AppendChunk(TrackTicks aDuration)
|
||||
Chunk* AppendChunk(StreamTime aDuration)
|
||||
{
|
||||
MOZ_ASSERT(aDuration >= 0);
|
||||
Chunk* c = mChunks.AppendElement();
|
||||
|
@ -329,15 +338,15 @@ protected:
|
|||
return c;
|
||||
}
|
||||
|
||||
Chunk* FindChunkContaining(TrackTicks aOffset, TrackTicks* aStart = nullptr)
|
||||
Chunk* FindChunkContaining(StreamTime aOffset, StreamTime* aStart = nullptr)
|
||||
{
|
||||
if (aOffset < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
TrackTicks offset = 0;
|
||||
StreamTime offset = 0;
|
||||
for (uint32_t i = 0; i < mChunks.Length(); ++i) {
|
||||
Chunk& c = mChunks[i];
|
||||
TrackTicks nextOffset = offset + c.GetDuration();
|
||||
StreamTime nextOffset = offset + c.GetDuration();
|
||||
if (aOffset < nextOffset) {
|
||||
if (aStart) {
|
||||
*aStart = offset;
|
||||
|
@ -357,10 +366,10 @@ protected:
|
|||
return &mChunks[mChunks.Length() - 1];
|
||||
}
|
||||
|
||||
void RemoveLeading(TrackTicks aDuration, uint32_t aStartIndex)
|
||||
void RemoveLeading(StreamTime aDuration, uint32_t aStartIndex)
|
||||
{
|
||||
NS_ASSERTION(aDuration >= 0, "Can't remove negative duration");
|
||||
TrackTicks t = aDuration;
|
||||
StreamTime t = aDuration;
|
||||
uint32_t chunksToRemove = 0;
|
||||
for (uint32_t i = aStartIndex; i < mChunks.Length() && t > 0; ++i) {
|
||||
Chunk* c = &mChunks[i];
|
||||
|
@ -376,10 +385,10 @@ protected:
|
|||
mDuration -= aDuration - t;
|
||||
}
|
||||
|
||||
void RemoveTrailing(TrackTicks aKeep, uint32_t aStartIndex)
|
||||
void RemoveTrailing(StreamTime aKeep, uint32_t aStartIndex)
|
||||
{
|
||||
NS_ASSERTION(aKeep >= 0, "Can't keep negative duration");
|
||||
TrackTicks t = aKeep;
|
||||
StreamTime t = aKeep;
|
||||
uint32_t i;
|
||||
for (i = aStartIndex; i < mChunks.Length(); ++i) {
|
||||
Chunk* c = &mChunks[i];
|
||||
|
|
|
@ -195,7 +195,7 @@ MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream,
|
|||
aStream->ApplyTrackDisabling(data->mID, data->mData);
|
||||
for (uint32_t j = 0; j < aStream->mListeners.Length(); ++j) {
|
||||
MediaStreamListener* l = aStream->mListeners[j];
|
||||
TrackTicks offset = (data->mCommands & SourceMediaStream::TRACK_CREATE)
|
||||
StreamTime offset = (data->mCommands & SourceMediaStream::TRACK_CREATE)
|
||||
? data->mStart : aStream->mBuffer.FindTrack(data->mID)->GetSegment()->GetDuration();
|
||||
l->NotifyQueuedTrackChanges(this, data->mID,
|
||||
offset, data->mCommands, *data->mData);
|
||||
|
@ -950,19 +950,19 @@ MediaStreamGraphImpl::CreateOrDestroyAudioStreams(GraphTime aAudioOutputStartTim
|
|||
}
|
||||
}
|
||||
|
||||
TrackTicks
|
||||
StreamTime
|
||||
MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
||||
GraphTime aFrom, GraphTime aTo)
|
||||
{
|
||||
MOZ_ASSERT(mRealtime, "Should only attempt to play audio in realtime mode");
|
||||
|
||||
TrackTicks ticksWritten = 0;
|
||||
StreamTime ticksWritten = 0;
|
||||
// We compute the number of needed ticks by converting a difference of graph
|
||||
// time rather than by substracting two converted stream time to ensure that
|
||||
// the rounding between {Graph,Stream}Time and track ticks is not dependant
|
||||
// on the absolute value of the {Graph,Stream}Time, and so that number of
|
||||
// ticks to play is the same for each cycle.
|
||||
TrackTicks ticksNeeded = aTo - aFrom;
|
||||
StreamTime ticksNeeded = aTo - aFrom;
|
||||
|
||||
if (aStream->mAudioOutputStreams.IsEmpty()) {
|
||||
return 0;
|
||||
|
@ -983,7 +983,7 @@ MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
|||
// because of the rounding issue. We track that to ensure we don't skip a
|
||||
// sample. One sample may be played twice, but this should not happen
|
||||
// again during an unblocked sequence of track samples.
|
||||
TrackTicks offset = GraphTimeToStreamTime(aStream, aFrom);
|
||||
StreamTime offset = GraphTimeToStreamTime(aStream, aFrom);
|
||||
if (audioOutput.mLastTickWritten &&
|
||||
audioOutput.mLastTickWritten != offset) {
|
||||
// If there is a global underrun of the MSG, this property won't hold, and
|
||||
|
@ -1006,7 +1006,7 @@ MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
|||
|
||||
// Check how many ticks of sound we can provide if we are blocked some
|
||||
// time in the middle of this cycle.
|
||||
TrackTicks toWrite = 0;
|
||||
StreamTime toWrite = 0;
|
||||
if (end >= aTo) {
|
||||
toWrite = ticksNeeded;
|
||||
} else {
|
||||
|
@ -1021,8 +1021,8 @@ MediaStreamGraphImpl::PlayAudio(MediaStream* aStream,
|
|||
aStream, toWrite, MediaTimeToSeconds(t), MediaTimeToSeconds(end),
|
||||
offset, offset + toWrite));
|
||||
} else {
|
||||
TrackTicks endTicksNeeded = offset + toWrite;
|
||||
TrackTicks endTicksAvailable = audio->GetDuration();
|
||||
StreamTime endTicksNeeded = offset + toWrite;
|
||||
StreamTime endTicksAvailable = audio->GetDuration();
|
||||
STREAM_LOG(PR_LOG_DEBUG+1, ("MediaStream %p writing %ld samples for %f to %f (samples %ld to %ld)\n",
|
||||
aStream, toWrite, MediaTimeToSeconds(t), MediaTimeToSeconds(end),
|
||||
offset, endTicksNeeded));
|
||||
|
@ -1093,12 +1093,12 @@ MediaStreamGraphImpl::PlayVideo(MediaStream* aStream)
|
|||
MOZ_ASSERT(framePosition >= aStream->mBufferStartTime, "frame position before buffer?");
|
||||
StreamTime frameBufferTime = GraphTimeToStreamTime(aStream, framePosition);
|
||||
|
||||
TrackTicks start;
|
||||
StreamTime start;
|
||||
const VideoFrame* frame = nullptr;
|
||||
for (StreamBuffer::TrackIter tracks(aStream->GetStreamBuffer(), MediaSegment::VIDEO);
|
||||
!tracks.IsEnded(); tracks.Next()) {
|
||||
VideoSegment* segment = tracks->Get<VideoSegment>();
|
||||
TrackTicks thisStart;
|
||||
StreamTime thisStart;
|
||||
const VideoFrame* thisFrame =
|
||||
segment->GetFrameAt(frameBufferTime, &thisStart);
|
||||
if (thisFrame && thisFrame->GetImage()) {
|
||||
|
@ -1196,10 +1196,10 @@ MediaStreamGraphImpl::PrepareUpdatesToMainThreadState(bool aFinalUpdate)
|
|||
GraphTime
|
||||
MediaStreamGraphImpl::RoundUpToNextAudioBlock(GraphTime aTime)
|
||||
{
|
||||
TrackTicks ticks = aTime;
|
||||
StreamTime ticks = aTime;
|
||||
uint64_t block = ticks >> WEBAUDIO_BLOCK_SIZE_BITS;
|
||||
uint64_t nextBlock = block + 1;
|
||||
TrackTicks nextTicks = nextBlock << WEBAUDIO_BLOCK_SIZE_BITS;
|
||||
StreamTime nextTicks = nextBlock << WEBAUDIO_BLOCK_SIZE_BITS;
|
||||
return nextTicks;
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ MediaStreamGraphImpl::Process(GraphTime aFrom, GraphTime aTo)
|
|||
bool doneAllProducing = false;
|
||||
// This is the number of frame that are written to the AudioStreams, for
|
||||
// this cycle.
|
||||
TrackTicks ticksPlayed = 0;
|
||||
StreamTime ticksPlayed = 0;
|
||||
|
||||
mMixer.StartMixing();
|
||||
|
||||
|
@ -1336,7 +1336,7 @@ MediaStreamGraphImpl::Process(GraphTime aFrom, GraphTime aTo)
|
|||
if (mRealtime) {
|
||||
CreateOrDestroyAudioStreams(aFrom, stream);
|
||||
if (CurrentDriver()->AsAudioCallbackDriver()) {
|
||||
TrackTicks ticksPlayedForThisStream = PlayAudio(stream, aFrom, aTo);
|
||||
StreamTime ticksPlayedForThisStream = PlayAudio(stream, aFrom, aTo);
|
||||
if (!ticksPlayed) {
|
||||
ticksPlayed = ticksPlayedForThisStream;
|
||||
} else {
|
||||
|
@ -2270,7 +2270,7 @@ SourceMediaStream::SetPullEnabled(bool aEnabled)
|
|||
}
|
||||
|
||||
void
|
||||
SourceMediaStream::AddTrackInternal(TrackID aID, TrackRate aRate, TrackTicks aStart,
|
||||
SourceMediaStream::AddTrackInternal(TrackID aID, TrackRate aRate, StreamTime aStart,
|
||||
MediaSegment* aSegment)
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
@ -2361,7 +2361,7 @@ SourceMediaStream::NotifyDirectConsumers(TrackData *aTrack,
|
|||
|
||||
for (uint32_t j = 0; j < mDirectListeners.Length(); ++j) {
|
||||
MediaStreamDirectListener* l = mDirectListeners[j];
|
||||
TrackTicks offset = 0; // FIX! need a separate TrackTicks.... or the end of the internal buffer
|
||||
StreamTime offset = 0; // FIX! need a separate StreamTime.... or the end of the internal buffer
|
||||
l->NotifyRealtimeData(static_cast<MediaStreamGraph*>(GraphImpl()), aTrack->mID,
|
||||
offset, aTrack->mCommands, *aSegment);
|
||||
}
|
||||
|
@ -2505,7 +2505,7 @@ SourceMediaStream::EndAllTrackAndFinish()
|
|||
// we will call NotifyEvent() to let GetUserMedia know
|
||||
}
|
||||
|
||||
TrackTicks
|
||||
StreamTime
|
||||
SourceMediaStream::GetBufferedTicks(TrackID aID)
|
||||
{
|
||||
StreamBuffer::Track* track = mBuffer.FindTrack(aID);
|
||||
|
|
|
@ -174,7 +174,7 @@ public:
|
|||
* at aTrackOffset (relative to the start of the stream).
|
||||
*/
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) {}
|
||||
};
|
||||
|
@ -197,7 +197,7 @@ public:
|
|||
* Note that NotifyQueuedTrackChanges() calls will also still occur.
|
||||
*/
|
||||
virtual void NotifyRealtimeData(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aMedia) {}
|
||||
};
|
||||
|
@ -487,10 +487,12 @@ public:
|
|||
|
||||
double StreamTimeToSeconds(StreamTime aTime)
|
||||
{
|
||||
return TrackTicksToSeconds(mBuffer.GraphRate(), aTime);
|
||||
NS_ASSERTION(0 <= aTime && aTime <= STREAM_TIME_MAX, "Bad time");
|
||||
return static_cast<double>(aTime)/mBuffer.GraphRate();
|
||||
}
|
||||
int64_t StreamTimeToMicroseconds(StreamTime aTime)
|
||||
{
|
||||
NS_ASSERTION(0 <= aTime && aTime <= STREAM_TIME_MAX, "Bad time");
|
||||
return (aTime*1000000)/mBuffer.GraphRate();
|
||||
}
|
||||
StreamTime MicrosecondsToStreamTimeRoundDown(int64_t aMicroseconds) {
|
||||
|
@ -618,7 +620,7 @@ protected:
|
|||
// blocking.
|
||||
MediaTime mBlockedAudioTime;
|
||||
// Last tick written to the audio output.
|
||||
TrackTicks mLastTickWritten;
|
||||
StreamTime mLastTickWritten;
|
||||
TrackID mTrackID;
|
||||
};
|
||||
nsTArray<AudioOutputStream> mAudioOutputStreams;
|
||||
|
@ -722,7 +724,7 @@ public:
|
|||
* AdvanceKnownTracksTime). Takes ownership of aSegment. aSegment should
|
||||
* contain data starting after aStart.
|
||||
*/
|
||||
void AddTrack(TrackID aID, TrackTicks aStart, MediaSegment* aSegment)
|
||||
void AddTrack(TrackID aID, StreamTime aStart, MediaSegment* aSegment)
|
||||
{
|
||||
AddTrackInternal(aID, GraphRate(), aStart, aSegment);
|
||||
}
|
||||
|
@ -730,7 +732,7 @@ public:
|
|||
/**
|
||||
* Like AddTrack, but resamples audio from aRate to the graph rate.
|
||||
*/
|
||||
void AddAudioTrack(TrackID aID, TrackRate aRate, TrackTicks aStart,
|
||||
void AddAudioTrack(TrackID aID, TrackRate aRate, StreamTime aStart,
|
||||
AudioSegment* aSegment)
|
||||
{
|
||||
AddTrackInternal(aID, aRate, aStart, aSegment);
|
||||
|
@ -800,7 +802,7 @@ public:
|
|||
* any "extra" buffering, but NotifyQueued TrackChanges() on a TrackUnion
|
||||
* will be buffered.
|
||||
*/
|
||||
TrackTicks GetBufferedTicks(TrackID aID);
|
||||
StreamTime GetBufferedTicks(TrackID aID);
|
||||
|
||||
void RegisterForAudioMixing();
|
||||
|
||||
|
@ -836,7 +838,7 @@ protected:
|
|||
#ifdef DEBUG
|
||||
int mResamplerChannelCount;
|
||||
#endif
|
||||
TrackTicks mStart;
|
||||
StreamTime mStart;
|
||||
// Each time the track updates are flushed to the media graph thread,
|
||||
// this is cleared.
|
||||
uint32_t mCommands;
|
||||
|
@ -852,7 +854,7 @@ protected:
|
|||
void ResampleAudioToGraphSampleRate(TrackData* aTrackData, MediaSegment* aSegment);
|
||||
|
||||
void AddTrackInternal(TrackID aID, TrackRate aRate,
|
||||
TrackTicks aStart, MediaSegment* aSegment);
|
||||
StreamTime aStart, MediaSegment* aSegment);
|
||||
|
||||
TrackData* FindDataForTrack(TrackID aID)
|
||||
{
|
||||
|
|
|
@ -350,7 +350,7 @@ public:
|
|||
* Queue audio (mix of stream audio and silence for blocked intervals)
|
||||
* to the audio output stream. Returns the number of frames played.
|
||||
*/
|
||||
TrackTicks PlayAudio(MediaStream* aStream, GraphTime aFrom, GraphTime aTo);
|
||||
StreamTime PlayAudio(MediaStream* aStream, GraphTime aFrom, GraphTime aTo);
|
||||
/**
|
||||
* Set the correct current video frame for stream aStream.
|
||||
*/
|
||||
|
@ -401,11 +401,14 @@ public:
|
|||
|
||||
double MediaTimeToSeconds(GraphTime aTime)
|
||||
{
|
||||
return TrackTicksToSeconds(GraphRate(), aTime);
|
||||
NS_ASSERTION(0 <= aTime && aTime <= STREAM_TIME_MAX, "Bad time");
|
||||
return static_cast<double>(aTime)/GraphRate();
|
||||
}
|
||||
GraphTime SecondsToMediaTime(double aS)
|
||||
{
|
||||
return SecondsToTicksRoundDown(GraphRate(), aS);
|
||||
NS_ASSERTION(0 <= aS && aS <= TRACK_TICKS_MAX/TRACK_RATE_MAX,
|
||||
"Bad seconds");
|
||||
return GraphRate() * aS;
|
||||
}
|
||||
GraphTime MillisecondsToMediaTime(int32_t aMS)
|
||||
{
|
||||
|
|
|
@ -96,7 +96,7 @@ StreamBuffer::ForgetUpTo(StreamTime aTime)
|
|||
--i;
|
||||
continue;
|
||||
}
|
||||
TrackTicks forgetTo = std::min(track->GetEnd() - 1, aTime);
|
||||
StreamTime forgetTo = std::min(track->GetEnd() - 1, aTime);
|
||||
track->ForgetUpTo(forgetTo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
/**
|
||||
* Media time relative to the start of a StreamBuffer.
|
||||
*/
|
||||
typedef MediaTime StreamTime;
|
||||
const StreamTime STREAM_TIME_MAX = MEDIA_TIME_MAX;
|
||||
|
||||
/**
|
||||
* Unique ID for track within a StreamBuffer. Tracks from different
|
||||
* StreamBuffers may have the same ID; this matters when appending StreamBuffers,
|
||||
|
@ -44,21 +38,6 @@ inline TrackTicks RateConvertTicksRoundUp(TrackRate aOutRate,
|
|||
return (aTicks * aOutRate + aInRate - 1) / aInRate;
|
||||
}
|
||||
|
||||
inline TrackTicks SecondsToTicksRoundDown(TrackRate aRate, double aSeconds)
|
||||
{
|
||||
NS_ASSERTION(0 < aRate && aRate <= TRACK_RATE_MAX, "Bad rate");
|
||||
NS_ASSERTION(0 <= aSeconds && aSeconds <= TRACK_TICKS_MAX/TRACK_RATE_MAX,
|
||||
"Bad seconds");
|
||||
return aSeconds * aRate;
|
||||
}
|
||||
|
||||
inline double TrackTicksToSeconds(TrackRate aRate, TrackTicks aTicks)
|
||||
{
|
||||
NS_ASSERTION(0 < aRate && aRate <= TRACK_RATE_MAX, "Bad rate");
|
||||
NS_ASSERTION(0 <= aTicks && aTicks <= TRACK_TICKS_MAX, "Bad ticks");
|
||||
return static_cast<double>(aTicks)/aRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* This object contains the decoded data for a stream's tracks.
|
||||
* A StreamBuffer can be appended to. Logically a StreamBuffer only gets longer,
|
||||
|
@ -81,11 +60,11 @@ public:
|
|||
* the same track across StreamBuffers. A StreamBuffer should never have
|
||||
* two tracks with the same ID (even if they don't overlap in time).
|
||||
* TODO Tracks can also be enabled and disabled over time.
|
||||
* TODO Add TimeVarying<TrackTicks,bool> mEnabled.
|
||||
* TODO Add TimeVarying<StreamTime,bool> mEnabled.
|
||||
* Takes ownership of aSegment.
|
||||
*/
|
||||
class Track {
|
||||
Track(TrackID aID, TrackTicks aStart, MediaSegment* aSegment, TrackRate aGraphRate)
|
||||
Track(TrackID aID, StreamTime aStart, MediaSegment* aSegment, TrackRate aGraphRate)
|
||||
: mStart(aStart),
|
||||
mSegment(aSegment),
|
||||
mGraphRate(aGraphRate),
|
||||
|
@ -112,8 +91,8 @@ public:
|
|||
MediaSegment* GetSegment() const { return mSegment; }
|
||||
TrackID GetID() const { return mID; }
|
||||
bool IsEnded() const { return mEnded; }
|
||||
TrackTicks GetStart() const { return mStart; }
|
||||
TrackTicks GetEnd() const { return mSegment->GetDuration(); }
|
||||
StreamTime GetStart() const { return mStart; }
|
||||
StreamTime GetEnd() const { return mSegment->GetDuration(); }
|
||||
MediaSegment::Type GetType() const { return mSegment->GetType(); }
|
||||
|
||||
void SetEnded() { mEnded = true; }
|
||||
|
@ -131,11 +110,11 @@ public:
|
|||
{
|
||||
return mSegment.forget();
|
||||
}
|
||||
void ForgetUpTo(TrackTicks aTime)
|
||||
void ForgetUpTo(StreamTime aTime)
|
||||
{
|
||||
mSegment->ForgetUpTo(aTime);
|
||||
}
|
||||
void FlushAfter(TrackTicks aNewEnd)
|
||||
void FlushAfter(StreamTime aNewEnd)
|
||||
{
|
||||
// Forget everything after a given endpoint
|
||||
// a specified amount
|
||||
|
@ -155,7 +134,7 @@ public:
|
|||
friend class StreamBuffer;
|
||||
|
||||
// Start offset is in ticks at rate mRate
|
||||
TrackTicks mStart;
|
||||
StreamTime mStart;
|
||||
// The segment data starts at the start of the owning StreamBuffer, i.e.,
|
||||
// there's mStart silence/no video at the beginning.
|
||||
nsAutoPtr<MediaSegment> mSegment;
|
||||
|
@ -223,7 +202,7 @@ public:
|
|||
* holding a Track reference.
|
||||
* aSegment must have aStart worth of null data.
|
||||
*/
|
||||
Track& AddTrack(TrackID aID, TrackTicks aStart, MediaSegment* aSegment)
|
||||
Track& AddTrack(TrackID aID, StreamTime aStart, MediaSegment* aSegment)
|
||||
{
|
||||
NS_ASSERTION(!FindTrack(aID), "Track with this ID already exists");
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
|
|||
// 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 = GraphTimeToStreamTime(aFrom);
|
||||
StreamTime outputStart = GraphTimeToStreamTime(aFrom);
|
||||
|
||||
nsAutoPtr<MediaSegment> segment;
|
||||
segment = aTrack->GetSegment()->CreateEmptyClone();
|
||||
|
@ -226,7 +226,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
|
|||
return;
|
||||
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
|
||||
MediaStreamListener* l = mListeners[j];
|
||||
TrackTicks offset = outputTrack->GetSegment()->GetDuration();
|
||||
StreamTime offset = outputTrack->GetSegment()->GetDuration();
|
||||
nsAutoPtr<MediaSegment> segment;
|
||||
segment = outputTrack->GetSegment()->CreateEmptyClone();
|
||||
l->NotifyQueuedTrackChanges(Graph(), outputTrack->GetID(), offset,
|
||||
|
@ -253,7 +253,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
|
|||
MediaInputPort::InputInterval interval = map->mInputPort->GetNextInputInterval(t);
|
||||
interval.mEnd = std::min(interval.mEnd, aTo);
|
||||
StreamTime inputEnd = source->GraphTimeToStreamTime(interval.mEnd);
|
||||
TrackTicks inputTrackEndPoint = TRACK_TICKS_MAX;
|
||||
StreamTime inputTrackEndPoint = STREAM_TIME_MAX;
|
||||
|
||||
if (aInputTrack->IsEnded() &&
|
||||
aInputTrack->GetEnd() <= inputEnd) {
|
||||
|
@ -264,7 +264,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) :
|
|||
if (interval.mStart >= interval.mEnd) {
|
||||
break;
|
||||
}
|
||||
TrackTicks ticks = interval.mEnd - interval.mStart;
|
||||
StreamTime ticks = interval.mEnd - interval.mStart;
|
||||
next = interval.mEnd;
|
||||
|
||||
StreamTime outputStart = outputTrack->GetEnd();
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
struct TrackMapEntry {
|
||||
// mEndOfConsumedInputTicks is the end of the input ticks that we've consumed.
|
||||
// 0 if we haven't consumed any yet.
|
||||
TrackTicks mEndOfConsumedInputTicks;
|
||||
StreamTime 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.
|
||||
|
|
|
@ -92,7 +92,7 @@ VideoChunk::~VideoChunk()
|
|||
|
||||
void
|
||||
VideoSegment::AppendFrame(already_AddRefed<Image>&& aImage,
|
||||
TrackTicks aDuration,
|
||||
StreamTime aDuration,
|
||||
const IntSize& aIntrinsicSize,
|
||||
bool aForceBlack)
|
||||
{
|
||||
|
|
|
@ -59,19 +59,19 @@ protected:
|
|||
struct VideoChunk {
|
||||
VideoChunk();
|
||||
~VideoChunk();
|
||||
void SliceTo(TrackTicks aStart, TrackTicks aEnd)
|
||||
void SliceTo(StreamTime aStart, StreamTime aEnd)
|
||||
{
|
||||
NS_ASSERTION(aStart >= 0 && aStart < aEnd && aEnd <= mDuration,
|
||||
"Slice out of bounds");
|
||||
mDuration = aEnd - aStart;
|
||||
}
|
||||
TrackTicks GetDuration() const { return mDuration; }
|
||||
StreamTime GetDuration() const { return mDuration; }
|
||||
bool CanCombineWithFollowing(const VideoChunk& aOther) const
|
||||
{
|
||||
return aOther.mFrame == mFrame;
|
||||
}
|
||||
bool IsNull() const { return !mFrame.GetImage(); }
|
||||
void SetNull(TrackTicks aDuration)
|
||||
void SetNull(StreamTime aDuration)
|
||||
{
|
||||
mDuration = aDuration;
|
||||
mFrame.SetNull();
|
||||
|
@ -86,7 +86,7 @@ struct VideoChunk {
|
|||
return 0;
|
||||
}
|
||||
|
||||
TrackTicks mDuration;
|
||||
StreamTime mDuration;
|
||||
VideoFrame mFrame;
|
||||
mozilla::TimeStamp mTimeStamp;
|
||||
};
|
||||
|
@ -100,10 +100,10 @@ public:
|
|||
~VideoSegment();
|
||||
|
||||
void AppendFrame(already_AddRefed<Image>&& aImage,
|
||||
TrackTicks aDuration,
|
||||
StreamTime aDuration,
|
||||
const IntSize& aIntrinsicSize,
|
||||
bool aForceBlack = false);
|
||||
const VideoFrame* GetFrameAt(TrackTicks aOffset, TrackTicks* aStart = nullptr)
|
||||
const VideoFrame* GetFrameAt(StreamTime aOffset, StreamTime* aStart = nullptr)
|
||||
{
|
||||
VideoChunk* c = FindChunkContaining(aOffset, aStart);
|
||||
if (!c) {
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
}
|
||||
return &c->mFrame;
|
||||
}
|
||||
const VideoFrame* GetLastFrame(TrackTicks* aStart = nullptr)
|
||||
const VideoFrame* GetLastFrame(StreamTime* aStart = nullptr)
|
||||
{
|
||||
VideoChunk* c = GetLastChunk();
|
||||
if (!c) {
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace mozilla {
|
|||
void
|
||||
MediaEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ public :
|
|||
* track data in form of MediaSegment.
|
||||
*/
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ TrackEncoder::TrackEncoder()
|
|||
void
|
||||
AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ AudioTrackEncoder::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) cons
|
|||
void
|
||||
VideoTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
* change from MediaStreamGraph. Called on the MediaStreamGraph thread.
|
||||
*/
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) = 0;
|
||||
|
||||
|
@ -146,7 +146,7 @@ public:
|
|||
{}
|
||||
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -239,7 +239,7 @@ public:
|
|||
* change from MediaStreamGraph. Called on the MediaStreamGraph thread.
|
||||
*/
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE;
|
||||
/**
|
||||
|
@ -297,10 +297,10 @@ protected:
|
|||
TrackRate mTrackRate;
|
||||
|
||||
/**
|
||||
* The total duration of frames in encoded video in TrackTicks, kept track of
|
||||
* The total duration of frames in encoded video in StreamTime, kept track of
|
||||
* in subclasses.
|
||||
*/
|
||||
TrackTicks mTotalFrameDuration;
|
||||
StreamTime mTotalFrameDuration;
|
||||
|
||||
/**
|
||||
* The last unique frame we've sent to track encoder, kept track of in
|
||||
|
|
|
@ -363,7 +363,7 @@ nsresult VP8TrackEncoder::PrepareRawFrame(VideoChunk &aChunk)
|
|||
*/
|
||||
VP8TrackEncoder::EncodeOperation
|
||||
VP8TrackEncoder::GetNextEncodeOperation(TimeDuration aTimeElapsed,
|
||||
TrackTicks aProcessedDuration)
|
||||
StreamTime aProcessedDuration)
|
||||
{
|
||||
int64_t durationInUsec =
|
||||
FramesToUsecs(aProcessedDuration + mEncodedFrameDuration,
|
||||
|
@ -381,20 +381,20 @@ VP8TrackEncoder::GetNextEncodeOperation(TimeDuration aTimeElapsed,
|
|||
}
|
||||
}
|
||||
|
||||
TrackTicks
|
||||
VP8TrackEncoder::CalculateRemainingTicks(TrackTicks aDurationCopied,
|
||||
TrackTicks aEncodedDuration)
|
||||
StreamTime
|
||||
VP8TrackEncoder::CalculateRemainingTicks(StreamTime aDurationCopied,
|
||||
StreamTime aEncodedDuration)
|
||||
{
|
||||
return mRemainingTicks + aEncodedDuration - aDurationCopied;
|
||||
}
|
||||
|
||||
// Try to extend the encodedDuration as long as possible if the target frame
|
||||
// has a long duration.
|
||||
TrackTicks
|
||||
VP8TrackEncoder::CalculateEncodedDuration(TrackTicks aDurationCopied)
|
||||
StreamTime
|
||||
VP8TrackEncoder::CalculateEncodedDuration(StreamTime aDurationCopied)
|
||||
{
|
||||
TrackTicks temp64 = aDurationCopied;
|
||||
TrackTicks encodedDuration = mEncodedFrameDuration;
|
||||
StreamTime temp64 = aDurationCopied;
|
||||
StreamTime encodedDuration = mEncodedFrameDuration;
|
||||
temp64 -= mRemainingTicks;
|
||||
while (temp64 > mEncodedFrameDuration) {
|
||||
temp64 -= mEncodedFrameDuration;
|
||||
|
@ -470,8 +470,8 @@ VP8TrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
|||
}
|
||||
|
||||
VideoSegment::ChunkIterator iter(mSourceSegment);
|
||||
TrackTicks durationCopied = 0;
|
||||
TrackTicks totalProcessedDuration = 0;
|
||||
StreamTime durationCopied = 0;
|
||||
StreamTime totalProcessedDuration = 0;
|
||||
TimeStamp timebase = TimeStamp::Now();
|
||||
EncodeOperation nextEncodeOperation = ENCODE_NORMAL_FRAME;
|
||||
|
||||
|
@ -486,7 +486,7 @@ VP8TrackEncoder::GetEncodedTrack(EncodedFrameContainer& aData)
|
|||
if (durationCopied >= mRemainingTicks) {
|
||||
VP8LOG("nextEncodeOperation is %d\n",nextEncodeOperation);
|
||||
// Calculate encodedDuration for this target frame.
|
||||
TrackTicks encodedDuration = CalculateEncodedDuration(durationCopied);
|
||||
StreamTime encodedDuration = CalculateEncodedDuration(durationCopied);
|
||||
|
||||
// Encode frame.
|
||||
if (nextEncodeOperation != SKIP_FRAME) {
|
||||
|
|
|
@ -43,15 +43,15 @@ protected:
|
|||
|
||||
private:
|
||||
// Calculate the target frame's encoded duration.
|
||||
TrackTicks CalculateEncodedDuration(TrackTicks aDurationCopied);
|
||||
StreamTime CalculateEncodedDuration(StreamTime aDurationCopied);
|
||||
|
||||
// Calculate the mRemainingTicks for next target frame.
|
||||
TrackTicks CalculateRemainingTicks(TrackTicks aDurationCopied,
|
||||
TrackTicks aEncodedDuration);
|
||||
StreamTime CalculateRemainingTicks(StreamTime aDurationCopied,
|
||||
StreamTime aEncodedDuration);
|
||||
|
||||
// Get the EncodeOperation for next target frame.
|
||||
EncodeOperation GetNextEncodeOperation(TimeDuration aTimeElapsed,
|
||||
TrackTicks aProcessedDuration);
|
||||
StreamTime aProcessedDuration);
|
||||
|
||||
// Get the encoded data from encoder to aData.
|
||||
nsresult GetEncodedPartitions(EncodedFrameContainer& aData);
|
||||
|
@ -62,11 +62,11 @@ private:
|
|||
// Output frame rate.
|
||||
uint32_t mEncodedFrameRate;
|
||||
// Duration for the output frame, reciprocal to mEncodedFrameRate.
|
||||
TrackTicks mEncodedFrameDuration;
|
||||
StreamTime mEncodedFrameDuration;
|
||||
// Encoded timestamp.
|
||||
TrackTicks mEncodedTimestamp;
|
||||
StreamTime mEncodedTimestamp;
|
||||
// Duration to the next encode frame.
|
||||
TrackTicks mRemainingTicks;
|
||||
StreamTime mRemainingTicks;
|
||||
|
||||
// Muted frame, we only create it once.
|
||||
nsRefPtr<layers::Image> mMuteFrame;
|
||||
|
|
|
@ -19,7 +19,7 @@ TEST(VideoSegment, TestAppendFrameForceBlack)
|
|||
|
||||
VideoSegment segment;
|
||||
segment.AppendFrame(testImage.forget(),
|
||||
mozilla::TrackTicks(90000),
|
||||
mozilla::StreamTime(90000),
|
||||
mozilla::gfx::IntSize(640, 480),
|
||||
true);
|
||||
|
||||
|
@ -37,7 +37,7 @@ TEST(VideoSegment, TestAppendFrameNotForceBlack)
|
|||
|
||||
VideoSegment segment;
|
||||
segment.AppendFrame(testImage.forget(),
|
||||
mozilla::TrackTicks(90000),
|
||||
mozilla::StreamTime(90000),
|
||||
mozilla::gfx::IntSize(640, 480));
|
||||
|
||||
VideoSegment::ChunkIterator iter(segment);
|
||||
|
|
|
@ -268,7 +268,7 @@ TEST(VP8VideoTrackEncoder, FrameEncode)
|
|||
for (nsTArray<nsRefPtr<Image>>::size_type i = 0; i < images.Length(); i++)
|
||||
{
|
||||
nsRefPtr<Image> image = images[i];
|
||||
segment.AppendFrame(image.forget(), mozilla::TrackTicks(90000), generator.GetSize());
|
||||
segment.AppendFrame(image.forget(), mozilla::StreamTime(90000), generator.GetSize());
|
||||
}
|
||||
|
||||
// track change notification.
|
||||
|
|
|
@ -84,7 +84,7 @@ CaptureTask::PrincipalChanged(DOMMediaStream* aMediaStream)
|
|||
|
||||
void
|
||||
CaptureTask::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ class CaptureTask : public MediaStreamListener,
|
|||
public:
|
||||
// MediaStreamListener methods.
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
AudioDestinationNode* aDestination) :
|
||||
AudioNodeEngine(aNode),
|
||||
mStart(0.0), mBeginProcessing(0),
|
||||
mStop(TRACK_TICKS_MAX),
|
||||
mStop(STREAM_TIME_MAX),
|
||||
mResampler(nullptr), mRemainingResamplerTail(0),
|
||||
mBufferEnd(0),
|
||||
mLoopStart(0), mLoopEnd(0),
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
NS_ERROR("Bad AudioBufferSourceNodeEngine TimelineParameter");
|
||||
}
|
||||
}
|
||||
virtual void SetStreamTimeParameter(uint32_t aIndex, TrackTicks aParam)
|
||||
virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam)
|
||||
{
|
||||
switch (aIndex) {
|
||||
case AudioBufferSourceNode::STOP: mStop = aParam; break;
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
|
||||
bool BegunResampling()
|
||||
{
|
||||
return mBeginProcessing == -TRACK_TICKS_MAX;
|
||||
return mBeginProcessing == -STREAM_TIME_MAX;
|
||||
}
|
||||
|
||||
void UpdateResampler(int32_t aOutRate, uint32_t aChannels)
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
AudioChunk* aOutput,
|
||||
uint32_t aChannels,
|
||||
uint32_t* aOffsetWithinBlock,
|
||||
TrackTicks* aCurrentPosition,
|
||||
StreamTime* aCurrentPosition,
|
||||
int32_t aBufferMax) {
|
||||
// TODO: adjust for mStop (see bug 913854 comment 9).
|
||||
uint32_t availableInOutputBuffer =
|
||||
|
@ -268,7 +268,7 @@ public:
|
|||
}
|
||||
speex_resampler_set_skip_frac_num(resampler, skipFracNum);
|
||||
|
||||
mBeginProcessing = -TRACK_TICKS_MAX;
|
||||
mBeginProcessing = -STREAM_TIME_MAX;
|
||||
}
|
||||
inputLimit = std::min(inputLimit, availableInInputBuffer);
|
||||
|
||||
|
@ -334,12 +334,12 @@ public:
|
|||
void FillWithZeroes(AudioChunk* aOutput,
|
||||
uint32_t aChannels,
|
||||
uint32_t* aOffsetWithinBlock,
|
||||
TrackTicks* aCurrentPosition,
|
||||
TrackTicks aMaxPos)
|
||||
StreamTime* aCurrentPosition,
|
||||
StreamTime aMaxPos)
|
||||
{
|
||||
MOZ_ASSERT(*aCurrentPosition < aMaxPos);
|
||||
uint32_t numFrames =
|
||||
std::min<TrackTicks>(WEBAUDIO_BLOCK_SIZE - *aOffsetWithinBlock,
|
||||
std::min<StreamTime>(WEBAUDIO_BLOCK_SIZE - *aOffsetWithinBlock,
|
||||
aMaxPos - *aCurrentPosition);
|
||||
if (numFrames == WEBAUDIO_BLOCK_SIZE) {
|
||||
aOutput->SetNull(numFrames);
|
||||
|
@ -366,12 +366,12 @@ public:
|
|||
AudioChunk* aOutput,
|
||||
uint32_t aChannels,
|
||||
uint32_t* aOffsetWithinBlock,
|
||||
TrackTicks* aCurrentPosition,
|
||||
StreamTime* aCurrentPosition,
|
||||
int32_t aBufferMax)
|
||||
{
|
||||
MOZ_ASSERT(*aCurrentPosition < mStop);
|
||||
uint32_t numFrames =
|
||||
std::min(std::min<TrackTicks>(WEBAUDIO_BLOCK_SIZE - *aOffsetWithinBlock,
|
||||
std::min(std::min<StreamTime>(WEBAUDIO_BLOCK_SIZE - *aOffsetWithinBlock,
|
||||
aBufferMax - mBufferPosition),
|
||||
mStop - *aCurrentPosition);
|
||||
if (numFrames == WEBAUDIO_BLOCK_SIZE && !mResampler) {
|
||||
|
@ -445,11 +445,11 @@ public:
|
|||
UpdateSampleRateIfNeeded(channels);
|
||||
|
||||
uint32_t written = 0;
|
||||
TrackTicks streamPosition = aStream->GetCurrentPosition();
|
||||
StreamTime streamPosition = aStream->GetCurrentPosition();
|
||||
while (written < WEBAUDIO_BLOCK_SIZE) {
|
||||
if (mStop != TRACK_TICKS_MAX &&
|
||||
if (mStop != STREAM_TIME_MAX &&
|
||||
streamPosition >= mStop) {
|
||||
FillWithZeroes(aOutput, channels, &written, &streamPosition, TRACK_TICKS_MAX);
|
||||
FillWithZeroes(aOutput, channels, &written, &streamPosition, STREAM_TIME_MAX);
|
||||
continue;
|
||||
}
|
||||
if (streamPosition < mBeginProcessing) {
|
||||
|
@ -469,7 +469,7 @@ public:
|
|||
if (mBufferPosition < mBufferEnd || mRemainingResamplerTail) {
|
||||
CopyFromBuffer(aStream, aOutput, channels, &written, &streamPosition, mBufferEnd);
|
||||
} else {
|
||||
FillWithZeroes(aOutput, channels, &written, &streamPosition, TRACK_TICKS_MAX);
|
||||
FillWithZeroes(aOutput, channels, &written, &streamPosition, STREAM_TIME_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -510,10 +510,10 @@ public:
|
|||
double mStart; // including the fractional position between ticks
|
||||
// Low pass filter effects from the resampler mean that samples before the
|
||||
// start time are influenced by resampling the buffer. mBeginProcessing
|
||||
// includes the extent of this filter. The special value of -TRACK_TICKS_MAX
|
||||
// includes the extent of this filter. The special value of -STREAM_TIME_MAX
|
||||
// indicates that the resampler has begun processing.
|
||||
TrackTicks mBeginProcessing;
|
||||
TrackTicks mStop;
|
||||
StreamTime mBeginProcessing;
|
||||
StreamTime mStop;
|
||||
nsRefPtr<ThreadSharedFloatArrayBufferList> mBuffer;
|
||||
SpeexResamplerState* mResampler;
|
||||
// mRemainingResamplerTail, like mBufferPosition, and
|
||||
|
|
|
@ -241,7 +241,7 @@ public:
|
|||
|
||||
virtual dom::DelayNodeEngine* AsDelayNodeEngine() { return nullptr; }
|
||||
|
||||
virtual void SetStreamTimeParameter(uint32_t aIndex, TrackTicks aParam)
|
||||
virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam)
|
||||
{
|
||||
NS_ERROR("Invalid SetStreamTimeParameter index");
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ AudioNodeExternalInputStream::ProcessInput(GraphTime aFrom, GraphTime aTo,
|
|||
|
||||
StreamTime outputStart = GraphTimeToStreamTime(interval.mStart);
|
||||
StreamTime outputEnd = GraphTimeToStreamTime(interval.mEnd);
|
||||
TrackTicks ticks = outputEnd - outputStart;
|
||||
StreamTime ticks = outputEnd - outputStart;
|
||||
|
||||
if (interval.mInputIsBlocked) {
|
||||
segment.AppendNullData(ticks);
|
||||
|
|
|
@ -98,7 +98,7 @@ void
|
|||
AudioNodeStream::SetStreamTimeParameterImpl(uint32_t aIndex, MediaStream* aRelativeToStream,
|
||||
double aStreamTime)
|
||||
{
|
||||
TrackTicks ticks = TicksFromDestinationTime(aRelativeToStream, aStreamTime);
|
||||
StreamTime ticks = TicksFromDestinationTime(aRelativeToStream, aStreamTime);
|
||||
mEngine->SetStreamTimeParameter(aIndex, ticks);
|
||||
}
|
||||
|
||||
|
@ -556,7 +556,7 @@ AudioNodeStream::AdvanceOutputSegment()
|
|||
}
|
||||
}
|
||||
|
||||
TrackTicks
|
||||
StreamTime
|
||||
AudioNodeStream::GetCurrentPosition()
|
||||
{
|
||||
NS_ASSERTION(!mFinished, "Don't create another track after finishing");
|
||||
|
@ -605,7 +605,7 @@ AudioNodeStream::FractionalTicksFromDestinationTime(AudioNodeStream* aDestinatio
|
|||
return thisFractionalTicks;
|
||||
}
|
||||
|
||||
TrackTicks
|
||||
StreamTime
|
||||
AudioNodeStream::TicksFromDestinationTime(MediaStream* aDestination,
|
||||
double aSeconds)
|
||||
{
|
||||
|
@ -615,13 +615,13 @@ AudioNodeStream::TicksFromDestinationTime(MediaStream* aDestination,
|
|||
double thisSeconds =
|
||||
FractionalTicksFromDestinationTime(destination, aSeconds);
|
||||
// Round to nearest
|
||||
TrackTicks ticks = thisSeconds + 0.5;
|
||||
StreamTime ticks = thisSeconds + 0.5;
|
||||
return ticks;
|
||||
}
|
||||
|
||||
double
|
||||
AudioNodeStream::DestinationTimeFromTicks(AudioNodeStream* aDestination,
|
||||
TrackTicks aPosition)
|
||||
StreamTime aPosition)
|
||||
{
|
||||
MOZ_ASSERT(SampleRate() == aDestination->SampleRate());
|
||||
GraphTime graphTime = StreamTimeToGraphTime(aPosition);
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
* the output. This is used only for DelayNodeEngine in a feedback loop.
|
||||
*/
|
||||
void ProduceOutputBeforeInput(GraphTime aFrom);
|
||||
TrackTicks GetCurrentPosition();
|
||||
StreamTime GetCurrentPosition();
|
||||
bool IsAudioParamStream() const
|
||||
{
|
||||
return mAudioParamStream;
|
||||
|
@ -145,17 +145,17 @@ public:
|
|||
double FractionalTicksFromDestinationTime(AudioNodeStream* aDestination,
|
||||
double aSeconds);
|
||||
/**
|
||||
* Convert a time in seconds on the destination stream to nearest TrackTicks
|
||||
* Convert a time in seconds on the destination stream to StreamTime
|
||||
* on this stream.
|
||||
*/
|
||||
TrackTicks TicksFromDestinationTime(MediaStream* aDestination,
|
||||
StreamTime TicksFromDestinationTime(MediaStream* aDestination,
|
||||
double aSeconds);
|
||||
/**
|
||||
* Get the destination stream time in seconds corresponding to a position on
|
||||
* this stream.
|
||||
*/
|
||||
double DestinationTimeFromTicks(AudioNodeStream* aDestination,
|
||||
TrackTicks aPosition);
|
||||
StreamTime aPosition);
|
||||
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
||||
|
|
|
@ -185,7 +185,7 @@ public:
|
|||
uint32_t numberOfChannels = mBiquads.Length();
|
||||
AllocateAudioBlock(numberOfChannels, aOutput);
|
||||
|
||||
TrackTicks pos = aStream->GetCurrentPosition();
|
||||
StreamTime pos = aStream->GetCurrentPosition();
|
||||
|
||||
double freq = mFrequency.GetValueAtTime(pos);
|
||||
double q = mQ.GetValueAtTime(pos);
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
// Compute the delay values for the duration of the input AudioChunk
|
||||
// If this DelayNode is in a cycle, make sure the delay value is at least
|
||||
// one block.
|
||||
TrackTicks tick = mSource->GetCurrentPosition();
|
||||
StreamTime tick = mSource->GetCurrentPosition();
|
||||
double computedDelay[WEBAUDIO_BLOCK_SIZE];
|
||||
for (size_t counter = 0; counter < WEBAUDIO_BLOCK_SIZE; ++counter) {
|
||||
double delayAtTick = mDelay.GetValueAtTime(tick, counter) * sampleRate;
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
aInput.mChannelData.Length());
|
||||
}
|
||||
|
||||
TrackTicks pos = aStream->GetCurrentPosition();
|
||||
StreamTime pos = aStream->GetCurrentPosition();
|
||||
mCompressor->setParameterValue(DynamicsCompressor::ParamThreshold,
|
||||
mThreshold.GetValueAtTime(pos));
|
||||
mCompressor->setParameterValue(DynamicsCompressor::ParamKnee,
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
// XXX we need to add a method to AudioEventTimeline to compute this buffer directly.
|
||||
float computedGain[WEBAUDIO_BLOCK_SIZE];
|
||||
for (size_t counter = 0; counter < WEBAUDIO_BLOCK_SIZE; ++counter) {
|
||||
TrackTicks tick = aStream->GetCurrentPosition();
|
||||
StreamTime tick = aStream->GetCurrentPosition();
|
||||
computedGain[counter] = mGain.GetValueAtTime(tick, counter) * aInput.mVolume;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
, mSource(nullptr)
|
||||
, mDestination(static_cast<AudioNodeStream*> (aDestination->Stream()))
|
||||
, mStart(-1)
|
||||
, mStop(TRACK_TICKS_MAX)
|
||||
, mStop(STREAM_TIME_MAX)
|
||||
// Keep the default values in sync with OscillatorNode::OscillatorNode.
|
||||
, mFrequency(440.f)
|
||||
, mDetune(0.f)
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void SetStreamTimeParameter(uint32_t aIndex, TrackTicks aParam)
|
||||
virtual void SetStreamTimeParameter(uint32_t aIndex, StreamTime aParam)
|
||||
{
|
||||
switch (aIndex) {
|
||||
case START: mStart = aParam; break;
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
return mType == OscillatorType::Square || mType == OscillatorType::Triangle;
|
||||
}
|
||||
|
||||
void UpdateParametersIfNeeded(TrackTicks ticks, size_t count)
|
||||
void UpdateParametersIfNeeded(StreamTime ticks, size_t count)
|
||||
{
|
||||
double frequency, detune;
|
||||
|
||||
|
@ -249,11 +249,11 @@ public:
|
|||
mAmplitudeAtZero = mNumberOfHarmonics / mSignalPeriod;
|
||||
}
|
||||
|
||||
void FillBounds(float* output, TrackTicks ticks,
|
||||
void FillBounds(float* output, StreamTime ticks,
|
||||
uint32_t& start, uint32_t& end)
|
||||
{
|
||||
MOZ_ASSERT(output);
|
||||
static_assert(TrackTicks(WEBAUDIO_BLOCK_SIZE) < UINT_MAX,
|
||||
static_assert(StreamTime(WEBAUDIO_BLOCK_SIZE) < UINT_MAX,
|
||||
"WEBAUDIO_BLOCK_SIZE overflows interator bounds.");
|
||||
start = 0;
|
||||
if (ticks < mStart) {
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
return blit;
|
||||
}
|
||||
|
||||
void ComputeSine(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
|
||||
void ComputeSine(float * aOutput, StreamTime ticks, uint32_t aStart, uint32_t aEnd)
|
||||
{
|
||||
for (uint32_t i = aStart; i < aEnd; ++i) {
|
||||
UpdateParametersIfNeeded(ticks, i);
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void ComputeSquare(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
|
||||
void ComputeSquare(float * aOutput, StreamTime ticks, uint32_t aStart, uint32_t aEnd)
|
||||
{
|
||||
for (uint32_t i = aStart; i < aEnd; ++i) {
|
||||
UpdateParametersIfNeeded(ticks, i);
|
||||
|
@ -329,7 +329,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void ComputeSawtooth(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
|
||||
void ComputeSawtooth(float * aOutput, StreamTime ticks, uint32_t aStart, uint32_t aEnd)
|
||||
{
|
||||
float dcoffset;
|
||||
for (uint32_t i = aStart; i < aEnd; ++i) {
|
||||
|
@ -346,7 +346,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void ComputeTriangle(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
|
||||
void ComputeTriangle(float * aOutput, StreamTime ticks, uint32_t aStart, uint32_t aEnd)
|
||||
{
|
||||
for (uint32_t i = aStart; i < aEnd; ++i) {
|
||||
UpdateParametersIfNeeded(ticks, i);
|
||||
|
@ -366,7 +366,7 @@ public:
|
|||
}
|
||||
|
||||
void ComputeCustom(float* aOutput,
|
||||
TrackTicks ticks,
|
||||
StreamTime ticks,
|
||||
uint32_t aStart,
|
||||
uint32_t aEnd)
|
||||
{
|
||||
|
@ -426,7 +426,7 @@ public:
|
|||
{
|
||||
MOZ_ASSERT(mSource == aStream, "Invalid source stream");
|
||||
|
||||
TrackTicks ticks = aStream->GetCurrentPosition();
|
||||
StreamTime ticks = aStream->GetCurrentPosition();
|
||||
if (mStart == -1) {
|
||||
ComputeSilence(aOutput);
|
||||
return;
|
||||
|
@ -503,8 +503,8 @@ public:
|
|||
DCBlocker mDCBlocker;
|
||||
AudioNodeStream* mSource;
|
||||
AudioNodeStream* mDestination;
|
||||
TrackTicks mStart;
|
||||
TrackTicks mStop;
|
||||
StreamTime mStart;
|
||||
StreamTime mStop;
|
||||
AudioParamTimeline mFrequency;
|
||||
AudioParamTimeline mDetune;
|
||||
OscillatorType mType;
|
||||
|
|
|
@ -100,7 +100,7 @@ private:
|
|||
public:
|
||||
explicit SharedBuffers(float aSampleRate)
|
||||
: mOutputQueue("SharedBuffers::outputQueue")
|
||||
, mDelaySoFar(TRACK_TICKS_MAX)
|
||||
, mDelaySoFar(STREAM_TIME_MAX)
|
||||
, mSampleRate(aSampleRate)
|
||||
, mLatency(0.0)
|
||||
, mDroppingBuffers(false)
|
||||
|
@ -184,14 +184,14 @@ public:
|
|||
{
|
||||
MutexAutoLock lock(mOutputQueue.Lock());
|
||||
if (mOutputQueue.ReadyToConsume() > 0) {
|
||||
if (mDelaySoFar == TRACK_TICKS_MAX) {
|
||||
if (mDelaySoFar == STREAM_TIME_MAX) {
|
||||
mDelaySoFar = 0;
|
||||
}
|
||||
buffer = mOutputQueue.Consume();
|
||||
} else {
|
||||
// If we're out of buffers to consume, just output silence
|
||||
buffer.SetNull(WEBAUDIO_BLOCK_SIZE);
|
||||
if (mDelaySoFar != TRACK_TICKS_MAX) {
|
||||
if (mDelaySoFar != STREAM_TIME_MAX) {
|
||||
// Remember the delay that we just hit
|
||||
mDelaySoFar += WEBAUDIO_BLOCK_SIZE;
|
||||
}
|
||||
|
@ -201,16 +201,16 @@ public:
|
|||
return buffer;
|
||||
}
|
||||
|
||||
TrackTicks DelaySoFar() const
|
||||
StreamTime DelaySoFar() const
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
return mDelaySoFar == TRACK_TICKS_MAX ? 0 : mDelaySoFar;
|
||||
return mDelaySoFar == STREAM_TIME_MAX ? 0 : mDelaySoFar;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
mDelaySoFar = TRACK_TICKS_MAX;
|
||||
mDelaySoFar = STREAM_TIME_MAX;
|
||||
mLatency = 0.0f;
|
||||
{
|
||||
MutexAutoLock lock(mOutputQueue.Lock());
|
||||
|
@ -223,8 +223,8 @@ private:
|
|||
OutputQueue mOutputQueue;
|
||||
// How much delay we've seen so far. This measures the amount of delay
|
||||
// caused by the main thread lagging behind in producing output buffers.
|
||||
// TRACK_TICKS_MAX means that we have not received our first buffer yet.
|
||||
TrackTicks mDelaySoFar;
|
||||
// STREAM_TIME_MAX means that we have not received our first buffer yet.
|
||||
StreamTime mDelaySoFar;
|
||||
// The samplerate of the context.
|
||||
float mSampleRate;
|
||||
// This is the latency caused by the buffering. If this grows too high, we
|
||||
|
@ -352,7 +352,7 @@ private:
|
|||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
// we now have a full input buffer ready to be sent to the main thread.
|
||||
TrackTicks playbackTick = mSource->GetCurrentPosition();
|
||||
StreamTime playbackTick = mSource->GetCurrentPosition();
|
||||
// Add the duration of the current sample
|
||||
playbackTick += WEBAUDIO_BLOCK_SIZE;
|
||||
// Add the delay caused by the main thread
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
SourceMediaStream *aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks &aLastEndTime) = 0;
|
||||
StreamTime &aLastEndTime) = 0;
|
||||
|
||||
/* Stop the device and release the corresponding MediaStream */
|
||||
virtual nsresult Stop(SourceMediaStream *aSource, TrackID aID) = 0;
|
||||
|
|
|
@ -52,7 +52,7 @@ MediaEngineCameraVideoSource::Intersect(ConstrainLongRange& aA, const ConstrainL
|
|||
bool MediaEngineCameraVideoSource::AppendToTrack(SourceMediaStream* aSource,
|
||||
layers::Image* aImage,
|
||||
TrackID aID,
|
||||
TrackTicks delta)
|
||||
StreamTime delta)
|
||||
{
|
||||
MOZ_ASSERT(aSource);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ protected:
|
|||
virtual bool AppendToTrack(SourceMediaStream* aSource,
|
||||
layers::Image* aImage,
|
||||
TrackID aID,
|
||||
TrackTicks delta);
|
||||
StreamTime delta);
|
||||
|
||||
static bool IsWithin(int32_t n, const dom::ConstrainLongRange& aRange);
|
||||
static bool IsWithin(double n, const dom::ConstrainDoubleRange& aRange);
|
||||
|
|
|
@ -229,7 +229,7 @@ MediaEngineDefaultVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
SourceMediaStream *aSource,
|
||||
TrackID aID,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks &aLastEndTime)
|
||||
StreamTime &aLastEndTime)
|
||||
{
|
||||
// AddTrack takes ownership of segment
|
||||
VideoSegment segment;
|
||||
|
@ -240,7 +240,7 @@ MediaEngineDefaultVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
|
||||
// Note: we're not giving up mImage here
|
||||
nsRefPtr<layers::Image> image = mImage;
|
||||
TrackTicks delta = aDesiredTime - aLastEndTime;
|
||||
StreamTime delta = aDesiredTime - aLastEndTime;
|
||||
|
||||
if (delta > 0) {
|
||||
// nullptr images are allowed
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
SourceMediaStream *aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks &aLastEndTime);
|
||||
StreamTime &aLastEndTime);
|
||||
virtual bool SatisfiesConstraintSets(
|
||||
const nsTArray<const dom::MediaTrackConstraintSet*>& aConstraintSets)
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
SourceMediaStream *aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks &aLastEndTime) {}
|
||||
StreamTime &aLastEndTime) {}
|
||||
|
||||
virtual bool IsFake() {
|
||||
return true;
|
||||
|
|
|
@ -42,7 +42,7 @@ MediaEngineGonkVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
SourceMediaStream* aSource,
|
||||
TrackID aID,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks& aLastEndTime)
|
||||
StreamTime& aLastEndTime)
|
||||
{
|
||||
VideoSegment segment;
|
||||
|
||||
|
@ -53,7 +53,7 @@ MediaEngineGonkVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
|
||||
// Note: we're not giving up mImage here
|
||||
nsRefPtr<layers::Image> image = mImage;
|
||||
TrackTicks delta = aDesiredTime - aLastEndTime;
|
||||
StreamTime delta = aDesiredTime - aLastEndTime;
|
||||
LOGFRAME(("NotifyPull, desired = %ld, delta = %ld %s", (int64_t) aDesiredTime,
|
||||
(int64_t) delta, image ? "" : "<null>"));
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
SourceMediaStream* aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks& aLastEndTime) MOZ_OVERRIDE;
|
||||
StreamTime &aLastEndTime) MOZ_OVERRIDE;
|
||||
virtual bool SatisfiesConstraintSets(
|
||||
const nsTArray<const dom::MediaTrackConstraintSet*>& aConstraintSets)
|
||||
{
|
||||
|
|
|
@ -193,14 +193,14 @@ void
|
|||
MediaEngineTabVideoSource::NotifyPull(MediaStreamGraph*,
|
||||
SourceMediaStream* aSource,
|
||||
TrackID aID, StreamTime aDesiredTime,
|
||||
TrackTicks& aLastEndTime)
|
||||
StreamTime& aLastEndTime)
|
||||
{
|
||||
VideoSegment segment;
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
|
||||
// Note: we're not giving up mImage here
|
||||
nsRefPtr<layers::CairoImage> image = mImage;
|
||||
TrackTicks delta = aDesiredTime - aLastEndTime;
|
||||
StreamTime delta = aDesiredTime - aLastEndTime;
|
||||
if (delta > 0) {
|
||||
// nullptr images are allowed
|
||||
gfx::IntSize size = image ? image->GetSize() : IntSize(0, 0);
|
||||
|
|
|
@ -25,7 +25,7 @@ class MediaEngineTabVideoSource : public MediaEngineVideoSource, nsIDOMEventList
|
|||
virtual nsresult Deallocate();
|
||||
virtual nsresult Start(mozilla::SourceMediaStream*, mozilla::TrackID);
|
||||
virtual void SetDirectListeners(bool aHasDirectListeners) {};
|
||||
virtual void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, mozilla::TrackTicks&);
|
||||
virtual void NotifyPull(mozilla::MediaStreamGraph*, mozilla::SourceMediaStream*, mozilla::TrackID, mozilla::StreamTime, mozilla::StreamTime&);
|
||||
virtual nsresult Stop(mozilla::SourceMediaStream*, mozilla::TrackID);
|
||||
virtual nsresult Config(bool, uint32_t, bool, uint32_t, bool, uint32_t, int32_t);
|
||||
virtual bool IsFake();
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
SourceMediaStream* aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks& aLastEndTime);
|
||||
StreamTime &aLastEndTime);
|
||||
|
||||
virtual const MediaSourceType GetMediaSource() {
|
||||
return mMediaSource;
|
||||
|
@ -181,7 +181,7 @@ public:
|
|||
SourceMediaStream* aSource,
|
||||
TrackID aId,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks& aLastEndTime);
|
||||
StreamTime &aLastEndTime);
|
||||
|
||||
virtual bool IsFake() {
|
||||
return false;
|
||||
|
|
|
@ -397,11 +397,11 @@ MediaEngineWebRTCAudioSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
SourceMediaStream *aSource,
|
||||
TrackID aID,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks &aLastEndTime)
|
||||
StreamTime &aLastEndTime)
|
||||
{
|
||||
// Ignore - we push audio data
|
||||
#ifdef DEBUG
|
||||
TrackTicks delta = aDesiredTime - aLastEndTime;
|
||||
StreamTime delta = aDesiredTime - aLastEndTime;
|
||||
LOG(("Audio: NotifyPull: aDesiredTime %ld, delta %ld",(int64_t) aDesiredTime,
|
||||
(int64_t) delta));
|
||||
aLastEndTime = aDesiredTime;
|
||||
|
|
|
@ -125,7 +125,7 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
SourceMediaStream* aSource,
|
||||
TrackID aID,
|
||||
StreamTime aDesiredTime,
|
||||
TrackTicks &aLastEndTime)
|
||||
StreamTime &aLastEndTime)
|
||||
{
|
||||
VideoSegment segment;
|
||||
|
||||
|
@ -134,7 +134,7 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
|||
// So mState could be kReleased here. We really don't care about the state,
|
||||
// though.
|
||||
|
||||
TrackTicks delta = aDesiredTime - aLastEndTime;
|
||||
StreamTime delta = aDesiredTime - aLastEndTime;
|
||||
LOGFRAME(("NotifyPull, desired = %ld, delta = %ld %s", (int64_t) aDesiredTime,
|
||||
(int64_t) delta, mImage.get() ? "" : "<null>"));
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ SpeechStreamListener::~SpeechStreamListener()
|
|||
void
|
||||
SpeechStreamListener::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
~SpeechStreamListener();
|
||||
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID,
|
||||
TrackTicks aTrackOffset,
|
||||
StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia) MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -940,7 +940,7 @@ nsresult MediaPipeline::PipelineTransport::SendRtcpPacket_s(
|
|||
// Called if we're attached with AddDirectListener()
|
||||
void MediaPipelineTransmit::PipelineListener::
|
||||
NotifyRealtimeData(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& media) {
|
||||
MOZ_MTLOG(ML_DEBUG, "MediaPipeline::NotifyRealtimeData()");
|
||||
|
@ -950,7 +950,7 @@ NotifyRealtimeData(MediaStreamGraph* graph, TrackID tid,
|
|||
|
||||
void MediaPipelineTransmit::PipelineListener::
|
||||
NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& queued_media) {
|
||||
MOZ_MTLOG(ML_DEBUG, "MediaPipeline::NotifyQueuedTrackChanges()");
|
||||
|
@ -972,7 +972,7 @@ NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
|
|||
|
||||
void MediaPipelineTransmit::PipelineListener::
|
||||
NewData(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& media) {
|
||||
if (!active_) {
|
||||
|
@ -1543,7 +1543,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) {
|
|||
nsRefPtr<layers::Image> image = image_;
|
||||
// our constructor sets track_rate_ to the graph rate
|
||||
MOZ_ASSERT(track_rate_ == source_->GraphRate());
|
||||
TrackTicks delta = desired_time - played_ticks_;
|
||||
StreamTime delta = desired_time - played_ticks_;
|
||||
|
||||
// Don't append if we've already provided a frame that supposedly
|
||||
// goes past the current aDesiredTime Doing so means a negative
|
||||
|
|
|
@ -463,20 +463,20 @@ public:
|
|||
|
||||
// Implement MediaStreamListener
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& queued_media) MOZ_OVERRIDE;
|
||||
virtual void NotifyPull(MediaStreamGraph* aGraph, StreamTime aDesiredTime) MOZ_OVERRIDE {}
|
||||
|
||||
// Implement MediaStreamDirectListener
|
||||
virtual void NotifyRealtimeData(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& media) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
void NewData(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& media);
|
||||
|
||||
|
@ -623,7 +623,7 @@ class MediaPipelineReceiveAudio : public MediaPipelineReceive {
|
|||
|
||||
// Implement MediaStreamListener
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& queued_media) MOZ_OVERRIDE {}
|
||||
virtual void NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) MOZ_OVERRIDE;
|
||||
|
@ -712,7 +712,7 @@ class MediaPipelineReceiveVideo : public MediaPipelineReceive {
|
|||
|
||||
// Implement MediaStreamListener
|
||||
virtual void NotifyQueuedTrackChanges(MediaStreamGraph* graph, TrackID tid,
|
||||
TrackTicks offset,
|
||||
StreamTime offset,
|
||||
uint32_t events,
|
||||
const MediaSegment& queued_media) MOZ_OVERRIDE {}
|
||||
virtual void NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) MOZ_OVERRIDE;
|
||||
|
|
|
@ -39,7 +39,7 @@ protected:
|
|||
|
||||
public:
|
||||
virtual void NotifyQueuedTrackChanges(mozilla::MediaStreamGraph* aGraph, mozilla::TrackID aID,
|
||||
mozilla::TrackTicks aTrackOffset,
|
||||
mozilla::StreamTime aTrackOffset,
|
||||
uint32_t aTrackEvents,
|
||||
const mozilla::MediaSegment& aQueuedMedia) = 0;
|
||||
virtual void NotifyPull(mozilla::MediaStreamGraph* aGraph, mozilla::StreamTime aDesiredTime) = 0;
|
||||
|
@ -54,7 +54,7 @@ protected:
|
|||
|
||||
public:
|
||||
virtual void NotifyRealtimeData(mozilla::MediaStreamGraph* graph, mozilla::TrackID tid,
|
||||
mozilla::TrackTicks offset,
|
||||
mozilla::StreamTime offset,
|
||||
uint32_t events,
|
||||
const mozilla::MediaSegment& media) = 0;
|
||||
};
|
||||
|
@ -128,11 +128,11 @@ class Fake_SourceMediaStream : public Fake_MediaStream {
|
|||
mStop(false),
|
||||
mPeriodic(new Fake_MediaPeriodic(this)) {}
|
||||
|
||||
void AddTrack(mozilla::TrackID aID, mozilla::TrackTicks aStart,
|
||||
void AddTrack(mozilla::TrackID aID, mozilla::StreamTime aStart,
|
||||
mozilla::MediaSegment* aSegment) {
|
||||
delete aSegment;
|
||||
}
|
||||
void AddAudioTrack(mozilla::TrackID aID, mozilla::TrackRate aRate, mozilla::TrackTicks aStart,
|
||||
void AddAudioTrack(mozilla::TrackID aID, mozilla::TrackRate aRate, mozilla::StreamTime aStart,
|
||||
mozilla::AudioSegment* aSegment) {
|
||||
delete aSegment;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче