diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-27 19:01:05 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-27 19:01:05 +0100 |
commit | ba0c6b5de1803eb14af25647322d0f0996ac6902 (patch) | |
tree | ebb20bf34bbaf26af5ffcdad2775662e58042c53 | |
parent | fea360ceb0c1222e0691bf825c76fce25b8495ef (diff) | |
download | istreamdev-ba0c6b5de1803eb14af25647322d0f0996ac6902.tar.gz istreamdev-ba0c6b5de1803eb14af25647322d0f0996ac6902.tar.bz2 |
WIP
-rwxr-xr-x | includes/inc_session.php | 3 | ||||
-rwxr-xr-x | includes/include.php | 35 | ||||
-rwxr-xr-x | streamstatus.php | 10 |
3 files changed, 29 insertions, 19 deletions
diff --git a/includes/inc_session.php b/includes/inc_session.php index 6bee609..743fcf3 100755 --- a/includes/inc_session.php +++ b/includes/inc_session.php @@ -43,9 +43,6 @@ function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, else generatelogo($type, $name, 'ram/' .$session .'/logo.png'); - // Copy status waiter - exec('cp streamstatus.php ram/' .$session); - return $session; } diff --git a/includes/include.php b/includes/include.php index 177a1c0..4db98a8 100755 --- a/includes/include.php +++ b/includes/include.php @@ -14,6 +14,8 @@ include ('getid3/getid3.php'); function selectpage() { + global $maxencodingprocesses; + // Sanity check if (!file_exists('ram')) die("Error: 'ram/' directory is missing, please create it!"); @@ -26,19 +28,26 @@ function selectpage() include('includes/inc_streaming.php'); break; case ("startstream"): - $type = $_REQUEST['type']; - $name = $_REQUEST['name']; - $title = $_REQUEST['title']; - $desc = stripslashes ($_REQUEST['desc']); - $qname = $_REQUEST['qname']; - $qparams = $_REQUEST['qparams']; - $category = $_REQUEST['category']; - $url = $_REQUEST['url']; - $mediapath = $_REQUEST['mediapath']; - $subdir = $_REQUEST['subdir']; - $session = sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir); - include('includes/inc_streaming.php'); - break; + // Dont create a session if too much are running already + $nbencprocess = exec("find ram/ -name segmenter.pid | wc | awk '{ print $1 }'"); + if ($nbencprocess < $maxencodingprocesses) + { + $type = $_REQUEST['type']; + $name = $_REQUEST['name']; + $title = $_REQUEST['title']; + $desc = stripslashes ($_REQUEST['desc']); + $qname = $_REQUEST['qname']; + $qparams = $_REQUEST['qparams']; + $category = $_REQUEST['category']; + $url = $_REQUEST['url']; + $mediapath = $_REQUEST['mediapath']; + $subdir = $_REQUEST['subdir']; + $session = sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir); + include('includes/inc_streaming.php'); + } + else + include('includes/inc_stream.php'); + break; case ("stopstream"): sessiondelete($_REQUEST['session']); // NO BREAK; diff --git a/streamstatus.php b/streamstatus.php index 38e20c9..54823be 100755 --- a/streamstatus.php +++ b/streamstatus.php @@ -5,26 +5,30 @@ if (file_exists('config.php')) else include ('config_default.php'); +global $maxencodingprocesses; + header('Content-Type: text/xml'); echo "<?xml version=\"1.0\"?>\n"; echo "<status>\n"; // First check that we are allowed to create a new encoding process -$nbencprocess = exec("find .. -name segmenter.pid | wc | awk '{ print $1 }'"); +$nbencprocess = exec("find -name segmenter.pid | wc | awk '{ print $1 }'"); if ($nbencprocess > $maxencodingprocesses) echo "<streamstatus>error</streamstatus><message>Error: maximun number of sessions reached</message>\n"; else { + $session = $_REQUEST['session']; + $cnt = 0; - while ( ( count(glob('*.ts')) < 2 ) && ( $cnt < 25 ) ) + while ( ( count(glob('ram/' .$session '/*.ts')) < 2 ) && ( $cnt < 25 ) ) { // wait for stream available sleep(1); $cnt++; } - if ( count(glob('*.ts')) < 2 ) + if ( count(glob('ram/' .$session '/*.ts')) < 2 ) echo "<streamstatus>error</streamstatus><message>Error: encoding did not start correclty</message>\n"; else echo "<streamstatus>ok</streamstatus>\n"; |