diff --git a/.gitignore b/.gitignore index cbc56376..3a8ec856 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /src/html/vue.js /target **/*.rs.bk +.vscode +logs diff --git a/src/lib/controls/onvif/manager.rs b/src/lib/controls/onvif/manager.rs index fad17eab..8444670c 100644 --- a/src/lib/controls/onvif/manager.rs +++ b/src/lib/controls/onvif/manager.rs @@ -3,11 +3,17 @@ use std::sync::{Arc, Mutex}; use anyhow::Result; use tracing::*; -use crate::stream::types::CaptureConfiguration; -use crate::stream::{manager as stream_manager, types::StreamInformation}; -use crate::video::types::VideoSourceType; -use crate::video::video_source_redirect::{VideoSourceRedirect, VideoSourceRedirectType}; -use crate::video_stream::types::VideoAndStreamInformation; +use crate::{ + stream::{ + manager as stream_manager, + types::{CaptureConfiguration, StreamInformation}, + }, + video::{ + types::VideoSourceType, + video_source_redirect::{VideoSourceRedirect, VideoSourceRedirectType}, + }, + video_stream::types::VideoAndStreamInformation, +}; use super::client::*; diff --git a/src/lib/custom/bluerov.rs b/src/lib/custom/bluerov.rs index fa9f7c44..ee211e38 100644 --- a/src/lib/custom/bluerov.rs +++ b/src/lib/custom/bluerov.rs @@ -1,10 +1,12 @@ +use tracing::*; use url::Url; -use crate::network::utils::get_visible_qgc_address; -use crate::stream::types::*; -use crate::video::{self, types::*, video_source::VideoSourceAvailable}; -use crate::video_stream::types::VideoAndStreamInformation; -use tracing::*; +use crate::{ + network::utils::get_visible_qgc_address, + stream::types::*, + video::{self, types::*, video_source::VideoSourceAvailable}, + video_stream::types::VideoAndStreamInformation, +}; fn get_cameras_with_encode_type(encode: VideoEncodeType) -> Vec { let cameras = video::video_source_local::VideoSourceLocal::cameras_available(); diff --git a/src/lib/custom/mod.rs b/src/lib/custom/mod.rs index 4f2ef0f3..3ff8a52c 100644 --- a/src/lib/custom/mod.rs +++ b/src/lib/custom/mod.rs @@ -1,11 +1,10 @@ -use clap::ValueEnum; - -use crate::cli; -use crate::video_stream::types::VideoAndStreamInformation; - mod bluerov; mod test; +use clap::ValueEnum; + +use crate::{cli, video_stream::types::VideoAndStreamInformation}; + #[derive(ValueEnum, PartialEq, Debug, Clone)] #[clap(rename_all = "verbatim")] pub enum CustomEnvironment { diff --git a/src/lib/custom/test.rs b/src/lib/custom/test.rs index 5411bb7b..e21c60dc 100644 --- a/src/lib/custom/test.rs +++ b/src/lib/custom/test.rs @@ -1,8 +1,10 @@ use url::Url; -use crate::stream::types::*; -use crate::video::{self, types::*, video_source_gst::VideoSourceGstType}; -use crate::video_stream::types::VideoAndStreamInformation; +use crate::{ + stream::types::*, + video::{self, types::*, video_source_gst::VideoSourceGstType}, + video_stream::types::VideoAndStreamInformation, +}; pub fn take_webrtc_stream() -> Vec { let size = STANDARD_SIZES.last().unwrap(); diff --git a/src/lib/helper/develop.rs b/src/lib/helper/develop.rs index eccdca4e..d0bf2d91 100644 --- a/src/lib/helper/develop.rs +++ b/src/lib/helper/develop.rs @@ -1,14 +1,12 @@ use std::collections::HashMap; -use crate::cli; -use crate::helper; use anyhow::{anyhow, Result}; use thirtyfour::prelude::*; -use tokio::process::Command; -use tokio::runtime::Runtime; -use tokio::sync::RwLock; +use tokio::{process::Command, runtime::Runtime, sync::RwLock}; use tracing::*; +use crate::{cli, helper}; + pub struct ChromeWebDriver { _process: tokio::task::JoinHandle<()>, webdriver: WebDriver, diff --git a/src/lib/helper/threads.rs b/src/lib/helper/threads.rs index 39da7ac3..95934893 100644 --- a/src/lib/helper/threads.rs +++ b/src/lib/helper/threads.rs @@ -1,6 +1,6 @@ +use std::{collections::HashMap, thread, time::Duration}; + use cached::proc_macro::cached; -use std::time::Duration; -use std::{collections::HashMap, thread}; use sysinfo::{PidExt, ProcessExt, System, SystemExt}; use tracing::*; diff --git a/src/lib/logger/manager.rs b/src/lib/logger/manager.rs index 7ac03094..5f5fc6c6 100644 --- a/src/lib/logger/manager.rs +++ b/src/lib/logger/manager.rs @@ -1,9 +1,9 @@ -use crate::cli; - use tracing::{metadata::LevelFilter, *}; use tracing_log::LogTracer; use tracing_subscriber::{fmt, layer::SubscriberExt, EnvFilter, Layer}; +use crate::cli; + // Start logger, should be done inside main pub fn init() { // Redirect all logs from libs using "Log" diff --git a/src/lib/mavlink/manager.rs b/src/lib/mavlink/manager.rs index a1b02ad0..eb0a9f57 100644 --- a/src/lib/mavlink/manager.rs +++ b/src/lib/mavlink/manager.rs @@ -1,8 +1,9 @@ -use std::marker::Send; -use std::sync::{Arc, Mutex, RwLock}; +use std::{ + marker::Send, + sync::{Arc, Mutex, RwLock}, +}; -use mavlink::common::MavMessage; -use mavlink::{MavConnection, MavHeader}; +use mavlink::{common::MavMessage, MavConnection, MavHeader}; use tokio::sync::broadcast; use tracing::*; diff --git a/src/lib/mavlink/mavlink_camera.rs b/src/lib/mavlink/mavlink_camera.rs index ba5a2896..2e7d2292 100644 --- a/src/lib/mavlink/mavlink_camera.rs +++ b/src/lib/mavlink/mavlink_camera.rs @@ -1,19 +1,18 @@ use std::sync::Arc; -use crate::{ - cli, mavlink::mavlink_camera_component::MavlinkCameraComponent, - network::utils::get_visible_qgc_address, video::types::VideoSourceType, - video_stream::types::VideoAndStreamInformation, -}; - use anyhow::{anyhow, Context, Result}; use mavlink::{common::MavMessage, MavHeader}; use tokio::sync::broadcast; use tracing::*; use url::Url; -use super::manager::Message; -use super::utils::*; +use crate::{ + cli, mavlink::mavlink_camera_component::MavlinkCameraComponent, + network::utils::get_visible_qgc_address, video::types::VideoSourceType, + video_stream::types::VideoAndStreamInformation, +}; + +use super::{manager::Message, utils::*}; #[derive(Debug)] pub struct MavlinkCamera { diff --git a/src/lib/mavlink/mavlink_camera_component.rs b/src/lib/mavlink/mavlink_camera_component.rs index 0ad007b6..6f1f1ee8 100644 --- a/src/lib/mavlink/mavlink_camera_component.rs +++ b/src/lib/mavlink/mavlink_camera_component.rs @@ -1,8 +1,8 @@ -use crate::video_stream::types::VideoAndStreamInformation; - use anyhow::Result; use tracing::*; +use crate::video_stream::types::VideoAndStreamInformation; + #[derive(Debug, Clone)] pub struct MavlinkCameraComponent { // MAVLink specific information diff --git a/src/lib/server/manager.rs b/src/lib/server/manager.rs index ae912169..6de51d30 100644 --- a/src/lib/server/manager.rs +++ b/src/lib/server/manager.rs @@ -1,5 +1,3 @@ -use super::pages; - use actix_cors::Cors; use actix_extensible_rate_limit::{ backend::{memory::InMemoryBackend, SimpleInputFunctionBuilder}, @@ -11,10 +9,11 @@ use paperclip::{ actix::{web, OpenApiExt}, v2::models::{Api, Info}, }; - use tracing::*; use tracing_actix_web::TracingLogger; +use super::pages; + fn json_error_handler(error: JsonPayloadError, _: &HttpRequest) -> actix_web::Error { warn!("Problem with json: {error}"); error.into() diff --git a/src/lib/server/pages.rs b/src/lib/server/pages.rs index de80c9a7..0b853a21 100644 --- a/src/lib/server/pages.rs +++ b/src/lib/server/pages.rs @@ -1,26 +1,26 @@ -use crate::controls::types::Control; -use crate::helper; -use crate::settings; -use crate::stream::{gst as gst_stream, manager as stream_manager, types::StreamInformation}; -use crate::video::{ - types::{Format, VideoSourceType}, - video_source, - video_source::VideoSource, - xml, -}; -use crate::video_stream::types::VideoAndStreamInformation; -use actix_web::http::header; +use std::io::prelude::*; + use actix_web::{ + http::header, web::{self, Json}, HttpRequest, HttpResponse, }; - use paperclip::actix::{api_v2_operation, Apiv2Schema, CreatedJson}; use serde::{Deserialize, Serialize}; use tracing::*; use validator::Validate; -use std::io::prelude::*; +use crate::{ + controls::types::Control, + helper, settings, + stream::{gst as gst_stream, manager as stream_manager, types::StreamInformation}, + video::{ + types::{Format, VideoSourceType}, + video_source::{self, VideoSource}, + xml, + }, + video_stream::types::VideoAndStreamInformation, +}; #[derive(Apiv2Schema, Debug, Serialize)] pub struct ApiVideoSource { diff --git a/src/lib/settings/manager.rs b/src/lib/settings/manager.rs index 441c50b8..d381cf58 100644 --- a/src/lib/settings/manager.rs +++ b/src/lib/settings/manager.rs @@ -1,14 +1,15 @@ +use std::{ + io::Write, + path::Path, + sync::{Arc, RwLock}, +}; + use anyhow::{anyhow, Error, Result}; use directories::ProjectDirs; use serde::{Deserialize, Serialize}; -use std::io::prelude::*; -use std::path::Path; -use std::sync::{Arc, RwLock}; use tracing::*; -use crate::cli; -use crate::custom; -use crate::video_stream::types::VideoAndStreamInformation; +use crate::{cli, custom, video_stream::types::VideoAndStreamInformation}; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct HeaderSettingsFile { diff --git a/src/lib/stream/gst/info.rs b/src/lib/stream/gst/info.rs index e02ef622..44627fb7 100644 --- a/src/lib/stream/gst/info.rs +++ b/src/lib/stream/gst/info.rs @@ -1,5 +1,4 @@ -use std::collections::BTreeMap; -use std::path::PathBuf; +use std::{collections::BTreeMap, path::PathBuf}; use glib; use gst::prelude::ObjectExt; diff --git a/src/lib/stream/gst/utils.rs b/src/lib/stream/gst/utils.rs index c15abbf4..b9a94bbb 100644 --- a/src/lib/stream/gst/utils.rs +++ b/src/lib/stream/gst/utils.rs @@ -1,5 +1,8 @@ use anyhow::{anyhow, Result}; use gst::prelude::*; +use tracing::*; + +use crate::video::types::VideoEncodeType; #[derive(Debug)] pub struct PluginRankConfig { diff --git a/src/lib/stream/manager.rs b/src/lib/stream/manager.rs index 11d70444..1c008043 100644 --- a/src/lib/stream/manager.rs +++ b/src/lib/stream/manager.rs @@ -1,26 +1,22 @@ use std::{collections::HashMap, sync::Arc}; +use anyhow::{anyhow, Context, Error, Result}; +use cached::proc_macro::cached; +use futures::stream::StreamExt; use tokio::sync::RwLock; +use tracing::*; use crate::{ settings, - stream::{types::CaptureConfiguration, webrtc::signalling_protocol::BindAnswer}, - video::video_source, -}; -use crate::{stream::sink::SinkInterface, video::types::VideoSourceType}; -use crate::{ - stream::sink::{webrtc_sink::WebRTCSink, Sink}, + stream::{ + sink::{webrtc_sink::WebRTCSink, Sink, SinkInterface}, + types::CaptureConfiguration, + webrtc::signalling_protocol::BindAnswer, + }, + video::{types::VideoSourceType, video_source}, video_stream::types::VideoAndStreamInformation, }; -use anyhow::{anyhow, Context, Error, Result}; - -type ClonableResult = Result>; - -use cached::proc_macro::cached; -use futures::stream::StreamExt; -use tracing::*; - use super::{ pipeline::PipelineGstreamerInterface, types::StreamStatus, @@ -28,6 +24,8 @@ use super::{ Stream, }; +type ClonableResult = Result>; + #[derive(Default)] pub struct Manager { streams: HashMap, diff --git a/src/lib/stream/mod.rs b/src/lib/stream/mod.rs index 2a7e3f88..35788e67 100644 --- a/src/lib/stream/mod.rs +++ b/src/lib/stream/mod.rs @@ -8,29 +8,30 @@ pub mod webrtc; use std::sync::Arc; -use tokio::sync::RwLock; - -use crate::mavlink::mavlink_camera::MavlinkCamera; -use crate::video::types::{VideoEncodeType, VideoSourceType}; -use crate::video::video_source::cameras_available; -use crate::video_stream::types::VideoAndStreamInformation; - +use ::gst::prelude::*; +use anyhow::{anyhow, Result}; use manager::Manager; use pipeline::Pipeline; use sink::{create_image_sink, create_rtsp_sink, create_udp_sink}; +use tokio::sync::RwLock; +use tracing::*; use types::*; use webrtc::signalling_protocol::PeerId; -use anyhow::{anyhow, Result}; - -use tracing::*; - -use self::gst::utils::wait_for_element_state; -use self::rtsp::rtsp_scheme::RTSPScheme; -use self::rtsp::rtsp_server::RTSP_SERVER_PORT; -use self::sink::SinkInterface; - -use ::gst::prelude::*; +use crate::{ + mavlink::mavlink_camera::MavlinkCamera, + video::{ + types::{VideoEncodeType, VideoSourceType}, + video_source::cameras_available, + }, + video_stream::types::VideoAndStreamInformation, +}; + +use self::{ + gst::utils::wait_for_element_state, + rtsp::{rtsp_scheme::RTSPScheme, rtsp_server::RTSP_SERVER_PORT}, + sink::SinkInterface, +}; #[derive(Debug)] pub struct Stream { diff --git a/src/lib/stream/pipeline/fake_pipeline.rs b/src/lib/stream/pipeline/fake_pipeline.rs index bcc2f456..4c82214a 100644 --- a/src/lib/stream/pipeline/fake_pipeline.rs +++ b/src/lib/stream/pipeline/fake_pipeline.rs @@ -1,3 +1,7 @@ +use anyhow::{anyhow, Result}; +use gst::prelude::*; +use tracing::*; + use crate::{ stream::types::CaptureConfiguration, video::{ @@ -12,12 +16,6 @@ use super::{ PIPELINE_VIDEO_TEE_NAME, }; -use anyhow::{anyhow, Result}; - -use tracing::*; - -use gst::prelude::*; - #[derive(Debug)] pub struct FakePipeline { pub state: PipelineState, diff --git a/src/lib/stream/pipeline/mod.rs b/src/lib/stream/pipeline/mod.rs index 0098d876..5c899eee 100644 --- a/src/lib/stream/pipeline/mod.rs +++ b/src/lib/stream/pipeline/mod.rs @@ -7,13 +7,10 @@ pub mod v4l_pipeline; use std::collections::HashMap; -use enum_dispatch::enum_dispatch; - use anyhow::{anyhow, Context, Result}; - -use tracing::*; - +use enum_dispatch::enum_dispatch; use gst::prelude::*; +use tracing::*; use crate::{ stream::{ diff --git a/src/lib/stream/pipeline/qr_pipeline.rs b/src/lib/stream/pipeline/qr_pipeline.rs index 1cd1a2c5..a3a5f4fb 100644 --- a/src/lib/stream/pipeline/qr_pipeline.rs +++ b/src/lib/stream/pipeline/qr_pipeline.rs @@ -1,3 +1,7 @@ +use anyhow::{anyhow, Result}; +use gst::prelude::*; +use tracing::*; + use crate::{ stream::types::CaptureConfiguration, video::{ @@ -12,12 +16,6 @@ use super::{ PIPELINE_VIDEO_TEE_NAME, }; -use anyhow::{anyhow, Result}; - -use tracing::*; - -use gst::prelude::*; - #[derive(Debug)] pub struct QrPipeline { pub state: PipelineState, diff --git a/src/lib/stream/pipeline/redirect_pipeline.rs b/src/lib/stream/pipeline/redirect_pipeline.rs index 59576610..fef719e3 100644 --- a/src/lib/stream/pipeline/redirect_pipeline.rs +++ b/src/lib/stream/pipeline/redirect_pipeline.rs @@ -1,3 +1,7 @@ +use anyhow::{anyhow, Context, Result}; +use gst::prelude::*; +use tracing::*; + use crate::{ stream::types::CaptureConfiguration, video::types::VideoSourceType, video_stream::types::VideoAndStreamInformation, @@ -5,12 +9,6 @@ use crate::{ use super::{PipelineGstreamerInterface, PipelineState, PIPELINE_RTP_TEE_NAME}; -use anyhow::{anyhow, Context, Result}; - -use tracing::*; - -use gst::prelude::*; - #[derive(Debug)] pub struct RedirectPipeline { pub state: PipelineState, diff --git a/src/lib/stream/pipeline/v4l_pipeline.rs b/src/lib/stream/pipeline/v4l_pipeline.rs index 86bbd6ad..c4dd5b89 100644 --- a/src/lib/stream/pipeline/v4l_pipeline.rs +++ b/src/lib/stream/pipeline/v4l_pipeline.rs @@ -1,3 +1,7 @@ +use anyhow::{anyhow, Result}; +use gst::prelude::*; +use tracing::*; + use crate::{ stream::types::CaptureConfiguration, video::types::{VideoEncodeType, VideoSourceType}, @@ -9,12 +13,6 @@ use super::{ PIPELINE_VIDEO_TEE_NAME, }; -use anyhow::{anyhow, Result}; - -use tracing::*; - -use gst::prelude::*; - #[derive(Debug)] pub struct V4lPipeline { pub state: PipelineState, diff --git a/src/lib/stream/rtsp/rtsp_server.rs b/src/lib/stream/rtsp/rtsp_server.rs index 5d63bc03..ce0cb328 100644 --- a/src/lib/stream/rtsp/rtsp_server.rs +++ b/src/lib/stream/rtsp/rtsp_server.rs @@ -1,6 +1,8 @@ -use std::collections::HashMap; -use std::sync::{Arc, Mutex}; -use std::thread; +use std::{ + collections::HashMap, + sync::{Arc, Mutex}, + thread, +}; use anyhow::{anyhow, Context, Result}; use gst_rtsp::RTSPLowerTrans; diff --git a/src/lib/stream/sink/image_sink.rs b/src/lib/stream/sink/image_sink.rs index a2d8367e..39f5b663 100644 --- a/src/lib/stream/sink/image_sink.rs +++ b/src/lib/stream/sink/image_sink.rs @@ -4,16 +4,14 @@ use std::{ }; use anyhow::{anyhow, Context, Error, Result}; - +use gst::prelude::*; use gst_video::VideoFrameExt; -use tracing::*; - use image::FlatSamples; +use tracing::*; -use gst::prelude::*; +use crate::{stream::pipeline::runner::PipelineRunner, video::types::VideoEncodeType}; use super::SinkInterface; -use crate::{stream::pipeline::runner::PipelineRunner, video::types::VideoEncodeType}; type ClonableResult = Result>; diff --git a/src/lib/stream/sink/mod.rs b/src/lib/stream/sink/mod.rs index ed4906fb..0a0ea405 100644 --- a/src/lib/stream/sink/mod.rs +++ b/src/lib/stream/sink/mod.rs @@ -3,7 +3,9 @@ pub mod rtsp_sink; pub mod udp_sink; pub mod webrtc_sink; +use anyhow::{anyhow, Result}; use enum_dispatch::enum_dispatch; +use tracing::*; use crate::video_stream::types::VideoAndStreamInformation; @@ -12,10 +14,6 @@ use rtsp_sink::RtspSink; use udp_sink::UdpSink; use webrtc_sink::WebRTCSink; -use anyhow::{anyhow, Result}; - -use tracing::*; - #[enum_dispatch] pub trait SinkInterface { /// Link this Sink's sink pad to the given Pipelines's Tee element's src pad. diff --git a/src/lib/stream/sink/rtsp_sink.rs b/src/lib/stream/sink/rtsp_sink.rs index 91843b92..7094bf5f 100644 --- a/src/lib/stream/sink/rtsp_sink.rs +++ b/src/lib/stream/sink/rtsp_sink.rs @@ -1,8 +1,6 @@ use anyhow::{anyhow, Context, Result}; - -use tracing::*; - use gst::prelude::*; +use tracing::*; use crate::stream::rtsp::rtsp_scheme::RTSPScheme; diff --git a/src/lib/stream/sink/udp_sink.rs b/src/lib/stream/sink/udp_sink.rs index 7e6ef888..82123005 100644 --- a/src/lib/stream/sink/udp_sink.rs +++ b/src/lib/stream/sink/udp_sink.rs @@ -1,11 +1,10 @@ use anyhow::{anyhow, Context, Result}; - +use gst::prelude::*; use tracing::*; -use gst::prelude::*; +use crate::stream::pipeline::runner::PipelineRunner; use super::SinkInterface; -use crate::stream::pipeline::runner::PipelineRunner; #[derive(Debug)] pub struct UdpSink { diff --git a/src/lib/stream/sink/webrtc_sink.rs b/src/lib/stream/sink/webrtc_sink.rs index 4100bc24..10f4c0bd 100644 --- a/src/lib/stream/sink/webrtc_sink.rs +++ b/src/lib/stream/sink/webrtc_sink.rs @@ -1,15 +1,20 @@ -use crate::cli; use anyhow::{anyhow, Context, Result}; use gst::prelude::*; use tokio::sync::mpsc::{self, WeakUnboundedSender}; use tracing::*; -use super::SinkInterface; -use crate::stream::webrtc::signalling_protocol::{ - Answer, BindAnswer, EndSessionQuestion, IceNegotiation, MediaNegotiation, Message, Question, - RTCIceCandidateInit, RTCSessionDescription, Sdp, +use crate::{ + cli, + stream::webrtc::{ + signalling_protocol::{ + Answer, BindAnswer, EndSessionQuestion, IceNegotiation, MediaNegotiation, Message, + Question, RTCIceCandidateInit, RTCSessionDescription, Sdp, + }, + webrtcbin_interface::WebRTCBinInterface, + }, }; -use crate::stream::webrtc::webrtcbin_interface::WebRTCBinInterface; + +use super::SinkInterface; #[derive(Clone)] pub struct WebRTCSinkWeakProxy { diff --git a/src/lib/stream/webrtc/signalling_server.rs b/src/lib/stream/webrtc/signalling_server.rs index 19cec31f..64eb10cf 100644 --- a/src/lib/stream/webrtc/signalling_server.rs +++ b/src/lib/stream/webrtc/signalling_server.rs @@ -1,15 +1,16 @@ use std::net::SocketAddr; -use crate::{cli, stream}; use anyhow::{anyhow, Context, Result}; -use async_tungstenite::tokio::TokioAdapter; -use async_tungstenite::{tungstenite, WebSocketStream}; +use async_tungstenite::{tokio::TokioAdapter, tungstenite, WebSocketStream}; use futures::{SinkExt, StreamExt}; -use tokio::net::{TcpListener, TcpStream}; -use tokio::sync::mpsc; - +use tokio::{ + net::{TcpListener, TcpStream}, + sync::mpsc, +}; use tracing::*; +use crate::{cli, stream}; + use super::signalling_protocol::{self, *}; #[derive(Debug)] diff --git a/src/lib/stream/webrtc/turn_server.rs b/src/lib/stream/webrtc/turn_server.rs index 5d27da41..8647c1ca 100644 --- a/src/lib/stream/webrtc/turn_server.rs +++ b/src/lib/stream/webrtc/turn_server.rs @@ -1,19 +1,20 @@ -use std::collections::HashMap; -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; -use std::sync::Arc; -use std::thread; +use std::{ + collections::HashMap, + net::{IpAddr, Ipv4Addr, SocketAddr}, + sync::Arc, + thread, +}; use anyhow::{Context, Result}; use tokio::net::UdpSocket; - -use webrtc_util::vnet::net::Net; - -use turn::auth::*; -use turn::relay::relay_static::*; -use turn::server::{config::*, *}; -use turn::Error; - use tracing::*; +use turn::{ + auth::*, + relay::relay_static::*, + server::{config::*, *}, + Error, +}; +use webrtc_util::vnet::net::Net; pub const DEFAULT_TURN_ENDPOINT: &str = "turn://user:pwd@0.0.0.0:3478"; diff --git a/src/lib/video/local/video_source_local_linux.rs b/src/lib/video/local/video_source_local_linux.rs index e96863e3..16854ecb 100644 --- a/src/lib/video/local/video_source_local_linux.rs +++ b/src/lib/video/local/video_source_local_linux.rs @@ -2,20 +2,19 @@ use std::cmp::max; use std::collections::HashMap; use std::sync::{Arc, Mutex}; -use crate::controls::types::*; -use crate::stream::types::VideoCaptureConfiguration; - -use crate::video::types::*; -use crate::video::video_source::{VideoSource, VideoSourceAvailable}; +use anyhow::{anyhow, Result}; +use lazy_static::lazy_static; use paperclip::actix::Apiv2Schema; use regex::Regex; use serde::{Deserialize, Serialize}; - -use anyhow::{anyhow, Result}; - use tracing::*; -use lazy_static::lazy_static; +use crate::video::video_source::VideoSourceAvailable; +use crate::{ + controls::types::*, + stream::types::VideoCaptureConfiguration, + video::{types::*, video_source::VideoSource}, +}; lazy_static! { static ref VIDEO_FORMATS: Arc>>> = Default::default(); diff --git a/src/lib/video/local/video_source_local_none.rs b/src/lib/video/local/video_source_local_none.rs index 41ad0a47..14630915 100644 --- a/src/lib/video/local/video_source_local_none.rs +++ b/src/lib/video/local/video_source_local_none.rs @@ -1,12 +1,15 @@ -use crate::controls::types::Control; -use crate::stream::types::VideoCaptureConfiguration; -use crate::video::types::*; -use crate::video::video_source::{VideoSource, VideoSourceAvailable}; - +use anyhow::Result; use paperclip::actix::Apiv2Schema; use serde::{Deserialize, Serialize}; -use anyhow::Result; +use crate::{ + controls::types::Control, + stream::types::VideoCaptureConfiguration, + video::{ + types::*, + video_source::{VideoSource, VideoSourceAvailable}, + }, +}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum VideoSourceLocalType {} diff --git a/src/lib/video/types.rs b/src/lib/video/types.rs index eec06957..2ae0714b 100644 --- a/src/lib/video/types.rs +++ b/src/lib/video/types.rs @@ -1,11 +1,12 @@ -use super::video_source::VideoSource; -use super::video_source_gst::VideoSourceGst; -use super::video_source_local::VideoSourceLocal; -use super::video_source_redirect::VideoSourceRedirect; use gst; use paperclip::actix::Apiv2Schema; use serde::{Deserialize, Serialize}; +use super::{ + video_source::VideoSource, video_source_gst::VideoSourceGst, + video_source_local::VideoSourceLocal, video_source_redirect::VideoSourceRedirect, +}; + #[derive(Apiv2Schema, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum VideoSourceType { Gst(VideoSourceGst), diff --git a/src/lib/video/video_source.rs b/src/lib/video/video_source.rs index 156244e9..38f7694d 100644 --- a/src/lib/video/video_source.rs +++ b/src/lib/video/video_source.rs @@ -1,10 +1,11 @@ +use tracing::*; + use crate::controls::types::{Control, ControlType}; -use super::types::*; -use super::video_source_gst::VideoSourceGst; -use super::video_source_local::VideoSourceLocal; -use super::video_source_redirect::VideoSourceRedirect; -use tracing::*; +use super::{ + types::*, video_source_gst::VideoSourceGst, video_source_local::VideoSourceLocal, + video_source_redirect::VideoSourceRedirect, +}; pub trait VideoSource { fn name(&self) -> &String; diff --git a/src/lib/video/video_source_gst.rs b/src/lib/video/video_source_gst.rs index ed2174a2..cc675564 100644 --- a/src/lib/video/video_source_gst.rs +++ b/src/lib/video/video_source_gst.rs @@ -1,13 +1,14 @@ -use crate::controls::types::Control; -use crate::stream::gst::utils::is_gst_plugin_available; - -use super::types::*; -use super::video_source::{VideoSource, VideoSourceAvailable}; -use super::video_source_local::VideoSourceLocal; - use paperclip::actix::Apiv2Schema; use serde::{Deserialize, Serialize}; +use crate::{controls::types::Control, stream::gst::utils::is_gst_plugin_available}; + +use super::{ + types::*, + video_source::{VideoSource, VideoSourceAvailable}, + video_source_local::VideoSourceLocal, +}; + #[derive(Apiv2Schema, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum VideoSourceGstType { // TODO: local should have a pipeline also diff --git a/src/lib/video/video_source_redirect.rs b/src/lib/video/video_source_redirect.rs index 353fd947..634a7c84 100644 --- a/src/lib/video/video_source_redirect.rs +++ b/src/lib/video/video_source_redirect.rs @@ -1,10 +1,13 @@ -use super::types::*; -use super::video_source::{VideoSource, VideoSourceAvailable}; -use crate::controls::types::Control; - use paperclip::actix::Apiv2Schema; use serde::{Deserialize, Serialize}; +use crate::controls::types::Control; + +use super::{ + types::*, + video_source::{VideoSource, VideoSourceAvailable}, +}; + #[derive(Apiv2Schema, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum VideoSourceRedirectType { Redirect(String), diff --git a/src/lib/video/xml.rs b/src/lib/video/xml.rs index a38fb69d..14083c9b 100644 --- a/src/lib/video/xml.rs +++ b/src/lib/video/xml.rs @@ -1,9 +1,10 @@ -use super::video_source::VideoSource; -use crate::controls::types::ControlType; - use anyhow::{anyhow, Result}; use serde::Serialize; +use crate::controls::types::ControlType; + +use super::video_source::VideoSource; + #[derive(Debug, Serialize)] #[serde(rename = "mavlinkcamera")] pub struct MavlinkCamera { @@ -191,10 +192,11 @@ pub fn from_video_source(video_source: &dyn VideoSource) -> Result { #[cfg(test)] mod tests { + use quick_xml::se::to_string; + use crate::video::types::VideoSourceType; use super::*; - use quick_xml::se::to_string; #[test] fn test_device() { diff --git a/src/lib/video_stream/types.rs b/src/lib/video_stream/types.rs index 55867fd3..b7ce83a2 100644 --- a/src/lib/video_stream/types.rs +++ b/src/lib/video_stream/types.rs @@ -1,12 +1,10 @@ -use crate::stream::types::StreamInformation; -use crate::video::types::VideoSourceType; +use std::collections::HashSet; +use anyhow::{anyhow, Result}; use paperclip::actix::Apiv2Schema; use serde::{Deserialize, Serialize}; -use std::collections::HashSet; - -use anyhow::{anyhow, Result}; +use crate::{stream::types::StreamInformation, video::types::VideoSourceType}; //TODO: move to stream ? #[derive(Apiv2Schema, Clone, Debug, PartialEq, Deserialize, Serialize)]