diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-27 03:26:17 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-27 03:26:17 +0100 |
commit | 05a58ef6e05078fde0e90f74bf2a609dbc543fd5 (patch) | |
tree | 621691bedfd73d2f0642c39a4f9c2d00934c3584 | |
parent | 32b78254c76ebd9a07ad19edf25f1f0846a33bb8 (diff) | |
download | istreamdev-05a58ef6e05078fde0e90f74bf2a609dbc543fd5.tar.gz istreamdev-05a58ef6e05078fde0e90f74bf2a609dbc543fd5.tar.bz2 |
Sessions are now working yeah!
-rwxr-xr-x | includes/inc_files.php | 75 | ||||
-rwxr-xr-x | includes/inc_home.php | 16 | ||||
-rwxr-xr-x | includes/inc_session.php | 16 | ||||
-rwxr-xr-x | includes/inc_stream.php | 31 | ||||
-rwxr-xr-x | 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: <i>" .sec2hms($fileinfo['playtime_seconds']) ."</i><br>"; + if ($fileinfo['fileformat']) + $info .= "Format: <i>" .$fileinfo['fileformat'] ."</i><br>"; + if ($fileinfo['video']['codec']) + $info .= "Video: <i>" .$fileinfo['video']['codec'] ."</i><br>"; + if ($fileinfo['audio']['codec']) + $info .= "Audio: <i>" .$fileinfo['audio']['codec'] ."</i><br>"; + if ($fileinfo['video']['resolution_x']) + $info .= "Resolution: <i>" .$fileinfo['video']['resolution_x'] ."x" .$fileinfo['video']['resolution_y'] ."</i><br>"; + + 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: <i>" .sec2hms($fileinfo['playtime_seconds']) ."</i><br>"; - if ($fileinfo['fileformat']) - $info .= "Format: <i>" .$fileinfo['fileformat'] ."</i><br>"; - if ($fileinfo['video']['codec']) - $info .= "Video: <i>" .$fileinfo['video']['codec'] ."</i><br>"; - if ($fileinfo['audio']['codec']) - $info .= "Audio: <i>" .$fileinfo['audio']['codec'] ."</i><br>"; - if ($fileinfo['video']['resolution_x']) - $info .= "Resolution: <i>" .$fileinfo['video']['resolution_x'] ."x" .$fileinfo['video']['resolution_y'] ."</i><br>"; - - // 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 "<div id=\"title\">iStreamdev</div>\r\n"; print "</div>\r\n";
print "<div id=\"content\">\r\n";
+$sessioncnt = 0;
+
+print " <span class=\"graytitle\">SESSIONS</span>\r\n";
+print " <ul class=\"pageitem\">\r\n";
+
// Streaming in progress
$dir_handle = @opendir('ram/');
if ($dir_handle)
{
- print " <ul class=\"pageitem\">\r\n";
while ($session = readdir($dir_handle))
{
if($session == "." || $session == ".." || $session == 'lost+found')
@@ -32,7 +36,7 @@ if ($dir_handle) break;
case 2:
$sessionname = "Rec: ";
- $picto = "rec";
+ $picto = "record";
break;
case 3:
$sessionname = "Media: ";
@@ -42,6 +46,8 @@ if ($dir_handle) continue;
}
+ $sessioncnt++;
+
$sessionname .= $realname;
print " <li class=\"menu\">";
@@ -55,11 +61,15 @@ if ($dir_handle) print " <input name=\"session\" type=\"hidden\" id=\"session\" value=\"{$session}\" />";
print " </form>\r\n";
}
- print " </ul>\r\n";
closedir($dir_handle);
}
+if (!$sessioncnt)
+ print "<li class=\"textbox\"><p>none</p></li>\r\n";
+
+print " </ul>\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 " <span class=\"graytitle\">Select stream mode</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"; -} +// Get logo +if ($type == 2) + generatelogo($type, $realname, 'ram/tmp-logo.png'); +else + generatelogo($type, $name, 'ram/tmp-logo.png'); -print " <center><img src=\"{$logopath}\"></img></center>\r\n"; +print " <center><img src=\"ram/tmp-logo.png\"></img></center>\r\n"; print " </ul>\r\n"; @@ -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 |