Remove uneeded function from media_packet.rs
This commit is contained in:
2 files changed
+10
-45
No files matched your search
+6
-22
@@ -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!();
|
||||
();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -345,7 +345,10 @@ impl<'a> MediaDataSubscriber<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn next_media_packet(&mut self, rx_timeout: Duration) -> std::result::Result<MediaData, Error> {
|
||||
pub fn next_media_packet(
|
||||
&mut self,
|
||||
rx_timeout: Duration,
|
||||
) -> std::result::Result<MediaData, Error> {
|
||||
// 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<MediaData, Error> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user