Skip to content

Commit e1a2a94

Browse files
committed
Add new keys for hlsStatus, access for broadcast status and rtmp status
1 parent 989f990 commit e1a2a94

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/OpenTok/Broadcast.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
*
4545
* @property boolean $isDvr
4646
* Whether the broadcast supports DVR functionality for the HLS stream.
47+
48+
* @property string $status
49+
* Broadcast state. Either `started` or `stopped`
4750
*
4851
* @property boolean $isLowLatency
4952
* Whether the broadcast supports low-latency mode for the HLS stream.
@@ -86,6 +89,8 @@ class Broadcast
8689
private $hasAudio;
8790
/** @ignore */
8891
private $hasVideo;
92+
/** @ignore */
93+
private $status;
8994

9095
public function __construct($broadcastData, $options = array())
9196
{
@@ -120,6 +125,10 @@ public function __construct($broadcastData, $options = array())
120125
$this->multiBroadcastTag = $this->data['multiBroadcastTag'];
121126
}
122127

128+
if (isset($this->data['status'])) {
129+
$this->status = $this->data['status'];
130+
}
131+
123132
$this->isStopped = $isStopped;
124133
$this->resolution = $this->data['resolution'];
125134
$this->isHls = isset($this->data['settings']['hls']);
@@ -148,7 +157,6 @@ public function __get($name)
148157
case 'partnerId':
149158
case 'sessionId':
150159
case 'broadcastUrls':
151-
case 'status':
152160
case 'maxDuration':
153161
case 'streamMode':
154162
return $this->data[$name];
@@ -170,6 +178,8 @@ public function __get($name)
170178
return $this->hasAudio;
171179
case 'hasVideo':
172180
return $this->hasVideo;
181+
case 'status':
182+
return $this->status;
173183
default:
174184
return null;
175185
}

tests/OpenTokTest/OpenTokTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,7 @@ public function testCanStartBroadcastWithDefaultHlsOptions(): void
16401640
$this->assertTrue($broadcast->isHls);
16411641
$this->assertFalse($broadcast->isDvr);
16421642
$this->assertFalse($broadcast->isLowLatency);
1643+
$this->assertEquals('live', $broadcast->broadcastUrls['rtmp']['foo']['status']);
16431644
}
16441645

16451646
public function testCanStartBroadcastWithDvrEnabled(): void

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
"createdAt":1472435659497,
66
"broadcastUrls":{
77
"hls":"https://cdn-broadcast001-dub.tokbox.com/29908/29908_6706b658-2eba-42cc-b4d2-7d01a104d182.smil/playlist.m3u8",
8+
"hlsStatus": "ready",
89
"rtmp": {
910
"foo": {
1011
"serverUrl": "rtmp://myfooserver/myfooapp",
11-
"streamName": "myfoostreamname"
12+
"streamName": "myfoostreamname",
13+
"status": "live"
1214
},
1315
"bar": {
1416
"serverUrl": "rtmp://mybarserver/mybarapp",
15-
"streamName": "mybarstreamname"
17+
"streamName": "mybarstreamname",
18+
"status": "offline"
1619
}
1720
}
1821
},

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
"createdAt":1472435659497,
66
"broadcastUrls":{
77
"hls":"https://cdn-broadcast001-dub.tokbox.com/29908/29908_6706b658-2eba-42cc-b4d2-7d01a104d182.smil/playlist.m3u8",
8+
"hlsStatus": "ready",
89
"rtmp": {
910
"foo": {
1011
"serverUrl": "rtmp://myfooserver/myfooapp",
11-
"streamName": "myfoostreamname"
12+
"streamName": "myfoostreamname",
13+
"status": "live"
1214
},
1315
"bar": {
1416
"serverUrl": "rtmp://mybarserver/mybarapp",
15-
"streamName": "mybarstreamname"
17+
"streamName": "mybarstreamname",
18+
"status": "offline"
1619
}
1720
}
1821
},

0 commit comments

Comments
 (0)