1
1
import { ReactNode , useCallback , useRef , useState } from "react" ;
2
2
import React from "react" ;
3
3
import { Session } from "sip.js/lib/api/session" ;
4
- import { SessionManager } from "sip.js/lib/platform/web" ;
4
+ import { SessionManager , SessionManagerOptions } from "sip.js/lib/platform/web" ;
5
5
import { ErrorMessageLevel1 , ErrorMessageLevel2 } from "../enums/error" ;
6
6
import { ProviderContext } from "./SIPProviderContext" ;
7
7
import {
@@ -15,9 +15,11 @@ import {
15
15
export const SIPProvider = ( props : {
16
16
options : SIPProviderOptions ;
17
17
children : ReactNode | JSX . Element ;
18
+ mergedSessionManagerOptions ?: SessionManagerOptions ;
18
19
} ) : React . ReactNode => {
19
- const { options, children } = props ;
20
+ const { options, mergedSessionManagerOptions = { } , children } = props ;
20
21
const refAudioRemote = useRef < HTMLAudioElement > ( null ) ;
22
+ const refVideoRemote = useRef < HTMLVideoElement > ( null ) ;
21
23
22
24
const [ sessions , setSessions ] = useState < Record < string , Session > > ( { } ) ;
23
25
const [ sessionTimer , setSessionTimer ] = useState < SessionTimer > ( { } ) ;
@@ -51,10 +53,15 @@ export const SIPProvider = (props: {
51
53
media : {
52
54
constraints : {
53
55
audio : true ,
54
- video : false ,
56
+ video : true ,
55
57
} ,
56
58
remote : {
57
- audio : refAudioRemote . current as HTMLAudioElement ,
59
+ audio :
60
+ props . options . refAudioRemote ??
61
+ ( refAudioRemote . current as HTMLAudioElement ) ,
62
+ video :
63
+ props . options . refVideoRemote ??
64
+ ( refVideoRemote . current as HTMLVideoElement ) ,
58
65
} ,
59
66
} ,
60
67
delegate : {
@@ -123,6 +130,7 @@ export const SIPProvider = (props: {
123
130
setStatus ( CONNECT_STATUS . DISCONNECTED ) ;
124
131
} ,
125
132
} ,
133
+ ...mergedSessionManagerOptions ,
126
134
} ) ;
127
135
setSessionManager ( sessionManager ) ;
128
136
sessionManager . connect ( ) ;
@@ -142,8 +150,8 @@ export const SIPProvider = (props: {
142
150
>
143
151
{ children }
144
152
</ ProviderContext . Provider >
145
-
146
153
< audio ref = { refAudioRemote } />
154
+ < video ref = { refVideoRemote } />
147
155
</ >
148
156
) ;
149
157
} ;
0 commit comments