Skip to content

Commit

Permalink
formats d'enregistrements multiples
Browse files Browse the repository at this point in the history
  • Loading branch information
MedAzizHaddad committed Jun 15, 2022
1 parent 9ae8bea commit cba8240
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 2 deletions.
111 changes: 111 additions & 0 deletions src/Core/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?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
{
/**
* @var string
*/
private $alt;

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

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

/**
* @var string
*/
private $link;

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

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

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

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

/**
* @return int
*/
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
{
$this->link = $link;
}
}
39 changes: 39 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 @@ -35,6 +36,7 @@ class Record
private $playbackUrl;
private $playbackLength;
private $metas;
private $playbacks;

/**
* Record constructor.
Expand All @@ -56,6 +58,43 @@ 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
32 changes: 32 additions & 0 deletions tests/Responses/GetRecordingsResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,38 @@ public function testRecordMetadataContent()
$this->assertEquals('moodle-mod_bigbluebuttonbn (2015080611)', $metas['bbb-origin-tag']);
}

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

$this->assertCount(6, $this->records->getRecords());
$aRecord = $this->records->getRecords()[0];
$formatN1 = $aRecord->getPlaybacks()[0]; // without images preview
$this->assertEquals('podcast', $formatN1['type']);
$this->assertEquals('https://testurl/podcast/1.ogg', $formatN1['url']);
$this->assertEquals('111', $formatN1['processingTime']);
$this->assertEquals('222', $formatN1['length']);
$this->assertEquals('333', $formatN1['size']);

$formatN2 = $aRecord->getPlaybacks()[1]; // having images preview
$this->assertEquals('presentation', $formatN2['type']);
$this->assertEquals('https://testurl/podcast/2.ogg', $formatN2['url']);
$this->assertEquals('444', $formatN2['processingTime']);
$this->assertEquals('555', $formatN2['length']);
$this->assertEquals('666', $formatN2['size']);

$images = $formatN2['preview'];
$this->assertEquals('testurl1', $images[0]->getAlt());
$this->assertEquals('136', $images[0]->getHeight());
$this->assertEquals('176', $images[0]->getWidth());
$this->assertEquals('https://testurl1.png', $images[0]->getLink());

$this->assertEquals('testurl2', $images[1]->getAlt());
$this->assertEquals('136', $images[1]->getHeight());
$this->assertEquals('176', $images[1]->getWidth());
$this->assertEquals('https://testurl2.png', $images[1]->getLink());
}

public function testGetRecordingResponseTypes()
{
$this->assertEachGetterValueIsString($this->records, ['getReturnCode']);
Expand Down
19 changes: 17 additions & 2 deletions tests/fixtures/get_recordings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,25 @@
<bbb-recording-tags><![CDATA[]]></bbb-recording-tags>
</metadata>
<playback>
<format>
<type>podcast</type>
<url>https://testurl/podcast/1.ogg</url>
<processingTime>111</processingTime>
<length>222</length>
<size>333</size>
</format>
<format>
<type>presentation</type>
<url>http://test-install.blindsidenetworks.com/playback/presentation/0.9.0/playback.html?meetingId=f71d810b6e90a4a34ae02b8c7143e8733178578e-1462807897120</url>
<length>44</length>
<url>https://testurl/podcast/2.ogg</url>
<processingTime>444</processingTime>
<length>555</length>
<size>666</size>
<preview>
<images>
<image alt="testurl1" height="136" width="176">https://testurl1.png</image>
<image alt="testurl2" height="136" width="176">https://testurl2.png</image>
</images>
</preview>
</format>
</playback>
</recording>
Expand Down

0 comments on commit cba8240

Please sign in to comment.