summaryrefslogtreecommitdiff
path: root/bin/jsonapi.php
blob: 372c06389cd7af46033a59c9f6f17df1d0273997 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php

function getGlobals()
{
	global $vdrstreamdev, $vdrrecpath, $mediasource;

	$ret = array();
	$ret['streamdev_server'] = $vdrstreamdev;
	$ret['rec_path'] = $vdrrecpath;
	$ret['video_path'] = "/home/storage/Foot/";
	$ret['audio_path'] = "/home/www/mp3/";

	return json_encode($ret);
}

function getTvCat()
{
	$ret = array();
	$ret['categories'] = vdrgetcategories();
	
	return json_encode($ret);
}

function getFullChanList()
{
	$catlist = array();

	// Get all categories
	$categories = vdrgetcategories();

	// For all categories
	$count = count($categories);
	for ($i = 0; $i < $count; $i++)
	{
		$tmpcat = array();

		$tmpcat['name'] = $categories[$i]['name'];
		$tmpcat['channel'] = vdrgetchannels($tmpcat['name'], 0);

		$catlist[] = $tmpcat;
	}

	$ret = array();
	$ret['category'] = $catlist;

	return json_encode($ret);
}

function getTvChan($cat)
{
	$ret = array();
	$ret['channel'] = vdrgetchannels($cat, 1);

	return json_encode($ret);
}

function getChanInfo($channum)
{
	$ret = array();
	
	$ret['program'] = vdrgetchaninfo($channum);

	return json_encode($ret);
}

function getRecInfo($rec)
{
	$ret = array();

	$info = array();
	list($info['channel'], $info['name'], $info['desc']) = vdrgetrecinfo($rec);

	$ret['program'] = $info;

	return json_encode($ret);
}

function startBroadcast($type, $url, $mode)
{
	$ret = array();

	$ret['session'] = substr(sessioncreate($type, $url, $mode), strlen("session"));

	return json_encode($ret); 
}

function stopBroadcast($session)
{
	$ret = array();

	if ($session == "all")
		$ret = sessiondelete($session);	
	else
		$ret = sessiondelete("session" .$session);

        return json_encode($ret);
}

function getStreamInfo($session)
{
	$ret = array();

	$info = sessiongetinfo("session" .$session);
	$info['session'] = substr($info['session'], strlen("session"));
	$ret['stream'] = $info;

	return json_encode($ret);
}

function getStreamStatus($session)
{
	$ret = sessiongetstatus("session" .$session);

	return json_encode($ret);
}

function getRunningSessions()
{
	$ret = array();

	$ret['broadcast'] = sessiongetlist();

        return json_encode($ret);

}

function browseFolder($path)
{
	$ret = array();

	$ret['list'] = filesgetlisting($path);
	
	return json_encode($ret);
}
?>