Changeset 165536 in webkit
- Timestamp:
- Mar 13, 2014 9:30:06 AM (10 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r165535 r165536 1 2014-03-13 Andres Gomez <agomez@igalia.com> 2 3 [GStreamer] WebKit gets stalled when trying to play a stream 4 https://bugs.webkit.org/show_bug.cgi?id=125926 5 6 Reviewed by Eric Carlson. 7 8 Added new test for checking the playback on Icecast/Shoutcast 9 streamed media. 10 11 * http/tests/media/media-play-stream-chunked-icy-expected.txt: Added. 12 * http/tests/media/media-play-stream-chunked-icy.html: Added. 13 * http/tests/media/resources/create-id3-db.php: Added. 14 * http/tests/media/resources/serve-video.php: Added support for 15 chunked streams and Icecast/Shoutcast headers. 16 * http/tests/resources/dir-helpers.php: Added. 17 * http/tests/resources/portabilityLayer.php: Added a couple of new 18 fallback functions when they are not available in old PHP 19 versions. 20 * media/content/metadata.db: Added. 21 * media/content/silence.mp3: Added. 22 1 23 2014-03-12 Chris Fleizach <cfleizach@apple.com> 2 24 -
trunk/LayoutTests/http/tests/media/resources/serve-video.php
r159746 r165536 1 1 <?php 2 2 3 // This script is based on the work done by gadgetguru 4 // <david@vuistbijl.nl> at 5 // https://github.com/gadgetguru/PHP-Streaming-Audio and released 6 // under the Public Domain. 7 8 // Set variables 9 $settings = array( 10 "chunkSize" => 1024 * 256, 11 "databaseFile" => "metadata.db", 12 "httpStatus" => "500 Internal Server Error", 13 "mediaDirectory" => array_key_exists("name", $_GET) ? dirname($_GET["name"]) : "", 14 "mimeType" => array_key_exists("type", $_GET) ? $_GET["type"] : "", 15 "radioGenre" => "Rock", 16 "radioName" => "WebKit Test Radio", 17 "radioUrl" => (array_key_exists("HTTPS", $_SERVER) ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"], 18 "setContentLength" => array_key_exists("content-length", $_GET) ? $_GET["content-length"] : "yes", 19 "setIcyData" => array_key_exists("icy-data", $_GET) ? $_GET["icy-data"] : "no", 20 "supportRanges" => array_key_exists("ranges", $_GET) ? $_GET["ranges"] : "yes", 21 ); 22 23 // 500 on errors 24 if (!array_key_exists("name", $_GET)) { 25 trigger_error("You have not specified a 'name' parameter.", E_USER_WARNING); 26 goto answering; 27 } 3 28 $fileName = $_GET["name"]; 4 $type = $_GET["type"];5 if (array_key_exists("ranges", $_GET))6 $ranges = $_GET["ranges"];7 29 30 if (!file_exists($fileName)) { 31 trigger_error("The file to stream specified at 'name' doesn't exist.", E_USER_WARNING); 32 goto answering; 33 } 34 $settings["databaseFile"] = $settings["mediaDirectory"] . "/" . $settings["databaseFile"]; 35 36 if ($settings["setIcyData"] != "yes" && $settings["mimeType"] == "") { 37 trigger_error("You have not specified a 'type' parameter.", E_USER_WARNING); 38 goto answering; 39 } 40 41 if ($settings["setIcyData"] == "yes") { 42 if (!file_exists($settings["databaseFile"])) { 43 44 // If the metadata database file doesn't exist it has to 45 // be create previously. 46 // 47 // Check the instructions about how to create it from the 48 // create-id3-db.php script file in this same directory. 49 50 trigger_error("The metadata database doesn't exist. To create one, check the script 'create-id3-db.php'.", E_USER_WARNING); 51 goto answering; 52 } 53 54 $playFiles = unserialize(file_get_contents($settings["databaseFile"])); 55 foreach ($playFiles as $i=>$playFile) { 56 if (basename($fileName) == $playFile["fileName"]) { 57 $fileInDB = true; 58 break; 59 } 60 } 61 62 if (!isset($fileInDB)) { 63 trigger_error("The requested file is not in the database.", E_USER_WARNING); 64 goto answering; 65 } 66 } 67 68 // There is everything needed to send the media file 8 69 $fileSize = filesize($fileName); 9 70 $start = 0; 10 71 $end = $fileSize - 1; 11 if ($ ranges != "no")72 if ($settings["supportRanges"] != "no" && array_key_exists("HTTP_RANGE", $_SERVER)) 12 73 $contentRange = $_SERVER["HTTP_RANGE"]; 13 74 if (isset($contentRange)) { … … 16 77 if (!empty($range[1])) 17 78 $end = intval($range[1]); 18 $ httpStatus= "206 Partial Content";79 $settings["httpStatus"] = "206 Partial Content"; 19 80 } else 20 $ httpStatus= "200 OK";81 $settings["httpStatus"] = "200 OK"; 21 82 22 header("Status: " . $httpStatus); 23 header("HTTP/1.1 " . $httpStatus); 83 84 answering: 85 86 header("Status: " . $settings["httpStatus"]); 87 header("HTTP/1.1 " . $settings["httpStatus"]); 88 header("Connection: close"); 89 90 if ($settings["httpStatus"] == "500 Internal Server Error") { 91 header("Content-Type: text/html"); 92 $errorMessage = sprintf("<html><body><h1>%s</h1><p/>", 93 $settings["httpStatus"]); 94 if (function_exists("error_get_last")) { 95 $errorArray = error_get_last(); 96 if ($errorArray) { 97 $errorMessage = sprintf("%sError type: %d<p/>Error message: %s<p/>". 98 "Error file: %s<p/>Error line: %d<p/>", 99 $errorMessage, $errorArray["type"], $errorArray["message"], 100 $errorArray["file"], $errorArray["line"]); 101 } 102 } 103 $errorMessage = $errorMessage . "</body><html>"; 104 print($errorMessage); 105 flush(); 106 exit; 107 } 108 24 109 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 25 110 header("Pragma: no-cache"); 26 111 header("Etag: " . '"' . $fileSize . "-" . filemtime($fileName) . '"'); 27 header("Content-Type: " . $type); 28 if ($ranges != "no") 112 if ($settings["setIcyData"] == "yes") { 113 $bitRate = ceil($playFiles[$i]["bitRate"] / 1000); 114 if ($settings["mimeType"] == "") 115 $settings["mimeType"] = $playFiles[$i]["mimeType"]; 116 header("icy-notice1: <BR>This stream requires a shoutcast/icecast compatible player.<BR>"); 117 header("icy-notice2: WebKit Stream Test<BR>"); 118 header("icy-name: " . $settings["radioName"]); 119 header("icy-genre: " . $settings["radioGenre"]); 120 header("icy-url: " . $settings["radioUrl"]); 121 header("icy-pub: 1"); 122 header("icy-br: " . $bitRate); 123 } 124 header("Content-Type: " . $settings["mimeType"]); 125 if ($settings["supportRanges"] != "no") 29 126 header("Accept-Ranges: bytes"); 30 header("Content-Length: " . ($end - $start + 1)); 127 if ($settings["setContentLength"] != "no") 128 header("Content-Length: " . ($end - $start + 1)); 31 129 if (isset($contentRange)) 32 130 header("Content-Range: bytes " . $start . "-" . $end . "/" . $fileSize); 33 header("Connection: close");34 131 35 $chunkSize = 1024 * 256;36 132 $offset = $start; 37 133 … … 40 136 41 137 while (!feof($fn) && $offset <= $end && connection_status() == 0) { 42 $readSize = min($ chunkSize, ($end - $offset) + 1);138 $readSize = min($settings["chunkSize"], ($end - $offset) + 1); 43 139 $buffer = fread($fn, $readSize); 44 140 print($buffer); 45 141 flush(); 46 $offset += $ chunkSize;142 $offset += $settings["chunkSize"]; 47 143 } 48 144 fclose($fn); -
trunk/LayoutTests/http/tests/resources/portabilityLayer.php
r39491 r165536 33 33 } 34 34 35 if (!function_exists('stream_copy_to_stream')) { 36 function stream_copy_to_stream($source, $dest) 37 { 38 $result = 0; 39 while (!feof($source)) { 40 $bytesWritten = fwrite($dest, fread($source, 8192)); 41 if (!$bytesWritten) 42 return FALSE; 43 $result = $result + $bytesWritten; 44 } 45 46 return $result; 47 } 48 } 49 50 if (!function_exists('scandir')) { 51 function scandir($dir) 52 { 53 if (!is_dir($dir)) 54 return FALSE; 55 56 $dh = opendir($dir); 57 while ($filename = readdir($dh)) { 58 $files[] = $filename; 59 } 60 61 closedir($dh); 62 sort($files); 63 64 return $files; 65 } 66 } 67 35 68 ?>
Note: See TracChangeset
for help on using the changeset viewer.