-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript interfaces for all exported classes
## Details - `mediasoup.types` namespace no longer exports `Worker`, `Router`, `Producer`, etc classes in `types` but instead it exports `WorkerInterface`, `RouterInterface`, `ProducerInterface`, etc. - NOTE: This is a breaking change somehow, but just at TS level. - Use the new interfaces everywhere. - This makes it easier for applications to create mediasoup mocks. ## TODO - How to export as interface/types the functions and consts exposed by `index.ts` such as `createWorker()`, `setLogEventListeners()`, `getSupportedRtpCapabilities()`, `observer`, etc? - In the future we may want to move those interfaces/types to another separate package so a Node application that only depends on mediasoup types doesn't need to install mediaosup. Even if we don't do that, we should change things so `types.ts` doesn't export **anything** that depends on compiled FBS types.
- Loading branch information
Showing
47 changed files
with
3,308 additions
and
2,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { EnhancedEventEmitter } from './enhancedEvents'; | ||
import { | ||
RtpObserverInterface, | ||
RtpObserverEvents, | ||
RtpObserverObserverEvents, | ||
} from './RtpObserverInterface'; | ||
import { ProducerInterface } from './ProducerInterface'; | ||
import { AppData } from './types'; | ||
|
||
export type ActiveSpeakerObserverOptions< | ||
ActiveSpeakerObserverAppData extends AppData = AppData, | ||
> = { | ||
interval?: number; | ||
|
||
/** | ||
* Custom application data. | ||
*/ | ||
appData?: ActiveSpeakerObserverAppData; | ||
}; | ||
|
||
export type ActiveSpeakerObserverDominantSpeaker = { | ||
/** | ||
* The audio Producer instance. | ||
*/ | ||
producer: ProducerInterface; | ||
}; | ||
|
||
export type ActiveSpeakerObserverEvents = RtpObserverEvents & { | ||
dominantspeaker: [ActiveSpeakerObserverDominantSpeaker]; | ||
}; | ||
|
||
export type ActiveSpeakerObserverObserver = | ||
EnhancedEventEmitter<ActiveSpeakerObserverObserverEvents>; | ||
|
||
export type ActiveSpeakerObserverObserverEvents = RtpObserverObserverEvents & { | ||
dominantspeaker: [ActiveSpeakerObserverDominantSpeaker]; | ||
}; | ||
|
||
export interface ActiveSpeakerObserverInterface< | ||
ActiveSpeakerObserverAppData extends AppData = AppData, | ||
> extends RtpObserverInterface< | ||
ActiveSpeakerObserverAppData, | ||
ActiveSpeakerObserverEvents, | ||
ActiveSpeakerObserverObserver | ||
> { | ||
get observer(): ActiveSpeakerObserverObserver; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { EnhancedEventEmitter } from './enhancedEvents'; | ||
import { | ||
RtpObserverInterface, | ||
RtpObserverEvents, | ||
RtpObserverObserverEvents, | ||
} from './RtpObserverInterface'; | ||
import { ProducerInterface } from './ProducerInterface'; | ||
import { AppData } from './types'; | ||
|
||
export type AudioLevelObserverOptions< | ||
AudioLevelObserverAppData extends AppData = AppData, | ||
> = { | ||
/** | ||
* Maximum number of entries in the 'volumes”' event. Default 1. | ||
*/ | ||
maxEntries?: number; | ||
|
||
/** | ||
* Minimum average volume (in dBvo from -127 to 0) for entries in the | ||
* 'volumes' event. Default -80. | ||
*/ | ||
threshold?: number; | ||
|
||
/** | ||
* Interval in ms for checking audio volumes. Default 1000. | ||
*/ | ||
interval?: number; | ||
|
||
/** | ||
* Custom application data. | ||
*/ | ||
appData?: AudioLevelObserverAppData; | ||
}; | ||
|
||
export type AudioLevelObserverVolume = { | ||
/** | ||
* The audio Producer instance. | ||
*/ | ||
producer: ProducerInterface; | ||
|
||
/** | ||
* The average volume (in dBvo from -127 to 0) of the audio Producer in the | ||
* last interval. | ||
*/ | ||
volume: number; | ||
}; | ||
|
||
export type AudioLevelObserverEvents = RtpObserverEvents & { | ||
volumes: [AudioLevelObserverVolume[]]; | ||
silence: []; | ||
}; | ||
|
||
export type AudioLevelObserverObserver = | ||
EnhancedEventEmitter<AudioLevelObserverObserverEvents>; | ||
|
||
export type AudioLevelObserverObserverEvents = RtpObserverObserverEvents & { | ||
volumes: [AudioLevelObserverVolume[]]; | ||
silence: []; | ||
}; | ||
|
||
export interface AudioLevelObserverInterface< | ||
AudioLevelObserverAppData extends AppData = AppData, | ||
> extends RtpObserverInterface< | ||
AudioLevelObserverAppData, | ||
AudioLevelObserverEvents, | ||
AudioLevelObserverObserver | ||
> { | ||
get observer(): AudioLevelObserverObserver; | ||
} |
Oops, something went wrong.