diff options
-rwxr-xr-x | includes/inc_home.php | 39 | ||||
-rwxr-xr-x | includes/inc_session.php | 7 | ||||
-rwxr-xr-x | includes/inc_streaminfo.php | 4 | ||||
-rwxr-xr-x | includes/inc_streaming.php | 7 | ||||
-rwxr-xr-x | istream.sh | 5 | ||||
-rwxr-xr-x | javascript/ajax.js | 14 | ||||
-rwxr-xr-x | javascript/functions.js | 4 | ||||
-rwxr-xr-x | streamstatus.php | 6 |
8 files changed, 62 insertions, 24 deletions
diff --git a/includes/inc_home.php b/includes/inc_home.php index 0c372ac..bc9a402 100755 --- a/includes/inc_home.php +++ b/includes/inc_home.php @@ -9,20 +9,45 @@ print "</div>\r\n"; print "<div id=\"content\">\r\n";
// Streaming in progress
-$dir_handle = @opendir('ram');
+$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))
+ if($session == "." || $session == ".." || $session == 'lost+found')
+ continue;
+
+ if (!is_dir('ram/' .$session))
continue;
+ // Get info
+ list($type, $realname, $title, $desc, $mode, $category, $url, $mediapath, $subdir) = readinfostream($session);
+
+ switch ($type)
+ {
+ case 1:
+ $sessionname = "Live: ";
+ $picto = "tv";
+ break;
+ case 2:
+ $sessionname = "Rec: ";
+ $picto = "rec";
+ break;
+ case 3:
+ $sessionname = "Media: ";
+ $picto = "media";
+ break;
+ default:
+ continue;
+ }
+
+ $sessionname .= $realname;
+
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 " <img src=\"images/pictos/{$picto}.png\" />";
+ print " <span class=\"name\">{$sessionname}</span><span class=\"arrow\"></span>";
print " </a>";
print " </li>\r\n";
print " <form name=\"{$session}\" id=\"{$session}\" method=\"post\" action=\"index.php\">";
@@ -30,7 +55,9 @@ if ($dir_handle) print " <input name=\"session\" type=\"hidden\" id=\"session\" value=\"{$session}\" />";
print " </form>\r\n";
}
- print " </ul>\r\n";
+ print " </ul>\r\n";
+
+ closedir($dir_handle);
}
// VDR menus
diff --git a/includes/inc_session.php b/includes/inc_session.php index c74d780..5c06c0c 100755 --- a/includes/inc_session.php +++ b/includes/inc_session.php @@ -26,11 +26,14 @@ function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, } $cmd = str_replace('%', '%%', $cmd); - exec($cmd); + exec ($cmd); // Write streaminfo writeinfostream($session, $type, $name, $title, $desc, $qname, $category, $url, $mediapath, $subdir); + // Copy status waiter + exec('cp streamstatus.php ram/' .$session); + return $session; } @@ -54,4 +57,6 @@ function sessiondelete($session) $cmd= $subcmd ."rm -rf " .$ram; exec ($cmd); +} + ?> diff --git a/includes/inc_streaminfo.php b/includes/inc_streaminfo.php index e41b24f..4124396 100755 --- a/includes/inc_streaminfo.php +++ b/includes/inc_streaminfo.php @@ -32,10 +32,10 @@ function readinfostream($session) { $ram = "ram/" .$session ."/"; - if (!file_exists($session ."streaminfo")) + if (!file_exists($ram ."streaminfo")) return array(0, "", "", "", ""); - $infofile = fopen($session ."streaminfo", 'r'); + $infofile = fopen($ram ."streaminfo", 'r'); if (!$infofile) return array(0, "", "", "", ""); diff --git a/includes/inc_streaming.php b/includes/inc_streaming.php index 9da377f..a294a9d 100755 --- a/includes/inc_streaming.php +++ b/includes/inc_streaming.php @@ -11,11 +11,15 @@ $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 "<body onorientationchange=\"updateOrientation();\" onload=\"ajax('{$session}');\">\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=\"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"; @@ -43,6 +47,7 @@ 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=\"session\" type=\"hidden\" id=\"session\" value=\"{$session}\" />"; print " <input name=\"type\" type=\"hidden\" id=\"type\" value={$type} />"; switch ($type) { @@ -11,7 +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 +SESSION=${10} if [ $# -eq 0 ] then @@ -28,13 +28,14 @@ fi test -L ram && (test -d /dev/shm/ram || mkdir /dev/shm/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$SESSION $SEGWIN && rm streamsegmenterpid & +$SEGMENTERPATH - $SEGDUR stream stream.m3u8 $HTTP_PATH$SESSION/ $SEGWIN && rm streamsegmenterpid & // Save segmenterpid echo "$!" > streamsegmenterpid diff --git a/javascript/ajax.js b/javascript/ajax.js index b9291cf..98006e6 100755 --- a/javascript/ajax.js +++ b/javascript/ajax.js @@ -1,16 +1,16 @@ -function ajax() +function ajax(session) { var xhr=null; - + xhr = new XMLHttpRequest(); //on définit l'appel de la fonction au retour serveur - xhr.onreadystatechange = function() { alert_ajax(xhr); }; - - xhr.open("GET", "streamstatus.php", true); + xhr.onreadystatechange = function() { alert_ajax(xhr, session); }; + + xhr.open("GET", "ram/" + session + "/streamstatus.php", true); xhr.send(null); } -function alert_ajax(xhr) +function alert_ajax(xhr, session) { if (xhr.readyState==4) { @@ -22,7 +22,7 @@ function alert_ajax(xhr) if ( streamstatus == 'error' ) this.location.href = 'error.php'; else - swapPic(); + swapPic(session); } } diff --git a/javascript/functions.js b/javascript/functions.js index c54f44e..b713232 100755 --- a/javascript/functions.js +++ b/javascript/functions.js @@ -46,8 +46,8 @@ function sendForm(formid) { frm.submit();
}
-function swapPic() {
- document.getElementById('videofeed').src = "ram/stream.m3u8";
+function swapPic(session) {
+ document.getElementById('videofeed').src = "ram/" +session +"/stream.m3u8";
}
function openSelectDate(timer_year,timer_month,timer_day) {
diff --git a/streamstatus.php b/streamstatus.php index 4582dc6..15e2c39 100755 --- a/streamstatus.php +++ b/streamstatus.php @@ -2,16 +2,16 @@ header('Content-Type: text/xml'); echo "<?xml version=\"1.0\"?>\n"; echo "<status>\n"; - $cnt = 0; - while ( ( count(glob('ram/*.ts')) < 2 ) && ( $cnt < 25 ) ) + $cnt = 0; + while ( ( count(glob('*.ts')) < 2 ) && ( $cnt < 25 ) ) { // wait for stream available sleep(1); $cnt++; } - if ( count(glob('ram/*.ts')) < 2 ) + if ( count(glob('*.ts')) < 2 ) echo "<streamstatus>error</streamstatus>\n"; else echo "<streamstatus>ok</streamstatus>\n"; |