From a2c30f1fb8098ecea72b8bc3fb9b296c5227353d Mon Sep 17 00:00:00 2001 From: mfiyalka Date: Mon, 30 Jan 2023 22:50:32 +0200 Subject: [PATCH] Added optional properties when starting archiving --- src/OpenTok/OpenTok.php | 8 ++++++++ src/OpenTok/Util/Validators.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/OpenTok/OpenTok.php b/src/OpenTok/OpenTok.php index 022d050..8b17480 100644 --- a/src/OpenTok/OpenTok.php +++ b/src/OpenTok/OpenTok.php @@ -454,6 +454,14 @@ public function startArchive(string $sessionId, $options = []): Archive 'resolution' => null, 'streamMode' => StreamMode::AUTO, ); + if (isset($options['multiArchiveTag'])) { + $defaults['multiArchiveTag'] = $options['multiArchiveTag']; + Validators::validateArchiveMultiArchiveTag($defaults['multiArchiveTag']); + } + if (isset($options['layout'])) { + $defaults['layout'] = $options['layout']; + Validators::validateArchiveLayout($defaults['layout']); + } $options = array_merge($defaults, array_intersect_key($options, $defaults)); list($name, $hasVideo, $hasAudio, $outputMode, $resolution, $streamMode) = array_values($options); diff --git a/src/OpenTok/Util/Validators.php b/src/OpenTok/Util/Validators.php index 7d1f92a..762a8f1 100755 --- a/src/OpenTok/Util/Validators.php +++ b/src/OpenTok/Util/Validators.php @@ -201,6 +201,22 @@ public static function validateArchiveId($archiveId) ); } } + public static function validateArchiveMultiArchiveTag($multiArchiveTag) + { + if ($multiArchiveTag != null && !is_string($multiArchiveTag) /* TODO: length? */) { + throw new InvalidArgumentException( + 'The multiArchiveTag was not a string: ' . print_r($multiArchiveTag, true) + ); + } + } + public static function validateArchiveLayout($layout) + { + if ($layout != null && !is_array($layout)) { + throw new InvalidArgumentException( + 'The layout was not an array: ' . print_r($layout, true) + ); + } + } public static function validateArchiveData($archiveData) { if (!self::$archiveSchemaUri) {