[MSE] Incorrect sample timestamps when using "sequence" mode
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jul 2015 02:37:39 +0000 (02:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Jul 2015 02:37:39 +0000 (02:37 +0000)
commitfb74e46aa19d166e682f0bc7d8adbc12ce9545c3
treeb661f86773f19276196ab6d8b609ced945f09de8
parentae33247060d7899023f490255585b3f41f1b3da9
[MSE] Incorrect sample timestamps when using "sequence" mode
https://bugs.webkit.org/show_bug.cgi?id=147252

Patch by Sajid Anwar <sajidanwar94@gmail.com> on 2015-07-24
Reviewed by Jer Noble.

Source/WebCore:

Test: media/media-source/media-source-sequence-timestamps.html

According to the specification, the "sequence" mode indicates that the samples in the buffer will use generated timestamps
instead of the presentation/decode timestamps already present in the sample. The current implementation always adds
the current timestamp offset to the samples' timestamps, as expected for "segments" mode.

Add a method to media samples to allow their presentation and decode timestamps to be set to specific values.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Fix an algorithm condition to align with the specification, and
    correctly set the presentation and decode timestamps of samples when in "sequence" mode.
* platform/MediaSample.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::setTimestamps): Add a new method to set the values of a sample's presentation and decode timestamps.
* platform/mock/mediasource/MockBox.h:
(WebCore::MockBox::setTimestamps): Set m_presentationTimestamp and m_decodeTimestamp.
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockMediaSample::offsetTimestampsBy): Pass to MockBox.
* testing/Internals.cpp:
(WebCore::Internals::setShouldGenerateTimestamps): Expose the internal `setShouldGenerateTimestamps` method of SourceBuffer.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

* media/media-source/media-source-sequence-timestamps-expected.txt: Added.
* media/media-source/media-source-sequence-timestamps.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187377 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-sequence-timestamps-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-sequence-timestamps.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/platform/MediaSample.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/mock/mediasource/MockBox.h
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl