1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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);
?>
|