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.
webrtc-rs
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 before use.
時雨堂のオープンソースソフトウェアについて
利用前に https://github.com/shiguredo/oss をお読みください。
概要
libwebrtc の C API バインディングを Rust から安全に利用するためのライブラリです。
特徴
- webrtc-build でビルドされた libwebrtc を利用
- C++ の薄い C API ラッパー層と Rust の安全な API 層の 2 層構造
cargo buildだけでビルド- デフォルトでは prebuilt 済みライブラリを GitHub Releases から自動ダウンロード
- CMake、libclang、C++ コンパイラなどのインストールは不要
サポートプラットフォーム
- Ubuntu 24.04 LTS x86_64
- Ubuntu 24.04 LTS arm64
- Ubuntu 22.04 LTS x86_64
- Ubuntu 22.04 LTS arm64
- Windows 11 x86_64
- Windows Server 2025 x86_64
- macOS Tahoe 26 arm64
- macOS Sequoia 15 arm64
- Raspberry Pi OS (64-bit) arm64
- Debian version: 13 (trixie)
Ubuntu の対応バージョン
直近の LTS 2 バージョンをサポートします。
macOS の対応バージョン
直近の 2 バージョンをサポートします。
Windows の対応バージョン
直近のバージョンをサポートします。
Raspberry Pi OS の対応バージョン
最新 Debian バージョンのみサポートします。
[!NOTE] Raspberry Pi OS (Legacy) や Raspberry Pi OS (32-bit) はサポート対象外です。
バージョニング
- メジャーバージョンは常に 0
- マイナーバージョンは libwebrtc の m バージョンと一致 (例: 0.146.x は m146)
- パッチバージョンは同一 m バージョン内での変更時にインクリメント
使い方
依存の追加
[]
= "0.146"
PeerConnectionFactory の生成
use ;
use Arc;
対応 API
PeerConnection
PeerConnectionFactory- PeerConnection の生成
PeerConnection- 接続の管理
PeerConnectionFactoryDependencies- ファクトリの依存関係設定
PeerConnectionFactoryOptions- ファクトリオプション (暗号化無効化)
PeerConnectionDependencies- PeerConnection の依存関係設定
set_proxy(...)で TURN 用の HTTP Proxy を設定
PeerConnectionRtcConfiguration- ICE / 接続設定
ConnectionContextdefault_network_manager()/default_socket_factory()を取得
NetworkManagerRef/PacketSocketFactoryRefConnectionContext::default_network_manager()/default_socket_factory()で取得
PeerConnectionOfferAnswerOptions- Offer/Answer オプション (ICE リスタート、Simulcast レイヤー数など)
PeerConnectionObserver/PeerConnectionObserverHandler- イベントコールバック
PeerConnectionState- 接続状態
IceConnectionState- ICE 接続状態
IceGatheringState- ICE 収集状態
IceCandidateError- ICE 候補エラー
TlsCertPolicy- TLS 証明書ポリシー (Secure, InsecureNoCheck)
CreateSessionDescriptionObserver- SDP 生成コールバック
SetLocalDescriptionObserver- ローカル SDP 設定コールバック
SetRemoteDescriptionObserver- リモート SDP 設定コールバック
メディア
AudioTrackSource/AudioTrack- 音声トラック
VideoTrackSource/VideoTrack- 映像トラック
AdaptedVideoTrackSource- アダプティブ映像ソース
AdaptedSize/AdaptFrameResult- アダプティブフレーム結果
AudioDeviceModule- 音声デバイスインターフェース
AudioDeviceModuleAudioLayer- 音声デバイスレイヤー種別 (PlatformDefault, Dummy など)
AudioDeviceModuleHandler/AudioDeviceModuleStats- カスタム ADM handler と統計
AudioTransport/AudioTransportRef/AudioTransportHandler- 音声トランスポート
MediaStreamTrack- メディアストリームトラック
I420Buffer- I420 フォーマットの映像バッファ
VideoFrame/VideoFrameRef- 映像フレーム
VideoSink/VideoSinkHandler- 映像フレームシンク
VideoSinkWants- 映像シンク要求設定
SdpVideoFormat- 映像フォーマット
映像コーデック
VideoCodecRef/VideoCodecType/VideoCodecStatus- 映像コーデック共通型とステータス
ScalabilityMode- スケーラビリティーモード
VideoFrameType/VideoFrameTypeVector/VideoFrameTypeVectorRef- エンコード対象フレーム種別
EncodedImageBuffer/EncodedImage/EncodedImageRef- エンコード済み映像データ
CodecSpecificInfo/CodecSpecificInfoRef/H264PacketizationMode- コーデック固有情報
VideoEncoder- カスタム映像エンコーダー
VideoEncoderHandler/VideoEncoderFactoryHandler- エンコーダー / エンコーダーファクトリーの handler trait
VideoEncoderEncoderInfo/VideoEncoderSettingsRef/VideoEncoderRateControlParametersRef- エンコーダー設定とメタ情報
VideoEncoderEncodedImageCallback/VideoEncoderEncodedImageCallbackRef- エンコード完了 callback
VideoEncoderEncodedImageCallbackHandler- エンコード完了 callback の handler trait
VideoEncoderEncodedImageCallbackResult- エンコード完了 callback の戻り値
VideoEncoderEncodedImageCallbackResultError- エンコード完了 callback のエラーコード
VideoEncoderEncodedImageCallbackPtr- C API 側 callback ポインターのラッパー
VideoDecoder- カスタム映像デコーダー
VideoDecoderHandler/VideoDecoderFactoryHandler- デコーダー / デコーダーファクトリーの handler trait
VideoDecoderDecoderInfo/VideoDecoderSettingsRef- デコーダー設定とメタ情報
VideoDecoderDecodedImageCallbackRef/VideoDecoderDecodedImageCallbackPtr- デコード完了 callback
RTP
RtpCapabilities- コーデック能力
RtpCodecCapability- 個別コーデック設定
RtpCodecCapabilityVector- コーデック能力ベクタ
RtpEncodingParameters/RtpEncodingParametersVector- エンコーディング設定
RtpParameters- RTP 送信パラメータ
DegradationPreference- 映像劣化方針
RtpTransceiver/RtpSender/RtpReceiver- トランシーバー管理
RtpTransceiverDirection- 送受信方向
RtpTransceiverInit- トランシーバー初期化
RtpCodec- RTP コーデック情報
Resolution- 解像度
MediaType- メディア種別 (Audio / Video)
DataChannel
DataChannel- 双方向データ転送
DataChannelInit- DataChannel 初期化設定 (ordered, protocol)
DataChannelObserver/DataChannelObserverHandler- データチャネルイベント
DataChannelState- チャネル状態
JSEP
SessionDescription- SDP Offer/Answer
SdpType- SDP タイプ (Offer, Answer, PrAnswer, Rollback)
IceCandidate- ICE 候補
IceServer/IceServerVector- ICE サーバー設定
IceTransportsType- ICE トランスポートモード
SdpParseError- SDP パースエラー
統計
RTCStatsReport- 統計レポート
SSL/TLS
SSLCertificateVerifier/SSLCertificateVerifierHandler- TLS 証明書のカスタム検証
SSLCertificateRef- SSL 証明書の参照
SSLCertChainRef- SSL 証明書チェーンの参照
SSLIdentity- TURN-TLS 接続でのクライアント認証 (mTLS) 用の SSL アイデンティティ
エラー
RtcError- libwebrtc のエラー型
Error/Result- Rust エラー型
ユーティリティ
Environment- WebRTC 環境の初期化
Thread- スレッド管理
AudioEncoderFactory/AudioDecoderFactory- 音声コーデックファクトリ
VideoEncoderFactory/VideoDecoderFactory- 映像コーデックファクトリ
AudioProcessingBuilder- 音声処理パイプライン
RtcEventLogFactory- イベントログ
TimestampAligner- タイムスタンプ調整
abgr_to_i420/convert_from_i420/i420_to_nv12/nv12_to_i420/yuy2_to_i420- カラーフォーマット変換 (libyuv)
random_bytes/random_string- ランダム生成
time_millis/thread_sleep_ms- 時間ユーティリティ
version- クレートのバージョン取得
log/log::Severity- ログ機能 (
log_to_debug,enable_timestamps,enable_threads,print)
- ログ機能 (
rtc_log_verbose!/rtc_log_info!/rtc_log_warning!/rtc_log_error!- ログ出力マクロ
ビルド
デフォルト (prebuilt)
デフォルトでは、リリース時に GitHub Actions でビルドされた prebuilt ライブラリ (Linux/macOS は libwebrtc_c.a、Windows は webrtc_c.lib) と生成済みバインディング (bindings.rs) を GitHub Releases から自動ダウンロードします。
CMake、libclang、C++ コンパイラなどのインストールは不要です。
必要なもの:
- Rust 1.88 以上
curl(prebuilt ダウンロードに使用)tar(prebuilt 展開に使用)- Linux の場合:
libx11-dev(リンク時に必要)
# Linux
# macOS は curl と tar がプリインストール済みのため追加インストール不要
ソースビルド
C++ ラッパーのコード変更や、prebuilt が提供されていないプラットフォームでビルドする場合は source-build feature を有効にしてください。
[]
= { = "0.146", = ["source-build"] }
または cargo build 時に指定:
ソースビルドでは以下が自動的に行われます:
- CMake のダウンロード
- libwebrtc のダウンロード (webrtc-build の GitHub Releases から)
- C++ ラッパーのコンパイル
- bindgen によるバインディング生成
ソースビルドに必要なもの:
- Rust 1.88 以上
- Linux の場合:
- C++ コンパイラ (
build-essential) libclang-dev(bindgen が利用)libx11-dev
- C++ コンパイラ (
- macOS の場合:
- Xcode Command Line Tools
- Windows の場合:
- Visual Studio 2022 (
Desktop development with C++) C++ Clang tools for Windows(Microsoft.VisualStudio.Component.VC.Llvm.Clang)bindgen用のlibclangとして利用します (C++ コンパイルは MSVC を利用)
- Visual Studio 2022 (
# Linux
# macOS は Xcode Command Line Tools があれば OK
# Windows は Visual Studio Installer から
# - Desktop development with C++
# - C++ Clang tools for Windows
# を有効化してください
環境変数
WEBRTC_C_TARGET- ビルドターゲットを変更する場合に指定 (デフォルトはホスト環境に応じて自動判定)
ライセンス
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.