From 0c9414a9fecf2278d468acb1cf184e776b5a15c7 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Sat, 27 Feb 2010 01:04:29 +0100 Subject: Multiple sessions support WIP --- includes/inc_home.php | 25 ++++ includes/inc_session.php | 57 ++++++++ includes/inc_stream.php | 308 ++++++++++++++++---------------------------- includes/inc_streaminfo.php | 18 ++- includes/inc_streaming.php | 63 +++++++++ includes/include.php | 77 ++++------- 6 files changed, 288 insertions(+), 260 deletions(-) create mode 100755 includes/inc_session.php create mode 100755 includes/inc_streaming.php (limited to 'includes') 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 "
iStreamdev
\r\n"; print "\r\n"; print "
\r\n"; +// Streaming in progress +$dir_handle = @opendir('ram'); +if ($dir_handle) +{ + print " Streaming...\r\n"; + print " \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 @@ + 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 "\r\n"; - - print "
\r\n"; - print "
\r\n"; - print "Stop Stream
\r\n"; - print "
iStreamdev
\r\n"; - print "
\r\n"; - - print "
\r\n"; - print " Now streaming\r\n"; - - // Print the right logo - print "
    \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 "
    \r\n"; +$type = $_REQUEST['type']; +$name = $_REQUEST['name']; - print "
\r\n"; - - print "
    \r\n"; - print "
  • {$realname}

    {$title}\r\n"; - print "
    {$desc}

\r\n"; - - print "
    \r\n"; - print "
  • Mode\r\n"; - print "

    {$mode}

\r\n"; - - print "
\r\n"; - - print "
"; - print " "; - print " "; - print " "; - switch ($type) - { - case 1: - print " "; - break; - case 3: - print " \r\n"; - print " \r\n"; - // NO BREAK - case 2: - print " "; - break; - - } - print "
\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 "\r\n"; +print "\r\n"; - print "
\r\n"; - print "
\r\n"; +print "
\r\n"; +print "
\r\n"; - print "Back
\r\n"; - print "
\r\n"; - print "\"home\"
\r\n"; +print "Back
\r\n"; +print "
\r\n"; +print "\"home\"
\r\n"; - print "
iStreamdev
\r\n"; - print "
\r\n"; +print "
iStreamdev
\r\n"; +print "
\r\n"; - print "
\r\n"; +print "
\r\n"; - print " Select stream mode\r\n"; +print " Select stream mode\r\n"; - // Print the right logo - print "
    \r\n"; +// Print the right logo +print "
      \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 "
      \r\n"; +print "
      \r\n"; - print "
    \r\n"; +print "
\r\n"; - // Check if running to display the start buttons - print "
\r\n"; - print "
\r\n"; +print "
\r\n"; +print "
\r\n"; - foreach ($quality as $qname => $qparams) - print "{$qname}"; - print "\r\n"; +foreach ($quality as $qname => $qparams) + print "{$qname}"; +print "\r\n"; - print "
\r\n"; +print "
\r\n"; - print "
    \r\n"; - print "
  • {$realname}

    {$title}\r\n"; - print "
    {$desc}

\r\n"; +print "
    \r\n"; +print "
  • {$realname}

    {$title}\r\n"; +print "
    {$desc}

\r\n"; - print "
\r\n"; +print "
\r\n"; - foreach ($quality as $qname => $qparams) +foreach ($quality as $qname => $qparams) +{ + print "
\r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + print " \r\n"; + switch ($type) { - print " \r\n"; - print " \r\n"; - print " \r\n"; - print " \r\n"; - print " \r\n"; - print " \r\n"; - print " \r\n"; - print " \r\n"; - print " \r\n"; - switch ($type) - { - case 1: - print " \r\n"; - break; - case 3: - $mediapath = $_REQUEST['mediapath']; - $subdir = $_REQUEST['subdir']; - print " \r\n"; - print " \r\n"; - // NO BREAK - case 2: - print " \r\n"; - break; - } - print "
"; - } - - print "
"; - switch ($type) - { - case 1: - print " "; - print " "; - break; - case 2: - $dir = dirname($name); - print " "; - print " "; - break; + case 1: + print " \r\n"; + break; case 3: $mediapath = $_REQUEST['mediapath']; $subdir = $_REQUEST['subdir']; - print " "; print " \r\n"; print " \r\n"; - break; - } - print "
\r\n"; + // NO BREAK + case 2: + print " \r\n"; + break; + } + print " "; +} +print "
"; +switch ($type) +{ + case 1: + print " "; + print " "; + break; + case 2: + $dir = dirname($name); + print " "; + print " "; + break; + case 3: + $mediapath = $_REQUEST['mediapath']; + $subdir = $_REQUEST['subdir']; + print " "; + print " \r\n"; + print " \r\n"; + break; } +print "
\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 @@ +\r\n"; + +print "
\r\n"; +print "
\r\n"; +print "Stop Stream
\r\n"; +print "
iStreamdev
\r\n"; +print "
\r\n"; + +print "
\r\n"; +print " Now streaming\r\n"; + +// Print the right logo +print "
    \r\n"; + +$logopath=$ram ."/logo.png"; +$logowidth = mediagetwidth($logopath); +print "
    \r\n"; + +print "
\r\n"; + +print "
    \r\n"; +print "
  • {$realname}

    {$title}\r\n"; +print "
    {$desc}

\r\n"; + +print "
    \r\n"; +print "
  • Mode\r\n"; +print "

    {$mode}

\r\n"; + +print "
\r\n"; + +print "
"; +print " "; +print " "; +switch ($type) +{ + case 1: + print " "; + break; + case 3: + print " \r\n"; + print " \r\n"; + // NO BREAK + case 2: + print " "; + break; + +} + +print "
\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); -- cgit v1.2.3