@@ -13,6 +13,7 @@ struct ReceiverStreamInternal {
13
13
14
14
packets : Vec < u64 > ,
15
15
started : bool ,
16
+ wait_for_probe : bool ,
16
17
seq_num_cycles : u16 ,
17
18
last_seq_num : i32 ,
18
19
last_report_seq_num : i32 ,
@@ -40,7 +41,7 @@ impl ReceiverStreamInternal {
40
41
( self . packets [ pos / 64 ] & ( 1 << ( pos % 64 ) ) ) != 0
41
42
}
42
43
43
- fn process_rtp ( & mut self , now : SystemTime , pkt : & rtp:: packet:: Packet ) {
44
+ fn process_rtp ( & mut self , now : SystemTime , pkt : & rtp:: packet:: Packet , is_probe : bool ) {
44
45
if !self . started {
45
46
// first frame
46
47
self . started = true ;
@@ -79,6 +80,7 @@ impl ReceiverStreamInternal {
79
80
80
81
self . last_rtp_time_rtp = pkt. header . timestamp ;
81
82
self . last_rtp_time_time = now;
83
+ self . wait_for_probe &= is_probe;
82
84
}
83
85
84
86
fn process_sender_report ( & mut self , now : SystemTime , sr : & rtcp:: sender_report:: SenderReport ) {
@@ -158,6 +160,7 @@ impl ReceiverStream {
158
160
clock_rate : u32 ,
159
161
reader : Arc < dyn RTPReader + Send + Sync > ,
160
162
now : Option < FnTimeGen > ,
163
+ wait_for_probe : bool ,
161
164
) -> Self {
162
165
let receiver_ssrc = rand:: random :: < u32 > ( ) ;
163
166
ReceiverStream {
@@ -171,6 +174,7 @@ impl ReceiverStream {
171
174
172
175
packets : vec ! [ 0u64 ; 128 ] ,
173
176
started : false ,
177
+ wait_for_probe,
174
178
seq_num_cycles : 0 ,
175
179
last_seq_num : 0 ,
176
180
last_report_seq_num : 0 ,
@@ -184,9 +188,9 @@ impl ReceiverStream {
184
188
}
185
189
}
186
190
187
- pub ( crate ) fn process_rtp ( & self , now : SystemTime , pkt : & rtp:: packet:: Packet ) {
191
+ pub ( crate ) fn process_rtp ( & self , now : SystemTime , pkt : & rtp:: packet:: Packet , is_probe : bool ) {
188
192
let mut internal = self . internal . lock ( ) ;
189
- internal. process_rtp ( now, pkt) ;
193
+ internal. process_rtp ( now, pkt, is_probe ) ;
190
194
}
191
195
192
196
pub ( crate ) fn process_sender_report (
@@ -198,9 +202,17 @@ impl ReceiverStream {
198
202
internal. process_sender_report ( now, sr) ;
199
203
}
200
204
201
- pub ( crate ) fn generate_report ( & self , now : SystemTime ) -> rtcp:: receiver_report:: ReceiverReport {
205
+ pub ( crate ) fn generate_report (
206
+ & self ,
207
+ now : SystemTime ,
208
+ ) -> Option < rtcp:: receiver_report:: ReceiverReport > {
202
209
let mut internal = self . internal . lock ( ) ;
203
- internal. generate_report ( now)
210
+
211
+ if internal. wait_for_probe {
212
+ return None ;
213
+ }
214
+
215
+ Some ( internal. generate_report ( now) )
204
216
}
205
217
}
206
218
@@ -213,14 +225,16 @@ impl RTPReader for ReceiverStream {
213
225
buf : & mut [ u8 ] ,
214
226
a : & Attributes ,
215
227
) -> Result < ( rtp:: packet:: Packet , Attributes ) > {
228
+ let is_probe = a. get ( & crate :: ATTR_READ_PROBE ) . is_some_and ( |v| * v != 0 ) ;
229
+
216
230
let ( pkt, attr) = self . parent_rtp_reader . read ( buf, a) . await ?;
217
231
218
232
let now = if let Some ( f) = & self . now {
219
233
f ( )
220
234
} else {
221
235
SystemTime :: now ( )
222
236
} ;
223
- self . process_rtp ( now, & pkt) ;
237
+ self . process_rtp ( now, & pkt, is_probe ) ;
224
238
225
239
Ok ( ( pkt, attr) )
226
240
}
0 commit comments