Skip to content

Commit 8ec0a1c

Browse files
rogurotusrainliu
authored andcommitted
refarctor params
1 parent 3cbcf98 commit 8ec0a1c

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

examples/examples/broadcast/broadcast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async fn main() -> Result<()> {
155155
tokio::spawn(async move {
156156
// Create Track that we send video back to browser on
157157
let local_track = Arc::new(TrackLocalStaticRTP::new(
158-
track.codec().await.capability,
158+
track.codec().capability,
159159
"video".to_owned(),
160160
"webrtc-rs".to_owned(),
161161
));

examples/examples/reflect/reflect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ async fn main() -> Result<()> {
242242
println!(
243243
"Track has started, of type {}: {}",
244244
track.payload_type(),
245-
track.codec().await.capability.mime_type
245+
track.codec().capability.mime_type
246246
);
247247
// Read RTP packets being sent to webrtc-rs
248248
while let Ok((rtp, _)) = track.read_rtp().await {
@@ -255,7 +255,7 @@ async fn main() -> Result<()> {
255255
println!(
256256
"on_track finished, of type {}: {}",
257257
track.payload_type(),
258-
track.codec().await.capability.mime_type
258+
track.codec().capability.mime_type
259259
);
260260
});
261261

examples/examples/save-to-disk-h264/save-to-disk-h264.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ async fn main() -> Result<()> {
233233
let h264_writer2 = Arc::clone(&h264_writer);
234234
let ogg_writer2 = Arc::clone(&ogg_writer);
235235
Box::pin(async move {
236-
let codec = track.codec().await;
236+
let codec = track.codec();
237237
let mime_type = codec.capability.mime_type.to_lowercase();
238238
if mime_type == MIME_TYPE_OPUS.to_lowercase() {
239239
println!("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)");

examples/examples/save-to-disk-vpx/save-to-disk-vpx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async fn main() -> Result<()> {
258258
let ivf_writer2 = Arc::clone(&ivf_writer);
259259
let ogg_writer2 = Arc::clone(&ogg_writer);
260260
Box::pin(async move {
261-
let codec = track.codec().await;
261+
let codec = track.codec();
262262
let mime_type = codec.capability.mime_type.to_lowercase();
263263
if mime_type == MIME_TYPE_OPUS.to_lowercase() {
264264
println!("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)");

examples/examples/swap-tracks/swap-tracks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ async fn main() -> Result<()> {
153153
println!(
154154
"Track has started, of type {}: {}",
155155
track.payload_type(),
156-
track.codec().await.capability.mime_type
156+
track.codec().capability.mime_type
157157
);
158158

159159
let mut last_timestamp = 0;
@@ -196,7 +196,7 @@ async fn main() -> Result<()> {
196196
println!(
197197
"Track has ended, of type {}: {}",
198198
track.payload_type(),
199-
track.codec().await.capability.mime_type
199+
track.codec().capability.mime_type
200200
);
201201
});
202202

webrtc/src/rtp_transceiver/rtp_receiver/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ impl RTCRtpReceiver {
477477
}
478478

479479
let current_track = &t.track;
480-
current_track.set_codec(codec.clone()).await;
480+
current_track.set_codec(codec.clone());
481481
current_track.set_params(params.clone()).await;
482482
}
483483
}
@@ -752,7 +752,7 @@ impl RTCRtpReceiver {
752752
if t.track.rid() == rid {
753753
t.track.set_kind(self.kind);
754754
if let Some(codec) = params.codecs.first() {
755-
t.track.set_codec(codec.clone()).await;
755+
t.track.set_codec(codec.clone());
756756
}
757757
t.track.set_params(params.clone()).await;
758758
t.track

webrtc/src/rtp_transceiver/rtp_receiver/rtp_receiver_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async fn test_set_rtp_parameters() -> Result<()> {
9292
receiver.set_rtp_parameters(P.clone()).await;
9393

9494
if let Some(t) = receiver.track().await {
95-
let incoming_track_codecs = t.codec().await;
95+
let incoming_track_codecs = t.codec();
9696

9797
assert_eq!(P.header_extensions, t.params().await.header_extensions);
9898
assert_eq!(

webrtc/src/rtp_transceiver/rtp_sender/rtp_sender_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ async fn test_rtp_sender_replace_track() -> Result<()> {
7474

7575
let last = pkt.payload[pkt.payload.len() - 1];
7676
if last == 0xAA {
77-
assert_eq!(track.codec().await.capability.mime_type, MIME_TYPE_VP8);
77+
assert_eq!(track.codec().capability.mime_type, MIME_TYPE_VP8);
7878
let _ = seen_packet_a_tx2.send(()).await;
7979
} else if last == 0xBB {
80-
assert_eq!(track.codec().await.capability.mime_type, MIME_TYPE_H264);
80+
assert_eq!(track.codec().capability.mime_type, MIME_TYPE_H264);
8181
let _ = seen_packet_b_tx2.send(()).await;
8282
} else {
8383
panic!("Unexpected RTP Data {last:02x}");

webrtc/src/track/track_local/track_local_static_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ async fn test_track_local_static_payload_type() -> Result<()> {
259259
let on_track_fired_tx2 = Arc::clone(&on_track_fired_tx);
260260
Box::pin(async move {
261261
assert_eq!(track.payload_type(), 100);
262-
assert_eq!(track.codec().await.capability.mime_type, MIME_TYPE_VP8);
262+
assert_eq!(track.codec().capability.mime_type, MIME_TYPE_VP8);
263263
{
264264
log::debug!("onTrackFiredFunc!!!");
265265
let mut done = on_track_fired_tx2.lock().await;

webrtc/src/track/track_remote/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct TrackRemote {
4848
kind: AtomicU8, //RTPCodecType,
4949
ssrc: AtomicU32, //SSRC,
5050
codec: SyncMutex<RTCRtpCodecParameters>,
51-
pub(crate) params: Mutex<RTCRtpParameters>,
51+
pub(crate) params: SyncMutex<RTCRtpParameters>,
5252
rid: String,
5353

5454
media_engine: Arc<MediaEngine>,
@@ -173,23 +173,23 @@ impl TrackRemote {
173173
}
174174

175175
/// codec gets the Codec of the track
176-
pub async fn codec(&self) -> RTCRtpCodecParameters {
176+
pub fn codec(&self) -> RTCRtpCodecParameters {
177177
let codec = self.codec.lock();
178178
codec.clone()
179179
}
180180

181-
pub async fn set_codec(&self, codec: RTCRtpCodecParameters) {
181+
pub fn set_codec(&self, codec: RTCRtpCodecParameters) {
182182
let mut c = self.codec.lock();
183183
*c = codec;
184184
}
185185

186186
pub async fn params(&self) -> RTCRtpParameters {
187-
let p = self.params.lock().await;
187+
let p = self.params.lock();
188188
p.clone()
189189
}
190190

191191
pub async fn set_params(&self, params: RTCRtpParameters) {
192-
let mut p = self.params.lock().await;
192+
let mut p = self.params.lock();
193193
*p = params;
194194
}
195195

@@ -266,7 +266,7 @@ impl TrackRemote {
266266
};
267267
}
268268
{
269-
let mut params = self.params.lock().await;
269+
let mut params = self.params.lock();
270270
*params = p;
271271
}
272272
}

0 commit comments

Comments
 (0)