<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214269] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214269">214269</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2017-03-22 12:32:38 -0700 (Wed, 22 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Media files served without an extension will not load in &lt;video&gt; 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 &lt;source&gt; 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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayerh">trunk/Source/WebCore/platform/graphics/MediaPlayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsmediavideoservedastextwithtypeexpectedtxt">trunk/LayoutTests/http/tests/media/video-served-as-text-with-type-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestsmediavideoservedastextwithtypehtml">trunk/LayoutTests/http/tests/media/video-served-as-text-with-type.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (214268 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-22 19:23:12 UTC (rev 214268)
+++ trunk/LayoutTests/ChangeLog        2017-03-22 19:32:38 UTC (rev 214269)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-03-22  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Media files served without an extension will not load in &lt;video&gt; 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:
+
</ins><span class="cx"> 2017-03-22  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove duplicate TestExpectations entry.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsmediavideoservedastextwithtypeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/media/video-served-as-text-with-type-expected.txt (0 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+
+EXPECTED (video.error == 'null') OK
+EVENT(loadstart)
+EVENT(loadedmetadata)
+loaded media file served as text with type= attribute OK
+END OF TEST
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestsmediavideoservedastextwithtypehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/media/video-served-as-text-with-type.html (0 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;media file served as 'text/plain'&lt;/title&gt;
+        &lt;script src=../../media-resources/media-file.js&gt;&lt;/script&gt;
+        &lt;script src=../../media-resources/video-test.js&gt;&lt;/script&gt;
+        &lt;script&gt;
+            function loadedmetadata(evt) 
+            {
+                logResult(true, &quot;loaded media file served as text with type= attribute&quot;);
+                endTest();
+            }
+
+            function error(evt)
+            {
+                logResult(false, &quot;failed trying to load media file served as text&quot;);
+                endTest();
+            }
+
+            function start() 
+            {
+                findMediaElement();
+
+                waitForEvent('loadedmetadata', loadedmetadata);
+                waitForEvent(&quot;error&quot;, error);
+                waitForEvent(&quot;loadstart&quot;);
+                testExpected(&quot;video.error&quot;, null);                
+
+                var movie = findMediaFile(&quot;video&quot;, &quot;resources/test&quot;);
+                var source = document.createElement('source');
+                source.src = &quot;/media/video-throttled-load.cgi?name=&quot; + movie + &quot;&amp;throttle=99999&amp;nph=1&amp;type=text/plain&quot;;
+                source.type = mimeTypeForFile(movie);
+                video.appendChild(source);
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+
+    &lt;body onload=&quot;start()&quot;&gt;
+        &lt;video controls&gt;&lt;/video&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (214268 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1548,3 +1548,6 @@
</span><span class="cx"> webkit.org/b/169572 imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location_hash.html [ Pass Failure ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/169637 imported/w3c/web-platform-tests/XMLHttpRequest/timeout-multiple-fetches.html [ Pass Failure ]
</span><ins>+
+# &lt;rdar://problem/19759913&gt;
+http/tests/media/video-served-as-text-with-type.html [ Skip ]
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (214268 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2017-03-22  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Media files served without an extension will not load in &lt;video&gt; 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 &lt;source&gt; 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):
+
</ins><span class="cx"> 2017-03-22  Andy Estes  &lt;aestes@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [QuickLook] Move QuickLook.{h,mm} to platform/ios/
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (214268 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -585,6 +585,10 @@
</span><span class="cx">     void setShouldDisableSleep(bool);
</span><span class="cx">     bool shouldDisableSleep() const;
</span><span class="cx"> 
</span><ins>+    const String&amp; contentMIMEType() const { return m_contentMIMEType; }
+    const String&amp; contentTypeCodecs() const { return m_contentTypeCodecs; }
+    bool contentMIMETypeWasInferredFromExtension() const { return m_contentMIMETypeWasInferredFromExtension; }
+
</ins><span class="cx"> private:
</span><span class="cx">     MediaPlayer(MediaPlayerClient&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (214268 => 214269)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -190,6 +190,7 @@
</span><span class="cx"> 
</span><span class="cx"> SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetClientBundleIdentifierKey, NSString *)
</span><span class="cx"> SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetRequiresCustomURLLoadingKey, NSString *)
</span><ins>+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetOutOfBandMIMETypeKey, NSString *)
</ins><span class="cx"> 
</span><span class="cx"> #define AVPlayer initAVPlayer()
</span><span class="cx"> #define AVPlayerItem initAVPlayerItem()
</span><span class="lines">@@ -212,6 +213,7 @@
</span><span class="cx"> #define AVURLAssetInheritURIQueryComponentFromReferencingURIKey getAVURLAssetInheritURIQueryComponentFromReferencingURIKey()
</span><span class="cx"> #define AVURLAssetClientBundleIdentifierKey getAVURLAssetClientBundleIdentifierKey()
</span><span class="cx"> #define AVURLAssetRequiresCustomURLLoadingKey getAVURLAssetRequiresCustomURLLoadingKey()
</span><ins>+#define AVURLAssetOutOfBandMIMETypeKey getAVURLAssetOutOfBandMIMETypeKey()
</ins><span class="cx"> #define AVAssetImageGeneratorApertureModeCleanAperture getAVAssetImageGeneratorApertureModeCleanAperture()
</span><span class="cx"> #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
</span><span class="cx"> #define AVLayerVideoGravityResizeAspect getAVLayerVideoGravityResizeAspect()
</span><span class="lines">@@ -943,6 +945,16 @@
</span><span class="cx">         [options setObject:@YES forKey:AVURLAssetRequiresCustomURLLoadingKey];
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    auto&amp; type = player()-&gt;contentMIMEType();
+    if (AVURLAssetOutOfBandMIMETypeKey &amp;&amp; !type.isEmpty() &amp;&amp; !player()-&gt;contentMIMETypeWasInferredFromExtension()) {
+        auto&amp; codecs = player()-&gt;contentTypeCodecs();
+        if (!codecs.isEmpty()) {
+            NSString *typeString = [NSString stringWithFormat:@&quot;%@; codecs=\&quot;%@\&quot;&quot;, (NSString *)type, (NSString *)codecs];
+            [options setObject:typeString forKey:AVURLAssetOutOfBandMIMETypeKey];
+        } else
+            [options setObject:(NSString *)type forKey:AVURLAssetOutOfBandMIMETypeKey];
+    }
+
</ins><span class="cx"> #if ENABLE(AVF_CAPTIONS)
</span><span class="cx">     const Vector&lt;RefPtr&lt;PlatformTextTrack&gt;&gt;&amp; outOfBandTrackSources = player()-&gt;outOfBandTrackSources();
</span><span class="cx">     if (!outOfBandTrackSources.isEmpty()) {
</span></span></pre>
</div>
</div>

</body>
</html>