Skip to content

Commit

Permalink
feat: re-apply plugins on migration
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 committed Aug 1, 2024
1 parent 8e0dd7d commit 2a64652
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,21 @@ export class HMSLocalAudioTrack extends HMSAudioTrack {
}

clone(stream?: HMSLocalStream) {
return new HMSLocalAudioTrack(
const track = new HMSLocalAudioTrack(
stream || (this.stream as HMSLocalStream).clone(),
this.nativeTrack.clone(),
this.source!,
this.eventBus,
this.settings,
this.room,
);

if (this.pluginsManager.pluginsMap.size > 0) {
this.pluginsManager.pluginsMap.forEach(value => {
track.addPlugin(value);
});
}
return track;
}

getManuallySelectedDeviceId() {
Expand Down
11 changes: 10 additions & 1 deletion packages/hms-video-store/src/media/tracks/HMSLocalVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,23 @@ export class HMSLocalVideoTrack extends HMSVideoTrack {
}

clone(stream?: HMSLocalStream) {
return new HMSLocalVideoTrack(
const track = new HMSLocalVideoTrack(
stream || (this.stream as HMSLocalStream).clone(),
this.nativeTrack.clone(),
this.source!,
this.eventBus,
this.settings,
this.room,
);
if (this.pluginsManager.pluginsMap.size > 0) {
this.pluginsManager.pluginsMap.forEach(value => {
track.addPlugin(value);
});
}
if (this.mediaStreamPluginsManager.plugins.size > 0) {
track.addStreamPlugins(Array.from(this.mediaStreamPluginsManager.plugins));
}
return track;
}

/** @internal */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class HMSAudioPluginsManager {
private readonly TAG = '[AudioPluginsManager]';
private readonly hmsTrack: HMSLocalAudioTrack;
// Map maintains the insertion order
private readonly pluginsMap: Map<string, HMSAudioPlugin>;
readonly pluginsMap: Map<string, HMSAudioPlugin>;
private audioContext?: AudioContext;

private sourceNode?: MediaStreamAudioSourceNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import HMSLogger from '../../utils/logger';
export class HMSMediaStreamPluginsManager {
private readonly TAG = '[MediaStreamPluginsManager]';
private analytics: VideoPluginsAnalytics;
private plugins: Set<HMSMediaStreamPlugin>;
readonly plugins: Set<HMSMediaStreamPlugin>;
private room?: Room;

constructor(eventBus: EventBus, room?: Room) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class HMSVideoPluginsManager {
private pluginsLoopRunning = false;
private pluginsLoopState: 'paused' | 'running' = 'paused';
private readonly hmsTrack: HMSLocalVideoTrack;
private readonly pluginsMap: Map<string, HMSVideoPlugin>; // plugin names to their instance mapping
readonly pluginsMap: Map<string, HMSVideoPlugin>; // plugin names to their instance mapping
private inputVideo?: HTMLVideoElement;
private inputCanvas?: CanvasElement;
private outputCanvas?: CanvasElement;
Expand Down

0 comments on commit 2a64652

Please sign in to comment.