@@ -14,6 +14,8 @@ use std::pin::Pin;
14
14
use std:: sync:: atomic:: { AtomicU32 , AtomicU8 , AtomicUsize , Ordering } ;
15
15
use std:: sync:: { Arc , Weak } ;
16
16
use tokio:: sync:: Mutex ;
17
+ use util:: sync:: Mutex as SyncMutex ;
18
+
17
19
use util:: Unmarshal ;
18
20
19
21
lazy_static ! {
@@ -38,14 +40,14 @@ struct TrackRemoteInternal {
38
40
pub struct TrackRemote {
39
41
tid : usize ,
40
42
41
- id : Mutex < String > ,
42
- stream_id : Mutex < String > ,
43
+ id : SyncMutex < String > ,
44
+ stream_id : SyncMutex < String > ,
43
45
44
46
receive_mtu : usize ,
45
47
payload_type : AtomicU8 , //PayloadType,
46
48
kind : AtomicU8 , //RTPCodecType,
47
49
ssrc : AtomicU32 , //SSRC,
48
- codec : Mutex < RTCRtpCodecParameters > ,
50
+ codec : SyncMutex < RTCRtpCodecParameters > ,
49
51
pub ( crate ) params : Mutex < RTCRtpParameters > ,
50
52
rid : String ,
51
53
@@ -110,24 +112,24 @@ impl TrackRemote {
110
112
/// id is the unique identifier for this Track. This should be unique for the
111
113
/// stream, but doesn't have to globally unique. A common example would be 'audio' or 'video'
112
114
/// and StreamID would be 'desktop' or 'webcam'
113
- pub async fn id ( & self ) -> String {
114
- let id = self . id . lock ( ) . await ;
115
+ pub fn id ( & self ) -> String {
116
+ let id = self . id . lock ( ) ;
115
117
id. clone ( )
116
118
}
117
119
118
- pub async fn set_id ( & self , s : String ) {
119
- let mut id = self . id . lock ( ) . await ;
120
+ pub fn set_id ( & self , s : String ) {
121
+ let mut id = self . id . lock ( ) ;
120
122
* id = s;
121
123
}
122
124
123
125
/// stream_id is the group this track belongs too. This must be unique
124
- pub async fn stream_id ( & self ) -> String {
125
- let stream_id = self . stream_id . lock ( ) . await ;
126
+ pub fn stream_id ( & self ) -> String {
127
+ let stream_id = self . stream_id . lock ( ) ;
126
128
stream_id. clone ( )
127
129
}
128
130
129
- pub async fn set_stream_id ( & self , s : String ) {
130
- let mut stream_id = self . stream_id . lock ( ) . await ;
131
+ pub fn set_stream_id ( & self , s : String ) {
132
+ let mut stream_id = self . stream_id . lock ( ) ;
131
133
* stream_id = s;
132
134
}
133
135
@@ -166,18 +168,18 @@ impl TrackRemote {
166
168
}
167
169
168
170
/// msid gets the Msid of the track
169
- pub async fn msid ( & self ) -> String {
170
- self . stream_id ( ) . await + " " + self . id ( ) . await . as_str ( )
171
+ pub fn msid ( & self ) -> String {
172
+ format ! ( "{} {}" , self . stream_id ( ) , self . id ( ) )
171
173
}
172
174
173
175
/// codec gets the Codec of the track
174
176
pub async fn codec ( & self ) -> RTCRtpCodecParameters {
175
- let codec = self . codec . lock ( ) . await ;
177
+ let codec = self . codec . lock ( ) ;
176
178
codec. clone ( )
177
179
}
178
180
179
181
pub async fn set_codec ( & self , codec : RTCRtpCodecParameters ) {
180
- let mut c = self . codec . lock ( ) . await ;
182
+ let mut c = self . codec . lock ( ) ;
181
183
* c = codec;
182
184
}
183
185
@@ -256,7 +258,7 @@ impl TrackRemote {
256
258
}
257
259
self . payload_type . store ( payload_type, Ordering :: SeqCst ) ;
258
260
{
259
- let mut codec = self . codec . lock ( ) . await ;
261
+ let mut codec = self . codec . lock ( ) ;
260
262
* codec = if let Some ( codec) = p. codecs . first ( ) {
261
263
codec. clone ( )
262
264
} else {
0 commit comments