implement Debug on WebRTC structs
This commit is contained in:
@@ -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