@@ -23,11 +23,26 @@ use crate::rtp_transceiver::*;
23
23
/// TrackLocalWriter is the Writer for outbound RTP Packets
24
24
#[ async_trait]
25
25
pub trait TrackLocalWriter : fmt:: Debug {
26
+ /// write_rtp_with_attributes encrypts a RTP packet and writes to the connection.
27
+ /// attributes are delivered to the interceptor chain
28
+ async fn write_rtp_with_attributes (
29
+ & self ,
30
+ pkt : & rtp:: packet:: Packet ,
31
+ attr : & Attributes ,
32
+ ) -> Result < usize > ;
33
+
26
34
/// write_rtp encrypts a RTP packet and writes to the connection
27
- async fn write_rtp ( & self , p : & rtp:: packet:: Packet ) -> Result < usize > ;
35
+ async fn write_rtp ( & self , pkt : & rtp:: packet:: Packet ) -> Result < usize > {
36
+ let attr = Attributes :: new ( ) ;
37
+ self . write_rtp_with_attributes ( pkt, & attr) . await
38
+ }
28
39
29
40
/// write encrypts and writes a full RTP packet
30
- async fn write ( & self , b : & [ u8 ] ) -> Result < usize > ;
41
+ async fn write ( & self , mut b : & [ u8 ] ) -> Result < usize > {
42
+ let pkt = rtp:: packet:: Packet :: unmarshal ( & mut b) ?;
43
+ let attr = Attributes :: new ( ) ;
44
+ self . write_rtp_with_attributes ( & pkt, & attr) . await
45
+ }
31
46
}
32
47
33
48
/// TrackLocalContext is the Context passed when a TrackLocal has been Binded/Unbinded from a PeerConnection, and used
@@ -149,22 +164,20 @@ impl std::fmt::Debug for InterceptorToTrackLocalWriter {
149
164
150
165
#[ async_trait]
151
166
impl TrackLocalWriter for InterceptorToTrackLocalWriter {
152
- async fn write_rtp ( & self , pkt : & rtp:: packet:: Packet ) -> Result < usize > {
167
+ async fn write_rtp_with_attributes (
168
+ & self ,
169
+ pkt : & rtp:: packet:: Packet ,
170
+ attr : & Attributes ,
171
+ ) -> Result < usize > {
153
172
if self . is_sender_paused ( ) {
154
173
return Ok ( 0 ) ;
155
174
}
156
175
157
176
let interceptor_rtp_writer = self . interceptor_rtp_writer . lock ( ) . await ;
158
177
if let Some ( writer) = & * interceptor_rtp_writer {
159
- let a = Attributes :: new ( ) ;
160
- Ok ( writer. write ( pkt, & a) . await ?)
178
+ Ok ( writer. write ( pkt, attr) . await ?)
161
179
} else {
162
180
Ok ( 0 )
163
181
}
164
182
}
165
-
166
- async fn write ( & self , mut b : & [ u8 ] ) -> Result < usize > {
167
- let pkt = rtp:: packet:: Packet :: unmarshal ( & mut b) ?;
168
- self . write_rtp ( & pkt) . await
169
- }
170
183
}
0 commit comments