Skip to content

Commit 4c8a853

Browse files
committed
feat: added quantization parameter
1 parent bec0caa commit 4c8a853

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"johnstevenson/json-works": "~1.1",
3434
"firebase/php-jwt": "^6.11",
3535
"guzzlehttp/guzzle": "~6.0|~7.0",
36-
"ext-json": "*",
36+
"ext-json": "*",
3737
"vonage/jwt": "^0.5.1"
3838
},
3939
"require-dev": {

src/OpenTok/Archive.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public function __construct($archiveData, $options = array())
136136
Validators::validateClient($client);
137137
Validators::validateHasStreamMode($streamMode);
138138

139+
if (isset($archiveData['maxBitrate']) && isset($archiveData['quantizationParameter'])) {
140+
throw new \DomainException('Max Bitrate cannot be set with QuantizationParameter ');
141+
}
142+
139143
$this->data = $archiveData;
140144

141145
if (isset($this->data['multiArchiveTag'])) {
@@ -179,6 +183,7 @@ public function __get($name)
179183
case 'resolution':
180184
case 'streamMode':
181185
case 'maxBitrate':
186+
case 'quantizationParameter':
182187
return $this->data[$name];
183188
case 'multiArchiveTag':
184189
return $this->multiArchiveTag;

src/OpenTok/OpenTok.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ public function disableForceMute(string $sessionId, array $options): bool
887887
* <li><code>maxBitRate</code> &mdash; Max Bitrate allowed for the broadcast composing. Must be between
888888
* 400000 and 2000000.</li>
889889
*
890+
* <li><code>quantizationParameter</code> &mdash; quantization parameter (QP) is an optional video encoding
891+
* value allowed for composed archiving, smaller values generate higher quality and larger archives</li>
892+
*
890893
* <li><code>outputs</code> (Array) &mdash;
891894
* Defines the HLS broadcast and RTMP streams. You can provide the following keys:
892895
* <ul>

tests/OpenTokTest/ArchiveTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function setUpBeforeClass(): void
3030
self::$mockBasePath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'mock' . DIRECTORY_SEPARATOR;
3131
}
3232

33-
public function setupArchives($streamMode)
33+
public function setupArchives($streamMode, $quantization = false)
3434
{
3535
// Set up fixtures
3636
$this->archiveData = array(
@@ -49,9 +49,15 @@ public function setupArchives($streamMode)
4949
'outputMode' => 'composed',
5050
'resolution' => '640x480',
5151
'streamMode' => $streamMode,
52-
'multiArchiveTag' => true
52+
'multiArchiveTag' => true,
53+
'maxBitrate' => 400000,
5354
);
5455

56+
if ($quantization) {
57+
unset($this->archiveData['maxBitrate']);
58+
$this->archiveData['quantizationParameter'] = 40;
59+
}
60+
5561
$this->archive = new Archive($this->archiveData, array(
5662
'apiKey' => $this->API_KEY,
5763
'apiSecret' => $this->API_SECRET,
@@ -127,6 +133,10 @@ public function testReadsProperties()
127133
$this->assertEquals($this->archiveData['resolution'], $this->archive->resolution);
128134
$this->assertEquals($this->archiveData['streamMode'], $this->archive->streamMode);
129135
$this->assertEquals($this->archiveData['multiArchiveTag'], $this->archive->multiArchiveTag);
136+
$this->assertEquals($this->archiveData['maxBitrate'], $this->archive->maxBitrate);
137+
138+
$this->setupArchives(StreamMode::AUTO, true);
139+
$this->assertEquals($this->archiveData['quantizationParameter'], $this->archive->quantizationParameter);
130140
}
131141

132142
public function testStopsArchive()

0 commit comments

Comments
 (0)