From 760b2b9c751da610eede2ce9368a631764397a91 Mon Sep 17 00:00:00 2001 From: voluntas Date: Thu, 22 Feb 2024 10:51:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A4=89=E6=9B=B4=E5=B1=A5=E6=AD=B4?= =?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.md | 3 ++ README.md | 4 +-- packages/sdk/src/base.ts | 65 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 35a2e479..fdb9cf25 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,9 @@ ## develop +- [CHANGE] stopAudioTrack と stopVideoTrack を非推奨にする + - 代わりに名前を変えただけの removeAudioTrack と removeVideoTrack を用意する + - @voluntas - [CHANGE] examples を Vite を利用して動かすように変更する - serve を削除 - Vite を追加 diff --git a/README.md b/README.md index c93afe6e..639b5bcd 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ https://github.com/shiguredo/sora-js-sdk-samples ``` # .env.local を作成して適切な値を設定してください -$ cp sample.env .env.local +$ cp .env.template .env.local $ pnpm install $ pnpm run dev ``` @@ -47,7 +47,7 @@ $ pnpm run dev ``` # .env.local を作成して適切な値を設定してください -$ cp sample.env .env.local +$ cp .env.template .env.local $ pnpm install $ pnpm exec playwright install --with-deps $ pnpm run e2e-test diff --git a/packages/sdk/src/base.ts b/packages/sdk/src/base.ts index 83991029..fc3787dc 100644 --- a/packages/sdk/src/base.ts +++ b/packages/sdk/src/base.ts @@ -331,7 +331,9 @@ export default class ConnectionBase { } /** - * audio track を停止するメソッド + * audio track を削除するメソッド + * + * @deprecated この関数は非推奨です。代わりに removeAudioTrack を使用してください * * @example * ``` @@ -345,11 +347,38 @@ export default class ConnectionBase { * @remarks * stream の audio track を停止後、PeerConnection の senders から対象の sender を削除します * - * @param stream - audio track を停止する MediaStream + * @param stream - audio track を削除する MediaStream * * @public */ stopAudioTrack(stream: MediaStream): Promise { + console.warn( + // @deprecated message + '@deprecated stopAudioTrack will be removed in a future version. Use removeAudioTrack instead.', + ) + return this.removeAudioTrack(stream) + } + + /** + * audio track を削除するメソッド + * + * @example + * ``` + * const sendrecv = connection.sendrecv("sora"); + * const mediaStream = await navigator.mediaDevices.getUserMedia({audio: true, video: true}); + * await sendrecv.connect(mediaStream); + * + * sendrecv.removeAudioTrack(mediaStream); + * ``` + * + * @remarks + * stream の audio track を停止後、PeerConnection の senders から対象の sender を削除します + * + * @param stream - audio track を削除する MediaStream + * + * @public + */ + removeAudioTrack(stream: MediaStream): Promise { for (const track of stream.getAudioTracks()) { track.enabled = false } @@ -374,8 +403,11 @@ export default class ConnectionBase { }, 100) }) } + /** - * video track を停止するメソッド + * video track を削除するメソッド + * + * @deprecated この関数は非推奨です。代わりに removeVideoTrack を使用してください * * @example * ``` @@ -394,6 +426,29 @@ export default class ConnectionBase { * @public */ stopVideoTrack(stream: MediaStream): Promise { + return this.removeVideoTrack(stream) + } + + /** + * video track を削除するメソッド + * + * @example + * ``` + * const sendrecv = connection.sendrecv("sora"); + * const mediaStream = await navigator.mediaDevices.getUserMedia({audio: true, video: true}); + * await sendrecv.connect(mediaStream); + * + * sendrecv.removeVideoTrack(mediaStream); + * ``` + * + * @remarks + * stream の video track を停止後、PeerConnection の senders から対象の sender を削除します + * + * @param stream - video track を削除する MediaStream + * + * @public + */ + removeVideoTrack(stream: MediaStream): Promise { for (const track of stream.getVideoTracks()) { track.enabled = false } @@ -442,7 +497,7 @@ export default class ConnectionBase { * @public */ async replaceAudioTrack(stream: MediaStream, audioTrack: MediaStreamTrack): Promise { - await this.stopAudioTrack(stream) + await this.removeAudioTrack(stream) const transceiver = this.getAudioTransceiver() if (transceiver === null) { throw new Error('Unable to set an audio track. Audio track sender is undefined') @@ -474,7 +529,7 @@ export default class ConnectionBase { * @public */ async replaceVideoTrack(stream: MediaStream, videoTrack: MediaStreamTrack): Promise { - await this.stopVideoTrack(stream) + await this.removeVideoTrack(stream) const transceiver = this.getVideoTransceiver() if (transceiver === null) { throw new Error('Unable to set video track. Video track sender is undefined') From f1ea5e13412672ceff74e964d41270c7de1d88d4 Mon Sep 17 00:00:00 2001 From: voluntas Date: Tue, 27 Feb 2024 16:15:00 +0900 Subject: [PATCH 2/2] =?UTF-8?q?stopVideoTrack=20=E3=81=AB=20console.warn?= =?UTF-8?q?=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/sdk/src/base.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/sdk/src/base.ts b/packages/sdk/src/base.ts index fc3787dc..ea136400 100644 --- a/packages/sdk/src/base.ts +++ b/packages/sdk/src/base.ts @@ -426,6 +426,10 @@ export default class ConnectionBase { * @public */ stopVideoTrack(stream: MediaStream): Promise { + console.warn( + // @deprecated message + '@deprecated stopVideoTrack will be removed in a future version. Use removeVideoTrack instead.', + ) return this.removeVideoTrack(stream) }