Skip to content

Commit 73793b5

Browse files
authored
Merge pull request #179 from riadvice/get-recordings
2 parents 9ae8bea + df2c508 commit 73793b5

6 files changed

Lines changed: 275 additions & 11 deletions

File tree

src/BigBlueButton.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public function setJSessionId($jSessionId)
397397
$this->jSessionId = $jSessionId;
398398
}
399399

400-
/**
400+
/**
401401
* @param array $curlopts
402402
*/
403403
public function setCurlOpts($curlopts)
@@ -429,7 +429,7 @@ private function processXmlResponse($url, $payload = '', $contentType = 'applica
429429
$cookiefile = tmpfile();
430430
$cookiefilepath = stream_get_meta_data($cookiefile)['uri'];
431431

432-
foreach ($this->curlopts as $opt => $value){
432+
foreach ($this->curlopts as $opt => $value) {
433433
curl_setopt($ch, $opt, $value);
434434
}
435435
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
@@ -487,12 +487,12 @@ public function setTimeOut($TimeOutInSeconds)
487487

488488
/**
489489
* Public accessor for buildUrl
490-
* @param string $method
491-
* @param string $params
492-
* @param bool $append
493-
* @return string
490+
* @param string $method
491+
* @param string $params
492+
* @param bool $append
493+
* @return string
494494
*/
495-
public function buildUrl($method = '', $params = '', $append = TRUE)
495+
public function buildUrl($method = '', $params = '', $append = true)
496496
{
497497
return $this->urlBuilder->buildUrl($method, $params, $append);
498498
}

src/Core/Format.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
/**
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Core;
22+
23+
class Format
24+
{
25+
/**
26+
* @var \SimpleXMLElement
27+
*/
28+
protected $rawXml;
29+
30+
private $type;
31+
private $url;
32+
private $processingTime;
33+
private $length;
34+
private $size;
35+
private $images;
36+
37+
/**
38+
* Record constructor.
39+
* @param $xml \SimpleXMLElement
40+
*/
41+
public function __construct($xml)
42+
{
43+
$this->rawXml = $xml;
44+
$this->type = $xml->type->__toString();
45+
$this->url = $xml->url->__toString();
46+
$this->processingTime = (int) $xml->processingTime->__toString();
47+
$this->length = (int) $xml->length->__toString();
48+
$this->size = (int) $xml->size->__toString();
49+
}
50+
51+
/**
52+
* @return Image[]
53+
*/
54+
public function getImages()
55+
{
56+
if ($this->images === null) {
57+
$this->images = [];
58+
foreach ($this->rawXml->preview->images->image as $imageXml) {
59+
$this->images[] = new Image($imageXml);
60+
}
61+
}
62+
63+
return $this->images;
64+
}
65+
66+
/**
67+
* @return string
68+
*/
69+
public function getType(): string
70+
{
71+
return $this->type;
72+
}
73+
74+
/**
75+
* @return string
76+
*/
77+
public function getUrl(): string
78+
{
79+
return $this->url;
80+
}
81+
82+
/**
83+
* @return int
84+
*/
85+
public function getProcessingTime(): int
86+
{
87+
return $this->processingTime;
88+
}
89+
90+
/**
91+
* @return int
92+
*/
93+
public function getLength(): int
94+
{
95+
return $this->length;
96+
}
97+
98+
/**
99+
* @return int
100+
*/
101+
public function getSize(): int
102+
{
103+
return $this->size;
104+
}
105+
}

src/Core/Image.php

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
4+
*
5+
* Copyright (c) 2016-2018 BigBlueButton Inc. and by respective authors (see below).
6+
*
7+
* This program is free software; you can redistribute it and/or modify it under the
8+
* terms of the GNU Lesser General Public License as published by the Free Software
9+
* Foundation; either version 3.0 of the License, or (at your option) any later
10+
* version.
11+
*
12+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
13+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License along
17+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
namespace BigBlueButton\Core;
21+
22+
/**
23+
* Class Record
24+
* @package BigBlueButton\Core
25+
*/
26+
class Image
27+
{
28+
private $alt;
29+
private $height;
30+
private $width;
31+
private $url;
32+
33+
/**
34+
* Record constructor.
35+
* @param $xml \SimpleXMLElement
36+
*/
37+
public function __construct($xml)
38+
{
39+
$this->alt = $xml['alt']->__toString();
40+
$this->height = (int) $xml['height'];
41+
$this->width = (int) $xml['width'];
42+
$this->url = $xml->__toString();
43+
}
44+
45+
/**
46+
* @return string
47+
*/
48+
public function getAlt(): string
49+
{
50+
return $this->alt;
51+
}
52+
53+
/**
54+
* @return int
55+
*/
56+
public function getHeight(): int
57+
{
58+
return $this->height;
59+
}
60+
61+
/**
62+
* @return int
63+
*/
64+
public function getWidth(): int
65+
{
66+
return $this->width;
67+
}
68+
69+
/**
70+
* @return string
71+
*/
72+
public function getUrl(): string
73+
{
74+
return $this->url;
75+
}
76+
}

src/Core/Record.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* You should have received a copy of the GNU Lesser General Public License along
1717
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
1818
*/
19+
1920
namespace BigBlueButton\Core;
2021

2122
/**
@@ -24,24 +25,41 @@
2425
*/
2526
class Record
2627
{
28+
29+
/**
30+
* @var \SimpleXMLElement
31+
*/
32+
protected $rawXml;
33+
2734
private $recordId;
2835
private $meetingId;
2936
private $name;
3037
private $isPublished;
3138
private $state;
3239
private $startTime;
3340
private $endTime;
41+
/**
42+
* @deprecated deprecated since 2.1.2
43+
*/
3444
private $playbackType;
45+
/**
46+
* @deprecated deprecated since 2.1.2
47+
*/
3548
private $playbackUrl;
49+
/**
50+
* @deprecated deprecated since 2.1.2
51+
*/
3652
private $playbackLength;
3753
private $metas;
54+
private $formats;
3855

3956
/**
4057
* Record constructor.
4158
* @param $xml \SimpleXMLElement
4259
*/
4360
public function __construct($xml)
4461
{
62+
$this->rawXml = $xml;
4563
$this->recordId = $xml->recordID->__toString();
4664
$this->meetingId = $xml->meetingID->__toString();
4765
$this->name = $xml->name->__toString();
@@ -116,6 +134,7 @@ public function getEndTime()
116134

117135
/**
118136
* @return string
137+
* @deprecated
119138
*/
120139
public function getPlaybackType()
121140
{
@@ -124,6 +143,7 @@ public function getPlaybackType()
124143

125144
/**
126145
* @return string
146+
* @deprecated
127147
*/
128148
public function getPlaybackUrl()
129149
{
@@ -132,6 +152,7 @@ public function getPlaybackUrl()
132152

133153
/**
134154
* @return string
155+
* @deprecated
135156
*/
136157
public function getPlaybackLength()
137158
{
@@ -145,4 +166,19 @@ public function getMetas()
145166
{
146167
return $this->metas;
147168
}
169+
170+
/**
171+
* @return Format[]
172+
*/
173+
public function getFormats()
174+
{
175+
if ($this->formats === null) {
176+
$this->formats = [];
177+
foreach ($this->rawXml->playback->format as $formatXml) {
178+
$this->formats[] = new Format($formatXml);
179+
}
180+
}
181+
182+
return $this->formats;
183+
}
148184
}

tests/Responses/GetRecordingsResponseTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* You should have received a copy of the GNU Lesser General Public License along
1717
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
1818
*/
19+
1920
namespace BigBlueButton\Parameters;
2021

2122
use BigBlueButton\Responses\GetRecordingsResponse;
@@ -65,6 +66,35 @@ public function testRecordMetadataContent()
6566
$this->assertEquals('moodle-mod_bigbluebuttonbn (2015080611)', $metas['bbb-origin-tag']);
6667
}
6768

69+
public function testRecordingsPlaybackFormats()
70+
{
71+
$this->assertEquals('SUCCESS', $this->records->getReturnCode());
72+
73+
$this->assertCount(6, $this->records->getRecords());
74+
$aRecord = $this->records->getRecords()[0];
75+
76+
// Test podcast format
77+
$podcastFormat = $aRecord->getFormats()[0]; // without images preview
78+
$this->assertEquals('podcast', $podcastFormat->getType());
79+
$this->assertEquals('https://test-install.blindsidenetworks.com/podcast/f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120/audio.ogg', $podcastFormat->getUrl());
80+
$this->assertEquals('111', $podcastFormat->getProcessingTime());
81+
$this->assertEquals('632', $podcastFormat->getLength());
82+
$this->assertEquals('10500', $podcastFormat->getSize());
83+
84+
$presentationFormat = $aRecord->getFormats()[1]; // having images preview
85+
$this->assertEquals('presentation', $presentationFormat->getType());
86+
$this->assertEquals('http://test-install.blindsidenetworks.com/playback/presentation/0.9.0/playback.html?meetingId=f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120', $presentationFormat->getUrl());
87+
$this->assertEquals(2973, $presentationFormat->getProcessingTime());
88+
$this->assertEquals(532, $presentationFormat->getLength());
89+
$this->assertEquals(168019, $presentationFormat->getSize());
90+
91+
$image = $presentationFormat->getImages()[0];
92+
$this->assertEquals('Welcome', $image->getAlt());
93+
$this->assertEquals(136, $image->getHeight());
94+
$this->assertEquals(176, $image->getWidth());
95+
$this->assertEquals('https://test-install.blindsidenetworks.com/presentation/f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120/presentation/d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1632646357291/thumbnails/thumb-1.png', $image->getUrl());
96+
}
97+
6898
public function testGetRecordingResponseTypes()
6999
{
70100
$this->assertEachGetterValueIsString($this->records, ['getReturnCode']);

0 commit comments

Comments
 (0)