Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiple recording formats #179

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
76 changes: 76 additions & 0 deletions src/Core/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
*
* Copyright (c) 2016-2018 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 Record
* @package BigBlueButton\Core
*/
class Image
{
private $alt;
private $height;
private $width;
private $url;

/**
* Record constructor.
* @param $xml \SimpleXMLElement
*/
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
*/
public function getAlt(): string
{
return $this->alt;
}

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

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

/**
* @return string
*/
public function getUrl(): string
{
return $this->url;
}
}
36 changes: 36 additions & 0 deletions src/Core/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* 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;

/**
Expand All @@ -24,24 +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 $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 Down Expand Up @@ -116,6 +134,7 @@ public function getEndTime()

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

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

/**
* @return string
* @deprecated
*/
public function getPlaybackLength()
{
Expand All @@ -145,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;
}
}
30 changes: 30 additions & 0 deletions tests/Responses/GetRecordingsResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* 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\Parameters;

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

public function testRecordingsPlaybackFormats()
{
$this->assertEquals('SUCCESS', $this->records->getReturnCode());

$this->assertCount(6, $this->records->getRecords());
$aRecord = $this->records->getRecords()[0];

// Test podcast format
$podcastFormat = $aRecord->getFormats()[0]; // without images preview
$this->assertEquals('podcast', $podcastFormat->getType());
$this->assertEquals('https://test-install.blindsidenetworks.com/podcast/f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120/audio.ogg', $podcastFormat->getUrl());
$this->assertEquals('111', $podcastFormat->getProcessingTime());
$this->assertEquals('632', $podcastFormat->getLength());
$this->assertEquals('10500', $podcastFormat->getSize());

$presentationFormat = $aRecord->getFormats()[1]; // having images preview
$this->assertEquals('presentation', $presentationFormat->getType());
$this->assertEquals('http://test-install.blindsidenetworks.com/playback/presentation/0.9.0/playback.html?meetingId=f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120', $presentationFormat->getUrl());
$this->assertEquals(2973, $presentationFormat->getProcessingTime());
$this->assertEquals(532, $presentationFormat->getLength());
$this->assertEquals(168019, $presentationFormat->getSize());

$image = $presentationFormat->getImages()[0];
$this->assertEquals('Welcome', $image->getAlt());
$this->assertEquals(136, $image->getHeight());
$this->assertEquals(176, $image->getWidth());
$this->assertEquals('https://test-install.blindsidenetworks.com/presentation/f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120/presentation/d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1632646357291/thumbnails/thumb-1.png', $image->getUrl());
}

public function testGetRecordingResponseTypes()
{
$this->assertEachGetterValueIsString($this->records, ['getReturnCode']);
Expand Down
Loading