Title: [214269] trunk
Revision
214269
Author
[email protected]
Date
2017-03-22 12:32:38 -0700 (Wed, 22 Mar 2017)

Log Message

Media files served without an extension will not load in <video> tag.
https://bugs.webkit.org/show_bug.cgi?id=169895

Reviewed by Eric Carlson.

Source/WebCore:

Test: http/tests/media/video-served-as-text-with-type.html

Media files served without an extension will commonly have no MIME type (or incorrect MIME type) information
delivered in the HTTP header. In situations like these, if media referenced by a <source> tag with a type=
attribute containing MIME type (and optionally, codec) information, that type should be used preferentially.

* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayer::contentMIMEType):
(WebCore::MediaPlayer::contentTypeCodecs):
(WebCore::MediaPlayer::contentMIMETypeWasInferredFromExtension):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):

LayoutTests:

* http/tests/media/video-served-as-text-with-type-expected.txt: Added.
* http/tests/media/video-served-as-text-with-type.html: Added.
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214268 => 214269)


--- trunk/LayoutTests/ChangeLog	2017-03-22 19:23:12 UTC (rev 214268)
+++ trunk/LayoutTests/ChangeLog	2017-03-22 19:32:38 UTC (rev 214269)
@@ -1,3 +1,14 @@
+2017-03-22  Jer Noble  <[email protected]>
+
+        Media files served without an extension will not load in <video> tag.
+        https://bugs.webkit.org/show_bug.cgi?id=169895
+
+        Reviewed by Eric Carlson.
+
+        * http/tests/media/video-served-as-text-with-type-expected.txt: Added.
+        * http/tests/media/video-served-as-text-with-type.html: Added.
+        * platform/mac/TestExpectations:
+
 2017-03-22  Ryan Haddad  <[email protected]>
 
         Remove duplicate TestExpectations entry.

Added: trunk/LayoutTests/http/tests/media/video-served-as-text-with-type-expected.txt (0 => 214269)


--- trunk/LayoutTests/http/tests/media/video-served-as-text-with-type-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-served-as-text-with-type-expected.txt	2017-03-22 19:32:38 UTC (rev 214269)
@@ -0,0 +1,7 @@
+
+EXPECTED (video.error == 'null') OK
+EVENT(loadstart)
+EVENT(loadedmetadata)
+loaded media file served as text with type= attribute OK
+END OF TEST
+

Added: trunk/LayoutTests/http/tests/media/video-served-as-text-with-type.html (0 => 214269)


--- trunk/LayoutTests/http/tests/media/video-served-as-text-with-type.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-served-as-text-with-type.html	2017-03-22 19:32:38 UTC (rev 214269)
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>media file served as 'text/plain'</title>
+        <script src=""
+        <script src=""
+        <script>
+            function loadedmetadata(evt) 
+            {
+                logResult(true, "loaded media file served as text with type= attribute");
+                endTest();
+            }
+
+            function error(evt)
+            {
+                logResult(false, "failed trying to load media file served as text");
+                endTest();
+            }
+
+            function start() 
+            {
+                findMediaElement();
+
+                waitForEvent('loadedmetadata', loadedmetadata);
+                waitForEvent("error", error);
+                waitForEvent("loadstart");
+                testExpected("video.error", null);                
+
+                var movie = findMediaFile("video", "resources/test");
+                var source = document.createElement('source');
+                source.src = "" + movie + "&throttle=99999&nph=1&type=text/plain";
+                source.type = mimeTypeForFile(movie);
+                video.appendChild(source);
+            }
+        </script>
+    </head>
+
+    <body _onload_="start()">
+        <video controls></video>
+    </body>
+</html>

Modified: trunk/LayoutTests/platform/mac/TestExpectations (214268 => 214269)


--- trunk/LayoutTests/platform/mac/TestExpectations	2017-03-22 19:23:12 UTC (rev 214268)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2017-03-22 19:32:38 UTC (rev 214269)
@@ -1548,3 +1548,6 @@
 webkit.org/b/169572 imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location_hash.html [ Pass Failure ]
 
 webkit.org/b/169637 imported/w3c/web-platform-tests/XMLHttpRequest/timeout-multiple-fetches.html [ Pass Failure ]
+
+# <rdar://problem/19759913>
+http/tests/media/video-served-as-text-with-type.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (214268 => 214269)


--- trunk/Source/WebCore/ChangeLog	2017-03-22 19:23:12 UTC (rev 214268)
+++ trunk/Source/WebCore/ChangeLog	2017-03-22 19:32:38 UTC (rev 214269)
@@ -1,3 +1,23 @@
+2017-03-22  Jer Noble  <[email protected]>
+
+        Media files served without an extension will not load in <video> tag.
+        https://bugs.webkit.org/show_bug.cgi?id=169895
+
+        Reviewed by Eric Carlson.
+
+        Test: http/tests/media/video-served-as-text-with-type.html
+
+        Media files served without an extension will commonly have no MIME type (or incorrect MIME type) information
+        delivered in the HTTP header. In situations like these, if media referenced by a <source> tag with a type=
+        attribute containing MIME type (and optionally, codec) information, that type should be used preferentially.
+
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayer::contentMIMEType):
+        (WebCore::MediaPlayer::contentTypeCodecs):
+        (WebCore::MediaPlayer::contentMIMETypeWasInferredFromExtension):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
+
 2017-03-22  Andy Estes  <[email protected]>
 
         [QuickLook] Move QuickLook.{h,mm} to platform/ios/

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (214268 => 214269)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-03-22 19:23:12 UTC (rev 214268)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2017-03-22 19:32:38 UTC (rev 214269)
@@ -585,6 +585,10 @@
     void setShouldDisableSleep(bool);
     bool shouldDisableSleep() const;
 
+    const String& contentMIMEType() const { return m_contentMIMEType; }
+    const String& contentTypeCodecs() const { return m_contentTypeCodecs; }
+    bool contentMIMETypeWasInferredFromExtension() const { return m_contentMIMETypeWasInferredFromExtension; }
+
 private:
     MediaPlayer(MediaPlayerClient&);
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (214268 => 214269)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2017-03-22 19:23:12 UTC (rev 214268)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2017-03-22 19:32:38 UTC (rev 214269)
@@ -190,6 +190,7 @@
 
 SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetClientBundleIdentifierKey, NSString *)
 SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetRequiresCustomURLLoadingKey, NSString *)
+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetOutOfBandMIMETypeKey, NSString *)
 
 #define AVPlayer initAVPlayer()
 #define AVPlayerItem initAVPlayerItem()
@@ -212,6 +213,7 @@
 #define AVURLAssetInheritURIQueryComponentFromReferencingURIKey getAVURLAssetInheritURIQueryComponentFromReferencingURIKey()
 #define AVURLAssetClientBundleIdentifierKey getAVURLAssetClientBundleIdentifierKey()
 #define AVURLAssetRequiresCustomURLLoadingKey getAVURLAssetRequiresCustomURLLoadingKey()
+#define AVURLAssetOutOfBandMIMETypeKey getAVURLAssetOutOfBandMIMETypeKey()
 #define AVAssetImageGeneratorApertureModeCleanAperture getAVAssetImageGeneratorApertureModeCleanAperture()
 #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
 #define AVLayerVideoGravityResizeAspect getAVLayerVideoGravityResizeAspect()
@@ -943,6 +945,16 @@
         [options setObject:@YES forKey:AVURLAssetRequiresCustomURLLoadingKey];
 #endif
 
+    auto& type = player()->contentMIMEType();
+    if (AVURLAssetOutOfBandMIMETypeKey && !type.isEmpty() && !player()->contentMIMETypeWasInferredFromExtension()) {
+        auto& codecs = player()->contentTypeCodecs();
+        if (!codecs.isEmpty()) {
+            NSString *typeString = [NSString stringWithFormat:@"%@; codecs=\"%@\"", (NSString *)type, (NSString *)codecs];
+            [options setObject:typeString forKey:AVURLAssetOutOfBandMIMETypeKey];
+        } else
+            [options setObject:(NSString *)type forKey:AVURLAssetOutOfBandMIMETypeKey];
+    }
+
 #if ENABLE(AVF_CAPTIONS)
     const Vector<RefPtr<PlatformTextTrack>>& outOfBandTrackSources = player()->outOfBandTrackSources();
     if (!outOfBandTrackSources.isEmpty()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to