rustfmt & signal_client improvememts

- handle ping message
- recv now only returns on SignalResponse
This commit is contained in:
Théo Monnom
2022-10-03 15:59:43 +02:00
parent 2213a70142
commit d64c7e5e08
35 changed files with 1584 additions and 174 deletions
@@ -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 {}