Title: [158291] trunk/Source/WebCore
Revision
158291
Author
jer.no...@apple.com
Date
2013-10-30 11:18:28 -0700 (Wed, 30 Oct 2013)

Log Message

[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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158290 => 158291)


--- trunk/Source/WebCore/ChangeLog	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/ChangeLog	2013-10-30 18:18:28 UTC (rev 158291)
@@ -1,3 +1,33 @@
+2013-10-30  Jer Noble  <jer.no...@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  <beid...@apple.com>
 
         IDBCursorBackendLevelDB should be made cross-platform

Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp (158290 => 158291)


--- trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp	2013-10-30 18:18:28 UTC (rev 158291)
@@ -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

Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (158290 => 158291)


--- trunk/Source/WebCore/dom/DOMImplementation.cpp	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp	2013-10-30 18:18:28 UTC (rev 158291)
@@ -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 = ""
+    if (MediaPlayer::supportsType(parameters, &client))
          return MediaDocument::create(frame, url);
 #endif
 

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (158290 => 158291)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2013-10-30 18:18:28 UTC (rev 158291)
@@ -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 = ""
+#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 = ""
+#if ENABLE(ENCRYPTED_MEDIA)
+            parameters.keySystem = system;
+#endif
+            if (!MediaPlayer::supportsType(parameters, this))
                 goto check_again;
         }
 

Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (158290 => 158291)


--- trunk/Source/WebCore/platform/MIMETypeRegistry.h	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h	2013-10-30 18:18:28 UTC (rev 158291)
@@ -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);

Modified: trunk/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp (158290 => 158291)


--- trunk/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp	2013-10-30 18:18:28 UTC (rev 158291)
@@ -96,12 +96,4 @@
     return false;
 }
 
-#if ENABLE(MEDIA_SOURCE)
-bool MIMETypeRegistry::isSupportedMediaSourceMIMEType(const String&, const String&)
-{
-    notImplemented();
-    return false;
 }
-#endif
-
-}

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (158290 => 158291)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2013-10-30 18:18:28 UTC (rev 158291)
@@ -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 = ""
-#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

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (158290 => 158291)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2013-10-30 18:18:28 UTC (rev 158291)
@@ -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);

Modified: trunk/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm (158290 => 158291)


--- trunk/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm	2013-10-30 18:04:41 UTC (rev 158290)
+++ trunk/Source/WebCore/platform/mac/MIMETypeRegistryMac.mm	2013-10-30 18:18:28 UTC (rev 158291)
@@ -73,11 +73,4 @@
     return false;
 }
 
-#if ENABLE(MEDIA_SOURCE)
-bool MIMETypeRegistry::isSupportedMediaSourceMIMEType(const String&, const String&)
-{
-    return false;
 }
-#endif
-
-}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to