mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 539620 - Deprecate X-Content-Duration for Content-Duration. r=chris.double
This commit is contained in:
parent
ca4ba0fb5c
commit
12876d55d8
@ -195,18 +195,23 @@ nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
|
||||
PRBool acceptsRanges = ranges.EqualsLiteral("bytes");
|
||||
|
||||
if (mOffset == 0) {
|
||||
// Look for duration headers from known Ogg content systems. In the case
|
||||
// of multiple options for obtaining the duration the order of precedence is;
|
||||
// Look for duration headers from known Ogg content systems.
|
||||
// In the case of multiple options for obtaining the duration
|
||||
// the order of precedence is:
|
||||
// 1) The Media resource metadata if possible (done by the decoder itself).
|
||||
// 2) X-Content-Duration.
|
||||
// 3) x-amz-meta-content-duration.
|
||||
// 4) Perform a seek in the decoder to find the value.
|
||||
// 2) Content-Duration message header.
|
||||
// 3) X-AMZ-Meta-Content-Duration.
|
||||
// 4) X-Content-Duration.
|
||||
// 5) Perform a seek in the decoder to find the value.
|
||||
nsCAutoString durationText;
|
||||
PRInt32 ec = 0;
|
||||
rv = hc->GetResponseHeader(NS_LITERAL_CSTRING("X-Content-Duration"), durationText);
|
||||
rv = hc->GetResponseHeader(NS_LITERAL_CSTRING("Content-Duration"), durationText);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = hc->GetResponseHeader(NS_LITERAL_CSTRING("X-AMZ-Meta-Content-Duration"), durationText);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = hc->GetResponseHeader(NS_LITERAL_CSTRING("X-Content-Duration"), durationText);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
float duration = durationText.ToFloat(&ec);
|
||||
|
@ -193,6 +193,7 @@ _TEST_FILES += \
|
||||
test_contentDuration4.html \
|
||||
test_contentDuration5.html \
|
||||
test_contentDuration6.html \
|
||||
test_contentDuration7.html \
|
||||
test_delay_load.html \
|
||||
test_duration1.html \
|
||||
test_ended1.html \
|
||||
@ -217,6 +218,7 @@ _TEST_FILES += \
|
||||
contentDuration4.sjs \
|
||||
contentDuration5.sjs \
|
||||
contentDuration6.sjs \
|
||||
contentDuration7.sjs \
|
||||
$(NULL)
|
||||
# These tests disabled until we figure out random failures.
|
||||
# Bug 492821:
|
||||
|
@ -15,7 +15,7 @@ function handleRequest(request, response)
|
||||
fis.init(file, -1, -1, false);
|
||||
bis.setInputStream(fis);
|
||||
var bytes = bis.readBytes(bis.available());
|
||||
response.setHeader("X-Content-Duration", "0.233", false);
|
||||
response.setHeader("Content-Duration", "0.233", false);
|
||||
response.setHeader("Content-Length", ""+bytes.length, false);
|
||||
response.setHeader("Content-Type", "video/ogg", false);
|
||||
response.write(bytes, bytes.length);
|
||||
|
@ -16,7 +16,7 @@ function handleRequest(request, response)
|
||||
bis.setInputStream(fis);
|
||||
var bytes = bis.readBytes(bis.available());
|
||||
response.setStatusLine(request.httpVersion, 200, "Content Follows");
|
||||
response.setHeader("X-Content-Duration", "-5", false);
|
||||
response.setHeader("Content-Duration", "-5", false);
|
||||
response.setHeader("Content-Length", ""+bytes.length, false);
|
||||
response.setHeader("Content-Type", "video/ogg", false);
|
||||
response.write(bytes, bytes.length);
|
||||
|
@ -16,7 +16,7 @@ function handleRequest(request, response)
|
||||
bis.setInputStream(fis);
|
||||
var bytes = bis.readBytes(bis.available());
|
||||
response.setStatusLine(request.httpVersion, 200, "Content Follows");
|
||||
response.setHeader("X-Content-Duration", "-6", false);
|
||||
response.setHeader("Content-Duration", "-6", false);
|
||||
response.setHeader("Content-Length", ""+bytes.length, false);
|
||||
response.setHeader("Content-Type", "video/ogg", false);
|
||||
response.write(bytes, bytes.length);
|
||||
|
@ -16,7 +16,7 @@ function handleRequest(request, response)
|
||||
bis.setInputStream(fis);
|
||||
var bytes = bis.readBytes(bis.available());
|
||||
response.setStatusLine(request.httpVersion, 200, "Content Follows");
|
||||
response.setHeader("X-Content-Duration", "Invalid Float Value", false);
|
||||
response.setHeader("Content-Duration", "Invalid Float Value", false);
|
||||
response.setHeader("Content-Length", ""+bytes.length, false);
|
||||
response.setHeader("Content-Type", "video/ogg", false);
|
||||
response.write(bytes, bytes.length);
|
||||
|
23
content/media/test/contentDuration7.sjs
Normal file
23
content/media/test/contentDuration7.sjs
Normal file
@ -0,0 +1,23 @@
|
||||
function handleRequest(request, response)
|
||||
{
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"].
|
||||
getService(Components.interfaces.nsIProperties).
|
||||
get("CurWorkD", Components.interfaces.nsILocalFile);
|
||||
var fis = Components.classes['@mozilla.org/network/file-input-stream;1'].
|
||||
createInstance(Components.interfaces.nsIFileInputStream);
|
||||
var bis = Components.classes["@mozilla.org/binaryinputstream;1"].
|
||||
createInstance(Components.interfaces.nsIBinaryInputStream);
|
||||
var paths = "tests/content/media/test/320x240.ogv";
|
||||
var split = paths.split("/");
|
||||
for(var i = 0; i < split.length; ++i) {
|
||||
file.append(split[i]);
|
||||
}
|
||||
fis.init(file, -1, -1, false);
|
||||
bis.setInputStream(fis);
|
||||
var bytes = bis.readBytes(bis.available());
|
||||
response.setHeader("X-Content-Duration", "0.233", false);
|
||||
response.setHeader("Content-Length", ""+bytes.length, false);
|
||||
response.setHeader("Content-Type", "video/ogg", false);
|
||||
response.write(bytes, bytes.length);
|
||||
bis.close();
|
||||
}
|
@ -13,7 +13,7 @@ var gSmallTests = [
|
||||
// Used by test_mozLoadFrom. Need one test file per decoder backend, plus
|
||||
// anything for testing clone-specific bugs.
|
||||
var gCloneTests = gSmallTests.concat([
|
||||
// Actual duration is ~200ms, we have X-Content-Duration lie about it.
|
||||
// Actual duration is ~200ms, we have Content-Duration lie about it.
|
||||
{ name:"bug520908.ogv", type:"video/ogg", duration:9000 },
|
||||
]);
|
||||
|
||||
|
27
content/media/test/test_contentDuration7.html
Normal file
27
content/media/test/test_contentDuration7.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media test: X-Content-Duration</title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function on_metadataloaded() {
|
||||
var v = document.getElementById('v');
|
||||
var d = Math.round(v.duration*1000);
|
||||
ok(d == 233, "Checking duration: " + d);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
</script>
|
||||
</pre>
|
||||
<video id='v'
|
||||
src='contentDuration7.sjs'
|
||||
onloadedmetadata='on_metadataloaded();'></video>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user