summaryrefslogtreecommitdiff
path: root/bin/session.php
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-03-27 19:46:30 +0100
committerTheTroll <trolldev@gmail.com>2010-03-27 19:46:30 +0100
commit275c3cd3d4532aa927945a940bb9c5b8304ba365 (patch)
tree1028da611e16c72bca64a46935cff7e42fe627bf /bin/session.php
parent4241ab5e4b0d7a1a0165175c1067ac22edd76de8 (diff)
downloadistreamdev-275c3cd3d4532aa927945a940bb9c5b8304ba365.tar.gz
istreamdev-275c3cd3d4532aa927945a940bb9c5b8304ba365.tar.bz2
Added debug mode
Diffstat (limited to 'bin/session.php')
-rwxr-xr-xbin/session.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/bin/session.php b/bin/session.php
index 886522a..172a02a 100755
--- a/bin/session.php
+++ b/bin/session.php
@@ -4,6 +4,8 @@ function sessioncreate($type, $url, $mode)
{
global $httppath, $ffmpegpath, $segmenterpath, $quality, $maxencodingprocesses;
+ addlog("Creating a new session for \"" .$url ."\" (" .$type .", " .$mode .")");
+
// Check url
if (!isurlvalid($url, $type))
return "";
@@ -11,7 +13,10 @@ function sessioncreate($type, $url, $mode)
// Check that the max number of session is not reached yet
$nbencprocess = exec("find ../ram/ -name segmenter.pid | wc | awk '{ print $1 }'");
if ($nbencprocess >= $maxencodingprocesses)
+ {
+ addlog("Error: Cannot create sesssion, too much sessions already encoding");
return "";
+ }
// Get a free session
$i=0;
@@ -22,6 +27,12 @@ function sessioncreate($type, $url, $mode)
break;
}
+ if ($i == 1000)
+ {
+ addlog("Error: Cannot find a new session name");
+ return "";
+ }
+
// Default
$qparams = $quality[0];
@@ -36,6 +47,7 @@ function sessioncreate($type, $url, $mode)
}
// Create session
+ addlog("Creating new session dir ram/" .$session);
exec('mkdir ../ram/' .$session);
// Extract $channame if needed
switch ($type)
@@ -74,6 +86,8 @@ function sessioncreate($type, $url, $mode)
$cmd = "";
}
+ addlog("Sending encoding command: " .$cmd);
+
$cmd = str_replace('%', '%%', $cmd);
exec ($cmd);
@@ -86,7 +100,7 @@ function sessioncreate($type, $url, $mode)
function sessiondelete($session)
{
$ret = array();
-
+
if ($session == 'all')
{
$dir_handle = @opendir('../ram/');
@@ -122,6 +136,8 @@ function sessiongetinfo($session)
{
$info = array();
+ addlog("Getting info for session " .$session);
+
// Get some info
list($type, $mode, $url, $channame) = readinfostream($session);
@@ -167,12 +183,16 @@ function sessiongetinfo($session)
function sessiondeletesingle($session)
{
+ addlog("Deleting session " .$session);
+
$ram = "../ram/" .$session ."/";
// Get segmenter PID if any
if (file_exists($ram ."segmenter.pid"))
$cmd = "/usr/local/bin/fw;kill `cat " .$ram ."segmenter.pid`; rm " .$ram ."segmenter.pid; ";
+ addlog("Sending session kill command: " .$cmd);
+
$cmd .= "rm -rf " .$ram;
exec ($cmd);
}
@@ -272,17 +292,25 @@ function sessiongetstatus($session, $prevmsg)
// Alway return ready
if ($status['status'] == "ready")
+ {
+ addlog("Returning status: " .$status['message']);
return $status;
+ }
// Status change
if ($status['message'] != $prevmsg)
+ {
+ addlog("Returning status: " .$status['message']);
return $status;
+ }
// Check session creation timeout
if ($checkstart && ((time() - $time) >= 10))
{
$status['status'] = "error";
$status['message'] = "Error: session could not start";
+
+ addlog("Returning status: " .$status['message']);
return $status;
}
@@ -292,6 +320,8 @@ function sessiongetstatus($session, $prevmsg)
/* Time out */
$status['status'] = "wait";
$status['message'] = $prevmsg;
+
+ addlog("Returning status: " .$status['message']);
return $status;
}
@@ -299,6 +329,8 @@ function sessiongetlist()
{
$sessions = array();
+ addlog("Listing sessions");
+
$dir_handle = @opendir('../ram/');
if ($dir_handle)
{
@@ -340,6 +372,8 @@ function streammusic($path, $file)
{
global $httppath;
+ addlog("Streaming music from path \"" .$path ."\"");
+
if (!isurlvalid($path, "media"))
return array();