11import { ReactNode , useCallback , useRef , useState } from "react" ;
22import React from "react" ;
33import { 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" ;
55import { ErrorMessageLevel1 , ErrorMessageLevel2 } from "../enums/error" ;
66import { ProviderContext } from "./SIPProviderContext" ;
77import {
@@ -15,9 +15,11 @@ import {
1515export const SIPProvider = ( props : {
1616 options : SIPProviderOptions ;
1717 children : ReactNode | JSX . Element ;
18+ mergedSessionManagerOptions ?: SessionManagerOptions ;
1819} ) : React . ReactNode => {
19- const { options, children } = props ;
20+ const { options, mergedSessionManagerOptions = { } , children } = props ;
2021 const refAudioRemote = useRef < HTMLAudioElement > ( null ) ;
22+ const refVideoRemote = useRef < HTMLVideoElement > ( null ) ;
2123
2224 const [ sessions , setSessions ] = useState < Record < string , Session > > ( { } ) ;
2325 const [ sessionTimer , setSessionTimer ] = useState < SessionTimer > ( { } ) ;
@@ -51,10 +53,15 @@ export const SIPProvider = (props: {
5153 media : {
5254 constraints : {
5355 audio : true ,
54- video : false ,
56+ video : true ,
5557 } ,
5658 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 ) ,
5865 } ,
5966 } ,
6067 delegate : {
@@ -123,6 +130,7 @@ export const SIPProvider = (props: {
123130 setStatus ( CONNECT_STATUS . DISCONNECTED ) ;
124131 } ,
125132 } ,
133+ ...mergedSessionManagerOptions ,
126134 } ) ;
127135 setSessionManager ( sessionManager ) ;
128136 sessionManager . connect ( ) ;
@@ -142,8 +150,8 @@ export const SIPProvider = (props: {
142150 >
143151 { children }
144152 </ ProviderContext . Provider >
145-
146153 < audio ref = { refAudioRemote } />
154+ < video ref = { refVideoRemote } />
147155 </ >
148156 ) ;
149157} ;
0 commit comments