async getNativeRtpCapabilities() { logger.debug('getNativeRtpCapabilities()'); const sdp = await this._channel.request('getRtpCapabilities'); const sdpObject = sdpTransform.parse(sdp); const caps = sdpCommonUtils.extractRtpCapabilities({ sdpObject }); return caps; }
/** * Expose Worker factory. */ async function createWorker({ logLevel = 'error' } = {}) { logger.debug('createWorker()'); const worker = new Worker_1.Worker({ logLevel }); return new Promise((resolve, reject) => { worker.on('@success', () => resolve(worker)); worker.on('@failure', reject); }); }
async stopSending(localId) { this._assertSendDirection(); logger.debug('stopSending() [localId:%s]', localId); // Remove the original track from our map and its events. const track = this._mapLocalIdTracks.get(localId); if (!track) throw new Error('associated track not found'); this._mapLocalIdTracks.delete(localId); // Remove the MID from the map. const mid = this._mapLocalIdMid.get(localId); if (!mid) throw new Error('associated MID not found'); this._mapLocalIdMid.delete(localId); await this._channel.request('handler.removeTrack', this._internal, { localId }); this._remoteSdp.disableMediaSection(mid); const offer = await this._channel.request('handler.createOffer', this._internal); logger.debug('stopSending() | calling handler.setLocalDescription() [offer:%o]', offer); await this._channel.request('handler.setLocalDescription', this._internal, offer); const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() }; logger.debug('stopSending() | calling handler.setRemoteDescription() [answer:%o]', answer); await this._channel.request('handler.setRemoteDescription', this._internal, answer); }
close() { logger.debug('close()'); if (this._closed) return; this._closed = true; // Deregister sending tracks events and emit 'ended' in remote tracks. for (const track of this._mapLocalIdTracks.values()) { if (track.data.remote) track.remoteStop(); } // Remove notification subscriptions. this._channel.removeAllListeners(this._internal.handlerId); // If running notify the worker. if (this._running) this._channel.notify('handler.close', this._internal); // Tell the parent. this.emit('@close'); }
/** * Create a mediasoup-client HandlerFactory. */ createHandlerFactory() { logger.debug('createHandlerFactory()'); return () => { const internal = { handlerId: uuid_1.v4() }; const handler = new Handler_1.Handler({ internal, channel: this._channel }); this._handlers.add(handler); handler.on('@close', () => this._handlers.delete(handler)); return handler; }; }
async getNativeSctpCapabilities(): Promise<SctpCapabilities> { logger.debug('getNativeSctpCapabilities()'); return { numStreams : SCTP_NUM_STREAMS }; }
/** * Create a AiortcMediaStream with audio/video tracks. */ async getUserMedia(constraints) { logger.debug('getUserMedia() [constraints:%o]', constraints); return media.getUserMedia(this._channel, constraints); }
/** * Create a mediasoup-client HandlerFactory. */ createHandlerFactory(): HandlerFactory { logger.debug('createHandlerFactory()'); return (): Handler => { const internal = { handlerId: uuidv4() }; const handler = new Handler( { internal, channel : this._channel }); this._handlers.add(handler); handler.on('@close', () => this._handlers.delete(handler)); return handler; }; }
async dump(): Promise<any> { logger.debug('dump()'); return this._channel.request('dump'); }
async getNativeSctpCapabilities() { logger.debug('getNativeSctpCapabilities()'); return { numStreams: SCTP_NUM_STREAMS }; }
async dump() { logger.debug('dump()'); return this._channel.request('dump'); }
async getNativeRtpCapabilities(): Promise<RtpCapabilities> { logger.debug('getNativeRtpCapabilities()'); const sdp = await this._channel.request('getRtpCapabilities'); const sdpObject = sdpTransform.parse(sdp); const caps = sdpCommonUtils.extractRtpCapabilities({ sdpObject }); return caps; }
/** * Create a AiortcMediaStream with audio/video tracks. */ async getUserMedia( constraints: media.AiortcMediaStreamConstraints ): Promise<AiortcMediaStream> { logger.debug('getUserMedia() [constraints:%o]', constraints); return media.getUserMedia(this._channel, constraints); }
/** * Expose Worker factory. */ export async function createWorker( { logLevel = 'error' }: WorkerSettings = {} ): Promise<Worker> { logger.debug('createWorker()'); const worker = new Worker({ logLevel }); return new Promise((resolve, reject) => { worker.on('@success', () => resolve(worker)); worker.on('@failure', reject); }); }
close(): void { logger.debug('close()'); if (this._closed) return; this._closed = true; // Deregister sending tracks events and emit 'ended' in remote tracks. for (const track of this._mapLocalIdTracks.values()) { if (track.data.remote) track.remoteStop(); } // Remove notification subscriptions. this._channel.removeAllListeners(this._internal.handlerId); // If running notify the worker. if (this._running) this._channel.notify('handler.close', this._internal); // Tell the parent. this.emit('@close'); }