diff --git a/src/bc_protocol.rs b/src/bc_protocol.rs index 6e47b1a..52ab222 100644 --- a/src/bc_protocol.rs +++ b/src/bc_protocol.rs @@ -274,13 +274,7 @@ impl BcCamera { let mut media_sub = MediaDataSubscriber::from_bc_sub(&sub_video); loop { - let binary_data = media_sub.get_media_packet_of_kind( - &vec![ - MediaDataKind::VideoDataIframe, - MediaDataKind::VideoDataPframe, - ], - RX_TIMEOUT, - )?; + let binary_data = media_sub.next_media_packet(RX_TIMEOUT)?; // We now have a complete interesting packet. Send it to gst. // Process the packet match binary_data.kind() { @@ -288,29 +282,19 @@ impl BcCamera { data_out.write_all(binary_data.body())?; } MediaDataKind::AudioDataAac | MediaDataKind::AudioDataAdpcm => { - // We should not have a packet of this kind as we skip them until we get - // a packet of interest - unreachable!(); + (); } MediaDataKind::InfoData => { - // We should not have a packet of this kind as we skip them until we get - // a packet of interest - unreachable!(); + (); } MediaDataKind::Unknown => { - // We should not have a packet of this kind as we skip them until we get - // a packet of interest - unreachable!(); + (); } MediaDataKind::Invalid => { - // We should not have a packet of this kind as we skip them until we get - // a packet of interest - unreachable!(); + (); } MediaDataKind::Continue => { - // We should not have a packet of this kind as it would be attached - // to a packet of interest - unreachable!(); + (); } }; } diff --git a/src/bc_protocol/media_packet.rs b/src/bc_protocol/media_packet.rs index 26038c2..b726a14 100644 --- a/src/bc_protocol/media_packet.rs +++ b/src/bc_protocol/media_packet.rs @@ -345,7 +345,10 @@ impl<'a> MediaDataSubscriber<'a> { } } - fn next_media_packet(&mut self, rx_timeout: Duration) -> std::result::Result { + pub fn next_media_packet( + &mut self, + rx_timeout: Duration, + ) -> std::result::Result { // Find the first packet (does nothing if already at one) self.advance_to_media_packet(rx_timeout)?; @@ -375,26 +378,4 @@ impl<'a> MediaDataSubscriber<'a> { data: binary.collect(), }) } - - pub fn get_media_packet_of_kind( - &mut self, - interested_kinds: &[MediaDataKind], - rx_timeout: Duration, - ) -> std::result::Result { - let result_media_packet: MediaData; - - // Loop over the messages until we find one we want - loop { - let media_packet = self.next_media_packet(rx_timeout)?; - match media_packet.kind() { - n if interested_kinds.contains(&n) => { - result_media_packet = media_packet; - break; - } - _ => (), - }; - } - - return Ok(result_media_packet); - } }