From 32b78254c76ebd9a07ad19edf25f1f0846a33bb8 Mon Sep 17 00:00:00 2001 From: TheTroll Date: Sat, 27 Feb 2010 02:12:43 +0100 Subject: Sessions WIP --- includes/inc_home.php | 39 +++++++++++++++++++++++++++++++++------ includes/inc_session.php | 7 ++++++- includes/inc_streaminfo.php | 4 ++-- includes/inc_streaming.php | 7 ++++++- istream.sh | 5 +++-- javascript/ajax.js | 14 +++++++------- javascript/functions.js | 4 ++-- 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 "\r\n"; print "
\r\n"; // Streaming in progress -$dir_handle = @opendir('ram'); +$dir_handle = @opendir('ram/'); if ($dir_handle) { - print " Streaming...\r\n"; print " \r\n"; + print " \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 "\r\n"; +print "\r\n"; print "
\r\n"; print "
\r\n"; print "Stop Stream
\r\n"; + +print "
\r\n"; +print "\"home\"
\r\n"; + print "
iStreamdev
\r\n"; print "
\r\n"; @@ -43,6 +47,7 @@ print "
\r\n"; print "
"; print " "; +print " "; print " "; switch ($type) { diff --git a/istream.sh b/istream.sh index 3327ad8..2cfe28c 100755 --- a/istream.sh +++ b/istream.sh @@ -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 "\n"; echo "\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 "error\n"; else echo "ok\n"; -- cgit v1.2.3