implement Debug on WebRTC structs
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
extern crate core;
|
||||
extern crate core;
|
||||
|
||||
pub mod proto {
|
||||
include!(concat!(env!("OUT_DIR"), "/livekit.rs"));
|
||||
}
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
use std::fmt;
|
||||
|
||||
macro_rules! id_str {
|
||||
($($name:ident;)*) => {
|
||||
$(
|
||||
impl $name {
|
||||
pub fn new(str: String) -> Self {
|
||||
Self(str)
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for $name {
|
||||
fn from(str: String) -> $name {
|
||||
$name(str)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name> for String {
|
||||
fn from(id: $name) -> String {
|
||||
id.0
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<$name> for String {
|
||||
fn eq(&self, u: &$name) -> bool {
|
||||
*self == *u.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name> for String {
|
||||
fn from(id: $name) -> String {
|
||||
id.0
|
||||
impl fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str(&self.0)
|
||||
}
|
||||
}
|
||||
)*
|
||||
@@ -23,13 +41,13 @@ macro_rules! id_str {
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||
pub struct ParticipantSid(pub String);
|
||||
pub struct ParticipantSid(String);
|
||||
|
||||
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||
pub struct ParticipantIdentity(pub String);
|
||||
pub struct ParticipantIdentity(String);
|
||||
|
||||
#[derive(Clone, Default, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||
pub struct TrackSid(pub String);
|
||||
pub struct TrackSid(String);
|
||||
|
||||
id_str! {
|
||||
ParticipantSid;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use core::num::flt2dec::Sign;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
@@ -18,7 +18,9 @@ pub struct DataChannel {
|
||||
|
||||
impl Debug for DataChannel {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
write!(f, "DataChannel[{}]", self.label())
|
||||
f.debug_struct("DataChannel")
|
||||
.field("label", &self.label())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
use cxx::UniquePtr;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
||||
use libwebrtc_sys::media_stream as sys_ms;
|
||||
|
||||
pub use sys_ms::ffi::TrackState;
|
||||
|
||||
pub struct MediaStreamTrack {
|
||||
cxx_handle: UniquePtr<sys_ms::ffi::MediaStreamTrack>,
|
||||
}
|
||||
|
||||
impl Debug for MediaStreamTrack {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
f.debug_struct("MediaStreamTrack")
|
||||
.field("id", &self.id())
|
||||
.field("kind", &self.kind())
|
||||
.field("enabled", &self.enabled())
|
||||
.field("state", &self.state())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl MediaStreamTrack {
|
||||
pub(crate) fn new(cxx_handle: UniquePtr<sys_ms::ffi::MediaStreamTrack>) -> Self {
|
||||
Self { cxx_handle }
|
||||
@@ -38,14 +49,20 @@ pub struct MediaStream {
|
||||
cxx_handle: UniquePtr<sys_ms::ffi::MediaStream>,
|
||||
}
|
||||
|
||||
impl Debug for MediaStream {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
f.debug_struct("MediaStream")
|
||||
.field("id", &self.id())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl MediaStream {
|
||||
pub(crate) fn new(cxx_handle: UniquePtr<sys_ms::ffi::MediaStream>) -> Self {
|
||||
Self {
|
||||
cxx_handle
|
||||
}
|
||||
Self { cxx_handle }
|
||||
}
|
||||
|
||||
pub fn id(&self) -> String {
|
||||
self.cxx_handle.id()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@@ -31,6 +32,18 @@ pub struct PeerConnection {
|
||||
native_observer: UniquePtr<sys_pc::ffi::NativePeerConnectionObserver>,
|
||||
}
|
||||
|
||||
impl Debug for PeerConnection {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
f.debug_struct("PeerConnection")
|
||||
.field("signaling_state", &self.signaling_state())
|
||||
.field("ice_connection_state", &self.ice_connection_state())
|
||||
.field("ice_gathering_state", &self.ice_gathering_state())
|
||||
.field("local_description", &self.local_description())
|
||||
.field("remote_description", &self.remote_description())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl PeerConnection {
|
||||
pub(crate) fn new(
|
||||
cxx_handle: UniquePtr<sys_pc::ffi::PeerConnection>,
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
use crate::media_stream::MediaStreamTrack;
|
||||
use cxx::UniquePtr;
|
||||
use libwebrtc_sys::rtp_receiver as sys_rec;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
||||
pub struct RtpReceiver {
|
||||
cxx_handle: UniquePtr<sys_rec::ffi::RtpReceiver>,
|
||||
}
|
||||
|
||||
impl Debug for RtpReceiver {
|
||||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
f.debug_struct("RtpReceiver")
|
||||
.field("track", &self.track())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl RtpReceiver {
|
||||
pub(crate) fn new(cxx_handle: UniquePtr<sys_rec::ffi::RtpReceiver>) -> Self {
|
||||
Self { cxx_handle }
|
||||
|
||||
Reference in New Issue
Block a user