Skip to content

Commit

Permalink
fix: now properly shown as speaker and listeners can also hear it
Browse files Browse the repository at this point in the history
  • Loading branch information
slkzgm committed Jan 4, 2025
1 parent 5a93361 commit deeb29c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 484 deletions.
1 change: 1 addition & 0 deletions src/_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type { Tweet } from './tweets';

export { Space } from './spaces/core/Space'
export { SpaceParticipant } from './spaces/core/SpaceParticipant'
export { Logger } from './spaces/logger'
export { SttTtsPlugin } from './spaces/plugins/SttTtsPlugin'
export { RecordToDiskPlugin } from './spaces/plugins/RecordToDiskPlugin'
export { MonitorAudioPlugin } from './spaces/plugins/MonitorAudioPlugin'
Expand Down
8 changes: 4 additions & 4 deletions src/spaces/core/JanusClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class JanusClient extends EventEmitter {
* 4) configure local PeerConnection
* 5) subscribe to any existing publishers
*/
public async initializeGuestSpeaker(): Promise<void> {
public async initializeGuestSpeaker(sessionUUID: string): Promise<void> {
this.logger.debug('[JanusClient] initializeGuestSpeaker() called');

// 1) Create a new Janus session
Expand Down Expand Up @@ -197,7 +197,7 @@ export class JanusClient extends EventEmitter {
this.enableLocalAudio();

// 4) configurePublisher => generate offer, wait for answer
await this.configurePublisher();
await this.configurePublisher(sessionUUID);

// 5) Subscribe to each existing publisher
await Promise.all(
Expand Down Expand Up @@ -569,7 +569,7 @@ export class JanusClient extends EventEmitter {
* Creates an SDP offer and sends "configure" to Janus with it.
* Used by both host and guest after attach + join.
*/
private async configurePublisher(): Promise<void> {
private async configurePublisher(sessionUUID: string = ''): Promise<void> {
if (!this.pc || !this.sessionId || !this.handleId) {
return;
}
Expand All @@ -588,7 +588,7 @@ export class JanusClient extends EventEmitter {
request: 'configure',
room: this.config.roomId,
periscope_user_id: this.config.userId,
session_uuid: '',
session_uuid: sessionUUID,
stream_name: this.config.streamName,
vidman_token: this.config.credential,
},
Expand Down
7 changes: 1 addition & 6 deletions src/spaces/core/SpaceParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class SpaceParticipant extends EventEmitter {
});

// 4) Initialize the guest speaker session in Janus
await this.janusClient.initializeGuestSpeaker();
await this.janusClient.initializeGuestSpeaker(this.sessionUUID);

this.janusClient.on('audioDataFromSpeaker', (data: AudioDataWithUser) => {
this.logger.debug(
Expand All @@ -271,11 +271,6 @@ export class SpaceParticipant extends EventEmitter {
this.handleAudioData(data);
});

// Optionally, if a plugin wants direct Janus references, call plugin.onJanusReady(...) here
// for (const { plugin } of this.plugins) {
// plugin.onJanusReady?.(this.janusClient);
// }

this.logger.info(
'[SpaceParticipant] Now speaker on the Space =>',
this.spaceId,
Expand Down
Loading

0 comments on commit deeb29c

Please sign in to comment.