|
4 | 4 |
|
5 | 5 | use OpenTok\Session; |
6 | 6 | use OpenTok\Archive; |
| 7 | +use OpenTok\Broadcast; |
| 8 | +use OpenTok\Layout; |
7 | 9 | use OpenTok\Role; |
8 | 10 | use OpenTok\MediaMode; |
9 | 11 | use OpenTok\ArchiveMode; |
@@ -384,6 +386,88 @@ public function listArchives($offset=0, $count=null) |
384 | 386 | return new ArchiveList($archiveListData, array( 'client' => $this->client )); |
385 | 387 | } |
386 | 388 |
|
| 389 | + public function startBroadcast($sessionId, $options=array()) |
| 390 | + { |
| 391 | + // unpack optional arguments (merging with default values) into named variables |
| 392 | + // NOTE: although the server can be authoritative about the default value of layout, its |
| 393 | + // not preferred to depend on that in the SDK because its then harder to garauntee backwards |
| 394 | + // compatibility |
| 395 | + $defaults = array( |
| 396 | + 'layout' => Layout::getBestFit() |
| 397 | + ); |
| 398 | + $options = array_merge($defaults, array_intersect_key($options, $defaults)); |
| 399 | + list($layout) = array_values($options); |
| 400 | + |
| 401 | + // validate arguments |
| 402 | + Validators::validateSessionId($sessionId); |
| 403 | + Validators::validateLayout($layout); |
| 404 | + |
| 405 | + // make API call |
| 406 | + $broadcastData = $this->client->startBroadcast($sessionId, $options); |
| 407 | + |
| 408 | + return new Broadcast($broadcastData, array( 'client' => $this->client )); |
| 409 | + } |
| 410 | + |
| 411 | + public function stopBroadcast($broadcastId) |
| 412 | + { |
| 413 | + // validate arguments |
| 414 | + Validators::validateBroadcastId($broadcastId); |
| 415 | + |
| 416 | + // make API call |
| 417 | + $broadcastData = $this->client->stopBroadcast($broadcastId); |
| 418 | + return new Broadcast($broadcastData, array( |
| 419 | + 'client' => $this->client, |
| 420 | + 'isStopped' => true |
| 421 | + )); |
| 422 | + } |
| 423 | + |
| 424 | + public function getBroadcast($broadcastId) |
| 425 | + { |
| 426 | + Validators::validateBroadcastId($broadcastId); |
| 427 | + |
| 428 | + $broadcastData = $this->client->getBroadcast($broadcastId); |
| 429 | + return new Broadcast($broadcastData, array( 'client' => $this->client )); |
| 430 | + } |
| 431 | + |
| 432 | + // TODO: not yet implemented by the platform |
| 433 | + // public function getBroadcastLayout($broadcastId) |
| 434 | + // { |
| 435 | + // Validators::validateBroadcastId($broadcastId); |
| 436 | + // |
| 437 | + // $layoutData = $this->client->getLayout($broadcastId, 'broadcast'); |
| 438 | + // return Layout::fromData($layoutData); |
| 439 | + // } |
| 440 | + |
| 441 | + public function updateBroadcastLayout($broadcastId, $layout) |
| 442 | + { |
| 443 | + Validators::validateBroadcastId($broadcastId); |
| 444 | + Validators::validateLayout($layout); |
| 445 | + |
| 446 | + // TODO: platform implementation does not meet API Review spec |
| 447 | + // $layoutData = $this->client->updateLayout($broadcastId, $layout, 'broadcast'); |
| 448 | + // return Layout::fromData($layoutData); |
| 449 | + |
| 450 | + $this->client->updateLayout($broadcastId, $layout, 'broadcast'); |
| 451 | + } |
| 452 | + |
| 453 | + public function updateStream($sessionId, $streamId, $properties = array()) |
| 454 | + { |
| 455 | + // unpack optional arguments (merging with default values) into named variables |
| 456 | + $defaults = array( |
| 457 | + 'layoutClassList' => array() |
| 458 | + ); |
| 459 | + $properties = array_merge($defaults, array_intersect_key($properties, $defaults)); |
| 460 | + list($layoutClassList) = array_values($properties); |
| 461 | + |
| 462 | + // validate arguments |
| 463 | + Validators::validateSessionId($sessionId); |
| 464 | + Validators::validateStreamId($streamId); |
| 465 | + Validators::validateLayoutClassList($layoutClassList, 'JSON'); |
| 466 | + |
| 467 | + // make API call |
| 468 | + $this->client->updateStream($sessionId, $streamId, $properties); |
| 469 | + } |
| 470 | + |
387 | 471 | /** |
388 | 472 | * Initiate an outgoing SIP call |
389 | 473 | * |
|
0 commit comments