mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-01-24 13:13:16 -05:00
upgrade to retina 0.0.3
The new version is more efficient.
This commit is contained in:
parent
9cb19d5c82
commit
4c95df5ba7
10
server/Cargo.lock
generated
10
server/Cargo.lock
generated
@ -1,5 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.15.1"
|
||||
@ -1874,9 +1876,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "retina"
|
||||
version = "0.0.1"
|
||||
version = "0.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ac613fa999c0d1075a825705e01ab302f7bab09410ed8df5d65a63eb9e922da"
|
||||
checksum = "151ca8320bb2fb48dc29a9106b7e6fcde088720cb7895b3a3aacac7e09faa68b"
|
||||
dependencies = [
|
||||
"async-stream",
|
||||
"base64",
|
||||
@ -1950,9 +1952,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rtp-rs"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1110d695193d446e901de09921ffbf2d86ae351bbfde9c5b53863ce177e17f5"
|
||||
checksum = "d4ed274a5b3d36c4434cff6a4de1b42f43e64ae326b1cfa72d13d9037a314355"
|
||||
|
||||
[[package]]
|
||||
name = "rtsp-types"
|
||||
|
@ -46,7 +46,7 @@ nom = "6.0.0"
|
||||
parking_lot = { version = "0.11.1", features = [] }
|
||||
protobuf = { git = "https://github.com/stepancheg/rust-protobuf" }
|
||||
reffers = "0.6.0"
|
||||
retina = "0.0.1"
|
||||
retina = "0.0.3"
|
||||
ring = "0.16.2"
|
||||
rusqlite = "0.25.3"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
@ -3,7 +3,6 @@
|
||||
// SPDX-License-Identifier: GPL-v3.0-or-later WITH GPL-3.0-linking-exception.
|
||||
|
||||
use crate::h264;
|
||||
use bytes::Buf;
|
||||
use cstr::cstr;
|
||||
use failure::format_err;
|
||||
use failure::{bail, Error};
|
||||
@ -386,7 +385,7 @@ impl Opener for RetinaOpener {
|
||||
)?;
|
||||
let stream = Box::new(RetinaStream {
|
||||
frame_rx,
|
||||
data: Vec::new(),
|
||||
frame: None,
|
||||
});
|
||||
Ok((extra_data, stream))
|
||||
}
|
||||
@ -420,27 +419,23 @@ impl RetinaOpener {
|
||||
|
||||
struct RetinaStream {
|
||||
frame_rx: tokio::sync::mpsc::Receiver<Result<retina::codec::VideoFrame, Error>>,
|
||||
data: Vec<u8>,
|
||||
frame: Option<retina::codec::VideoFrame>,
|
||||
}
|
||||
|
||||
impl Stream for RetinaStream {
|
||||
fn next(&mut self) -> Result<VideoFrame, Error> {
|
||||
let mut frame = self
|
||||
.frame_rx
|
||||
.blocking_recv()
|
||||
.ok_or_else(|| format_err!("stream ended"))??;
|
||||
self.data.clear();
|
||||
while frame.has_remaining() {
|
||||
let chunk = frame.chunk();
|
||||
self.data.extend_from_slice(chunk);
|
||||
let len = chunk.len();
|
||||
frame.advance(len);
|
||||
}
|
||||
// TODO: use Option::insert after bumping MSRV to 1.53.
|
||||
self.frame = Some(
|
||||
self.frame_rx
|
||||
.blocking_recv()
|
||||
.ok_or_else(|| format_err!("stream ended"))??,
|
||||
);
|
||||
let frame = self.frame.as_ref().unwrap();
|
||||
Ok(VideoFrame {
|
||||
pts: frame.timestamp.elapsed(),
|
||||
duration: 0,
|
||||
is_key: frame.is_random_access_point,
|
||||
data: &self.data,
|
||||
data: &frame.data()[..],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user