Include docs for neolink_rtsp and neolink
This commit is contained in:
6 files changed
+43
-3
No files matched your search
@@ -74,6 +74,10 @@ pub enum Error {
|
||||
/// A generic catch all error
|
||||
#[error(display = "Other error")]
|
||||
Other(&'static str),
|
||||
|
||||
/// A generic catch all error
|
||||
#[error(display = "Other error")]
|
||||
OtherString(String),
|
||||
}
|
||||
|
||||
impl<'a> From<std::sync::mpsc::RecvTimeoutError> for Error {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// The command line for the rtsp subcommand
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub struct Opt {
|
||||
/// The path to the config file
|
||||
#[structopt(short, long, parse(from_os_str))]
|
||||
pub config: PathBuf,
|
||||
}
|
||||
@@ -1,16 +1,23 @@
|
||||
use err_derive::Error;
|
||||
|
||||
/// The main error for the rtsp subcommand
|
||||
#[derive(Debug, Error)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum Error {
|
||||
/// Raised when the config file fails to deserlize
|
||||
#[error(display = "Configuration parsing error")]
|
||||
ConfigError(#[error(source)] toml::de::Error),
|
||||
/// Raised when `neolink_core` raises an error
|
||||
#[error(display = "Communication error")]
|
||||
ProtocolError(#[error(source)] neolink_core::Error),
|
||||
/// Raised when there is an IO error such as unable to find
|
||||
/// config file
|
||||
#[error(display = "I/O error")]
|
||||
IoError(#[error(source)] std::io::Error),
|
||||
/// Raised when the config file fails validataion
|
||||
#[error(display = "Validation error")]
|
||||
ValidationError(#[error(source)] validator::ValidationErrors),
|
||||
/// Raised when there is an ADPCM decoding error
|
||||
#[error(display = "ADPCM Decoding Error")]
|
||||
AdpcmDecodingError(&'static str),
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
//! data using an ordinary std::io::Write interface.
|
||||
pub(crate) use self::maybe_app_src::MaybeAppSrc;
|
||||
use super::adpcm::adpcm_to_pcm;
|
||||
use super::errors::Error;
|
||||
use gstreamer::prelude::Cast;
|
||||
use gstreamer::{Bin, Structure};
|
||||
use gstreamer_app::AppSrc;
|
||||
@@ -39,8 +40,13 @@ impl StreamOutput for GstOutputs {
|
||||
fn write_audio(&mut self, data: &[u8], format: StreamFormat) -> StreamOutputError {
|
||||
self.set_format(Some(format));
|
||||
if let StreamFormat::ADPCM = format {
|
||||
let pcm = adpcm_to_pcm(data)
|
||||
.map_err(|_| neolink_core::Error::Other("ADPCM decoding error"))?;
|
||||
let pcm = adpcm_to_pcm(data).map_err(|e| {
|
||||
if let Error::AdpcmDecodingError(msg) = e {
|
||||
neolink_core::Error::OtherString(format!("ADPCM decoding error: {}", msg))
|
||||
} else {
|
||||
neolink_core::Error::Other("Generic error during ADPCM decoding")
|
||||
}
|
||||
})?;
|
||||
self.vidsrc.write_all(&pcm)?;
|
||||
} else {
|
||||
self.vidsrc.write_all(data)?;
|
||||
|
||||
+13
-1
@@ -1,3 +1,10 @@
|
||||
#![warn(missing_docs)]
|
||||
//!
|
||||
//! # Neolink RTSP
|
||||
//!
|
||||
//! This crate serves as the rtsp source for the
|
||||
//! `neolink rtsp` subcommand
|
||||
//!
|
||||
use gio::TlsAuthenticationMode;
|
||||
use log::*;
|
||||
use neolink_core::bc_protocol::BcCamera;
|
||||
@@ -9,8 +16,10 @@ use std::time::Duration;
|
||||
use validator::Validate;
|
||||
|
||||
mod adpcm;
|
||||
/// The command line parameters for this subcommand
|
||||
pub mod cmdline;
|
||||
pub mod config;
|
||||
mod config;
|
||||
/// The errors this subcommand can raise
|
||||
pub mod errors;
|
||||
mod gst;
|
||||
|
||||
@@ -19,6 +28,9 @@ use config::{CameraConfig, Config, UserConfig};
|
||||
use errors::Error;
|
||||
use gst::{GstOutputs, RtspServer};
|
||||
|
||||
/// Entry point for the rtsp subcommand
|
||||
///
|
||||
/// Opt is the command line options
|
||||
pub fn main(opt: Opt) -> Result<(), Error> {
|
||||
let config: Config = toml::from_str(&fs::read_to_string(opt.config)?)?;
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
#![warn(missing_docs)]
|
||||
//!
|
||||
//! # Neolink
|
||||
//!
|
||||
//! Neolink is a small program that acts a general contol interface for Reolink IP cameras.
|
||||
//!
|
||||
//! It contains sub commands for running an rtsp proxy which can be used on Reolink cameras
|
||||
//! that do not nativly support RTSP.
|
||||
//!
|
||||
use env_logger::Env;
|
||||
use log::*;
|
||||
use structopt::StructOpt;
|
||||
|
||||
Reference in new issue
Block a user