Skip to content

Commit cf456a4

Browse files
committed
Add streams to sip dial
1 parent 5d255be commit cf456a4

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/OpenTok/OpenTok.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,8 @@ public function dial($sessionId, $token, $sipUri, $options = [])
11401140
'secure' => true,
11411141
'from' => null,
11421142
'video' => false,
1143-
'observeForceMute' => false
1143+
'observeForceMute' => false,
1144+
'streams' => null
11441145
);
11451146

11461147
$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)