Skip to content

Commit 17db241

Browse files
committed
define RtpReceiver/RtpSender/RtpTransceiver trait APIs
1 parent 72d8205 commit 17db241

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

src/rtp_transceiver.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
11
//! Async Media API
22
3-
use rtc::shared::error::Result;
4-
3+
use crate::media_stream::{TrackLocal, TrackRemote};
4+
use rtc::media_stream::MediaStreamId;
5+
use rtc::rtp_transceiver::rtp_receiver::{RTCRtpContributingSource, RTCRtpSynchronizationSource};
6+
use rtc::rtp_transceiver::rtp_sender::{
7+
RTCRtpCapabilities, RTCRtpCodec, RTCRtpReceiveParameters, RTCRtpSendParameters,
8+
RTCSetParameterOptions, RtpCodecKind,
9+
};
510
pub use rtc::rtp_transceiver::{
611
RTCRtpReceiverId, RTCRtpSenderId, RTCRtpTransceiverDirection, RTCRtpTransceiverInit,
712
};
13+
use rtc::shared::error::Result;
14+
use rtc::statistics::StatsSelector;
15+
use rtc::statistics::report::RTCStatsReport;
16+
use std::sync::Arc;
17+
use std::time::Instant;
818

919
#[async_trait::async_trait]
1020
pub trait RtpReceiver: Send + Sync + 'static {
11-
async fn close(&self) -> Result<()>;
21+
async fn track(&self) -> Arc<dyn TrackRemote>;
22+
async fn get_capabilities(&self, kind: RtpCodecKind) -> Option<RTCRtpCapabilities>;
23+
async fn get_parameters(&mut self) -> RTCRtpReceiveParameters;
24+
async fn get_contributing_sources(&self) -> Vec<RTCRtpContributingSource>;
25+
async fn get_synchronization_sources(&self) -> Vec<RTCRtpSynchronizationSource>;
26+
async fn get_stats(&self, now: Instant, selector: StatsSelector) -> RTCStatsReport;
1227
}
1328

1429
#[async_trait::async_trait]
1530
pub trait RtpSender: Send + Sync + 'static {
16-
async fn close(&self) -> Result<()>;
31+
async fn track(&self) -> Arc<dyn TrackLocal>;
32+
async fn get_capabilities(&self, kind: RtpCodecKind) -> Option<RTCRtpCapabilities>;
33+
async fn set_parameters(
34+
&mut self,
35+
parameters: RTCRtpSendParameters,
36+
set_parameter_options: Option<RTCSetParameterOptions>,
37+
) -> Result<()>;
38+
async fn get_parameters(&mut self) -> RTCRtpSendParameters;
39+
async fn replace_track(&mut self, track: Arc<dyn TrackLocal>) -> Result<()>;
40+
async fn set_streams(&mut self, streams: Vec<MediaStreamId>);
41+
async fn get_stats(&self, now: Instant, selector: StatsSelector) -> RTCStatsReport;
1742
}
1843

1944
#[async_trait::async_trait]
2045
pub trait RtpTransceiver: Send + Sync + 'static {
21-
async fn close(&self) -> Result<()>;
46+
async fn mid(&self) -> Option<String>;
47+
async fn sender(&self) -> Option<Arc<dyn RtpSender>>;
48+
async fn receiver(&self) -> Option<Arc<dyn RtpReceiver>>;
49+
async fn direction(&self) -> RTCRtpTransceiverDirection;
50+
async fn current_direction(&self) -> RTCRtpTransceiverDirection;
51+
async fn stop(&self) -> Result<()>;
52+
async fn set_codec_preferences(&self, codecs: Vec<RTCRtpCodec>) -> Result<()>;
2253
}

0 commit comments

Comments
 (0)