Skip to content

Commit

Permalink
pnpm up -L -r
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Oct 18, 2024
1 parent f00b774 commit a083241
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 440 deletions.
2 changes: 1 addition & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.1/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": true
},
Expand Down
34 changes: 25 additions & 9 deletions examples/check_stereo_multi/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ async function updateDeviceLists() {
const devices = await navigator.mediaDevices.enumerateDevices()

for (let i = 0; i < 2; i++) {
const audioInputSelect = document.querySelector<HTMLSelectElement>(`#sendonly-audio-input-${i + 1}`)
const audioInputSelect = document.querySelector<HTMLSelectElement>(
`#sendonly-audio-input-${i + 1}`,
)

if (audioInputSelect) {
audioInputSelect.innerHTML = ''
Expand Down Expand Up @@ -138,7 +140,9 @@ class SendonlyClient {
}

private initializeCanvas() {
this.canvas = document.querySelector<HTMLCanvasElement>(`#sendonly-waveform-${this.sendonlyClientId}`)
this.canvas = document.querySelector<HTMLCanvasElement>(
`#sendonly-waveform-${this.sendonlyClientId}`,
)
if (this.canvas) {
this.canvasCtx = this.canvas.getContext('2d')
}
Expand Down Expand Up @@ -177,13 +181,17 @@ class SendonlyClient {
const result = isStereo ? 'Stereo' : 'Mono'

// differenceの値を表示する要素を追加
const differenceElement = document.querySelector<HTMLDivElement>(`#sendonly-difference-value-${this.sendonlyClientId}`)
const differenceElement = document.querySelector<HTMLDivElement>(
`#sendonly-difference-value-${this.sendonlyClientId}`,
)
if (differenceElement) {
differenceElement.textContent = `Difference: ${difference.toFixed(6)}`
}

// sendonly-stereo 要素に結果を反映
const sendonlyStereoElement = document.querySelector<HTMLDivElement>(`#sendonly-stereo-${this.sendonlyClientId}`)
const sendonlyStereoElement = document.querySelector<HTMLDivElement>(
`#sendonly-stereo-${this.sendonlyClientId}`,
)
if (sendonlyStereoElement) {
sendonlyStereoElement.textContent = result
}
Expand Down Expand Up @@ -265,7 +273,9 @@ class SendonlyClient {
event.event_type === 'connection.created' &&
this.connection.connectionId === event.connection_id
) {
const connectionIdElement = document.querySelector<HTMLDivElement>(`#sendonly-connection-id-${this.sendonlyClientId}`)
const connectionIdElement = document.querySelector<HTMLDivElement>(
`#sendonly-connection-id-${this.sendonlyClientId}`,
)
if (connectionIdElement) {
connectionIdElement.textContent = event.connection_id
}
Expand All @@ -275,7 +285,9 @@ class SendonlyClient {
private startChannelCheck() {
this.channelCheckInterval = window.setInterval(async () => {
const channels = await this.getChannels()
const channelElement = document.querySelector<HTMLDivElement>(`#sendonly-channels-${this.sendonlyClientId}`)
const channelElement = document.querySelector<HTMLDivElement>(
`#sendonly-channels-${this.sendonlyClientId}`,
)
if (channelElement) {
channelElement.textContent =
channels !== undefined ? `getParameters codecs channels: ${channels}` : 'undefined'
Expand Down Expand Up @@ -320,7 +332,9 @@ class RecvonlyClient {
}

private initializeCanvas(streamId: string) {
const canvas = document.querySelector<HTMLCanvasElement>(`#recvonly-waveform-canvas-${streamId}`)
const canvas = document.querySelector<HTMLCanvasElement>(
`#recvonly-waveform-canvas-${streamId}`,
)
if (canvas) {
this.canvases.set(streamId, canvas)
this.canvasCtxs.set(streamId, canvas.getContext('2d'))
Expand Down Expand Up @@ -360,7 +374,9 @@ class RecvonlyClient {
const result = isStereo ? 'Stereo' : 'Mono'

// differenceの値を表示する要素を追加
const differenceElement = document.querySelector<HTMLDivElement>(`#recvonly-difference-value-${stream.id}`)
const differenceElement = document.querySelector<HTMLDivElement>(
`#recvonly-difference-value-${stream.id}`,
)
if (differenceElement) {
differenceElement.textContent = `Difference: ${difference.toFixed(6)}`
}
Expand Down Expand Up @@ -474,7 +490,7 @@ class RecvonlyClient {
waveformCanvas.id = `recvonly-waveform-canvas-${stream.id}`
waveformCanvas.width = 800
waveformCanvas.height = 400

waveformDiv.appendChild(h3)
waveformDiv.appendChild(differenceValueDiv)
waveformDiv.appendChild(waveformCanvas)
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"dist"
],
"devDependencies": {
"@biomejs/biome": "1.9.2",
"@playwright/test": "1.47.2",
"typedoc": "0.26.7",
"typescript": "5.6.2",
"vite": "5.4.7",
"vitest": "2.1.1"
"@biomejs/biome": "1.9.4",
"@playwright/test": "1.48.1",
"typedoc": "0.26.10",
"typescript": "5.6.3",
"vite": "5.4.9",
"vitest": "2.1.3"
},
"packageManager": "pnpm@9.11.0",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test": "vitest run"
},
"devDependencies": {
"jsdom": "25.0.0",
"vite-plugin-dts": "4.2.1"
"jsdom": "25.0.1",
"vite-plugin-dts": "4.2.4"
}
}
23 changes: 13 additions & 10 deletions packages/sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ export const decompressMessage = async (binaryMessage: Uint8Array): Promise<Arra
return await new Response(decompressedStream).arrayBuffer()
}

export function addStereoToFmtp(sdp: string): string{
const splitSdp = sdp.match(/^(v=.+?)(m=audio.+)/sm)
export function addStereoToFmtp(sdp: string): string {
const splitSdp = sdp.match(/^(v=.+?)(m=audio.+)/ms)
if (splitSdp === null) {
return sdp
}
Expand All @@ -508,21 +508,21 @@ export function addStereoToFmtp(sdp: string): string{

const mediaDescriptionsList: string[][] = []
let mediaDescriptionList: string[] = []
for (const line of splitSdp[2].split(/\n/)){
for (const line of splitSdp[2].split(/\n/)) {
const typ = line[0]
if (typ === 'm' ) {
if (typ === 'm') {
mediaDescriptionList = [line]
mediaDescriptionsList.push(mediaDescriptionList)
} else {
mediaDescriptionList.push(line)
}
}

const mediaDescriptions = mediaDescriptionsList.map(mediaDescription => {
const mediaDescriptions = mediaDescriptionsList.map((mediaDescription) => {
return mediaDescription.join('\n')
})

const newMediaDescriptions = mediaDescriptions.map(mediaDescription => {
const newMediaDescriptions = mediaDescriptions.map((mediaDescription) => {
if (!isAudio(mediaDescription)) {
return mediaDescription
}
Expand All @@ -549,11 +549,11 @@ export function addStereoToFmtp(sdp: string): string{
return `${sessionDescription}${newMediaDescriptions.join('\n')}`
}

function isAudio(mediaDescription: string): boolean{
function isAudio(mediaDescription: string): boolean {
return /^m=audio/.test(mediaDescription)
}

function isSetupActive(mediaDescription: string): boolean{
function isSetupActive(mediaDescription: string): boolean {
return /a=setup:active/.test(mediaDescription)
}

Expand All @@ -570,5 +570,8 @@ function isFmtp(mediaDescription: string): boolean {
}

function appendStereo(mediaDescription: string): string {
return mediaDescription.replace(/(?<!stereo=1;.*)minptime=\d+(?!.*stereo=1)/, (match) => `${match};stereo=1`)
}
return mediaDescription.replace(
/(?<!stereo=1;.*)minptime=\d+(?!.*stereo=1)/,
(match) => `${match};stereo=1`,
)
}
2 changes: 1 addition & 1 deletion packages/sdk/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference types="vite/client" />

declare const __SORA_JS_SDK_VERSION__: string;
declare const __SORA_JS_SDK_VERSION__: string
Loading

0 comments on commit a083241

Please sign in to comment.