+2013-02-22 Aaron Colwell <acolwell@chromium.org>
+
+ Factor MediaSource methods out of MediaPlayer & MediaPlayerPrivate and into a new MediaSourcePrivate interface.
+ https://bugs.webkit.org/show_bug.cgi?id=109857
+
+ Reviewed by Adam Barth.
+
+ This is a simple refactor that moves MediaSource related methods out of MediaPlayer & MediaPlayerPrivate
+ so that the MediaSource implementation can be updated without further polluting these interfaces.
+ MediaSourcePrivate is the new WebCore interface that ports must implement to support the MediaSource API.
+
+ No new tests. No user visible behavior has changed.
+
+ * Modules/mediasource/MediaSource.cpp:
+ (WebCore::MediaSource::MediaSource):
+ (WebCore::MediaSource::duration):
+ (WebCore::MediaSource::setDuration):
+ (WebCore::MediaSource::addSourceBuffer):
+ (WebCore::MediaSource::removeSourceBuffer):
+ (WebCore::MediaSource::setReadyState):
+ (WebCore::MediaSource::endOfStream):
+ (WebCore::MediaSource::buffered):
+ (WebCore::MediaSource::append):
+ (WebCore::MediaSource::abort):
+ (WebCore::MediaSource::setTimestampOffset):
+ (WebCore::MediaSource::setPrivateAndOpen):
+ (WebCore):
+ (WebCore::MediaSource::hasPendingActivity):
+ (WebCore::MediaSource::stop):
+ * Modules/mediasource/MediaSource.h:
+ (MediaSource):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement):
+ (WebCore::HTMLMediaElement::loadResource):
+ (WebCore::HTMLMediaElement::createMediaPlayer):
+ (WebCore::HTMLMediaElement::reportMemoryUsage):
+ * html/HTMLMediaElement.h:
+ (HTMLMediaElement):
+ * platform/graphics/MediaPlayer.cpp:
+ (NullMediaPlayerPrivate):
+ (WebCore::NullMediaPlayerPrivate::load):
+ (WebCore::MediaPlayer::load):
+ (WebCore):
+ (WebCore::MediaPlayer::loadWithNextMediaEngine):
+ * platform/graphics/MediaPlayer.h:
+ (WebCore):
+ (MediaPlayerClient):
+ (MediaPlayer):
+ * platform/graphics/MediaPlayerPrivate.h:
+ (MediaPlayerPrivateInterface):
+ * platform/graphics/MediaSourcePrivate.h: Added.
+ (WebCore):
+ (MediaSourcePrivate): Contains the MediaSource methods extracted from MediaPlayer.
+ (WebCore::MediaSourcePrivate::MediaSourcePrivate):
+ (WebCore::MediaSourcePrivate::~MediaSourcePrivate):
+
2013-02-22 Beth Dakin <bdakin@apple.com>
RenderLayer::scrollTo() should call FrameLoaderClient::didChangeScrollOffset()
MediaSource::MediaSource(ScriptExecutionContext* context)
: ActiveDOMObject(context, this)
, m_readyState(closedKeyword())
- , m_player(0)
, m_asyncEventQueue(GenericEventQueue::create(this))
{
m_sourceBuffers = SourceBufferList::create(scriptExecutionContext(), m_asyncEventQueue.get());
double MediaSource::duration() const
{
- return m_readyState == closedKeyword() ? std::numeric_limits<float>::quiet_NaN() : m_player->duration();
+ return m_readyState == closedKeyword() ? std::numeric_limits<float>::quiet_NaN() : m_private->duration();
}
void MediaSource::setDuration(double duration, ExceptionCode& ec)
ec = INVALID_STATE_ERR;
return;
}
- m_player->sourceSetDuration(duration);
+ m_private->setDuration(duration);
}
SourceBuffer* MediaSource::addSourceBuffer(const String& type, ExceptionCode& ec)
// 4. If the readyState attribute is not in the "open" state then throw an
// INVALID_STATE_ERR exception and abort these steps.
- if (!m_player || m_readyState != openKeyword()) {
+ if (!m_private || m_readyState != openKeyword()) {
ec = INVALID_STATE_ERR;
return 0;
}
RefPtr<SourceBuffer> buffer = SourceBuffer::create(id, this);
- switch (m_player->sourceAddId(buffer->id(), contentType.type(), codecs)) {
- case MediaPlayer::Ok:
+ switch (m_private->addId(buffer->id(), contentType.type(), codecs)) {
+ case MediaSourcePrivate::Ok:
// 6. Add the new object to sourceBuffers and fire a addsourcebuffer on that object.
m_sourceBuffers->add(buffer);
m_activeSourceBuffers->add(buffer);
// 7. Return the new object to the caller.
return buffer.get();
- case MediaPlayer::NotSupported:
+ case MediaSourcePrivate::NotSupported:
// 2 (cont). If type contains a MIME type ... that is not supported with the types
// specified for the other SourceBuffer objects in sourceBuffers, then throw
// a NOT_SUPPORTED_ERR exception and abort these steps.
ec = NOT_SUPPORTED_ERR;
return 0;
- case MediaPlayer::ReachedIdLimit:
+ case MediaSourcePrivate::ReachedIdLimit:
// 3 (cont). If the user agent can't handle any more SourceBuffer objects then throw
// a QUOTA_EXCEEDED_ERR exception and abort these steps.
ec = QUOTA_EXCEEDED_ERR;
// 2. If sourceBuffers is empty then throw an INVALID_STATE_ERR exception and
// abort these steps.
- if (!m_player || !m_sourceBuffers->length()) {
+ if (!m_private || !m_sourceBuffers->length()) {
ec = INVALID_STATE_ERR;
return;
}
// 7. Destroy all resources for sourceBuffer.
m_activeSourceBuffers->remove(buffer);
- m_player->sourceRemoveId(buffer->id());
+ m_private->removeId(buffer->id());
// 4. Remove track information from audioTracks, videoTracks, and textTracks for all tracks
// associated with sourceBuffer and fire a simple event named change on the modified lists.
if (m_readyState == closedKeyword()) {
m_sourceBuffers->clear();
m_activeSourceBuffers->clear();
- m_player = 0;
+ m_private.clear();
scheduleEvent(eventNames().webkitsourcecloseEvent);
return;
}
// 3.1 http://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html#dom-endofstream
// 1. If the readyState attribute is not in the "open" state then throw an
// INVALID_STATE_ERR exception and abort these steps.
- if (!m_player || m_readyState != openKeyword()) {
+ if (!m_private || m_readyState != openKeyword()) {
ec = INVALID_STATE_ERR;
return;
}
- MediaPlayer::EndOfStreamStatus eosStatus = MediaPlayer::EosNoError;
+ MediaSourcePrivate::EndOfStreamStatus eosStatus = MediaSourcePrivate::EosNoError;
if (error.isNull() || error.isEmpty())
- eosStatus = MediaPlayer::EosNoError;
+ eosStatus = MediaSourcePrivate::EosNoError;
else if (error == "network")
- eosStatus = MediaPlayer::EosNetworkError;
+ eosStatus = MediaSourcePrivate::EosNetworkError;
else if (error == "decode")
- eosStatus = MediaPlayer::EosDecodeError;
+ eosStatus = MediaSourcePrivate::EosDecodeError;
else {
ec = INVALID_ACCESS_ERR;
return;
// 2. Change the readyState attribute value to "ended".
setReadyState(endedKeyword());
- m_player->sourceEndOfStream(eosStatus);
+ m_private->endOfStream(eosStatus);
}
PassRefPtr<TimeRanges> MediaSource::buffered(const String& id, ExceptionCode& ec) const
{
- if (!m_player || m_readyState == closedKeyword()) {
+ if (!m_private || m_readyState == closedKeyword()) {
ec = INVALID_STATE_ERR;
return 0;
}
- return m_player->sourceBuffered(id);
+ return m_private->buffered(id);
}
void MediaSource::append(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode& ec)
return;
}
- if (!m_player || m_readyState == closedKeyword()) {
+ if (!m_private || m_readyState == closedKeyword()) {
ec = INVALID_STATE_ERR;
return;
}
if (m_readyState == endedKeyword())
setReadyState(openKeyword());
- if (!m_player->sourceAppend(id, data->data(), data->length())) {
+ if (!m_private->append(id, data->data(), data->length())) {
ec = SYNTAX_ERR;
return;
}
void MediaSource::abort(const String& id, ExceptionCode& ec)
{
- if (!m_player || m_readyState != openKeyword()) {
+ if (!m_private || m_readyState != openKeyword()) {
ec = INVALID_STATE_ERR;
return;
}
- if (!m_player->sourceAbort(id))
+ if (!m_private->abort(id))
ASSERT_NOT_REACHED();
}
bool MediaSource::setTimestampOffset(const String& id, double offset, ExceptionCode& ec)
{
- if (!m_player || m_readyState == closedKeyword()) {
+ if (!m_private || m_readyState == closedKeyword()) {
ec = INVALID_STATE_ERR;
return false;
}
- if (!m_player->sourceSetTimestampOffset(id, offset)) {
+ if (!m_private->setTimestampOffset(id, offset)) {
ec = INVALID_STATE_ERR;
return false;
}
return true;
}
+void MediaSource::setPrivateAndOpen(PassOwnPtr<MediaSourcePrivate> mediaSourcePrivate)
+{
+ ASSERT(mediaSourcePrivate);
+ ASSERT(!m_private);
+ m_private = mediaSourcePrivate;
+ setReadyState(openKeyword());
+}
+
const AtomicString& MediaSource::interfaceName() const
{
return eventNames().interfaceForMediaSource;
bool MediaSource::hasPendingActivity() const
{
- return m_player || m_asyncEventQueue->hasPendingEvents()
+ return m_private || m_asyncEventQueue->hasPendingEvents()
|| ActiveDOMObject::hasPendingActivity();
}
void MediaSource::stop()
{
- m_player = 0;
+ m_private.clear();
m_asyncEventQueue->cancelAllEvents();
}
#include "ActiveDOMObject.h"
#include "GenericEventQueue.h"
-#include "MediaPlayer.h"
+#include "MediaSourcePrivate.h"
#include "SourceBuffer.h"
#include "SourceBufferList.h"
#include <wtf/RefCounted.h>
void endOfStream(const String& error, ExceptionCode&);
- void setMediaPlayer(MediaPlayer* player) { m_player = player; }
+ void setPrivateAndOpen(PassOwnPtr<MediaSourcePrivate>);
PassRefPtr<TimeRanges> buffered(const String& id, ExceptionCode&) const;
void append(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode&);
EventTargetData m_eventTargetData;
String m_readyState;
- MediaPlayer* m_player;
+ OwnPtr<MediaSourcePrivate> m_private;
RefPtr<SourceBufferList> m_sourceBuffers;
RefPtr<SourceBufferList> m_activeSourceBuffers;
addBehaviorRestriction(RequireUserGestureForLoadRestriction);
}
-#if ENABLE(MEDIA_SOURCE)
- m_mediaSourceURL.setProtocol(mediaSourceBlobProtocol);
- m_mediaSourceURL.setPath(createCanonicalUUIDString());
-#endif
-
setHasCustomStyleCallbacks();
addElementToDocumentMap(this, document);
return;
}
-#if ENABLE(MEDIA_SOURCE)
- ASSERT(!m_mediaSource);
-
- if (url.protocolIs(mediaSourceBlobProtocol)) {
- m_mediaSource = MediaSourceRegistry::registry().lookupMediaSource(url.string());
-
- if (m_mediaSource) {
- m_mediaSource->setMediaPlayer(m_player.get());
- m_mediaSourceURL = url;
- }
- }
-#endif
-
// The resource fetch algorithm
m_networkState = NETWORK_LOADING;
m_muted = true;
updateVolume();
+#if ENABLE(MEDIA_SOURCE)
+ ASSERT(!m_mediaSource);
+
+ if (url.protocolIs(mediaSourceBlobProtocol))
+ m_mediaSource = MediaSourceRegistry::registry().lookupMediaSource(url.string());
+
+ if (m_mediaSource) {
+ if (!m_player->load(url, m_mediaSource))
+ mediaLoadingFailed(MediaPlayer::FormatError);
+ } else
+#endif
if (!m_player->load(url, contentType, keySystem))
mediaLoadingFailed(MediaPlayer::FormatError);
#endif
}
-#if ENABLE(MEDIA_SOURCE)
-void HTMLMediaElement::mediaPlayerSourceOpened()
-{
- beginProcessingMediaPlayerCallback();
-
- setSourceState(MediaSource::openKeyword());
-
- endProcessingMediaPlayerCallback();
-}
-
-String HTMLMediaElement::mediaPlayerSourceURL() const
-{
- return m_mediaSourceURL.string();
-}
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
void HTMLMediaElement::mediaPlayerKeyAdded(MediaPlayer*, const String& keySystem, const String& sessionId)
{
m_audioSourceNode->lock();
#endif
- m_player = MediaPlayer::create(this);
-
#if ENABLE(MEDIA_SOURCE)
if (m_mediaSource)
- m_mediaSource->setMediaPlayer(m_player.get());
+ m_mediaSource->setReadyState(MediaSource::closedKeyword());
#endif
+ m_player = MediaPlayer::create(this);
+
#if ENABLE(WEB_AUDIO)
if (m_audioSourceNode) {
// When creating the player, make sure its AudioSourceProvider knows about the MediaElementAudioSourceNode.
info.addMember(m_proxyWidget, "proxyWidget");
#endif
#if ENABLE(MEDIA_SOURCE)
- info.addMember(m_mediaSourceURL, "mediaSourceURL");
info.addMember(m_mediaSource, "mediaSource");
#endif
#if ENABLE(VIDEO_TRACK)
virtual void mediaPlayerFirstVideoFrameAvailable(MediaPlayer*);
virtual void mediaPlayerCharacteristicChanged(MediaPlayer*);
-#if ENABLE(MEDIA_SOURCE)
- virtual void mediaPlayerSourceOpened();
- virtual String mediaPlayerSourceURL() const;
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
virtual void mediaPlayerKeyAdded(MediaPlayer*, const String& keySystem, const String& sessionId) OVERRIDE;
virtual void mediaPlayerKeyError(MediaPlayer*, const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode) OVERRIDE;
int m_processingMediaPlayerCallback;
#if ENABLE(MEDIA_SOURCE)
- KURL m_mediaSourceURL;
RefPtr<MediaSource> m_mediaSource;
#endif
#include "InbandTextTrackPrivate.h"
#endif
+#if ENABLE(MEDIA_SOURCE)
+#include "MediaSource.h"
+#endif
+
#if PLATFORM(QT)
#include <QtGlobal>
#endif
NullMediaPlayerPrivate(MediaPlayer*) { }
virtual void load(const String&) { }
+#if ENABLE(MEDIA_SOURCE)
+ virtual void load(const String&, PassRefPtr<MediaSource>) { }
+#endif
virtual void cancelLoad() { }
virtual void prepareToPlay() { }
virtual bool hasSingleSecurityOrigin() const { return true; }
-#if ENABLE(MEDIA_SOURCE)
- virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
- virtual PassRefPtr<TimeRanges> sourceBuffered(const String&) { return TimeRanges::create(); }
- virtual bool sourceRemoveId(const String&) { return false; }
- virtual bool sourceAppend(const String&, const unsigned char*, unsigned) { return false; }
- virtual bool sourceAbort(const String&) { return false; }
- virtual void sourceSetDuration(double) { }
- virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { }
- virtual bool sourceSetTimestampOffset(const String&, double) { return false; }
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
virtual MediaPlayer::MediaKeyException generateKeyRequest(const String&, const unsigned char*, unsigned) OVERRIDE { return MediaPlayer::InvalidPlayerState; }
virtual MediaPlayer::MediaKeyException addKey(const String&, const unsigned char*, unsigned, const unsigned char*, unsigned, const String&) OVERRIDE { return MediaPlayer::InvalidPlayerState; }
m_keySystem = keySystem.lower();
m_contentMIMETypeWasInferredFromExtension = false;
+#if ENABLE(MEDIA_SOURCE)
+ m_mediaSource = 0;
+#endif
+
// If the MIME type is missing or is not meaningful, try to figure it out from the URL.
if (m_contentMIMEType.isEmpty() || m_contentMIMEType == applicationOctetStream() || m_contentMIMEType == textPlain()) {
if (m_url.protocolIsData())
return m_currentMediaEngine;
}
+#if ENABLE(MEDIA_SOURCE)
+bool MediaPlayer::load(const KURL& url, PassRefPtr<MediaSource> mediaSource)
+{
+ m_mediaSource = mediaSource;
+ m_contentMIMEType = "";
+ m_contentTypeCodecs = "";
+ m_url = url;
+ m_keySystem = "";
+ m_contentMIMETypeWasInferredFromExtension = false;
+ loadWithNextMediaEngine(0);
+ return m_currentMediaEngine;
+}
+#endif
+
void MediaPlayer::loadWithNextMediaEngine(MediaPlayerFactory* current)
{
MediaPlayerFactory* engine = 0;
m_private->prepareForRendering();
}
- if (m_private)
+ if (m_private) {
+#if ENABLE(MEDIA_SOURCE)
+ if (m_mediaSource)
+ m_private->load(m_url.string(), m_mediaSource);
+ else
+#endif
m_private->load(m_url.string());
- else {
+ } else {
m_private = createNullMediaPlayer(this);
if (m_mediaPlayerClient) {
m_mediaPlayerClient->mediaPlayerEngineUpdated(this);
m_private->pause();
}
-#if ENABLE(MEDIA_SOURCE)
-
-MediaPlayer::AddIdStatus MediaPlayer::sourceAddId(const String& id, const String& type, const Vector<String>& codecs)
-{
- return m_private->sourceAddId(id, type, codecs);
-}
-
-PassRefPtr<TimeRanges> MediaPlayer::sourceBuffered(const String& id)
-{
- return m_private->sourceBuffered(id);
-}
-
-bool MediaPlayer::sourceRemoveId(const String& id)
-{
- return m_private->sourceRemoveId(id);
-}
-
-bool MediaPlayer::sourceAppend(const String& id, const unsigned char* data, unsigned length)
-{
- return m_private->sourceAppend(id, data, length);
-}
-
-bool MediaPlayer::sourceAbort(const String& id)
-{
- return m_private->sourceAbort(id);
-}
-
-void MediaPlayer::sourceSetDuration(double duration)
-{
- m_private->sourceSetDuration(duration);
-}
-
-void MediaPlayer::sourceEndOfStream(MediaPlayer::EndOfStreamStatus status)
-{
- return m_private->sourceEndOfStream(status);
-}
-
-bool MediaPlayer::sourceSetTimestampOffset(const String& id, double offset)
-{
- return m_private->sourceSetTimestampOffset(id, offset);
-}
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
MediaPlayer::MediaKeyException MediaPlayer::generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength)
{
m_private->setPrivateBrowsingMode(m_privateBrowsing);
}
-#if ENABLE(MEDIA_SOURCE)
-void MediaPlayer::sourceOpened()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerSourceOpened();
-}
-
-String MediaPlayer::sourceURL() const
-{
- if (m_mediaPlayerClient)
- return m_mediaPlayerClient->mediaPlayerSourceURL();
- return String();
-}
-#endif
-
// Client callbacks.
void MediaPlayer::networkStateChanged()
{
class Document;
class GStreamerGWorld;
class MediaPlayerPrivateInterface;
+#if ENABLE(MEDIA_SOURCE)
class MediaSource;
+#endif
class TextTrackRepresentation;
// Structure that will hold every native
virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const { return 0; }
#endif
-#if ENABLE(MEDIA_SOURCE)
- virtual void mediaPlayerSourceOpened() { }
- virtual String mediaPlayerSourceURL() const { return "x-media-source-unsupported:"; }
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
enum MediaKeyErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError, HardwareChangeError, DomainError };
virtual void mediaPlayerKeyAdded(MediaPlayer*, const String& /* keySystem */, const String& /* sessionId */) { }
void setSize(const IntSize& size);
bool load(const KURL&, const ContentType&, const String& keySystem);
+#if ENABLE(MEDIA_SOURCE)
+ bool load(const KURL&, PassRefPtr<MediaSource>);
+#endif
void cancelLoad();
bool visible() const;
void play();
void pause();
-#if ENABLE(MEDIA_SOURCE)
- enum AddIdStatus { Ok, NotSupported, ReachedIdLimit };
- AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs);
- bool sourceRemoveId(const String& id);
- PassRefPtr<TimeRanges> sourceBuffered(const String& id);
- bool sourceAppend(const String& id, const unsigned char* data, unsigned length);
- void sourceSetDuration(double);
- bool sourceAbort(const String& id);
- enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
- void sourceEndOfStream(EndOfStreamStatus);
- bool sourceSetTimestampOffset(const String& id, double offset);
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
// Represents synchronous exceptions that can be thrown from the Encrypted Media methods.
// This is different from the asynchronous MediaKeyError.
AudioSourceProvider* audioSourceProvider();
#endif
-#if ENABLE(MEDIA_SOURCE)
- void sourceOpened();
- String sourceURL() const;
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
void keyAdded(const String& keySystem, const String& sessionId);
void keyError(const String& keySystem, const String& sessionId, MediaPlayerClient::MediaKeyErrorCode, unsigned short systemCode);
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
WebMediaPlayerProxy* m_playerProxy; // not owned or used, passed to m_private
#endif
+
+#if ENABLE(MEDIA_SOURCE)
+ RefPtr<MediaSource> m_mediaSource;
+#endif
};
typedef PassOwnPtr<MediaPlayerPrivateInterface> (*CreateMediaEnginePlayer)(MediaPlayer*);
virtual ~MediaPlayerPrivateInterface() { }
virtual void load(const String& url) = 0;
+#if ENABLE(MEDIA_SOURCE)
+ virtual void load(const String& url, PassRefPtr<MediaSource>) = 0;
+#endif
virtual void cancelLoad() = 0;
virtual void prepareToPlay() { }
virtual AudioSourceProvider* audioSourceProvider() { return 0; }
#endif
-#if ENABLE(MEDIA_SOURCE)
- virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
- virtual PassRefPtr<TimeRanges> sourceBuffered(const String& id) { return TimeRanges::create(); }
- virtual bool sourceRemoveId(const String& id) { return false; }
- virtual bool sourceAppend(const String& id, const unsigned char* data, unsigned length) { return false; }
- virtual bool sourceAbort(const String& id) { return false; }
- virtual void sourceSetDuration(double) { }
- virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { }
- virtual bool sourceSetTimestampOffset(const String& id, double offset) { return false; }
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
virtual MediaPlayer::MediaKeyException addKey(const String&, const unsigned char*, unsigned, const unsigned char*, unsigned, const String&) { return MediaPlayer::KeySystemNotSupported; }
virtual MediaPlayer::MediaKeyException generateKeyRequest(const String&, const unsigned char*, unsigned) { return MediaPlayer::KeySystemNotSupported; }
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef MediaSourcePrivate_h
+#define MediaSourcePrivate_h
+
+#if ENABLE(MEDIA_SOURCE)
+
+#include "TimeRanges.h"
+
+namespace WebCore {
+
+class MediaSourcePrivate {
+ WTF_MAKE_NONCOPYABLE(MediaSourcePrivate); WTF_MAKE_FAST_ALLOCATED;
+public:
+ MediaSourcePrivate() { }
+ virtual ~MediaSourcePrivate() { }
+
+ enum AddIdStatus { Ok, NotSupported, ReachedIdLimit };
+ virtual AddIdStatus addId(const String& id, const String& type, const Vector<String>& codecs) = 0;
+ virtual bool removeId(const String& id) = 0;
+ virtual PassRefPtr<TimeRanges> buffered(const String& id) = 0;
+ virtual bool append(const String& id, const unsigned char* data, unsigned length) = 0;
+ virtual double duration() = 0;
+ virtual void setDuration(double) = 0;
+ virtual bool abort(const String& id) = 0;
+ enum EndOfStreamStatus { EosNoError, EosNetworkError, EosDecodeError };
+ virtual void endOfStream(EndOfStreamStatus) = 0;
+ virtual bool setTimestampOffset(const String& id, double offset) = 0;
+};
+
+}
+
+#endif
+#endif
+2013-02-22 Aaron Colwell <acolwell@chromium.org>
+
+ Factor MediaSource methods out of MediaPlayer & MediaPlayerPrivate and into a new MediaSourcePrivate interface.
+ https://bugs.webkit.org/show_bug.cgi?id=109857
+
+ Reviewed by Adam Barth.
+
+ WebMediaSource and WebMediaSource client were created to replace the MediaSource methods in WebMediaPlayer and
+ WebMediaPlayerClient. This allows the MediaSource implementation to be updated without further polluting the
+ media player interfaces.
+
+ * WebKit.gyp:
+ * public/WebMediaPlayer.h:
+ (WebMediaPlayer):
+ (WebKit::WebMediaPlayer::load):
+ * public/WebMediaPlayerClient.h:
+ (WebKit):
+ * public/WebMediaSource.h: Added.
+ (WebKit):
+ (WebMediaSource):
+ (WebKit::WebMediaSource::~WebMediaSource):
+ * public/WebMediaSourceClient.h: Added.
+ (WebKit):
+ (WebMediaSourceClient):
+ (WebKit::WebMediaSourceClient::~WebMediaSourceClient):
+ * src/AssertMatchingEnums.cpp:
+ * src/WebMediaPlayerClientImpl.cpp:
+ (WebKit):
+ (WebMediaSourceClientImpl): Temporary WebMediaSourceClient implementation to keep things working until Chromium
+ changes land.
+ (WebKit::WebMediaSourceClientImpl::WebMediaSourceClientImpl):
+ (WebKit::WebMediaSourceClientImpl::~WebMediaSourceClientImpl):
+ (WebKit::WebMediaSourceClientImpl::addId):
+ (WebKit::WebMediaSourceClientImpl::removeId):
+ (WebKit::WebMediaSourceClientImpl::buffered):
+ (WebKit::WebMediaSourceClientImpl::append):
+ (WebKit::WebMediaSourceClientImpl::abort):
+ (WebKit::WebMediaSourceClientImpl::duration):
+ (WebKit::WebMediaSourceClientImpl::setDuration):
+ (WebKit::WebMediaSourceClientImpl::endOfStream):
+ (WebKit::WebMediaSourceClientImpl::setTimestampOffset):
+ (WebKit::WebMediaPlayerClientImpl::sourceOpened):
+ (WebKit::WebMediaPlayerClientImpl::sourceURL):
+ (WebKit::WebMediaPlayerClientImpl::load):
+ (WebKit::WebMediaPlayerClientImpl::loadRequested):
+ (WebKit::WebMediaPlayerClientImpl::loadInternal):
+ * src/WebMediaPlayerClientImpl.h:
+ (WebMediaPlayerClientImpl):
+ * src/WebMediaSourceImpl.cpp: Added.
+ (WebKit):
+ (MediaSourcePrivateImpl):
+ (WebKit::MediaSourcePrivateImpl::~MediaSourcePrivateImpl):
+ (WebKit::MediaSourcePrivateImpl::MediaSourcePrivateImpl):
+ (WebKit::MediaSourcePrivateImpl::addId):
+ (WebKit::MediaSourcePrivateImpl::removeId):
+ (WebKit::MediaSourcePrivateImpl::buffered):
+ (WebKit::MediaSourcePrivateImpl::append):
+ (WebKit::MediaSourcePrivateImpl::abort):
+ (WebKit::MediaSourcePrivateImpl::duration):
+ (WebKit::MediaSourcePrivateImpl::setDuration):
+ (WebKit::MediaSourcePrivateImpl::endOfStream):
+ (WebKit::MediaSourcePrivateImpl::setTimestampOffset):
+ (WebKit::WebMediaSourceImpl::WebMediaSourceImpl):
+ (WebKit::WebMediaSourceImpl::~WebMediaSourceImpl):
+ (WebKit::WebMediaSourceImpl::open):
+ * src/WebMediaSourceImpl.h: Added.
+ (WebKit):
+ (WebMediaSourceImpl):
+
2013-02-22 Alec Flett <alecflett@chromium.org>
IndexedDB: Remove old SerializedScriptValue-based get() callbacks
'public/WebMediaPlayer.h',
'public/WebMediaPlayerAction.h',
'public/WebMediaPlayerClient.h',
+ 'public/WebMediaSource.h',
+ 'public/WebMediaSourceClient.h',
'public/WebMediaStreamRegistry.h',
'public/WebMemoryUsageInfo.h',
'public/WebMenuItemInfo.h',
'src/WebLabelElement.cpp',
'src/WebMediaPlayerClientImpl.cpp',
'src/WebMediaPlayerClientImpl.h',
+ 'src/WebMediaSourceImpl.cpp',
+ 'src/WebMediaSourceImpl.h',
'src/WebMediaStreamRegistry.cpp',
'src/WebNetworkStateNotifier.cpp',
'src/WebNode.cpp',
#include "../../../Platform/chromium/public/WebCanvas.h"
#include "../../../Platform/chromium/public/WebString.h"
+#include "WebMediaSource.h"
#include "WebTimeRange.h"
#include "WebVideoFrame.h"
virtual ~WebMediaPlayer() {}
virtual void load(const WebURL&, CORSMode) = 0;
+ // FIXME: Remove the default implementation once the Chromium code implements this method.
+ // https://bugs.webkit.org/show_bug.cgi?id=110371
+ virtual void load(const WebURL& url, WebMediaSource* mediaSource, CORSMode corsMode) { delete mediaSource; load(url, corsMode); };
virtual void cancelLoad() = 0;
// Playback controls.
namespace WebKit {
class WebFrame;
+class WebMediaSource;
class WebPlugin;
class WebRequest;
class WebURL;
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebMediaSource_h
+#define WebMediaSource_h
+
+#include "../../../Platform/chromium/public/WebURL.h"
+#include "WebTimeRange.h"
+
+namespace WebKit {
+
+class WebMediaSourceClient;
+
+class WebMediaSource {
+public:
+ virtual ~WebMediaSource() { };
+ virtual void open(WebMediaSourceClient*) = 0;
+};
+
+} // namespace WebKit
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebMediaSourceClient_h
+#define WebMediaSourceClient_h
+
+#include "../../../Platform/chromium/public/WebString.h"
+#include "WebTimeRange.h"
+
+namespace WebKit {
+
+class WebMediaSourceClient {
+public:
+ enum AddIdStatus {
+ AddIdStatusOk,
+ AddIdStatusNotSupported,
+ AddIdStatusReachedIdLimit
+ };
+
+ enum EndOfStreamStatus {
+ EndOfStreamStatusNoError,
+ EndOfStreamStatusNetworkError,
+ EndOfStreamStatusDecodeError,
+ };
+
+ virtual ~WebMediaSourceClient() { }
+
+ virtual AddIdStatus addId(const WebString& id, const WebString& type, const WebVector<WebString>& codecs) = 0;
+ virtual bool removeId(const WebString& id) = 0;
+ virtual WebTimeRanges buffered(const WebString& id) = 0;
+ virtual bool append(const WebString& id, const unsigned char* data, unsigned length) = 0;
+ virtual bool abort(const WebString& id) = 0;
+ virtual double duration() = 0;
+ virtual void setDuration(double) = 0;
+ virtual void endOfStream(EndOfStreamStatus) = 0;
+ virtual bool setTimestampOffset(const WebString& id, double offset) = 0;
+};
+
+} // namespace WebKit
+
+#endif
#include "IDBMetadata.h"
#include "IconURL.h"
#include "MediaPlayer.h"
+#if ENABLE(MEDIA_SOURCE)
+#include "MediaSourcePrivate.h"
+#endif
#include "MediaStreamSource.h"
#include "NotificationClient.h"
#include "PageVisibilityState.h"
#include "WebInputElement.h"
#include "WebMediaPlayer.h"
#include "WebMediaPlayerClient.h"
+#include "WebMediaSourceClient.h"
#include "WebNotificationPresenter.h"
#include "WebPageVisibilityState.h"
#include "WebSettings.h"
COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::PreloadAuto, MediaPlayer::Auto);
#if ENABLE(MEDIA_SOURCE)
-COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::AddIdStatusOk, MediaPlayer::Ok);
-COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::AddIdStatusNotSupported, MediaPlayer::NotSupported);
-COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::AddIdStatusReachedIdLimit, MediaPlayer::ReachedIdLimit);
-#endif
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::AddIdStatusOk, MediaSourcePrivate::Ok);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::AddIdStatusNotSupported, MediaSourcePrivate::NotSupported);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::AddIdStatusReachedIdLimit, MediaSourcePrivate::ReachedIdLimit);
-#if ENABLE(ENCRYPTED_MEDIA)
-COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::EndOfStreamStatusNoError, MediaPlayer::EosNoError);
-COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::EndOfStreamStatusNetworkError, MediaPlayer::EosNetworkError);
-COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::EndOfStreamStatusDecodeError, MediaPlayer::EosDecodeError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::EndOfStreamStatusNoError, MediaSourcePrivate::EosNoError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::EndOfStreamStatusNetworkError, MediaSourcePrivate::EosNetworkError);
+COMPILE_ASSERT_MATCHING_ENUM(WebMediaSourceClient::EndOfStreamStatusDecodeError, MediaSourcePrivate::EosDecodeError);
#endif
#if ENABLE(ENCRYPTED_MEDIA)
#include "WebFrameImpl.h"
#include "WebHelperPluginImpl.h"
#include "WebMediaPlayer.h"
+#include "WebMediaSourceClient.h"
+#include "WebMediaSourceImpl.h"
#include "WebViewImpl.h"
#include <public/Platform.h>
#include <public/WebCString.h>
namespace WebKit {
+// FIXME: Remove this class once the Chromium code implements its own
+// version of WebMediaPlayer::load(WebURL, WebMediaSource, CORSMode).
+// https://bugs.webkit.org/show_bug.cgi?id=110371
+class WebMediaSourceClientImpl : public WebMediaSourceClient {
+public:
+ explicit WebMediaSourceClientImpl(WebMediaPlayer*);
+ virtual ~WebMediaSourceClientImpl();
+
+ // WebMediaSourceClient methods.
+ virtual AddIdStatus addId(const WebString& id, const WebString& type, const WebVector<WebString>& codecs);
+ virtual bool removeId(const WebString& id);
+ virtual WebTimeRanges buffered(const WebString& id);
+ virtual bool append(const WebString& id, const unsigned char* data, unsigned length);
+ virtual bool abort(const WebString& id);
+ virtual double duration();
+ virtual void setDuration(double);
+ virtual void endOfStream(EndOfStreamStatus);
+ virtual bool setTimestampOffset(const WebString& id, double offset);
+
+private:
+ WebMediaPlayer* m_webMediaPlayer;
+};
+
+WebMediaSourceClientImpl::WebMediaSourceClientImpl(WebMediaPlayer* webMediaPlayer)
+ : m_webMediaPlayer(webMediaPlayer)
+{
+}
+
+WebMediaSourceClientImpl::~WebMediaSourceClientImpl()
+{
+}
+
+WebMediaSourceClient::AddIdStatus WebMediaSourceClientImpl::addId(const WebString& id, const WebString& type, const WebVector<WebString>& codecs)
+{
+ return static_cast<WebMediaSourceClient::AddIdStatus>(m_webMediaPlayer->sourceAddId(id, type, codecs));
+}
+
+bool WebMediaSourceClientImpl::removeId(const WebString& id)
+{
+ return m_webMediaPlayer->sourceRemoveId(id);
+}
+
+WebTimeRanges WebMediaSourceClientImpl::buffered(const WebString& id)
+{
+ return m_webMediaPlayer->sourceBuffered(id);
+}
+
+bool WebMediaSourceClientImpl::append(const WebString& id, const unsigned char* data, unsigned length)
+{
+ return m_webMediaPlayer->sourceAppend(id, data, length);
+}
+
+bool WebMediaSourceClientImpl::abort(const WebString& id)
+{
+ return m_webMediaPlayer->sourceAbort(id);
+}
+
+double WebMediaSourceClientImpl::duration()
+{
+ return m_webMediaPlayer->duration();
+}
+
+void WebMediaSourceClientImpl::setDuration(double duration)
+{
+ return m_webMediaPlayer->sourceSetDuration(duration);
+}
+
+void WebMediaSourceClientImpl::endOfStream(EndOfStreamStatus status)
+{
+ m_webMediaPlayer->sourceEndOfStream(static_cast<WebMediaPlayer::EndOfStreamStatus>(status));
+}
+
+bool WebMediaSourceClientImpl::setTimestampOffset(const WebString& id, double offset)
+{
+ return m_webMediaPlayer->sourceSetTimestampOffset(id, offset);
+}
+
static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* client, const WebURL& url, Frame* frame)
{
WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
return static_cast<WebMediaPlayer::Preload>(m_preload);
}
+// FIXME: Remove this and sourceURL() once the Chromium code implements
+// its own version of WebMediaPlayer::load(WebURL, WebMediaSource, CORSMode).
+// https://bugs.webkit.org/show_bug.cgi?id=110371
void WebMediaPlayerClientImpl::sourceOpened()
{
#if ENABLE(MEDIA_SOURCE)
- ASSERT(m_mediaPlayer);
- m_mediaPlayer->sourceOpened();
+ ASSERT(m_webMediaPlayer);
+ if (m_mediaSource) {
+ OwnPtr<WebMediaSource> mediaSource = adoptPtr(new WebMediaSourceImpl(m_mediaSource));
+ mediaSource->open(new WebMediaSourceClientImpl(m_webMediaPlayer.get()));
+ }
#endif
}
WebKit::WebURL WebMediaPlayerClientImpl::sourceURL() const
{
#if ENABLE(MEDIA_SOURCE)
- ASSERT(m_mediaPlayer);
- return KURL(ParsedURLString, m_mediaPlayer->sourceURL());
-#else
- return KURL();
+ if (m_mediaSource)
+ return m_url;
#endif
+ return KURL();
}
void WebMediaPlayerClientImpl::keyAdded(const WebString& keySystem, const WebString& sessionId)
void WebMediaPlayerClientImpl::load(const String& url)
{
- m_url = url;
+ m_url = KURL(ParsedURLString, url);
+#if ENABLE(MEDIA_SOURCE)
+ m_mediaSource = 0;
+#endif
+ loadRequested();
+}
+#if ENABLE(MEDIA_SOURCE)
+void WebMediaPlayerClientImpl::load(const String& url, PassRefPtr<WebCore::MediaSource> mediaSource)
+{
+ m_url = KURL(ParsedURLString, url);
+ m_mediaSource = mediaSource;
+ loadRequested();
+}
+#endif
+
+void WebMediaPlayerClientImpl::loadRequested()
+{
MutexLocker locker(m_webMediaPlayerMutex);
if (m_preload == MediaPlayer::None) {
#if ENABLE(WEB_AUDIO)
#endif
Frame* frame = static_cast<HTMLMediaElement*>(m_mediaPlayer->mediaPlayerClient())->document()->frame();
- m_webMediaPlayer = createWebMediaPlayer(this, KURL(ParsedURLString, m_url), frame);
+ m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame);
if (m_webMediaPlayer) {
#if ENABLE(WEB_AUDIO)
// Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
#endif
- m_webMediaPlayer->load(
- KURL(ParsedURLString, m_url),
- static_cast<WebMediaPlayer::CORSMode>(m_mediaPlayer->mediaPlayerClient()->mediaPlayerCORSMode()));
+
+ WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode>(m_mediaPlayer->mediaPlayerClient()->mediaPlayerCORSMode());
+#if ENABLE(MEDIA_SOURCE)
+ if (m_mediaSource) {
+ m_webMediaPlayer->load(m_url, new WebMediaSourceImpl(m_mediaSource), corsMode);
+ return;
+ }
+#endif
+ m_webMediaPlayer->load(m_url, corsMode);
}
}
}
#endif
-#if ENABLE(MEDIA_SOURCE)
-WebCore::MediaPlayer::AddIdStatus WebMediaPlayerClientImpl::sourceAddId(const String& id, const String& type, const Vector<String>& codecs)
-{
- if (!m_webMediaPlayer)
- return WebCore::MediaPlayer::NotSupported;
-
- return static_cast<WebCore::MediaPlayer::AddIdStatus>(m_webMediaPlayer->sourceAddId(id, type, codecs));
-}
-
-bool WebMediaPlayerClientImpl::sourceRemoveId(const String& id)
-{
- if (!m_webMediaPlayer)
- return false;
-
- return m_webMediaPlayer->sourceRemoveId(id);
-}
-
-PassRefPtr<TimeRanges> WebMediaPlayerClientImpl::sourceBuffered(const String& id)
-{
- if (!m_webMediaPlayer)
- return TimeRanges::create();
-
- WebTimeRanges webRanges = m_webMediaPlayer->sourceBuffered(id);
- RefPtr<TimeRanges> ranges = TimeRanges::create();
- for (size_t i = 0; i < webRanges.size(); ++i)
- ranges->add(webRanges[i].start, webRanges[i].end);
- return ranges.release();
-}
-
-bool WebMediaPlayerClientImpl::sourceAppend(const String& id, const unsigned char* data, unsigned length)
-{
- if (m_webMediaPlayer)
- return m_webMediaPlayer->sourceAppend(id, data, length);
- return false;
-}
-
-bool WebMediaPlayerClientImpl::sourceAbort(const String& id)
-{
- if (!m_webMediaPlayer)
- return false;
-
- return m_webMediaPlayer->sourceAbort(id);
-}
-
-void WebMediaPlayerClientImpl::sourceSetDuration(double duration)
-{
- if (m_webMediaPlayer)
- m_webMediaPlayer->sourceSetDuration(duration);
-}
-
-void WebMediaPlayerClientImpl::sourceEndOfStream(WebCore::MediaPlayer::EndOfStreamStatus status)
-{
- if (m_webMediaPlayer)
- m_webMediaPlayer->sourceEndOfStream(static_cast<WebMediaPlayer::EndOfStreamStatus>(status));
-}
-
-bool WebMediaPlayerClientImpl::sourceSetTimestampOffset(const String& id, double offset)
-{
- if (!m_webMediaPlayer)
- return false;
- return m_webMediaPlayer->sourceSetTimestampOffset(id, offset);
-}
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength)
{
// MediaPlayerPrivateInterface methods:
virtual void load(const WTF::String& url);
+#if ENABLE(MEDIA_SOURCE)
+ virtual void load(const WTF::String& url, PassRefPtr<WebCore::MediaSource>);
+#endif
virtual void cancelLoad();
#if USE(ACCELERATED_COMPOSITING)
virtual WebKit::WebLayer* platformLayer() const;
virtual void putCurrentFrame(WebVideoFrame*);
#endif
-#if ENABLE(MEDIA_SOURCE)
- virtual WebCore::MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs);
- virtual bool sourceRemoveId(const String&);
- virtual WTF::PassRefPtr<WebCore::TimeRanges> sourceBuffered(const String&);
- virtual bool sourceAppend(const String&, const unsigned char* data, unsigned length);
- virtual bool sourceAbort(const String&);
- virtual void sourceSetDuration(double);
- virtual void sourceEndOfStream(WebCore::MediaPlayer::EndOfStreamStatus);
- virtual bool sourceSetTimestampOffset(const String&, double offset);
-#endif
-
#if ENABLE(ENCRYPTED_MEDIA)
virtual WebCore::MediaPlayer::MediaKeyException generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength) OVERRIDE;
virtual WebCore::MediaPlayer::MediaKeyException addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId) OVERRIDE;
WebMediaPlayerClientImpl();
private:
void startDelayedLoad();
+ void loadRequested();
void loadInternal();
static PassOwnPtr<WebCore::MediaPlayerPrivateInterface> create(WebCore::MediaPlayer*);
WebCore::MediaPlayer* m_mediaPlayer;
OwnPtr<WebMediaPlayer> m_webMediaPlayer;
WebVideoFrame* m_currentVideoFrame;
- String m_url;
+ WebCore::KURL m_url;
bool m_delayingLoad;
WebCore::MediaPlayer::Preload m_preload;
RefPtr<WebHelperPluginImpl> m_helperPlugin;
AudioSourceProviderImpl m_audioSourceProvider;
#endif
+
+#if ENABLE(MEDIA_SOURCE)
+ RefPtr<WebCore::MediaSource> m_mediaSource;
+#endif
};
} // namespace WebKit
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebMediaSourceImpl.h"
+
+#include "MediaSourcePrivate.h"
+#include "WebMediaSourceClient.h"
+
+#if ENABLE(MEDIA_SOURCE)
+
+namespace WebKit {
+
+class MediaSourcePrivateImpl : public WebCore::MediaSourcePrivate {
+public:
+ explicit MediaSourcePrivateImpl(PassOwnPtr<WebMediaSourceClient>);
+ virtual ~MediaSourcePrivateImpl() { }
+
+ // MediaSourcePrivate methods.
+ virtual WebCore::MediaSourcePrivate::AddIdStatus addId(const String& id, const String& type, const Vector<String>& codecs);
+ virtual bool removeId(const String& id);
+ virtual PassRefPtr<WebCore::TimeRanges> buffered(const String& id);
+ virtual bool append(const String& id, const unsigned char* data, unsigned length);
+ virtual bool abort(const String& id);
+ virtual double duration();
+ virtual void setDuration(double);
+ virtual void endOfStream(WebCore::MediaSourcePrivate::EndOfStreamStatus);
+ virtual bool setTimestampOffset(const String& id, double offset);
+
+private:
+ OwnPtr<WebKit::WebMediaSourceClient> m_client;
+};
+
+MediaSourcePrivateImpl::MediaSourcePrivateImpl(PassOwnPtr<WebKit::WebMediaSourceClient> client)
+ : m_client(client)
+{
+}
+
+WebCore::MediaSourcePrivate::AddIdStatus MediaSourcePrivateImpl::addId(const String& id, const String& type, const Vector<String>& codecs)
+{
+ if (!m_client)
+ return WebCore::MediaSourcePrivate::NotSupported;
+
+ return static_cast<WebCore::MediaSourcePrivate::AddIdStatus>(m_client->addId(id, type, codecs));
+}
+
+bool MediaSourcePrivateImpl::removeId(const String& id)
+{
+ if (!m_client)
+ return false;
+
+ return m_client->removeId(id);
+}
+
+PassRefPtr<WebCore::TimeRanges> MediaSourcePrivateImpl::buffered(const String& id)
+{
+ if (!m_client)
+ return WebCore::TimeRanges::create();
+
+ WebTimeRanges webRanges = m_client->buffered(id);
+ RefPtr<WebCore::TimeRanges> ranges = WebCore::TimeRanges::create();
+ for (size_t i = 0; i < webRanges.size(); ++i)
+ ranges->add(webRanges[i].start, webRanges[i].end);
+ return ranges.release();
+}
+
+bool MediaSourcePrivateImpl::append(const String& id, const unsigned char* data, unsigned length)
+{
+ if (!m_client)
+ return false;
+
+ return m_client->append(id, data, length);
+}
+
+bool MediaSourcePrivateImpl::abort(const String& id)
+{
+ if (!m_client)
+ return false;
+
+ return m_client->abort(id);
+}
+
+double MediaSourcePrivateImpl::duration()
+{
+ if (!m_client)
+ return std::numeric_limits<float>::quiet_NaN();
+ return m_client->duration();
+}
+
+void MediaSourcePrivateImpl::setDuration(double duration)
+{
+ if (m_client)
+ m_client->setDuration(duration);
+}
+
+void MediaSourcePrivateImpl::endOfStream(WebCore::MediaSourcePrivate::EndOfStreamStatus status)
+{
+ if (m_client)
+ m_client->endOfStream(static_cast<WebMediaSourceClient::EndOfStreamStatus>(status));
+}
+
+bool MediaSourcePrivateImpl::setTimestampOffset(const String& id, double offset)
+{
+ if (!m_client)
+ return false;
+ return m_client->setTimestampOffset(id, offset);
+}
+
+
+WebMediaSourceImpl::WebMediaSourceImpl(PassRefPtr<WebCore::MediaSource> mediaSource)
+{
+ m_mediaSource = mediaSource;
+}
+
+WebMediaSourceImpl::~WebMediaSourceImpl()
+{
+}
+
+
+void WebMediaSourceImpl::open(WebMediaSourceClient* client)
+{
+ ASSERT(client);
+ m_mediaSource->setPrivateAndOpen(adoptPtr(new MediaSourcePrivateImpl(adoptPtr(client))));
+}
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebMediaSourceImpl_h
+#define WebMediaSourceImpl_h
+
+#if ENABLE(MEDIA_SOURCE)
+
+#include "MediaSource.h"
+#include "WebMediaSource.h"
+
+namespace WebKit {
+
+class WebMediaSourceImpl : public WebMediaSource {
+public:
+ WebMediaSourceImpl(PassRefPtr<WebCore::MediaSource>);
+ virtual ~WebMediaSourceImpl();
+
+ // WebMediaSource methods.
+ virtual void open(WebMediaSourceClient*);
+
+private:
+ RefPtr<WebCore::MediaSource> m_mediaSource;
+};
+
+}
+
+#endif
+
+#endif