Bug 123322 - [MSE] Add mock MediaSource classes for testing.
Summary: [MSE] Add mock MediaSource classes for testing.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords:
Depends on: 123374
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-24 23:29 PDT by Jer Noble
Modified: 2013-11-07 09:56 PST (History)
8 users (show)

See Also:


Attachments
Patch (103.59 KB, patch)
2013-10-30 10:53 PDT, Jer Noble
eric.carlson: review+
Details | Formatted Diff | Diff
Patch for landing (98.05 KB, patch)
2013-11-07 08:54 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (98.06 KB, patch)
2013-11-07 09:10 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch for landing (98.16 KB, patch)
2013-11-07 09:27 PST, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2013-10-24 23:29:44 PDT
[MSE] Add mock MediaSource classes for testing.
Comment 1 Jer Noble 2013-10-30 10:53:40 PDT
Created attachment 215524 [details]
Patch
Comment 2 Eric Carlson 2013-11-01 14:52:05 PDT
Comment on attachment 215524 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=215524&action=review

r=me with a few nits.

> Source/WebCore/platform/graphics/MediaPlayer.cpp:1213
> +void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister registerMediaEngine)

"callRegisterMediaEngine" is an odd name for an externally visible method (even though that is what it does).

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:206
> +#if ENABLE(MEDIA_SOURCE)
> +void MediaPlayerPrivateAVFoundation::load(const String&, PassRefPtr<HTMLMediaSource>)
> +{
> +    m_networkState = MediaPlayer::FormatError;
> +    m_player->networkStateChanged();
> +}
> +#endif

This was part of bug 123593.

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:133
> +    virtual void load(const String&, PassRefPtr<HTMLMediaSource>);

Ditto.

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:910
> +#if ENABLE(MEDIA_SOURCE)
> +    if (parameters.isMediaSource)
> +        return MediaPlayer::IsNotSupported;
> +#endif

Ditto.

> Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h:98
> +    virtual void load(const String&, PassRefPtr<HTMLMediaSource>);

Ditto.

> Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm:678
> +#if ENABLE(MEDIA_SOURCE)
> +void MediaPlayerPrivateQTKit::load(const String&, PassRefPtr<HTMLMediaSource>)
> +{
> +    m_networkState = MediaPlayer::FormatError;
> +    m_player->networkStateChanged();
> +}
> +#endif

Ditto.

> Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm:1481
> +#if ENABLE(MEDIA_SOURCE)
> +    if (parameters.isMediaSource)
> +        return MediaPlayer::IsNotSupported;
> +#endif

Ditto.

> Source/WebCore/platform/mock/mediasource/MockBox.cpp:42
> +MockBox::MockBox(ArrayBuffer* data)
> +{
> +    m_type = peekType(data);
> +    m_length = peekLength(data);
> +}

Should you check that data is big enough for a box?

> Source/WebCore/platform/mock/mediasource/MockBox.cpp:63
> +    RefPtr<JSC::DataView> view = JSC::DataView::create(data, 0, data->byteLength());
> +    m_trackID = view->get<int32_t>(8, true);

Ditto.

> Source/WebCore/platform/mock/mediasource/MockBox.cpp:83
> +    RefPtr<JSC::DataView> view = JSC::DataView::create(data, 0, data->byteLength());

Ditto.

> Source/WebCore/platform/mock/mediasource/MockBox.cpp:110
> +    RefPtr<JSC::DataView> view = JSC::DataView::create(data, 0, data->byteLength());

Ditto.

> Source/WebCore/platform/mock/mediasource/MockBox.h:70
> +class MockTrackBox : public MockBox {

Can this be marked FINAL?

> Source/WebCore/platform/mock/mediasource/MockBox.h:97
> +class MockInitializationBox : public MockBox {

Ditto.

> Source/WebCore/platform/mock/mediasource/MockBox.h:121
> +class MockSampleBox : public MockBox {

Ditto.

> Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h:38
> +class MockMediaPlayerMediaSource : public MediaPlayerPrivateInterface {

Can this be marked FINAL?

> Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h:72
> +    // MediaPlayerPrivate Overrides
> +    virtual void load(const String& url) OVERRIDE;
> +    virtual void load(const String& url, PassRefPtr<HTMLMediaSource>) OVERRIDE;
> +    virtual void cancelLoad() OVERRIDE;
> +    virtual void play() OVERRIDE;
> +    virtual void pause() OVERRIDE;
> +    virtual IntSize naturalSize() const OVERRIDE;
> +    virtual bool hasVideo() const OVERRIDE;
> +    virtual bool hasAudio() const OVERRIDE;
> +    virtual void setVisible(bool) OVERRIDE;
> +    virtual bool seeking() const OVERRIDE;
> +    virtual bool paused() const OVERRIDE;
> +    virtual MediaPlayer::NetworkState networkState() const OVERRIDE;
> +    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
> +    virtual PassRefPtr<TimeRanges> buffered() const OVERRIDE;
> +    virtual bool didLoadingProgress() const OVERRIDE;
> +    virtual void setSize(const IntSize&) OVERRIDE;
> +    virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
> +    virtual double currentTimeDouble() const OVERRIDE;
> +    virtual double durationDouble() const OVERRIDE;
> +    virtual void seekDouble(double time) OVERRIDE;
> +
> +    void advanceCurrentTime();
> +    void updateDuration(double);
> +    void setReadyState(MediaPlayer::ReadyState);

Can these be made private?

> Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h:81
> +    bool m_playing;

Nit: packing.

> Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp:131
> +    RefPtr<MockSourceBufferPrivate> sourceBuffer = prpSourceBuffer;
> +    return sourceBuffer->hasAudio();

Nit: the local isn't necessary.

> Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp:141
> +    RefPtr<MockSourceBufferPrivate> sourceBuffer = prpSourceBuffer;

Ditto.

> Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h:39
> +class MockMediaSourcePrivate : public MediaSourcePrivate {

Can this be marked FINAL?

> Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h:53
> +    // MediaSourcePrivate Overrides
> +    virtual AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) OVERRIDE;
> +    virtual double duration() OVERRIDE;
> +    virtual void setDuration(double) OVERRIDE;
> +    virtual void markEndOfStream(EndOfStreamStatus) OVERRIDE;
> +    virtual void unmarkEndOfStream() OVERRIDE;
> +    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
> +    virtual void setReadyState(MediaPlayer::ReadyState) OVERRIDE;
> +
> +    const Vector<MockSourceBufferPrivate*>& activeSourceBuffers() const { return m_activeSourceBuffers; }

Can these be made private?

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:44
> +class MockMediaSample : public MediaSample {

FINAL?

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:46
> +    static RefPtr<MockMediaSample> create(MockSampleBox box) { return adoptRef(new MockMediaSample(box)); }

const MockSampleBox&

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:58
> +    MockMediaSample(MockSampleBox box)

Ditto.

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:74
> +class MockMediaDescription : public MediaDescription {

FINAL?

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:76
> +    static RefPtr<MockMediaDescription> create(MockTrackBox box) { return adoptRef(new MockMediaDescription(box)); }

const MockTrackBox&

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:85
> +    MockMediaDescription(MockTrackBox box) : m_box(box) { }

Ditto.

> Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:143
> +        MockTrackBox trackBox = *it;

MockTrackBox&

> Source/WebCore/platform/mock/mediasource/MockTracks.h:40
> +    static RefPtr<MockAudioTrackPrivate> create(MockTrackBox box) { return adoptRef(new MockAudioTrackPrivate(box)); }

const MockTrackBox&

> Source/WebCore/platform/mock/mediasource/MockTracks.h:46
> +    MockAudioTrackPrivate(MockTrackBox box)

Ditto.

> Source/WebCore/platform/mock/mediasource/MockTracks.h:57
> +    static RefPtr<MockTextTrackPrivate> create(MockTrackBox box) { return adoptRef(new MockTextTrackPrivate(box)); }

Ditto.

> Source/WebCore/platform/mock/mediasource/MockTracks.h:63
> +    MockTextTrackPrivate(MockTrackBox box)

Ditto.

> Source/WebCore/platform/mock/mediasource/MockTracks.h:76
> +    static RefPtr<MockVideoTrackPrivate> create(MockTrackBox box) { return adoptRef(new MockVideoTrackPrivate(box)); }

Ditto.

> Source/WebCore/platform/mock/mediasource/MockTracks.h:82
> +    MockVideoTrackPrivate(MockTrackBox box)

Ditto.

> LayoutTests/ChangeLog:71
> +

Four ChangeLog entries?
Comment 3 Jer Noble 2013-11-07 08:52:50 PST
(In reply to comment #2)
> (From update of attachment 215524 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=215524&action=review
> 
> r=me with a few nits.
> 
> > Source/WebCore/platform/graphics/MediaPlayer.cpp:1213
> > +void MediaPlayerFactorySupport::callRegisterMediaEngine(MediaEngineRegister registerMediaEngine)
> 
> "callRegisterMediaEngine" is an odd name for an externally visible method (even though that is what it does).

I agonized over this, but couldn't come up with another name with which I was happy.

> > Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:206
> > +#if ENABLE(MEDIA_SOURCE)
> > +void MediaPlayerPrivateAVFoundation::load(const String&, PassRefPtr<HTMLMediaSource>)
> > +{
> > +    m_networkState = MediaPlayer::FormatError;
> > +    m_player->networkStateChanged();
> > +}
> > +#endif
> 
> This was part of bug 123593.

Removed this and the following dittos.

> > Source/WebCore/platform/mock/mediasource/MockBox.cpp:42
> > +MockBox::MockBox(ArrayBuffer* data)
> > +{
> > +    m_type = peekType(data);
> > +    m_length = peekLength(data);
> > +}
> 
> Should you check that data is big enough for a box?

I added an ASSERT here (and the following dittos).

> > Source/WebCore/platform/mock/mediasource/MockBox.h:70
> > +class MockTrackBox : public MockBox {
> 
> Can this be marked FINAL?

Yes.  And the dittos as well.

> > Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h:38
> > +class MockMediaPlayerMediaSource : public MediaPlayerPrivateInterface {
> 
> Can this be marked FINAL?

No.  Marking it as final (somehow) breaks passing this class into Function objects.

> > Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h:72
> > +    // MediaPlayerPrivate Overrides
> > +    virtual void load(const String& url) OVERRIDE;
> > +    virtual void load(const String& url, PassRefPtr<HTMLMediaSource>) OVERRIDE;
> > +    virtual void cancelLoad() OVERRIDE;
> > +    virtual void play() OVERRIDE;
> > +    virtual void pause() OVERRIDE;
> > +    virtual IntSize naturalSize() const OVERRIDE;
> > +    virtual bool hasVideo() const OVERRIDE;
> > +    virtual bool hasAudio() const OVERRIDE;
> > +    virtual void setVisible(bool) OVERRIDE;
> > +    virtual bool seeking() const OVERRIDE;
> > +    virtual bool paused() const OVERRIDE;
> > +    virtual MediaPlayer::NetworkState networkState() const OVERRIDE;
> > +    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
> > +    virtual PassRefPtr<TimeRanges> buffered() const OVERRIDE;
> > +    virtual bool didLoadingProgress() const OVERRIDE;
> > +    virtual void setSize(const IntSize&) OVERRIDE;
> > +    virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
> > +    virtual double currentTimeDouble() const OVERRIDE;
> > +    virtual double durationDouble() const OVERRIDE;
> > +    virtual void seekDouble(double time) OVERRIDE;
> > +
> > +    void advanceCurrentTime();
> > +    void updateDuration(double);
> > +    void setReadyState(MediaPlayer::ReadyState);
> 
> Can these be made private?

All except for readyState().

> > Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h:81
> > +    bool m_playing;
> 
> Nit: packing.

Sorted.

> > Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp:131
> > +    RefPtr<MockSourceBufferPrivate> sourceBuffer = prpSourceBuffer;
> > +    return sourceBuffer->hasAudio();
> 
> Nit: the local isn't necessary.

Removed.

> > Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp:141
> > +    RefPtr<MockSourceBufferPrivate> sourceBuffer = prpSourceBuffer;
> 
> Ditto.

Ditto.

> > Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h:39
> > +class MockMediaSourcePrivate : public MediaSourcePrivate {
> 
> Can this be marked FINAL?

Yes.

> > Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h:53
> > +    // MediaSourcePrivate Overrides
> > +    virtual AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) OVERRIDE;
> > +    virtual double duration() OVERRIDE;
> > +    virtual void setDuration(double) OVERRIDE;
> > +    virtual void markEndOfStream(EndOfStreamStatus) OVERRIDE;
> > +    virtual void unmarkEndOfStream() OVERRIDE;
> > +    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
> > +    virtual void setReadyState(MediaPlayer::ReadyState) OVERRIDE;
> > +
> > +    const Vector<MockSourceBufferPrivate*>& activeSourceBuffers() const { return m_activeSourceBuffers; }
> 
> Can these be made private?

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:44
> > +class MockMediaSample : public MediaSample {
> 
> FINAL?

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:46
> > +    static RefPtr<MockMediaSample> create(MockSampleBox box) { return adoptRef(new MockMediaSample(box)); }
> 
> const MockSampleBox&

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:58
> > +    MockMediaSample(MockSampleBox box)
> 
> Ditto.

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:74
> > +class MockMediaDescription : public MediaDescription {
> 
> FINAL?

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:76
> > +    static RefPtr<MockMediaDescription> create(MockTrackBox box) { return adoptRef(new MockMediaDescription(box)); }
> 
> const MockTrackBox&

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:85
> > +    MockMediaDescription(MockTrackBox box) : m_box(box) { }
> 
> Ditto.

Yes.

> > Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp:143
> > +        MockTrackBox trackBox = *it;
> 
> MockTrackBox&

const MockTrackBox&.

> > Source/WebCore/platform/mock/mediasource/MockTracks.h:40
> > +    static RefPtr<MockAudioTrackPrivate> create(MockTrackBox box) { return adoptRef(new MockAudioTrackPrivate(box)); }
> 
> const MockTrackBox&

Ok.

> > Source/WebCore/platform/mock/mediasource/MockTracks.h:46
> > +    MockAudioTrackPrivate(MockTrackBox box)
> 
> Ditto.

Ok.

> > Source/WebCore/platform/mock/mediasource/MockTracks.h:57
> > +    static RefPtr<MockTextTrackPrivate> create(MockTrackBox box) { return adoptRef(new MockTextTrackPrivate(box)); }
> 
> Ditto.

Ok.

> > Source/WebCore/platform/mock/mediasource/MockTracks.h:63
> > +    MockTextTrackPrivate(MockTrackBox box)
> 
> Ditto.

Ok.

> > Source/WebCore/platform/mock/mediasource/MockTracks.h:76
> > +    static RefPtr<MockVideoTrackPrivate> create(MockTrackBox box) { return adoptRef(new MockVideoTrackPrivate(box)); }
> 
> Ditto.

Ok.

> > Source/WebCore/platform/mock/mediasource/MockTracks.h:82
> > +    MockVideoTrackPrivate(MockTrackBox box)
> 
> Ditto.

Ok.

> > LayoutTests/ChangeLog:71
> > +
> 
> Four ChangeLog entries?

Removed.
Comment 4 Jer Noble 2013-11-07 08:54:32 PST
Created attachment 216305 [details]
Patch for landing
Comment 5 Jer Noble 2013-11-07 09:10:12 PST
Created attachment 216306 [details]
Patch for landing
Comment 6 EFL EWS Bot 2013-11-07 09:18:48 PST
Comment on attachment 216306 [details]
Patch for landing

Attachment 216306 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/22748239
Comment 7 EFL EWS Bot 2013-11-07 09:21:02 PST
Comment on attachment 216306 [details]
Patch for landing

Attachment 216306 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/22778214
Comment 8 kov's GTK+ EWS bot 2013-11-07 09:21:55 PST
Comment on attachment 216306 [details]
Patch for landing

Attachment 216306 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/22778215
Comment 9 Jer Noble 2013-11-07 09:27:41 PST
Created attachment 216309 [details]
Patch for landing

Fixed the build error in Internals.cpp for ports which do not enable MEDIA_SOURCE.
Comment 10 Jer Noble 2013-11-07 09:56:59 PST
Committed r158853: <http://trac.webkit.org/changeset/158853>