-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Bandwidth/DX-2704
DX-2704 Adding StartStream and StopStream Verbs
- Loading branch information
Showing
3 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
/** | ||
* StartStream.php | ||
* | ||
* Implementation of the BXML StartStream verb | ||
* | ||
* @copyright Bandwidth INC | ||
*/ | ||
|
||
namespace BandwidthLib\Voice\Bxml; | ||
|
||
require_once "Verb.php"; | ||
|
||
class StartStream extends Verb { | ||
|
||
/** | ||
* Sets the destination attribute for StartStream | ||
* | ||
* @param string $destination A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL encoded as base64 encoded PCMU/G711 audio. See below for more details on the websocket packet format. | ||
*/ | ||
public function destination($destination) { | ||
$this->destination = $destination; | ||
} | ||
|
||
/** | ||
* Sets the name attribute for StartStream | ||
* | ||
* @param string $name A name to refer to this stream by. Used when sending [`<StopStream>`][1]. If not provided, a random name will be generated and sent in the [`Media Stream Started`][2] webook | ||
*/ | ||
public function name($name) { | ||
$this->name = $name; | ||
} | ||
|
||
/** | ||
* Sets the tracks attribute for StartStream | ||
* | ||
* @param string $tracks The part of the call to send a stream from. `inbound`, `outbound` or `both`. Default is `inbound`. | ||
* | ||
*/ | ||
public function tracks($tracks) { | ||
$this->tracks = $tracks; | ||
} | ||
|
||
/** | ||
* Sets the username attribute for StartStream | ||
* | ||
* @param string $username The username to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). | ||
*/ | ||
public function username($username) { | ||
$this->username = $username; | ||
} | ||
|
||
/** | ||
* Sets the password attribute for StartStream | ||
* | ||
* @param string $password The password to send in the HTTP request to `streamEventUrl`. If specified, the URLs must be TLS-encrypted (i.e., `https`). | ||
*/ | ||
public function password($password) { | ||
$this->password = $password; | ||
} | ||
|
||
/** | ||
* Sets the streamEventUrl attribute for StartStream | ||
* | ||
* @param string $streamEventUrl URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. | ||
*/ | ||
public function streamEventUrl($streamEventUrl) { | ||
$this->streamEventUrl = $streamEventUrl; | ||
} | ||
|
||
/** | ||
* Sets the streamEventMethod attribute for StartStream | ||
* | ||
* @param bool $streamEventMethod The HTTP method to use for the request to `streamEventUrl`. GET or POST. Default value is POST. | ||
*/ | ||
public function streamEventMethod($streamEventMethod) { | ||
$this->streamEventMethod = $streamEventMethod; | ||
} | ||
|
||
public function toBxml($doc) { | ||
$element = $doc->createElement("StartStream"); | ||
|
||
if(isset($this->destination)) { | ||
$element->setattribute("destination", $this->destination); | ||
} | ||
|
||
if(isset($this->name)) { | ||
$element->setattribute("name", $this->name); | ||
} | ||
|
||
if(isset($this->tracks)) { | ||
$element->setattribute("tracks", $this->tracks); | ||
} | ||
|
||
if(isset($this->username)) { | ||
$element->setattribute("username", $this->username); | ||
} | ||
|
||
if(isset($this->password)) { | ||
$element->setattribute("password", $this->password); | ||
} | ||
|
||
if(isset($this->streamEventUrl)) { | ||
$element->setattribute("streamEventUrl", $this->streamEventUrl); | ||
} | ||
|
||
if(isset($this->streamEventMethod)) { | ||
$element->setattribute("streamEventMethod", $this->streamEventMethod); | ||
} | ||
|
||
return $element; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* StopStreamphp | ||
* | ||
* Implementation of the BXML StopStream verb | ||
* | ||
* @copyright Bandwidth INC | ||
*/ | ||
|
||
namespace BandwidthLib\Voice\Bxml; | ||
|
||
require_once "Verb.php"; | ||
|
||
class StopStream extends Verb { | ||
|
||
/** | ||
* Sets the name attribute for StopStream | ||
* | ||
* @param float $name (required) The name of the stream to stop. This is either the user selected name when sending the [`<StartStream>`][1] verb, or the system generated name returned in the [Media Stream Started][2] webhook if `<StartStream>` was sent with no `name` attribute. | ||
*/ | ||
public function name($name) { | ||
$this->name = $name; | ||
} | ||
|
||
public function toBxml($doc) { | ||
$element = $doc->createElement("StopStream"); | ||
|
||
if(isset($this->name)) { | ||
$element->setAttribute("name", $this->name); | ||
} | ||
|
||
return $element; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters