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 +++++--------------- istream.sh | 2 +- 5 files changed, 90 insertions(+), 50 deletions(-) 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"; diff --git a/istream.sh b/istream.sh index 2cfe28c..3862e34 100755 --- a/istream.sh +++ b/istream.sh @@ -35,7 +35,7 @@ cd ram/$SESSION -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$SESSION/ $SEGWIN && rm streamsegmenterpid & +$SEGMENTERPATH - $SEGDUR stream stream.m3u8 $HTTP_PATH$SESSION/ $SEGWIN & // Save segmenterpid echo "$!" > streamsegmenterpid -- cgit v1.2.3