diff --git a/dom/media/CanvasCaptureMediaStream.cpp b/dom/media/CanvasCaptureMediaStream.cpp index b587a6eb9f3a..85938db8dad1 100644 --- a/dom/media/CanvasCaptureMediaStream.cpp +++ b/dom/media/CanvasCaptureMediaStream.cpp @@ -54,7 +54,7 @@ void OutputStreamDriver::SetImage(const RefPtr& aImage, TRACE_COMMENT("SourceMediaStream %p track %i", mSourceStream.get(), mTrackId); VideoSegment segment; - segment.AppendFrame(do_AddRef(aImage), 1, aImage->GetSize(), mPrincipalHandle, + segment.AppendFrame(do_AddRef(aImage), aImage->GetSize(), mPrincipalHandle, false, aTime); mSourceStream->AppendToTrack(mTrackId, &segment); } diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 828e807cf85d..586361bb31ea 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -2797,7 +2797,7 @@ void SourceMediaStream::AddDirectTrackListenerImpl( continue; } MOZ_ASSERT(!iter->mTimeStamp.IsNull()); - bufferedVideo.AppendFrame(do_AddRef(iter->mFrame.GetImage()), 1, + bufferedVideo.AppendFrame(do_AddRef(iter->mFrame.GetImage()), iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetForceBlack(), iter->mTimeStamp); @@ -2811,9 +2811,9 @@ void SourceMediaStream::AddDirectTrackListenerImpl( continue; } bufferedVideo.AppendFrame( - do_AddRef(iter->mFrame.GetImage()), 1, - iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetPrincipalHandle(), - iter->mFrame.GetForceBlack(), iter->mTimeStamp); + do_AddRef(iter->mFrame.GetImage()), iter->mFrame.GetIntrinsicSize(), + iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetForceBlack(), + iter->mTimeStamp); } } } diff --git a/dom/media/MediaStreamListener.cpp b/dom/media/MediaStreamListener.cpp index 1aed46d74f3f..9ade6c825139 100644 --- a/dom/media/MediaStreamListener.cpp +++ b/dom/media/MediaStreamListener.cpp @@ -28,9 +28,10 @@ void DirectMediaStreamTrackListener::MirrorAndDisableSegment( aTo.Clear(); if (aMode == DisabledTrackMode::SILENCE_BLACK) { for (VideoSegment::ChunkIterator it(aFrom); !it.IsEnded(); it.Next()) { - aTo.AppendFrame(do_AddRef(it->mFrame.GetImage()), it->GetDuration(), + aTo.AppendFrame(do_AddRef(it->mFrame.GetImage()), it->mFrame.GetIntrinsicSize(), it->GetPrincipalHandle(), true); + aTo.ExtendLastFrameBy(it->GetDuration()); } } else if (aMode == DisabledTrackMode::SILENCE_FREEZE) { aTo.AppendNullData(aFrom.GetDuration()); diff --git a/dom/media/VideoSegment.cpp b/dom/media/VideoSegment.cpp index 1d5b5eb93557..f5027ff08ead 100644 --- a/dom/media/VideoSegment.cpp +++ b/dom/media/VideoSegment.cpp @@ -86,11 +86,10 @@ already_AddRefed VideoFrame::CreateBlackImage( } void VideoSegment::AppendFrame(already_AddRefed&& aImage, - StreamTime aDuration, const IntSize& aIntrinsicSize, const PrincipalHandle& aPrincipalHandle, bool aForceBlack, TimeStamp aTimeStamp) { - VideoChunk* chunk = AppendChunk(aDuration); + VideoChunk* chunk = AppendChunk(0); chunk->mTimeStamp = aTimeStamp; VideoFrame frame(aImage, aIntrinsicSize); MOZ_ASSERT_IF(!IsNull(), !aTimeStamp.IsNull()); diff --git a/dom/media/VideoSegment.h b/dom/media/VideoSegment.h index c4b5e3aa0f6b..a96d6c32164f 100644 --- a/dom/media/VideoSegment.h +++ b/dom/media/VideoSegment.h @@ -108,7 +108,7 @@ class VideoSegment : public MediaSegmentBase { ~VideoSegment(); - void AppendFrame(already_AddRefed&& aImage, StreamTime aDuration, + void AppendFrame(already_AddRefed&& aImage, const IntSize& aIntrinsicSize, const PrincipalHandle& aPrincipalHandle, bool aForceBlack = false, diff --git a/dom/media/VideoStreamTrack.cpp b/dom/media/VideoStreamTrack.cpp index 5cc62669f56b..149495ebabe5 100644 --- a/dom/media/VideoStreamTrack.cpp +++ b/dom/media/VideoStreamTrack.cpp @@ -33,7 +33,7 @@ class VideoOutput : public DirectMediaStreamTrackListener { mSegment.Clear(); } const VideoFrame& f = i->mFrame; - mSegment.AppendFrame(do_AddRef(f.GetImage()), 0, f.GetIntrinsicSize(), + mSegment.AppendFrame(do_AddRef(f.GetImage()), f.GetIntrinsicSize(), f.GetPrincipalHandle(), f.GetForceBlack(), i->mTimeStamp); mLastFrameTime = i->mTimeStamp; diff --git a/dom/media/encoder/MediaEncoder.cpp b/dom/media/encoder/MediaEncoder.cpp index e19551077f6f..d1794c86cfb0 100644 --- a/dom/media/encoder/MediaEncoder.cpp +++ b/dom/media/encoder/MediaEncoder.cpp @@ -235,7 +235,7 @@ class MediaEncoder::VideoTrackListener : public DirectMediaStreamTrackListener { VideoSegment copy; for (VideoSegment::ConstChunkIterator iter(video); !iter.IsEnded(); iter.Next()) { - copy.AppendFrame(do_AddRef(iter->mFrame.GetImage()), 1, + copy.AppendFrame(do_AddRef(iter->mFrame.GetImage()), iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetForceBlack(), iter->mTimeStamp); diff --git a/dom/media/encoder/TrackEncoder.cpp b/dom/media/encoder/TrackEncoder.cpp index cf7b7421d8df..e6f7bf1d0396 100644 --- a/dom/media/encoder/TrackEncoder.cpp +++ b/dom/media/encoder/TrackEncoder.cpp @@ -482,9 +482,10 @@ void VideoTrackEncoder::NotifyEndOfStream() { (mLastChunk.mTimeStamp - mStartTime).ToSeconds(), absoluteEndTime.ToSeconds())); mOutgoingBuffer.AppendFrame( - lastImage.forget(), duration.value(), - mLastChunk.mFrame.GetIntrinsicSize(), PRINCIPAL_HANDLE_NONE, - mLastChunk.mFrame.GetForceBlack(), mLastChunk.mTimeStamp); + lastImage.forget(), mLastChunk.mFrame.GetIntrinsicSize(), + PRINCIPAL_HANDLE_NONE, mLastChunk.mFrame.GetForceBlack(), + mLastChunk.mTimeStamp); + mOutgoingBuffer.ExtendLastFrameBy(duration.value()); } } @@ -544,7 +545,7 @@ void VideoTrackEncoder::AdvanceCurrentTime(const TimeStamp& aTime) { // We encode at least one frame per second, even if there are none // flowing. previousChunk->mTimeStamp += TimeDuration::FromSeconds(1.0); - tempSegment.AppendFrame(do_AddRef(previousChunk->mFrame.GetImage()), 1, + tempSegment.AppendFrame(do_AddRef(previousChunk->mFrame.GetImage()), previousChunk->mFrame.GetIntrinsicSize(), previousChunk->mFrame.GetPrincipalHandle(), previousChunk->mFrame.GetForceBlack(), @@ -571,7 +572,7 @@ void VideoTrackEncoder::AdvanceCurrentTime(const TimeStamp& aTime) { if (!previousChunk->IsNull()) { appendDupes(iter->mTimeStamp); } - tempSegment.AppendFrame(do_AddRef(iter->mFrame.GetImage()), 1, + tempSegment.AppendFrame(do_AddRef(iter->mFrame.GetImage()), iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetForceBlack(), iter->mTimeStamp); @@ -654,9 +655,10 @@ void VideoTrackEncoder::AdvanceCurrentTime(const TimeStamp& aTime) { mEncodedTicks += duration.value(); mOutgoingBuffer.AppendFrame( - do_AddRef(mLastChunk.mFrame.GetImage()), duration.value(), + do_AddRef(mLastChunk.mFrame.GetImage()), mLastChunk.mFrame.GetIntrinsicSize(), PRINCIPAL_HANDLE_NONE, mLastChunk.mFrame.GetForceBlack(), mLastChunk.mTimeStamp); + mOutgoingBuffer.ExtendLastFrameBy(duration.value()); chunkAppended = true; mLastChunk = chunk; } diff --git a/dom/media/gtest/TestVideoSegment.cpp b/dom/media/gtest/TestVideoSegment.cpp index 33ffadc4300f..8f8bb9c8dc55 100644 --- a/dom/media/gtest/TestVideoSegment.cpp +++ b/dom/media/gtest/TestVideoSegment.cpp @@ -17,9 +17,8 @@ TEST(VideoSegment, TestAppendFrameForceBlack) { RefPtr testImage = nullptr; VideoSegment segment; - segment.AppendFrame(testImage.forget(), mozilla::StreamTime(90000), - mozilla::gfx::IntSize(640, 480), PRINCIPAL_HANDLE_NONE, - true); + segment.AppendFrame(testImage.forget(), mozilla::gfx::IntSize(640, 480), + PRINCIPAL_HANDLE_NONE, true); VideoSegment::ChunkIterator iter(segment); while (!iter.IsEnded()) { @@ -33,8 +32,8 @@ TEST(VideoSegment, TestAppendFrameNotForceBlack) { RefPtr testImage = nullptr; VideoSegment segment; - segment.AppendFrame(testImage.forget(), mozilla::StreamTime(90000), - mozilla::gfx::IntSize(640, 480), PRINCIPAL_HANDLE_NONE); + segment.AppendFrame(testImage.forget(), mozilla::gfx::IntSize(640, 480), + PRINCIPAL_HANDLE_NONE); VideoSegment::ChunkIterator iter(segment); while (!iter.IsEnded()) { diff --git a/dom/media/gtest/TestVideoTrackEncoder.cpp b/dom/media/gtest/TestVideoTrackEncoder.cpp index acdadd8385f2..427d872625fc 100644 --- a/dom/media/gtest/TestVideoTrackEncoder.cpp +++ b/dom/media/gtest/TestVideoTrackEncoder.cpp @@ -281,7 +281,7 @@ TEST(VP8VideoTrackEncoder, FrameEncode) { TimeStamp now = TimeStamp::Now(); for (nsTArray>::size_type i = 0; i < images.Length(); i++) { RefPtr image = images[i]; - segment.AppendFrame(image.forget(), 1, generator.GetSize(), + segment.AppendFrame(image.forget(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(i)); } @@ -304,7 +304,7 @@ TEST(VP8VideoTrackEncoder, SingleFrameEncode) { generator.Init(mozilla::gfx::IntSize(640, 480)); VideoSegment segment; TimeStamp now = TimeStamp::Now(); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -340,7 +340,7 @@ TEST(VP8VideoTrackEncoder, SameFrameEncode) { TimeStamp now = TimeStamp::Now(); VideoSegment segment; for (uint32_t i = 0; i < 15; ++i) { - segment.AppendFrame(do_AddRef(image), 1, generator.GetSize(), + segment.AppendFrame(do_AddRef(image), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(i * 0.1)); } @@ -375,7 +375,7 @@ TEST(VP8VideoTrackEncoder, SkippedFrames) { // Pass 100 frames of the shortest possible duration where we don't get // rounding errors between input/output rate. for (uint32_t i = 0; i < 100; ++i) { - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(i)); } @@ -411,13 +411,13 @@ TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode) { // then one frame to make the total duration one second. uint32_t usPerFrame = 99999; // 99.999ms for (uint32_t i = 0; i < 9; ++i) { - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMicroseconds(i * usPerFrame)); } // This last frame has timestamp start + 0.9s and duration 0.1s. - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.9)); @@ -448,12 +448,12 @@ TEST(VP8VideoTrackEncoder, TimestampFrameEncode) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.05)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.2)); @@ -497,12 +497,12 @@ TEST(VP8VideoTrackEncoder, DriftingFrameEncode) { [&](TimeStamp, TimeStamp aTime) { return now + (aTime - now) * 2; })); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.05)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.2)); @@ -541,7 +541,7 @@ TEST(VP8VideoTrackEncoder, Suspended) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -550,7 +550,7 @@ TEST(VP8VideoTrackEncoder, Suspended) { encoder.Suspend(now + TimeDuration::FromSeconds(0.1)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.1)); encoder.AppendVideoSegment(std::move(segment)); @@ -558,7 +558,7 @@ TEST(VP8VideoTrackEncoder, Suspended) { encoder.Resume(now + TimeDuration::FromSeconds(0.2)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.2)); encoder.AppendVideoSegment(std::move(segment)); @@ -592,7 +592,7 @@ TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -601,7 +601,7 @@ TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) { encoder.Suspend(now + TimeDuration::FromSeconds(0.1)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.1)); encoder.AppendVideoSegment(std::move(segment)); @@ -639,7 +639,7 @@ TEST(VP8VideoTrackEncoder, AlwaysSuspended) { encoder.Suspend(now); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -669,7 +669,7 @@ TEST(VP8VideoTrackEncoder, SuspendedBeginning) { YUVBufferGenerator generator; generator.Init(mozilla::gfx::IntSize(640, 480)); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -678,7 +678,7 @@ TEST(VP8VideoTrackEncoder, SuspendedBeginning) { encoder.Resume(now + TimeDuration::FromSeconds(0.5)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(0.5)); encoder.AppendVideoSegment(std::move(segment)); @@ -713,7 +713,7 @@ TEST(VP8VideoTrackEncoder, SuspendedOverlap) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -723,7 +723,7 @@ TEST(VP8VideoTrackEncoder, SuspendedOverlap) { encoder.Suspend(now + TimeDuration::FromSeconds(0.5)); // Pass another 1s frame and resume after 0.3 of this new frame. - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromSeconds(1)); encoder.AppendVideoSegment(std::move(segment)); @@ -759,7 +759,7 @@ TEST(VP8VideoTrackEncoder, PrematureEnding) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -790,7 +790,7 @@ TEST(VP8VideoTrackEncoder, DelayedStart) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now + TimeDuration::FromSeconds(0.5)); @@ -822,7 +822,7 @@ TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.AppendVideoSegment(std::move(segment)); @@ -853,7 +853,7 @@ TEST(VP8VideoTrackEncoder, VeryDelayedStart) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now + TimeDuration::FromSeconds(10)); @@ -887,7 +887,7 @@ TEST(VP8VideoTrackEncoder, LongFramesReEncoded) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); encoder.SetStartOffset(now); @@ -939,21 +939,21 @@ TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(400)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(600)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(750)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(900)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1100)); @@ -1008,21 +1008,21 @@ TEST(VP8VideoTrackEncoder, LongKeyFrameInterval) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(600)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(900)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1100)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1900)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2100)); @@ -1076,21 +1076,21 @@ TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval) { generator.Init(mozilla::gfx::IntSize(640, 480)); TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(600)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(900)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1100)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1900)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2100)); @@ -1153,27 +1153,27 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) { EncodedFrameContainer container; TimeStamp now = TimeStamp::Now(); VideoSegment segment; - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(100)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(120)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(130)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(200)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(300)); // The underlying encoder only gets passed frame N when frame N+1 is known, // so we pass in the next frame *before* the keyframe interval change. - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(500)); @@ -1186,19 +1186,19 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) { encoder.AdvanceCurrentTime(now + TimeDuration::FromMilliseconds(501)); ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container))); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1300)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(1400)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2400)); // The underlying encoder only gets passed frame N when frame N+1 is known, // so we pass in the next frame *before* the keyframe interval change. - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2500)); @@ -1209,13 +1209,13 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) { encoder.AdvanceCurrentTime(now + TimeDuration::FromMilliseconds(2501)); ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container))); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2600)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2800)); - segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), + segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(), PRINCIPAL_HANDLE_NONE, false, now + TimeDuration::FromMilliseconds(2900)); diff --git a/dom/media/mediasink/DecodedStream.cpp b/dom/media/mediasink/DecodedStream.cpp index b4d59d3fdf6c..f75c428c6cb9 100644 --- a/dom/media/mediasink/DecodedStream.cpp +++ b/dom/media/mediasink/DecodedStream.cpp @@ -596,9 +596,12 @@ static void WriteVideoToMediaStream(MediaStream* aStream, layers::Image* aImage, auto end = aStream->MicrosecondsToStreamTimeRoundDown(aEnd.ToMicroseconds()); auto start = aStream->MicrosecondsToStreamTimeRoundDown(aStart.ToMicroseconds()); - StreamTime duration = end - start; - aOutput->AppendFrame(image.forget(), duration, aIntrinsicSize, - aPrincipalHandle, false, aTimeStamp); + aOutput->AppendFrame(image.forget(), aIntrinsicSize, aPrincipalHandle, false, + aTimeStamp); + // Extend this so we get accurate durations for all frames. + // Because this track is pushed, we need durations so the graph can track + // when playout of the track has finished. + aOutput->ExtendLastFrameBy(end - start); } static bool ZeroDurationAtLastChunk(VideoSegment& aInput) { diff --git a/dom/media/webrtc/MediaEngineDefault.cpp b/dom/media/webrtc/MediaEngineDefault.cpp index 44f36cd5fabd..179c387f3ff8 100644 --- a/dom/media/webrtc/MediaEngineDefault.cpp +++ b/dom/media/webrtc/MediaEngineDefault.cpp @@ -323,7 +323,7 @@ void MediaEngineDefaultVideoSource::GenerateFrame() { } VideoSegment segment; - segment.AppendFrame(ycbcr_image.forget(), 1, + segment.AppendFrame(ycbcr_image.forget(), gfx::IntSize(mOpts.mWidth, mOpts.mHeight), mPrincipalHandle); ; diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp index 691f7dbcd0a5..c3b43f4afc47 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -638,7 +638,7 @@ int MediaEngineRemoteVideoSource::DeliverFrame( MOZ_ASSERT(mState == kStarted); VideoSegment segment; mImageSize = image->GetSize(); - segment.AppendFrame(image.forget(), 1, mImageSize, mPrincipal); + segment.AppendFrame(image.forget(), mImageSize, mPrincipal); mStream->AppendToTrack(mTrackID, &segment); } diff --git a/dom/media/webrtc/MediaEngineTabVideoSource.cpp b/dom/media/webrtc/MediaEngineTabVideoSource.cpp index a25ef67f0ba0..fe679fa8bbac 100644 --- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp @@ -384,7 +384,7 @@ void MediaEngineTabVideoSource::Draw() { } VideoSegment segment; - segment.AppendFrame(do_AddRef(rgbImage), 1, size, mPrincipalHandle); + segment.AppendFrame(do_AddRef(rgbImage), size, mPrincipalHandle); // This can fail if either a) we haven't added the track yet, or b) // we've removed or ended the track. mStreamMain->AppendToTrack(mTrackIDMain, &segment); diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 22be8d216e88..d5e27931edee 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -1782,7 +1782,7 @@ class MediaPipelineReceiveVideo::PipelineListener VideoSegment segment; auto size = image->GetSize(); - segment.AppendFrame(image.forget(), 1, size, mPrincipalHandle); + segment.AppendFrame(image.forget(), size, mPrincipalHandle); mSource->AppendToTrack(mTrackId, &segment); }