import debugModule from "debug" ; import { Router , WebRtcTransport } from "mediasoup/lib/types" ; import { VoiceSendDirection } from "src/types" ; import { config } from "../config" ; const log = debugModule ( "shawarma:create-transport" ) ; export const transportToOptions = ( { id , iceParameters , iceCandidates , dtlsParameters , } ) => ( { id , iceParameters , iceCandidates , dtlsParameters } ) ; export type TransportOptions = ReturnType < typeof transportToOptions > ; export const createTransport = async ( direction , router , peerId ) => { log ( "create-transport" , direction ) ; const { listenIps , initialAvailableOutgoingBitrate , } = config . mediasoup . webRtcTransport ; const transport = await router . createWebRtcTransport ( { listenIps : listenIps , enableUdp : true , enableTcp : true , preferUdp : true , initialAvailableOutgoingBitrate : initialAvailableOutgoingBitrate , appData : { peerId , clientDirection : direction } , } ) ; return transport ; } ;