UNPKG

mediasfu-reactnative-expo

Version:

mediasfu-reactnative-expo – Expo-managed React Native WebRTC SDK for video conferencing, webinars, live streaming, broadcast, screen sharing, whiteboard, chat, recording, live subtitles, translation, and AI agent rooms on iOS, Android, and web. Prebuilt r

72 lines 4.33 kB
import { connectSendTransportVideo as sharedConnectSendTransportVideo } from 'mediasfu-shared'; const connectLocalSendTransportVideo = async ({ videoParams, parameters, }) => { try { let { localVideoProducer, localProducerTransport, updateLocalVideoProducer, updateLocalProducerTransport, } = parameters; // Produce local video data if transport exists if (localProducerTransport) { localVideoProducer = await localProducerTransport.produce(videoParams); // Update local producer and transport updateLocalVideoProducer?.(localVideoProducer); updateLocalProducerTransport?.(localProducerTransport); } } catch (error) { console.error('Error connecting local video transport:', error); throw error; // Re-throw to propagate the error } }; /** * Connects the send transport for video by producing video data and updates the relevant states. * * This function supports both a primary and a local video producer, delegating local handling to a separate function. * * @param {ConnectSendTransportVideoOptions} options - The options for connecting the send transport for video. * @param {ProducerOptions} options.videoParams - The parameters for the video producer. * @param {'all' | 'local' | 'remote'} [options.targetOption] - The target option for the video transport connection. * @param {ConnectSendTransportVideoParameters} options.parameters - The parameters for the video transport connection. * @param {Producer | null} options.parameters.videoProducer - The primary video producer. * @param {Producer | null} [options.parameters.localVideoProducer] - The local video producer. * @param {Device | null} options.parameters.device - The device information. * @param {Transport | null} options.parameters.producerTransport - The primary producer transport. * @param {Transport | null} [options.parameters.localProducerTransport] - The local producer transport. * @param {string} options.parameters.islevel - The connection level for the video transport. * @param {boolean} options.parameters.updateMainWindow - The flag to update the main window state. * @param {(producer: Producer | null) => void} options.parameters.updateVideoProducer - The function to update the video producer state. * @param {(localProducer: Producer | null) => void} [options.parameters.updateLocalVideoProducer] - The function to update the local video producer state. * @param {(transport: Transport | null) => void} options.parameters.updateProducerTransport - The function to update the producer transport state. * @param {(localTransport: Transport | null) => void} [options.parameters.updateLocalProducerTransport] - The function to update the local producer transport state. * @param {(state: boolean) => void} options.parameters.updateUpdateMainWindow - The function to update the main window state. * @param {any} [options.parameters] - Additional parameters for future use. * @returns {Promise<void>} A promise that resolves when the send transport for video is connected. * * @throws Will throw an error if the connection fails. * * @example * const options = { * videoParams: { * // video producer options (e.g., codec, bitrate) * }, * targetOption: 'all', * parameters: { * videoProducer: null, * localVideoProducer: null, * producerTransport: transport, * localProducerTransport: localTransport, * islevel: '2', * updateMainWindow: false, * updateVideoProducer: (producer) => console.log('Updated producer'), * updateLocalVideoProducer: (localProducer) => console.log('Updated local producer'), * updateProducerTransport: (transport) => console.log('Updated transport'), * updateLocalProducerTransport: (localTransport) => console.log('Updated local transport'), * updateUpdateMainWindow: (state) => console.log('Updated main window:', state), * }, * }; * * connectSendTransportVideo(options) * .then(() => console.log('Video transport connected successfully')) * .catch((error) => console.error('Error connecting video transport:', error)); */ export const connectSendTransportVideo = async (options) => { await sharedConnectSendTransportVideo(options); }; //# sourceMappingURL=connectSendTransportVideo.js.map