Skip to content

Commit

Permalink
src: lib: Reorganize and merge imports
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Nov 6, 2024
1 parent 2bb9135 commit 28e8a4a
Show file tree
Hide file tree
Showing 38 changed files with 219 additions and 212 deletions.
16 changes: 11 additions & 5 deletions src/lib/controls/onvif/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;

Expand Down
12 changes: 7 additions & 5 deletions src/lib/custom/bluerov.rs
Original file line number Diff line number Diff line change
@@ -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<VideoSourceType> {
let cameras = video::video_source_local::VideoSourceLocal::cameras_available();
Expand Down
9 changes: 4 additions & 5 deletions src/lib/custom/mod.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions src/lib/custom/test.rs
Original file line number Diff line number Diff line change
@@ -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<VideoAndStreamInformation> {
let size = STANDARD_SIZES.last().unwrap();
Expand Down
8 changes: 3 additions & 5 deletions src/lib/helper/develop.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/helper/threads.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/logger/manager.rs
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 5 additions & 4 deletions src/lib/mavlink/manager.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
15 changes: 7 additions & 8 deletions src/lib/mavlink/mavlink_camera.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/mavlink/mavlink_camera_component.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/lib/server/manager.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use super::pages;

use actix_cors::Cors;
use actix_extensible_rate_limit::{
backend::{memory::InMemoryBackend, SimpleInputFunctionBuilder},
Expand All @@ -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()
Expand Down
28 changes: 14 additions & 14 deletions src/lib/server/pages.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
13 changes: 7 additions & 6 deletions src/lib/settings/manager.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/stream/gst/info.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::path::PathBuf;
use std::{collections::BTreeMap, path::PathBuf};

use glib;
use gst::prelude::ObjectExt;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/stream/gst/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use anyhow::{anyhow, Result};
use gst::prelude::*;
use tracing::*;

use crate::video::types::VideoEncodeType;

#[derive(Debug)]
pub struct PluginRankConfig {
Expand Down
26 changes: 12 additions & 14 deletions src/lib/stream/manager.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
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<T> = Result<T, Arc<Error>>;

use cached::proc_macro::cached;
use futures::stream::StreamExt;
use tracing::*;

use super::{
pipeline::PipelineGstreamerInterface,
types::StreamStatus,
webrtc::{self, signalling_protocol::RTCSessionDescription},
Stream,
};

type ClonableResult<T> = Result<T, Arc<Error>>;

#[derive(Default)]
pub struct Manager {
streams: HashMap<uuid::Uuid, Stream>,
Expand Down
35 changes: 18 additions & 17 deletions src/lib/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 4 additions & 6 deletions src/lib/stream/pipeline/fake_pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use anyhow::{anyhow, Result};
use gst::prelude::*;
use tracing::*;

use crate::{
stream::types::CaptureConfiguration,
video::{
Expand All @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions src/lib/stream/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
Loading

0 comments on commit 28e8a4a

Please sign in to comment.