Back out f08e636ecdc4 (bug 792935) for mochitest failures

This commit is contained in:
Steve Workman 2013-01-31 10:54:26 -08:00
parent ec47546792
commit e551562a63
5 changed files with 0 additions and 231 deletions

View File

@ -343,9 +343,6 @@ ifdef MOZ_DASH
MOCHITEST_FILES += \
test_can_play_type_dash.html \
dash/dash-manifest.mpd \
dash/dash-manifest-sjs.mpd \
test_dash_detect_stream_switch.html \
dash_detect_stream_switch.sjs \
dash/dash-webm-video-320x180.webm \
dash/dash-webm-video-428x240.webm \
dash/dash-webm-audio-128k.webm \

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<MPD
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:DASH:schema:MPD:2011"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011"
type="static"
mediaPresentationDuration="PT3.958S"
minBufferTime="PT1S"
profiles="urn:webm:dash:profile:webm-on-demand:2012">
<BaseURL>./dash_detect_stream_switch.sjs?name=</BaseURL>
<Period id="0" start="PT0S" duration="PT3.958S" >
<AdaptationSet id="0" mimeType="video/webm" codecs="vp8" lang="eng" subsegmentAlignment="true" subsegmentStartsWithSAP="1" bitstreamSwitching="true">
<Representation id="0" bandwidth="54207" width="320" height="180">
<BaseURL>dash-webm-video-320x180.webm</BaseURL>
<SegmentBase indexRange="35090-35123">
<Initialization range="0-228" />
</SegmentBase>
</Representation>
<Representation id="1" bandwidth="78006" width="428" height="240">
<BaseURL>dash-webm-video-428x240.webm</BaseURL>
<SegmentBase indexRange="50173-50206">
<Initialization range="0-228" />
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" mimeType="audio/webm" codecs="vorbis" lang="eng" audioSamplingRate="48000" subsegmentStartsWithSAP="1">
<Representation id="2" bandwidth="57264">
<BaseURL>dash-webm-audio-128k.webm</BaseURL>
<SegmentBase indexRange="41927-41946">
<Initialization range="0-4521" />
</SegmentBase>
</Representation>
</AdaptationSet>
</Period>
</MPD>

View File

@ -1,114 +0,0 @@
/* -*- Mode: JavaScript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* dash_detect_stream_switch.sjs
*
* Parses requests for DASH manifests and ensures stream switching takes place
* by verifying the subsegments downloaded and the streams they belong to.
* If unexpected subsegments (byte ranges) are requested, the script will
* will respond with a 404.
*/
var DEBUG = false;
function parseQuery(request, key) {
var params = request.queryString.split('&');
if (DEBUG) {
dump("DASH-SJS: request params = \"" + params + "\"\n");
}
for (var j = 0; j < params.length; ++j) {
var p = params[j];
if (p == key)
return true;
if (p.indexOf(key + "=") === 0)
return p.substring(key.length + 1);
if (p.indexOf("=") < 0 && key === "")
return p;
}
return false;
}
function handleRequest(request, response)
{
try {
var name = parseQuery(request, "name");
var range = request.hasHeader("Range") ? request.getHeader("Range")
: undefined;
// Should not get request for 1st subsegment from 2nd stream, nor 2nd
// subsegment from 1st stream.
if (name == "dash-webm-video-320x180.webm" && range == "bytes=25514-32767" ||
name == "dash-webm-video-428x240.webm" && range == "bytes=228-35852")
{
throw "Should not request " + name + " with byte-range " + range;
} else {
var rangeSplit = range.split("=");
if (rangeSplit.length != 2) {
throw "DASH-SJS: ERROR: invalid number of tokens (" + rangeSplit.length +
") delimited by \'=\' in \'Range\' header.";
}
var offsets = rangeSplit[1].split("-");
if (offsets.length != 2) {
throw "DASH-SJS: ERROR: invalid number of tokens (" + offsets.length +
") delimited by \'-\' in \'Range\' header.";
}
var startOffset = parseInt(offsets[0]);
var endOffset = parseInt(offsets[1]);
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/" + name;
var split = paths.split("/");
for (var i = 0; i < split.length; ++i) {
file.append(split[i]);
}
fis.init(file, -1, -1, false);
// Exception: start offset should be within file bounds.
if (startOffset > file.fileSize) {
throw "Starting offset [" + startOffset + "] is after end of file [" +
file.fileSize + "].";
}
// End offset may be too large in the MPD. Real world HTTP servers just
// return what data they can; do the same here - reduce the end offset.
if (endOffset >= file.fileSize) {
if (DEBUG) {
dump("DASH-SJS: reducing endOffset [" + endOffset + "] to fileSize [" +
(file.fileSize-1) + "]\n");
}
endOffset = file.fileSize-1;
}
fis.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, startOffset);
bis.setInputStream(fis);
var byteLengthToRead = endOffset + 1 - startOffset;
var totalBytesExpected = byteLengthToRead + startOffset;
if (DEBUG) {
dump("DASH-SJS: byteLengthToRead = " + byteLengthToRead +
" byteLengthToRead+startOffset = " + totalBytesExpected +
" fileSize = " + file.fileSize + "\n");
}
var bytes = bis.readBytes(byteLengthToRead);
response.setStatusLine(request.httpVersion, 206, "Partial Content");
response.setHeader("Content-Length", ""+bytes.length, false);
response.setHeader("Content-Type", "application/dash+xml", false);
var contentRange = "bytes " + startOffset + "-" + endOffset + "/" +
file.fileSize;
response.setHeader("Content-Range", contentRange, false);
response.write(bytes, bytes.length);
bis.close();
}
} catch (e) {
dump ("DASH-SJS-ERROR: " + e + "\n");
response.setStatusLine(request.httpVersion, 404, "Not found");
}
}

View File

@ -195,13 +195,6 @@ var gInvalidTests = [
{ name:"invalid-cmap-s1c2.opus", type:"audio/ogg; codecs=opus"},
];
// Files to test for stream switching. Note: media files referenced in DASH MPD
// files should be accessed via dash_detect_stream_switch.sjs.
var gStreamSwitchTests = [
{ name:"dash-manifest-sjs.mpd", type:"application/dash+xml",
width:320, height:180, duration:3.966 }
];
// Converts a path/filename to a file:// URI which we can load from disk.
// Optionally checks whether the file actually exists on disk at the location
// we've specified.

View File

@ -1,72 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=792935
-->
<head>
<title>Test for Bug 792935 - DASH Stream Switching</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript" src="manifest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=792935">Mozilla Bug 792935</a>
</div>
<pre id="test">
<script type="text/javascript">
var manager = new MediaTestManager;
function createTestArray() {
var tests = [];
var tmpVid = document.createElement("video");
for (var testNum=0; testNum<gStreamSwitchTests.length; testNum++) {
var test = gStreamSwitchTests[testNum];
if (!tmpVid.canPlayType(test.type)) {
continue;
}
tests.push(test);
}
return tests;
}
function ended(evt) {
var v = evt.target;
if (v.parentNode) {
v.parentNode.removeChild(v);
}
ok(true, "Fully played DASH video implies correct byte ranges downloaded.");
dump("STREAM-SWITCH-TEST: Finished " + v._name + "\n");
manager.finished(v.token);
}
function error(evt) {
var v = evt.target;
ok(false, "Error suggests wrong byte range requested for " + v._name);
}
function startTest(test, token) {
var v = document.createElement('video');
manager.started(token);
v.type = test.type;
v.src = test.name;
v._name = test.name + " stream switch test";
v.token = token;
v.autoplay = true;
v.addEventListener("error", error, false);
v.addEventListener("ended", ended, false);
dump("STREAM-SWITCH-TEST: Started " + name + "\n");
document.body.appendChild(v);
}
manager.runTests(createTestArray(), startTest);
</script>
</pre>
</body>
</html>