rustfmt & signal_client improvememts
- handle ping message - recv now only returns on SignalResponse
This commit is contained in:
@@ -18,11 +18,12 @@ class IceCandidate {
|
||||
public:
|
||||
explicit IceCandidate(
|
||||
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate);
|
||||
|
||||
|
||||
rust::String sdp_mid() const;
|
||||
int sdp_mline_index() const;
|
||||
rust::String candidate() const; // TODO(theomonnom) Return livekit::Candidate instead of rust::String
|
||||
|
||||
rust::String candidate() const; // TODO(theomonnom) Return livekit::Candidate
|
||||
// instead of rust::String
|
||||
|
||||
rust::String stringify() const;
|
||||
std::unique_ptr<webrtc::IceCandidateInterface> release();
|
||||
|
||||
@@ -30,7 +31,9 @@ class IceCandidate {
|
||||
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate_;
|
||||
};
|
||||
|
||||
std::unique_ptr<IceCandidate> create_ice_candidate(rust::String sdp_mid, int sdp_mline_index, rust::String sdp);
|
||||
std::unique_ptr<IceCandidate> create_ice_candidate(rust::String sdp_mid,
|
||||
int sdp_mline_index,
|
||||
rust::String sdp);
|
||||
|
||||
static std::unique_ptr<IceCandidate> _unique_ice_candidate() {
|
||||
return nullptr; // Ignore
|
||||
@@ -49,7 +52,9 @@ class SessionDescription {
|
||||
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description_;
|
||||
};
|
||||
|
||||
std::unique_ptr<SessionDescription> create_session_description(SdpType type, rust::String sdp);
|
||||
std::unique_ptr<SessionDescription> create_session_description(
|
||||
SdpType type,
|
||||
rust::String sdp);
|
||||
|
||||
static std::unique_ptr<SessionDescription> _unique_session_description() {
|
||||
return nullptr; // Ignore
|
||||
|
||||
@@ -69,7 +69,8 @@ create_native_add_ice_candidate_observer(
|
||||
|
||||
class NativePeerConnectionObserver : public webrtc::PeerConnectionObserver {
|
||||
public:
|
||||
explicit NativePeerConnectionObserver(std::shared_ptr<RTCRuntime> rtc_runtime,
|
||||
explicit NativePeerConnectionObserver(
|
||||
std::shared_ptr<RTCRuntime> rtc_runtime,
|
||||
rust::Box<PeerConnectionObserverWrapper> observer);
|
||||
|
||||
void OnSignalingChange(
|
||||
|
||||
@@ -28,7 +28,8 @@ class PeerConnectionFactory {
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_factory_;
|
||||
};
|
||||
|
||||
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory(std::shared_ptr<RTCRuntime> rtc_runtime);
|
||||
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory(
|
||||
std::shared_ptr<RTCRuntime> rtc_runtime);
|
||||
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(
|
||||
RTCConfiguration conf);
|
||||
} // namespace livekit
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace livekit {
|
||||
DataChannel::DataChannel(
|
||||
std::shared_ptr<RTCRuntime> rtc_runtime,
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel)
|
||||
: rtc_runtime_(std::move(rtc_runtime)), data_channel_(std::move(data_channel)) {}
|
||||
: rtc_runtime_(std::move(rtc_runtime)),
|
||||
data_channel_(std::move(data_channel)) {}
|
||||
|
||||
void DataChannel::register_observer(NativeDataChannelObserver& observer) {
|
||||
data_channel_->RegisterObserver(&observer);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::fmt::Debug;
|
||||
use std::slice;
|
||||
|
||||
#[cxx::bridge(namespace = "livekit")]
|
||||
|
||||
@@ -71,7 +71,7 @@ pub mod ffi {
|
||||
fn create_session_description(sdp_type: SdpType, sdp: String) -> Result<UniquePtr<SessionDescription>>;
|
||||
|
||||
fn _unique_ice_candidate() -> UniquePtr<IceCandidate>; // Ignore
|
||||
fn _unique_session_description() -> UniquePtr<SessionDescription>; // Ignore
|
||||
fn _unique_session_description() -> UniquePtr<SessionDescription>; // Ignore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +84,11 @@ impl Display for ffi::SdpParseError {
|
||||
}
|
||||
|
||||
unsafe impl Send for ffi::SessionDescription {}
|
||||
|
||||
unsafe impl Sync for ffi::SessionDescription {}
|
||||
|
||||
unsafe impl Send for ffi::IceCandidate {}
|
||||
|
||||
unsafe impl Sync for ffi::IceCandidate {}
|
||||
|
||||
impl ffi::SdpParseError {
|
||||
|
||||
@@ -152,7 +152,8 @@ void NativePeerConnectionObserver::OnRemoveStream(
|
||||
|
||||
void NativePeerConnectionObserver::OnDataChannel(
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
observer_->on_data_channel(std::make_unique<DataChannel>(rtc_runtime_, data_channel));
|
||||
observer_->on_data_channel(
|
||||
std::make_unique<DataChannel>(rtc_runtime_, data_channel));
|
||||
}
|
||||
|
||||
void NativePeerConnectionObserver::OnRenegotiationNeeded() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::fmt::Debug;
|
||||
|
||||
use cxx::UniquePtr;
|
||||
|
||||
use crate::candidate::ffi::Candidate;
|
||||
@@ -259,21 +260,27 @@ pub mod ffi {
|
||||
|
||||
// https://webrtc.github.io/webrtc-org/native-code/native-apis/
|
||||
unsafe impl Send for ffi::PeerConnection {}
|
||||
|
||||
unsafe impl Sync for ffi::PeerConnection {}
|
||||
|
||||
unsafe impl Send for ffi::NativePeerConnectionObserver {}
|
||||
|
||||
unsafe impl Sync for ffi::NativePeerConnectionObserver {}
|
||||
|
||||
unsafe impl Sync for ffi::NativeAddIceCandidateObserver {}
|
||||
|
||||
unsafe impl Send for ffi::NativeAddIceCandidateObserver {}
|
||||
|
||||
unsafe impl Sync for ffi::NativeSetRemoteSdpObserverHandle {}
|
||||
|
||||
unsafe impl Send for ffi::NativeSetRemoteSdpObserverHandle {}
|
||||
|
||||
unsafe impl Sync for ffi::NativeSetLocalSdpObserverHandle {}
|
||||
|
||||
unsafe impl Send for ffi::NativeSetLocalSdpObserverHandle {}
|
||||
|
||||
unsafe impl Sync for ffi::NativeCreateSdpObserverHandle {}
|
||||
|
||||
unsafe impl Send for ffi::NativeCreateSdpObserverHandle {}
|
||||
|
||||
impl Default for ffi::RTCOfferAnswerOptions {
|
||||
|
||||
@@ -67,7 +67,8 @@ std::unique_ptr<PeerConnection> PeerConnectionFactory::create_peer_connection(
|
||||
return std::make_unique<PeerConnection>(rtc_runtime_, result.value());
|
||||
}
|
||||
|
||||
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory(std::shared_ptr<RTCRuntime> rtc_runtime) {
|
||||
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory(
|
||||
std::shared_ptr<RTCRuntime> rtc_runtime) {
|
||||
return std::make_unique<PeerConnectionFactory>(std::move(rtc_runtime));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
use std::any::Any;
|
||||
|
||||
use crate::jsep::CreateSdpObserver;
|
||||
use crate::peer_connection::PeerConnectionObserver;
|
||||
|
||||
#[cxx::bridge(namespace = "livekit")]
|
||||
pub mod ffi {
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -40,7 +35,7 @@ pub mod ffi {
|
||||
|
||||
type PeerConnection = crate::peer_connection::ffi::PeerConnection;
|
||||
type NativePeerConnectionObserver =
|
||||
crate::peer_connection::ffi::NativePeerConnectionObserver;
|
||||
crate::peer_connection::ffi::NativePeerConnectionObserver;
|
||||
type PeerConnectionFactory;
|
||||
type NativeRTCConfiguration;
|
||||
type RTCRuntime = crate::webrtc::ffi::RTCRuntime;
|
||||
@@ -59,4 +54,5 @@ pub mod ffi {
|
||||
}
|
||||
|
||||
unsafe impl Send for ffi::PeerConnectionFactory {}
|
||||
|
||||
unsafe impl Sync for ffi::PeerConnectionFactory {}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::rtc_error::ffi::RTCErrorType;
|
||||
use std::error::Error;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
use crate::rtc_error::ffi::RTCErrorType;
|
||||
|
||||
// cxx doesn't support custom Exception type, so we serialize RTCError inside the cxx::Exception "what" string
|
||||
|
||||
#[cxx::bridge(namespace = "livekit")]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use cxx::UniquePtr;
|
||||
|
||||
#[cxx::bridge(namespace = "livekit")]
|
||||
pub mod ffi {
|
||||
unsafe extern "C++" {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use cxx::UniquePtr;
|
||||
|
||||
#[cxx::bridge(namespace = "livekit")]
|
||||
pub mod ffi {
|
||||
unsafe extern "C++" {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace livekit {
|
||||
RTCRuntime::RTCRuntime() {
|
||||
//rtc::LogMessage::LogToDebug(rtc::LS_INFO);
|
||||
// rtc::LogMessage::LogToDebug(rtc::LS_INFO);
|
||||
RTC_LOG(LS_INFO) << "RTCRuntime()";
|
||||
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use cxx::UniquePtr;
|
||||
|
||||
#[cxx::bridge(namespace = "livekit")]
|
||||
pub mod ffi {
|
||||
unsafe extern "C++" {
|
||||
@@ -12,4 +10,5 @@ pub mod ffi {
|
||||
}
|
||||
|
||||
unsafe impl Send for ffi::RTCRuntime {}
|
||||
|
||||
unsafe impl Sync for ffi::RTCRuntime {}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::error::Error;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use cxx::UniquePtr;
|
||||
use log::trace;
|
||||
|
||||
use libwebrtc_sys::data_channel as sys_dc;
|
||||
|
||||
pub use sys_dc::ffi::{Priority, DataState};
|
||||
pub use sys_dc::ffi::{DataState, Priority};
|
||||
|
||||
pub struct DataChannel {
|
||||
cxx_handle: UniquePtr<sys_dc::ffi::DataChannel>,
|
||||
@@ -31,7 +31,7 @@ impl Display for DataSendError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for DataSendError { }
|
||||
impl Error for DataSendError {}
|
||||
|
||||
impl DataChannel {
|
||||
pub(crate) fn new(cxx_handle: UniquePtr<sys_dc::ffi::DataChannel>) -> Self {
|
||||
@@ -100,7 +100,8 @@ impl DataChannel {
|
||||
}
|
||||
|
||||
pub type OnStateChangeHandler = Box<dyn FnMut() + Send + Sync>;
|
||||
pub type OnMessageHandler = Box<dyn FnMut(&[u8], bool) + Send + Sync>; // data, is_binary
|
||||
pub type OnMessageHandler = Box<dyn FnMut(&[u8], bool) + Send + Sync>;
|
||||
// data, is_binary
|
||||
pub type OnBufferedAmountChangeHandler = Box<dyn FnMut(u64) + Send + Sync>;
|
||||
|
||||
struct InternalDataChannelObserver {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use std::fmt::{Debug, Display, Formatter, write};
|
||||
use cxx::UniquePtr;
|
||||
use libwebrtc_sys::jsep as sys_jsep;
|
||||
use std::fmt::{Debug, Display, Formatter};
|
||||
|
||||
pub use sys_jsep::ffi::{SdpType, SdpParseError};
|
||||
use cxx::UniquePtr;
|
||||
|
||||
use libwebrtc_sys::jsep as sys_jsep;
|
||||
pub use sys_jsep::ffi::{SdpParseError, SdpType};
|
||||
|
||||
// TODO Maybe we can replace that by a serialized IceCandidateInit
|
||||
pub struct IceCandidate {
|
||||
|
||||
@@ -363,16 +363,16 @@ pub type OnRenegotiationNeededHandler = Box<dyn FnMut() + Send + Sync>;
|
||||
pub type OnNegotiationNeededEventHandler = Box<dyn FnMut(u32) + Send + Sync>;
|
||||
pub type OnIceConnectionChangeHandler = Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
||||
pub type OnStandardizedIceConnectionChangeHandler =
|
||||
Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
||||
Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
||||
pub type OnConnectionChangeHandler = Box<dyn FnMut(PeerConnectionState) + Send + Sync>;
|
||||
pub type OnIceGatheringChangeHandler = Box<dyn FnMut(IceGatheringState) + Send + Sync>;
|
||||
pub type OnIceCandidateHandler = Box<dyn FnMut(IceCandidate) + Send + Sync>;
|
||||
pub type OnIceCandidateErrorHandler =
|
||||
Box<dyn FnMut(String, i32, String, i32, String) + Send + Sync>;
|
||||
Box<dyn FnMut(String, i32, String, i32, String) + Send + Sync>;
|
||||
pub type OnIceCandidatesRemovedHandler = Box<dyn FnMut(Vec<IceCandidate>) + Send + Sync>;
|
||||
pub type OnIceConnectionReceivingChangeHandler = Box<dyn FnMut(bool) + Send + Sync>;
|
||||
pub type OnIceSelectedCandidatePairChangedHandler =
|
||||
Box<dyn FnMut(libwebrtc_sys::peer_connection::ffi::CandidatePairChangeEvent) + Send + Sync>;
|
||||
Box<dyn FnMut(libwebrtc_sys::peer_connection::ffi::CandidatePairChangeEvent) + Send + Sync>;
|
||||
pub type OnAddTrackHandler = Box<dyn FnMut(RtpReceiver, Vec<MediaStream>) + Send + Sync>;
|
||||
pub type OnTrackHandler = Box<dyn FnMut(RtpTransceiver) + Send + Sync>;
|
||||
pub type OnRemoveTrackHandler = Box<dyn FnMut(RtpReceiver) + Send + Sync>;
|
||||
@@ -387,16 +387,16 @@ pub(crate) struct InternalObserver {
|
||||
on_negotiation_needed_event_handler: Arc<Mutex<Option<OnNegotiationNeededEventHandler>>>,
|
||||
on_ice_connection_change_handler: Arc<Mutex<Option<OnIceConnectionChangeHandler>>>,
|
||||
on_standardized_ice_connection_change_handler:
|
||||
Arc<Mutex<Option<OnStandardizedIceConnectionChangeHandler>>>,
|
||||
Arc<Mutex<Option<OnStandardizedIceConnectionChangeHandler>>>,
|
||||
on_connection_change_handler: Arc<Mutex<Option<OnConnectionChangeHandler>>>,
|
||||
on_ice_gathering_change_handler: Arc<Mutex<Option<OnIceGatheringChangeHandler>>>,
|
||||
on_ice_candidate_handler: Arc<Mutex<Option<OnIceCandidateHandler>>>,
|
||||
on_ice_candidate_error_handler: Arc<Mutex<Option<OnIceCandidateErrorHandler>>>,
|
||||
on_ice_candidates_removed_handler: Arc<Mutex<Option<OnIceCandidatesRemovedHandler>>>,
|
||||
on_ice_connection_receiving_change_handler:
|
||||
Arc<Mutex<Option<OnIceConnectionReceivingChangeHandler>>>,
|
||||
Arc<Mutex<Option<OnIceConnectionReceivingChangeHandler>>>,
|
||||
on_ice_selected_candidate_pair_changed_handler:
|
||||
Arc<Mutex<Option<OnIceSelectedCandidatePairChangedHandler>>>,
|
||||
Arc<Mutex<Option<OnIceSelectedCandidatePairChangedHandler>>>,
|
||||
on_add_track_handler: Arc<Mutex<Option<OnAddTrackHandler>>>,
|
||||
on_track_handler: Arc<Mutex<Option<OnTrackHandler>>>,
|
||||
on_remove_track_handler: Arc<Mutex<Option<OnRemoveTrackHandler>>>,
|
||||
@@ -626,6 +626,7 @@ impl sys_pc::PeerConnectionObserver for InternalObserver {
|
||||
mod tests {
|
||||
use log::trace;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use libwebrtc_sys::peer_connection::ffi::RTCOfferAnswerOptions;
|
||||
use libwebrtc_sys::peer_connection_factory::ffi::{ContinualGatheringPolicy, IceTransportsType};
|
||||
|
||||
@@ -652,7 +653,7 @@ mod tests {
|
||||
password: "".into(),
|
||||
}],
|
||||
continual_gathering_policy: ContinualGatheringPolicy::GatherOnce,
|
||||
ice_transport_type: IceTransportsType::All
|
||||
ice_transport_type: IceTransportsType::All,
|
||||
};
|
||||
|
||||
let mut bob = factory.create_peer_connection(config.clone()).unwrap();
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
// TODO(theomonnom) Wrap the RTCError ffi so we can use Option(u16)
|
||||
pub use libwebrtc_sys::rtc_error::ffi::RTCError;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use cxx::{SharedPtr};
|
||||
use cxx::SharedPtr;
|
||||
|
||||
use libwebrtc_sys::webrtc as sys_rtc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user