diff options
-rwxr-xr-x | includes/inc_home.php | 25 | ||||
-rwxr-xr-x | includes/inc_session.php | 57 | ||||
-rwxr-xr-x | includes/inc_stream.php | 308 | ||||
-rwxr-xr-x | includes/inc_streaminfo.php | 18 | ||||
-rwxr-xr-x | includes/inc_streaming.php | 63 | ||||
-rwxr-xr-x | includes/include.php | 77 | ||||
-rwxr-xr-x | istream.sh | 5 |
7 files changed, 291 insertions, 262 deletions
diff --git a/includes/inc_home.php b/includes/inc_home.php index d907b87..0c372ac 100755 --- a/includes/inc_home.php +++ b/includes/inc_home.php @@ -8,6 +8,31 @@ print "<div id=\"title\">iStreamdev</div>\r\n"; print "</div>\r\n";
print "<div id=\"content\">\r\n";
+// Streaming in progress
+$dir_handle = @opendir('ram');
+if ($dir_handle)
+{
+ print " <span class=\"graytitle\">Streaming...</span>\r\n";
+ print " <ul class=\"pageitem\">\r\n";
+ while ($session = readdir($dir_handle))
+ {
+ if (!is_dir($session))
+ continue;
+
+ print " <li class=\"menu\">";
+ print " <a href=\"javascript:sendForm('{$session}');\">";
+ print " <img src=\"images/pictos/tv.png\" />";
+ print " <span class=\"name\">{$session}</span><span class=\"arrow\"></span>";
+ print " </a>";
+ print " </li>\r\n";
+ print " <form name=\"{$session}\" id=\"{$session}\" method=\"post\" action=\"index.php\">";
+ print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"streaming\" />";
+ print " <input name=\"session\" type=\"hidden\" id=\"session\" value=\"{$session}\" />";
+ print " </form>\r\n";
+ }
+ print " </ul>\r\n";
+}
+
// VDR menus
if ($vdrenabled)
{
diff --git a/includes/inc_session.php b/includes/inc_session.php new file mode 100755 index 0000000..c74d780 --- /dev/null +++ b/includes/inc_session.php @@ -0,0 +1,57 @@ +<?php + +function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir) +{ + global $httppath, $ffmpegpath, $segmenterpath; + + // TODO: Get a session + $session = session0; + + // Create session + exec('mkdir ram/' .$session); + + switch ($type) + { + case 1: + $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \" | at now"; + break; + case 2: + $cmd = "export SHELL=\"/bin/sh\";printf \"cat \\\"" .$url ."\\\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \" | at now"; + break; + case 3: + $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \" | at now"; + break; + default: + $cmd = ""; + } + + $cmd = str_replace('%', '%%', $cmd); + exec($cmd); + + // Write streaminfo + writeinfostream($session, $type, $name, $title, $desc, $qname, $category, $url, $mediapath, $subdir); + + return $session; +} + +function sessiondelete($session) +{ + $ram = "ram/" .$session ."/"; + $subcmd = ""; + + // Get segmenter PID if any + if (file_exists($ram ."streamsegmenterpid")) + { + $pidfile = fopen($ram ."streamsegmenterpid", 'r'); + if ($pidfile) + { + $pid = fgets($pidfile); + $pid = substr($pid, 0, -1); + $subcmd = "kill " .$pid ." ; "; + fclose($pidfile); + } + } + + $cmd= $subcmd ."rm -rf " .$ram; + exec ($cmd); +?> diff --git a/includes/inc_stream.php b/includes/inc_stream.php index 1e65633..f29271e 100755 --- a/includes/inc_stream.php +++ b/includes/inc_stream.php @@ -2,228 +2,144 @@ global $vdrstreamdev, $quality; -// Check if we are running -if (infostreamexist()) -{ - // Get current stream info - list($type, $realname, $title, $desc, $mode, $category, $url, $mediapath, $subdir) = readinfostream(); - - print "<body onorientationchange=\"updateOrientation();\" onload=\"ajax();\">\r\n"; - - print "<div id=\"topbar\" class=\"transparent\">\r\n"; - print "<div id=\"leftnav\">\r\n"; - print "<a href=\"javascript:sendForm('stopstream');\">Stop Stream</a></div>\r\n"; - print "<div id=\"title\">iStreamdev</div>\r\n"; - print "</div>\r\n"; - - print "<div id=\"content\">\r\n"; - print " <span class=\"graytitle\">Now streaming</span>\r\n"; - - // Print the right logo - print " <ul class=\"pageitem\">\r\n"; - - switch ($type) - { - case 1: - $channoslash = preg_replace("$/$", " ", $realname); - $logopath = "logos/" .$channoslash .".png"; - if (!file_exists($logopath)) - $logopath = "logos/nologoTV.png"; - break; - case 2: - $channoslash = preg_replace("$/$", " ", $realname); - $logopath = "logos/" .$channoslash .".png"; - if (!file_exists($logopath)) - $logopath = "logos/nologoREC.png"; - break; - case 3: - if (file_exists("ram/stream-tb.png")) - $logopath = "ram/stream-tb.png"; - else if (file_exists("ram/stream-tb.jpg")) - $logopath = "ram/stream-tb.jpg"; - else - $logopath = "logos/nologoMEDIA.png"; - } - +$category = $_SESSION['currentcat']; - $logowidth = mediagetwidth($logopath); - print " <center><video id=\"videofeed\" width=\"{$logowidth}\" poster=\"{$logopath}\" /></center>\r\n"; +$type = $_REQUEST['type']; +$name = $_REQUEST['name']; - print " </ul>\r\n"; - - print " <ul class=\"pageitem\">\r\n"; - print " <li class=\"textbox\"><span class=\"header\">{$realname}</span><p><strong>{$title}</strong>\r\n"; - print " <br>{$desc}</p></li></ul>\r\n"; - - print " <ul class=\"pageitem\">\r\n"; - print " <li id=\"modetext\" class=\"textbox\"><span class=\"header\">Mode</span>\r\n"; - print " <p id='streamtitle'>{$mode}</p></li></ul>\r\n"; - - print " </div>\r\n"; - - print " <form name=\"stopstream\" id=\"stopstream\" method=\"post\" action=\"index.php\">"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stopstream\" />"; - print " <input name=\"actionafterstop\" type=\"hidden\" id=\"actionafterstop\" value=\"stream\" />"; - print " <input name=\"type\" type=\"hidden\" id=\"type\" value={$type} />"; - switch ($type) - { - case 1: - print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$realname}\" />"; - break; - case 3: - print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; - print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; - // NO BREAK - case 2: - print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$url}\" />"; - break; - - } - print " </form>\r\n"; -} -else +switch ($type) { - $category = $_SESSION['currentcat']; - - $type = $_REQUEST['type']; - $name = $_REQUEST['name']; - - switch ($type) - { - // Live TV - case 1: - list($title, $desc, $realname) = vdrgetinfostream($name, 1); - $channum = vdrgetchannum($realname); - break; - // Recording - case 2: - list($title, $desc, $realname) = vdrgetinfostream($name, 0); - break; - // Media - case 3: - list($title, $desc) = mediagetinfostream($name); - $realname = basename($name); - break; - default: - $realname = ""; - $title = ""; - $desc = ""; - $channame = ""; - } + // Live TV + case 1: + list($title, $desc, $realname) = vdrgetinfostream($name, 1); + $channum = vdrgetchannum($realname); + break; + // Recording + case 2: + list($title, $desc, $realname) = vdrgetinfostream($name, 0); + break; + // Media + case 3: + list($title, $desc) = mediagetinfostream($name); + $realname = basename($name); + break; + default: + $realname = ""; + $title = ""; + $desc = ""; + $channame = ""; +} - print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n"; +print "<body onorientationchange=\"updateOrientation();\" onload=\"updateOrientation();\">\r\n"; - print "<div id=\"topbar\" class=\"transparent\">\r\n"; - print "<div id=\"leftnav\">\r\n"; +print "<div id=\"topbar\" class=\"transparent\">\r\n"; +print "<div id=\"leftnav\">\r\n"; - print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n"; - print "<div id=\"rightnav\">\r\n"; - print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; +print "<a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n"; +print "<div id=\"rightnav\">\r\n"; +print "<a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n"; - print "<div id=\"title\">iStreamdev</div>\r\n"; - print "</div>\r\n"; +print "<div id=\"title\">iStreamdev</div>\r\n"; +print "</div>\r\n"; - print "<div id=\"content\">\r\n"; +print "<div id=\"content\">\r\n"; - print " <span class=\"graytitle\">Select stream mode</span>\r\n"; +print " <span class=\"graytitle\">Select stream mode</span>\r\n"; - // Print the right logo - print " <ul class=\"pageitem\">\r\n"; +// Print the right logo +print " <ul class=\"pageitem\">\r\n"; - switch ($type) - { - case 1: - $channoslash = preg_replace("$/$", " ", $realname); - $logopath = "logos/" .$channoslash .".png"; - if (!file_exists($logopath)) - $logopath = "logos/nologoTV.png"; - break; - case 2: - $channoslash = preg_replace("$/$", " ", $realname); - $logopath = "logos/" .$channoslash .".png"; - if (!file_exists($logopath)) - $logopath = "logos/nologoREC.png"; - break; - case 3: - if (file_exists("ram/stream-tb.png")) - $logopath = "ram/stream-tb.png"; - else if (file_exists("ram/stream-tb.jpg")) - $logopath = "ram/stream-tb.jpg"; - else - $logopath = "logos/nologoMEDIA.png"; - } +switch ($type) +{ + case 1: + $channoslash = preg_replace("$/$", " ", $realname); + $logopath = "logos/" .$channoslash .".png"; + if (!file_exists($logopath)) + $logopath = "logos/nologoTV.png"; + break; + case 2: + $channoslash = preg_replace("$/$", " ", $realname); + $logopath = "logos/" .$channoslash .".png"; + if (!file_exists($logopath)) + $logopath = "logos/nologoREC.png"; + break; + case 3: + if (file_exists("ram/stream-tb.png")) + $logopath = "ram/stream-tb.png"; + else if (file_exists("ram/stream-tb.jpg")) + $logopath = "ram/stream-tb.jpg"; + else + $logopath = "logos/nologoMEDIA.png"; +} - print " <center><img src=\"{$logopath}\"></img></center>\r\n"; +print " <center><img src=\"{$logopath}\"></img></center>\r\n"; - print " </ul>\r\n"; +print " </ul>\r\n"; - // Check if running to display the start buttons - print " <div id=\"tributton\">\r\n"; - print " <div class=\"links\">\r\n"; +print " <div id=\"tributton\">\r\n"; +print " <div class=\"links\">\r\n"; - foreach ($quality as $qname => $qparams) - print "<a href=\"javascript:sendForm('$qname')\">{$qname}</a>"; - print "\r\n"; +foreach ($quality as $qname => $qparams) + print "<a href=\"javascript:sendForm('$qname')\">{$qname}</a>"; +print "\r\n"; - print " </div></div>\r\n"; +print " </div></div>\r\n"; - print " <ul class=\"pageitem\">\r\n"; - print " <li class=\"textbox\"><span class=\"header\">{$realname}</span><p><strong>{$title}</strong>\r\n"; - print " <br>{$desc}</p></li></ul>\r\n"; +print " <ul class=\"pageitem\">\r\n"; +print " <li class=\"textbox\"><span class=\"header\">{$realname}</span><p><strong>{$title}</strong>\r\n"; +print " <br>{$desc}</p></li></ul>\r\n"; - print " </div>\r\n"; +print " </div>\r\n"; - foreach ($quality as $qname => $qparams) +foreach ($quality as $qname => $qparams) +{ + print " <form name=\"{$qname}\" id=\"{$qname}\" method=\"post\" action=\"index.php\">\r\n"; + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"startstream\" />\r\n"; + print " <input name=\"type\" type=\"hidden\" id=\"type\" value={$type} />\r\n"; + print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$realname}\" />\r\n"; + print " <input name=\"title\" type=\"hidden\" id=\"title\" value=\"{$title}\" />\r\n"; + print " <input name=\"desc\" type=\"hidden\" id=\"desc\" value=\"{$desc}\" />\r\n"; + print " <input name=\"qname\" type=\"hidden\" id=\"qname\" value=\"{$qname}\" />\r\n"; + print " <input name=\"qparams\" type=\"hidden\" id=\"qparams\" value=\"{$qparams}\" />\r\n"; + print " <input name=\"category\" type=\"hidden\" id=\"category\" value=\"{$category}\" />\r\n"; + switch ($type) { - print " <form name=\"{$qname}\" id=\"{$qname}\" method=\"post\" action=\"index.php\">\r\n"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"startstream\" />\r\n"; - print " <input name=\"type\" type=\"hidden\" id=\"type\" value={$type} />\r\n"; - print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$realname}\" />\r\n"; - print " <input name=\"title\" type=\"hidden\" id=\"title\" value=\"{$title}\" />\r\n"; - print " <input name=\"desc\" type=\"hidden\" id=\"desc\" value=\"{$desc}\" />\r\n"; - print " <input name=\"qname\" type=\"hidden\" id=\"qname\" value=\"{$qname}\" />\r\n"; - print " <input name=\"qparams\" type=\"hidden\" id=\"qparams\" value=\"{$qparams}\" />\r\n"; - print " <input name=\"category\" type=\"hidden\" id=\"category\" value=\"{$category}\" />\r\n"; - switch ($type) - { - case 1: - print " <input name=\"url\" type=\"hidden\" id=\"url\" value=\"{$vdrstreamdev}{$channum}\" />\r\n"; - break; - case 3: - $mediapath = $_REQUEST['mediapath']; - $subdir = $_REQUEST['subdir']; - print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; - print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; - // NO BREAK - case 2: - print " <input name=\"url\" type=\"hidden\" id=\"url\" value=\"{$name}\" />\r\n"; - break; - } - print " </form>"; - } - - print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">"; - switch ($type) - { - case 1: - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"listchannels\" />"; - print " <input name=\"cat\"type=\"hidden\" id=\"cat\" value=\"{$category}\" />"; - break; - case 2: - $dir = dirname($name); - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"recordings\" />"; - print " <input name=\"dir\"type=\"hidden\" id=\"dir\" value=\"{$dir}\" />"; - break; + case 1: + print " <input name=\"url\" type=\"hidden\" id=\"url\" value=\"{$vdrstreamdev}{$channum}\" />\r\n"; + break; case 3: $mediapath = $_REQUEST['mediapath']; $subdir = $_REQUEST['subdir']; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"video\" />"; print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; - break; - } - print " </form>\r\n"; + // NO BREAK + case 2: + print " <input name=\"url\" type=\"hidden\" id=\"url\" value=\"{$name}\" />\r\n"; + break; + } + print " </form>"; +} +print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">"; +switch ($type) +{ + case 1: + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"listchannels\" />"; + print " <input name=\"cat\"type=\"hidden\" id=\"cat\" value=\"{$category}\" />"; + break; + case 2: + $dir = dirname($name); + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"recordings\" />"; + print " <input name=\"dir\"type=\"hidden\" id=\"dir\" value=\"{$dir}\" />"; + break; + case 3: + $mediapath = $_REQUEST['mediapath']; + $subdir = $_REQUEST['subdir']; + print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"video\" />"; + print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; + print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; + break; } +print " </form>\r\n"; ?> diff --git a/includes/inc_streaminfo.php b/includes/inc_streaminfo.php index 576bd5d..e41b24f 100755 --- a/includes/inc_streaminfo.php +++ b/includes/inc_streaminfo.php @@ -8,9 +8,11 @@ 3 : Media */ -function writeinfostream($type=0, $name="", $title="", $desc="", $mode="", $category="", $url="", $mediapath="", $subdir="") +function writeinfostream($session, $type=0, $name="", $title="", $desc="", $mode="", $category="", $url="", $mediapath="", $subdir="") { - $infofile = fopen("ram/streaminfo", 'w'); + $ram = "ram/" .$session ."/"; + + $infofile = fopen($ram ."streaminfo", 'w'); fwrite($infofile, "type=" .$type ."\n"); fwrite($infofile, "name=" .$name ."\n"); @@ -26,13 +28,14 @@ function writeinfostream($type=0, $name="", $title="", $desc="", $mode="", $cate } -function readinfostream() +function readinfostream($session) { + $ram = "ram/" .$session ."/"; - if (!file_exists("ram/streaminfo")) + if (!file_exists($session ."streaminfo")) return array(0, "", "", "", ""); - $infofile = fopen("ram/streaminfo", 'r'); + $infofile = fopen($session ."streaminfo", 'r'); if (!$infofile) return array(0, "", "", "", ""); @@ -63,9 +66,4 @@ function readinfostream() return array($type, $name, $title, $desc, $mode, $category, $url, $mediapath, $subdir); } -function infostreamexist() -{ - return file_exists("ram/streaminfo"); -} - ?> diff --git a/includes/inc_streaming.php b/includes/inc_streaming.php new file mode 100755 index 0000000..9da377f --- /dev/null +++ b/includes/inc_streaming.php @@ -0,0 +1,63 @@ +<?php + +global $vdrstreamdev, $quality; + +// Get $session if we are not directly included from startstream +if ($session == "") + $session = $_REQUEST['session']; + +$ram = "ram/" .$session ."/"; + +// Get current stream info +list($type, $realname, $title, $desc, $mode, $category, $url, $mediapath, $subdir) = readinfostream($session); + +print "<body onorientationchange=\"updateOrientation();\" onload=\"ajax();\">\r\n"; + +print "<div id=\"topbar\" class=\"transparent\">\r\n"; +print "<div id=\"leftnav\">\r\n"; +print "<a href=\"javascript:sendForm('stopstream');\">Stop Stream</a></div>\r\n"; +print "<div id=\"title\">iStreamdev</div>\r\n"; +print "</div>\r\n"; + +print "<div id=\"content\">\r\n"; +print " <span class=\"graytitle\">Now streaming</span>\r\n"; + +// Print the right logo +print " <ul class=\"pageitem\">\r\n"; + +$logopath=$ram ."/logo.png"; +$logowidth = mediagetwidth($logopath); +print " <center><video id=\"videofeed\" width=\"{$logowidth}\" poster=\"{$logopath}\" /></center>\r\n"; + +print " </ul>\r\n"; + +print " <ul class=\"pageitem\">\r\n"; +print " <li class=\"textbox\"><span class=\"header\">{$realname}</span><p><strong>{$title}</strong>\r\n"; +print " <br>{$desc}</p></li></ul>\r\n"; + +print " <ul class=\"pageitem\">\r\n"; +print " <li id=\"modetext\" class=\"textbox\"><span class=\"header\">Mode</span>\r\n"; +print " <p id='streamtitle'>{$mode}</p></li></ul>\r\n"; + +print " </div>\r\n"; + +print " <form name=\"stopstream\" id=\"stopstream\" method=\"post\" action=\"index.php\">"; +print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stopstream\" />"; +print " <input name=\"type\" type=\"hidden\" id=\"type\" value={$type} />"; +switch ($type) +{ + case 1: + print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$realname}\" />"; + break; + case 3: + print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n"; + print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n"; + // NO BREAK + case 2: + print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$url}\" />"; + break; + +} + +print " </form>\r\n"; +?> diff --git a/includes/include.php b/includes/include.php index 5324609..ae77137 100755 --- a/includes/include.php +++ b/includes/include.php @@ -4,6 +4,7 @@ if (file_exists('config.php')) include ('config.php'); else include ('config_default.php'); +include ('includes/inc_session.php'); include ('includes/inc_utils.php'); include ('includes/inc_auth.php'); include ('includes/inc_vdr.php'); @@ -15,34 +16,28 @@ function selectpage() { $action = $_REQUEST['action']; - if ($action == "stopstream") - { - $subcmd = ""; - - // Get segmenter PID - if (file_exists("ram/streamsegmenterpid")) - { - $pidfile = fopen('ram/streamsegmenterpid', 'r'); - if ($pidfile) - { - $pid = fgets($pidfile); - $pid = substr($pid, 0, -1); - $subcmd = "kill " .$pid ." ; "; - fclose($pidfile); - } - } - - $cmd= $subcmd ."rm ram/stream*"; - exec ($cmd); - - $action = $_REQUEST['actionafterstop']; - } - - if (infostreamexist()) - $action = "stream"; - switch ($action) { + case ("streaming"): + include('includes/inc_streaming.php'); + break; + case ("startstream"): + $type = $_REQUEST['type']; + $name = $_REQUEST['name']; + $title = $_REQUEST['title']; + $desc = stripslashes ($_REQUEST['desc']); + $qname = $_REQUEST['qname']; + $qparams = $_REQUEST['qparams']; + $category = $_REQUEST['category']; + $url = $_REQUEST['url']; + $mediapath = $_REQUEST['mediapath']; + $subdir = $_REQUEST['subdir']; + $session = sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir); + include('includes/inc_streaming.php'); + break; + case ("stopstream"): + sessiondelete($_REQUEST['session']); + // NO BREAK; case ("stream"): include('includes/inc_stream.php'); break; @@ -97,8 +92,8 @@ function selectpage() $url = $_REQUEST['url']; $mediapath = $_REQUEST['mediapath']; $subdir = $_REQUEST['subdir']; - start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir); - include('includes/inc_stream.php'); + $session = start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir); + include('includes/inc_streaming.php'); break; case ("playdir"): include('includes/inc_mp3.php'); @@ -110,32 +105,6 @@ function selectpage() } } -function start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir) -{ - global $httppath, $ffmpegpath, $segmenterpath; - - switch ($type) - { - case 1: - $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." \" | at now"; - break; - case 2: - $cmd = "export SHELL=\"/bin/sh\";printf \"cat \\\"" .$url ."\\\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." \" | at now"; - break; - case 3: - $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." \" | at now"; - break; - default: - $cmd = ""; - } - - $cmd = str_replace('%', '%%', $cmd); - exec($cmd); - - // Write streaminfo - writeinfostream($type, $name, $title, $desc, $qname, $category, $url, $mediapath, $subdir); -} - function delete_timer($timer) { $ret = vdrdeltimer($timer); @@ -11,6 +11,7 @@ SEGDUR=10 # Length of Segments produced (between 10 and 30) SEGWIN=$7 # Amount of Segments to produce FFPATH=$8 SEGMENTERPATH=$9 +SESSION=$10 if [ $# -eq 0 ] then @@ -26,14 +27,14 @@ fi test -L ram && (test -d /dev/shm/ram || mkdir /dev/shm/ram) -cd ram +cd ram/$SESSION 2> /dev/null rm stream*.ts 2> /dev/null $FFPATH -i "$STREAM" -deinterlace -f mpegts -acodec libmp3lame -ab $ARATE -ac $ACHANNELS -s $XY -vcodec libx264 -b $VRATE -flags +loop \ -cmp \+chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 \ -sc_threshold 40 -i_qfactor 0.71 -bt $VRATE -maxrate $VRATE -bufsize $VRATE -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 \ -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 30 -async 2 -threads 4 - | \ -$SEGMENTERPATH - $SEGDUR stream stream.m3u8 $HTTP_PATH $SEGWIN & +$SEGMENTERPATH - $SEGDUR stream stream.m3u8 $HTTP_PATH$SESSION $SEGWIN && rm streamsegmenterpid & // Save segmenterpid echo "$!" > streamsegmenterpid |