Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Nov 2, 2023
1 parent 40bd9dc commit 6dc6b99
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 103 deletions.
2 changes: 0 additions & 2 deletions libwebrtc/src/audio_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub struct AudioFrame<'a> {
pub sample_rate: u32,
pub num_channels: u32,
pub samples_per_channel: u32,
pub timestamp_us: i64,
}

impl AudioFrame<'_> {
Expand All @@ -31,7 +30,6 @@ impl AudioFrame<'_> {
sample_rate,
num_channels,
samples_per_channel,
timestamp_us: 0,
}
}
}
2 changes: 1 addition & 1 deletion libwebrtc/src/data_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use crate::{imp::data_channel as dc_imp, rtp_parameters::Priority};
use serde::Deserialize;
use std::{default, fmt::Debug, str::Utf8Error};
use std::{fmt::Debug, str::Utf8Error};
use thiserror::Error;

#[derive(Clone, Debug)]
Expand Down
18 changes: 9 additions & 9 deletions libwebrtc/src/native/peer_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use crate::rtp_receiver::RtpReceiver;
use crate::rtp_sender::RtpSender;
use crate::rtp_transceiver::RtpTransceiver;
use crate::rtp_transceiver::RtpTransceiverInit;
use crate::stats::QualityLimitationReason;
use crate::stats::RtcStats;
use crate::MediaType;
use crate::RtcErrorType;
Expand All @@ -51,6 +50,7 @@ use tokio::sync::oneshot;
use webrtc_sys::data_channel as sys_dc;
use webrtc_sys::jsep as sys_jsep;
use webrtc_sys::peer_connection as sys_pc;
use webrtc_sys::peer_connection_factory as sys_pcf;
use webrtc_sys::rtc_error as sys_err;

impl From<OfferOptions> for sys_pc::ffi::RtcOfferAnswerOptions {
Expand Down Expand Up @@ -205,7 +205,7 @@ impl PeerConnection {
options: OfferOptions,
) -> Result<SessionDescription, RtcError> {
let (tx, mut rx) = mpsc::channel::<Result<SessionDescription, RtcError>>(1);
let ctx = Box::new(sys_pc::AsyncContext(Box::new(tx)));
let ctx = Box::new(sys_pc::PeerContext(Box::new(tx)));
type CtxType = mpsc::Sender<Result<SessionDescription, RtcError>>;

self.sys_handle.create_offer(
Expand All @@ -231,7 +231,7 @@ impl PeerConnection {
options: AnswerOptions,
) -> Result<SessionDescription, RtcError> {
let (tx, mut rx) = mpsc::channel::<Result<SessionDescription, RtcError>>(1);
let ctx = Box::new(sys_pc::AsyncContext(Box::new(tx)));
let ctx = Box::new(sys_pc::PeerContext(Box::new(tx)));
type CtxType = mpsc::Sender<Result<SessionDescription, RtcError>>;

self.sys_handle.create_answer(
Expand All @@ -254,7 +254,7 @@ impl PeerConnection {

pub async fn set_local_description(&self, desc: SessionDescription) -> Result<(), RtcError> {
let (tx, rx) = oneshot::channel::<Result<(), RtcError>>();
let ctx = Box::new(sys_pc::AsyncContext(Box::new(tx)));
let ctx = Box::new(sys_pc::PeerContext(Box::new(tx)));

self.sys_handle
.set_local_description(desc.handle.sys_handle, ctx, |ctx, err| {
Expand All @@ -275,7 +275,7 @@ impl PeerConnection {

pub async fn set_remote_description(&self, desc: SessionDescription) -> Result<(), RtcError> {
let (tx, rx) = oneshot::channel::<Result<(), RtcError>>();
let ctx = Box::new(sys_pc::AsyncContext(Box::new(tx)));
let ctx = Box::new(sys_pc::PeerContext(Box::new(tx)));

self.sys_handle
.set_remote_description(desc.handle.sys_handle, ctx, |ctx, err| {
Expand All @@ -299,7 +299,7 @@ impl PeerConnection {

pub async fn add_ice_candidate(&self, candidate: IceCandidate) -> Result<(), RtcError> {
let (tx, rx) = oneshot::channel::<Result<(), RtcError>>();
let ctx = Box::new(sys_pc::AsyncContext(Box::new(tx)));
let ctx = Box::new(sys_pc::PeerContext(Box::new(tx)));

self.sys_handle
.add_ice_candidate(candidate.handle.sys_handle, ctx, |ctx, err| {
Expand Down Expand Up @@ -444,7 +444,7 @@ impl PeerConnection {

pub async fn get_stats(&self) -> Result<Vec<RtcStats>, RtcError> {
let (tx, rx) = oneshot::channel::<Result<Vec<RtcStats>, RtcError>>();
let ctx = Box::new(sys_pc::AsyncContext(Box::new(tx)));
let ctx = Box::new(sys_pc::PeerContext(Box::new(tx)));

self.sys_handle.get_stats(ctx, |ctx, stats| {
let tx = ctx
Expand Down Expand Up @@ -549,7 +549,7 @@ pub struct PeerObserver {
pub track_handler: Mutex<Option<OnTrack>>,
}

impl sys_pc::PeerConnectionObserver for PeerObserver {
impl sys_pcf::PeerConnectionObserver for PeerObserver {
fn on_signaling_change(&self, new_state: sys_pc::ffi::SignalingState) {
if let Some(f) = self.signaling_change_handler.lock().as_mut() {
f(new_state.into());
Expand Down Expand Up @@ -635,7 +635,7 @@ impl sys_pc::PeerConnectionObserver for PeerObserver {

fn on_ice_selected_candidate_pair_changed(
&self,
_event: sys_pc::ffi::CandidatePairChangeEvent,
_event: sys_pcf::ffi::CandidatePairChangeEvent,
) {
}

Expand Down
14 changes: 6 additions & 8 deletions libwebrtc/src/native/peer_connection_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use cxx::UniquePtr;
use lazy_static::lazy_static;
use parking_lot::Mutex;
use std::sync::Arc;
use webrtc_sys::peer_connection as sys_pc;
use webrtc_sys::peer_connection_factory as sys_pcf;
use webrtc_sys::rtc_error as sys_err;
use webrtc_sys::webrtc as sys_rtc;
Expand Down Expand Up @@ -78,13 +77,12 @@ impl PeerConnectionFactory {
config: RtcConfiguration,
) -> Result<PeerConnection, RtcError> {
let observer = Arc::new(imp_pc::PeerObserver::default());
let native_observer = sys_pc::ffi::create_native_peer_connection_observer(Box::new(
sys_pc::PeerConnectionObserverWrapper::new(observer.clone()),
));

let res = self
.sys_handle
.create_peer_connection(config.into(), native_observer);
let res = self.sys_handle.create_peer_connection(
config.into(),
Box::new(sys_pcf::PeerConnectionObserverWrapper::new(
observer.clone(),
)),
);

match res {
Ok(sys_handle) => Ok(PeerConnection {
Expand Down
2 changes: 1 addition & 1 deletion libwebrtc/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub enum RtcStats {
pub enum QualityLimitationReason {
#[default]
None,
CPU,
Cpu,
Bandwidth,
Other,
}
Expand Down
24 changes: 12 additions & 12 deletions livekit-ffi/protocol/stats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ enum IceCandidateType {
}

enum IceServerTransportProtocol {
UDP = 0;
TCP = 1;
TLS = 2;
TRANSPORT_UDP = 0;
TRANSPORT_TCP = 1;
TRANSPORT_TLS = 2;
}

enum IceTcpCandidateType {
ACTIVE = 0;
PASSIVE = 1;
SO = 2;
CANDIDATE_ACTIVE = 0;
CANDIDATE_PASSIVE = 1;
CANDIDATE_SO = 2;
}

message RtcStats {
Expand Down Expand Up @@ -132,7 +132,7 @@ message RtcStats {

message MediaPlayout {
RtcStatsData rtc = 1;
AudioSourceStats audio_playout = 2;
AudioPlayoutStats audio_playout = 2;
}

message PeerConnection {
Expand All @@ -147,7 +147,7 @@ message RtcStats {

message Transport {
RtcStatsData rtc = 1;
CandidatePairStats candidate_pair = 2;
TransportStats transport = 2;
}

message CandidatePair {
Expand Down Expand Up @@ -403,7 +403,7 @@ message CandidatePairStats {
string transport_id = 1;
string local_candidate_id = 2;
string remote_candidate_id = 3;
IceCandidatePairState state = 4;
optional IceCandidatePairState state = 4;
bool nominated = 5;
uint64 packets_sent = 6;
uint64 packets_received = 7;
Expand All @@ -429,15 +429,15 @@ message IceCandidateStats {
string address = 2;
int32 port = 3;
string protocol = 4;
IceCandidateType candidate_type = 5;
optional IceCandidateType candidate_type = 5;
int32 priority = 6;
string url = 7;
IceServerTransportProtocol relay_protocol = 8;
optional IceServerTransportProtocol relay_protocol = 8;
string foundation = 9;
string related_address = 10;
int32 related_port = 11;
string username_fragment = 12;
IceTcpCandidateType tcp_type = 13;
optional IceTcpCandidateType tcp_type = 13;
}

message CertificateStats {
Expand Down
Loading

0 comments on commit 6dc6b99

Please sign in to comment.