From 3d4a3d869a0a7b593fe152a8eae4791c04dc69e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sat, 15 Jun 2024 13:23:24 -0300 Subject: [PATCH] server: Add endpoint for gst_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/server/manager.rs | 1 + src/server/pages.rs | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/server/manager.rs b/src/server/manager.rs index 1376b301..24b4796c 100644 --- a/src/server/manager.rs +++ b/src/server/manager.rs @@ -64,6 +64,7 @@ pub async fn run(server_address: &str) -> Result<(), std::io::Error> { r"/{filename:.*(\.html|\.js|\.css)}", web::get().to(pages::root), ) + .route("/gst_info", web::get().to(pages::gst_info)) .route("/info", web::get().to(pages::info)) .route("/delete_stream", web::delete().to(pages::remove_stream)) .route("/reset_settings", web::post().to(pages::reset_settings)) diff --git a/src/server/pages.rs b/src/server/pages.rs index e5e79ca7..01e322c3 100644 --- a/src/server/pages.rs +++ b/src/server/pages.rs @@ -1,6 +1,6 @@ use crate::helper; use crate::settings; -use crate::stream::{manager as stream_manager, types::StreamInformation}; +use crate::stream::{gst as gst_stream, manager as stream_manager, types::StreamInformation}; use crate::video::{ types::{Control, Format, VideoSourceType}, video_source, @@ -464,3 +464,18 @@ pub async fn thumbnail(thumbnail_file_request: web::Query) )), } } + +#[api_v2_operation] +/// Provides information related to all gst plugins available for camera manager +pub async fn gst_info() -> HttpResponse { + let gst_info = gst_stream::info::Info::default(); + + match serde_json::to_string_pretty(&gst_info) { + Ok(json) => HttpResponse::Ok() + .content_type("application/json") + .body(json), + Err(error) => HttpResponse::InternalServerError() + .content_type("text/plain") + .body(format!("{error:#?}")), + } +}