Skip to content

Commit

Permalink
gDM の音声配信の有無を audio トグルの状態と連動させる
Browse files Browse the repository at this point in the history
  • Loading branch information
tnamao committed Jan 17, 2024
1 parent c8f0468 commit 8721d5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ async function createMediaStream(
throw new Error('Failed to call getUserMedia. Make sure domain is secure')
}
const mediaConstraints = {
// getDisplayMedia では配信する画面の音声を利用するため、デバイス指定 (audioInput) は使わない
audio: createGetDisplayMediaAudioConstraints({
audio: state.audio,
autoGainControl: state.autoGainControl,
noiseSuppression: state.noiseSuppression,
echoCancellation: state.echoCancellation,
Expand Down Expand Up @@ -576,7 +578,9 @@ async function createMediaStream(
throw new Error('Failed to call getDisplayMedia. Make sure domain is secure')
}
const mediaStreamConstraints = {
// getDisplayMedia (mediacaptureRegion) では配信する画面の音声を利用するため、デバイス指定 (audioInput) は使わない
audio: createGetDisplayMediaAudioConstraints({
audio: state.audio,
autoGainControl: state.autoGainControl,
noiseSuppression: state.noiseSuppression,
echoCancellation: state.echoCancellation,
Expand Down
7 changes: 6 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ export function createFakeMediaConstraints(

// getDisplayMedia の audio constraints を生成
type CreateGetDisplayMediaAudioConstraintsParameters = {
audio: SoraDevtoolsState['audio']
autoGainControl: (typeof AUTO_GAIN_CONTROLS)[number]
noiseSuppression: (typeof NOISE_SUPPRESSIONS)[number]
echoCancellation: (typeof ECHO_CANCELLATIONS)[number]
Expand All @@ -464,7 +465,11 @@ type CreateGetDisplayMediaAudioConstraintsParameters = {
export function createGetDisplayMediaAudioConstraints(
parameters: CreateGetDisplayMediaAudioConstraintsParameters,
): boolean | MediaTrackConstraints {
const { autoGainControl, noiseSuppression, echoCancellation, echoCancellationType } = parameters
const { audio, autoGainControl, noiseSuppression, echoCancellation, echoCancellationType } =
parameters
if (!audio) {
return false
}
if (!autoGainControl && !noiseSuppression && !echoCancellation && !echoCancellationType) {
return true
}
Expand Down

0 comments on commit 8721d5b

Please sign in to comment.