Skip to content

Commit

Permalink
done AFAIS
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Nov 8, 2024
1 parent 0a203d0 commit eff296c
Show file tree
Hide file tree
Showing 29 changed files with 583 additions and 775 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### NEXT

- Node: Add TypeScript interfaces for all exported classes ([PR #1463](https://github.com/versatica/mediasoup/pull/1463)).

### 3.14.16

- `SimulcastConsumer`: Fix cannot switch layers if initial `tsReferenceSpatialLayer disappears` disappears ([PR #1459](https://github.com/versatica/mediasoup/pull/1459) by @Lynnworld).
Expand Down
5 changes: 5 additions & 0 deletions node/src/ActiveSpeakerObserverTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ export interface ActiveSpeakerObserverInterface<
ActiveSpeakerObserverEvents,
ActiveSpeakerObserverObserver
> {
/**
* Observer.
*
* @override
*/
get observer(): ActiveSpeakerObserverObserver;
}
5 changes: 5 additions & 0 deletions node/src/AudioLevelObserverTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,10 @@ export interface AudioLevelObserverInterface<
AudioLevelObserverEvents,
AudioLevelObserverObserver
> {
/**
* Observer.
*
* @override
*/
get observer(): AudioLevelObserverObserver;
}
86 changes: 2 additions & 84 deletions node/src/Consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
readonly #observer: ConsumerObserver =
new EnhancedEventEmitter<ConsumerObserverEvents>();

/**
* @private
*/
constructor({
internal,
data,
Expand Down Expand Up @@ -137,122 +134,75 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
this.handleWorkerNotifications();
}

/**
* Consumer id.
*/
get id(): string {
return this.#internal.consumerId;
}

/**
* Associated Producer id.
*/
get producerId(): string {
return this.#data.producerId;
}

/**
* Whether the Consumer is closed.
*/
get closed(): boolean {
return this.#closed;
}

/**
* Media kind.
*/
get kind(): MediaKind {
return this.#data.kind;
}

/**
* RTP parameters.
*/
get rtpParameters(): RtpParameters {
return this.#data.rtpParameters;
}

/**
* Consumer type.
*/
get type(): ConsumerType {
return this.#data.type;
}

/**
* Whether the Consumer is paused.
*/
get paused(): boolean {
return this.#paused;
}

/**
* Whether the associate Producer is paused.
*/
get producerPaused(): boolean {
return this.#producerPaused;
}

/**
* Current priority.
*/
get priority(): number {
return this.#priority;
}

/**
* Consumer score.
*/
get score(): ConsumerScore {
return this.#score;
}

/**
* Preferred video layers.
*/
get preferredLayers(): ConsumerLayers | undefined {
return this.#preferredLayers;
}

/**
* Current video layers.
*/
get currentLayers(): ConsumerLayers | undefined {
return this.#currentLayers;
}

/**
* App custom data.
*/
get appData(): ConsumerAppData {
return this.#appData;
}

/**
* App custom data setter.
*/
set appData(appData: ConsumerAppData) {
this.#appData = appData;
}

/**
* Observer.
*/
get observer(): ConsumerObserver {
return this.#observer;
}

/**
* @private
* Just for testing purposes.
*
* @private
*/
get channelForTesting(): Channel {
return this.#channel;
}

/**
* Close the Consumer.
*/
close(): void {
if (this.#closed) {
return;
Expand Down Expand Up @@ -285,11 +235,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
this.#observer.safeEmit('close');
}

/**
* Transport was closed.
*
* @private
*/
transportClosed(): void {
if (this.#closed) {
return;
Expand All @@ -308,9 +253,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
this.#observer.safeEmit('close');
}

/**
* Dump Consumer.
*/
async dump(): Promise<ConsumerDump> {
logger.debug('dump()');

Expand All @@ -329,9 +271,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
return parseConsumerDumpResponse(data);
}

/**
* Get Consumer stats.
*/
async getStats(): Promise<(ConsumerStat | ProducerStat)[]> {
logger.debug('getStats()');

Expand All @@ -350,9 +289,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
return parseConsumerStats(data);
}

/**
* Pause the Consumer.
*/
async pause(): Promise<void> {
logger.debug('pause()');

Expand All @@ -373,9 +309,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
}
}

/**
* Resume the Consumer.
*/
async resume(): Promise<void> {
logger.debug('resume()');

Expand All @@ -396,9 +329,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
}
}

/**
* Set preferred video layers.
*/
async setPreferredLayers({
spatialLayer,
temporalLayer,
Expand Down Expand Up @@ -453,9 +383,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
this.#preferredLayers = preferredLayers;
}

/**
* Set priority.
*/
async setPriority(priority: number): Promise<void> {
logger.debug('setPriority()');

Expand Down Expand Up @@ -485,18 +412,12 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
this.#priority = status.priority;
}

/**
* Unset priority.
*/
async unsetPriority(): Promise<void> {
logger.debug('unsetPriority()');

await this.setPriority(1);
}

/**
* Request a key frame to the Producer.
*/
async requestKeyFrame(): Promise<void> {
logger.debug('requestKeyFrame()');

Expand All @@ -508,9 +429,6 @@ export class ConsumerImpl<ConsumerAppData extends AppData = AppData>
);
}

/**
* Enable 'trace' event.
*/
async enableTraceEvent(types: ConsumerTraceEventType[] = []): Promise<void> {
logger.debug('enableTraceEvent()');

Expand Down
Loading

0 comments on commit eff296c

Please sign in to comment.