From 5b60bac2e766f44f9427d8e9dce90c2e84b36321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 13 Jun 2024 10:46:38 +0200 Subject: [PATCH] cosmetic changes part 1 --- src/Consumer.ts | 10 ++++++++-- src/Producer.ts | 10 ++++++++-- src/handlers/HandlerInterface.ts | 19 ++++--------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Consumer.ts b/src/Consumer.ts index 227ffeba..76698d82 100644 --- a/src/Consumer.ts +++ b/src/Consumer.ts @@ -2,7 +2,7 @@ import { Logger } from './Logger'; import { EnhancedEventEmitter } from './EnhancedEventEmitter'; import { InvalidStateError } from './errors'; import { MediaKind, RtpParameters } from './RtpParameters'; -import { AppData, ReceiverCallback } from './types'; +import { AppData } from './types'; const logger = new Logger('Consumer'); @@ -12,10 +12,16 @@ export type ConsumerOptions = { kind?: 'audio' | 'video'; rtpParameters: RtpParameters; streamId?: string; - onRtpReceiver?: ReceiverCallback; + onRtpReceiver?: OnRtpReceiverCallback; appData?: ConsumerAppData; }; +/** + * Invoked synchronously immediately after a new RTCRtpReceiver is created. + * This allows for creating encoded streams in chromium browsers. + */ +export type OnRtpReceiverCallback = (rtpReceiver: RTCRtpReceiver) => void; + export type ConsumerEvents = { transportclose: []; trackended: []; diff --git a/src/Producer.ts b/src/Producer.ts index 962ac189..3e9e05c3 100644 --- a/src/Producer.ts +++ b/src/Producer.ts @@ -7,7 +7,7 @@ import { RtpParameters, RtpEncodingParameters, } from './RtpParameters'; -import { AppData, SenderCallback } from './types'; +import { AppData } from './types'; const logger = new Logger('Producer'); @@ -19,10 +19,16 @@ export type ProducerOptions = { stopTracks?: boolean; disableTrackOnPause?: boolean; zeroRtpOnPause?: boolean; - onRtpSender?: SenderCallback; + onRtpSender?: OnRtpSenderCallback; appData?: ProducerAppData; }; +/** + * Invoked synchronously immediately after a new RTCRtpSender is created. + * This allows for creating encoded streams in chromium browsers. + */ +export type OnRtpSenderCallback = (rtpSender: RTCRtpSender) => void; + // https://mediasoup.org/documentation/v3/mediasoup-client/api/#ProducerCodecOptions export type ProducerCodecOptions = { opusStereo?: boolean; diff --git a/src/handlers/HandlerInterface.ts b/src/handlers/HandlerInterface.ts index 62062f2b..db495435 100644 --- a/src/handlers/HandlerInterface.ts +++ b/src/handlers/HandlerInterface.ts @@ -1,5 +1,4 @@ import { EnhancedEventEmitter } from '../EnhancedEventEmitter'; -import { ProducerCodecOptions } from '../Producer'; import { IceParameters, IceCandidate, @@ -7,6 +6,8 @@ import { IceGatheringState, ConnectionState, } from '../Transport'; +import { ProducerCodecOptions, OnRtpSenderCallback } from '../Producer'; +import { OnRtpReceiverCallback } from '../Consumer'; import { RtpCapabilities, RtpCodecCapability, @@ -34,18 +35,12 @@ export type HandlerRunOptions = { extendedRtpCapabilities: any; }; -/* - * Invoked synchronously immediately after a new RTCRtpSender is created. - * This allows for creating encoded streams in chromium browsers. - */ -export type SenderCallback = (sender: RTCRtpSender) => void; - export type HandlerSendOptions = { track: MediaStreamTrack; encodings?: RtpEncodingParameters[]; codecOptions?: ProducerCodecOptions; codec?: RtpCodecCapability; - onRtpSender?: SenderCallback; + onRtpSender?: OnRtpSenderCallback; }; export type HandlerSendResult = { @@ -54,12 +49,6 @@ export type HandlerSendResult = { rtpSender?: RTCRtpSender; }; -/* - * Invoked synchronously immediately after a new RTCRtpReceiver is created. - * This allows for creating encoded streams in chromium browsers. - */ -export type ReceiverCallback = (receiver: RTCRtpReceiver) => void; - export type HandlerReceiveOptions = { trackId: string; kind: 'audio' | 'video'; @@ -71,7 +60,7 @@ export type HandlerReceiveOptions = { * can just synchronize up to one audio stream with one video stream. */ streamId?: string; - onRtpReceiver?: ReceiverCallback; + onRtpReceiver?: OnRtpReceiverCallback; }; export type HandlerReceiveResult = {