11 Commits

Author SHA1 Message Date
0922fc4f41 новый-старый clientrow
All checks were successful
Deploy / publish-web (push) Successful in 41s
2026-01-29 23:19:31 +06:00
9fc8f954e3 новый-старый clientrow 2026-01-29 23:18:47 +06:00
a645885cf2 client volumes
All checks were successful
Deploy / publish-web (push) Successful in 1m31s
2026-01-29 22:05:05 +06:00
4c8a0e791c client volumes 2026-01-29 22:04:40 +06:00
fbdceb2e55 client volumes 2026-01-29 21:59:41 +06:00
aeaea47609 client volumes and dominant client
All checks were successful
Deploy / deploy (push) Successful in 33s
2026-01-29 21:40:56 +06:00
f4fd752448 client volumes and dominant client
All checks were successful
Deploy / deploy (push) Successful in 34s
2026-01-29 21:34:46 +06:00
595354b7f0 Merge pull request 'shareFps' (#9) from shareFps into master
All checks were successful
Deploy / publish-web (push) Successful in 1m32s
Reviewed-on: #9
2026-01-12 07:23:51 +00:00
Nadar
d08b011596 shareFps 2026-01-12 10:22:56 +03:00
12ce381abd minor update
All checks were successful
Deploy / publish-web (push) Successful in 46s
2025-12-27 02:52:17 +06:00
2d30ac2863 minor update
All checks were successful
Deploy / publish-web (push) Successful in 44s
2025-12-27 02:49:39 +06:00
14 changed files with 137 additions and 31 deletions

Binary file not shown.

View File

@@ -31,17 +31,17 @@ body {
.p-select-overlay { .p-select-overlay {
/* Force dropdown width to match computed min-width from PrimeVue internals. */ /* Force dropdown width to match computed min-width from PrimeVue internals. */
width: 0; width: 0 !important;
} }
.p-select-label { .p-select-label {
width: 0; width: 0 !important;
overflow: hidden; overflow: hidden !important;
text-overflow: ellipsis; text-overflow: ellipsis !important;
} }
.p-select-option-label { .p-select-option-label {
min-width: 0; min-width: 0 !important;
overflow: hidden; overflow: hidden !important;
text-overflow: ellipsis; text-overflow: ellipsis !important;
} }

View File

@@ -6,18 +6,28 @@
'bg-surface-800': expanded, 'bg-surface-800': expanded,
}" }"
> >
<div class="p-3 flex items-center gap-3" @click="toggleExpand"> <div class="p-3" @click="toggleExpand">
<PrimeAvatar size="small"> <div class="flex items-center gap-3">
<PrimeAvatar
size="small"
class="shrink-0"
:class="{
'outline-1 outline-primary outline-offset-2': speaking,
}"
>
<template #icon> <template #icon>
<User :size="20" /> <User :size="20" />
</template> </template>
</PrimeAvatar> </PrimeAvatar>
<div class="flex-1 overflow-hidden text-sm leading-5 font-medium text-color whitespace-nowrap overflow-ellipsis"> <p class="flex-1 text-sm leading-5 font-medium text-color truncate w-0">
{{ client.displayName || client.username }} {{ client.displayName || client.username }}
</p>
<Component :is="expanded ? ChevronUp : ChevronDown" v-if="!isMe" :size="20" class="text-muted-color" />
</div> </div>
<div class="flex align-center gap-1"> <div v-if="hasBadges" class="flex justify-end align-center gap-1 mt-2">
<PrimeBadge v-if="!!shareConsumer" v-tooltip.top="'Watch'" severity="success" value="Streaming" size="small" @click.stop="watchStream" /> <PrimeBadge v-if="!!shareConsumer" v-tooltip.top="'Watch'" severity="success" value="Streaming" size="small" @click.stop="watchStream" />
<PrimeBadge v-if="premuted" severity="danger" value="Muted" size="small" /> <PrimeBadge v-if="premuted" severity="danger" value="Muted" size="small" />
@@ -26,8 +36,6 @@
<PrimeBadge v-if="isMe" severity="secondary" value="You" size="small" class="shrink-0" /> <PrimeBadge v-if="isMe" severity="secondary" value="You" size="small" class="shrink-0" />
</div> </div>
<Component :is="expanded ? ChevronUp : ChevronDown" v-if="!isMe" :size="20" />
</div> </div>
<CollapseTransition v-if="!isMe"> <CollapseTransition v-if="!isMe">
@@ -61,7 +69,7 @@ const props = defineProps<{
}>() }>()
const { outputMuted } = useApp() const { outputMuted } = useApp()
const { consumers: allConsumers, micProducer } = useMediasoup() const { consumers: allConsumers, micProducer, speakingClients } = useMediasoup()
const { me } = useClients() const { me } = useClients()
const { show } = useFullscreenVideo() const { show } = useFullscreenVideo()
@@ -94,6 +102,10 @@ const audioTrack = computed(() => {
return audioConsumer.value?.track return audioConsumer.value?.track
}) })
const speaking = computed(() => {
return speakingClients.value.find(speaker => speaker.clientId === props.client.socketId)
})
const audioConsumerPaused = ref(false) const audioConsumerPaused = ref(false)
const inputMuted = computed(() => { const inputMuted = computed(() => {
@@ -103,6 +115,14 @@ const inputMuted = computed(() => {
return premuted.value || audioConsumerPaused.value return premuted.value || audioConsumerPaused.value
}) })
const hasBadges = computed(() => {
return !!shareConsumer.value
|| premuted.value
|| inputMuted.value
|| props.client.outputMuted
|| isMe.value
})
watch(allConsumers, () => { watch(allConsumers, () => {
audioConsumerPaused.value = audioConsumer.value?.paused ?? false audioConsumerPaused.value = audioConsumer.value?.paused ?? false
}) })

View File

@@ -12,7 +12,17 @@ export const useApp = createGlobalState(() => {
const ready = ref(false) const ready = ref(false)
const isTauri = computed(() => '__TAURI_INTERNALS__' in window) const isTauri = computed(() => '__TAURI_INTERNALS__' in window)
const commitSha = __COMMIT_SHA__ const commitSha = __COMMIT_SHA__
const version = computedAsync(() => isTauri.value ? getVersion() : 'web', '-') const version = computedAsync(() => {
if (import.meta.dev) {
return 'dev'
}
else if (isTauri.value) {
return getVersion()
}
else {
return 'web'
}
}, '-')
const inputMuted = computed(() => { const inputMuted = computed(() => {
return !!mediasoup.micProducer.value?.paused return !!mediasoup.micProducer.value?.paused

View File

@@ -29,11 +29,25 @@ export const useFullscreenVideo = createGlobalState(() => {
videoEl.value = el videoEl.value = el
} }
stream.getTracks().forEach(t =>
t.addEventListener('ended', hide),
)
videoEl.value.addEventListener('ended', hide)
await videoEl.value.requestFullscreen() await videoEl.value.requestFullscreen()
} }
function hide() { function hide() {
if (!videoEl.value)
return
(videoEl.value.srcObject as MediaStream).getTracks().forEach(t =>
t.removeEventListener('ended', hide),
)
videoEl.value.removeEventListener('ended', hide)
videoEl.value?.remove() videoEl.value?.remove()
videoEl.value = undefined
} }
useEventListener(document, 'fullscreenchange', () => { useEventListener(document, 'fullscreenchange', () => {

View File

@@ -1,6 +1,8 @@
import type { SpeakingClient } from '#shared/types'
import type { MediaKind, ProducerOptions } from 'mediasoup-client/types' import type { MediaKind, ProducerOptions } from 'mediasoup-client/types'
import { createSharedComposable } from '@vueuse/core' import { createSharedComposable } from '@vueuse/core'
import * as mediasoupClient from 'mediasoup-client' import * as mediasoupClient from 'mediasoup-client'
import { shallowRef } from 'vue'
import { useDevices } from '~/composables/use-devices' import { useDevices } from '~/composables/use-devices'
import { usePreferences } from '~/composables/use-preferences' import { usePreferences } from '~/composables/use-preferences'
import { useSignaling } from '~/composables/use-signaling' import { useSignaling } from '~/composables/use-signaling'
@@ -40,6 +42,8 @@ export const useMediasoup = createSharedComposable(() => {
const consumers = shallowRef<Map<string, mediasoupClient.types.Consumer>>(new Map()) const consumers = shallowRef<Map<string, mediasoupClient.types.Consumer>>(new Map())
const producers = shallowRef<Map<string, mediasoupClient.types.Producer>>(new Map()) const producers = shallowRef<Map<string, mediasoupClient.types.Producer>>(new Map())
const speakingClients = shallowRef<SpeakingClient[]>([])
watch(signaling.socket, (socket) => { watch(signaling.socket, (socket) => {
if (!socket) if (!socket)
return return
@@ -227,6 +231,10 @@ export const useMediasoup = createSharedComposable(() => {
triggerRef(consumers) triggerRef(consumers)
}) })
socket.on('speakingPeers', (value: SpeakingClient[]) => {
speakingClients.value = value
})
}, { immediate: true, flush: 'sync' }) }, { immediate: true, flush: 'sync' })
async function enableProducer(type: ProducerType, options: ProducerOptions) { async function enableProducer(type: ProducerType, options: ProducerOptions) {
@@ -317,7 +325,7 @@ export const useMediasoup = createSharedComposable(() => {
if (!device.value) if (!device.value)
return return
const stream = await getShareStream() const stream = await getShareStream(preferences.shareFps.value)
const track = stream.getVideoTracks()[0] const track = stream.getVideoTracks()[0]
@@ -327,7 +335,7 @@ export const useMediasoup = createSharedComposable(() => {
await enableProducer('share', { await enableProducer('share', {
track, track,
codec: device.value.rtpCapabilities.codecs?.find( codec: device.value.rtpCapabilities.codecs?.find(
c => c.mimeType.toLowerCase() === 'video/h264', c => c.mimeType.toLowerCase() === 'video/AV1',
), ),
codecOptions: { codecOptions: {
videoGoogleStartBitrate: 1000, videoGoogleStartBitrate: 1000,
@@ -424,6 +432,7 @@ export const useMediasoup = createSharedComposable(() => {
init, init,
consumers, consumers,
producers, producers,
speakingClients,
sendTransport, sendTransport,
recvTransport, recvTransport,
rtpCapabilities, rtpCapabilities,

View File

@@ -19,6 +19,8 @@ export const usePreferences = createGlobalState(() => {
const noiseSuppression = useLocalStorage('NOISE_SUPPRESSION', true) const noiseSuppression = useLocalStorage('NOISE_SUPPRESSION', true)
const echoCancellation = useLocalStorage('ECHO_CANCELLATION', true) const echoCancellation = useLocalStorage('ECHO_CANCELLATION', true)
const shareFps = useLocalStorage('SHARE_FPS', 30)
const toggleInputHotkey = ref<SyncedPreferences['toggleInputHotkey']>('') const toggleInputHotkey = ref<SyncedPreferences['toggleInputHotkey']>('')
const toggleOutputHotkey = ref<SyncedPreferences['toggleOutputHotkey']>('') const toggleOutputHotkey = ref<SyncedPreferences['toggleOutputHotkey']>('')
@@ -57,6 +59,7 @@ export const usePreferences = createGlobalState(() => {
autoGainControl, autoGainControl,
noiseSuppression, noiseSuppression,
echoCancellation, echoCancellation,
shareFps,
toggleInputHotkey, toggleInputHotkey,
toggleOutputHotkey, toggleOutputHotkey,
inputDeviceExist, inputDeviceExist,

View File

@@ -1,10 +1,10 @@
<template> <template>
<div class="grid grid-cols-[1fr_1.25fr] gap-2 p-2 h-screen grid-rows-[auto_1fr]"> <div class="grid grid-cols-[1fr_1.25fr] gap-2 p-2 h-screen grid-rows-[auto_1fr] max-w-full">
<div <div
class="flex items-center justify-between gap-2 rounded-xl p-3 bg-surface-950" class="flex items-center justify-between gap-2 rounded-xl p-3 bg-surface-950"
> >
<div class="inline-flex items-center gap-3"> <div class="inline-flex items-center gap-3">
<PrimeBadge v-if="isTauri" class="opacity-50" severity="secondary" :value="version" size="small" /> <PrimeBadge class="opacity-50" severity="secondary" :value="version" size="small" />
<PrimeBadge :severity="connected ? 'success' : 'danger' " /> <PrimeBadge :severity="connected ? 'success' : 'danger' " />
</div> </div>
@@ -72,7 +72,6 @@ import {
} from 'lucide-vue-next' } from 'lucide-vue-next'
const { const {
isTauri,
version, version,
clients, clients,
inputMuted, inputMuted,

View File

@@ -47,6 +47,18 @@
<!-- <label for="outputDevice">Output device</label> --> <!-- <label for="outputDevice">Output device</label> -->
<!-- </PrimeFloatLabel> --> <!-- </PrimeFloatLabel> -->
<PrimeDivider align="left">
Video
</PrimeDivider>
<div>
<div class="text-sm mb-2">
Share FPS
</div>
<PrimeSelectButton v-model="shareFps" :options="[5, 30, 60]" fluid size="small" />
</div>
<template v-if="isTauri"> <template v-if="isTauri">
<PrimeDivider align="left"> <PrimeDivider align="left">
Hotkeys Hotkeys
@@ -117,6 +129,7 @@ const {
toggleOutputHotkey, toggleOutputHotkey,
inputDeviceExist, inputDeviceExist,
outputDeviceExist, outputDeviceExist,
shareFps,
} = usePreferences() } = usePreferences()
const setupToggleInputHotkey = (event: KeyboardEvent) => setupHotkey(event, toggleInputHotkey) const setupToggleInputHotkey = (event: KeyboardEvent) => setupHotkey(event, toggleInputHotkey)

View File

@@ -8,3 +8,8 @@ export interface ChadClient {
} }
export type UpdatedClient = Omit<ChadClient, 'socketId' | 'userId' | 'isMe'> export type UpdatedClient = Omit<ChadClient, 'socketId' | 'userId' | 'isMe'>
export interface SpeakingClient {
clientId: ChadClient['socketId']
volume: number
}

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "chad", "productName": "chad",
"version": "0.2.17", "version": "0.2.22",
"identifier": "xyz.koptilnya.chad", "identifier": "xyz.koptilnya.chad",
"build": { "build": {
"frontendDist": "../.output/public", "frontendDist": "../.output/public",

View File

@@ -22,8 +22,8 @@ export default fp<Partial<ServerOptions>>(
await fastify.io.close() await fastify.io.close()
}) })
fastify.ready(() => { fastify.ready(async () => {
registerWebrtcSocket(fastify.io, fastify.mediasoupRouter) await registerWebrtcSocket(fastify.io, fastify.mediasoupRouter)
}) })
}, },
{ name: 'socket-io', dependencies: ['mediasoup-worker', 'mediasoup-router'] }, { name: 'socket-io', dependencies: ['mediasoup-worker', 'mediasoup-router'] },

View File

@@ -1,6 +1,7 @@
import type { types } from 'mediasoup' import type { types } from 'mediasoup'
import type { Server as SocketServer } from 'socket.io' import type { Server as SocketServer } from 'socket.io'
import type { import type {
ChadClient,
Namespace, Namespace,
SomeSocket, SomeSocket,
} from '../types/webrtc.ts' } from '../types/webrtc.ts'
@@ -8,9 +9,39 @@ import { consola } from 'consola'
import prisma from '../prisma/client.ts' import prisma from '../prisma/client.ts'
import { socketToClient } from '../utils/socket-to-client.ts' import { socketToClient } from '../utils/socket-to-client.ts'
export default function (io: SocketServer, router: types.Router) { export default async function (io: SocketServer, router: types.Router) {
const namespace: Namespace = io.of('/webrtc') const namespace: Namespace = io.of('/webrtc')
const audioLevelObserver = await router.createAudioLevelObserver({
maxEntries: 10,
threshold: -80,
interval: 800,
})
const activeSpeakerObserver = await router.createActiveSpeakerObserver()
audioLevelObserver.on('volumes', async (volumes: types.AudioLevelObserverVolume[]) => {
namespace.emit('speakingPeers', volumes.map(({ producer, volume }) => {
const { socketId } = producer.appData as { socketId: ChadClient['socketId'] }
return {
clientId: socketId,
volume,
}
}))
})
audioLevelObserver.on('silence', () => {
namespace.emit('speakingPeers', [])
namespace.emit('activeSpeaker', undefined)
})
activeSpeakerObserver.on('dominantspeaker', ({ producer }) => {
const { socketId } = producer.appData as { socketId: ChadClient['socketId'] }
namespace.emit('activeSpeaker', socketId)
})
namespace.on('connection', async (socket) => { namespace.on('connection', async (socket) => {
consola.info('[WebRtc]', 'Client connected', socket.id) consola.info('[WebRtc]', 'Client connected', socket.id)
@@ -182,8 +213,8 @@ export default function (io: SocketServer, router: types.Router) {
) )
} }
// TODO: Add into the AudioLevelObserver and ActiveSpeakerObserver. await audioLevelObserver.addProducer({ producerId: producer.id })
// https://github.com/versatica/mediasoup-demo/blob/v3/server/lib/Room.js#L1276 await activeSpeakerObserver.addProducer({ producerId: producer.id })
} }
catch (error) { catch (error) {
if (error instanceof Error) { if (error instanceof Error) {

View File

@@ -118,6 +118,8 @@ export interface ServerToClientEvents {
consumerResumed: (arg: { consumerId: string }) => void consumerResumed: (arg: { consumerId: string }) => void
consumerScore: (arg: { consumerId: string, score: types.ConsumerScore }) => void consumerScore: (arg: { consumerId: string, score: types.ConsumerScore }) => void
clientChanged: (clientId: ChadClient['socketId'], client: ChadClient) => void clientChanged: (clientId: ChadClient['socketId'], client: ChadClient) => void
speakingPeers: (arg: { clientId: ChadClient['socketId'], volume: types.AudioLevelObserverVolume['volume'] }[]) => void
activeSpeaker: (clientId?: ChadClient['socketId']) => void
} }
export interface InterServerEvent {} export interface InterServerEvent {}