-
Notifications
You must be signed in to change notification settings - Fork 2
/
OpenTokArchive.php
executable file
·122 lines (93 loc) · 2.92 KB
/
OpenTokArchive.php
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
<?php
require_once 'API_Config.php';
class OpenTokArchive {
private $archiveId;
private $archiveTitle;
//Array of resources listed in this Manifest
private $resources = array();
//Array of the timeline from the Manifest file
private $timeline = array();
public function __construct($archiveId, $archiveTitle, $resources, $timeline) {
$this->archiveId = $archiveId;
$this->archiveTitle = $archiveTitle;
$this->resources = $resources;
$this->timeline = $timeline;
}
/*************/
////Getters///
/*************/
public function getId() {
return $this->archiveId;
}
public function getTitle() {
return $this->archiveTitle;
}
public function getResources() {
return $this->resources;
}
public function getTimeline() {
return $this->timeline;
}
/*************/
////Public FNs/
/*************/
public function downloadArchiveURL($videoId) {
return API_Config::API_SERVER . '/archive/url/'.$this->archiveId.'/'.$videoId;
}
/*************/
////Parser/////
/*************/
public static function parseManifest($manifest) {
$archiveId = $manifest['archiveid'];
$title = $manifest['title'];
$resources = array();
$timeline = array();
foreach($manifest->resources->video as $videoResourceItem) {
$resources[] = OpenTokArchiveVideoResource::parseXML($videoResourceItem);
}
foreach($manifest->timeline->event as $timelineItem) {
$timeline[] = OpenTokArchiveTimelineEvent::parseXML($timelineItem);
}
return new OpenTokArchive($archiveId, $title, $resources, $timeline);
}
}
class OpenTokArchiveVideoResource {
private $id;
private $type = 'video';
private $length;
public function __construct($id, $length) {
$this->id = $id;
$this->length = $length;
}
public function getId() {
return $this->id;
}
public function getLength() {
return $this->length;
}
public static function parseXML($videoResourceItem) {
return new OpenTokArchiveVideoResource($videoResourceItem['id'], $videoResourceItem['length']);
}
}
class OpenTokArchiveTimelineEvent {
private $eventType;
private $resourceId;
private $offset;
public function __construct($eventType, $resourceId, $offset) {
$this->eventType = $eventType;
$this->resourceId = $resourceId;
$this->offset = $offset;
}
public function getEventType() {
return $this->eventType;
}
public function getResourceId() {
return $this->resourceId;
}
public function getOffset() {
return $this->offset;
}
public static function parseXML($timelineItem) {
return new OpenTokArchiveTimelineEvent($timelineItem['type'], $timelineItem['id'], $timelineItem['offset']);
}
}