Skip to content

Commit

Permalink
Merge pull request #236 from opentok/dev
Browse files Browse the repository at this point in the history
v4.4.0
  • Loading branch information
Manik Sachdeva authored Jan 8, 2019
2 parents 3bc33d5 + 1c72c46 commit a8b636c
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 51 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Add this package (`opentok/opentok`) to your `composer.json` file, or just run t
command line:

```
$ ./composer.phar require opentok/opentok 4.3.x
$ ./composer.phar require opentok/opentok 4.4.x
```

### Manually:
Expand Down Expand Up @@ -255,16 +255,18 @@ You can only start live streaming broadcasts for sessions that use the OpenTok M
Start the live streaming broadcast of an OpenTok Session using the
`startBroadcast($sessionId, $options)` method of the `OpenTok\OpenTok` class.
This will return an `OpenTok\Broadcast` instance. The `$options` parameter is
an optional array used to assign a layout type for the broadcast.
an optional array used to assign broadcast options such as layout, maxDuration, resolution, and more.

```php
// Start a live streaming broadcast of a session
$broadcast = $opentok->startBroadcast($sessionId);


// Start a live streaming broadcast of a session, setting a layout type
// Start a live streaming broadcast of a session, using broadcast options
$options = array(
'layout' => Layout::getBestFit()
'layout' => Layout::getBestFit(),
'maxDuration' => 5400,
'resolution' => '1280x720'
);
$broadcast = $opentok->startBroadcast($sessionId, $options);

Expand Down
3 changes: 3 additions & 0 deletions src/OpenTok/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public function __get($name)
case 'partnerId':
case 'sessionId':
case 'broadcastUrls':
case 'status':
case 'maxDuration':
case 'resolution':
return $this->data[$name];
break;
case 'hlsUrl':
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTok/OpenTok.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public function startBroadcast($sessionId, $options=array())
$defaults = array(
'layout' => Layout::getBestFit()
);
$options = array_merge($defaults, array_intersect_key($options, $defaults));
$options = array_merge($defaults, $options);
list($layout) = array_values($options);

// validate arguments
Expand Down
14 changes: 9 additions & 5 deletions src/OpenTok/Util/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

// TODO: build this dynamically
/** @internal */
define('OPENTOK_SDK_VERSION', '4.3.0');
define('OPENTOK_SDK_VERSION', '4.4.0');
/** @internal */
define('OPENTOK_SDK_USER_AGENT', 'OpenTok-PHP-SDK/' . OPENTOK_SDK_VERSION);

Expand Down Expand Up @@ -280,13 +280,17 @@ public function startBroadcast($sessionId, $options)
'/v2/project/'.$this->apiKey.'/broadcast'
);

$optionsJson = [
'sessionId' => $sessionId,
'layout' => $options['layout']->jsonSerialize()
];
unset($options['layout']);
$optionsJson = array_merge($optionsJson, $options);

try {
$response = $this->client->send($request, [
'debug' => $this->isDebug(),
'json' => [
'sessionId' => $sessionId,
'layout' => $options['layout']->jsonSerialize()
]
'json' => $optionsJson
]);
$broadcastJson = json_decode($response->getBody(), true);
} catch (\Exception $e) {
Expand Down
4 changes: 2 additions & 2 deletions tests/OpenTok/ArchiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testStopsArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeaderLine('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/4.3.0', $userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/4.4.0', $userAgent);

// TODO: test the properties of the actual archive object
$this->assertEquals('stopped', $this->archive->status);
Expand Down Expand Up @@ -195,7 +195,7 @@ public function testDeletesArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeaderLine('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/4.3.0', $userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/4.4.0', $userAgent);

$this->assertTrue($success);
// TODO: assert that all properties of the archive object were cleared
Expand Down
Loading

0 comments on commit a8b636c

Please sign in to comment.