Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Sora Rust SDK
Sora Rust SDK は WebRTC SFU Sora の Rust クライアントアプリケーションを開発するためのライブラリです。
About Shiguredo's open source software
We will not respond to PRs or issues that have not been discussed on Discord. Also, Discord is only available in Japanese.
Please read https://github.com/shiguredo/oss/blob/master/README.en.md before use.
時雨堂のオープンソースソフトウェアについて
利用前に https://github.com/shiguredo/oss をお読みください。
Sora Rust SDK について
様々なプラットフォームに対応した WebRTC SFU Sora 向けの Rust SDK です。
特徴
- マルチストリーム対応
- サイマルキャスト対応
- スポットライト対応
- DataChannel シグナリング対応
- DataChannel メッセージング対応
- JSON-RPC over DataChannel 対応
- 転送フィルター対応
- シグナリング通知対応
- シグナリングリダイレクト対応
- 複数シグナリング URL 対応
- メタデータ認証対応
- シグナリング通知メタデータ対応
- クライアント証明書認証対応
- TURN-TLS 対応
- HTTP プロキシ対応
- VP8 / VP9 / AV1 / H.264 / H.265 対応
- MP4 ファイルから無変換での音声・映像送信対応
- 複数クライアント同時実行対応
使い方
依存関係の追加
Cargo.toml に以下を追加してください。
[]
= "<version>"
= "<version>"
= { = "1", = ["rt-multi-thread", "macros", "sync", "time"] }
shiguredo_webrtc は VideoTrack や AudioTrack、RtpTransceiver など sora_sdk の公開 API で必要な型を提供します。
sendrecv で接続する
映像・音声を送受信する例です。
use ;
async
sendonly で接続する
映像・音声を送信する例です。
use ;
async
recvonly で接続する
映像・音声を受信する例です。
use ;
async
SoraClient::builder() の設定
SoraClient::builder() では以下の設定が可能です。
let = builder
// コールバック
.on_signaling_message
.on_notify
.on_push
.on_track
.on_remove_track
.on_switched
.on_websocket_close
// メッセージング
.on_message
// DataChannel
.on_data_channel
.on_data_channel_open
.on_data_channel_message
.on_data_channel_close
// 送信トラック
.sender_video_track
.sender_audio_track
// 接続オプション
.client_id // クライアント ID
.bundle_id // バンドル ID
.metadata // メタデータ (認証用など)
.audio // 音声設定
.video // 映像設定
.data_channel_signaling // DataChannel シグナリング
.ignore_disconnect_websocket // WebSocket 切断を無視
.simulcast // サイマルキャスト
.simulcast_request_rid // サイマルキャスト rid 指定
.spotlight // スポットライト
.spotlight_focus_rid // スポットライト フォーカス rid
.spotlight_unfocus_rid // スポットライト アンフォーカス rid
.signaling_notify_metadata // シグナリング通知メタデータ
.data_channels // DataChannel 設定
.forwarding_filters // 転送フィルター
// TLS 設定
.insecure // サーバー証明書の検証をスキップ
.client_cert // クライアント証明書 (PEM)
.ca_cert // CA 証明書 (PEM)
// TURN-TLS 設定
.turn_tls_insecure // TURN-TLS 証明書の検証をスキップ
.turn_tls_ca_cert // TURN-TLS CA 証明書 (DER)
// プロキシ設定
.proxy // HTTP プロキシ
// タイムアウト設定
.websocket_connection_timeout
.websocket_close_timeout
.disconnect_wait_timeout
// その他
.user_agent // WebSocket User-Agent
.build?;
切断と統計情報の取得
SoraClient::builder().build() が返す SoraClientHandle を使って、別タスクから切断や統計情報の取得ができます。
// 別タスクから切断する
let handle_clone = handle.clone;
spawn;
// 統計情報を取得する
let stats = handle.get_stats.await?;
メッセージ受信
SoraClient::builder() の on_message コールバックで # プレフィックス付きラベルのユーザー定義 DataChannel からメッセージを受信できます。
.on_message
メッセージ送信
SoraClientHandle を使って # プレフィックス付きラベルのユーザー定義 DataChannel にバイナリデータを送信できます。
handle.send_message.await?;
RPC
SoraClientHandle を使って JSON-RPC 2.0 over DataChannel でリクエストを送信できます。
SDK が JSON-RPC 2.0 メッセージの組み立てと id 採番を行います。
use ;
// リクエストを送信してレスポンスを待つ (デフォルトタイムアウト 5 秒)
let params: JsonString = r#"{"key": "value"}"#.parse?;
let response = handle.send_rpc_request.await?;
match response
// notification (レスポンスを待たない)
let response = handle.send_rpc_request.await?;
// response: None
// タイムアウトを 10 秒に変更
let response = handle.send_rpc_request.await?;
複数クライアントの同時実行
SoraClientContext は Send + Sync を実装しているため、複数の SoraClient で共有できます。
let context = new?;
for i in 0..5
構成
sora-rust-sdk/
├── src/ # sora_sdk クレート
├── examples/
│ └── sumomo/ # Sora クライアントサンプル
└── e2e-tests/ # エンドツーエンドテスト
サンプル
sumomo
Sora クライアントのサンプルです。詳細は examples/sumomo/README.md を参照してください。
zakuro
Sora WebRTC SFU 負荷試験ツールです。将来的に zakuro (C++ 版) を置き換える予定です。 詳細は examples/zakuro/README.md を参照してください。
ビルド
前提条件
- Rust 1.88 以上
- libclang (bindgen 用)
- Python 3 (webrtc ビルド用)
ビルド手順
対応 WebRTC SFU Sora
- Sora 2025.1.0 以降
対応プラットフォーム
- Ubuntu 24.04 LTS x86_64
- Ubuntu 24.04 LTS arm64
- Ubuntu 22.04 LTS x86_64
- Ubuntu 22.04 LTS arm64
- macOS Tahoe 26 arm64
- macOS Sequoia 15 arm64
- Windows 11 x86_64
- Windows Server 2025 x86_64
Ubuntu の対応バージョン
直近の LTS 2 バージョンをサポートします。
macOS の対応バージョン
直近の 2 バージョンをサポートします。
Windows の対応バージョン
直近のバージョンをサポートします。
優先実装
優先実装とは Sora のライセンスを契約頂いているお客様限定で Sora Rust SDK の実装予定機能を有償にて前倒しで実装することです。
優先実装が可能な対応一覧
詳細は Discord やメールなどでお気軽にお問い合わせください
- Windows arm64 対応
サポートについて
Discord
- サポートしません
- アドバイスします
- フィードバック歓迎します
最新の状況などは Discord で共有しています。質問や相談も Discord でのみ受け付けています。
バグ報告
Discord へお願いします。
ライセンス
Apache License 2.0
Copyright 2026-2026, Wandbox LLC (Original Author)
Copyright 2026-2026, Shiguredo Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.