Bug 1423253 - Remove durations from VideoSegment::AppendFrame. r=padenot

VideoSegments still have durations, and they are still needed by the
MediaStreamGraph as it shuffles MediaSegments around.
They do not have a say in the wall-clock duration of video frames however.
Removing this should prevent any producers starting to add video chunks with
durations in the future.

Differential Revision: https://phabricator.services.mozilla.com/D22914

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-03-22 11:43:40 +00:00
Родитель 0bb89b2b34
Коммит e57962eea8
15 изменённых файлов: 92 добавлений и 88 удалений

Просмотреть файл

@ -54,7 +54,7 @@ void OutputStreamDriver::SetImage(const RefPtr<layers::Image>& aImage,
TRACE_COMMENT("SourceMediaStream %p track %i", mSourceStream.get(), mTrackId); TRACE_COMMENT("SourceMediaStream %p track %i", mSourceStream.get(), mTrackId);
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(do_AddRef(aImage), 1, aImage->GetSize(), mPrincipalHandle, segment.AppendFrame(do_AddRef(aImage), aImage->GetSize(), mPrincipalHandle,
false, aTime); false, aTime);
mSourceStream->AppendToTrack(mTrackId, &segment); mSourceStream->AppendToTrack(mTrackId, &segment);
} }

Просмотреть файл

@ -2797,7 +2797,7 @@ void SourceMediaStream::AddDirectTrackListenerImpl(
continue; continue;
} }
MOZ_ASSERT(!iter->mTimeStamp.IsNull()); 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.GetIntrinsicSize(),
iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetPrincipalHandle(),
iter->mFrame.GetForceBlack(), iter->mTimeStamp); iter->mFrame.GetForceBlack(), iter->mTimeStamp);
@ -2811,9 +2811,9 @@ void SourceMediaStream::AddDirectTrackListenerImpl(
continue; continue;
} }
bufferedVideo.AppendFrame( bufferedVideo.AppendFrame(
do_AddRef(iter->mFrame.GetImage()), 1, do_AddRef(iter->mFrame.GetImage()), iter->mFrame.GetIntrinsicSize(),
iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetForceBlack(),
iter->mFrame.GetForceBlack(), iter->mTimeStamp); iter->mTimeStamp);
} }
} }
} }

Просмотреть файл

@ -28,9 +28,10 @@ void DirectMediaStreamTrackListener::MirrorAndDisableSegment(
aTo.Clear(); aTo.Clear();
if (aMode == DisabledTrackMode::SILENCE_BLACK) { if (aMode == DisabledTrackMode::SILENCE_BLACK) {
for (VideoSegment::ChunkIterator it(aFrom); !it.IsEnded(); it.Next()) { 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(), it->mFrame.GetIntrinsicSize(), it->GetPrincipalHandle(),
true); true);
aTo.ExtendLastFrameBy(it->GetDuration());
} }
} else if (aMode == DisabledTrackMode::SILENCE_FREEZE) { } else if (aMode == DisabledTrackMode::SILENCE_FREEZE) {
aTo.AppendNullData(aFrom.GetDuration()); aTo.AppendNullData(aFrom.GetDuration());

Просмотреть файл

@ -86,11 +86,10 @@ already_AddRefed<Image> VideoFrame::CreateBlackImage(
} }
void VideoSegment::AppendFrame(already_AddRefed<Image>&& aImage, void VideoSegment::AppendFrame(already_AddRefed<Image>&& aImage,
StreamTime aDuration,
const IntSize& aIntrinsicSize, const IntSize& aIntrinsicSize,
const PrincipalHandle& aPrincipalHandle, const PrincipalHandle& aPrincipalHandle,
bool aForceBlack, TimeStamp aTimeStamp) { bool aForceBlack, TimeStamp aTimeStamp) {
VideoChunk* chunk = AppendChunk(aDuration); VideoChunk* chunk = AppendChunk(0);
chunk->mTimeStamp = aTimeStamp; chunk->mTimeStamp = aTimeStamp;
VideoFrame frame(aImage, aIntrinsicSize); VideoFrame frame(aImage, aIntrinsicSize);
MOZ_ASSERT_IF(!IsNull(), !aTimeStamp.IsNull()); MOZ_ASSERT_IF(!IsNull(), !aTimeStamp.IsNull());

Просмотреть файл

@ -108,7 +108,7 @@ class VideoSegment : public MediaSegmentBase<VideoSegment, VideoChunk> {
~VideoSegment(); ~VideoSegment();
void AppendFrame(already_AddRefed<Image>&& aImage, StreamTime aDuration, void AppendFrame(already_AddRefed<Image>&& aImage,
const IntSize& aIntrinsicSize, const IntSize& aIntrinsicSize,
const PrincipalHandle& aPrincipalHandle, const PrincipalHandle& aPrincipalHandle,
bool aForceBlack = false, bool aForceBlack = false,

Просмотреть файл

@ -33,7 +33,7 @@ class VideoOutput : public DirectMediaStreamTrackListener {
mSegment.Clear(); mSegment.Clear();
} }
const VideoFrame& f = i->mFrame; 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(), f.GetPrincipalHandle(), f.GetForceBlack(),
i->mTimeStamp); i->mTimeStamp);
mLastFrameTime = i->mTimeStamp; mLastFrameTime = i->mTimeStamp;

Просмотреть файл

@ -235,7 +235,7 @@ class MediaEncoder::VideoTrackListener : public DirectMediaStreamTrackListener {
VideoSegment copy; VideoSegment copy;
for (VideoSegment::ConstChunkIterator iter(video); !iter.IsEnded(); for (VideoSegment::ConstChunkIterator iter(video); !iter.IsEnded();
iter.Next()) { iter.Next()) {
copy.AppendFrame(do_AddRef(iter->mFrame.GetImage()), 1, copy.AppendFrame(do_AddRef(iter->mFrame.GetImage()),
iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetIntrinsicSize(),
iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetPrincipalHandle(),
iter->mFrame.GetForceBlack(), iter->mTimeStamp); iter->mFrame.GetForceBlack(), iter->mTimeStamp);

Просмотреть файл

@ -482,9 +482,10 @@ void VideoTrackEncoder::NotifyEndOfStream() {
(mLastChunk.mTimeStamp - mStartTime).ToSeconds(), (mLastChunk.mTimeStamp - mStartTime).ToSeconds(),
absoluteEndTime.ToSeconds())); absoluteEndTime.ToSeconds()));
mOutgoingBuffer.AppendFrame( mOutgoingBuffer.AppendFrame(
lastImage.forget(), duration.value(), lastImage.forget(), mLastChunk.mFrame.GetIntrinsicSize(),
mLastChunk.mFrame.GetIntrinsicSize(), PRINCIPAL_HANDLE_NONE, PRINCIPAL_HANDLE_NONE, mLastChunk.mFrame.GetForceBlack(),
mLastChunk.mFrame.GetForceBlack(), mLastChunk.mTimeStamp); 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 // We encode at least one frame per second, even if there are none
// flowing. // flowing.
previousChunk->mTimeStamp += TimeDuration::FromSeconds(1.0); 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.GetIntrinsicSize(),
previousChunk->mFrame.GetPrincipalHandle(), previousChunk->mFrame.GetPrincipalHandle(),
previousChunk->mFrame.GetForceBlack(), previousChunk->mFrame.GetForceBlack(),
@ -571,7 +572,7 @@ void VideoTrackEncoder::AdvanceCurrentTime(const TimeStamp& aTime) {
if (!previousChunk->IsNull()) { if (!previousChunk->IsNull()) {
appendDupes(iter->mTimeStamp); appendDupes(iter->mTimeStamp);
} }
tempSegment.AppendFrame(do_AddRef(iter->mFrame.GetImage()), 1, tempSegment.AppendFrame(do_AddRef(iter->mFrame.GetImage()),
iter->mFrame.GetIntrinsicSize(), iter->mFrame.GetIntrinsicSize(),
iter->mFrame.GetPrincipalHandle(), iter->mFrame.GetPrincipalHandle(),
iter->mFrame.GetForceBlack(), iter->mTimeStamp); iter->mFrame.GetForceBlack(), iter->mTimeStamp);
@ -654,9 +655,10 @@ void VideoTrackEncoder::AdvanceCurrentTime(const TimeStamp& aTime) {
mEncodedTicks += duration.value(); mEncodedTicks += duration.value();
mOutgoingBuffer.AppendFrame( mOutgoingBuffer.AppendFrame(
do_AddRef(mLastChunk.mFrame.GetImage()), duration.value(), do_AddRef(mLastChunk.mFrame.GetImage()),
mLastChunk.mFrame.GetIntrinsicSize(), PRINCIPAL_HANDLE_NONE, mLastChunk.mFrame.GetIntrinsicSize(), PRINCIPAL_HANDLE_NONE,
mLastChunk.mFrame.GetForceBlack(), mLastChunk.mTimeStamp); mLastChunk.mFrame.GetForceBlack(), mLastChunk.mTimeStamp);
mOutgoingBuffer.ExtendLastFrameBy(duration.value());
chunkAppended = true; chunkAppended = true;
mLastChunk = chunk; mLastChunk = chunk;
} }

Просмотреть файл

@ -17,9 +17,8 @@ TEST(VideoSegment, TestAppendFrameForceBlack) {
RefPtr<layers::Image> testImage = nullptr; RefPtr<layers::Image> testImage = nullptr;
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(testImage.forget(), mozilla::StreamTime(90000), segment.AppendFrame(testImage.forget(), mozilla::gfx::IntSize(640, 480),
mozilla::gfx::IntSize(640, 480), PRINCIPAL_HANDLE_NONE, PRINCIPAL_HANDLE_NONE, true);
true);
VideoSegment::ChunkIterator iter(segment); VideoSegment::ChunkIterator iter(segment);
while (!iter.IsEnded()) { while (!iter.IsEnded()) {
@ -33,8 +32,8 @@ TEST(VideoSegment, TestAppendFrameNotForceBlack) {
RefPtr<layers::Image> testImage = nullptr; RefPtr<layers::Image> testImage = nullptr;
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(testImage.forget(), mozilla::StreamTime(90000), segment.AppendFrame(testImage.forget(), mozilla::gfx::IntSize(640, 480),
mozilla::gfx::IntSize(640, 480), PRINCIPAL_HANDLE_NONE); PRINCIPAL_HANDLE_NONE);
VideoSegment::ChunkIterator iter(segment); VideoSegment::ChunkIterator iter(segment);
while (!iter.IsEnded()) { while (!iter.IsEnded()) {

Просмотреть файл

@ -281,7 +281,7 @@ TEST(VP8VideoTrackEncoder, FrameEncode) {
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
for (nsTArray<RefPtr<Image>>::size_type i = 0; i < images.Length(); i++) { for (nsTArray<RefPtr<Image>>::size_type i = 0; i < images.Length(); i++) {
RefPtr<Image> image = images[i]; RefPtr<Image> image = images[i];
segment.AppendFrame(image.forget(), 1, generator.GetSize(), segment.AppendFrame(image.forget(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(i)); now + TimeDuration::FromSeconds(i));
} }
@ -304,7 +304,7 @@ TEST(VP8VideoTrackEncoder, SingleFrameEncode) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
VideoSegment segment; VideoSegment segment;
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -340,7 +340,7 @@ TEST(VP8VideoTrackEncoder, SameFrameEncode) {
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
for (uint32_t i = 0; i < 15; ++i) { 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(i * 0.1)); 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 // Pass 100 frames of the shortest possible duration where we don't get
// rounding errors between input/output rate. // rounding errors between input/output rate.
for (uint32_t i = 0; i < 100; ++i) { 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(i)); now + TimeDuration::FromMilliseconds(i));
} }
@ -411,13 +411,13 @@ TEST(VP8VideoTrackEncoder, RoundingErrorFramesEncode) {
// then one frame to make the total duration one second. // then one frame to make the total duration one second.
uint32_t usPerFrame = 99999; // 99.999ms uint32_t usPerFrame = 99999; // 99.999ms
for (uint32_t i = 0; i < 9; ++i) { 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMicroseconds(i * usPerFrame)); now + TimeDuration::FromMicroseconds(i * usPerFrame));
} }
// This last frame has timestamp start + 0.9s and duration 0.1s. // 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.9)); now + TimeDuration::FromSeconds(0.9));
@ -448,12 +448,12 @@ TEST(VP8VideoTrackEncoder, TimestampFrameEncode) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.05)); now + TimeDuration::FromSeconds(0.05));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.2)); now + TimeDuration::FromSeconds(0.2));
@ -497,12 +497,12 @@ TEST(VP8VideoTrackEncoder, DriftingFrameEncode) {
[&](TimeStamp, TimeStamp aTime) { return now + (aTime - now) * 2; })); [&](TimeStamp, TimeStamp aTime) { return now + (aTime - now) * 2; }));
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.05)); now + TimeDuration::FromSeconds(0.05));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.2)); now + TimeDuration::FromSeconds(0.2));
@ -541,7 +541,7 @@ TEST(VP8VideoTrackEncoder, Suspended) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -550,7 +550,7 @@ TEST(VP8VideoTrackEncoder, Suspended) {
encoder.Suspend(now + TimeDuration::FromSeconds(0.1)); encoder.Suspend(now + TimeDuration::FromSeconds(0.1));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.1)); now + TimeDuration::FromSeconds(0.1));
encoder.AppendVideoSegment(std::move(segment)); encoder.AppendVideoSegment(std::move(segment));
@ -558,7 +558,7 @@ TEST(VP8VideoTrackEncoder, Suspended) {
encoder.Resume(now + TimeDuration::FromSeconds(0.2)); encoder.Resume(now + TimeDuration::FromSeconds(0.2));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.2)); now + TimeDuration::FromSeconds(0.2));
encoder.AppendVideoSegment(std::move(segment)); encoder.AppendVideoSegment(std::move(segment));
@ -592,7 +592,7 @@ TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -601,7 +601,7 @@ TEST(VP8VideoTrackEncoder, SuspendedUntilEnd) {
encoder.Suspend(now + TimeDuration::FromSeconds(0.1)); encoder.Suspend(now + TimeDuration::FromSeconds(0.1));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.1)); now + TimeDuration::FromSeconds(0.1));
encoder.AppendVideoSegment(std::move(segment)); encoder.AppendVideoSegment(std::move(segment));
@ -639,7 +639,7 @@ TEST(VP8VideoTrackEncoder, AlwaysSuspended) {
encoder.Suspend(now); encoder.Suspend(now);
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -669,7 +669,7 @@ TEST(VP8VideoTrackEncoder, SuspendedBeginning) {
YUVBufferGenerator generator; YUVBufferGenerator generator;
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -678,7 +678,7 @@ TEST(VP8VideoTrackEncoder, SuspendedBeginning) {
encoder.Resume(now + TimeDuration::FromSeconds(0.5)); encoder.Resume(now + TimeDuration::FromSeconds(0.5));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(0.5)); now + TimeDuration::FromSeconds(0.5));
encoder.AppendVideoSegment(std::move(segment)); encoder.AppendVideoSegment(std::move(segment));
@ -713,7 +713,7 @@ TEST(VP8VideoTrackEncoder, SuspendedOverlap) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -723,7 +723,7 @@ TEST(VP8VideoTrackEncoder, SuspendedOverlap) {
encoder.Suspend(now + TimeDuration::FromSeconds(0.5)); encoder.Suspend(now + TimeDuration::FromSeconds(0.5));
// Pass another 1s frame and resume after 0.3 of this new frame. // 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromSeconds(1)); now + TimeDuration::FromSeconds(1));
encoder.AppendVideoSegment(std::move(segment)); encoder.AppendVideoSegment(std::move(segment));
@ -759,7 +759,7 @@ TEST(VP8VideoTrackEncoder, PrematureEnding) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -790,7 +790,7 @@ TEST(VP8VideoTrackEncoder, DelayedStart) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now + TimeDuration::FromSeconds(0.5)); encoder.SetStartOffset(now + TimeDuration::FromSeconds(0.5));
@ -822,7 +822,7 @@ TEST(VP8VideoTrackEncoder, DelayedStartOtherEventOrder) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.AppendVideoSegment(std::move(segment)); encoder.AppendVideoSegment(std::move(segment));
@ -853,7 +853,7 @@ TEST(VP8VideoTrackEncoder, VeryDelayedStart) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now + TimeDuration::FromSeconds(10)); encoder.SetStartOffset(now + TimeDuration::FromSeconds(10));
@ -887,7 +887,7 @@ TEST(VP8VideoTrackEncoder, LongFramesReEncoded) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
encoder.SetStartOffset(now); encoder.SetStartOffset(now);
@ -939,21 +939,21 @@ TEST(VP8VideoTrackEncoder, ShortKeyFrameInterval) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(400)); now + TimeDuration::FromMilliseconds(400));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(600)); now + TimeDuration::FromMilliseconds(600));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(750)); now + TimeDuration::FromMilliseconds(750));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(900)); now + TimeDuration::FromMilliseconds(900));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1100)); now + TimeDuration::FromMilliseconds(1100));
@ -1008,21 +1008,21 @@ TEST(VP8VideoTrackEncoder, LongKeyFrameInterval) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(600)); now + TimeDuration::FromMilliseconds(600));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(900)); now + TimeDuration::FromMilliseconds(900));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1100)); now + TimeDuration::FromMilliseconds(1100));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1900)); now + TimeDuration::FromMilliseconds(1900));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2100)); now + TimeDuration::FromMilliseconds(2100));
@ -1076,21 +1076,21 @@ TEST(VP8VideoTrackEncoder, DefaultKeyFrameInterval) {
generator.Init(mozilla::gfx::IntSize(640, 480)); generator.Init(mozilla::gfx::IntSize(640, 480));
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(600)); now + TimeDuration::FromMilliseconds(600));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(900)); now + TimeDuration::FromMilliseconds(900));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1100)); now + TimeDuration::FromMilliseconds(1100));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1900)); now + TimeDuration::FromMilliseconds(1900));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2100)); now + TimeDuration::FromMilliseconds(2100));
@ -1153,27 +1153,27 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) {
EncodedFrameContainer container; EncodedFrameContainer container;
TimeStamp now = TimeStamp::Now(); TimeStamp now = TimeStamp::Now();
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, now); PRINCIPAL_HANDLE_NONE, false, now);
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(100)); now + TimeDuration::FromMilliseconds(100));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(120)); now + TimeDuration::FromMilliseconds(120));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(130)); now + TimeDuration::FromMilliseconds(130));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(200)); now + TimeDuration::FromMilliseconds(200));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(300)); now + TimeDuration::FromMilliseconds(300));
// The underlying encoder only gets passed frame N when frame N+1 is known, // 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. // 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(500)); now + TimeDuration::FromMilliseconds(500));
@ -1186,19 +1186,19 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) {
encoder.AdvanceCurrentTime(now + TimeDuration::FromMilliseconds(501)); encoder.AdvanceCurrentTime(now + TimeDuration::FromMilliseconds(501));
ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container))); ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container)));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1300)); now + TimeDuration::FromMilliseconds(1300));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(1400)); now + TimeDuration::FromMilliseconds(1400));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2400)); now + TimeDuration::FromMilliseconds(2400));
// The underlying encoder only gets passed frame N when frame N+1 is known, // 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. // 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, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2500)); now + TimeDuration::FromMilliseconds(2500));
@ -1209,13 +1209,13 @@ TEST(VP8VideoTrackEncoder, DynamicKeyFrameIntervalChanges) {
encoder.AdvanceCurrentTime(now + TimeDuration::FromMilliseconds(2501)); encoder.AdvanceCurrentTime(now + TimeDuration::FromMilliseconds(2501));
ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container))); ASSERT_TRUE(NS_SUCCEEDED(encoder.GetEncodedTrack(container)));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2600)); now + TimeDuration::FromMilliseconds(2600));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2800)); now + TimeDuration::FromMilliseconds(2800));
segment.AppendFrame(generator.GenerateI420Image(), 1, generator.GetSize(), segment.AppendFrame(generator.GenerateI420Image(), generator.GetSize(),
PRINCIPAL_HANDLE_NONE, false, PRINCIPAL_HANDLE_NONE, false,
now + TimeDuration::FromMilliseconds(2900)); now + TimeDuration::FromMilliseconds(2900));

Просмотреть файл

@ -596,9 +596,12 @@ static void WriteVideoToMediaStream(MediaStream* aStream, layers::Image* aImage,
auto end = aStream->MicrosecondsToStreamTimeRoundDown(aEnd.ToMicroseconds()); auto end = aStream->MicrosecondsToStreamTimeRoundDown(aEnd.ToMicroseconds());
auto start = auto start =
aStream->MicrosecondsToStreamTimeRoundDown(aStart.ToMicroseconds()); aStream->MicrosecondsToStreamTimeRoundDown(aStart.ToMicroseconds());
StreamTime duration = end - start; aOutput->AppendFrame(image.forget(), aIntrinsicSize, aPrincipalHandle, false,
aOutput->AppendFrame(image.forget(), duration, aIntrinsicSize, aTimeStamp);
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) { static bool ZeroDurationAtLastChunk(VideoSegment& aInput) {

Просмотреть файл

@ -323,7 +323,7 @@ void MediaEngineDefaultVideoSource::GenerateFrame() {
} }
VideoSegment segment; VideoSegment segment;
segment.AppendFrame(ycbcr_image.forget(), 1, segment.AppendFrame(ycbcr_image.forget(),
gfx::IntSize(mOpts.mWidth, mOpts.mHeight), gfx::IntSize(mOpts.mWidth, mOpts.mHeight),
mPrincipalHandle); mPrincipalHandle);
; ;

Просмотреть файл

@ -638,7 +638,7 @@ int MediaEngineRemoteVideoSource::DeliverFrame(
MOZ_ASSERT(mState == kStarted); MOZ_ASSERT(mState == kStarted);
VideoSegment segment; VideoSegment segment;
mImageSize = image->GetSize(); mImageSize = image->GetSize();
segment.AppendFrame(image.forget(), 1, mImageSize, mPrincipal); segment.AppendFrame(image.forget(), mImageSize, mPrincipal);
mStream->AppendToTrack(mTrackID, &segment); mStream->AppendToTrack(mTrackID, &segment);
} }

Просмотреть файл

@ -384,7 +384,7 @@ void MediaEngineTabVideoSource::Draw() {
} }
VideoSegment segment; 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) // This can fail if either a) we haven't added the track yet, or b)
// we've removed or ended the track. // we've removed or ended the track.
mStreamMain->AppendToTrack(mTrackIDMain, &segment); mStreamMain->AppendToTrack(mTrackIDMain, &segment);

Просмотреть файл

@ -1782,7 +1782,7 @@ class MediaPipelineReceiveVideo::PipelineListener
VideoSegment segment; VideoSegment segment;
auto size = image->GetSize(); auto size = image->GetSize();
segment.AppendFrame(image.forget(), 1, size, mPrincipalHandle); segment.AppendFrame(image.forget(), size, mPrincipalHandle);
mSource->AppendToTrack(mTrackId, &segment); mSource->AppendToTrack(mTrackId, &segment);
} }