Skip to content

Commit df2c508

Browse files
committed
Improve multiple recording formats implementation.
1 parent cba8240 commit df2c508

6 files changed

Lines changed: 197 additions & 130 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: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,22 @@
2525
*/
2626
class Image
2727
{
28-
/**
29-
* @var string
30-
*/
3128
private $alt;
32-
33-
/**
34-
* @var int
35-
*/
3629
private $height;
37-
38-
/**
39-
* @var int
40-
*/
4130
private $width;
31+
private $url;
4232

4333
/**
44-
* @var string
34+
* Record constructor.
35+
* @param $xml \SimpleXMLElement
4536
*/
46-
private $link;
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+
}
4744

4845
/**
4946
* @return string
@@ -53,14 +50,6 @@ public function getAlt(): string
5350
return $this->alt;
5451
}
5552

56-
/**
57-
* @param string $alt
58-
*/
59-
public function setAlt(string $alt): void
60-
{
61-
$this->alt = $alt;
62-
}
63-
6453
/**
6554
* @return int
6655
*/
@@ -69,14 +58,6 @@ public function getHeight(): int
6958
return $this->height;
7059
}
7160

72-
/**
73-
* @param int $height
74-
*/
75-
public function setHeight(int $height): void
76-
{
77-
$this->height = $height;
78-
}
79-
8061
/**
8162
* @return int
8263
*/
@@ -85,27 +66,11 @@ public function getWidth(): int
8566
return $this->width;
8667
}
8768

88-
/**
89-
* @param int $width
90-
*/
91-
public function setWidth(int $width): void
92-
{
93-
$this->width = $width;
94-
}
95-
9669
/**
9770
* @return string
9871
*/
99-
public function getLink(): string
100-
{
101-
return $this->link;
102-
}
103-
104-
/**
105-
* @param string $link
106-
*/
107-
public function setLink(string $link): void
72+
public function getUrl(): string
10873
{
109-
$this->link = $link;
74+
return $this->url;
11075
}
11176
}

src/Core/Record.php

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,41 @@
2525
*/
2626
class Record
2727
{
28+
29+
/**
30+
* @var \SimpleXMLElement
31+
*/
32+
protected $rawXml;
33+
2834
private $recordId;
2935
private $meetingId;
3036
private $name;
3137
private $isPublished;
3238
private $state;
3339
private $startTime;
3440
private $endTime;
41+
/**
42+
* @deprecated deprecated since 2.1.2
43+
*/
3544
private $playbackType;
45+
/**
46+
* @deprecated deprecated since 2.1.2
47+
*/
3648
private $playbackUrl;
49+
/**
50+
* @deprecated deprecated since 2.1.2
51+
*/
3752
private $playbackLength;
3853
private $metas;
39-
private $playbacks;
54+
private $formats;
4055

4156
/**
4257
* Record constructor.
4358
* @param $xml \SimpleXMLElement
4459
*/
4560
public function __construct($xml)
4661
{
62+
$this->rawXml = $xml;
4763
$this->recordId = $xml->recordID->__toString();
4864
$this->meetingId = $xml->meetingID->__toString();
4965
$this->name = $xml->name->__toString();
@@ -58,43 +74,6 @@ public function __construct($xml)
5874
foreach ($xml->metadata->children() as $meta) {
5975
$this->metas[$meta->getName()] = $meta->__toString();
6076
}
61-
62-
foreach ($xml->playback->children() as $format) {
63-
$aFormat = [];
64-
foreach ($format->children() as $formAttribut) {
65-
// if ($formAttribut != "preview"){ }
66-
$aFormat[$formAttribut->getName()] = $formAttribut->__toString();
67-
}
68-
if (isset($format->preview)) {
69-
$images = [];
70-
foreach ($format->preview->images->children() as $image) {
71-
$imageObj = new Image();
72-
$imageObj->setAlt( $image['alt']->__toString());
73-
$imageObj->setHeight((int) $image['height']->__toString());
74-
$imageObj->setWidth((int) $image['width']->__toString());
75-
$imageObj->setLink($image->__toString());
76-
$images[] = $imageObj;
77-
}
78-
$aFormat['preview'] = $images;
79-
}
80-
$this->playbacks[] = $aFormat;
81-
}
82-
}
83-
84-
/**
85-
* @return array
86-
*/
87-
public function getPlaybacks(): array
88-
{
89-
return $this->playbacks;
90-
}
91-
92-
/**
93-
* @param array $playbacks
94-
*/
95-
public function setPlaybacks(array $playbacks): void
96-
{
97-
$this->playbacks = $playbacks;
9877
}
9978

10079
/**
@@ -155,6 +134,7 @@ public function getEndTime()
155134

156135
/**
157136
* @return string
137+
* @deprecated
158138
*/
159139
public function getPlaybackType()
160140
{
@@ -163,6 +143,7 @@ public function getPlaybackType()
163143

164144
/**
165145
* @return string
146+
* @deprecated
166147
*/
167148
public function getPlaybackUrl()
168149
{
@@ -171,6 +152,7 @@ public function getPlaybackUrl()
171152

172153
/**
173154
* @return string
155+
* @deprecated
174156
*/
175157
public function getPlaybackLength()
176158
{
@@ -184,4 +166,19 @@ public function getMetas()
184166
{
185167
return $this->metas;
186168
}
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+
}
187184
}

0 commit comments

Comments
 (0)