diff options
author | TheTroll <trolldev@gmail.com> | 2010-02-27 01:04:29 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-02-27 01:04:29 +0100 |
commit | 0c9414a9fecf2278d468acb1cf184e776b5a15c7 (patch) | |
tree | 4fd8140bb93e525976b3c7acde9cfb2ef3052961 /includes/inc_session.php | |
parent | 6d9cbb4df3b1aa89126069162dbf9f1e330b5fa6 (diff) | |
download | istreamdev-0c9414a9fecf2278d468acb1cf184e776b5a15c7.tar.gz istreamdev-0c9414a9fecf2278d468acb1cf184e776b5a15c7.tar.bz2 |
Multiple sessions support WIP
Diffstat (limited to 'includes/inc_session.php')
-rwxr-xr-x | includes/inc_session.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/includes/inc_session.php b/includes/inc_session.php new file mode 100755 index 0000000..c74d780 --- /dev/null +++ b/includes/inc_session.php @@ -0,0 +1,57 @@ +<?php + +function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir) +{ + global $httppath, $ffmpegpath, $segmenterpath; + + // TODO: Get a session + $session = session0; + + // Create session + exec('mkdir ram/' .$session); + + switch ($type) + { + case 1: + $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 2 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \" | at now"; + break; + case 2: + $cmd = "export SHELL=\"/bin/sh\";printf \"cat \\\"" .$url ."\\\"/0* | ./istream.sh - " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \" | at now"; + break; + case 3: + $cmd = "export SHELL=\"/bin/sh\";printf \"./istream.sh \\\"" .$url ."\\\" " .$qparams ." " .$httppath ." 1260 " .$ffmpegpath ." " .$segmenterpath ." " .$session ." \" | at now"; + break; + default: + $cmd = ""; + } + + $cmd = str_replace('%', '%%', $cmd); + exec($cmd); + + // Write streaminfo + writeinfostream($session, $type, $name, $title, $desc, $qname, $category, $url, $mediapath, $subdir); + + return $session; +} + +function sessiondelete($session) +{ + $ram = "ram/" .$session ."/"; + $subcmd = ""; + + // Get segmenter PID if any + if (file_exists($ram ."streamsegmenterpid")) + { + $pidfile = fopen($ram ."streamsegmenterpid", 'r'); + if ($pidfile) + { + $pid = fgets($pidfile); + $pid = substr($pid, 0, -1); + $subcmd = "kill " .$pid ." ; "; + fclose($pidfile); + } + } + + $cmd= $subcmd ."rm -rf " .$ram; + exec ($cmd); +?> |