Skip to content

Commit

Permalink
Merge pull request #346 from opentok/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
SecondeJK authored Oct 23, 2023
2 parents 3fe0e17 + f84ba7f commit 73ac40b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/OpenTok/OpenTok.php
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,9 @@ public function listStreams($sessionId)
* on PSTN phones. If from is undefined or set to a string (for example, "[email protected]"),
* +00000000 will show up as the incoming number on PSTN phones.</li>
*
* <li><code>'streams'</code> (array) &mdash; The Stream IDs of the participants which will included in the SIP
* call. If not provided, all streams in session will be selected.</li>
*
* </ul>
*
* @return SipCall An object contains the OpenTok connection ID and stream ID
Expand All @@ -1140,7 +1143,8 @@ public function dial($sessionId, $token, $sipUri, $options = [])
'secure' => true,
'from' => null,
'video' => false,
'observeForceMute' => false
'observeForceMute' => false,
'streams' => null
);

$options = array_merge($defaults, array_intersect_key($options, $defaults));
Expand Down
6 changes: 5 additions & 1 deletion src/OpenTok/Util/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public function setStreamClassLists($sessionId, $payload)
* @param string $sessionId
* @param string $token
* @param string $sipUri
* @param array{secure: bool, headers?: array<string, string>, auth?: array{username: string, password: string}, from?: string, video?: boolean} $options
* @param array{secure: bool, headers?: array<string, string>, auth?: array{username: string, password: string}, from?: string, video?: boolean, streams?: array} $options
* @return array{id: string, streamId: string, connectId: string}
* @throws AuthenticationException
* @throws DomainException
Expand Down Expand Up @@ -726,6 +726,10 @@ public function dial($sessionId, $token, $sipUri, $options)
$body['sip']['video'] = (bool) $options['video'];
}

if (array_key_exists('streams', $options)) {
$body['sip']['streams'] = $options['streams'];
}

// set up the request
$request = new Request('POST', '/v2/project/' . $this->apiKey . '/call');

Expand Down
34 changes: 34 additions & 0 deletions tests/OpenTokTest/OpenTokTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,40 @@ public function testSipCallVideo(): void
$this->assertEquals(true, $body->sip->video);
}

public function testSipCallStreams(): void
{
$this->setupOTWithMocks([[
'code' => 200,
'headers' => [
'Content-Type' => 'application/json'
],
'path' => 'v2/project/APIKEY/dial'
]]);

$sessionId = '1_MX4xMjM0NTY3OH4-VGh1IEZlYiAyNyAwNDozODozMSBQU1QgMjAxNH4wLjI0NDgyMjI';
$bogusToken = 'T1==TEST';
$bogusSipUri = 'sip:[email protected]';

$options = [
'video' => true,
'streams' => ['stream1', 'stream2']
];

$sipCall = $this->opentok->dial($sessionId, $bogusToken, $bogusSipUri, $options);

$this->assertInstanceOf('OpenTok\SipCall', $sipCall);
$this->assertNotNull($sipCall->id);
$this->assertNotNull($sipCall->connectionId);
$this->assertNotNull($sipCall->streamId);

$this->assertCount(1, $this->historyContainer);
$request = $this->historyContainer[0]['request'];

$body = json_decode($request->getBody());
$this->assertEquals(true, $body->sip->video);
$this->assertEquals('stream1', $body->sip->streams[0]);
}

public function testSipCallVideoWithObserveForceMute(): void
{
$this->setupOTWithMocks([[
Expand Down

0 comments on commit 73ac40b

Please sign in to comment.