Skip to content

Commit

Permalink
コード整理
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jan 11, 2025
1 parent 06b37a9 commit fffa27a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
1 change: 0 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
with:
node-version: ${{ matrix.node }}
- uses: pnpm/action-setup@v4
- run: pnpm --version
- run: pnpm install
- run: pnpm exec playwright install ${{ matrix.browser }} --with-deps
- run: pnpm exec playwright test --project=${{ matrix.browser }}
Expand Down
21 changes: 7 additions & 14 deletions replace_track/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@

<body>
<div class="container">
<h1>replaceTrack サンプル</h1>
<label for="video-codec-type">ビデオコーデックを選択:</label>
<select id="video-codec-type">
<option value="" selected>未指定</option>
<option value="VP8">VP8</option>
<option value="VP9">VP9</option>
<option value="AV1">AV1</option>
<option value="H264">H264</option>
<option value="H265">H265</option>
</select><br>
<button id="connect">connect</button>
<button id="replace-stream">replace stream</button>
<button id="disconnect">disconnect</button>
<button id="get-stats">getStats</button><br />
<h2>replaceTrack サンプル</h2>
<p>
<button id="connect">connect</button>
<button id="replace-stream">replace stream</button>
<button id="disconnect">disconnect</button>
</p>
<div id="connection-id"></div>
<video id="local-video" muted autoplay playsinline controls
style="border: 1px solid blue; transform: scaleX(-1);"></video>
Expand All @@ -32,6 +24,7 @@ <h1>replaceTrack サンプル</h1>
<button id="get-stats">getStats</button>
<pre id="stats-report-json"></pre>
</p>
<button id="get-stats">getStats</button><br />
</div>

<script type="module" src="./main.ts"></script>
Expand Down
19 changes: 5 additions & 14 deletions sendrecv/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ import Sora, {
} from "sora-js-sdk";
import { generateJwt } from "../src/misc";

const getVideoCodecType = (): VideoCodecType | undefined => {
const videoCodecTypeElement =
document.querySelector<HTMLSelectElement>("#video-codec-type");
const videoCodecType = videoCodecTypeElement?.value;
if (videoCodecType === "") {
return undefined;
}
return videoCodecType as VideoCodecType;
};

document.addEventListener("DOMContentLoaded", async () => {
const signalingUrl = import.meta.env.VITE_SORA_SIGNALING_URL;
const channelIdPrefix = import.meta.env.VITE_SORA_CHANNEL_ID_PREFIX || "";
Expand All @@ -37,6 +27,7 @@ document.addEventListener("DOMContentLoaded", async () => {
});
await client.connect(stream);
});

document.querySelector("#disconnect")?.addEventListener("click", async () => {
await client.disconnect();
});
Expand Down Expand Up @@ -123,15 +114,15 @@ class SoraClient {
return this.connection.pc.getStats();
}

setOptions(options: ConnectionOptions) {
this.options = { ...this.options, ...options };
}

private onnotify(event: SignalingNotifyMessage): void {
if (
event.event_type === "connection.created" &&
this.connection.connectionId === event.connection_id
) {
const channelIdElement = document.querySelector("#channel-id");
if (channelIdElement) {
channelIdElement.textContent = this.channelId;
}
const sessionIdElement = document.querySelector("#session-id");
if (sessionIdElement) {
sessionIdElement.textContent = this.connection.sessionId;
Expand Down
8 changes: 4 additions & 4 deletions tests/sendrecv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ test("sendrecv x2", async ({ browser }) => {
await sendrecv1.click("#connect");
await sendrecv2.click("#connect");

// data-testid="connection-id" 要素が存在し、その内容が空でないことを確認するまで待つ
// "connection-id" 要素が存在し、その内容が空でないことを確認するまで待つ
await sendrecv1.waitForSelector("#connection-id:not(:empty)");

// data-testid="connection-id" 要素の内容を取得
// "connection-id" 要素の内容を取得
const sendrecv1ConnectionId = await sendrecv1.$eval(
"#connection-id",
(el) => el.textContent,
);
console.log(`sendrecv1 connectionId=${sendrecv1ConnectionId}`);

// data-testid="connection-id" 要素が存在し、その内容が空でないことを確認するまで待つ
// "connection-id" 要素が存在し、その内容が空でないことを確認するまで待つ
await sendrecv2.waitForSelector("#connection-id:not(:empty)");

// data-testid="connection-id" 要素の内容を取得
// "connection-id" 要素の内容を取得
const sendrecv2ConnectionId = await sendrecv2.$eval(
"#connection-id",
(el) => el.textContent,
Expand Down

0 comments on commit fffa27a

Please sign in to comment.