Skip to content

Commit

Permalink
split RtpParameters.ts into rtpParametersTypes.ts and rtpParametersFb…
Browse files Browse the repository at this point in the history
…sUtils.ts and same for SCTP and SRTP files
  • Loading branch information
ibc committed Nov 8, 2024
1 parent 90b2265 commit fd1f37f
Show file tree
Hide file tree
Showing 34 changed files with 685 additions and 695 deletions.
4 changes: 2 additions & 2 deletions node/src/AudioLevelObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { RtpObserver } from './RtpObserverTypes';
import { RtpObserverImpl, RtpObserverConstructorOptions } from './RtpObserver';
import { Producer } from './ProducerTypes';
import { AppData } from './types';
import * as utils from './utils';
import * as fbsUtils from './fbsUtils';
import { Event, Notification } from './fbs/notification';
import * as FbsAudioLevelObserver from './fbs/audio-level-observer';

Expand Down Expand Up @@ -66,7 +66,7 @@ export class AudioLevelObserverImpl<

// Get the corresponding Producer instance and remove entries with
// no Producer (it may have been closed in the meanwhile).
const volumes: AudioLevelObserverVolume[] = utils
const volumes: AudioLevelObserverVolume[] = fbsUtils
.parseVector(notification, 'volumes', parseVolume)
.map(
({
Expand Down
17 changes: 8 additions & 9 deletions node/src/Consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ import {
import { Channel } from './Channel';
import { TransportInternal } from './Transport';
import { ProducerStat } from './ProducerTypes';
import { MediaKind, RtpParameters } from './rtpParametersTypes';
import {
MediaKind,
RtpParameters,
parseRtpEncodingParameters,
parseRtpParameters,
} from './RtpParameters';
} from './rtpParametersFbsUtils';
import { parseRtpStreamStats } from './RtpStream';
import { AppData } from './types';
import * as utils from './utils';
import * as fbsUtils from './fbsUtils';
import { Event, Notification } from './fbs/notification';
import { TraceDirection as FbsTraceDirection } from './fbs/common';
import * as FbsRequest from './fbs/request';
Expand Down Expand Up @@ -765,18 +764,18 @@ function parseBaseConsumerDump(
rtpParameters: parseRtpParameters(data.rtpParameters()!),
consumableRtpEncodings:
data.consumableRtpEncodingsLength() > 0
? utils.parseVector(
? fbsUtils.parseVector(
data,
'consumableRtpEncodings',
parseRtpEncodingParameters
)
: undefined,
traceEventTypes: utils.parseVector(
traceEventTypes: fbsUtils.parseVector(
data,
'traceEventTypes',
consumerTraceEventTypeFromFbs
),
supportedCodecPayloadTypes: utils.parseVector(
supportedCodecPayloadTypes: fbsUtils.parseVector(
data,
'supportedCodecPayloadTypes'
),
Expand Down Expand Up @@ -830,7 +829,7 @@ function parsePipeConsumerDump(
data: FbsConsumer.ConsumerDump
): PipeConsumerDump {
const base = parseBaseConsumerDump(data.base()!);
const rtpStreams = utils.parseVector(data, 'rtpStreams', parseRtpStream);
const rtpStreams = fbsUtils.parseVector(data, 'rtpStreams', parseRtpStream);

return {
...base,
Expand Down Expand Up @@ -886,5 +885,5 @@ function parseConsumerDumpResponse(
function parseConsumerStats(
binary: FbsConsumer.GetStatsResponse
): (ConsumerStat | ProducerStat)[] {
return utils.parseVector(binary, 'stats', parseRtpStreamStats);
return fbsUtils.parseVector(binary, 'stats', parseRtpStreamStats);
}
2 changes: 1 addition & 1 deletion node/src/ConsumerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
RtpCapabilities,
RtpEncodingParameters,
RtpParameters,
} from './RtpParameters';
} from './rtpParametersTypes';
import { RtpStreamSendStats } from './RtpStream';
import { AppData } from './types';

Expand Down
16 changes: 7 additions & 9 deletions node/src/DataConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import {
} from './DataConsumerTypes';
import { Channel } from './Channel';
import { TransportInternal } from './Transport';
import {
SctpStreamParameters,
parseSctpStreamParameters,
} from './SctpParameters';
import { SctpStreamParameters } from './sctpParametersTypes';
import { parseSctpStreamParameters } from './sctpParametersFbsUtils';
import { AppData } from './types';
import * as utils from './utils';
import * as fbsUtils from './fbsUtils';
import { Event, Notification } from './fbs/notification';
import * as FbsTransport from './fbs/transport';
import * as FbsRequest from './fbs/request';
Expand Down Expand Up @@ -399,7 +397,7 @@ export class DataConsumerImpl<DataConsumerAppData extends AppData = AppData>
response.body(data);

// Update subchannels.
this.#subchannels = utils.parseVector(data, 'subchannels');
this.#subchannels = fbsUtils.parseVector(data, 'subchannels');
}

async addSubchannel(subchannel: number): Promise<void> {
Expand All @@ -425,7 +423,7 @@ export class DataConsumerImpl<DataConsumerAppData extends AppData = AppData>
response.body(data);

// Update subchannels.
this.#subchannels = utils.parseVector(data, 'subchannels');
this.#subchannels = fbsUtils.parseVector(data, 'subchannels');
}

async removeSubchannel(subchannel: number): Promise<void> {
Expand All @@ -451,7 +449,7 @@ export class DataConsumerImpl<DataConsumerAppData extends AppData = AppData>
response.body(data);

// Update subchannels.
this.#subchannels = utils.parseVector(data, 'subchannels');
this.#subchannels = fbsUtils.parseVector(data, 'subchannels');
}

private handleWorkerNotifications(): void {
Expand Down Expand Up @@ -606,7 +604,7 @@ export function parseDataConsumerDumpResponse(
bufferedAmountLowThreshold: data.bufferedAmountLowThreshold(),
paused: data.paused(),
dataProducerPaused: data.dataProducerPaused(),
subchannels: utils.parseVector(data, 'subchannels'),
subchannels: fbsUtils.parseVector(data, 'subchannels'),
};
}

Expand Down
2 changes: 1 addition & 1 deletion node/src/DataConsumerTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnhancedEventEmitter } from './enhancedEvents';
import { SctpStreamParameters } from './SctpParameters';
import { SctpStreamParameters } from './sctpParametersTypes';
import { AppData } from './types';

export type DataConsumerOptions<DataConsumerAppData extends AppData = AppData> =
Expand Down
6 changes: 2 additions & 4 deletions node/src/DataProducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
} from './DataProducerTypes';
import { Channel } from './Channel';
import { TransportInternal } from './Transport';
import {
SctpStreamParameters,
parseSctpStreamParameters,
} from './SctpParameters';
import { SctpStreamParameters } from './sctpParametersTypes';
import { parseSctpStreamParameters } from './sctpParametersFbsUtils';
import { AppData } from './types';
import * as FbsTransport from './fbs/transport';
import * as FbsNotification from './fbs/notification';
Expand Down
2 changes: 1 addition & 1 deletion node/src/DataProducerTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnhancedEventEmitter } from './enhancedEvents';
import { SctpStreamParameters } from './SctpParameters';
import { SctpStreamParameters } from './sctpParametersTypes';
import { AppData } from './types';

export type DataProducerOptions<DataProducerAppData extends AppData = AppData> =
Expand Down
2 changes: 1 addition & 1 deletion node/src/DirectTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
parseBaseTransportStats,
parseTransportTraceEventData,
} from './Transport';
import { SctpParameters } from './SctpParameters';
import { SctpParameters } from './sctpParametersTypes';
import { AppData } from './types';
import { UnsupportedError } from './errors';
import { Event, Notification } from './fbs/notification';
Expand Down
10 changes: 5 additions & 5 deletions node/src/PipeTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ import {
import { Producer } from './ProducerTypes';
import { Consumer, ConsumerType } from './ConsumerTypes';
import { ConsumerImpl } from './Consumer';
import { RtpParameters } from './rtpParametersTypes';
import {
RtpParameters,
serializeRtpEncodingParameters,
serializeRtpParameters,
} from './RtpParameters';
import { SctpParameters } from './SctpParameters';
} from './rtpParametersFbsUtils';
import { SctpParameters } from './sctpParametersTypes';
import { SrtpParameters } from './srtpParametersTypes';
import {
parseSrtpParameters,
serializeSrtpParameters,
SrtpParameters,
} from './SrtpParameters';
} from './srtpParametersFbsUtils';
import { AppData } from './types';
import { generateUUIDv4 } from './utils';
import { MediaKind as FbsMediaKind } from './fbs/rtp-parameters/media-kind';
Expand Down
4 changes: 2 additions & 2 deletions node/src/PipeTransportTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
TransportObserverEvents,
} from './TransportTypes';
import { Consumer } from './ConsumerTypes';
import { SrtpParameters } from './SrtpParameters';
import { SctpParameters, NumSctpStreams } from './SctpParameters';
import { SrtpParameters } from './srtpParametersTypes';
import { SctpParameters, NumSctpStreams } from './sctpParametersTypes';
import { Either, AppData } from './types';

export type PipeTransportOptions<
Expand Down
6 changes: 3 additions & 3 deletions node/src/PlainTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import {
parseBaseTransportStats,
parseTransportTraceEventData,
} from './Transport';
import { SctpParameters } from './SctpParameters';
import { SctpParameters } from './sctpParametersTypes';
import { SrtpParameters } from './srtpParametersTypes';
import {
parseSrtpParameters,
serializeSrtpParameters,
SrtpParameters,
} from './SrtpParameters';
} from './srtpParametersFbsUtils';
import { AppData } from './types';
import { Event, Notification } from './fbs/notification';
import * as FbsRequest from './fbs/request';
Expand Down
4 changes: 2 additions & 2 deletions node/src/PlainTransportTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
TransportEvents,
TransportObserverEvents,
} from './TransportTypes';
import { SrtpParameters, SrtpCryptoSuite } from './SrtpParameters';
import { SctpParameters, NumSctpStreams } from './SctpParameters';
import { SrtpParameters, SrtpCryptoSuite } from './srtpParametersTypes';
import { SctpParameters, NumSctpStreams } from './sctpParametersTypes';
import { Either, AppData } from './types';

export type PlainTransportOptions<
Expand Down
15 changes: 8 additions & 7 deletions node/src/Producer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import {
} from './ProducerTypes';
import { Channel } from './Channel';
import { TransportInternal } from './Transport';
import { MediaKind, RtpParameters, parseRtpParameters } from './RtpParameters';
import { Event, Notification } from './fbs/notification';
import { MediaKind, RtpParameters } from './rtpParametersTypes';
import { parseRtpParameters } from './rtpParametersFbsUtils';
import { parseRtpStreamRecvStats } from './RtpStream';
import { AppData } from './types';
import * as utils from './utils';
import * as fbsUtils from './fbsUtils';
import { Event, Notification } from './fbs/notification';
import { TraceDirection as FbsTraceDirection } from './fbs/common';
import * as FbsNotification from './fbs/notification';
import * as FbsRequest from './fbs/request';
Expand Down Expand Up @@ -340,7 +341,7 @@ export class ProducerImpl<ProducerAppData extends AppData = AppData>

data!.body(notification);

const score: ProducerScore[] = utils.parseVector(
const score: ProducerScore[] = fbsUtils.parseVector(
notification,
'scores',
parseProducerScore
Expand Down Expand Up @@ -517,11 +518,11 @@ export function parseProducerDump(
// TODO: Make flatbuffers TS return undefined instead of null.
rtpStreams:
data.rtpStreamsLength() > 0
? utils.parseVector(data, 'rtpStreams', (rtpStream: any) =>
? fbsUtils.parseVector(data, 'rtpStreams', (rtpStream: any) =>
rtpStream.unpack()
)
: undefined,
traceEventTypes: utils.parseVector<ProducerTraceEventType>(
traceEventTypes: fbsUtils.parseVector<ProducerTraceEventType>(
data,
'traceEventTypes',
producerTraceEventTypeFromFbs
Expand All @@ -533,7 +534,7 @@ export function parseProducerDump(
function parseProducerStats(
binary: FbsProducer.GetStatsResponse
): ProducerStat[] {
return utils.parseVector(binary, 'stats', parseRtpStreamRecvStats);
return fbsUtils.parseVector(binary, 'stats', parseRtpStreamRecvStats);
}

function parseProducerScore(binary: FbsProducer.Score): ProducerScore {
Expand Down
2 changes: 1 addition & 1 deletion node/src/ProducerTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnhancedEventEmitter } from './enhancedEvents';
import { MediaKind, RtpParameters } from './RtpParameters';
import { MediaKind, RtpParameters } from './rtpParametersTypes';
import { RtpStreamRecvStats } from './RtpStream';
import { AppData } from './types';

Expand Down
Loading

0 comments on commit fd1f37f

Please sign in to comment.