Skip to content

Commit

Permalink
Sora の切断処理も Track の解放処理はデバイス無効化時と同じ関数を呼ぶ
Browse files Browse the repository at this point in the history
  • Loading branch information
tnamao committed Oct 23, 2023
1 parent 94e095d commit e71a8bf
Showing 1 changed file with 5 additions and 59 deletions.
64 changes: 5 additions & 59 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -872,65 +872,11 @@ function setSoraCallbacks(
createSoraDevtoolsTimelineMessage('event-on-disconnect', message),
),
);
const {
fakeContents,
soraContents,
reconnect,
lightAdjustmentProcessor,
noiseSuppressionProcessor,
virtualBackgroundProcessor,
} = getState();
const { localMediaStream, remoteMediaStreams } = soraContents;
let originalTrack;
if (lightAdjustmentProcessor && lightAdjustmentProcessor.isProcessing()) {
originalTrack = lightAdjustmentProcessor.getOriginalTrack();
lightAdjustmentProcessor.stopProcessing();
}
if (virtualBackgroundProcessor && virtualBackgroundProcessor.isProcessing()) {
if (originalTrack === undefined) {
originalTrack = virtualBackgroundProcessor.getOriginalTrack();
}
virtualBackgroundProcessor.stopProcessing();
}
if (originalTrack !== undefined) {
originalTrack.stop();
dispatch(
slice.actions.setTimelineMessage(
createSoraDevtoolsMediaStreamTrackLog('stop', originalTrack),
),
);
} else {
if (localMediaStream) {
localMediaStream.getVideoTracks().forEach((track) => {
track.stop();
dispatch(
slice.actions.setTimelineMessage(createSoraDevtoolsMediaStreamTrackLog('stop', track)),
);
});
}
}

if (noiseSuppressionProcessor && noiseSuppressionProcessor.isProcessing()) {
const originalTrack = noiseSuppressionProcessor.getOriginalTrack();
if (originalTrack) {
originalTrack.stop();
dispatch(
slice.actions.setTimelineMessage(
createSoraDevtoolsMediaStreamTrackLog('stop', originalTrack),
),
);
}
noiseSuppressionProcessor.stopProcessing();
} else {
if (localMediaStream) {
localMediaStream.getAudioTracks().forEach((track) => {
track.stop();
dispatch(
slice.actions.setTimelineMessage(createSoraDevtoolsMediaStreamTrackLog('stop', track)),
);
});
}
}
// ローカルの MediaStream の Track と MediaProcessor を止める
stopLocalVideoTrack(dispatch, getState());
stopLocalAudioTrack(dispatch, getState());
const { fakeContents, soraContents, reconnect } = getState();
const { remoteMediaStreams } = soraContents;
remoteMediaStreams.forEach((mediaStream) => {
mediaStream.getTracks().forEach((track) => {
track.stop();
Expand Down

0 comments on commit e71a8bf

Please sign in to comment.