Updates of all packages

This commit is contained in:
QuantumEntangledAndy committed 2023-04-15 08:05:58 +07:00
1 parent a424fa55c0
commit 78375b220d
26 files changed
+848 -881

No files matched your search

Generated
+641 -720
View File
File diff suppressed because it is too large. Load diff
+19 -19
View File
@@ -12,26 +12,26 @@ members = [
]
[dependencies]
anyhow = "1.0.42"
anyhow = "1.0.70"
byte-slice-cast = "1.2.2"
crossbeam-channel = "0.5.1"
clap = { version = "4.2.2", features = ["derive"] }
crossbeam-channel = "0.5.8"
env_logger = "*"
futures = "0.3.26"
gstreamer = "0.19.0"
gstreamer-app = "0.19.0"
gstreamer-rtsp = "0.19.0"
gstreamer-rtsp-server = { version = "0.19.0", features = ["v1_16"] }
lazy_static = "1.4"
log = { version = "0.4" }
futures = "0.3.28"
gstreamer = "0.20.3"
gstreamer-app = "0.20.0"
gstreamer-rtsp = "0.20.0"
gstreamer-rtsp-server = { version = "0.20.3", features = ["v1_16"] }
lazy_static = "1.4.0"
log = { version = "0.4.17" }
neolink_core = { path = "crates/core", version = "0.5.6" }
regex = "1"
rumqttc = "0.8.0"
serde = { version = "1.0", features = ["derive"] }
structopt = "0.3"
time = "0.2"
tokio = { version = "1.0", features = ["rt", "macros", "io-util"] }
regex = "1.7.3"
rumqttc = "0.20.0"
serde = { version = "1.0.160", features = ["derive"] }
time = "0.3.20"
tokio = { version = "1.27.0", features = ["rt", "macros", "io-util"] }
tokio-stream = "0.1.12"
toml = "0.5"
validator = "0.10"
validator_derive = "0.10"
yaserde = "0.3.16"
toml = "0.7.3"
validator = "0.16.0"
validator_derive = "0.16.0"
yaserde = "0.8.0"
+2
View File
@@ -50,6 +50,8 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgstrtspserver-1.0-0 \
libgstreamer1.0-0 \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad && \
+24 -25
View File
@@ -1,39 +1,38 @@
[package]
name = "neolink_core"
description = "Core services and structure for Reolink IP cameras"
version = "0.5.7"
version = "0.5.6"
authors = ["George Hilliard <thirtythreeforty@gmail.com>", "Andrew King <sheepchaan@gmail.com>"]
edition = "2018"
license = "AGPL-3.0-or-later"
[dependencies]
aes = "0.6"
bytes = "1.0.0"
cfb-mode = "0.6"
cookie-factory = "0.3"
crc32fast = "1.2.1"
crossbeam-channel = "0.5.6"
aes = "0.8.2"
bytes = "1.4.0"
cfb-mode = "0.8.2"
cookie-factory = "0.3.2"
crc32fast = "1.3.2"
crossbeam-channel = "0.5.8"
delegate = "0.9.0"
err-derive = "0.2"
futures = "0.3.25"
err-derive = "0.3.1"
futures = "0.3.28"
get_if_addrs = "0.5.3"
lazy_static = "1.4"
local-ip-address = "0.4.4"
log = { version = "0.4" }
md5 = "0.7"
nom = { version = "6.1.2", features = ["alloc"] }
rand = "0.8.4"
regex = "1.5.4"
serde = { version = "1.0", features = ["derive"] }
time = "0.2"
tokio = { version = "1.24.2", features = ["full"] }
tokio-stream = { version = "0.1.11", features = ["sync", "time", "net"] }
tokio-util = { version = "0.7.4", features = ["full"] }
xml-rs = "0.8"
yaserde = "0.3.16"
yaserde_derive = "0.3.16"
lazy_static = "1.4.0"
local-ip-address = "0.5.1"
log = "0.4.17"
md5 = "0.7.0"
nom = { version = "7.1.3", features = ["alloc"] }
rand = "0.8.5"
regex = "1.7.3"
serde = { version = "1.0.106", features = ["derive"] }
time = { version = "0.3.20" , features = [ "macros", "parsing", "local-offset" ]}
tokio = { version = "1.27.0", features = ["full"] }
tokio-stream = { version = "0.1.12", features = ["sync", "time", "net"] }
tokio-util = { version = "0.7.7", features = ["full"] }
yaserde = "0.8.0"
yaserde_derive = "0.8.0"
[dev-dependencies]
assert_matches = "1.5.0"
env_logger = "*"
indoc = "0.3"
indoc = "2.0.1"
+10 -5
View File
@@ -1,7 +1,12 @@
use super::model::EncryptionProtocol;
use aes::Aes128;
use cfb_mode::cipher::{NewStreamCipher, StreamCipher};
use cfb_mode::Cfb;
use aes::{
cipher::{AsyncStreamCipher, KeyIvInit},
Aes128,
};
use cfb_mode::{Decryptor, Encryptor};
type Aes128CfbEnc = Encryptor<Aes128>;
type Aes128CfbDec = Decryptor<Aes128>;
const XML_KEY: [u8; 8] = [0x1F, 0x2D, 0x3C, 0x4B, 0x5A, 0x69, 0x78, 0xFF];
const IV: &[u8] = b"0123456789abcdef";
@@ -20,7 +25,7 @@ pub fn decrypt(offset: u32, buf: &[u8], encryption_protocol: &EncryptionProtocol
// AES decryption
let mut decrypted = buf.to_vec();
Cfb::<Aes128>::new(aeskey.into(), IV.into()).decrypt(&mut decrypted);
Aes128CfbDec::new(aeskey.into(), IV.into()).decrypt(&mut decrypted);
decrypted
}
}
@@ -39,7 +44,7 @@ pub fn encrypt(offset: u32, buf: &[u8], encryption_protocol: &EncryptionProtocol
EncryptionProtocol::Aes(aeskey) => {
// AES encryption
let mut encrypted = buf.to_vec();
Cfb::<Aes128>::new(aeskey.into(), IV.into()).encrypt(&mut encrypted);
Aes128CfbEnc::new(aeskey.into(), IV.into()).encrypt(&mut encrypted);
encrypted
}
}
+16
View File
@@ -10,6 +10,22 @@ pub enum Error {
#[error(display = "IO Error: {:?}", _0)]
Io(#[error(source)] std::sync::Arc<std::io::Error>),
/// Raised when fails to parse time from the camera
#[error(display = "Error in time coversion: {:?}", _0)]
TimeRange(#[error(source)] time::error::ComponentRange),
/// Raised when fails to parse time from the camera
#[error(display = "Error in time parsing")]
TimeParse,
/// Raised when fails to parse time from the camera
#[error(display = "Error in try from NonZeroInt")]
TryFromInt(#[error(source)] std::num::TryFromIntError),
/// /// Raised when fails to parse time from the camera
#[error(display = "Error in time conversion")]
TimeTryFrom(#[error(source)] time::error::TryFromParsed),
/// Raised when a Bc reply was not understood
#[error(display = "Communication error")]
UnintelligibleReply {
+26 -11
View File
@@ -1,6 +1,9 @@
use super::{BcCamera, Error, Result};
use crate::bc::{model::*, xml::*};
use time::{date, Date, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset};
use std::convert::{TryFrom, TryInto};
use time::{
macros::date, parsing::Parsed, Date, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset,
};
impl BcCamera {
///
@@ -115,9 +118,9 @@ impl BcCamera {
//osd_format: Some("MDY".to_string()),
time_format: Some(0),
// Reolink uses positive seconds to indicate a negative UTC offset:
time_zone: Some(-timestamp.offset().as_seconds()),
time_zone: Some(-timestamp.offset().whole_seconds()),
year: Some(timestamp.year()),
month: Some(timestamp.month()),
month: Some(timestamp.month().into()),
day: Some(timestamp.day()),
hour: Some(timestamp.hour()),
minute: Some(timestamp.minute()),
@@ -153,14 +156,26 @@ fn try_build_timestamp(
hour: u8,
minute: u8,
second: u8,
) -> std::result::Result<OffsetDateTime, time::ComponentRangeError> {
let date = Date::try_from_ymd(year, month, day)?;
let time = Time::try_from_hms(hour, minute, second)?;
let offset = if timezone > 0 {
UtcOffset::west_seconds(timezone as u32)
} else {
UtcOffset::east_seconds(-timezone as u32)
};
) -> std::result::Result<OffsetDateTime, crate::Error> {
let date = Date::try_from(
Parsed::new()
.with_year(year)
.ok_or(Error::TimeParse)?
.with_month(month.try_into()?)
.ok_or(Error::TimeParse)?
.with_day(day.try_into()?)
.ok_or(Error::TimeParse)?,
)?;
let time = Time::try_from(
Parsed::new()
.with_hour_24(hour)
.ok_or(Error::TimeParse)?
.with_minute(minute)
.ok_or(Error::TimeParse)?
.with_second(second)
.ok_or(Error::TimeParse)?,
)?;
let offset = UtcOffset::from_whole_seconds(timezone)?;
Ok(PrimitiveDateTime::new(date, time).assume_offset(offset))
}
+11 -11
View File
@@ -2,7 +2,7 @@ use super::model::BcMediaIframe;
use super::model::*;
use crate::Error;
use bytes::{Buf, BytesMut};
use nom::{combinator::*, error::context, number::streaming::*, take};
use nom::{bytes::streaming::take, combinator::*, error::context, number::streaming::*};
type IResult<I, O, E = nom::error::VerboseError<I>> = Result<(I, O), nom::Err<E>>;
@@ -182,18 +182,18 @@ fn bcmedia_iframe(buf: &[u8]) -> IResult<&[u8], BcMediaIframe> {
};
let (buf, _unknown_remained) = if additional_header_size > 4 {
let remainder = additional_header_size - 4;
let (buf, unknown_remained) = take!(buf, remainder)?;
let (buf, unknown_remained) = take(remainder)(buf)?;
(buf, Some(unknown_remained))
} else {
(buf, None)
};
let (buf, data_slice) = take!(buf, payload_size)?;
let (buf, data_slice) = take(payload_size)(buf)?;
let pad_size = match payload_size % PAD_SIZE {
0 => 0,
n => PAD_SIZE - n,
};
let (buf, _padding) = take!(buf, pad_size)?;
let (buf, _padding) = take(pad_size)(buf)?;
assert_eq!(payload_size as usize, data_slice.len());
let video_type = match video_type_str {
@@ -223,13 +223,13 @@ fn bcmedia_pframe(buf: &[u8]) -> IResult<&[u8], BcMediaPframe> {
let (buf, additional_header_size) = le_u32(buf)?;
let (buf, microseconds) = le_u32(buf)?;
let (buf, _unknown_b) = le_u32(buf)?;
let (buf, _additional_header) = take!(buf, additional_header_size)?;
let (buf, data_slice) = take!(buf, payload_size)?;
let (buf, _additional_header) = take(additional_header_size)(buf)?;
let (buf, data_slice) = take(payload_size)(buf)?;
let pad_size = match payload_size % PAD_SIZE {
0 => 0,
n => PAD_SIZE - n,
};
let (buf, _padding) = take!(buf, pad_size)?;
let (buf, _padding) = take(pad_size)(buf)?;
assert_eq!(payload_size as usize, data_slice.len());
let video_type = match video_type_str {
@@ -252,12 +252,12 @@ fn bcmedia_pframe(buf: &[u8]) -> IResult<&[u8], BcMediaPframe> {
fn bcmedia_aac(buf: &[u8]) -> IResult<&[u8], BcMediaAac> {
let (buf, payload_size) = le_u16(buf)?;
let (buf, _payload_size_b) = le_u16(buf)?;
let (buf, data_slice) = take!(buf, payload_size)?;
let (buf, data_slice) = take(payload_size)(buf)?;
let pad_size = match payload_size as u32 % PAD_SIZE {
0 => 0,
n => PAD_SIZE - n,
};
let (buf, _padding) = take!(buf, pad_size)?;
let (buf, _padding) = take(pad_size)(buf)?;
Ok((
buf,
@@ -281,12 +281,12 @@ fn bcmedia_adpcm(buf: &[u8]) -> IResult<&[u8], BcMediaAdpcm> {
// On other cameras is half the block size without the header
let (buf, _half_block_size) = le_u16(buf)?;
let block_size = payload_size - SUB_HEADER_SIZE;
let (buf, data_slice) = take!(buf, block_size)?;
let (buf, data_slice) = take(block_size)(buf)?;
let pad_size = match payload_size as u32 % PAD_SIZE {
0 => 0,
n => PAD_SIZE - n,
};
let (buf, _padding) = take!(buf, pad_size)?;
let (buf, _padding) = take(pad_size)(buf)?;
Ok((
buf,
+9 -8
View File
@@ -2,10 +2,11 @@ use super::{crc::calc_crc, model::*, xml::*, xml_crypto::decrypt};
use crate::Error;
use bytes::{Buf, BytesMut};
use nom::{
bytes::streaming::take,
combinator::*,
error::{context as error_context, ContextError, ErrorKind, ParseError},
number::streaming::*,
take, Err,
Err,
};
type IResult<I, O, E = nom::error::VerboseError<I>> = Result<(I, O), nom::Err<E>>;
@@ -67,7 +68,7 @@ fn udp_disc(buf: &[u8]) -> IResult<&[u8], UdpDiscovery> {
)(buf)?;
let (buf, tid) = error_context("DISC: Missing TID", le_u32)(buf)?;
let (buf, checksum) = error_context("DISC: Missing checksum", le_u32)(buf)?;
let (buf, enc_data_slice) = take!(buf, payload_size)?;
let (buf, enc_data_slice) = take(payload_size)(buf)?;
let actual_checksum = calc_crc(enc_data_slice);
assert_eq!(checksum, actual_checksum);
@@ -98,11 +99,11 @@ fn udp_ack(buf: &[u8]) -> IResult<&[u8], UdpAck> {
let (buf, _unknown) = error_context("ACK: Missing unknown", le_u32)(buf)?;
let (buf, payload_size) = error_context("ACK: Missing payload_size", le_u32)(buf)?;
let (buf, payload) = if payload_size > 0 {
let (buf, t_payload) = take!(buf, payload_size)?; // It is a binary payload of
// `00 01 01 01 01 00 01`
// This is a truth map of missing packets
// since last contigious packet_id up
// to the last packet we sent and it recieved
let (buf, t_payload) = take(payload_size)(buf)?; // It is a binary payload of
// `00 01 01 01 01 00 01`
// This is a truth map of missing packets
// since last contigious packet_id up
// to the last packet we sent and it recieved
(buf, t_payload.to_vec())
} else {
(buf, vec![])
@@ -123,7 +124,7 @@ fn udp_data(buf: &[u8]) -> IResult<&[u8], UdpData> {
error_context("DATA: Unable to verify UnownA", verify(le_u32, |&x| x == 0))(buf)?;
let (buf, packet_id) = error_context("DATA: Missing packet_id", le_u32)(buf)?;
let (buf, payload_size) = error_context("DATA: Missing payload_size", le_u32)(buf)?;
let (buf, payload) = take!(buf, payload_size)?;
let (buf, payload) = take(payload_size)(buf)?;
let data = UdpData {
connection_id,
+4 -4
View File
@@ -7,11 +7,11 @@ edition = "2018"
license = "AGPL-3.0-or-later"
[dependencies]
aes = "0.6"
aes = "0.8.2"
anyhow = "1.0.42"
cfb-mode = "0.6"
cfb-mode = "0.8.2"
env_logger = "*"
hex-string = "0.1.0"
md5 = "0.7"
md5 = "0.7.0"
requestty = "0.5.0"
log = { version = "0.4" }
log = "0.4.17"
+8 -4
View File
@@ -6,15 +6,19 @@ use hex_string::HexString;
use requestty::Question;
use std::convert::TryInto;
use aes::Aes128;
use cfb_mode::cipher::{NewStreamCipher, StreamCipher};
use cfb_mode::Cfb;
use aes::{
cipher::{AsyncStreamCipher, KeyIvInit},
Aes128,
};
use cfb_mode::Decryptor;
type Aes128CfbDec = Decryptor<Aes128>;
const IV: &[u8] = b"0123456789abcdef";
fn decrypt(buf: &[u8], aeskey: &[u8; 16]) -> Vec<u8> {
let mut decrypted = buf.to_vec();
Cfb::<Aes128>::new(aeskey.into(), IV.into()).decrypt(&mut decrypted);
Aes128CfbDec::new(aeskey.into(), IV.into()).decrypt(&mut decrypted);
decrypted
}
+19 -15
View File
@@ -75,6 +75,9 @@ notice = "warn"
# output a note when they are encountered.
ignore = [
#"RUSTSEC-0000-0000",
# This is rust-xml which is unmaintaned. Not much we can do since
# all the xml serde like crates seem to use it
"RUSTSEC-2022-0048",
]
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
# lower than the range specified will be ignored. Note that ignored advisories
@@ -106,10 +109,11 @@ allow = [
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"BSD-3-Clause",
"AGPL-3.0-only",
"AGPL-3.0-or-later",
"AGPL-3.0",
"Unicode-DFS-2016",
"ISC",
"OpenSSL",
"Zlib",
]
# List of explicitly disallowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
@@ -118,7 +122,7 @@ deny = [
#"Nokia",
]
# Lint level for licenses considered copyleft
copyleft = "warn"
copyleft = "allow"
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
# * both - The license will be approved if it is both OSI-approved *AND* FSF
# * either - The license will be approved if it is either OSI-approved *OR* FSF
@@ -142,28 +146,28 @@ exceptions = [
# Each entry is the crate and version constraint, and its specific allow
# list
#{ allow = ["Zlib"], name = "adler32", version = "*" },
{ allow = ["untrusted"], name = "untrusted", version = "*" },
]
# Some crates don't have (easily) machine readable licensing information,
# adding a clarification entry for it allows you to manually specify the
# licensing information
#[[licenses.clarify]]
[[licenses.clarify]]
# The name of the crate the clarification applies to
#name = "ring"
name = "ring"
# The optional version constraint for the crate
#version = "*"
version = "*"
# The SPDX expression for the license requirements of the crate
#expression = "MIT AND ISC AND OpenSSL"
expression = "MIT AND ISC AND OpenSSL"
# One or more files in the crate's source used as the "source of truth" for
# the license expression. If the contents match, the clarification will be used
# when running the license check, otherwise the clarification will be ignored
# and the crate will be checked normally, which may produce warnings or errors
# depending on the rest of your configuration
#license-files = [
license-files = [
# Each entry is a crate relative path, and the (opaque) hash of its contents
#{ path = "LICENSE", hash = 0xbd0eed23 }
#]
{ path = "LICENSE", hash = 0xbd0eed23 }
]
[licenses.private]
# If true, ignores workspace crates that aren't published, or are only
@@ -183,7 +187,7 @@ registries = [
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
[bans]
# Lint level for when multiple versions of the same crate are detected
multiple-versions = "warn"
multiple-versions = "allow"
# Lint level for when a crate version requirement is `*`
wildcards = "allow"
# The graph highlighting used when creating dotgraphs for crates
@@ -268,8 +272,8 @@ allow-git = []
[sources.allow-org]
# 1 or more github.com organizations to allow git sources for
github = [""]
#github = [""]
# 1 or more gitlab.com organizations to allow git sources for
gitlab = [""]
#gitlab = [""]
# 1 or more bitbucket.org organizations to allow git sources for
bitbucket = [""]
#bitbucket = [""]
+6 -9
View File
@@ -1,24 +1,21 @@
use clap::Parser;
use std::path::PathBuf;
use structopt::{clap::AppSettings, StructOpt};
use std::str::FromStr;
/// A standards-compliant bridge to Reolink IP cameras
///
/// Neolink is free software released under the GNU AGPL v3.
/// You can find its source code at https://github.com/thirtythreeforty/neolink
#[derive(StructOpt, Debug)]
#[structopt(
name = "neolink",
setting(AppSettings::ArgRequiredElseHelp),
setting(AppSettings::UnifiedHelpMessage)
)]
#[derive(Parser, Debug)]
#[command(name = "neolink", arg_required_else_help = true)]
pub struct Opt {
#[structopt(short, long, global(true), parse(from_os_str))]
#[arg(short, long, global = true, value_parser = PathBuf::from_str)]
pub config: Option<PathBuf>,
#[structopt(subcommand)]
pub cmd: Option<Command>,
}
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub enum Command {
Rtsp(super::rtsp::Opt),
StatusLight(super::statusled::Opt),
+4 -3
View File
@@ -1,12 +1,13 @@
use clap::Parser;
use std::path::PathBuf;
use structopt::StructOpt;
use std::str::FromStr;
/// The image command will dump a still image from the camera
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {
/// The name of the camera to get the image from. Must be a name in the config
pub camera: String,
/// The path of the output.
#[structopt(short, long, parse(from_os_str))]
#[structopt(short, long, value_parser = PathBuf::from_str)]
pub file_path: PathBuf,
}
+2 -2
View File
@@ -23,10 +23,10 @@
//! Neolink source code is available online at <https://github.com/thirtythreeforty/neolink>
//!
use anyhow::{Context, Result};
use clap::Parser;
use env_logger::Env;
use log::*;
use std::fs;
use structopt::StructOpt;
use validator::Validate;
mod cmdline;
@@ -53,7 +53,7 @@ async fn main() -> Result<()> {
env!("NEOLINK_PROFILE")
);
let opt = Opt::from_args();
let opt = Opt::parse();
let conf_path = opt.config.context("Must supply --config file")?;
let config: Config = toml::from_str(
+2 -2
View File
@@ -1,4 +1,4 @@
use structopt::StructOpt;
use clap::Parser;
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {}
+2 -1
View File
@@ -8,6 +8,7 @@ use rumqttc::{
MqttOptions, Publish, QoS, TlsConfiguration, Transport,
};
use std::sync::{Arc, Mutex};
use std::time::Duration;
pub(crate) struct Mqtt {
app: Arc<App>,
@@ -80,7 +81,7 @@ impl Mqtt {
mqttoptions.set_credentials(username, password);
}
mqttoptions.set_keep_alive(5);
mqttoptions.set_keep_alive(Duration::from_secs(5));
// On unclean disconnect send this
mqttoptions.set_last_will(LastWill::new(
+3 -3
View File
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use structopt::StructOpt;
use clap::Parser;
fn onoff_parse(src: &str) -> Result<bool> {
match src {
@@ -13,11 +13,11 @@ fn onoff_parse(src: &str) -> Result<bool> {
}
/// The pir command will control the PIR status of the camera
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {
/// The name of the camera. Must be a name in the config
pub camera: String,
/// Whether to turn the PIR ON or OFF
#[structopt(parse(try_from_str = onoff_parse), name = "on|off")]
#[arg(value_parser = onoff_parse, name = "on|off")]
pub on: Option<bool>,
}
+2 -2
View File
@@ -1,7 +1,7 @@
use structopt::StructOpt;
use clap::Parser;
/// The reboot command will reboot the camera
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {
/// The name of the camera to change the lights of. Must be a name in the config
pub camera: String,
+2 -2
View File
@@ -1,5 +1,5 @@
use structopt::StructOpt;
use clap::Parser;
/// The rtsp command will serve all cameras in the config over the rtsp protocol
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {}
+12 -12
View File
@@ -44,7 +44,7 @@ impl Default for NeoMediaFactory {
impl NeoMediaFactory {
pub(crate) fn new() -> Self {
let factory = Object::new::<NeoMediaFactory>(&[]);
let factory = Object::new::<NeoMediaFactory>();
factory.set_shared(false);
// factory.set_do_retransmission(false); // Can't use as the method is missing on the 32bit docker gst dll
factory.set_launch("videotestsrc pattern=\"snow\" ! video/x-raw,width=896,height=512,framerate=25/1 ! textoverlay name=\"inittextoverlay\" text=\"Stream not Ready\" valignment=top halignment=left font-desc=\"Sans, 32\" ! jpegenc ! rtpjpegpay name=pay0");
@@ -59,13 +59,12 @@ impl NeoMediaFactory {
pub(crate) fn add_permitted_roles<T: AsRef<str>>(&self, permitted_roles: &HashSet<T>) {
for permitted_role in permitted_roles {
self.add_role_from_structure(&Structure::new(
permitted_role.as_ref(),
&[
(*RTSP_PERM_MEDIA_FACTORY_ACCESS, &true),
(*RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, &true),
],
));
self.add_role_from_structure(
&Structure::builder(permitted_role.as_ref())
.field(RTSP_PERM_MEDIA_FACTORY_ACCESS, true)
.field(RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, true)
.build(),
);
}
// During auth, first it binds anonymously. At this point it checks
// RTSP_PERM_MEDIA_FACTORY_ACCESS to see if anyone can connect
@@ -87,10 +86,11 @@ impl NeoMediaFactory {
.collect::<HashSet<&str>>()
.contains(&"anonymous")
{
self.add_role_from_structure(&Structure::new(
"anonymous",
&[(*RTSP_PERM_MEDIA_FACTORY_ACCESS, &true)],
));
self.add_role_from_structure(
&Structure::builder("anonymous")
.field(RTSP_PERM_MEDIA_FACTORY_ACCESS, true)
.build(),
);
}
}
+5 -4
View File
@@ -41,7 +41,7 @@ impl Default for NeoRtspServer {
impl NeoRtspServer {
pub(crate) fn new() -> AnyResult<Self> {
gstreamer::init().context("Gstreamer failed to initialise")?;
let factory = Object::new::<NeoRtspServer>(&[]);
let factory = Object::new::<NeoRtspServer>();
Ok(factory)
}
@@ -259,7 +259,8 @@ impl NeoRtspServerImpl {
.expect("The server should have mountpoints");
for path in paths {
media.paths.insert(path.clone());
mounts.add_factory(path, &media.factory);
// We can clone here because GObjects are referernce counted
mounts.add_factory(path, media.factory.clone());
// debug!("Adding path: {}", path);
}
Ok(())
@@ -302,13 +303,13 @@ impl NeoRtspServerImpl {
let auth = self.obj().auth().unwrap_or_else(RTSPAuth::new);
auth.set_supported_methods(RTSPAuthMethod::Basic);
let mut un_authtoken = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"anonymous")]);
let mut un_authtoken = RTSPToken::new(&[(RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"anonymous")]);
auth.set_default_token(Some(&mut un_authtoken));
for credential in credentials {
let (user, pass) = credential;
trace!("Setting credentials for user {}", user);
let token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, user)]);
let token = RTSPToken::new(&[(RTSP_TOKEN_MEDIA_FACTORY_ROLE, user)]);
let basic = RTSPAuth::make_basic(user, pass);
auth.add_basic(basic.as_str(), &token);
}
+1 -1
View File
@@ -42,7 +42,7 @@ impl Camera<LoggedIn> {
// We'd like now_local() but it's deprecated - try to get the local time, but if no
// time zone, fall back to UTC.
let new_time =
OffsetDateTime::try_now_local().unwrap_or_else(|_| OffsetDateTime::now_utc());
OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc());
warn!(
"{}: Camera has no time set, setting to {}",
+3 -3
View File
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use structopt::StructOpt;
use clap::Parser;
fn onoff_parse(src: &str) -> Result<bool> {
match src {
@@ -13,11 +13,11 @@ fn onoff_parse(src: &str) -> Result<bool> {
}
/// The status-light command will control the blue status light on the camera
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {
/// The name of the camera to change the lights of. Must be a name in the config
pub camera: String,
/// Whether to turn the light on or off
#[structopt(parse(try_from_str = onoff_parse), name = "on|off")]
#[arg(value_parser = onoff_parse, name = "on|off")]
pub on: bool,
}
+7 -6
View File
@@ -1,5 +1,6 @@
use clap::Parser;
use std::path::PathBuf;
use structopt::StructOpt;
use std::str::FromStr;
/// The talk command will send audio for the camera to say
///
@@ -7,19 +8,19 @@ use structopt::StructOpt;
/// This should be ok with most common formats.
///
/// `gst-launch` can be used to prepare this data
#[derive(StructOpt, Debug)]
#[derive(Parser, Debug)]
pub struct Opt {
/// The name of the camera to talk through. Must be a name in the config
pub camera: String,
/// The path to the audio file.
#[structopt(short, long, parse(from_os_str), conflicts_with = "microphone")]
#[arg(short, long, value_parser = PathBuf::from_str, conflicts_with = "microphone")]
pub file_path: Option<PathBuf>,
/// Use the microphone as the source. Defaults to autoaudiosrc - Which microphone depends
/// on [gstreamer](https://gstreamer.freedesktop.org/documentation/autodetect/autoaudiosrc.html?gi-language=c#autoaudiosrc-page)
#[structopt(short, long, conflicts_with = "file_path")]
#[arg(short, long, conflicts_with = "file_path")]
pub microphone: bool,
/// Use a specific microphone like "alsasrc device=hw:1"
#[structopt(
#[arg(
short,
long,
default_value = "autoaudiosrc",
@@ -27,6 +28,6 @@ pub struct Opt {
)]
pub input_src: String,
/// Use to change the volume of the input
#[structopt(short, long, default_value = "1.0")]
#[arg(short, long, default_value = "1.0")]
pub volume: f32,
}
+8 -9
View File
@@ -166,15 +166,14 @@ fn create_pipeline(
// provide the format we request.
// This can be set after linking the two objects, because format negotiation between
// both elements will happen during pre-rolling of the pipeline.
appsink.set_caps(Some(&Caps::new_simple(
"audio/x-adpcm",
&[
("layout", &"dvi"),
("block_align", &(block_align as i32)),
("channels", &(1i32)),
("rate", &(sample_rate as i32)),
],
)));
appsink.set_caps(Some(
&Caps::builder("audio/x-adpcm")
.field("layout", "dvi")
.field("block_align", block_align as i32)
.field("channels", 1i32)
.field("rate", sample_rate as i32)
.build(),
));
Ok(pipeline)
}