Skip to content

Commit

Permalink
Improve multiple recording formats implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
GhaziTriki committed Jun 15, 2022
1 parent cba8240 commit df2c508
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 130 deletions.
14 changes: 7 additions & 7 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public function setJSessionId($jSessionId)
$this->jSessionId = $jSessionId;
}

/**
/**
* @param array $curlopts
*/
public function setCurlOpts($curlopts)
Expand Down Expand Up @@ -429,7 +429,7 @@ private function processXmlResponse($url, $payload = '', $contentType = 'applica
$cookiefile = tmpfile();
$cookiefilepath = stream_get_meta_data($cookiefile)['uri'];

foreach ($this->curlopts as $opt => $value){
foreach ($this->curlopts as $opt => $value) {
curl_setopt($ch, $opt, $value);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
Expand Down Expand Up @@ -487,12 +487,12 @@ public function setTimeOut($TimeOutInSeconds)

/**
* Public accessor for buildUrl
* @param string $method
* @param string $params
* @param bool $append
* @return string
* @param string $method
* @param string $params
* @param bool $append
* @return string
*/
public function buildUrl($method = '', $params = '', $append = TRUE)
public function buildUrl($method = '', $params = '', $append = true)
{
return $this->urlBuilder->buildUrl($method, $params, $append);
}
Expand Down
105 changes: 105 additions & 0 deletions src/Core/Format.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

/**
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
*
* Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/

namespace BigBlueButton\Core;

class Format
{
/**
* @var \SimpleXMLElement
*/
protected $rawXml;

private $type;
private $url;
private $processingTime;
private $length;
private $size;
private $images;

/**
* Record constructor.
* @param $xml \SimpleXMLElement
*/
public function __construct($xml)
{
$this->rawXml = $xml;
$this->type = $xml->type->__toString();
$this->url = $xml->url->__toString();
$this->processingTime = (int) $xml->processingTime->__toString();
$this->length = (int) $xml->length->__toString();
$this->size = (int) $xml->size->__toString();
}

/**
* @return Image[]
*/
public function getImages()
{
if ($this->images === null) {
$this->images = [];
foreach ($this->rawXml->preview->images->image as $imageXml) {
$this->images[] = new Image($imageXml);
}
}

return $this->images;
}

/**
* @return string
*/
public function getType(): string
{
return $this->type;
}

/**
* @return string
*/
public function getUrl(): string
{
return $this->url;
}

/**
* @return int
*/
public function getProcessingTime(): int
{
return $this->processingTime;
}

/**
* @return int
*/
public function getLength(): int
{
return $this->length;
}

/**
* @return int
*/
public function getSize(): int
{
return $this->size;
}
}
59 changes: 12 additions & 47 deletions src/Core/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,22 @@
*/
class Image
{
/**
* @var string
*/
private $alt;

/**
* @var int
*/
private $height;

/**
* @var int
*/
private $width;
private $url;

/**
* @var string
* Record constructor.
* @param $xml \SimpleXMLElement
*/
private $link;
public function __construct($xml)
{
$this->alt = $xml['alt']->__toString();
$this->height = (int) $xml['height'];
$this->width = (int) $xml['width'];
$this->url = $xml->__toString();
}

/**
* @return string
Expand All @@ -53,14 +50,6 @@ public function getAlt(): string
return $this->alt;
}

/**
* @param string $alt
*/
public function setAlt(string $alt): void
{
$this->alt = $alt;
}

/**
* @return int
*/
Expand All @@ -69,14 +58,6 @@ public function getHeight(): int
return $this->height;
}

/**
* @param int $height
*/
public function setHeight(int $height): void
{
$this->height = $height;
}

/**
* @return int
*/
Expand All @@ -85,27 +66,11 @@ public function getWidth(): int
return $this->width;
}

/**
* @param int $width
*/
public function setWidth(int $width): void
{
$this->width = $width;
}

/**
* @return string
*/
public function getLink(): string
{
return $this->link;
}

/**
* @param string $link
*/
public function setLink(string $link): void
public function getUrl(): string
{
$this->link = $link;
return $this->url;
}
}
73 changes: 35 additions & 38 deletions src/Core/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,41 @@
*/
class Record
{

/**
* @var \SimpleXMLElement
*/
protected $rawXml;

private $recordId;
private $meetingId;
private $name;
private $isPublished;
private $state;
private $startTime;
private $endTime;
/**
* @deprecated deprecated since 2.1.2
*/
private $playbackType;
/**
* @deprecated deprecated since 2.1.2
*/
private $playbackUrl;
/**
* @deprecated deprecated since 2.1.2
*/
private $playbackLength;
private $metas;
private $playbacks;
private $formats;

/**
* Record constructor.
* @param $xml \SimpleXMLElement
*/
public function __construct($xml)
{
$this->rawXml = $xml;
$this->recordId = $xml->recordID->__toString();
$this->meetingId = $xml->meetingID->__toString();
$this->name = $xml->name->__toString();
Expand All @@ -58,43 +74,6 @@ public function __construct($xml)
foreach ($xml->metadata->children() as $meta) {
$this->metas[$meta->getName()] = $meta->__toString();
}

foreach ($xml->playback->children() as $format) {
$aFormat = [];
foreach ($format->children() as $formAttribut) {
// if ($formAttribut != "preview"){ }
$aFormat[$formAttribut->getName()] = $formAttribut->__toString();
}
if (isset($format->preview)) {
$images = [];
foreach ($format->preview->images->children() as $image) {
$imageObj = new Image();
$imageObj->setAlt( $image['alt']->__toString());
$imageObj->setHeight((int) $image['height']->__toString());
$imageObj->setWidth((int) $image['width']->__toString());
$imageObj->setLink($image->__toString());
$images[] = $imageObj;
}
$aFormat['preview'] = $images;
}
$this->playbacks[] = $aFormat;
}
}

/**
* @return array
*/
public function getPlaybacks(): array
{
return $this->playbacks;
}

/**
* @param array $playbacks
*/
public function setPlaybacks(array $playbacks): void
{
$this->playbacks = $playbacks;
}

/**
Expand Down Expand Up @@ -155,6 +134,7 @@ public function getEndTime()

/**
* @return string
* @deprecated
*/
public function getPlaybackType()
{
Expand All @@ -163,6 +143,7 @@ public function getPlaybackType()

/**
* @return string
* @deprecated
*/
public function getPlaybackUrl()
{
Expand All @@ -171,6 +152,7 @@ public function getPlaybackUrl()

/**
* @return string
* @deprecated
*/
public function getPlaybackLength()
{
Expand All @@ -184,4 +166,19 @@ public function getMetas()
{
return $this->metas;
}

/**
* @return Format[]
*/
public function getFormats()
{
if ($this->formats === null) {
$this->formats = [];
foreach ($this->rawXml->playback->format as $formatXml) {
$this->formats[] = new Format($formatXml);
}
}

return $this->formats;
}
}
Loading

0 comments on commit df2c508

Please sign in to comment.