Skip to content

Commit

Permalink
server: Add endpoint for gst_info
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Jun 15, 2024
1 parent 00c8e71 commit 3d4a3d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/server/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 16 additions & 1 deletion src/server/pages.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -464,3 +464,18 @@ pub async fn thumbnail(thumbnail_file_request: web::Query<ThumbnailFileRequest>)
)),
}
}

#[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:#?}")),
}
}

0 comments on commit 3d4a3d8

Please sign in to comment.