summaryrefslogtreecommitdiff
path: root/bin/session.php
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-03-17 14:06:08 +0100
committerTheTroll <trolldev@gmail.com>2010-03-17 14:06:08 +0100
commit737a6402836788d359fcd99bef93ae059c085577 (patch)
tree2cb70992cf1fe452ebec552970b49e5a31cfb712 /bin/session.php
parent4e2acf476cadde8495ff3cf484a866fe8d0ba8ec (diff)
downloadistreamdev-737a6402836788d359fcd99bef93ae059c085577.tar.gz
istreamdev-737a6402836788d359fcd99bef93ae059c085577.tar.bz2
Session start/stop implemented
Diffstat (limited to 'bin/session.php')
-rwxr-xr-xbin/session.php93
1 files changed, 92 insertions, 1 deletions
diff --git a/bin/session.php b/bin/session.php
index 8b998d2..e575a5b 100755
--- a/bin/session.php
+++ b/bin/session.php
@@ -78,6 +78,8 @@ function sessioncreate($type, $url, $mode)
function sessiondelete($session)
{
+ $ret = array();
+
if ($session == 'all')
{
$dir_handle = @opendir('../ram/');
@@ -100,9 +102,44 @@ function sessiondelete($session)
}
}
else
- return sessiondeletesingle($session);
+ sessiondeletesingle($session);
+
+ $ret['status'] = "ok";
+ $ret['message'] = "Successfully stopped broadcast";
+
+ return $ret;
+
+}
+
+function sessiongetinfo($session)
+{
+ $info = array();
+
+ // Get some info
+ list($type, $mode, $url, $channame) = readinfostream($session);
+
+ // Fill common info
+ $info['session'] = $session;
+ $info['type'] = $type;
+ $info['mode'] = $mode;
+
+ // Type info
+ switch ($type)
+ {
+ case 'tv':
+ $info['channel'] = $channame;
+ break;
+ case 'rec':
+ $info['channel'] = $channame;
+ break;
+ case 'vid':
+ break;
+ }
+
+ return $info;
}
+
function sessiondeletesingle($session)
{
$ram = "../ram/" .$session ."/";
@@ -115,4 +152,58 @@ function sessiondeletesingle($session)
exec ($cmd);
}
+function sessiongetstatus($session)
+{
+ global $maxencodingprocesses, $httppath;
+
+ $status = array();
+
+ $path = '../ram/' .$session;
+
+ // Check that session exists
+ if (($session == "") || !count(glob($path)))
+ {
+ $status['status'] = "error";
+
+ $nbencprocess = exec("find ../ram/ -name segmenter.pid | wc | awk '{ print $1 }'");
+ if ($nbencprocess >= $maxencodingprocesses)
+ $status['message'] = "Error: maximun number of sessions reached";
+ else
+ $status['message'] = "Error: cannot create session";
+ }
+ else
+ {
+ // Get stream info
+ list($type, $mode, $url, $channame) = readinfostream($session);
+
+ if (count(glob($path . '/*.ts')) < 2)
+ {
+ $status['status'] = "wait";
+ switch ($type)
+ {
+ case 'tv':
+ $status['message'] = "Requesting live channel " .$channame;
+ break;
+ case 'rec':
+ $status['message'] = "Requesting recording channel " .$channame;
+ break;
+ case 'vid':
+ $status['message'] = "Requesting video file " .$url;
+ break;
+ }
+ }
+ else
+ {
+ $status['status'] = "ready";
+ $status['message'] = $mode ." Broadcast ready";
+
+ $status['url'] = $httppath ."ram/" .$session ."/stream.m3u8";
+
+ }
+ }
+
+ return $status;
+}
+
+
?>