Skip to content

Commit 7f05eb6

Browse files
authored
Merge pull request #344 from opentok/feature/sip-dial-streams
Feature/sip dial streams
2 parents 5d255be + a76dbe5 commit 7f05eb6

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

src/OpenTok/OpenTok.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,9 @@ public function listStreams($sessionId)
11231123
* on PSTN phones. If from is undefined or set to a string (for example, "[email protected]"),
11241124
* +00000000 will show up as the incoming number on PSTN phones.</li>
11251125
*
1126+
* <li><code>'streams'</code> (array) &mdash; The Stream IDs of the participants which will included in the SIP
1127+
* call. If not provided, all streams in session will be selected.</li>
1128+
*
11261129
* </ul>
11271130
*
11281131
* @return SipCall An object contains the OpenTok connection ID and stream ID
@@ -1140,7 +1143,8 @@ public function dial($sessionId, $token, $sipUri, $options = [])
11401143
'secure' => true,
11411144
'from' => null,
11421145
'video' => false,
1143-
'observeForceMute' => false
1146+
'observeForceMute' => false,
1147+
'streams' => null
11441148
);
11451149

11461150
$options = array_merge($defaults, array_intersect_key($options, $defaults));

src/OpenTok/Util/Client.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ public function setStreamClassLists($sessionId, $payload)
690690
* @param string $sessionId
691691
* @param string $token
692692
* @param string $sipUri
693-
* @param array{secure: bool, headers?: array<string, string>, auth?: array{username: string, password: string}, from?: string, video?: boolean} $options
693+
* @param array{secure: bool, headers?: array<string, string>, auth?: array{username: string, password: string}, from?: string, video?: boolean, streams?: array} $options
694694
* @return array{id: string, streamId: string, connectId: string}
695695
* @throws AuthenticationException
696696
* @throws DomainException
@@ -726,6 +726,10 @@ public function dial($sessionId, $token, $sipUri, $options)
726726
$body['sip']['video'] = (bool) $options['video'];
727727
}
728728

729+
if (array_key_exists('streams', $options)) {
730+
$body['sip']['streams'] = $options['streams'];
731+
}
732+
729733
// set up the request
730734
$request = new Request('POST', '/v2/project/' . $this->apiKey . '/call');
731735

tests/OpenTokTest/OpenTokTest.php

+34
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,40 @@ public function testSipCallVideo(): void
24022402
$this->assertEquals(true, $body->sip->video);
24032403
}
24042404

2405+
public function testSipCallStreams(): void
2406+
{
2407+
$this->setupOTWithMocks([[
2408+
'code' => 200,
2409+
'headers' => [
2410+
'Content-Type' => 'application/json'
2411+
],
2412+
'path' => 'v2/project/APIKEY/dial'
2413+
]]);
2414+
2415+
$sessionId = '1_MX4xMjM0NTY3OH4-VGh1IEZlYiAyNyAwNDozODozMSBQU1QgMjAxNH4wLjI0NDgyMjI';
2416+
$bogusToken = 'T1==TEST';
2417+
$bogusSipUri = 'sip:[email protected]';
2418+
2419+
$options = [
2420+
'video' => true,
2421+
'streams' => ['stream1', 'stream2']
2422+
];
2423+
2424+
$sipCall = $this->opentok->dial($sessionId, $bogusToken, $bogusSipUri, $options);
2425+
2426+
$this->assertInstanceOf('OpenTok\SipCall', $sipCall);
2427+
$this->assertNotNull($sipCall->id);
2428+
$this->assertNotNull($sipCall->connectionId);
2429+
$this->assertNotNull($sipCall->streamId);
2430+
2431+
$this->assertCount(1, $this->historyContainer);
2432+
$request = $this->historyContainer[0]['request'];
2433+
2434+
$body = json_decode($request->getBody());
2435+
$this->assertEquals(true, $body->sip->video);
2436+
$this->assertEquals('stream1', $body->sip->streams[0]);
2437+
}
2438+
24052439
public function testSipCallVideoWithObserveForceMute(): void
24062440
{
24072441
$this->setupOTWithMocks([[

0 commit comments

Comments
 (0)