Jump to live if more than 15s difference
This commit is contained in:
2 files changed
+44
-44
No files matched your search
+16
-16
@@ -7,7 +7,7 @@ use crate::bc::model::*;
|
|||||||
use crate::bc::xml::*;
|
use crate::bc::xml::*;
|
||||||
use crate::{Credentials, Error, Result};
|
use crate::{Credentials, Error, Result};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use std::io;
|
use nom::AsBytes;
|
||||||
use tokio_util::codec::{Decoder, Encoder};
|
use tokio_util::codec::{Decoder, Encoder};
|
||||||
|
|
||||||
pub(crate) struct BcCodex {
|
pub(crate) struct BcCodex {
|
||||||
@@ -48,24 +48,24 @@ impl Decoder for BcCodex {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn decode_eof(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>> {
|
fn decode_eof(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>> {
|
||||||
// match self.decode(buf)? {
|
|
||||||
// Some(frame) => Ok(Some(frame)),
|
|
||||||
// None => {
|
|
||||||
// if buf.is_empty() {
|
|
||||||
// Ok(None)
|
|
||||||
// } else {
|
|
||||||
// Err(io::Error::new(
|
|
||||||
// io::ErrorKind::Other,
|
|
||||||
// format!("bytes remaining on BC stream: {:X?}", buf),
|
|
||||||
// )
|
|
||||||
// .into())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
match self.decode(buf)? {
|
match self.decode(buf)? {
|
||||||
Some(frame) => Ok(Some(frame)),
|
Some(frame) => Ok(Some(frame)),
|
||||||
None => Ok(None),
|
None => {
|
||||||
|
if buf.is_empty() {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
log::debug!("bytes remaining on BC stream: {:X?}", buf.as_bytes());
|
||||||
|
// Right after this we seem to get an issue with the camera dropping us
|
||||||
|
// Needs probing
|
||||||
|
// \xf0\xde\xbc\n\x03\0\0\0@\x9c\0\0\0\x01\x04\0\xc8\0\0\0\0\0\0\0\t\x11\xc6\xa0\x12\xdb\xf7:E\x96*
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// match self.decode(buf)? {
|
||||||
|
// Some(frame) => Ok(Some(frame)),
|
||||||
|
// None => Ok(None),
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>> {
|
fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>> {
|
||||||
|
|||||||
+28
-28
@@ -296,11 +296,11 @@ impl NeoMediaSenders {
|
|||||||
occ.remove();
|
occ.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if let Err(e) = occ.get_mut().process_jump_to_live(&self.buffer).await {
|
if let Err(e) = occ.get_mut().process_jump_to_live(&self.buffer).await {
|
||||||
// debug!("Could not handle jump to live: {:?}", e);
|
debug!("Could not handle jump to live: {:?}", e);
|
||||||
// occ.remove();
|
occ.remove();
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
if let Err(e) = occ.get_mut().process_buffer(&self.buffer).await {
|
if let Err(e) = occ.get_mut().process_buffer(&self.buffer).await {
|
||||||
debug!("Could not send client data: {:?}", e);
|
debug!("Could not send client data: {:?}", e);
|
||||||
occ.remove();
|
occ.remove();
|
||||||
@@ -563,26 +563,26 @@ impl NeoMediaSender {
|
|||||||
Ok(last_sent_time)
|
Ok(last_sent_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
// async fn process_jump_to_live(&mut self, buffer: &NeoBuffer) -> AnyResult<()> {
|
async fn process_jump_to_live(&mut self, buffer: &NeoBuffer) -> AnyResult<()> {
|
||||||
// if self.inited {
|
if self.inited {
|
||||||
// if let (Some(buffer_start), Some(buffer_end)) = (buffer.start_time(), buffer.end_time())
|
if let (Some(buffer_start), Some(buffer_end)) = (buffer.start_time(), buffer.end_time())
|
||||||
// {
|
{
|
||||||
// let runtime = self.get_buftime().unwrap_or(self.last_sent_time);
|
let runtime = self.get_buftime().unwrap_or(self.last_sent_time);
|
||||||
// if runtime < buffer_start.saturating_sub(LATENCY * 2)
|
if runtime < buffer_start.saturating_sub(15 * SECS)
|
||||||
// || runtime > buffer_end.saturating_add(LATENCY * 2)
|
|| runtime > buffer_end.saturating_add(15 * SECS)
|
||||||
// {
|
{
|
||||||
// debug!(
|
debug!(
|
||||||
// "Outside buffer jumping to live: {:?} < {:?} < {:?}",
|
"Outside buffer jumping to live: {:?} < {:?} < {:?}",
|
||||||
// Duration::from_micros(buffer_start.try_into().unwrap_or(0)),
|
Duration::from_micros(buffer_start.try_into().unwrap_or(0)),
|
||||||
// Duration::from_micros(runtime.try_into().unwrap_or(0)),
|
Duration::from_micros(runtime.try_into().unwrap_or(0)),
|
||||||
// Duration::from_micros(buffer_end.try_into().unwrap_or(0))
|
Duration::from_micros(buffer_end.try_into().unwrap_or(0))
|
||||||
// );
|
);
|
||||||
// self.jump_to_live(buffer).await?;
|
self.jump_to_live(buffer).await?;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// Ok(())
|
Ok(())
|
||||||
// }
|
}
|
||||||
|
|
||||||
fn get_runtime(&self) -> Option<FrameTime> {
|
fn get_runtime(&self) -> Option<FrameTime> {
|
||||||
if let Some(appsrc) = self.vid.as_ref() {
|
if let Some(appsrc) = self.vid.as_ref() {
|
||||||
@@ -598,9 +598,9 @@ impl NeoMediaSender {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn get_buftime(&self) -> Option<FrameTime> {
|
fn get_buftime(&self) -> Option<FrameTime> {
|
||||||
// self.get_runtime().map(|time| self.runtime_to_buftime(time))
|
self.get_runtime().map(|time| self.runtime_to_buftime(time))
|
||||||
// }
|
}
|
||||||
|
|
||||||
async fn send_buffer(&mut self, media: &BcMedia) -> AnyResult<bool> {
|
async fn send_buffer(&mut self, media: &BcMedia) -> AnyResult<bool> {
|
||||||
if self.inited && self.playing {
|
if self.inited && self.playing {
|
||||||
|
|||||||
Reference in new issue
Block a user