diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 2a8b09b5aa07..653f2f5b9ad4 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -1194,12 +1194,6 @@ MediaStreamGraphImpl::PrepareUpdatesToMainThreadState(bool aFinalUpdate) } } -/** - * Returns smallest value of t such that - * TimeToTicksRoundUp(aSampleRate, t) is a multiple of WEBAUDIO_BLOCK_SIZE - * and floor(TimeToTicksRoundUp(aSampleRate, t)/WEBAUDIO_BLOCK_SIZE) > - * floor(TimeToTicksRoundUp(aSampleRate, aTime)/WEBAUDIO_BLOCK_SIZE). - */ GraphTime MediaStreamGraphImpl::RoundUpToNextAudioBlock(GraphTime aTime) { diff --git a/dom/media/MediaStreamGraphImpl.h b/dom/media/MediaStreamGraphImpl.h index 1f47a05e7618..9f199caed9fb 100644 --- a/dom/media/MediaStreamGraphImpl.h +++ b/dom/media/MediaStreamGraphImpl.h @@ -285,10 +285,8 @@ public: GraphTime aTime, GraphTime aEndBlockingDecisions, GraphTime* aEnd); /** - * Returns smallest value of t such that - * TimeToTicksRoundUp(aSampleRate, t) is a multiple of WEBAUDIO_BLOCK_SIZE - * and floor(TimeToTicksRoundUp(aSampleRate, t)/WEBAUDIO_BLOCK_SIZE) > - * floor(TimeToTicksRoundUp(aSampleRate, aTime)/WEBAUDIO_BLOCK_SIZE). + * Returns smallest value of t such that t is a multiple of + * WEBAUDIO_BLOCK_SIZE and t > aTime. */ GraphTime RoundUpToNextAudioBlock(GraphTime aTime); /** diff --git a/dom/media/TrackUnionStream.cpp b/dom/media/TrackUnionStream.cpp index 9e04a2f101f3..66b209e10f64 100644 --- a/dom/media/TrackUnionStream.cpp +++ b/dom/media/TrackUnionStream.cpp @@ -192,7 +192,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 = TimeToTicksRoundUp(rate, GraphTimeToStreamTime(aFrom)); + TrackTicks outputStart = GraphTimeToStreamTime(aFrom); nsAutoPtr segment; segment = aTrack->GetSegment()->CreateEmptyClone(); @@ -219,6 +219,7 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) : map->mSegment = aTrack->GetSegment()->CreateEmptyClone(); return mTrackMap.Length() - 1; } + void TrackUnionStream::EndTrack(uint32_t aIndex) { StreamBuffer::Track* outputTrack = mBuffer.FindTrack(mTrackMap[aIndex].mOutputTrackID); @@ -244,7 +245,6 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) : StreamBuffer::Track* outputTrack = mBuffer.FindTrack(map->mOutputTrackID); MOZ_ASSERT(outputTrack && !outputTrack->IsEnded(), "Can't copy to ended track"); - TrackRate rate = outputTrack->GetRate(); MediaSegment* segment = map->mSegment; MediaStream* source = map->mInputPort->GetSource(); @@ -271,9 +271,8 @@ TrackUnionStream::TrackUnionStream(DOMMediaStream* aWrapper) : StreamTime outputEnd = GraphTimeToStreamTime(interval.mEnd); TrackTicks startTicks = outputTrack->GetEnd(); StreamTime outputStart = GraphTimeToStreamTime(interval.mStart); - MOZ_ASSERT(startTicks == TimeToTicksRoundUp(rate, outputStart), "Samples missing"); - TrackTicks endTicks = TimeToTicksRoundUp(rate, outputEnd); - TrackTicks ticks = endTicks - startTicks; + MOZ_ASSERT(startTicks == outputStart, "Samples missing"); + TrackTicks ticks = outputEnd - startTicks; StreamTime inputStart = source->GraphTimeToStreamTime(interval.mStart); if (interval.mInputIsBlocked) { diff --git a/dom/media/webrtc/MediaEngineDefault.cpp b/dom/media/webrtc/MediaEngineDefault.cpp index b27b139c94cb..50526df5acff 100644 --- a/dom/media/webrtc/MediaEngineDefault.cpp +++ b/dom/media/webrtc/MediaEngineDefault.cpp @@ -240,9 +240,7 @@ MediaEngineDefaultVideoSource::NotifyPull(MediaStreamGraph* aGraph, // Note: we're not giving up mImage here nsRefPtr image = mImage; - TrackTicks target = - aSource->TimeToTicksRoundUp(aSource->GraphRate(), aDesiredTime); - TrackTicks delta = target - aLastEndTime; + TrackTicks delta = aDesiredTime - aLastEndTime; if (delta > 0) { // nullptr images are allowed @@ -251,7 +249,7 @@ MediaEngineDefaultVideoSource::NotifyPull(MediaStreamGraph* aGraph, // This can fail if either a) we haven't added the track yet, or b) // we've removed or finished the track. if (aSource->AppendToTrack(aID, &segment)) { - aLastEndTime = target; + aLastEndTime = aDesiredTime; } } } diff --git a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp index 5c9e7c0f4496..0cdf1f02f433 100644 --- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp @@ -53,11 +53,9 @@ MediaEngineGonkVideoSource::NotifyPull(MediaStreamGraph* aGraph, // Note: we're not giving up mImage here nsRefPtr image = mImage; - TrackTicks target = aSource->TimeToTicksRoundUp( - aSource->GraphRate(), aDesiredTime); - TrackTicks delta = target - aLastEndTime; - LOGFRAME(("NotifyPull, desired = %ld, target = %ld, delta = %ld %s", (int64_t) aDesiredTime, - (int64_t) target, (int64_t) delta, image ? "" : "")); + TrackTicks delta = aDesiredTime - aLastEndTime; + LOGFRAME(("NotifyPull, desired = %ld, delta = %ld %s", (int64_t) aDesiredTime, + (int64_t) delta, image ? "" : "")); // Bug 846188 We may want to limit incoming frames to the requested frame rate // mFps - if you want 30FPS, and the camera gives you 60FPS, this could @@ -76,7 +74,7 @@ MediaEngineGonkVideoSource::NotifyPull(MediaStreamGraph* aGraph, // This can fail if either a) we haven't added the track yet, or b) // we've removed or finished the track. if (aSource->AppendToTrack(aID, &(segment))) { - aLastEndTime = target; + aLastEndTime = aDesiredTime; } } } diff --git a/dom/media/webrtc/MediaEngineTabVideoSource.cpp b/dom/media/webrtc/MediaEngineTabVideoSource.cpp index 76e6bb86c71b..99af1c62b305 100644 --- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp @@ -200,9 +200,7 @@ MediaEngineTabVideoSource::NotifyPull(MediaStreamGraph*, // Note: we're not giving up mImage here nsRefPtr image = mImage; - TrackTicks target = aSource->TimeToTicksRoundUp( - aSource->GraphRate(), aDesiredTime); - TrackTicks delta = target - aLastEndTime; + TrackTicks delta = aDesiredTime - aLastEndTime; if (delta > 0) { // nullptr images are allowed gfx::IntSize size = image ? image->GetSize() : IntSize(0, 0); @@ -210,7 +208,7 @@ MediaEngineTabVideoSource::NotifyPull(MediaStreamGraph*, // This can fail if either a) we haven't added the track yet, or b) // we've removed or finished the track. if (aSource->AppendToTrack(aID, &(segment))) { - aLastEndTime = target; + aLastEndTime = aDesiredTime; } } } diff --git a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp index fc07c395cf1d..5371b0c6ed00 100644 --- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp +++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp @@ -401,10 +401,10 @@ MediaEngineWebRTCAudioSource::NotifyPull(MediaStreamGraph* aGraph, { // Ignore - we push audio data #ifdef DEBUG - TrackTicks target = aSource->TimeToTicksRoundUp(SAMPLE_FREQUENCY, aDesiredTime); - TrackTicks delta = target - aLastEndTime; - LOG_FRAMES(("Audio: NotifyPull: aDesiredTime %ld, target %ld, delta %ld",(int64_t) aDesiredTime, (int64_t) target, (int64_t) delta)); - aLastEndTime = target; + TrackTicks delta = aDesiredTime - aLastEndTime; + LOG(("Audio: NotifyPull: aDesiredTime %ld, delta %ld",(int64_t) aDesiredTime, + (int64_t) delta)); + aLastEndTime = aDesiredTime; #endif } diff --git a/dom/media/webrtc/MediaEngineWebRTCVideo.cpp b/dom/media/webrtc/MediaEngineWebRTCVideo.cpp index ebf5467f958e..2b504a7b2be8 100644 --- a/dom/media/webrtc/MediaEngineWebRTCVideo.cpp +++ b/dom/media/webrtc/MediaEngineWebRTCVideo.cpp @@ -134,11 +134,9 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph, // So mState could be kReleased here. We really don't care about the state, // though. - TrackTicks target = aSource->TimeToTicksRoundUp( - aSource->GraphRate(), aDesiredTime); - TrackTicks delta = target - aLastEndTime; - LOGFRAME(("NotifyPull, desired = %ld, target = %ld, delta = %ld %s", (int64_t) aDesiredTime, - (int64_t) target, (int64_t) delta, mImage ? "" : "")); + TrackTicks delta = aDesiredTime - aLastEndTime; + LOGFRAME(("NotifyPull, desired = %ld, delta = %ld %s", (int64_t) aDesiredTime, + (int64_t) delta, mImage.get() ? "" : "")); // Bug 846188 We may want to limit incoming frames to the requested frame rate // mFps - if you want 30FPS, and the camera gives you 60FPS, this could @@ -153,7 +151,7 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph, if (delta > 0) { // nullptr images are allowed if (AppendToTrack(aSource, mImage, aID, delta)) { - aLastEndTime = target; + aLastEndTime = aDesiredTime; } } } diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 9eff9a3624a4..e03cfdd027e4 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -1543,9 +1543,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { nsRefPtr image = image_; // our constructor sets track_rate_ to the graph rate MOZ_ASSERT(track_rate_ == source_->GraphRate()); - TrackTicks target = source_->TimeToTicksRoundUp( - source_->GraphRate(), desired_time); - TrackTicks delta = target - played_ticks_; + TrackTicks 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 @@ -1555,7 +1553,7 @@ NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { segment.AppendFrame(image.forget(), delta, IntSize(width_, height_)); // Handle track not actually added yet or removed/finished if (source_->AppendToTrack(track_id_, &segment)) { - played_ticks_ = target; + played_ticks_ = desired_time; } else { MOZ_MTLOG(ML_ERROR, "AppendToTrack failed"); return;