[MSE] Add MediaSource compatable loading functions to MediaPlayer
https://bugs.webkit.org/show_bug.cgi?id=123353
Reviewed by Eric Carlson.
Add methods to MediaPlayer to allow it to select the correct MediaPlayerFactory
when attempting to load a MediaSource URL.
* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::addSourceBuffer):
(WebCore::MediaSource::isTypeSupported):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::loadResource):
(WebCore::HTMLMediaElement::canPlayType):
(WebCore::HTMLMediaElement::selectNextSourceChild):
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::load):
(WebCore::MediaPlayer::supportsType):
* platform/graphics/MediaPlayer.h:
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createDocument):
Remove the isSupportedMediaSourceMIMEType() method:
* platform/MIMETypeRegistry.h:
* platform/efl/MIMETypeRegistryEfl.cpp:
* platform/mac/MIMETypeRegistryMac.mm:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 55cea82..db4483c 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2013-10-30 Jer Noble <jer.noble@apple.com>
+
+ [MSE] Add MediaSource compatable loading functions to MediaPlayer
+ https://bugs.webkit.org/show_bug.cgi?id=123353
+
+ Reviewed by Eric Carlson.
+
+ Add methods to MediaPlayer to allow it to select the correct MediaPlayerFactory
+ when attempting to load a MediaSource URL.
+
+ * Modules/mediasource/MediaSource.cpp:
+ (WebCore::MediaSource::addSourceBuffer):
+ (WebCore::MediaSource::isTypeSupported):
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::loadResource):
+ (WebCore::HTMLMediaElement::canPlayType):
+ (WebCore::HTMLMediaElement::selectNextSourceChild):
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::load):
+ (WebCore::MediaPlayer::supportsType):
+ * platform/graphics/MediaPlayer.h:
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createDocument):
+
+ Remove the isSupportedMediaSourceMIMEType() method:
+ * platform/MIMETypeRegistry.h:
+ * platform/efl/MIMETypeRegistryEfl.cpp:
+ * platform/mac/MIMETypeRegistryMac.mm:
+
+
2013-10-30 Brady Eidson <beidson@apple.com>
IDBCursorBackendLevelDB should be made cross-platform
diff --git a/Source/WebCore/Modules/mediasource/MediaSource.cpp b/Source/WebCore/Modules/mediasource/MediaSource.cpp
index 162406c..f21b263 100644
--- a/Source/WebCore/Modules/mediasource/MediaSource.cpp
+++ b/Source/WebCore/Modules/mediasource/MediaSource.cpp
@@ -38,6 +38,7 @@
#include "GenericEventQueue.h"
#include "Logging.h"
#include "MIMETypeRegistry.h"
+#include "MediaPlayer.h"
#include "MediaSourceRegistry.h"
#include "SourceBufferPrivate.h"
#include "TimeRanges.h"
@@ -95,7 +96,6 @@
// 5. Create a new SourceBuffer object and associated resources.
ContentType contentType(type);
- Vector<String> codecs = contentType.codecs();
RefPtr<SourceBufferPrivate> sourceBufferPrivate = createSourceBufferPrivate(contentType, ec);
if (!sourceBufferPrivate) {
@@ -204,7 +204,11 @@
// 4. If type contains at a codec that the MediaSource does not support, then return false.
// 5. If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.
// 6. Return true.
- return MIMETypeRegistry::isSupportedMediaSourceMIMEType(contentType.type(), codecs);
+ MediaEngineSupportParameters parameters = { };
+ parameters.type = contentType.type();
+ parameters.codecs = codecs;
+ parameters.isMediaSource = true;
+ return MediaPlayer::supportsType(parameters, 0) != MediaPlayer::IsNotSupported;
}
EventTargetInterface MediaSource::eventTargetInterface() const
diff --git a/Source/WebCore/dom/DOMImplementation.cpp b/Source/WebCore/dom/DOMImplementation.cpp
index 301b502..bb2fec0 100644
--- a/Source/WebCore/dom/DOMImplementation.cpp
+++ b/Source/WebCore/dom/DOMImplementation.cpp
@@ -356,7 +356,10 @@
// Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument
// Key system is not applicable here.
DOMImplementationSupportsTypeClient client(frame && frame->settings().needsSiteSpecificQuirks(), url.host());
- if (MediaPlayer::supportsType(ContentType(type), String(), url, &client))
+ MediaEngineSupportParameters parameters = { };
+ parameters.type = type;
+ parameters.url = url;
+ if (MediaPlayer::supportsType(parameters, &client))
return MediaDocument::create(frame, url);
#endif
diff --git a/Source/WebCore/html/HTMLMediaElement.cpp b/Source/WebCore/html/HTMLMediaElement.cpp
index d754de7..6c5c53c 100644
--- a/Source/WebCore/html/HTMLMediaElement.cpp
+++ b/Source/WebCore/html/HTMLMediaElement.cpp
@@ -762,7 +762,15 @@
String HTMLMediaElement::canPlayType(const String& mimeType, const String& keySystem, const URL& url) const
{
- MediaPlayer::SupportsType support = MediaPlayer::supportsType(ContentType(mimeType), keySystem, url, this);
+ MediaEngineSupportParameters parameters = { };
+ ContentType contentType(mimeType);
+ parameters.type = contentType.type();
+ parameters.codecs = contentType.parameter(ASCIILiteral("codecs"));
+ parameters.url = url;
+#if ENABLE(ENCRYPTED_MEDIA)
+ parameters.keySystem = keySystem;
+#endif
+ MediaPlayer::SupportsType support = MediaPlayer::supportsType(parameters, this);
String canPlay;
// 4.8.10.3
@@ -1114,7 +1122,7 @@
if (m_mediaSource) {
if (m_mediaSource->attachToElement())
- m_player->load(url, m_mediaSource);
+ m_player->load(url, contentType, m_mediaSource);
else {
// Forget our reference to the MediaSource, so we leave it alone
// while processing remainder of load failure.
@@ -3521,7 +3529,15 @@
if (shouldLog)
LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'type' is '%s' - key system is '%s'", type.utf8().data(), system.utf8().data());
#endif
- if (!MediaPlayer::supportsType(ContentType(type), system, mediaURL, this))
+ MediaEngineSupportParameters parameters = { };
+ ContentType contentType(type);
+ parameters.type = contentType.type();
+ parameters.codecs = contentType.parameter(ASCIILiteral("codecs"));
+ parameters.url = mediaURL;
+#if ENABLE(ENCRYPTED_MEDIA)
+ parameters.keySystem = system;
+#endif
+ if (!MediaPlayer::supportsType(parameters, this))
goto check_again;
}
diff --git a/Source/WebCore/platform/MIMETypeRegistry.h b/Source/WebCore/platform/MIMETypeRegistry.h
index ecc766c..f720f58 100644
--- a/Source/WebCore/platform/MIMETypeRegistry.h
+++ b/Source/WebCore/platform/MIMETypeRegistry.h
@@ -67,11 +67,6 @@
// Check to see if a mime type is suitable for being loaded using <video> and <audio>
static bool isSupportedMediaMIMEType(const String& mimeType);
-#if ENABLE(MEDIA_SOURCE)
- // Check to see if the mime type and codecs are supported by the MediaSource implementation.
- static bool isSupportedMediaSourceMIMEType(const String& mimeType, const String& codecs);
-#endif
-
// Check to see if the mime type is not suitable for being loaded as a text
// document in a frame. Only valid for mime types begining with "text/".
static bool isUnsupportedTextMIMEType(const String& mimeType);
diff --git a/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp b/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp
index d7e0b0c..4ae8181 100644
--- a/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp
+++ b/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp
@@ -96,12 +96,4 @@
return false;
}
-#if ENABLE(MEDIA_SOURCE)
-bool MIMETypeRegistry::isSupportedMediaSourceMIMEType(const String&, const String&)
-{
- notImplemented();
- return false;
-}
-#endif
-
}
diff --git a/Source/WebCore/platform/graphics/MediaPlayer.cpp b/Source/WebCore/platform/graphics/MediaPlayer.cpp
index 5fce7fc..fd32ff3 100644
--- a/Source/WebCore/platform/graphics/MediaPlayer.cpp
+++ b/Source/WebCore/platform/graphics/MediaPlayer.cpp
@@ -379,11 +379,11 @@
}
#if ENABLE(MEDIA_SOURCE)
-bool MediaPlayer::load(const URL& url, PassRefPtr<HTMLMediaSource> mediaSource)
+bool MediaPlayer::load(const URL& url, const ContentType& contentType, PassRefPtr<HTMLMediaSource> mediaSource)
{
m_mediaSource = mediaSource;
- m_contentMIMEType = "";
- m_contentTypeCodecs = "";
+ m_contentMIMEType = contentType.type().lower();
+ m_contentTypeCodecs = contentType.parameter(codecs());
m_url = url;
m_keySystem = "";
m_contentMIMETypeWasInferredFromExtension = false;
@@ -741,23 +741,8 @@
return m_private->copyVideoTextureToPlatformTexture(context, texture, level, type, internalFormat, premultiplyAlpha, flipY);
}
-MediaPlayer::SupportsType MediaPlayer::supportsType(const ContentType& contentType, const String& keySystem, const URL& url, const MediaPlayerSupportsTypeClient* client)
+MediaPlayer::SupportsType MediaPlayer::supportsType(const MediaEngineSupportParameters& parameters, const MediaPlayerSupportsTypeClient* client)
{
- MediaEngineSupportParameters parameters;
- parameters.type = contentType.type().lower();
- // The codecs string is not lower-cased because MP4 values are case sensitive
- // per http://tools.ietf.org/html/rfc4281#page-7.
- parameters.codecs = contentType.parameter(codecs());
- parameters.url = url;
-#if ENABLE(ENCRYPTED_MEDIA)
- parameters.keySystem = keySystem.lower();
-#else
- UNUSED_PARAM(keySystem);
-#endif
-#if ENABLE(MEDIA_SOURCE)
- parameters.isMediaSource = false;
-#endif
-
// 4.8.10.3 MIME types - The canPlayType(type) method must return the empty string if type is a type that the
// user agent knows it cannot render or is the type "application/octet-stream"
if (parameters.type == applicationOctetStream())
@@ -777,7 +762,7 @@
if (client && client->mediaPlayerNeedsSiteSpecificHacks()) {
String host = client->mediaPlayerDocumentHost();
if ((host.endsWith(".youtube.com", false) || equalIgnoringCase("youtube.com", host))
- && (contentType.type().startsWith("video/webm", false) || contentType.type().startsWith("video/x-flv", false)))
+ && (parameters.type.startsWith("video/webm", false) || parameters.type.startsWith("video/x-flv", false)))
return IsNotSupported;
}
#else
diff --git a/Source/WebCore/platform/graphics/MediaPlayer.h b/Source/WebCore/platform/graphics/MediaPlayer.h
index 5faf9dc..e4257d5 100644
--- a/Source/WebCore/platform/graphics/MediaPlayer.h
+++ b/Source/WebCore/platform/graphics/MediaPlayer.h
@@ -102,6 +102,18 @@
} media;
};
+struct MediaEngineSupportParameters {
+ String type;
+ String codecs;
+ URL url;
+#if ENABLE(ENCRYPTED_MEDIA)
+ String keySystem;
+#endif
+#if ENABLE(MEDIA_SOURCE)
+ bool isMediaSource;
+#endif
+};
+
extern const PlatformMedia NoPlatformMedia;
class CachedResourceLoader;
@@ -253,7 +265,7 @@
// Media engine support.
enum SupportsType { IsNotSupported, IsSupported, MayBeSupported };
- static MediaPlayer::SupportsType supportsType(const ContentType&, const String& keySystem, const URL&, const MediaPlayerSupportsTypeClient*);
+ static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&, const MediaPlayerSupportsTypeClient*);
static void getSupportedTypes(HashSet<String>&);
static bool isAvailable();
static void getSitesInMediaCache(Vector<String>&);
@@ -282,7 +294,7 @@
bool load(const URL&, const ContentType&, const String& keySystem);
#if ENABLE(MEDIA_SOURCE)
- bool load(const URL&, PassRefPtr<HTMLMediaSource>);
+ bool load(const URL&, const ContentType&, PassRefPtr<HTMLMediaSource>);
#endif
void cancelLoad();
@@ -524,18 +536,6 @@
#endif
};
-struct MediaEngineSupportParameters {
- String type;
- String codecs;
- URL url;
-#if ENABLE(ENCRYPTED_MEDIA)
- String keySystem;
-#endif
-#if ENABLE(MEDIA_SOURCE)
- bool isMediaSource;
-#endif
-};
-
typedef PassOwnPtr<MediaPlayerPrivateInterface> (*CreateMediaEnginePlayer)(MediaPlayer*);
typedef void (*MediaEngineSupportedTypes)(HashSet<String>& types);
typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const MediaEngineSupportParameters& parameters);
diff --git a/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm b/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm
index 8836640..d22e2b6 100644
--- a/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm
+++ b/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm
@@ -73,11 +73,4 @@
return false;
}
-#if ENABLE(MEDIA_SOURCE)
-bool MIMETypeRegistry::isSupportedMediaSourceMIMEType(const String&, const String&)
-{
- return false;
-}
-#endif
-
}