-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(video): Added SIP and DTMF playing (#776)
- Loading branch information
1 parent
15503f9
commit 727027e
Showing
6 changed files
with
260 additions
and
172 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ import { MediaMode } from '../lib/interfaces/MediaMode'; | |
import { ArchiveMode } from '../lib/interfaces/ArchiveMode'; | ||
import { Auth } from '@vonage/auth'; | ||
|
||
export const BASE_URL = 'https://video.api.vonage.com/'.replace(/\/+$/, ''); | ||
const BASE_URL = 'https://video.api.vonage.com/'.replace(/\/+$/, ''); | ||
|
||
describe('video', () => { | ||
let client; | ||
|
@@ -534,4 +534,50 @@ describe('video', () => { | |
|
||
await client.setStreamClassLists('sess-1234', [{id: 'stream-1234', layoutClassList: ["full"]}]); | ||
}); | ||
|
||
test("can initiate a SIP call", async () => { | ||
const options = { | ||
token: client.generateClientToken(), | ||
sip: { | ||
uri: 'sip:[email protected];transport=tls' | ||
} | ||
} | ||
|
||
const expectedResponse = { | ||
id: "b0a5a8c7-dc38-459f-a48d-a7f2008da853", | ||
connectionId: "e9f8c166-6c67-440d-994a-04fb6dfed007", | ||
streamId: "482bce73-f882-40fd-8ca5-cb74ff416036", | ||
}; | ||
|
||
const expectedBody = Object.assign({}, { sessionId: "2_MX40NTMyODc3Mn5-fg" }, options); | ||
|
||
nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) | ||
.persist() | ||
.post('/v2/project/abcd-1234/dial', expectedBody) | ||
.reply(200, expectedResponse); | ||
|
||
const resp = await client.intiateSIPCall("2_MX40NTMyODc3Mn5-fg", options); | ||
|
||
expect(resp.id).toEqual(expectedResponse.id); | ||
expect(resp.connectionId).toEqual(expectedResponse.connectionId); | ||
expect(resp.streamId).toEqual(expectedResponse.streamId); | ||
}); | ||
|
||
test("can play DTMF digits to everyone", async () => { | ||
nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) | ||
.persist() | ||
.post('/v2/project/abcd-1234/session/2_MX40NTMyODc3Mn5-fg/play-dtmf', { digits: '1234#'}) | ||
.reply(200); | ||
|
||
await client.playDTMF("2_MX40NTMyODc3Mn5-fg", "1234#"); | ||
}); | ||
|
||
test("can play DTMF digits into one connection", async () => { | ||
nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) | ||
.persist() | ||
.post('/v2/project/abcd-1234/session/2_MX40NTMyODc3Mn5-fg/connection/396edda0-fc30-41fd-8e63/play-dtmf', {digits: "1234#"}) | ||
.reply(200); | ||
|
||
await client.playDTMF("2_MX40NTMyODc3Mn5-fg", "1234#", "396edda0-fc30-41fd-8e63"); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { Video } from './video'; | ||
export { SIPCallOptions } from './interfaces/SIPCallOptions'; |
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,5 @@ | ||
export interface SIPCallResponse { | ||
id: string; | ||
connectionId: string; | ||
streamId: string; | ||
} |
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,17 @@ | ||
export interface SIPCallOptions { | ||
token: string; | ||
sip: { | ||
uri: string; | ||
from?: string; | ||
headers?: { | ||
[key: string]: string; | ||
}, | ||
auth?: { | ||
username: string; | ||
password: string; | ||
} | ||
secure?: boolean; | ||
video?: boolean; | ||
observeForceMute?: boolean; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { VetchResponse } from '@vonage/vetch'; | ||
|
||
export interface VideoResponse<T> extends VetchResponse<T> {} | ||
export type VideoResponse<T> = VetchResponse<T> |
Oops, something went wrong.