aboutsummaryrefslogtreecommitdiff
path: root/view/streams-json-v1.php
blob: c705bd7ff63d6b6fc0865fc6adfd3fc08be7690b (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
<?php

header('Content-Type: application/json');

if($conference->isClosed())
{
	echo '[]';
	return;
}

$overview = new Overview();

$struct = array();
foreach($overview->getGroups() as $group => $rooms)
{
	$roomstruct = array();
	foreach($rooms as $room)
	{
		$streams = array();
		foreach($room->getStreams() as $stream)
		{
			$key = $stream->getSelection().'-'.$stream->getLanguage();

			$urls = array();
			switch($stream->getPlayerType())
			{
				case 'video':
					foreach ($stream->getVideoProtos() as $proto => $display)
					{
						$urls[$proto] = array(
							'display' => $display,
							'tech' => $stream->getVideoTech($proto),
							'url' => $stream->getVideoUrl($proto),
						);
					}
					break;

				case 'slides':
					foreach ($stream->getSlidesProtos() as $proto => $display)
					{
						$urls[$proto] = array(
							'display' => $display,
							'tech' => $stream->getSlidesTech($proto),
							'url' => $stream->getSlidesUrl($proto),
						);
					}
					break;

				case 'audio':
					foreach ($stream->getAudioProtos() as $proto => $display)
					{
						$urls[$proto] = array(
							'display' => $display,
							'tech' => $stream->getAudioTech($proto),
							'url' => $stream->getAudioUrl($proto),
						);
					}
					break;

				case 'music':
					foreach ($stream->getMusicProtos() as $proto => $display)
					{
						$urls[$proto] = array(
							'display' => $display,
							'tech' => $stream->getMusicTech($proto),
							'url' => $stream->getMusicUrl($proto),
						);
					}
					break;
			}

			$streams[] = array(
				'slug' => $key,
				'display' => $stream->getDisplay(),
				'type' => $stream->getPlayerType(),
				'isTranslated' => $stream->isTranslated(),
				'videoSize' => $stream->getVideoSize(),
				'urls' => $urls,
			);
		}

		$roomstruct[] = array(
			'slug' => $room->getSlug(),
			'schedulename' => $room->getScheduleName(),
			'thumb' => forceslash(baseurl()).$room->getThumb(),
			'link' => forceslash(baseurl()).$room->getLink(),
			'display' => $room->getDisplay(),
			'streams' => $streams,
		);
	}

	$struct[] = array(
		'group' => $group,
		'rooms' => $roomstruct,
	);
}

echo json_encode($struct, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);