diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 3b7d1c6cd..ef8b811f3 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -27,7 +27,14 @@ generate = [ "Gst.URIType", "Gst.ElementFactoryListType", "Gst.Format", - "Gst.MessageType", + "Gst.BufferingMode", + "Gst.CoreError", + "Gst.ResourceError", + "Gst.LibraryError", + "Gst.StreamError", + "Gst.PluginError", + "Gst.ParseError", + "Gst.URIError", ] manual = [ diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index 8c07ab191..8e0ec8139 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -146,10 +146,10 @@ pub trait ElementExt { fn lost_state(&self); - //fn message_full<'a, 'b, P: Into>, Q: Into>>(&self, type_: MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32); + //fn message_full<'a, 'b, P: Into>, Q: Into>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32); //#[cfg(feature = "v1_10")] - //fn message_full_with_details<'a, 'b, P: Into>, Q: Into>>(&self, type_: MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32, structure: /*Ignored*/&mut Structure); + //fn message_full_with_details<'a, 'b, P: Into>, Q: Into>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32, structure: /*Ignored*/&mut Structure); fn no_more_pads(&self); @@ -395,12 +395,12 @@ impl + IsA> ElementExt for O { } } - //fn message_full<'a, 'b, P: Into>, Q: Into>>(&self, type_: MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32) { + //fn message_full<'a, 'b, P: Into>, Q: Into>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32) { // unsafe { TODO: call ffi::gst_element_message_full() } //} //#[cfg(feature = "v1_10")] - //fn message_full_with_details<'a, 'b, P: Into>, Q: Into>>(&self, type_: MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32, structure: /*Ignored*/&mut Structure) { + //fn message_full_with_details<'a, 'b, P: Into>, Q: Into>>(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: P, debug: Q, file: &str, function: &str, line: i32, structure: /*Ignored*/&mut Structure) { // unsafe { TODO: call ffi::gst_element_message_full_with_details() } //} diff --git a/gstreamer/src/auto/enums.rs b/gstreamer/src/auto/enums.rs index 331befa52..71ee6af78 100644 --- a/gstreamer/src/auto/enums.rs +++ b/gstreamer/src/auto/enums.rs @@ -2,9 +2,151 @@ // DO NOT EDIT use ffi; +use glib_ffi; +use glib::error::ErrorDomain; use glib::translate::*; use std; +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum BufferingMode { + Stream, + Download, + Timeshift, + Live, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for BufferingMode { + type GlibType = ffi::GstBufferingMode; + + fn to_glib(&self) -> ffi::GstBufferingMode { + match *self { + BufferingMode::Stream => ffi::GST_BUFFERING_STREAM, + BufferingMode::Download => ffi::GST_BUFFERING_DOWNLOAD, + BufferingMode::Timeshift => ffi::GST_BUFFERING_TIMESHIFT, + BufferingMode::Live => ffi::GST_BUFFERING_LIVE, + BufferingMode::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for BufferingMode { + fn from_glib(value: ffi::GstBufferingMode) -> Self { + match value as i32 { + 0 => BufferingMode::Stream, + 1 => BufferingMode::Download, + 2 => BufferingMode::Timeshift, + 3 => BufferingMode::Live, + value => BufferingMode::__Unknown(value), + } + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum CoreError { + Failed, + TooLazy, + NotImplemented, + StateChange, + Pad, + Thread, + Negotiation, + Event, + Seek, + Caps, + Tag, + MissingPlugin, + Clock, + Disabled, + NumErrors, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for CoreError { + type GlibType = ffi::GstCoreError; + + fn to_glib(&self) -> ffi::GstCoreError { + match *self { + CoreError::Failed => ffi::GST_CORE_ERROR_FAILED, + CoreError::TooLazy => ffi::GST_CORE_ERROR_TOO_LAZY, + CoreError::NotImplemented => ffi::GST_CORE_ERROR_NOT_IMPLEMENTED, + CoreError::StateChange => ffi::GST_CORE_ERROR_STATE_CHANGE, + CoreError::Pad => ffi::GST_CORE_ERROR_PAD, + CoreError::Thread => ffi::GST_CORE_ERROR_THREAD, + CoreError::Negotiation => ffi::GST_CORE_ERROR_NEGOTIATION, + CoreError::Event => ffi::GST_CORE_ERROR_EVENT, + CoreError::Seek => ffi::GST_CORE_ERROR_SEEK, + CoreError::Caps => ffi::GST_CORE_ERROR_CAPS, + CoreError::Tag => ffi::GST_CORE_ERROR_TAG, + CoreError::MissingPlugin => ffi::GST_CORE_ERROR_MISSING_PLUGIN, + CoreError::Clock => ffi::GST_CORE_ERROR_CLOCK, + CoreError::Disabled => ffi::GST_CORE_ERROR_DISABLED, + CoreError::NumErrors => ffi::GST_CORE_ERROR_NUM_ERRORS, + CoreError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for CoreError { + fn from_glib(value: ffi::GstCoreError) -> Self { + match value as i32 { + 1 => CoreError::Failed, + 2 => CoreError::TooLazy, + 3 => CoreError::NotImplemented, + 4 => CoreError::StateChange, + 5 => CoreError::Pad, + 6 => CoreError::Thread, + 7 => CoreError::Negotiation, + 8 => CoreError::Event, + 9 => CoreError::Seek, + 10 => CoreError::Caps, + 11 => CoreError::Tag, + 12 => CoreError::MissingPlugin, + 13 => CoreError::Clock, + 14 => CoreError::Disabled, + 15 => CoreError::NumErrors, + value => CoreError::__Unknown(value), + } + } +} + +impl ErrorDomain for CoreError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_core_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 1 => Some(CoreError::Failed), + 2 => Some(CoreError::TooLazy), + 3 => Some(CoreError::NotImplemented), + 4 => Some(CoreError::StateChange), + 5 => Some(CoreError::Pad), + 6 => Some(CoreError::Thread), + 7 => Some(CoreError::Negotiation), + 8 => Some(CoreError::Event), + 9 => Some(CoreError::Seek), + 10 => Some(CoreError::Caps), + 11 => Some(CoreError::Tag), + 12 => Some(CoreError::MissingPlugin), + 13 => Some(CoreError::Clock), + 14 => Some(CoreError::Disabled), + 15 => Some(CoreError::NumErrors), + _ => Some(CoreError::Failed), + } + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum FlowReturn { CustomSuccess2, @@ -114,6 +256,76 @@ impl FromGlib for Format { } } +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum LibraryError { + Failed, + TooLazy, + Init, + Shutdown, + Settings, + Encode, + NumErrors, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for LibraryError { + type GlibType = ffi::GstLibraryError; + + fn to_glib(&self) -> ffi::GstLibraryError { + match *self { + LibraryError::Failed => ffi::GST_LIBRARY_ERROR_FAILED, + LibraryError::TooLazy => ffi::GST_LIBRARY_ERROR_TOO_LAZY, + LibraryError::Init => ffi::GST_LIBRARY_ERROR_INIT, + LibraryError::Shutdown => ffi::GST_LIBRARY_ERROR_SHUTDOWN, + LibraryError::Settings => ffi::GST_LIBRARY_ERROR_SETTINGS, + LibraryError::Encode => ffi::GST_LIBRARY_ERROR_ENCODE, + LibraryError::NumErrors => ffi::GST_LIBRARY_ERROR_NUM_ERRORS, + LibraryError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for LibraryError { + fn from_glib(value: ffi::GstLibraryError) -> Self { + match value as i32 { + 1 => LibraryError::Failed, + 2 => LibraryError::TooLazy, + 3 => LibraryError::Init, + 4 => LibraryError::Shutdown, + 5 => LibraryError::Settings, + 6 => LibraryError::Encode, + 7 => LibraryError::NumErrors, + value => LibraryError::__Unknown(value), + } + } +} + +impl ErrorDomain for LibraryError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_library_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 1 => Some(LibraryError::Failed), + 2 => Some(LibraryError::TooLazy), + 3 => Some(LibraryError::Init), + 4 => Some(LibraryError::Shutdown), + 5 => Some(LibraryError::Settings), + 6 => Some(LibraryError::Encode), + 7 => Some(LibraryError::NumErrors), + _ => Some(LibraryError::Failed), + } + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum PadDirection { Unknown, @@ -149,6 +361,240 @@ impl FromGlib for PadDirection { } } +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum ParseError { + Syntax, + NoSuchElement, + NoSuchProperty, + Link, + CouldNotSetProperty, + EmptyBin, + Empty, + DelayedLink, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for ParseError { + type GlibType = ffi::GstParseError; + + fn to_glib(&self) -> ffi::GstParseError { + match *self { + ParseError::Syntax => ffi::GST_PARSE_ERROR_SYNTAX, + ParseError::NoSuchElement => ffi::GST_PARSE_ERROR_NO_SUCH_ELEMENT, + ParseError::NoSuchProperty => ffi::GST_PARSE_ERROR_NO_SUCH_PROPERTY, + ParseError::Link => ffi::GST_PARSE_ERROR_LINK, + ParseError::CouldNotSetProperty => ffi::GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY, + ParseError::EmptyBin => ffi::GST_PARSE_ERROR_EMPTY_BIN, + ParseError::Empty => ffi::GST_PARSE_ERROR_EMPTY, + ParseError::DelayedLink => ffi::GST_PARSE_ERROR_DELAYED_LINK, + ParseError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for ParseError { + fn from_glib(value: ffi::GstParseError) -> Self { + match value as i32 { + 0 => ParseError::Syntax, + 1 => ParseError::NoSuchElement, + 2 => ParseError::NoSuchProperty, + 3 => ParseError::Link, + 4 => ParseError::CouldNotSetProperty, + 5 => ParseError::EmptyBin, + 6 => ParseError::Empty, + 7 => ParseError::DelayedLink, + value => ParseError::__Unknown(value), + } + } +} + +impl ErrorDomain for ParseError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_parse_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 0 => Some(ParseError::Syntax), + 1 => Some(ParseError::NoSuchElement), + 2 => Some(ParseError::NoSuchProperty), + 3 => Some(ParseError::Link), + 4 => Some(ParseError::CouldNotSetProperty), + 5 => Some(ParseError::EmptyBin), + 6 => Some(ParseError::Empty), + 7 => Some(ParseError::DelayedLink), + value => Some(ParseError::__Unknown(value)), + } + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum PluginError { + Module, + Dependencies, + NameMismatch, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for PluginError { + type GlibType = ffi::GstPluginError; + + fn to_glib(&self) -> ffi::GstPluginError { + match *self { + PluginError::Module => ffi::GST_PLUGIN_ERROR_MODULE, + PluginError::Dependencies => ffi::GST_PLUGIN_ERROR_DEPENDENCIES, + PluginError::NameMismatch => ffi::GST_PLUGIN_ERROR_NAME_MISMATCH, + PluginError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for PluginError { + fn from_glib(value: ffi::GstPluginError) -> Self { + match value as i32 { + 0 => PluginError::Module, + 1 => PluginError::Dependencies, + 2 => PluginError::NameMismatch, + value => PluginError::__Unknown(value), + } + } +} + +impl ErrorDomain for PluginError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_plugin_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 0 => Some(PluginError::Module), + 1 => Some(PluginError::Dependencies), + 2 => Some(PluginError::NameMismatch), + value => Some(PluginError::__Unknown(value)), + } + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum ResourceError { + Failed, + TooLazy, + NotFound, + Busy, + OpenRead, + OpenWrite, + OpenReadWrite, + Close, + Read, + Write, + Seek, + Sync, + Settings, + NoSpaceLeft, + NotAuthorized, + NumErrors, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for ResourceError { + type GlibType = ffi::GstResourceError; + + fn to_glib(&self) -> ffi::GstResourceError { + match *self { + ResourceError::Failed => ffi::GST_RESOURCE_ERROR_FAILED, + ResourceError::TooLazy => ffi::GST_RESOURCE_ERROR_TOO_LAZY, + ResourceError::NotFound => ffi::GST_RESOURCE_ERROR_NOT_FOUND, + ResourceError::Busy => ffi::GST_RESOURCE_ERROR_BUSY, + ResourceError::OpenRead => ffi::GST_RESOURCE_ERROR_OPEN_READ, + ResourceError::OpenWrite => ffi::GST_RESOURCE_ERROR_OPEN_WRITE, + ResourceError::OpenReadWrite => ffi::GST_RESOURCE_ERROR_OPEN_READ_WRITE, + ResourceError::Close => ffi::GST_RESOURCE_ERROR_CLOSE, + ResourceError::Read => ffi::GST_RESOURCE_ERROR_READ, + ResourceError::Write => ffi::GST_RESOURCE_ERROR_WRITE, + ResourceError::Seek => ffi::GST_RESOURCE_ERROR_SEEK, + ResourceError::Sync => ffi::GST_RESOURCE_ERROR_SYNC, + ResourceError::Settings => ffi::GST_RESOURCE_ERROR_SETTINGS, + ResourceError::NoSpaceLeft => ffi::GST_RESOURCE_ERROR_NO_SPACE_LEFT, + ResourceError::NotAuthorized => ffi::GST_RESOURCE_ERROR_NOT_AUTHORIZED, + ResourceError::NumErrors => ffi::GST_RESOURCE_ERROR_NUM_ERRORS, + ResourceError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for ResourceError { + fn from_glib(value: ffi::GstResourceError) -> Self { + match value as i32 { + 1 => ResourceError::Failed, + 2 => ResourceError::TooLazy, + 3 => ResourceError::NotFound, + 4 => ResourceError::Busy, + 5 => ResourceError::OpenRead, + 6 => ResourceError::OpenWrite, + 7 => ResourceError::OpenReadWrite, + 8 => ResourceError::Close, + 9 => ResourceError::Read, + 10 => ResourceError::Write, + 11 => ResourceError::Seek, + 12 => ResourceError::Sync, + 13 => ResourceError::Settings, + 14 => ResourceError::NoSpaceLeft, + 15 => ResourceError::NotAuthorized, + 16 => ResourceError::NumErrors, + value => ResourceError::__Unknown(value), + } + } +} + +impl ErrorDomain for ResourceError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_resource_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 1 => Some(ResourceError::Failed), + 2 => Some(ResourceError::TooLazy), + 3 => Some(ResourceError::NotFound), + 4 => Some(ResourceError::Busy), + 5 => Some(ResourceError::OpenRead), + 6 => Some(ResourceError::OpenWrite), + 7 => Some(ResourceError::OpenReadWrite), + 8 => Some(ResourceError::Close), + 9 => Some(ResourceError::Read), + 10 => Some(ResourceError::Write), + 11 => Some(ResourceError::Seek), + 12 => Some(ResourceError::Sync), + 13 => Some(ResourceError::Settings), + 14 => Some(ResourceError::NoSpaceLeft), + 15 => Some(ResourceError::NotAuthorized), + 16 => Some(ResourceError::NumErrors), + _ => Some(ResourceError::Failed), + } + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum SeekType { None, @@ -307,6 +753,162 @@ impl FromGlib for StateChangeReturn { } } +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum StreamError { + Failed, + TooLazy, + NotImplemented, + TypeNotFound, + WrongType, + CodecNotFound, + Decode, + Encode, + Demux, + Mux, + Format, + Decrypt, + DecryptNokey, + NumErrors, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for StreamError { + type GlibType = ffi::GstStreamError; + + fn to_glib(&self) -> ffi::GstStreamError { + match *self { + StreamError::Failed => ffi::GST_STREAM_ERROR_FAILED, + StreamError::TooLazy => ffi::GST_STREAM_ERROR_TOO_LAZY, + StreamError::NotImplemented => ffi::GST_STREAM_ERROR_NOT_IMPLEMENTED, + StreamError::TypeNotFound => ffi::GST_STREAM_ERROR_TYPE_NOT_FOUND, + StreamError::WrongType => ffi::GST_STREAM_ERROR_WRONG_TYPE, + StreamError::CodecNotFound => ffi::GST_STREAM_ERROR_CODEC_NOT_FOUND, + StreamError::Decode => ffi::GST_STREAM_ERROR_DECODE, + StreamError::Encode => ffi::GST_STREAM_ERROR_ENCODE, + StreamError::Demux => ffi::GST_STREAM_ERROR_DEMUX, + StreamError::Mux => ffi::GST_STREAM_ERROR_MUX, + StreamError::Format => ffi::GST_STREAM_ERROR_FORMAT, + StreamError::Decrypt => ffi::GST_STREAM_ERROR_DECRYPT, + StreamError::DecryptNokey => ffi::GST_STREAM_ERROR_DECRYPT_NOKEY, + StreamError::NumErrors => ffi::GST_STREAM_ERROR_NUM_ERRORS, + StreamError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for StreamError { + fn from_glib(value: ffi::GstStreamError) -> Self { + match value as i32 { + 1 => StreamError::Failed, + 2 => StreamError::TooLazy, + 3 => StreamError::NotImplemented, + 4 => StreamError::TypeNotFound, + 5 => StreamError::WrongType, + 6 => StreamError::CodecNotFound, + 7 => StreamError::Decode, + 8 => StreamError::Encode, + 9 => StreamError::Demux, + 10 => StreamError::Mux, + 11 => StreamError::Format, + 12 => StreamError::Decrypt, + 13 => StreamError::DecryptNokey, + 14 => StreamError::NumErrors, + value => StreamError::__Unknown(value), + } + } +} + +impl ErrorDomain for StreamError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_stream_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 1 => Some(StreamError::Failed), + 2 => Some(StreamError::TooLazy), + 3 => Some(StreamError::NotImplemented), + 4 => Some(StreamError::TypeNotFound), + 5 => Some(StreamError::WrongType), + 6 => Some(StreamError::CodecNotFound), + 7 => Some(StreamError::Decode), + 8 => Some(StreamError::Encode), + 9 => Some(StreamError::Demux), + 10 => Some(StreamError::Mux), + 11 => Some(StreamError::Format), + 12 => Some(StreamError::Decrypt), + 13 => Some(StreamError::DecryptNokey), + 14 => Some(StreamError::NumErrors), + _ => Some(StreamError::Failed), + } + } +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum URIError { + UnsupportedProtocol, + BadUri, + BadState, + BadReference, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for URIError { + type GlibType = ffi::GstURIError; + + fn to_glib(&self) -> ffi::GstURIError { + match *self { + URIError::UnsupportedProtocol => ffi::GST_URI_ERROR_UNSUPPORTED_PROTOCOL, + URIError::BadUri => ffi::GST_URI_ERROR_BAD_URI, + URIError::BadState => ffi::GST_URI_ERROR_BAD_STATE, + URIError::BadReference => ffi::GST_URI_ERROR_BAD_REFERENCE, + URIError::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for URIError { + fn from_glib(value: ffi::GstURIError) -> Self { + match value as i32 { + 0 => URIError::UnsupportedProtocol, + 1 => URIError::BadUri, + 2 => URIError::BadState, + 3 => URIError::BadReference, + value => URIError::__Unknown(value), + } + } +} + +impl ErrorDomain for URIError { + fn domain() -> glib_ffi::GQuark { + unsafe { ffi::gst_uri_error_quark() } + } + + fn code(self) -> i32 { + self.to_glib() as i32 + } + + fn from(code: i32) -> Option { + match code { + 0 => Some(URIError::UnsupportedProtocol), + 1 => Some(URIError::BadUri), + 2 => Some(URIError::BadState), + 3 => Some(URIError::BadReference), + value => Some(URIError::__Unknown(value)), + } + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum URIType { Unknown, diff --git a/gstreamer/src/auto/flags.rs b/gstreamer/src/auto/flags.rs index e978fc075..e79a0220d 100644 --- a/gstreamer/src/auto/flags.rs +++ b/gstreamer/src/auto/flags.rs @@ -4,67 +4,6 @@ use ffi; use glib::translate::*; -bitflags! { - pub struct MessageType: u32 { - const MESSAGE_UNKNOWN = 0; - const MESSAGE_EOS = 1; - const MESSAGE_ERROR = 2; - const MESSAGE_WARNING = 4; - const MESSAGE_INFO = 8; - const MESSAGE_TAG = 16; - const MESSAGE_BUFFERING = 32; - const MESSAGE_STATE_CHANGED = 64; - const MESSAGE_STATE_DIRTY = 128; - const MESSAGE_STEP_DONE = 256; - const MESSAGE_CLOCK_PROVIDE = 512; - const MESSAGE_CLOCK_LOST = 1024; - const MESSAGE_NEW_CLOCK = 2048; - const MESSAGE_STRUCTURE_CHANGE = 4096; - const MESSAGE_STREAM_STATUS = 8192; - const MESSAGE_APPLICATION = 16384; - const MESSAGE_ELEMENT = 32768; - const MESSAGE_SEGMENT_START = 65536; - const MESSAGE_SEGMENT_DONE = 131072; - const MESSAGE_DURATION_CHANGED = 262144; - const MESSAGE_LATENCY = 524288; - const MESSAGE_ASYNC_START = 1048576; - const MESSAGE_ASYNC_DONE = 2097152; - const MESSAGE_REQUEST_STATE = 4194304; - const MESSAGE_STEP_START = 8388608; - const MESSAGE_QOS = 16777216; - const MESSAGE_PROGRESS = 33554432; - const MESSAGE_TOC = 67108864; - const MESSAGE_RESET_TIME = 134217728; - const MESSAGE_STREAM_START = 268435456; - const MESSAGE_NEED_CONTEXT = 536870912; - const MESSAGE_HAVE_CONTEXT = 1073741824; - const MESSAGE_EXTENDED = 2147483648; - const MESSAGE_DEVICE_ADDED = 2147483649; - const MESSAGE_DEVICE_REMOVED = 2147483650; - const MESSAGE_PROPERTY_NOTIFY = 2147483651; - const MESSAGE_STREAM_COLLECTION = 2147483652; - const MESSAGE_STREAMS_SELECTED = 2147483653; - const MESSAGE_REDIRECT = 2147483654; - const MESSAGE_ANY = 4294967295; - } -} - -#[doc(hidden)] -impl ToGlib for MessageType { - type GlibType = ffi::GstMessageType; - - fn to_glib(&self) -> ffi::GstMessageType { - ffi::GstMessageType::from_bits_truncate(self.bits()) - } -} - -#[doc(hidden)] -impl FromGlib for MessageType { - fn from_glib(value: ffi::GstMessageType) -> MessageType { - MessageType::from_bits_truncate(value.bits()) - } -} - bitflags! { pub struct SeekFlags: u32 { const SEEK_FLAG_NONE = 0; diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index 8393b68cd..44d752173 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -43,57 +43,24 @@ pub use self::u_r_i_handler::URIHandler; pub use self::u_r_i_handler::URIHandlerExt; mod enums; +pub use self::enums::BufferingMode; +pub use self::enums::CoreError; pub use self::enums::FlowReturn; pub use self::enums::Format; +pub use self::enums::LibraryError; pub use self::enums::PadDirection; +pub use self::enums::ParseError; +pub use self::enums::PluginError; +pub use self::enums::ResourceError; pub use self::enums::SeekType; pub use self::enums::State; pub use self::enums::StateChange; pub use self::enums::StateChangeReturn; +pub use self::enums::StreamError; +pub use self::enums::URIError; pub use self::enums::URIType; mod flags; -pub use self::flags::MessageType; -pub use self::flags::MESSAGE_UNKNOWN; -pub use self::flags::MESSAGE_EOS; -pub use self::flags::MESSAGE_ERROR; -pub use self::flags::MESSAGE_WARNING; -pub use self::flags::MESSAGE_INFO; -pub use self::flags::MESSAGE_TAG; -pub use self::flags::MESSAGE_BUFFERING; -pub use self::flags::MESSAGE_STATE_CHANGED; -pub use self::flags::MESSAGE_STATE_DIRTY; -pub use self::flags::MESSAGE_STEP_DONE; -pub use self::flags::MESSAGE_CLOCK_PROVIDE; -pub use self::flags::MESSAGE_CLOCK_LOST; -pub use self::flags::MESSAGE_NEW_CLOCK; -pub use self::flags::MESSAGE_STRUCTURE_CHANGE; -pub use self::flags::MESSAGE_STREAM_STATUS; -pub use self::flags::MESSAGE_APPLICATION; -pub use self::flags::MESSAGE_ELEMENT; -pub use self::flags::MESSAGE_SEGMENT_START; -pub use self::flags::MESSAGE_SEGMENT_DONE; -pub use self::flags::MESSAGE_DURATION_CHANGED; -pub use self::flags::MESSAGE_LATENCY; -pub use self::flags::MESSAGE_ASYNC_START; -pub use self::flags::MESSAGE_ASYNC_DONE; -pub use self::flags::MESSAGE_REQUEST_STATE; -pub use self::flags::MESSAGE_STEP_START; -pub use self::flags::MESSAGE_QOS; -pub use self::flags::MESSAGE_PROGRESS; -pub use self::flags::MESSAGE_TOC; -pub use self::flags::MESSAGE_RESET_TIME; -pub use self::flags::MESSAGE_STREAM_START; -pub use self::flags::MESSAGE_NEED_CONTEXT; -pub use self::flags::MESSAGE_HAVE_CONTEXT; -pub use self::flags::MESSAGE_EXTENDED; -pub use self::flags::MESSAGE_DEVICE_ADDED; -pub use self::flags::MESSAGE_DEVICE_REMOVED; -pub use self::flags::MESSAGE_PROPERTY_NOTIFY; -pub use self::flags::MESSAGE_STREAM_COLLECTION; -pub use self::flags::MESSAGE_STREAMS_SELECTED; -pub use self::flags::MESSAGE_REDIRECT; -pub use self::flags::MESSAGE_ANY; pub use self::flags::SeekFlags; pub use self::flags::SEEK_FLAG_NONE; pub use self::flags::SEEK_FLAG_FLUSH; diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 8b39c9414..74bf36393 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -8,12 +8,12 @@ use ffi; use Object; -use MessageType; use miniobject::*; -use std::ffi::CStr; + +use std::ptr; use glib; -use glib::translate::{from_glib, from_glib_none, from_glib_full, ToGlibPtr, ToGlib}; +use glib::translate::{from_glib, from_glib_none, from_glib_full, ToGlibPtr}; #[repr(C)] pub struct MessageImpl(ffi::GstMessage); @@ -37,18 +37,6 @@ impl MessageImpl { } } - pub fn get_message_type(&self) -> MessageType { - unsafe { - from_glib((*self.as_ptr()).type_) - } - } - - pub fn get_message_type_name(&self) -> &'static str { - unsafe { - CStr::from_ptr(ffi::gst_message_type_get_name(self.get_message_type().to_glib())).to_str().unwrap() - } - } - pub fn get_seqnum(&self) -> u32 { unsafe { ffi::gst_message_get_seqnum(self.as_mut_ptr()) @@ -61,9 +49,269 @@ impl MessageImpl { } } - // TODO get_structure(), get_mut_structure() + // TODO get_structure() + + pub fn view(&self) -> MessageView { + let type_ = unsafe { (*self.as_ptr()).type_ }; + + if type_ == ffi::GST_MESSAGE_EOS { + MessageView::Eos(Eos(self)) + } else if type_ == ffi::GST_MESSAGE_ERROR { + MessageView::Error(Error(self)) + } else if type_ == ffi::GST_MESSAGE_WARNING { + MessageView::Warning(Warning(self)) + } else if type_ == ffi::GST_MESSAGE_INFO { + MessageView::Info(Info(self)) + } else if type_ == ffi::GST_MESSAGE_TAG { + MessageView::Tag(Tag(self)) + } else if type_ == ffi::GST_MESSAGE_BUFFERING { + MessageView::Buffering(Buffering(self)) + } else if type_ == ffi::GST_MESSAGE_STATE_CHANGED { + MessageView::StateChanged(StateChanged(self)) + } else if type_ == ffi::GST_MESSAGE_STATE_DIRTY { + MessageView::StateDirty(StateDirty(self)) + } else if type_ == ffi::GST_MESSAGE_STEP_DONE { + MessageView::StepDone(StepDone(self)) + } else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE { + MessageView::ClockProvide(ClockProvide(self)) + } else if type_ == ffi::GST_MESSAGE_CLOCK_LOST { + MessageView::ClockLost(ClockLost(self)) + } else if type_ == ffi::GST_MESSAGE_NEW_CLOCK { + MessageView::NewClock(NewClock(self)) + } else if type_ == ffi::GST_MESSAGE_STRUCTURE_CHANGE { + MessageView::StructureChange(StructureChange(self)) + } else if type_ == ffi::GST_MESSAGE_STREAM_STATUS { + MessageView::StreamStatus(StreamStatus(self)) + } else if type_ == ffi::GST_MESSAGE_APPLICATION { + MessageView::Application(Application(self)) + } else if type_ == ffi::GST_MESSAGE_ELEMENT { + MessageView::Element(Element(self)) + } else if type_ == ffi::GST_MESSAGE_SEGMENT_START { + MessageView::SegmentStart(SegmentStart(self)) + } else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE { + MessageView::SegmentDone(SegmentDone(self)) + } else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED { + MessageView::DurationChanged(DurationChanged(self)) + } else if type_ == ffi::GST_MESSAGE_LATENCY { + MessageView::Latency(Latency(self)) + } else if type_ == ffi::GST_MESSAGE_ASYNC_START { + MessageView::AsyncStart(AsyncStart(self)) + } else if type_ == ffi::GST_MESSAGE_ASYNC_DONE { + MessageView::AsyncDone(AsyncDone(self)) + } else if type_ == ffi::GST_MESSAGE_REQUEST_STATE { + MessageView::RequestState(RequestState(self)) + } else if type_ == ffi::GST_MESSAGE_STEP_START { + MessageView::StepStart(StepStart(self)) + } else if type_ == ffi::GST_MESSAGE_QOS { + MessageView::Qos(Qos(self)) + } else if type_ == ffi::GST_MESSAGE_PROGRESS { + MessageView::Progress(Progress(self)) + } else if type_ == ffi::GST_MESSAGE_TOC { + MessageView::Toc(Toc(self)) + } else if type_ == ffi::GST_MESSAGE_RESET_TIME { + MessageView::ResetTime(ResetTime(self)) + } else if type_ == ffi::GST_MESSAGE_STREAM_START { + MessageView::StreamStart(StreamStart(self)) + } else if type_ == ffi::GST_MESSAGE_NEED_CONTEXT { + MessageView::NeedContext(NeedContext(self)) + } else if type_ == ffi::GST_MESSAGE_HAVE_CONTEXT { + MessageView::HaveContext(HaveContext(self)) + } else if type_ == ffi::GST_MESSAGE_DEVICE_ADDED { + MessageView::DeviceAdded(DeviceAdded(self)) + } else if type_ == ffi::GST_MESSAGE_DEVICE_REMOVED { + MessageView::DeviceRemoved(DeviceRemoved(self)) + } else if type_ == ffi::GST_MESSAGE_PROPERTY_NOTIFY { + MessageView::PropertyNotify(PropertyNotify(self)) + } else if type_ == ffi::GST_MESSAGE_STREAM_COLLECTION { + MessageView::StreamCollection(StreamCollection(self)) + } else if type_ == ffi::GST_MESSAGE_STREAMS_SELECTED { + MessageView::StreamsSelected(StreamsSelected(self)) + } else { + unimplemented!() + } + } } +pub enum MessageView<'a> { + Eos(Eos<'a>), + Error(Error<'a>), + Warning(Warning<'a>), + Info(Info<'a>), + Tag(Tag<'a>), + Buffering(Buffering<'a>), + StateChanged(StateChanged<'a>), + StateDirty(StateDirty<'a>), + StepDone(StepDone<'a>), + ClockProvide(ClockProvide<'a>), + ClockLost(ClockLost<'a>), + NewClock(NewClock<'a>), + StructureChange(StructureChange<'a>), + StreamStatus(StreamStatus<'a>), + Application(Application<'a>), + Element(Element<'a>), + SegmentStart(SegmentStart<'a>), + SegmentDone(SegmentDone<'a>), + DurationChanged(DurationChanged<'a>), + Latency(Latency<'a>), + AsyncStart(AsyncStart<'a>), + AsyncDone(AsyncDone<'a>), + RequestState(RequestState<'a>), + StepStart(StepStart<'a>), + Qos(Qos<'a>), + Progress(Progress<'a>), + Toc(Toc<'a>), + ResetTime(ResetTime<'a>), + StreamStart(StreamStart<'a>), + NeedContext(NeedContext<'a>), + HaveContext(HaveContext<'a>), + DeviceAdded(DeviceAdded<'a>), + DeviceRemoved(DeviceRemoved<'a>), + PropertyNotify(PropertyNotify<'a>), + StreamCollection(StreamCollection<'a>), + StreamsSelected(StreamsSelected<'a>), + Redirect(Redirect<'a>), + __NonExhaustive, +} + +pub struct Eos<'a>(&'a MessageImpl); + +pub struct Error<'a>(&'a MessageImpl); +impl<'a> Error<'a> { + pub fn get_error(&self) -> glib::Error { + unsafe { + let mut error = ptr::null_mut(); + + ffi::gst_message_parse_error(self.0.as_mut_ptr(), &mut error, ptr::null_mut()); + + from_glib_full(error) + } + } + + pub fn get_debug(&self) -> Option { + unsafe { + let mut debug = ptr::null_mut(); + + ffi::gst_message_parse_error(self.0.as_mut_ptr(), ptr::null_mut(), &mut debug); + + from_glib_full(debug) + } + } + + // TODO get_details() +} + +pub struct Warning<'a>(&'a MessageImpl); +impl<'a> Warning<'a> { + pub fn get_error(&self) -> glib::Error { + unsafe { + let mut error = ptr::null_mut(); + + ffi::gst_message_parse_warning(self.0.as_mut_ptr(), &mut error, ptr::null_mut()); + + from_glib_full(error) + } + } + + pub fn get_debug(&self) -> Option { + unsafe { + let mut debug = ptr::null_mut(); + + ffi::gst_message_parse_warning(self.0.as_mut_ptr(), ptr::null_mut(), &mut debug); + + from_glib_full(debug) + } + } + + // TODO get_details() +} + +pub struct Info<'a>(&'a MessageImpl); +impl<'a> Info<'a> { + pub fn get_error(&self) -> glib::Error { + unsafe { + let mut error = ptr::null_mut(); + + ffi::gst_message_parse_info(self.0.as_mut_ptr(), &mut error, ptr::null_mut()); + + from_glib_full(error) + } + } + + pub fn get_debug(&self) -> Option { + unsafe { + let mut debug = ptr::null_mut(); + + ffi::gst_message_parse_info(self.0.as_mut_ptr(), ptr::null_mut(), &mut debug); + + from_glib_full(debug) + } + } + + // TODO get_details() +} + +pub struct Tag<'a>(&'a MessageImpl); +impl<'a> Tag<'a> { + // TODO: get_tags() +} + +pub struct Buffering<'a>(&'a MessageImpl); +impl<'a> Buffering<'a> { + pub fn get_percent(&self) -> i32 { + let mut p = 0; + unsafe { + ffi::gst_message_parse_buffering(self.0.as_mut_ptr(), &mut p); + } + + p + } + + pub fn get_buffering_stats(&self) -> (::BufferingMode, i32, i32, i64) { + let mut mode = ffi::GstBufferingMode::Stream; + let mut avg_in = 0; + let mut avg_out = 0; + let mut buffering_left = 0; + + unsafe { + ffi::gst_message_parse_buffering_stats(self.0.as_mut_ptr(), &mut mode, &mut avg_in, &mut avg_out, &mut buffering_left); + } + + (from_glib(mode), avg_in, avg_out, buffering_left) + } +} + +pub struct StateChanged<'a>(&'a MessageImpl); +pub struct StateDirty<'a>(&'a MessageImpl); +pub struct StepDone<'a>(&'a MessageImpl); +pub struct ClockProvide<'a>(&'a MessageImpl); +pub struct ClockLost<'a>(&'a MessageImpl); +pub struct NewClock<'a>(&'a MessageImpl); +pub struct StructureChange<'a>(&'a MessageImpl); +pub struct StreamStatus<'a>(&'a MessageImpl); +pub struct Application<'a>(&'a MessageImpl); +pub struct Element<'a>(&'a MessageImpl); +pub struct SegmentStart<'a>(&'a MessageImpl); +pub struct SegmentDone<'a>(&'a MessageImpl); +pub struct DurationChanged<'a>(&'a MessageImpl); +pub struct Latency<'a>(&'a MessageImpl); +pub struct AsyncStart<'a>(&'a MessageImpl); +pub struct AsyncDone<'a>(&'a MessageImpl); +pub struct RequestState<'a>(&'a MessageImpl); +pub struct StepStart<'a>(&'a MessageImpl); +pub struct Qos<'a>(&'a MessageImpl); +pub struct Progress<'a>(&'a MessageImpl); +pub struct Toc<'a>(&'a MessageImpl); +pub struct ResetTime<'a>(&'a MessageImpl); +pub struct StreamStart<'a>(&'a MessageImpl); +pub struct NeedContext<'a>(&'a MessageImpl); +pub struct HaveContext<'a>(&'a MessageImpl); +pub struct DeviceAdded<'a>(&'a MessageImpl); +pub struct DeviceRemoved<'a>(&'a MessageImpl); +pub struct PropertyNotify<'a>(&'a MessageImpl); +pub struct StreamCollection<'a>(&'a MessageImpl); +pub struct StreamsSelected<'a>(&'a MessageImpl); +pub struct Redirect<'a>(&'a MessageImpl); + impl glib::types::StaticType for GstRc { fn static_type() -> glib::types::Type { unsafe {