|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SquareetLabs\LaravelOpenVidu\Builders; |
|
4
|
|
|
|
|
5
|
|
|
use SquareetLabs\LaravelOpenVidu\Enums\MediaMode; |
|
6
|
|
|
use SquareetLabs\LaravelOpenVidu\Enums\OutputMode; |
|
7
|
|
|
use SquareetLabs\LaravelOpenVidu\Enums\RecordingLayout; |
|
8
|
|
|
use SquareetLabs\LaravelOpenVidu\Exceptions\OpenViduInvalidArgumentException; |
|
9
|
|
|
use SquareetLabs\LaravelOpenVidu\RecordingProperties; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class RecordingPropertiesBuilder |
|
13
|
|
|
* @package SquareetLabs\LaravelOpenVidu\Builders |
|
14
|
|
|
*/ |
|
15
|
|
|
class RecordingPropertiesBuilder implements BuilderInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @param array $properties |
|
19
|
|
|
* @return RecordingProperties|null |
|
20
|
|
|
* @throws OpenViduInvalidArgumentException |
|
21
|
|
|
*/ |
|
22
|
|
|
public static function build(array $properties) |
|
23
|
|
|
{ |
|
24
|
|
|
if (array_key_exists('session', $properties)) { |
|
25
|
|
|
return new RecordingProperties( |
|
26
|
|
|
$properties['session'], |
|
27
|
|
|
array_key_exists('name', $properties) ? $properties['name'] : '', |
|
28
|
|
|
array_key_exists('outputMode', $properties) ? $properties['outputMode'] : OutputMode::COMPOSED, |
|
29
|
|
|
array_key_exists('recordingLayout', $properties) ? $properties['recordingLayout'] : RecordingLayout::BEST_FIT, |
|
30
|
|
|
array_key_exists('resolution', $properties) ? $properties['resolution'] : null, |
|
31
|
|
|
array_key_exists('hasAudio', $properties) ? $properties['hasAudio'] : true, |
|
32
|
|
|
array_key_exists('hasVideo', $properties) ? $properties['hasVideo'] : true, |
|
33
|
|
|
array_key_exists('customLayout', $properties) ? $properties['customLayout'] : MediaMode::ROUTED |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
throw new OpenViduInvalidArgumentException('RecordingPropertiesBuilder::build spects an array with session key'); |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|