Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to populate an offline room with simulated participants #531

Merged
merged 10 commits into from
Dec 9, 2022
Prev Previous commit
Next Next commit
also publish local audio
  • Loading branch information
lukasIO committed Dec 7, 2022
commit e4cb611138b35b3decdf7c9a7d5a58c6c2ed063a
16 changes: 15 additions & 1 deletion src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
count: number,
options: { audio?: boolean; video?: boolean; aspectRatios: Array<number> },
) {
this.name = 'sim-room';
this.localParticipant.identity = 'simulated-local';
this.localParticipant
.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged)
.on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted)
Expand Down Expand Up @@ -1289,7 +1291,19 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
);
// @ts-ignore
this.localParticipant.addTrackPublication(pub);
this.localParticipant.emit(ParticipantEvent.LocalTrackPublished, pub);
const audioPub = new LocalTrackPublication(
Track.Kind.Audio,
TrackInfo.fromPartial({
source: TrackSource.MICROPHONE,
sid: Math.floor(Math.random() * 10_000).toString(),
type: TrackType.AUDIO,
name: 'video-dummy',
}),
new LocalAudioTrack(getEmptyAudioStreamTrack()),
);
// @ts-ignore
this.localParticipant.addTrackPublication(audioPub);
this.localParticipant.emit(ParticipantEvent.LocalTrackPublished, audioPub);

for (let i = 0; i < count - 1; i += 1) {
let info: ParticipantInfo = ParticipantInfo.fromPartial({
Expand Down