Skip to content

Commit 156ad67

Browse files
committed
isAudio and isVideo added to Broadcast
1 parent a1e0533 commit 156ad67

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

src/OpenTok/Broadcast.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ class Broadcast
8282
private $multiBroadcastTag;
8383
/** @ignore */
8484
private $resolution;
85-
85+
/** @ignore */
86+
private $isAudio;
87+
/** @ignore */
88+
private $isVideo;
89+
8690
public function __construct($broadcastData, $options = array())
8791
{
8892
// unpack optional arguments (merging with default values) into named variables
@@ -98,9 +102,12 @@ public function __construct($broadcastData, $options = array())
98102
'isHls' => true,
99103
'isLowLatency' => false,
100104
'isDvr' => false,
105+
'isAudio' => true,
106+
'isVideo' => true
101107
);
108+
102109
$options = array_merge($defaults, array_intersect_key($options, $defaults));
103-
list($apiKey, $apiSecret, $apiUrl, $client, $isStopped, $streamMode) = array_values($options);
110+
list($apiKey, $apiSecret, $apiUrl, $client, $isStopped, $streamMode, $isAudio, $isVideo) = array_values($options);
104111

105112
// validate params
106113
Validators::validateBroadcastData($broadcastData);
@@ -118,6 +125,8 @@ public function __construct($broadcastData, $options = array())
118125
$this->isHls = isset($this->data['settings']['hls']);
119126
$this->isLowLatency = $this->data['settings']['hls']['lowLatency'] ?? false;
120127
$this->isDvr = $this->data['settings']['hls']['dvr'] ?? false;
128+
$this->isAudio = $isAudio;
129+
$this->isVideo = $isVideo;
121130

122131
$this->client = isset($client) ? $client : new Client();
123132
if (!$this->client->isConfigured()) {
@@ -157,6 +166,10 @@ public function __get($name)
157166
return $this->isDvr;
158167
case 'multiBroadcastTag':
159168
return $this->multiBroadcastTag;
169+
case 'isAudio':
170+
return $this->isAudio;
171+
case 'isVideo':
172+
return $this->isVideo;
160173
default:
161174
return null;
162175
}

src/OpenTok/OpenTok.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -820,19 +820,21 @@ public function startBroadcast(string $sessionId, array $options = []): Broadcas
820820
Validators::validateResolution($options['resolution']);
821821
}
822822

823-
if (isset($options['output']['hls'])) {
824-
Validators::validateBroadcastOutputOptions($options['output']['hls']);
823+
if (isset($options['outputs']['hls'])) {
824+
Validators::validateBroadcastOutputOptions($options['outputs']['hls']);
825825
}
826826

827-
if (isset($options['output']['rtmp'])) {
828-
Validators::validateRtmpStreams($options['output']['rtmp']);
827+
if (isset($options['outputs']['rtmp'])) {
828+
Validators::validateRtmpStreams($options['outputs']['rtmp']);
829829
}
830830

831831
$defaults = [
832832
'layout' => Layout::getBestFit(),
833+
'hasAudio' => true,
834+
'hasVideo' => true,
833835
'streamMode' => 'auto',
834836
'resolution' => '640x480',
835-
'output' => [
837+
'outputs' => [
836838
'hls' => [
837839
'dvr' => false,
838840
'lowLatency' => false
@@ -842,7 +844,7 @@ public function startBroadcast(string $sessionId, array $options = []): Broadcas
842844

843845
$options = array_merge($defaults, $options);
844846

845-
list($layout, $streamMode) = array_values($options);
847+
list($layout, $hasAudio, $hasVideo, $streamMode) = array_values($options);
846848

847849
// validate arguments
848850
Validators::validateSessionId($sessionId);

tests/OpenTokTest/OpenTokTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ public function testCanStartBroadcastWithRmtp()
14091409
$sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4';
14101410

14111411
$options = [
1412-
'output' => [
1412+
'outputs' => [
14131413
'hls' => [
14141414
'dvr' => true,
14151415
'lowLatency' => false
@@ -1451,7 +1451,7 @@ public function testCannotStartBroadcastWithOver5RtmpChannels(): void
14511451
$sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4';
14521452

14531453
$options = [
1454-
'output' => [
1454+
'outputs' => [
14551455
'hls' => [
14561456
'dvr' => true,
14571457
'lowLatency' => false
@@ -1525,7 +1525,7 @@ public function testCanStartBroadcastWithDvrEnabled()
15251525
$sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4';
15261526

15271527
$options = [
1528-
'output' => [
1528+
'outputs' => [
15291529
'hls' => [
15301530
'dvr' => true,
15311531
'lowLatency' => false
@@ -1552,7 +1552,7 @@ public function testCanStartBroadcastWithLowLatencyEnabled()
15521552
$sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4';
15531553

15541554
$options = [
1555-
'output' => [
1555+
'outputs' => [
15561556
'hls' => [
15571557
'dvr' => true,
15581558
'lowLatency' => false
@@ -1581,7 +1581,7 @@ public function testCannotStartBroadcastWithBothHlsAndDvrEnabled()
15811581
$sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4';
15821582

15831583
$options = [
1584-
'output' => [
1584+
'outputs' => [
15851585
'hls' => [
15861586
'dvr' => true,
15871587
'lowLatency' => true

tests/mock/v2/project/APIKEY/broadcast/BROADCASTID/start_default

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
"partnerId":854511,
2323
"maxDuration":5400,
2424
"resolution": "1280x720",
25-
"streamMode": "auto"
25+
"streamMode": "auto",
26+
"hasAudio": true,
27+
"hasVideo": true
2628
}

tests/mock/v2/project/APIKEY/broadcast/BROADCASTID/start_dvr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
"partnerId":854511,
2323
"maxDuration":5400,
2424
"resolution": "1280x720",
25-
"streamMode": "auto"
25+
"streamMode": "auto",
26+
"hasAudio": true,
27+
"hasVideo": true
2628
}

tests/mock/v2/project/APIKEY/broadcast/BROADCASTID/start_ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
"partnerId":854511,
2323
"maxDuration":5400,
2424
"resolution": "1280x720",
25-
"streamMode": "auto"
25+
"streamMode": "auto",
26+
"hasAudio": true,
27+
"hasVideo": true
2628
}

0 commit comments

Comments
 (0)