From 25da173ec8790264fbb5d23218b3201efb2232a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Brzezi=C5=84ski?= Date: Wed, 20 Mar 2024 19:24:33 +0100 Subject: [PATCH] audio: Implement From/ToValue in Audio/VideoConverterConfig Part-of: --- gstreamer-audio/src/audio_converter.rs | 24 ++++++++++++++++++++++++ gstreamer-video/src/video_converter.rs | 26 +++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/gstreamer-audio/src/audio_converter.rs b/gstreamer-audio/src/audio_converter.rs index d98472b47..3f4eed91e 100644 --- a/gstreamer-audio/src/audio_converter.rs +++ b/gstreamer-audio/src/audio_converter.rs @@ -73,6 +73,30 @@ impl From for gst::Structure { } } +impl glib::value::ToValue for AudioConverterConfig { + fn to_value(&self) -> glib::Value { + self.0.to_value() + } + + fn value_type(&self) -> glib::Type { + self.0.value_type() + } +} + +impl glib::value::ToValueOptional for AudioConverterConfig { + fn to_value_optional(s: Option<&Self>) -> glib::Value { + skip_assert_initialized!(); + s.map(|s| &s.0).to_value() + } +} + +impl From for glib::Value { + fn from(s: AudioConverterConfig) -> glib::Value { + skip_assert_initialized!(); + s.0.into() + } +} + impl AudioConverterConfig { pub fn new() -> Self { Self(gst::Structure::new_empty("GstAudioConverter")) diff --git a/gstreamer-video/src/video_converter.rs b/gstreamer-video/src/video_converter.rs index 5865304b5..3e2ff4772 100644 --- a/gstreamer-video/src/video_converter.rs +++ b/gstreamer-video/src/video_converter.rs @@ -3,7 +3,7 @@ use std::{ops, ptr}; use crate::VideoFrameExt; -use glib::translate::*; +use glib::{prelude::*, translate::*}; #[derive(Debug)] #[doc(alias = "GstVideoConverter")] @@ -179,6 +179,30 @@ impl From for gst::Structure { } } +impl glib::value::ToValue for VideoConverterConfig { + fn to_value(&self) -> glib::Value { + self.0.to_value() + } + + fn value_type(&self) -> glib::Type { + self.0.value_type() + } +} + +impl glib::value::ToValueOptional for VideoConverterConfig { + fn to_value_optional(s: Option<&Self>) -> glib::Value { + skip_assert_initialized!(); + s.map(|s| &s.0).to_value() + } +} + +impl From for glib::Value { + fn from(s: VideoConverterConfig) -> glib::Value { + skip_assert_initialized!(); + s.0.into() + } +} + impl VideoConverterConfig { pub fn new() -> Self { Self(gst::Structure::new_empty("GstVideoConverter"))