From 05a58ef6e05078fde0e90f74bf2a609dbc543fd5 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Sat, 27 Feb 2010 03:26:17 +0100 Subject: Sessions are now working yeah! --- includes/inc_files.php | 75 +++++++++++++++++++++++++++++++++++------------- includes/inc_home.php | 16 +++++++++-- includes/inc_session.php | 16 +++++++++-- includes/inc_stream.php | 31 +++++--------------- 4 files changed, 89 insertions(+), 49 deletions(-) (limited to 'includes') diff --git a/includes/inc_files.php b/includes/inc_files.php index c3cda85..dc8c0a8 100755 --- a/includes/inc_files.php +++ b/includes/inc_files.php @@ -2,7 +2,27 @@ $audiotypes='mp3 aac wav '; -function mediagetinfostream($stream = "") +function mediagetinfostream($stream) +{ + // Get info + $getid3 = new getID3; + $fileinfo = $getid3->analyze($stream); + + $title = "Media:"; + $info = "Duration: " .sec2hms($fileinfo['playtime_seconds']) ."
"; + if ($fileinfo['fileformat']) + $info .= "Format: " .$fileinfo['fileformat'] ."
"; + if ($fileinfo['video']['codec']) + $info .= "Video: " .$fileinfo['video']['codec'] ."
"; + if ($fileinfo['audio']['codec']) + $info .= "Audio: " .$fileinfo['audio']['codec'] ."
"; + if ($fileinfo['video']['resolution_x']) + $info .= "Resolution: " .$fileinfo['video']['resolution_x'] ."x" .$fileinfo['video']['resolution_y'] ."
"; + + return array($title, $info); +} + +function mediagentb($stream, $dest) { global $ffmpegpath; @@ -10,19 +30,7 @@ function mediagetinfostream($stream = "") $getid3 = new getID3; $fileinfo = $getid3->analyze($stream); - $title = "Media:"; - $info = "Duration: " .sec2hms($fileinfo['playtime_seconds']) ."
"; - if ($fileinfo['fileformat']) - $info .= "Format: " .$fileinfo['fileformat'] ."
"; - if ($fileinfo['video']['codec']) - $info .= "Video: " .$fileinfo['video']['codec'] ."
"; - if ($fileinfo['audio']['codec']) - $info .= "Audio: " .$fileinfo['audio']['codec'] ."
"; - if ($fileinfo['video']['resolution_x']) - $info .= "Resolution: " .$fileinfo['video']['resolution_x'] ."x" .$fileinfo['video']['resolution_y'] ."
"; - - // Extract a thumbnail - exec("rm ram/stream-tb.*"); + exec("rm " .$dest); $path = dirname($stream); if (file_exists(substr($stream, 0, -4) .".tbn")) @@ -39,7 +47,7 @@ function mediagetinfostream($stream = "") if ($file) { - $getid3 = new getID3; + $getid3 = new getID3; $fileinfo = $getid3->analyze($file); } @@ -57,13 +65,13 @@ function mediagetinfostream($stream = "") } } - if ($file) - exec("cp \"" .$file ."\" ram/stream-tb-tmp.jpg; " .$ffmpegpath ." -y -i ram/stream-tb-tmp.jpg -s " .$resx ."x" .$resy ." ram/stream-tb.jpg"); + exec("cp \"" .$file ."\" ram/stream-tb-tmp.jpg; " .$ffmpegpath ." -y -i ram/stream-tb-tmp.jpg -s " .$resx ."x" .$resy ." " .$dest ." ; rm ram/stream-tb-tmp.jpg"); else - exec($ffmpegpath ." -y -i \"" .$stream ."\" -an -ss 00:00:05.00 -r 1 -vframes 1 -s " .$resx ."x" .$resy ." -f mjpeg ram/stream-tb.png"); - - return array($title, $info); + exec($ffmpegpath ." -y -i \"" .$stream ."\" -an -ss 00:00:05.00 -r 1 -vframes 1 -s " .$resx ."x" .$resy ." -f mjpeg " .$dest); + + if (!file_exists($dest)) + exec('cp logos/nologoMEDIA.png ' .$dest); } function mediagetwidth($file) @@ -132,3 +140,30 @@ function mediagetmusicinfo($file ="") return array ($name, $duration); } + +function generatelogo($type, $name, $dest) +{ + switch ($type) + { + case 1: + $channoslash = preg_replace("$/$", " ", $name); + $logopath = "logos/" .$channoslash .".png"; + if (!file_exists($logopath)) + $logopath = "logos/nologoTV.png"; + exec("cp \"" .$logopath ."\" " .$dest); + break; + case 2: + $channoslash = preg_replace("$/$", " ", $name); + $logopath = "logos/" .$channoslash .".png"; + if (!file_exists($logopath)) + $logopath = "logos/nologoREC.png"; + exec("cp \"" .$logopath ."\" " .$dest); + break; + case 3: + // Generate TB + mediagentb($name, $dest); + break; + } +} + +?> diff --git a/includes/inc_home.php b/includes/inc_home.php index bc9a402..00a19e6 100755 --- a/includes/inc_home.php +++ b/includes/inc_home.php @@ -8,11 +8,15 @@ print "
iStreamdev
\r\n"; print "\r\n"; print "
\r\n"; +$sessioncnt = 0; + +print " SESSIONS\r\n"; +print " \r\n"; + // VDR menus if ($vdrenabled) { diff --git a/includes/inc_session.php b/includes/inc_session.php index 5c06c0c..95d01cb 100755 --- a/includes/inc_session.php +++ b/includes/inc_session.php @@ -4,8 +4,14 @@ function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, { global $httppath, $ffmpegpath, $segmenterpath; - // TODO: Get a session - $session = session0; + // Get a free session + $i=0; + for ($i=0; $i<1000; $i++) + { + $session = "session" .$i; + if (!file_exists('ram/' .$session)) + break; + } // Create session exec('mkdir ram/' .$session); @@ -31,6 +37,12 @@ function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, // Write streaminfo writeinfostream($session, $type, $name, $title, $desc, $qname, $category, $url, $mediapath, $subdir); + // Create logo + if ($type == 3) + generatelogo($type, $url, 'ram/' .$session .'/logo.png'); + else + generatelogo($type, $name, 'ram/' .$session .'/logo.png'); + // Copy status waiter exec('cp streamstatus.php ram/' .$session); diff --git a/includes/inc_stream.php b/includes/inc_stream.php index f29271e..925fd7b 100755 --- a/includes/inc_stream.php +++ b/includes/inc_stream.php @@ -20,7 +20,7 @@ switch ($type) break; // Media case 3: - list($title, $desc) = mediagetinfostream($name); + list($title, $desc) = mediagetinfostream($name, 0); $realname = basename($name); break; default: @@ -49,30 +49,13 @@ print " Select stream mode\r\n"; // Print the right logo print " \r\n"; -- cgit v1.2.3