From 77218e98240b07ef13b86fb7078e2d605897a349 Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Fri, 30 Nov 2012 03:08:17 -0500 Subject: [PATCH] Bug 816664: wallpaper patch for negative delta times for video frames r=roc,derf --- content/media/MediaSegment.h | 2 ++ content/media/webrtc/MediaEngineWebRTCAudio.cpp | 2 +- content/media/webrtc/MediaEngineWebRTCVideo.cpp | 16 ++++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/content/media/MediaSegment.h b/content/media/MediaSegment.h index ebe7e371f5ea..2106c9723c1f 100644 --- a/content/media/MediaSegment.h +++ b/content/media/MediaSegment.h @@ -215,6 +215,7 @@ protected: void AppendFromInternal(MediaSegmentBase* aSource) { static_cast(this)->CheckCompatible(*static_cast(aSource)); + MOZ_ASSERT(aSource->mDuration >= 0); mDuration += aSource->mDuration; aSource->mDuration = 0; if (!mChunks.IsEmpty() && !aSource->mChunks.IsEmpty() && @@ -248,6 +249,7 @@ protected: Chunk* AppendChunk(TrackTicks aDuration) { + MOZ_ASSERT(aDuration >= 0); Chunk* c = mChunks.AppendElement(); c->mDuration = aDuration; mDuration += aDuration; diff --git a/content/media/webrtc/MediaEngineWebRTCAudio.cpp b/content/media/webrtc/MediaEngineWebRTCAudio.cpp index 09c2a9798ced..7ebb513824db 100644 --- a/content/media/webrtc/MediaEngineWebRTCAudio.cpp +++ b/content/media/webrtc/MediaEngineWebRTCAudio.cpp @@ -161,7 +161,7 @@ MediaEngineWebRTCAudioSource::NotifyPull(MediaStreamGraph* aGraph, #ifdef DEBUG TrackTicks target = TimeToTicksRoundUp(SAMPLE_FREQUENCY, aDesiredTime); TrackTicks delta = target - aLastEndTime; - LOG(("Audio:NotifyPull: target %lu, delta %lu",(uint64_t) target, (uint64_t) delta)); + LOG(("Audio: NotifyPull: aDesiredTime %ld, target %ld, delta %ld",(int64_t) aDesiredTime, (int64_t) target, (int64_t) delta)); aLastEndTime = target; #endif } diff --git a/content/media/webrtc/MediaEngineWebRTCVideo.cpp b/content/media/webrtc/MediaEngineWebRTCVideo.cpp index 5af557bcf5d2..4cc3a6ee4a96 100644 --- a/content/media/webrtc/MediaEngineWebRTCVideo.cpp +++ b/content/media/webrtc/MediaEngineWebRTCVideo.cpp @@ -114,12 +114,16 @@ MediaEngineWebRTCVideoSource::NotifyPull(MediaStreamGraph* aGraph, nsRefPtr image = mImage; TrackTicks target = TimeToTicksRoundUp(USECS_PER_S, aDesiredTime); TrackTicks delta = target - aLastEndTime; - LOGFRAME(("NotifyPull, target = %lu, delta = %lu %s", (uint64_t) target, (uint64_t) delta, - image ? "" : "")); - // NULL images are allowed - segment.AppendFrame(image ? image.forget() : nullptr, delta, gfxIntSize(mWidth, mHeight)); - aSource->AppendToTrack(aID, &(segment)); - aLastEndTime = target; + LOGFRAME(("NotifyPull, desired = %ld, target = %ld, delta = %ld %s", (int64_t) aDesiredTime, + (int64_t) target, (int64_t) delta, image ? "" : "")); + // Don't append if we've already provided a frame that supposedly goes past the current aDesiredTime + // Doing so means a negative delta and thus messes up handling of the graph + if (delta > 0) { + // NULL images are allowed + segment.AppendFrame(image ? image.forget() : nullptr, delta, gfxIntSize(mWidth, mHeight)); + aSource->AppendToTrack(aID, &(segment)); + aLastEndTime = target; + } } void -- 2.11.4.GIT