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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<?php
function sessioncreate($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir)
{
global $httppath, $ffmpegpath, $segmenterpath;
// Get a free session
$i=0;
for ($i=0; $i<1000; $i++)
{
$session = "session" .$i;
if (!file_exists('ram/' .$session))
break;
}
// 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);
// Create logo
if ($type == 3)
generatelogo($type, $url, 'ram/' .$session .'/logo.png');
else
generatelogo($type, $name, 'ram/' .$session .'/logo.png');
// Copy status waiter
exec('cp streamstatus.php ram/' .$session);
return $session;
}
function sessiondelete($session)
{
$ram = "ram/" .$session ."/";
$subcmd = "";
// Get segmenter PID if any
if (file_exists($ram ."segmenter.pid"))
{
$pidfile = fopen($ram ."segmenter.pid", 'r');
if ($pidfile)
{
$pid = fgets($pidfile);
$subcmd = "kill " .$pid ." ; ";
fclose($pidfile);
}
}
$cmd= $subcmd ."rm -rf " .$ram;
exec ($cmd);
}
?>
|