import { RTCPeerConnection , mediaDevices , MediaStream , } from 'react-native-webrtc' ; import { objEmpty } from '../helpers' ; import logger from '../logger' ; const _RTCPeerConnection = ( config ) => { const _config = objEmpty ( config ) ? null : config ; logger . info ( '_RTCPeerConnection' , _config ) ; return new RTCPeerConnection ( _config ) ; } ; const _getUserMedia = ( constraints ) => mediaDevices . getUserMedia ( constraints ) ; const _enumerateDevices = ( ) => mediaDevices . enumerateDevices ( ) ; const streamIsValid = ( stream ) => stream && stream instanceof MediaStream ; const getSupportedConstraints = ( ) => ( { } ) ; const attachMediaStream = ( htmlElementId , stream ) => null ; const detachMediaStream = ( htmlElementId ) => null ; const muteMediaElement = ( htmlElementId ) => null ; const unmuteMediaElement = ( htmlElementId ) => null ; const toggleMuteMediaElement = ( htmlElementId ) => null ; const setMediaElementSinkId = ( htmlElementId , deviceId ) : Promise < boolean > => Promise . resolve ( false ) ; const sdpToJsonHack = ( sdp ) => { Object . defineProperty ( sdp , 'toJSON' , { value : ( ) => sdp } ) ; return sdp ; } ; const stopStream = ( stream ) => { if ( streamIsValid ( stream ) ) { stream . getTracks ( ) . forEach ( ( t ) => t . stop ( ) ) ; } stream = null ; } ; export { _RTCPeerConnection as RTCPeerConnection , _getUserMedia as getUserMedia , _getUserMedia as getDisplayMedia , _enumerateDevices as enumerateDevices , getSupportedConstraints , streamIsValid , attachMediaStream , detachMediaStream , sdpToJsonHack , stopStream , muteMediaElement , unmuteMediaElement , toggleMuteMediaElement , setMediaElementSinkId , } ;