@@ -13,6 +13,7 @@ struct ReceiverStreamInternal {
1313
1414 packets : Vec < u64 > ,
1515 started : bool ,
16+ wait_for_probe : bool ,
1617 seq_num_cycles : u16 ,
1718 last_seq_num : i32 ,
1819 last_report_seq_num : i32 ,
@@ -40,7 +41,7 @@ impl ReceiverStreamInternal {
4041 ( self . packets [ pos / 64 ] & ( 1 << ( pos % 64 ) ) ) != 0
4142 }
4243
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 ) {
4445 if !self . started {
4546 // first frame
4647 self . started = true ;
@@ -79,6 +80,7 @@ impl ReceiverStreamInternal {
7980
8081 self . last_rtp_time_rtp = pkt. header . timestamp ;
8182 self . last_rtp_time_time = now;
83+ self . wait_for_probe &= is_probe;
8284 }
8385
8486 fn process_sender_report ( & mut self , now : SystemTime , sr : & rtcp:: sender_report:: SenderReport ) {
@@ -158,6 +160,7 @@ impl ReceiverStream {
158160 clock_rate : u32 ,
159161 reader : Arc < dyn RTPReader + Send + Sync > ,
160162 now : Option < FnTimeGen > ,
163+ wait_for_probe : bool ,
161164 ) -> Self {
162165 let receiver_ssrc = rand:: random :: < u32 > ( ) ;
163166 ReceiverStream {
@@ -171,6 +174,7 @@ impl ReceiverStream {
171174
172175 packets : vec ! [ 0u64 ; 128 ] ,
173176 started : false ,
177+ wait_for_probe,
174178 seq_num_cycles : 0 ,
175179 last_seq_num : 0 ,
176180 last_report_seq_num : 0 ,
@@ -184,9 +188,9 @@ impl ReceiverStream {
184188 }
185189 }
186190
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 ) {
188192 let mut internal = self . internal . lock ( ) ;
189- internal. process_rtp ( now, pkt) ;
193+ internal. process_rtp ( now, pkt, is_probe ) ;
190194 }
191195
192196 pub ( crate ) fn process_sender_report (
@@ -198,9 +202,17 @@ impl ReceiverStream {
198202 internal. process_sender_report ( now, sr) ;
199203 }
200204
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 > {
202209 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) )
204216 }
205217}
206218
@@ -213,14 +225,16 @@ impl RTPReader for ReceiverStream {
213225 buf : & mut [ u8 ] ,
214226 a : & Attributes ,
215227 ) -> Result < ( rtp:: packet:: Packet , Attributes ) > {
228+ let is_probe = a. get ( & crate :: ATTR_READ_PROBE ) . is_some_and ( |v| * v != 0 ) ;
229+
216230 let ( pkt, attr) = self . parent_rtp_reader . read ( buf, a) . await ?;
217231
218232 let now = if let Some ( f) = & self . now {
219233 f ( )
220234 } else {
221235 SystemTime :: now ( )
222236 } ;
223- self . process_rtp ( now, & pkt) ;
237+ self . process_rtp ( now, & pkt, is_probe ) ;
224238
225239 Ok ( ( pkt, attr) )
226240 }
0 commit comments