Remove uneeded function from media_packet.rs

This commit is contained in:
QuantumEntangledAndy committed 2020-08-09 15:23:14 +07:00
1 parent 024659ee45
commit 07257ede2d
2 files changed
+10 -45

No files matched your search

+6 -22
View File
@@ -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!();
();
}
};
}
+4 -23
View File
@@ -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);
}
}