Changeset 165569 in webkit


Ignore:
Timestamp:
Mar 13, 2014 3:02:17 PM (10 years ago)
Author:
Andres Gomez
Message:

Unreviewed, rolling out r165536.

It breaks http/tests/media/media-play-stream-chunked-icy.html

Reverted changeset:

"[GStreamer] WebKit gets stalled when trying to play a stream"
https://bugs.webkit.org/show_bug.cgi?id=125926
http://trac.webkit.org/changeset/165536

Location:
trunk/LayoutTests
Files:
6 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r165545 r165569  
     12014-03-13  Andres Gomez  <agomez@igalia.com>
     2
     3        Unreviewed, rolling out r165536.
     4
     5        It breaks http/tests/media/media-play-stream-chunked-icy.html
     6
     7        Reverted changeset:
     8
     9        "[GStreamer] WebKit gets stalled when trying to play a stream"
     10        https://bugs.webkit.org/show_bug.cgi?id=125926
     11        http://trac.webkit.org/changeset/165536
     12
    1132014-03-13  Brian Burg  <bburg@apple.com>
    214
  • trunk/LayoutTests/http/tests/media/resources/serve-video.php

    r165536 r165569  
    11<?php
    22
    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.
     3    $fileName = $_GET["name"];
     4    $type = $_GET["type"];
     5    if (array_key_exists("ranges", $_GET))
     6        $ranges = $_GET["ranges"];
    77
    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     }
    28     $fileName = $_GET["name"];
    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
    698    $fileSize = filesize($fileName);
    709    $start = 0;
    7110    $end = $fileSize - 1;
    72     if ($settings["supportRanges"] != "no" && array_key_exists("HTTP_RANGE", $_SERVER))
     11    if ($ranges != "no")
    7312        $contentRange = $_SERVER["HTTP_RANGE"];
    7413    if (isset($contentRange)) {
     
    7716        if (!empty($range[1]))
    7817            $end = intval($range[1]);
    79         $settings["httpStatus"] = "206 Partial Content";
     18        $httpStatus = "206 Partial Content";
    8019    } else
    81         $settings["httpStatus"] = "200 OK";
     20        $httpStatus = "200 OK";
    8221
    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 
     22    header("Status: " . $httpStatus);
     23    header("HTTP/1.1 " . $httpStatus);
    10924    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    11025    header("Pragma: no-cache");
    11126    header("Etag: " . '"' . $fileSize . "-" . filemtime($fileName) . '"');
    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")
     27    header("Content-Type: " . $type);
     28    if ($ranges != "no")
    12629        header("Accept-Ranges: bytes");
    127     if ($settings["setContentLength"] != "no")
    128         header("Content-Length: " . ($end - $start + 1));
     30    header("Content-Length: " . ($end - $start + 1));
    12931    if (isset($contentRange))
    13032        header("Content-Range: bytes " . $start . "-" . $end . "/" . $fileSize);
     33    header("Connection: close");
    13134
     35    $chunkSize = 1024 * 256;
    13236    $offset = $start;
    13337
     
    13640
    13741    while (!feof($fn) && $offset <= $end && connection_status() == 0) {
    138         $readSize = min($settings["chunkSize"], ($end - $offset) + 1);
     42        $readSize = min($chunkSize, ($end - $offset) + 1);
    13943        $buffer = fread($fn, $readSize);
    14044        print($buffer);
    14145        flush();
    142         $offset += $settings["chunkSize"];
     46        $offset += $chunkSize;
    14347    }
    14448    fclose($fn);
  • trunk/LayoutTests/http/tests/resources/portabilityLayer.php

    r165536 r165569  
    3333}
    3434
    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 
    6835?>
Note: See TracChangeset for help on using the changeset viewer.