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

オーディオデバイスの設定を認識しない問題を修正 #4505

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/Main/MainView/QallView/QallAudio.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<script setup lang="ts">
import { useQall } from '/@/composables/qall/useQall'
import AudioComponent from './AudioComponent.vue'
import VoiceComponent from './VoiceComponent.vue'

Check warning on line 3 in src/components/Main/MainView/QallView/QallAudio.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallAudio.vue#L3

Added line #L3 was not covered by tests

const { tracksMap, screenShareTrackSidMap, screenShareTracks } = useQall()
</script>
<template>
<template v-for="[sid, track] in Array.from(tracksMap.entries())" :key="sid">
<AudioComponent
<VoiceComponent

Check warning on line 9 in src/components/Main/MainView/QallView/QallAudio.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/QallAudio.vue#L9

Added line #L9 was not covered by tests
v-if="
track.trackPublication?.kind === 'audio' &&
track.isRemote &&
!screenShareTracks?.some?.(([_, valueSid]) => valueSid === sid)
"
:track-info="track"
:is-show="false"
/>
</template>
</template>
19 changes: 18 additions & 1 deletion src/components/Main/MainView/QallView/UserCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
import type { TrackInfo } from '/@/composables/qall/useLiveKitSDK'
import { useUsersStore } from '/@/store/entities/users'
import { buildUserIconPath } from '/@/lib/apis'
import { useQall } from '/@/composables/qall/useQall'

Check warning on line 6 in src/components/Main/MainView/QallView/UserCard.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/UserCard.vue#L6

Added line #L6 was not covered by tests

const { trackInfo } = defineProps<{
trackInfo: TrackInfo
}>()
const { speakerIdentitys } = useQall()

Check warning on line 11 in src/components/Main/MainView/QallView/UserCard.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/UserCard.vue#L11

Added line #L11 was not covered by tests
const { findUserByName } = useUsersStore()
const user = computed(() => findUserByName(trackInfo.username))
const userIconFileId = computed(() => user.value?.iconFileId ?? '')
const iconImage = computed(() => buildUserIconPath(userIconFileId.value))
const isSpeaking = computed(() => {
return (
user.value &&
speakerIdentitys.value.some(s => s.name === trackInfo.username)

Check warning on line 19 in src/components/Main/MainView/QallView/UserCard.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/UserCard.vue#L16-L19

Added lines #L16 - L19 were not covered by tests
)
})

Check warning on line 21 in src/components/Main/MainView/QallView/UserCard.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/UserCard.vue#L21

Added line #L21 was not covered by tests
</script>

<template>
<div v-if="user" :class="$style.UserCard">
<div v-if="user" :class="$style.UserCard" :data-is-speaking="isSpeaking">

Check warning on line 25 in src/components/Main/MainView/QallView/UserCard.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/UserCard.vue#L25

Added line #L25 was not covered by tests
<div :class="$style.OuterIcon">
<img :src="iconImage" :class="$style.OuterImage" />
</div>
Expand All @@ -23,6 +31,7 @@
</div>

<div :class="$style.NameLabel">{{ trackInfo.username }}</div>
<div v-show="isSpeaking" :class="$style.borderBox"></div>

Check warning on line 34 in src/components/Main/MainView/QallView/UserCard.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/UserCard.vue#L34

Added line #L34 was not covered by tests
</div>
</template>

Expand All @@ -35,6 +44,14 @@
border-radius: 12px;
pointer-events: none;
user-select: none;
box-sizing: border-box;
}

.borderBox {
border: 2px solid $common-ui-qall;
width: 100%;
height: 100%;
border-radius: 12px;
}

.InnerIcon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { buildUserIconPath } from '/@/lib/apis'
import AudioTrack from './AudioTrack.vue'
import { useUserVolume } from '/@/store/app/userVolume'
import UserCard from './UserCard.vue'
const { trackInfo, isShow } = defineProps<{
trackInfo: TrackInfo
isShow?: boolean
Expand All @@ -29,14 +28,6 @@
</script>

<template>
<div :class="isShow ? $style.container : []">
<UserCard :track-info="trackInfo" />
<AudioTrack :track-info="trackInfo" :volume="parseToFloat(volume)" />
</div>
<AudioTrack :track-info="trackInfo" :volume="parseToFloat(volume)" />

Check warning on line 31 in src/components/Main/MainView/QallView/VoiceComponent.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/QallView/VoiceComponent.vue#L31

Added line #L31 was not covered by tests
</template>
<style lang="scss" module>
.container {
width: 100%;
height: 100%;
}
</style>
<style lang="scss" module></style>
31 changes: 21 additions & 10 deletions src/composables/qall/useLiveKitSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
AudioPresets,
createLocalScreenTracks,
Room,
LocalVideoTrack
LocalVideoTrack,
LocalAudioTrack
} from 'livekit-client'
import type {
RemoteTrack,
Expand Down Expand Up @@ -85,7 +86,7 @@
const room = ref<Room>()
const audioContext = ref<AudioContext>()
const isRnnoiseSupported = computed(() => !!audioContext.value)
const speakerIdentity = ref<string[]>([])
const speakerIdentitys = ref<{ identity: string; name?: string }[]>([])

Check warning on line 89 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L89

Added line #L89 was not covered by tests
const tracksMap: Ref<Map<string, TrackInfo>> = ref(new Map())
const cameraProcessorMap: Ref<Map<string, CameraProcessor>> = ref(new Map())
const screenShareTrackSidMap = ref<Map<string, string>>(new Map())
Expand Down Expand Up @@ -141,7 +142,7 @@

function handleActiveSpeakerChange(speakers: Participant[]) {
// show UI indicators when participant is speaking
speakerIdentity.value = speakers.map(s => s.identity)
speakerIdentitys.value = speakers

Check warning on line 145 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L145

Added line #L145 was not covered by tests
}

function handleDisconnect() {
Expand Down Expand Up @@ -264,8 +265,7 @@
const addMicTrack = async () => {
let stream: MediaStream | undefined

const noiseSuppression = useRtcSettings().noiseSuppression
.value as NoiseSuppressionType
const { noiseSuppression, audioInputDeviceId } = useRtcSettings()

Check warning on line 268 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L268

Added line #L268 was not covered by tests
try {
if (!room.value?.localParticipant?.permissions?.canPublish) {
throw new Error('権限がありません')
Expand All @@ -275,12 +275,21 @@
audioContext.value = new AudioContext()
}

stream = await navigator.mediaDevices.getUserMedia({ audio: true })
stream = await navigator.mediaDevices.getUserMedia({
audio: {
deviceId: {
ideal: audioInputDeviceId.value
},
autoGainControl: true,
noiseSuppression: true,
echoCancellation: true
}
})

Check warning on line 287 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L278-L287

Added lines #L278 - L287 were not covered by tests
const source = audioContext.value.createMediaStreamSource(stream)

let lastNode: AudioNode = source

if (noiseSuppression === 'rnnoise') {
if (noiseSuppression.value === 'rnnoise') {

Check warning on line 292 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L292

Added line #L292 was not covered by tests
const [rnnoiseBinary] = await Promise.all([
loadRnnoiseWasmBinary(),
audioContext.value?.audioWorklet.addModule(rnnoiseWorkletPath)
Expand All @@ -291,7 +300,7 @@
})
source.connect(rnnoiseNode)
lastNode = rnnoiseNode
} else if (noiseSuppression === 'speex') {
} else if (noiseSuppression.value === 'speex') {

Check warning on line 303 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L303

Added line #L303 was not covered by tests
const [speexBinary] = await Promise.all([
loadSpeexWasmBinary(),
audioContext.value?.audioWorklet.addModule(speexWorkletPath)
Expand All @@ -313,9 +322,11 @@
}

audioTrackId.value = audioTrack.id
const livekitAudioTrack = new LocalAudioTrack(audioTrack, undefined, false)
livekitAudioTrack.source = Track.Source.Microphone

Check warning on line 326 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L325-L326

Added lines #L325 - L326 were not covered by tests

// Publish the processed stream
await room.value.localParticipant.publishTrack(audioTrack, {
await room.value.localParticipant.publishTrack(livekitAudioTrack, {

Check warning on line 329 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L329

Added line #L329 was not covered by tests
audioPreset: AudioPresets.speech,
forceStereo: true,
red: false,
Expand All @@ -334,7 +345,6 @@
addErrorToast('マイクの共有に失敗しました')
}
}

const removeMicTrack = async () => {
try {
if (!room.value) {
Expand Down Expand Up @@ -633,6 +643,7 @@
tracksMap,
screenShareTrackSidMap,
screenShareTracks,
speakerIdentitys,

Check warning on line 646 in src/composables/qall/useLiveKitSDK.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useLiveKitSDK.ts#L646

Added line #L646 was not covered by tests
isMicOn,
qallMitt
}
Expand Down
2 changes: 2 additions & 0 deletions src/composables/qall/useQall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
tracksMap,
screenShareTrackSidMap,
screenShareTracks,
speakerIdentitys,

Check warning on line 61 in src/composables/qall/useQall.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useQall.ts#L61

Added line #L61 was not covered by tests
isMicOn,
qallMitt
} = useLiveKitSDK()
Expand Down Expand Up @@ -321,6 +322,7 @@
isMicOn,
isCameraOn,
isScreenSharing,
speakerIdentitys,

Check warning on line 325 in src/composables/qall/useQall.ts

View check run for this annotation

Codecov / codecov/patch

src/composables/qall/useQall.ts#L325

Added line #L325 was not covered by tests
selectedTrack
}
}
Loading