Skip to content

Commit

Permalink
cosmetic changes part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Jun 13, 2024
1 parent f0d659d commit 5b60bac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
10 changes: 8 additions & 2 deletions src/Consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -12,10 +12,16 @@ export type ConsumerOptions<ConsumerAppData extends AppData = AppData> = {
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: [];
Expand Down
10 changes: 8 additions & 2 deletions src/Producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
RtpParameters,
RtpEncodingParameters,
} from './RtpParameters';
import { AppData, SenderCallback } from './types';
import { AppData } from './types';

const logger = new Logger('Producer');

Expand All @@ -19,10 +19,16 @@ export type ProducerOptions<ProducerAppData extends AppData = AppData> = {
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;
Expand Down
19 changes: 4 additions & 15 deletions src/handlers/HandlerInterface.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { EnhancedEventEmitter } from '../EnhancedEventEmitter';
import { ProducerCodecOptions } from '../Producer';
import {
IceParameters,
IceCandidate,
DtlsParameters,
IceGatheringState,
ConnectionState,
} from '../Transport';
import { ProducerCodecOptions, OnRtpSenderCallback } from '../Producer';
import { OnRtpReceiverCallback } from '../Consumer';
import {
RtpCapabilities,
RtpCodecCapability,
Expand Down Expand Up @@ -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 = {
Expand All @@ -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';
Expand All @@ -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 = {
Expand Down

0 comments on commit 5b60bac

Please sign in to comment.