use crate::{gstd_types, resources::Pipeline, Error, GstClient};
#[derive(Debug, Clone)]
pub struct PipelineBus {
client: GstClient,
pipeline: Pipeline,
}
impl PipelineBus {
pub(crate) fn new(pipeline: &Pipeline) -> Self {
Self {
pipeline: pipeline.clone(),
client: pipeline.client.clone(),
}
}
pub async fn read(&self) -> Result<gstd_types::SuccessResponse, Error> {
let resp = self
.client
.get(&format!("pipelines/{}/bus/message", self.pipeline.name))
.await?;
self.client.process_resp(resp).await
}
pub async fn set_timeout(&self, time_ns: i32) -> Result<gstd_types::SuccessResponse, Error> {
let resp = self
.client
.put(&format!(
"pipelines/{}/bus/timeout?name={time_ns}",
self.pipeline.name
))
.await?;
self.client.process_resp(resp).await
}
pub async fn set_filter(&self, filter: &str) -> Result<gstd_types::SuccessResponse, Error> {
let resp = self
.client
.put(&format!(
"pipelines/{}/bus/types?name={filter}",
self.pipeline.name
))
.await?;
self.client.process_resp(resp).await
}
}