2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-05-09 09:20:59 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::Caps;
|
|
|
|
use crate::Stream;
|
|
|
|
use crate::StreamFlags;
|
|
|
|
use crate::StreamType;
|
2018-07-27 10:36:40 +00:00
|
|
|
use glib::translate::*;
|
2020-04-14 17:29:43 +00:00
|
|
|
use std::fmt;
|
2018-05-09 09:20:59 +00:00
|
|
|
|
|
|
|
impl Stream {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_stream_new")]
|
2019-05-23 18:19:24 +00:00
|
|
|
pub fn new(
|
|
|
|
stream_id: Option<&str>,
|
|
|
|
caps: Option<&Caps>,
|
2018-07-27 10:36:40 +00:00
|
|
|
type_: StreamType,
|
|
|
|
flags: StreamFlags,
|
|
|
|
) -> Stream {
|
2018-05-09 09:20:59 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let stream_id = stream_id.to_glib_none();
|
|
|
|
let caps = caps.to_glib_none();
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
let (major, minor, _, _) = crate::version();
|
2018-05-09 09:20:59 +00:00
|
|
|
if (major, minor) > (1, 12) {
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
from_glib_full(ffi::gst_stream_new(
|
2018-07-27 10:36:40 +00:00
|
|
|
stream_id.0,
|
|
|
|
caps.0,
|
2021-04-27 15:15:46 +00:00
|
|
|
type_.into_glib(),
|
|
|
|
flags.into_glib(),
|
2018-07-27 10:36:40 +00:00
|
|
|
))
|
2018-05-09 09:20:59 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Work-around for 1.14 switching from transfer-floating to transfer-full
|
|
|
|
unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
from_glib_none(ffi::gst_stream_new(
|
2018-07-27 10:36:40 +00:00
|
|
|
stream_id.0,
|
|
|
|
caps.0,
|
2021-04-27 15:15:46 +00:00
|
|
|
type_.into_glib(),
|
|
|
|
flags.into_glib(),
|
2018-07-27 10:36:40 +00:00
|
|
|
))
|
2018-05-09 09:20:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-14 17:29:43 +00:00
|
|
|
|
|
|
|
pub fn debug(&self) -> Debug {
|
|
|
|
Debug(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct Debug<'a>(&'a Stream);
|
|
|
|
|
|
|
|
impl<'a> fmt::Debug for Debug<'a> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.debug_struct("Stream")
|
2021-04-11 19:39:50 +00:00
|
|
|
.field("stream_id", &self.0.stream_id())
|
|
|
|
.field("stream_type", &self.0.stream_type())
|
|
|
|
.field("stream_flags", &self.0.stream_flags())
|
|
|
|
.field("caps", &self.0.caps())
|
|
|
|
.field("tags", &self.0.tags())
|
2020-04-14 17:29:43 +00:00
|
|
|
.finish()
|
|
|
|
}
|
2018-05-09 09:20:59 +00:00
|
|
|
}
|