mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-12-03 06:22:32 -05:00
lose "extern crate" everywhere (Rust 2018 edition)
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
|
||||
//! Tools for implementing a `http_serve::Entity` body composed from many "slices".
|
||||
|
||||
use crate::base::Error;
|
||||
use base::Error;
|
||||
use failure::Fail;
|
||||
use futures::{Stream, stream};
|
||||
use hyper::body::Payload;
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
|
||||
//! Subcommand to check the database and sample file dir for errors.
|
||||
|
||||
use crate::db::check;
|
||||
use db::check;
|
||||
use failure::Error;
|
||||
use serde::Deserialize;
|
||||
|
||||
static USAGE: &'static str = r#"
|
||||
Checks database integrity.
|
||||
|
||||
@@ -28,17 +28,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate cursive;
|
||||
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::traits::{Boxable, Identifiable, Finder};
|
||||
use self::cursive::views;
|
||||
use crate::db::{self, writer};
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use cursive::Cursive;
|
||||
use cursive::traits::{Boxable, Identifiable, Finder};
|
||||
use cursive::views;
|
||||
use db::writer;
|
||||
use failure::Error;
|
||||
use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use super::{decode_size, encode_size};
|
||||
|
||||
/// Builds a `CameraChange` from an active `edit_camera_dialog`.
|
||||
|
||||
@@ -28,13 +28,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate cursive;
|
||||
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::traits::{Boxable, Identifiable};
|
||||
use self::cursive::views;
|
||||
use crate::db::{self, writer};
|
||||
use cursive::Cursive;
|
||||
use cursive::traits::{Boxable, Identifiable};
|
||||
use cursive::views;
|
||||
use db::writer;
|
||||
use failure::Error;
|
||||
use log::{debug, trace};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::rc::Rc;
|
||||
|
||||
@@ -33,14 +33,14 @@
|
||||
//! This code is a bit messy, but it's essentially a prototype. Eventually Moonfire NVR's
|
||||
//! configuration will likely be almost entirely done through a web-based UI.
|
||||
|
||||
extern crate cursive;
|
||||
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::views;
|
||||
use crate::clock;
|
||||
use crate::db;
|
||||
use base::clock;
|
||||
use cursive::Cursive;
|
||||
use cursive::views;
|
||||
use db;
|
||||
use failure::Error;
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
use std::fmt::Write;
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -28,12 +28,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate cursive;
|
||||
|
||||
use self::cursive::Cursive;
|
||||
use self::cursive::traits::{Boxable, Identifiable};
|
||||
use self::cursive::views;
|
||||
use crate::db;
|
||||
use cursive::Cursive;
|
||||
use cursive::traits::{Boxable, Identifiable};
|
||||
use cursive::views;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Builds a `UserChange` from an active `edit_user_dialog`.
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::db;
|
||||
use failure::Error;
|
||||
use log::info;
|
||||
use serde::Deserialize;
|
||||
|
||||
static USAGE: &'static str = r#"
|
||||
Initializes a database.
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::db::dir;
|
||||
use db::dir;
|
||||
use docopt;
|
||||
use failure::{Error, Fail};
|
||||
use libc;
|
||||
use rusqlite;
|
||||
use serde::Deserialize;
|
||||
use std::path::Path;
|
||||
|
||||
mod check;
|
||||
|
||||
@@ -28,20 +28,22 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::clock;
|
||||
use crate::db::{self, dir, writer};
|
||||
use failure::Error;
|
||||
use base::clock;
|
||||
use crate::stream;
|
||||
use crate::streamer;
|
||||
use crate::web;
|
||||
use db::{dir, writer};
|
||||
use failure::{Error, bail};
|
||||
use fnv::FnvHashMap;
|
||||
use futures::{Future, Stream};
|
||||
use log::{error, info, warn};
|
||||
use serde::Deserialize;
|
||||
use std::error::Error as StdError;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::thread;
|
||||
use crate::stream;
|
||||
use crate::streamer;
|
||||
use tokio;
|
||||
use tokio_signal::unix::{Signal, SIGINT, SIGTERM};
|
||||
use crate::web;
|
||||
|
||||
// These are used in a hack to get the name of the current time zone (e.g. America/Los_Angeles).
|
||||
// They seem to be correct for Linux and macOS at least.
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::db::recording;
|
||||
use failure::Error;
|
||||
use serde::Deserialize;
|
||||
|
||||
const USAGE: &'static str = r#"
|
||||
Usage: moonfire-nvr ts <ts>...
|
||||
@@ -44,7 +44,7 @@ struct Args {
|
||||
pub fn run() -> Result<(), Error> {
|
||||
let arg: Args = super::parse_args(&USAGE)?;
|
||||
for timestamp in &arg.arg_ts {
|
||||
let t = recording::Time::parse(timestamp)?;
|
||||
let t = db::recording::Time::parse(timestamp)?;
|
||||
println!("{} == {}", t, t.0);
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
///
|
||||
/// See `guide/schema.md` for more information.
|
||||
|
||||
use crate::db;
|
||||
use failure::Error;
|
||||
use serde::Deserialize;
|
||||
|
||||
const USAGE: &'static str = r#"
|
||||
Upgrade to the latest database schema.
|
||||
|
||||
@@ -41,7 +41,8 @@
|
||||
//! would be more trouble than it's worth.
|
||||
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use failure::Error;
|
||||
use failure::{Error, bail};
|
||||
use lazy_static::lazy_static;
|
||||
use regex::bytes::Regex;
|
||||
|
||||
// See ISO/IEC 14496-10 table 7-1 - NAL unit type codes, syntax element categories, and NAL unit
|
||||
@@ -248,7 +249,7 @@ pub fn transform_sample_data(annexb_sample: &[u8], avc_sample: &mut Vec<u8>) ->
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::db::testutil;
|
||||
use db::testutil;
|
||||
|
||||
const ANNEX_B_TEST_INPUT: [u8; 35] = [
|
||||
0x00, 0x00, 0x00, 0x01, 0x67, 0x4d, 0x00, 0x1f,
|
||||
|
||||
@@ -28,8 +28,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::db::{self, auth::SessionHash};
|
||||
use failure::Error;
|
||||
use db::auth::SessionHash;
|
||||
use failure::{Error, format_err};
|
||||
use serde::Serialize;
|
||||
use serde::ser::{SerializeMap, SerializeSeq, Serializer};
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops::Not;
|
||||
|
||||
40
src/main.rs
40
src/main.rs
@@ -30,44 +30,8 @@
|
||||
|
||||
#![cfg_attr(all(feature="nightly", test), feature(test))]
|
||||
|
||||
extern crate base64;
|
||||
extern crate bytes;
|
||||
extern crate byteorder;
|
||||
extern crate core;
|
||||
extern crate docopt;
|
||||
extern crate futures;
|
||||
extern crate futures_cpupool;
|
||||
#[macro_use] extern crate failure;
|
||||
extern crate fnv;
|
||||
extern crate http;
|
||||
extern crate http_serve;
|
||||
extern crate hyper;
|
||||
#[macro_use] extern crate lazy_static;
|
||||
extern crate libc;
|
||||
#[macro_use] extern crate log;
|
||||
extern crate reffers;
|
||||
extern crate rusqlite;
|
||||
extern crate memchr;
|
||||
extern crate memmap;
|
||||
extern crate moonfire_base as base;
|
||||
extern crate moonfire_db as db;
|
||||
extern crate moonfire_ffmpeg;
|
||||
extern crate mylog;
|
||||
extern crate openssl;
|
||||
extern crate parking_lot;
|
||||
extern crate regex;
|
||||
extern crate ring;
|
||||
extern crate serde;
|
||||
#[macro_use] extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
extern crate smallvec;
|
||||
extern crate time;
|
||||
extern crate tokio;
|
||||
extern crate tokio_signal;
|
||||
extern crate url;
|
||||
extern crate uuid;
|
||||
|
||||
use crate::base::clock as clock;
|
||||
use log::{error, info};
|
||||
use serde::Deserialize;
|
||||
|
||||
mod body;
|
||||
mod cmds;
|
||||
|
||||
36
src/mp4.rs
36
src/mp4.rs
@@ -76,19 +76,18 @@
|
||||
//! * mdat (media data container)
|
||||
//! ```
|
||||
|
||||
extern crate time;
|
||||
|
||||
use crate::base::{strutil, Error, ErrorKind, ResultExt, bail_t, format_err_t};
|
||||
use base::{strutil, Error, ErrorKind, ResultExt, bail_t, format_err_t};
|
||||
use bytes::{Buf, BytesMut};
|
||||
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
|
||||
use crate::body::{Chunk, BoxedError, wrap_error};
|
||||
use crate::db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use crate::db::{self, dir};
|
||||
use db::dir;
|
||||
use db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use futures::Stream;
|
||||
use futures::stream;
|
||||
use http;
|
||||
use http::header::HeaderValue;
|
||||
use http_serve;
|
||||
use log::{debug, error, trace, warn};
|
||||
use memmap;
|
||||
use openssl::hash;
|
||||
use parking_lot::{Once, ONCE_INIT};
|
||||
@@ -1536,15 +1535,16 @@ impl http_serve::Entity for File {
|
||||
/// to verify the output is byte-for-byte as expected.
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::base::strutil;
|
||||
use base::{clock::RealClocks, strutil};
|
||||
use bytes::Buf;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use crate::clock::RealClocks;
|
||||
use crate::db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use crate::db::testutil::{self, TestDb, TEST_STREAM_ID};
|
||||
use crate::db::writer;
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use db::recording::{self, TIME_UNITS_PER_SEC};
|
||||
use db::testutil::{self, TestDb, TEST_STREAM_ID};
|
||||
use db::writer;
|
||||
use futures::Future;
|
||||
use futures::Stream as FuturesStream;
|
||||
use log::info;
|
||||
use openssl::hash;
|
||||
use http_serve::{self, Entity};
|
||||
use std::fs;
|
||||
@@ -1552,7 +1552,6 @@ mod tests {
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
use super::*;
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
|
||||
fn fill_slice<E: http_serve::Entity>(slice: &mut [u8], e: &E, start: u64)
|
||||
where E::Error : ::std::fmt::Debug {
|
||||
@@ -2215,7 +2214,6 @@ mod tests {
|
||||
|
||||
#[cfg(all(test, feature="nightly"))]
|
||||
mod bench {
|
||||
extern crate reqwest;
|
||||
extern crate test;
|
||||
|
||||
use base::clock::RealClocks;
|
||||
@@ -2225,7 +2223,7 @@ mod bench {
|
||||
use hyper;
|
||||
use http::header;
|
||||
use http_serve;
|
||||
use self::test::Bencher;
|
||||
use lazy_static::lazy_static;
|
||||
use std::error::Error as StdError;
|
||||
use super::tests::create_mp4_from_db;
|
||||
use url::Url;
|
||||
@@ -2268,9 +2266,9 @@ mod bench {
|
||||
struct MyService(super::File);
|
||||
|
||||
impl hyper::service::Service for MyService {
|
||||
type ReqBody = ::hyper::Body;
|
||||
type ResBody = ::body::Body;
|
||||
type Error = ::body::BoxedError;
|
||||
type ReqBody = hyper::Body;
|
||||
type ResBody = crate::body::Body;
|
||||
type Error = crate::body::BoxedError;
|
||||
type Future = future::FutureResult<::http::Response<Self::ResBody>, Self::Error>;
|
||||
|
||||
fn call(&mut self, req: ::http::Request<Self::ReqBody>) -> Self::Future {
|
||||
@@ -2283,7 +2281,7 @@ mod bench {
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn build_index(b: &mut Bencher) {
|
||||
fn build_index(b: &mut test::Bencher) {
|
||||
testutil::init();
|
||||
let db = TestDb::new(RealClocks {});
|
||||
testutil::add_dummy_recordings_to_db(&db.db, 1);
|
||||
@@ -2310,7 +2308,7 @@ mod bench {
|
||||
|
||||
/// Benchmarks serving the generated part of a `.mp4` file (up to the first byte from disk).
|
||||
#[bench]
|
||||
fn serve_generated_bytes(b: &mut Bencher) {
|
||||
fn serve_generated_bytes(b: &mut test::Bencher) {
|
||||
testutil::init();
|
||||
let server = &*SERVER;
|
||||
let p = server.generated_len;
|
||||
@@ -2333,7 +2331,7 @@ mod bench {
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mp4_construction(b: &mut Bencher) {
|
||||
fn mp4_construction(b: &mut test::Bencher) {
|
||||
testutil::init();
|
||||
let db = TestDb::new(RealClocks {});
|
||||
testutil::add_dummy_recordings_to_db(&db.db, 60);
|
||||
|
||||
@@ -30,11 +30,10 @@
|
||||
|
||||
//! Tools for implementing a `http_serve::Entity` body composed from many "slices".
|
||||
|
||||
use crate::base::format_err_t;
|
||||
use base::format_err_t;
|
||||
use crate::body::{BoxedError, wrap_error};
|
||||
use failure::Error;
|
||||
use futures::stream;
|
||||
use futures::Stream;
|
||||
use failure::{Error, bail};
|
||||
use futures::{Stream, stream};
|
||||
use std::fmt;
|
||||
use std::ops::Range;
|
||||
|
||||
@@ -151,9 +150,10 @@ impl<S> Slices<S> where S: Slice {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::body::BoxedError;
|
||||
use crate::db::testutil;
|
||||
use db::testutil;
|
||||
use futures::{Future, Stream};
|
||||
use futures::stream;
|
||||
use lazy_static::lazy_static;
|
||||
use std::ops::Range;
|
||||
use super::{Slice, Slices};
|
||||
|
||||
|
||||
@@ -28,9 +28,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use failure::Error;
|
||||
use crate::h264;
|
||||
use moonfire_ffmpeg;
|
||||
use failure::{Error, bail};
|
||||
use ffmpeg;
|
||||
use lazy_static::lazy_static;
|
||||
use log::{debug, info, warn};
|
||||
use std::os::raw::c_char;
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::result::Result;
|
||||
@@ -55,7 +57,7 @@ pub trait Opener<S : Stream> : Sync {
|
||||
|
||||
pub trait Stream {
|
||||
fn get_extra_data(&self) -> Result<h264::ExtraData, Error>;
|
||||
fn get_next<'p>(&'p mut self) -> Result<moonfire_ffmpeg::Packet<'p>, moonfire_ffmpeg::Error>;
|
||||
fn get_next<'p>(&'p mut self) -> Result<ffmpeg::Packet<'p>, ffmpeg::Error>;
|
||||
}
|
||||
|
||||
pub struct Ffmpeg {}
|
||||
@@ -63,7 +65,7 @@ pub struct Ffmpeg {}
|
||||
impl Ffmpeg {
|
||||
fn new() -> Ffmpeg {
|
||||
START.call_once(|| {
|
||||
moonfire_ffmpeg::Ffmpeg::new();
|
||||
ffmpeg::Ffmpeg::new();
|
||||
//ffmpeg::init().unwrap();
|
||||
//ffmpeg::format::network::init();
|
||||
});
|
||||
@@ -79,11 +81,11 @@ macro_rules! c_str {
|
||||
|
||||
impl Opener<FfmpegStream> for Ffmpeg {
|
||||
fn open(&self, src: Source) -> Result<FfmpegStream, Error> {
|
||||
use moonfire_ffmpeg::InputFormatContext;
|
||||
use ffmpeg::InputFormatContext;
|
||||
let (mut input, discard_first) = match src {
|
||||
#[cfg(test)]
|
||||
Source::File(filename) => {
|
||||
let mut open_options = moonfire_ffmpeg::Dictionary::new();
|
||||
let mut open_options = ffmpeg::Dictionary::new();
|
||||
|
||||
// Work around https://github.com/scottlamb/moonfire-nvr/issues/10
|
||||
open_options.set(c_str!("advanced_editlist"), c_str!("false")).unwrap();
|
||||
@@ -97,7 +99,7 @@ impl Opener<FfmpegStream> for Ffmpeg {
|
||||
(i, false)
|
||||
}
|
||||
Source::Rtsp(url) => {
|
||||
let mut open_options = moonfire_ffmpeg::Dictionary::new();
|
||||
let mut open_options = ffmpeg::Dictionary::new();
|
||||
open_options.set(c_str!("rtsp_transport"), c_str!("tcp")).unwrap();
|
||||
// https://trac.ffmpeg.org/ticket/5018 workaround attempt.
|
||||
open_options.set(c_str!("probesize"), c_str!("262144")).unwrap();
|
||||
@@ -147,7 +149,7 @@ impl Opener<FfmpegStream> for Ffmpeg {
|
||||
}
|
||||
|
||||
pub struct FfmpegStream {
|
||||
input: moonfire_ffmpeg::InputFormatContext,
|
||||
input: ffmpeg::InputFormatContext,
|
||||
video_i: usize,
|
||||
}
|
||||
|
||||
@@ -166,7 +168,7 @@ impl Stream for FfmpegStream {
|
||||
h264::ExtraData::parse(codec.extradata(), codec.width() as u16, codec.height() as u16)
|
||||
}
|
||||
|
||||
fn get_next<'i>(&'i mut self) -> Result<moonfire_ffmpeg::Packet<'i>, moonfire_ffmpeg::Error> {
|
||||
fn get_next<'i>(&'i mut self) -> Result<ffmpeg::Packet<'i>, ffmpeg::Error> {
|
||||
loop {
|
||||
let p = self.input.read_frame()?;
|
||||
if p.stream_index() == self.video_i {
|
||||
|
||||
@@ -28,14 +28,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::clock::{Clocks, TimerGuard};
|
||||
use crate::db::{Camera, Database, Stream, dir, recording, writer};
|
||||
use failure::Error;
|
||||
use base::clock::{Clocks, TimerGuard};
|
||||
use crate::h264;
|
||||
use crate::stream;
|
||||
use db::{Camera, Database, Stream, dir, recording, writer};
|
||||
use failure::{Error, bail, format_err};
|
||||
use log::{debug, info, trace, warn};
|
||||
use std::result::Result;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use crate::stream;
|
||||
use time;
|
||||
|
||||
pub static ROTATE_INTERVAL_SEC: i64 = 60;
|
||||
@@ -186,18 +187,16 @@ impl<'a, C, S> Streamer<'a, C, S> where C: 'a + Clocks + Clone, S: 'a + stream::
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::clock::{self, Clocks};
|
||||
use crate::db::{self, CompositeId};
|
||||
use crate::db::recording;
|
||||
use crate::db::testutil;
|
||||
use failure::Error;
|
||||
use base::clock::{self, Clocks};
|
||||
use crate::h264;
|
||||
use moonfire_ffmpeg;
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use db::{CompositeId, recording, testutil};
|
||||
use failure::{Error, bail};
|
||||
use log::trace;
|
||||
use parking_lot::Mutex;
|
||||
use std::cmp;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use crate::stream::{self, Opener, Stream};
|
||||
use time;
|
||||
|
||||
struct ProxyingStream<'a> {
|
||||
@@ -227,9 +226,9 @@ mod tests {
|
||||
}
|
||||
|
||||
impl<'a> Stream for ProxyingStream<'a> {
|
||||
fn get_next(&mut self) -> Result<moonfire_ffmpeg::Packet, moonfire_ffmpeg::Error> {
|
||||
fn get_next(&mut self) -> Result<ffmpeg::Packet, ffmpeg::Error> {
|
||||
if self.pkts_left == 0 {
|
||||
return Err(moonfire_ffmpeg::Error::eof());
|
||||
return Err(ffmpeg::Error::eof());
|
||||
}
|
||||
self.pkts_left -= 1;
|
||||
|
||||
|
||||
37
src/web.rs
37
src/web.rs
@@ -28,26 +28,26 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate hyper;
|
||||
|
||||
use crate::base::clock::Clocks;
|
||||
use crate::base::{ErrorKind, strutil};
|
||||
use base::clock::Clocks;
|
||||
use base::{ErrorKind, strutil};
|
||||
use crate::body::{Body, BoxedError};
|
||||
use crate::json;
|
||||
use crate::mp4;
|
||||
use base64;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use core::borrow::Borrow;
|
||||
use core::str::FromStr;
|
||||
use crate::db::{self, auth, recording};
|
||||
use crate::db::dir::SampleFileDir;
|
||||
use failure::Error;
|
||||
use db::{auth, recording};
|
||||
use db::dir::SampleFileDir;
|
||||
use failure::{Error, bail, format_err};
|
||||
use fnv::FnvHashMap;
|
||||
use futures::{Future, Stream, future};
|
||||
use futures_cpupool;
|
||||
use crate::json;
|
||||
use http::{self, Request, Response, status::StatusCode};
|
||||
use http::{Request, Response, status::StatusCode};
|
||||
use http_serve;
|
||||
use http::header::{self, HeaderValue};
|
||||
use crate::mp4;
|
||||
use lazy_static::lazy_static;
|
||||
use log::{debug, info, warn};
|
||||
use regex::Regex;
|
||||
use serde_json;
|
||||
use std::collections::HashMap;
|
||||
@@ -849,18 +849,16 @@ impl ::hyper::service::Service for Service {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
extern crate reqwest;
|
||||
|
||||
use crate::db;
|
||||
use crate::db::testutil::{self, TestDb};
|
||||
use db::testutil::{self, TestDb};
|
||||
use futures::Future;
|
||||
use http::{self, header};
|
||||
use http::header;
|
||||
use log::info;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error as StdError;
|
||||
use super::Segments;
|
||||
|
||||
struct Server {
|
||||
db: TestDb<crate::base::clock::RealClocks>,
|
||||
db: TestDb<base::clock::RealClocks>,
|
||||
base_url: String,
|
||||
//test_camera_uuid: Uuid,
|
||||
handle: Option<::std::thread::JoinHandle<()>>,
|
||||
@@ -869,7 +867,7 @@ mod tests {
|
||||
|
||||
impl Server {
|
||||
fn new(require_auth: bool) -> Server {
|
||||
let db = TestDb::new(crate::base::clock::RealClocks {});
|
||||
let db = TestDb::new(base::clock::RealClocks {});
|
||||
let (shutdown_tx, shutdown_rx) = futures::sync::oneshot::channel::<()>();
|
||||
let addr = "127.0.0.1:0".parse().unwrap();
|
||||
let service = super::Service::new(super::Config {
|
||||
@@ -1077,13 +1075,12 @@ mod tests {
|
||||
|
||||
#[cfg(all(test, feature="nightly"))]
|
||||
mod bench {
|
||||
extern crate reqwest;
|
||||
extern crate test;
|
||||
|
||||
use db::testutil::{self, TestDb};
|
||||
use futures::Future;
|
||||
use hyper;
|
||||
use self::test::Bencher;
|
||||
use lazy_static::lazy_static;
|
||||
use std::error::Error as StdError;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -1125,7 +1122,7 @@ mod bench {
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn serve_stream_recordings(b: &mut Bencher) {
|
||||
fn serve_stream_recordings(b: &mut test::Bencher) {
|
||||
testutil::init();
|
||||
let server = &*SERVER;
|
||||
let url = reqwest::Url::parse(&format!("{}/api/cameras/{}/main/recordings", server.base_url,
|
||||
|
||||
Reference in New Issue
Block a user