gstreamer-base-0.24.0/.cargo_vcs_info.json0000644000000001540000000000100140200ustar { "git": { "sha1": "ef17224f7a88b01d788c7ebc81a85d10df5f09a1" }, "path_in_vcs": "gstreamer-base" }gstreamer-base-0.24.0/CHANGELOG.md000064400000000000000000002626151046102023000144350ustar 00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html), specifically the [variant used by Rust](http://doc.crates.io/manifest.html#the-version-field). ## [0.24.0] - 2025-07-15 ### Changed - Compatible with gtk-rs-core 0.21 / gtk4-rs 0.10. - Update GStreamer gir files to latest (upcoming) 1.28 APIs. - Minimum support Rust version is updated from 1.71.1 to 1.83. - `gst::Structure` fields and fields of related API are using `gst::IdStr` when built against GStreamer 1.26 and use a local implementation of that as fallback on older versions to offer the same API. - Rework of `gst_validate` action and action type API. - Rework of `gst_play::PlayMessage` API to be easier to use correctly. - Remove `bool` result from `gst::BufferList::foreach()` as return values are more flexibly handled via mutable variables captured by the closure. - `gst::Element::foreach_pad()` returns `ControlFlow` instead of `bool` from callback now. - Return iterators instead of `Vec`s from more functions. - Make `gst::event::SelectStreams` builder API for convenient. - Add `#[must_use]` annotations to all iterator structs. - Return `gst_video::VideoInfo` and `gst_audio::AudioInfo` references from more functions instead of copies. - Change some `gst::Clock` functions to not return `Option`s anymore. - Change `gst_sdp::SDPMedia::set_media_from_caps()` to a method. - Various `gst_allocators` allocator API was moved to extension traits and renamed to not have the same name as a method of the parent class. ### Added - Allow setting generic properties as part of the `gst_app::AppSink` and `AppSrc`, `gst::Bin` and `gst::Pipeline` builders. - Bindings for the `gstreamer-mse` library. - Bindings for the `gstreamer-d3d12` library. ### Removed - API deprecated in previous releases was removed. - `gst_webrtc::DataChannel` duplicated signal API was removed. ## [0.23.7] - 2025-06-20 ### Fixed - Provide existing messages immediately from a `gst::Bus` stream when creating it instead of only providing them on the next message. ### Added - `gst::QueryType` enum and accessor for it from queries. ### Changed - Don't unnecessarily store buffer twice in `gst_gl::GLVideoFrame`. - Don't store memory twice in `gst::memory::MemoryMap` and `MappedMemory`. ## [0.23.6] - 2025-05-13 ### Fixed - Lower debug message level when allocation queries in subclasses fail. - Catch panics from typefinders implemented in Rust. - Use correctly aligned arrays in `gst_audio` tests. - Drop pad probes and callbacks from `appsink` when releasing a `gst_utils::StreamProducer`. - Leak in `gst::ElementImpl::parent_request_new_pad()`. - Request a new keyframe from `gst_utils::StreamProducer` when discarding a buffer. ### Added - Implement `gst::ByteSliceExt` over all `AsRef<[u8]>` instead of just `&[u8]` and `&mut [u8]`. - `gst::Allocator::memory_type()` getter. - Setters for `gst::AllocationParams` and implement `Copy`, `PartialEq` and `Eq`. - New API for creating a `gst_audio::AudioInfo` and `gst_video::VideoInfo` builder from an existing value. - Setters for `gst_video::VideoAlignment` and implement `Default`. - Implement `Default`, `Copy` and `Clone` for `gst::BufferPoolAcquireParams` and add setters. - `gst::ChildProxy::set_child_property_from_str()` convenience API. - `gst::BufferList::drain()` for iterating over a buffer list while draining it. - `gst_utils::StreamProducer::wait_for_keyframe()` configuration. - `gst_utils::ConsumptionLink` getter for the stream producer. - Bindings for `gst_tag` language code API. ### Changed - Update various dependencies. - Update to GStreamer 1.26.1 gir files. ## [0.23.5] - 2025-02-17 ### Fixed - Properly validate `gst::IntRange::with_step()` step size - Fix `gst::Buffer` serde serialization - Forward gap events by default in `gst_utils::StreamProducer`. - Correctly account for alternate interlace mode in `gst_video::VideoMeta::add_full()`. - Return `Result`s instead of `bool`s in new `gst_play` API. ### Added - Support for `TracerImpl::USE_STRUCTURE_PARAMS` with GStreamer < 1.26. - Bindings for `gst_analytics::ODMtd`. - Bindings for `TopSurroundRight` and `TopSurroundLeft` audio channels. - Bindings for AV1 and H266 codec helpers API. - Bindings for `gst_audio::reorder_channels_with_reorder_map()`. ### Changed - Updated GStreamer gir files for latest 1.26 APIs. - Documentation links URL was updated. ## [0.23.4] - 2024-12-21 ### Fixed - `gst_video::VideoFrame::plane_data()` does not return a truncated buffer for the alpha plane in A420 and similar formats anymore. - `FnMut` closures are now correctly passed via a mutable reference to FFI code. - Order of arguments in `gst_video::VideoFormat::from_mask()` was corrected. ### Added - Bindings for 1.26 `gst_analytics::Tensor` API. - `gst::DebugCategory::as_ptr()` and `Hash` impl, `gst::DebugMessage::as_ptr()`. - Support for hex-dumping `&mut [u8]` in addition to `&[u8]`, `gst::Buffer`, etc. - Functions to work with meta `glib::Type`s. ### Changed - Updated GStreamer gir files for latest 1.26 APIs. ## [0.23.3] - 2024-11-01 ### Fixed - Bind `gst::Pad::proxy_query_caps()` to the correct C function. - Update `gst_utils::StreamProducer` appsrc latency upon appsink latency event. - Fix type of `gst_app::AppSinkBuilder::processing_deadline()`. ### Added - Various new `gst::Iterator` constructors for convenience. ### Changed - Updated GStreamer gir files for latest 1.26 APIs. ## [0.23.2] - 2024-09-28 ### Fixed - Lifetime of `gst::TagList::index()` return value is correctly bound to `&self` now. - Don't assume `gst::Structure` name / field names have `'static` lifetime. - Set pad probe data to `NULL` if `HANDLED` is returned and the item is an event, buffer or buffer list. - Don't unnecessarily add `#[link]` attribute to the `extern "C"` sections to allow linking against gstreamer-full and make static linking easier. ### Changed - Add `#[must_use]` to `gst_video::VideoTimeCode::add_interval()`. ### Added - Add API to take events/buffers from a `gst::PadProbeInfo`. - Add `gst::EventViewMut` and `gst::Event::view_mut()`, and a few setters for event fields. - Add `gst::MessageViewMut` and `gst::Message::view_mut()`, and a few setters for message fields. ## [0.23.1] - 2024-08-27 ### Fixed - Support `gst_utils::StreamProducer` API on platforms without 64 bit atomics. - Fix off-by-one in `gst::BufferList::remove()` range end handling. - Pass an empty tag array instead of NULL in `gst::CustomMeta::register_simple()`. - Fix various new clippy warnings. ### Added - Add getters for `gst::format::Percent`. ## [0.23.0] - 2024-07-11 ### Changed - Compatible with gtk-rs-core 0.20 / gtk4-rs 0.9. - Update GStreamer gir files to latest (upcoming) 1.26 APIs. - Minimum support Rust version is updated from 1.70 to 1.71.1. - Move `gst::Meta` tags into separate modules and improve API around them. - Improve `gst::Meta` transform functions and make the API more generic, and as part of that add support the video meta transform. - Pass an immutable instead of mutable output buffer reference to `gst_rtp::RtpHeaderExtension::write()` function. - Make `gst_net::PtpClock::new()` constructor fallible. - Change `gst_rtsp_server::RTSPToken` API to be consistent with `gst::Structure`, specifically add a builder. - Change `from_glib_ptr_borrow()` functions to work with references instead of raw pointers for improved safety. - Improve code generation when building with `panic=abort`. - Change `gst::BufferList` APIs to work with ranges instead of index+length. - Use various `usize` instead of `u32` for various indices in `gst::Buffer`, `gst::Caps`, `gst::Structure` and related APIs. - `gst::Clock` calibration-related API uses plain `u64` instead of `gst::ClockTime` for the clock rate. - `gst::debug!` and related macros use `obj = x` instead of `obj: x` for specifying the target object now. Similar for `imp` and `id`. The old syntax is still supported but deprecated. The new syntax works better with tooling, especially rustfmt. ### Added - Mutable access to the `gst_webrtc::WebRTCSessionDescription` fields. - `gst::StructureBuilder::field_if_some()` and the same for related builders to only set a value if `Some(x)` is provided. - `gst::StructureBuilder::field_from_iter()` and `field_if_not_empty()` for various builders. - `gst::PadBuilder` API for selecting an automatically generated name. - Adapter for the `log` crate around the GStreamer debug log system. This allows the macros from the `log` crate to be output via the GStreamer debug log system. - Bindings for the double click `gst_video::Navigation` event. - Bindings for `gst_pbutils` missing/install plugins API. - Setters for `gst_editing_services::FrameCompositionMeta`. - `ges::UriClipAsset::new()`. ## [0.22.6] - 2024-06-19 ### Fixed - When logging with an id and a formatted log message this would previously panic. - A couple of clippy warnings. ## [0.22.5] - 2024-05-23 ### Fixed - A couple of clippy warnings and compiler warnings about unused imports with latest rustc. - Memory leak in builder for the `SelectStreams` event. - Add parameter validity assertions to various `BufferList` and `Caps` APIs where these assertions were missing to avoid assertions in C. ### Added - `StreamProducer::set_forward_preroll()` API to configure if the preroll buffer should be directly forwarded or not yet. ### Changed - Remove nonsensical gstreamer-video test that fails with latest GStreamer main. - Update to itertools 0.13. ## [0.22.4] - 2024-04-08 ### Added - Implement `From` / `ToValue` for `gst_audio::AudioConverterConfig` and `gst_video::VideoConverterConfig`. ### Changed - Fixed various 1.77 clippy warnings. ## [0.22.3] - 2024-03-19 ### Changed - Change `ges::CompositionMeta` position fields to `f64`s in correspondence with the C API. - Change `gst_analytics::AnalyticsMtdRef::obj_type()` to an `Option` in correspondence with the C API. ### Added - `gst::Fraction::new_raw()` and `from_integer()` const constructors. ## [0.22.2] - 2024-02-26 ### Changed - Update GStreamer gir files and add more new 1.24 API. ### Fixed - Add `gst::Object` as parent class for various `gst_rtp` types. - Handle all already queued messages in `gst::BusStream` instead of just new messages. ### Added - Add `gst::CustomMeta::is_registered()`. ## [0.22.1] - 2024-02-13 ### Changed - Update GStreamer gir files and add more new 1.24 API. ### Fixed - Make `AnalyticsODLocation` struct fields public. - `MetaRefMut::upcast_mut()` returns a mutable reference now. ## [0.22.0] - 2024-02-08 ### Changed - Compatible with gtk-rs-core 0.19 / gtk4-rs 0.8. - Update GStreamer gir files to latest (upcoming) 1.24 APIs. - Various standalone functions were moved to separate modules or methods. - `gst::Rank` is not implemented as an enum but as a struct with associated constants now. - Optimized `gst::Buffer::from_slice()` and `Memory::from_slice()` implementations that have one heap allocation fewer. - Various `gst::Buffer` and `gst::Memory` functions take ranges now instead of offset/size parameters. ### Added - Bindings for `gst_gl::GLContext::thread_add()`, `GLFrameBuffer::draw_to_texture()`. - New `gst_gl::GLVideoFrame` type that replaces `gst_video::VideoFrame` for GL-specific API, and comes with mostly the same interface. - Basic gstreamer-tag bindings. - `gst::Buffer:dump()` and `dump_range()` together with the same API on `gst::Memory` for hex-dumping the whole buffer/memory content. - Implement `Clone` on `gst::MetaRef`. - Bindings for `gst::Buffer::map_range_readable()` and its writable variant. - Array-based accessor for `gst_video::VideoFrame` and `gst_audio::AudioBuffer` plane data. - Support for handling custom authentication in `gstreamer-rtsp-server`. - Accessors for various base class struct fields. - Owned buffer getter for `AudioBuffer` / `VideoFrame`. - `gst_rtp::RTPSourceMeta` bindings. - `gst::macos_main()` bindings. - gstreamer-analytics bindings. ### Fixed - API typo in owned `gst::ReferenceTimestampMeta` reference getter. - Allow variable expansion in `gst::loggable_error!` macro. - `gstreamer-gl-*` crates can build docs again on stable. ### Removed - `gst::Pad::caps()` property getter. Use `current_caps()` instead which does the same thing. - Various deprecated APIs that were deprecated in previous releases. - Getter for a mutable buffer reference from `AudioBuffer` / `VideoFrame` as that allowed invalidating the buffer map. ### Fixed ## [0.21.3] - 2023-12-18 ### Added - Update GStreamer gir files to latest (upcoming) 1.24 APIs. - Add an example for writing subclasses with virtual methods. - Add `gst::ClockTime::absdiff()` and same for similar types. ### Fixed - In `Play` example, set bus to flushing before dropping `Play` instance. - Add missing `docsrs` configuration for correct documentation generation. - Make `gst_pbutils::element_properties` module public. - Add missing `gst_audio::AudioFilterImpl::parent_allowed_caps()`. - Fix assertions in `gst::Memory` copy/share/resize functions. ### Changed - Update to itertool 0.12, pretty-hex 0.4. ## [0.21.2] - 2023-11-11 ### Changed - Update GStreamer gir files to latest (upcoming) 1.24 APIs. - Update to latest gir code generator from the gtk-rs 0.18 branch. ### Fixed - Big endian video format order is correct again. - `gst::MetaRef::has_tags()` and `tags()` API actually works and works based on the tags of the concrete meta instance. - `gst::MetaRef::tags()` returns strings with arbitrary lifetimes now because they're statically stored anyway. - Fix another potential deadlock in `gst_utils::StreamProducer` when sending force-keyunit events. ### Added - Bindings for `gst_video::VBIEncoder` and `VBIParser`. - Accessors for the different `gst::PadProbeData` types on `PadProbeInfo`. - `Default` impl for `gst::AllocationParams`. - `From` / `TryFrom` implementations between formatted types (e.g. `gst::Bytes`) and `usize`. - `gst::MetaRef::copy()` to copy metas from one buffer to another. - `gst::ElementImpl::catch_panic_future()` to wrap a `Future` in such a way that panics are converted to GStreamer error messages and the element is marked as unusable. - `gst_gl::GLDisplay::handle()` to get a raw display handle. ## [0.21.1] - 2023-10-04 ### Changed - Update GStreamer gir files to latest (upcoming) 1.24 APIs. ### Fixed - Use correct media links in the tutorials code. - Fix a couple of new 1.72/1.73 clippy warnings. - Fix description of gstreamer-validate crate. - Copyright/license files for the gstreamer-gl were added. - Ordering of raw video formats follows the rules of latest libgstvideo now. - Fix potential deadlock in `gst_utils::StreamProducer` when sending force-keyunit events. ### Added - `max-time` / `max-bytes` setters to `gst_app::AppSink` builder. - `gst::CustomMeta::register_simple()`. ## [0.21.0] - 2023-08-08 ### Changed - Minimum supported Rust version is updated to 1.70.0. - Compatible with gtk-rs-core 0.18. - `gst::Bin::add_many()`, `remove_many()` and `gst::Element::link_many()`, `unlink_many()` are more generic now. - `gst_base::Aggregator::src_pad()` returns an `AggregatorPad`. - `gst::Bus::add_watch()` now returns a guard value that automatically removes the watch when it goes out of scope. - `gst::Bin`, `Pipeline` and `Pad` constructors don't take the optional name parameter anymore but it can instead be provided via the builder API. - `gst::Pad` and `GhostPad` builders inherit name from the pad template (or target) if possible and no other name is provided explicitly. - The preroll samples and selected sticky events are forwarded to `StreamProducer` consumers. ### Added - Support for the upcoming GStreamer 1.24 APIs. - Support for inline variable names in format strings for error/warning/info messages. - Methods for converting between floating point seconds and `gst::ClockTime`. - Various additions to the gst-validate bindings. - `Display` implementations for error/warning/info messages. - More useful `Debug` implementations for messages, events and queries and `gst_pbutils::DiscovererInfo` related structs. - API for listing/checking `gst::Meta` tags. ## [0.20.7] - 2023-07-05 ### Fixed - Fix `wait-for-eos` property name string in `appsink`. - Fix various memory leaks in `BaseTransform` subclassing bindings. - Mark some GES APIs as `Send+Sync`. ### Added - Implement `DiscovererInfo::debug()` and on related structs. + Add subclassing bindings for `GESFormatter`. ## [0.20.6] - 2023-06-06 ### Added - Getter for the `gst_rtsp_server::RTSPContext` URI field. ### Fixed - `gst_pbutils::DiscovererStreamInfo::stream_id()` can return `NULL`. This is mapped to the empty string for this release to keep backwards compatibility. - `gst_pbutils::DiscovererStreamInfo` iterator methods can be called on any subclass directly now without casting. - Debug logs use the actual function name against instead of the name of a closure generated by the log macros. ### Changed - Minor performance improvements to debug logging. ## [0.20.5] - 2023-04-22 ### Added - `glib::HasParamSpec` impl for miniobjects to allow using them with the properties derive macro. - `Default` impl for `gst_player::Player`. ## [0.20.4] - 2023-04-07 ### Fixed - Work around `gst_webrtc::WebRTCICE::add_candidate()` API breakage in 1.24. ### Changed - Reduce size of `gst_audio::AudioBuffer` and `gst_video::VideoFrame` by a factor of two by not storing an unnecessary copy of the audio/video info. ## [0.20.3] - 2023-03-14 ### Fixed - `gst::ParamSpecArray` uses the correct `glib::Type` now. - Work around accidental ABI breakage in 1.18 gst-rtsp-server `GstRTSPClient`. ### Added - Document `gst_utils::StreamProducer::forward_eos()` default value. ## [0.20.2] - 2023-02-21 ### Added - `glib::HasParamSpec` impl for `gst::ClockTime` - `Default` impl for `gst_play::Play` - Constructors for non-raw `gst_audio::AudioCapsBuilder` / `gst_video::VideoCapsBuilder` ## [0.20.1] - 2023-02-13 ### Fixed - Fix memory leaks when converting a `gst_audio::AudioBuffer` or `gst_video::VideoFrame` to a `gst::Buffer` or FFI type. ## [0.20.0] - 2023-02-10 ### Fixed - Make `gst_gL::GLDisplay::create_context()` `other_context` parameter optional. - Make allocation query caps optional. ### Added - Conversions between `gst::Signed` and `T` and signed integer types. - Bindings for the object lock via `gst::Object::lock()`. - Various `FromIterator`, `Extend` and `From` impls for creating `Caps`, `Structure`, `Buffer`, `BufferList`, `CapsFeatures` and other types. - `PartialEq` impls between owned/borrowed miniobjects/structures. - API for appending items to `gst::Array` and `gst::List`. ### Changed - Compatible with the 0.17 gtk-rs release. - Updated minimum supported Rust version to 1.64. - Require GStreamer 1.22.0 or newer when enabling the `v1_22` feature. - Require the object lock to be taken for various `gst_gl::GLDisplay` methods. - Renamed `gst::TagSetter::add()` to `add_tags()` to avoid name conflict with `Bin::add()`. - Mark various un-extendable enums as exhaustive. - Make use of `glib::GStr` and related API in caps, structure, tags and logging API to reduce temporary string allocations. - Various code optimizations to reduce generated code size and allow more optimal code to be generated. - Reduce size of various types, including reduction of `gst_audio::AudioInfo` from 832 to 320 bytes. - Use actual function name instead of module name in log output. - Change `gst_utils::StreamProducer` API to forward buffers by default and allow temporarily discarding via new `set_discard()` function. ## [0.19.8] - 2023-02-09 ### Changed - Update GStreamer .gir files to 1.22.0 release. ### Fixed - Marked `gst::MessageType` as non-exhaustive. ### Added - Added bindings for `gst::Message::structure_mut()`. - Added subclassing support for `gst_allocators::FdAllocator` and `DmabufAllocator`. ## [0.19.7] - 2023-01-19 ### Fixed - Work around the possibility that the caps in the allocation query can be `NULL` by returning any caps for now. This will be handled properly with a minimal API change in the 0.20 release. ## [0.19.6] - 2023-01-18 ### Fixed - The `AppSrc` and `AppSink` builders now assert that GStreamer is initialized before creating an instance. ## [0.19.5] - 2022-12-27 ### Fixed - Clear video frame values when mapping as GL texture to avoid out of bounds reads when trying to access the GL texture as raw video frame. - Allow returning `Handled` from `BufferList` pad probes. ### Changed - Update GStreamer .gir files to latest 1.21 git. ## [0.19.4] - 2022-12-16 ### Added - Subclassing bindings for `gst_audio::AudioFilter`. ### Fixed - Various new clippy warnings. ### Changed - Update GStreamer .gir files to 1.21.3 release. ## [0.19.3] - 2022-11-28 ### Added - `FromIterator` and `Extend` for `Caps`. - `PartialEq` impls between owned/borrowed miniobjects/structures. ### Fixed - Sticky event ordering for instant-rate-change. ### Changed - Updated GStreamer .gir files to post 1.22.2 release. ## [0.19.2] - 2022-11-13 ### Added - Subclassing support for `gst::Allocator`. - `gst_gl::GLBaseMemory::context()` to retrieve the GL context used by the memory. ### Changed - Updated GStreamer .gir files to 1.22.2 release. ### Fixed - `gst::Allocator::register()` does not cause use-after free with GStreamer < 1.20.5 anymore. - Don't generate version constants in `gstreamer-editing-services-sys` as they are useless and change with every update. ### Changed - Fixed various new clippy warnings. ## [0.19.1] - 2022-10-24 ### Changed - Make it possible to use objects not just as reference in the logging macros. ## [0.19.0] - 2022-10-22 ### Added - Builders for element construction. `gst::ElementFactory::make()` returns a builder now that allows to easily set the name or any other property at construction time. The old API is available as `make_with_name()`. - Builders for `Bin` and `Pipeline` as well as a `Default` trait implementation to simplify object construction. - Builders for `appsrc` and `appsink`, which allow type-safe construction of both elements while also allowing to easily set all their properties at construction time. - Builders for the GStreamer-specific fraction/array param/property specs. - Infrastructure for casting between `gst::Memory` subtypes/supertypes, and make use of it for GL memory. - Bindings for the `gstreamer-allocator` library with support for file descriptor-based and DMABUF memory. - Complete bindings for `gst_video` `Navigation` events. - Constructors for error/warning/info messages with a pre-built `glib::Error`. This also leads to some minor simplification of the existing API. - Accessors for static pads of various base classes for making accessing them cheaper and less error-prone than getting them by name. - Builder for pad templates. - Static PTP clock API for statistics, initialization and deinitialization. - New `gstreamer-utils` crate that currently contains only a `StreamProducer` API. This allows building 1:N bridges between live pipelines via `appsink` / `appsrc` elements. - Bindings for the new `gstreamer-play` library that was added in 1.20. - `gst::Caps::new_empty_simple()` to create caps without fields and just a name. - `gst_audio::AudioCapsBuilder` and `gst_video::VideoCapsBuilder` for building (possibly) unfixed raw audio/videos caps with typed setters for the various fields. This makes it impossible to mix up types and e.g. use an `u32` instead of an `i32` for the width of video caps. - `gst::Buffer::ptr_eq()` to compare buffers by pointer instead of doing a deep comparison, and also `ptr_eq()` on all other miniobject types. - Accessors for `gst_webrtc::WebRTCICECandidateStats` fields. - Bindings for the `gstreamer-validate` API. - Subclassing bindings for `gst_audio::AudioVisualizer` base class for easily writing audio visualization elements. - `gst_pbutils::EncodingProfile` API for element properties. - Support for returning buffer lists from `BaseSrc` / `PushSrc` subclasses. - Support for implementing `gst::Bin::do_latency()`. - Minimal bindings for the `gstreamer-mpegts` library. ### Fixed - Signature for `gst_base::Aggregator::connect_samples_selected()` to remove unnecessary generic parameter and make it straightforward to use. - Various APIs had optional parameters/return types corrected to match the C API more closely. - Logging does not evaluate its arguments anymore if the debug category is not enabled or below the current threshold. - Registering custom metas is now possible without transform function. - `gst::subclass::ElementImpl::request_new_pad()` signature uses a `&str` instead of an owned `String` now. ### Removed - `fragile` dependency and instead use the same functionality from `glib`. - `gst_audio::AudioAggregator` `ignore_inactive_pads` property, which was duplicated from the `Aggregator` base class. ### Changed - Compatible with the 0.16 gtk-rs release. - Updated minimum supported GStreamer version from 1.8 to 1.14. - Updated to the latest GStreamer 1.22 APIs while still supporting up to GStreamer 1.14. Any new 1.22 APIs might still change until the stable 1.22 release. - Updated minimum supported Rust version to 1.63. - In `EventView` / `QueryView`, getters that return references now return references that can outlive the view and are only bound by the lifetime of the corresponding event/query. - In addition `Query`, `Event` and `Message` views are implemented more consistently now, which makes them easier to use and as a side effect allows to pass e.g. more strongly typed queries to functions that only accept a single query type. - Various improvements to `gst::ClockTime`, `gst::format::Bytes`, `gst::format::Signed` and related types and their usage in the API, which should make its use from applications easier and less error-prone. Check the `gst::format` module-level documentation for details. - `gst::StreamsSelected` event builder takes the selected streams as iterator instead of slice. - For consistency with other macros the `gst` prefix of the logging macros was also removed. - Various iterator implementations were added and the existing ones were optimized by implementing more specialized traits and custom implementations for a couple of iterator functions. - GStreamer initialization safety checks were optimized. - `gst::Bus::post()` takes ownership of the passed messages like the C API. - Better and easier to read `Debug` impls for `Caps`, `TagList`, `Structure` and `Promise`. - `ser_de` feature was renamed to `serde`. - `gst::Tracer` implementations get result enums passed as `Result`s now instead of single enums. - `gst::Pad`, `ProxyPad`, `GhostPad` default functions are all associated functions instead of methods now to avoid conflicts between multiple types with the same method. - `Pad` tasks are catching panics from the task function and if the parent of the pad is an element then the panic is converted into an error message and the task is simply stopped. Otherwise the panic is rethrown. ## [0.18.8] - 2022-04-26 ### Added - Bindings for `RTPBasePayload` and `RTPBaseDepayload`. - Accessors for `RTPBuffer` buffer. - Bindings for `RTPBuffer` length calculation API. - More complete `gst::Task` bindings. ### Fixed - Export `gst::subclass::TaskPoolFunction`. ## [0.18.7] - 2022-04-04 ### Added - Bindings for `VideoAggregator` and the `VideoAggregatorPad`s. - Bindings for `AudioAggregator` and the `AudioAggregatorPad`s. - Bindings for `TaskPool`. - Various helper functions for `VideoFormatInfo`, `VideoInfo` and `VideoFrame`. ## [0.18.6] - 2022-03-08 ### Fixed - Require `Send` and not `Sync` for the values of an `gst::Array` / `gst::List`. ### Changed - Simplify and speed up log message string construction ## [0.18.5] - 2022-02-20 ### Changed - Require GStreamer 1.20.0 at least when building with `v1_20`. Earlier versions were already going to fail due to API mismatches before. ### Added - `gst::BufferPool` subclassing support. - `Debug` impl for `gst::MiniObject`. - `gst_rtsp_server::RTSPOnvifServer` and related API, including subclassing support. ### Fixed - Handle empty slices correctly at the FFI layer. - `MiniObjectRef::downcast_ref()` and similar functions return the correct type now. While this is an API change, the previous API would've never worked. ## [0.18.4] - 2022-02-04 ### Changed - Update gir files to GStreamer 1.20.0 release. ### Added - `gst_video::VideoCodecFrame::input_buffer_owned()` for getting an owned reference. ### Fixed - All documentation links in the `README.md`s are correct again. ## [0.18.3] - 2022-01-31 ### Added - `Default` implementation for `gst_video::VideoOverlayComposition` when targeting GStreamer 1.20. - `gst_video::VideoOverlayComposition::add_rectangle()` in addition to the addition of all rectangles via an iterator during construction. - Subclassing support for `gst_rtp::RTPHeaderExtension`. - `gst_webrtc::WebRTCError` for programmatically handling WebRTC errors. ### Fixed - `gst_rtp::RTPHeaderExtension` has `gst::Element` set as parent class now. - Global functions are re-exported from the `gst_rtp` crate root. ### Changed - GIO-style async operations in GES no longer need `Send`-able closures. ### Removed - `fragile` is no longer a dependency and instead the corresponding GLib API is used. ## [0.18.2] - 2022-01-24 ### Added - `glib::FromValue` for mini object references. - Bindings for `gst::DebugCategory::get_line()`. ## [0.18.1] - 2022-01-18 ### Fixed - `Message::view()` also handles the redirect message now. - `Message` and `Query` view variants that return references now borrow again from the underlying query and not the view enum, allowing to use them in a wider scope. ### Changed - All miniobjects, `VideoTimeCode`, `Structure` and `CapsFeatures` are marked as `#[repr(transparent)]` now to ensure that their memory representation is exactly the underlying raw pointer. ## [0.18.0] - 2022-01-16 ### Added - `gst_rtp::RtpHeaderExtension::read()` and `write()`. - `gst::ElementMetadata` has a `const` constructor now. - `gst_rtp::RtpBuffer` API works on buffer references instead of plain buffers for statically enforcing writability and usage in more places. - `gst_video::VideoCodecAlphaMeta` and `gst::CustomMeta`. - `gst::MiniObject` for generically passing around mini objects instead of their concrete types. - `gst_app::AppSink` `new-event` callback and `pull_object()` function. - `gst_pbutils::PbUtilsCapsDescriptionFlags` and `pb_utils_get_caps_description_flags()`. - `gst_rtp::RtpBuffer::remove_extension_data()`. - `gst_video::VideoDecoder` subframe API. - `gst_webrtc::WebRTCSCTPTransport`. - `gst::ElementFactory` `create_with_properties()` / `make_with_properties()`. - `gst_video::VideoContentLightLevel` and `VideoMasteringDisplayInfo` for HDR signalling. - Lots of missing `GES` API. - `gst::AllocationParams` and support in the allocation query. - `propose_allocation()` and `decide_allocation()` support in the various base classes. - `Iterator` implementation for `gst_video::VideoOverlayComposition`. - `Extend`, `IntoIterator` and `FromIterator` implementations for `Buffer`, `Caps`, `BufferList`, `CapsFeatures`, `StreamCollection` and `Structure` for more natural Rust APIs. - `instant-rate-change` events/messages bindings. - Support for arithmetic operations on `Option` and related types. - `gst_video::ColorBalance`. - `gst::MetaFlags`. - `gst_base::Aggregator::set_position()`. - Convenience getters for `gst::ElementFactory` and `gst::DeviceProviderFactory` metadata. - `gst_rtp::RtpBuffer::set_padding()`, `get_padding()` and `payload_mut()`. - `#[must_use]` to many types and functions. - `gst::Event`, `gst::Message` and `gst::Structure` `has_name()`. - `gst_video::Navigation` subclassing support and API improvements. - `gst::Structure` and `gst::Caps` `foreach()`, `map_in_place()` and `filter_map_in_place()`. - `gst_gl::GLBufferPool` and various GL constants and functions. - `gst_pbutils` codec utils APIs. ### Fixed - `gst_base::BaseTransform::prepare_output_buffer()` correctly reflects buffer writability. ### Changed - Compatible with the 0.15 gtk-rs release. - Updated to the latest GStreamer 1.20 APIs while still supporting up to GStreamer 1.8. Any new 1.20 APIs might still change until the stable 1.20 release. - Update all code to the Rust 2021 edition. This causes no user-facing changes. - `gst::Sample::segment()` returns a reference instead of a copy of the segment. - `gst::Object::set_property_from_str()` returns a `Result` now instead of silently failing like the C version. - Allow handling passed in buffers in `gst_base::PushSrc::create`. - Allow passing in `None` in `gst_player::Player::set_uri()`. - Use `[[f32; 4]; 4]` instead of `[f32; 16]` for affine transformation matrix. - `gst::Pad::sticky_event()` statically gets the event of the requested type instead of requiring to match on it afterwards. - Clean up `gst_pbutils` `EncodingProfile` API to be harder to misuse and less confusing. - Various `gst::Array`, `gst::List`, `gst::IntRange` and `gst::Fraction` API improvements that should reduce some friction. - Directly generate `NUL`-terminated C strings in debug log API instead of having multiple allocations per message. - Various functions return `glib::SList` and `glib::List` now to avoid copying into a `Vec` if only iteration is needed. - `gst::ChildProxy` API is more consistent with object property API. - Improved `gst::Buffer::foreach()`, `gst::Pad::sticky_events_foreach()` and `gst::BufferList::foreach()` APIs. - Don't post error messages from `propose_allocation()` and `decide_allocation()`. ## [0.17.4] - 2021-09-13 ### Added - Add constructor for device provider metadata. ## [0.17.3] - 2021-08-23 ### Fixed - `gst::Value::deserialize()` takes the target type as parameter now. This is technically an API change but the function would've never worked previously. ### Added - The release date-time parameter to `gst::plugin_define!` is optional now like in the C version of the macro. - Bindings to `gst::Tracer` and `gst::TracerFactory` for allowing to implement custom tracers in Rust. - Bindings for the new `gst::Value::deserialize_with_psec()` function from GStreamer 1.20. - serde `Serialize`/`Deserialize` impls for `gst::PadDirection`, `gst::PadPresence`, `gst::URIType` and `gst::Rank`. ## [0.17.2] - 2021-08-05 ### Fixed - Various new clippy warnings. - Compilation of `gstreamer-audio` on big-endian platforms. ### Added - Support for 1.20 `Gap` event `GapFlags`. - Support for 1.20 `Structure::serialize()` / `Caps::serialize()`. ## [0.17.1] - 2021-07-13 ### Fixed - Store 1.19 as plugin version when building plugins with `v1_20`. Otherwise plugins fail to load with GStreamer versions below 1.20.0. - Fix documentation for `gst::Element::request_pad_simple()` to actually show up. ## [0.17.0] - 2021-06-28 ### Fixed - Use `#[repr(transparent)]` where it is more correct and remove unneeded `#[repr(C)]` annotations. - Don't provide direct access to the logged object in logging functions as the object might currently be finalized and might be unsafe to access. - Moved X11/EGL/Wayland-specific GL APIs into their own crates instead of having them inside gstreamer-gl and behind feature flags. This simplifies conditional usage of them in applications. - Various nullability issues: parameters and return values that should've been or shouldn't have been nullable were fixed. - Print source object correctly in `gst::Message` `Debug` impl. - `gst_rtsp_server::RTSPServer::attach()` is fallible. - `gst::ElementFactoryListType` is a proper bitflags type now instead of generic `u64`. - `gst::PluginFeature::load()` returns the same type as the one passed in. - Value returned by `gst::PromiseFuture` can no longer be freed while still in scope. - Only assign to `GError**`s in subclassing code if they're not `NULL`. ### Added - Bindings for the GStreamer Controller library and the corresponding core API. - Subclassing support for `gst_player::PlayerVideoRenderer`. - `gst::PARAM_FLAG_CONTROLLABLE` and related bindings. - `gst_video::VideoOrientation` and `VideoOrientationMethod` bindings. - Support for removing pad probes from inside the pad probe callback. - `gst_check::Harness::pull_until_eos()` bindings. - `ges::TransitionClip` and `OperationClip`. - Bindings for `gst_gl::GLMemory` and related APIs. - Subclassing support for `gst_gl::GLFilter` and `gst_gl::BaseSrc`. - `gst::TagList::remove()`. - `gst::CapsFeatures` and `gst::Structure` API based on `glib::Quark`s instead of strings. - Subclassing support for `gst_video::VideoFilter`. - Bindings for various new 1.20 APIs: `gst_app::LeakyType`, `gst_video::VideoDecoderRequestSyncPointFlags`, `gst_rtp::RTPHeaderExtension`, `gst_audio::AudioLevelMeta`, `gst_webrtc::WebRTCKind` and various other new flags/enum types. - Subclassing support for `gst_rtsp_server::RTSPMountPoints`. ### Removed - Deprecated APIs in 0.16. - Don't declare that `gst_app::AppSink` and `AppSrc` inherit from `gst_base::BaseSink` and `BaseSrc` to avoid exposing API that is meant for subclasses to applications. - `gst_app::AppSrc` and `AppSink` signals that are also covered by the callbacks. The callbacks are more flexible and have lower overhead. - Duplicated getters/setters for `gst_base::BaseSink` and `BaseTransform` properties. ### Changed - Compatible with the 0.14 gtk-rs release. - Updated to the new GStreamer 1.20 APIs while still supporting up to GStreamer 1.8. Any new 1.20 APIs might still change until the stable 1.20 release. - FFI and safe high-level bindings are in the same repository now and use the same version numbers. - The .gir files are shared with gtk-rs and the GStreamer-specific ones are in a separate git submodule. - Update all code to the Rust 2018 edition. As part of this, most macros lost their `gst_` prefix. - Re-export dependency crates from the different preludes. - Getter functions don't have a `get_` prefix anymore and GObject property accessors don't include the `_property_` part in the middle of their function names anymore. Applications developers should use [`fix-getters-calls`](https://crates.io/crates/fix-getters-calls) to ease migration of their applications. Use [`fix-getters-def`](https://crates.io/crates/fix-getters-def) if you also want your `get` functions definition to comply with the API standards applied in this release. - Lots of changes to the subclassing API. Check the various elements in [gst-plugins-rs](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs) for examples. - Major improvements to the documentation infrastructure and generated documentation. - `gst::ClockID` bindings are refactored to use different types for single-shot and periodic clock ids, which makes misuse harder. - `gst::ProxyPad` extension trait uses trait functions instead of associated functions now for usability reasons. - Use `Result` for overriding flow returns from pad probes. - `gst_video::VideoInfo::align()` returns a `Result` instead of a `bool`. - Use actual error types instead of `()` in `gst_sdp` APIs. - `Display` impl for `gst::ClockTime` provides better human-readable strings. - `gst::Element::link_filtered()` and `link_pads_filtered()` takes a non-optional caps now. That's easier to use and for not providing caps the non-filtered variants of the functions exist. - Replace various manual bindings with auto-generated ones. - `gst::Element::get_request_pad()` is replaced by `request_pad_simple()` as a simpler version of `request_pad()` and in accordance with the deprecation in GStreamer 1.20. - `gst::ClockTime` and APIs working on it were changed to make possibility of using `GST_CLOCK_TIME_NONE` expressed in the type system. `Option` can be `None` while `gst::ClockTime` is always a valid time. ## [0.16.7] - 2021-02-13 ### Fixed - Usage of the logging system with a GStreamer library with the logging system compiled out does not crash any longer. - Double-free in `gst_video::VideoTimeCode` API when converting between validated and unvalidated timecodes. ### Added - `gst::Element::get_current_state()` and `get_pending_state()` convenience APIs. - `gst_audio::AudioConverterConfig` for setting the configuration on e.g. the `audiomixer` element. The low-level `AudioConverter` API is still not included in the bindings. ## [0.16.6] - 2020-12-20 ### Fixed - `VideoTimeCodeInterval`'s `Ord` and `PartialEq` implementations compare against the correct fields now. - `SDPMessage::medias_mut()` iterator does not crash any longer. ### Added - `PartialEq` and `Eq` implementations on `VideoAlignment`. - Alignment API for `VideoMeta` and `get_plane_height()` / `get_plane_size()`. - `VideoInfo::align_full()`. ## [0.16.5] - 2020-11-23 ### Fixed - Make sure to use `$crate` in more macros to allow them to work without anything special in scope already. - Update documentation location. - Don't panic if C code stores invalid seqnums in events and the seqnum is used directly or via the `Display` impl. - Fix docs build for some crates on docs.rs. - Fix `Debug` impl for `gst_video::VideoTimeCode` to print the correct type name. - Fix plugin version to be 1.18 instead of 1.17 when compiling a plugin with `v1_18`. ### Added - Event handling support in pad probes, that is returning `PadProbeReturn::Handled` for events. - `EventRef::get_structure_mut()` getter that allows changing the events' structures. ### Changed - Remove unnecessary `PhantomData` markers and use `repr(transparent)` instead of `repr(C)` where it is more correct. ## [0.16.4] - 2020-10-09 ### Fixed - Correctly implement `ExactSizeIterator` on the `AudioFormat` and `VideoFormat` iterators. Previously they returned the overall size instead of the remaining size, and they didn't implement `Iterator::size_hint()`. - Don't implement `ExactSizeIterator` on the buffer `gst::Meta` iterator. The overall length is not known easily and the implementation would've simply panicked in the past. ### Added - `gst::ClockID::wait_async_stream()` for async integration for clock waiting. - `From` / `TryFrom` impls for converting between `gst::ClockTime` and `std::time::Duration`. ## [0.16.3] - 2020-09-08 ### Fixed - Reset vfuncs if calling `BaseTransformClass::configure()` multiple times. - Fix `gst::debug_remove_default_log_function()` to actually remove the default log function. ### Added - Some more new APIs added in 1.18. - API for getting an owned buffer from a readable `gst_video::VideoFrame` / `VideoFrameRef`. ### Changed - Updated bindings to 1.18.0. This stabilized GStreamer 1.18 support and any API behind the "v1_18" feature is considered stable now. - Factor out some common code from `gst::Pad::ProbeInfo` code. This reduces the code generated for each pad probe considerably. - Update paste dependency to 1.0 and pretty-hex to 0.2. ## [0.16.2] - 2020-07-27 ### Fixed - Use correct pointer for the plane data in `gst_audio::AudioBuffer`. ### Added - Add `gst::GhostPad` convenience constructors that take a target pad, similar to the ones that existed in 0.15 and before. - Add `gst::parse_bin_from_description_with_name` that allows setting a name for the created bin without having to use unsafe code in application code. ## [0.16.1] - 2020-07-10 ### Fixed - Allow calling `gst::DebugCategory::new()` before `gst::init()` again. ## [0.16.0] - 2020-07-06 ### Added - Updated bindings to 1.17.2, adding experimental 1.18 support. This can be opted-in via the "v1_18" feature flag but there might still be API changes in the newly added API. - `gst::MemoryRef::dump()` for dumping contents of a memory. - `gst::Bus::stream()` instead of a custom constructor on the `BusStream`. - Use more accurate types for `Seqnum`, `GroupId` and `MetaSeqnum`. These are now proper wrapper types instead of plain integers, which makes misuse harder. - Provide `TryFrom` impls for conversion between `glib::DateTime` and `gst::DateTime`. - Add `get_allocator()` functions to `gst_base::{Aggregator, BaseTransform, BaseSrc}`, and allow overriding `BaseSrc::alloc()`. - Add subclassing bindings for `gst_base::PushSrc`. - Add new `gst::BufferCursor` API that allows to handle a buffer as `Read`, `Write` and `Seek` and accesses the underlying memories of the buffer individually without mapping them all together. - Add `gst::Plugin::get_plugin_name()`. - Support for `gst_video::VideoAFDMeta` and `VideoBarMeta`. - API for getting all / iterating over all `gst_audio::AudioFormat` and `gst_video::VideoFormat`. - Bindings and subclassing bindings for `gst_video::VideoSink`. - `gst::Pad` can be constructed via the builder pattern and `gst::PadBuilder` now, which allows to safely set the pad functions and various other fields during construction. The `PadBuilder` works on any `gst::Pad` subclass and also has special support for `GhostPad`s by allowing to set pad functions of the proxy pad. - `gst::Message`, `gst::Event` and `gst::Query` type constructors are now on the specific target type instead of various `new_XXX()` functions on the basic type. E.g. `gst::message::Eos::new()`. - Support for overriding `gst_audio::AudioSrc/Sink::reset()`. - Support for overriding `gst_base::BaseParse::stop()`. - Support for overriding `gst::Element::post_message()`. - Added bindings for `gst::BufferList::foreach()` and `foreach_mut()`. - Added bindings for `gst::Buffer::foreach_meta()` and `foreach_meta_mut()`. ### Fixed - Allow using any `glib::Object` as target object for logging instead of just `gst::Object`. - Remove restriction API from `gst_pbutils::EncodingContainerProfile`. They are supposed to be used only with the other encoding profiles. - Return `&'static str` for various `gst::StructureRef` functions where the string is backed by a `glib::Quark`. - Fix various `gst::DateTime` functions to actually return `Option`s. - Add support for filling in a buffer passed to the `gst::Pad` getrange function, allow passing one in into `get_range()` and `pull_range()` and provide the corresponding API on `gst_base::BaseSrc` too. - Allocator in audio/video `Decoder` base classes is optional and can return `None`. - `gst_video::ValidVideoTimeCode::add_interval()` always returns a valid timecode again. - Allow resolving a `gst::Promise` with `None` and also handle that correctly in the callback. This is allowed by the API. - Allow calling various debugging related functions before `gst::init()`. - Various enum/function versions were fixed to only show up if the corresponding version feature is enabled. - `gst::Pad` function setters are marked unsafe now as changing the functions is not thread-safe. - Remove `gst::Object::set_name()` as changing the name after construction generally causes problems and is potentially unsafe. - Remove `gst::Pad::set_pad_template()` as changing the pad template after construction is generally unsafe. - `gst::Pad::stream_lock()` borrows the pad now instead of taking a new reference. - Unimplemented `Jitter` and `Buffer` queries were removed from the bindings. These are not implemented in C and only have a type registered. - Various `LAST`, `NONE` variants of enums and flags were removed as these only make sense in C. - Call the parent impl of various vfuncs that were omitted before to not require further subclasses of them to implement them but automatically call the parent ones. ### Changed - Use `NonZeroU64/U32` for various ID types to allow further optimizations. - Use `thiserror` crate for deriving error types. - Switch from `lazy_static` to `once_cell`. - Change various miniobject functions like `gst::Caps::append()` from taking the object by value to modifying it internally. This makes them easier to use and only applies to functions that are defined on the non-reference type and take ownership of the values passed in. - Use `mem::ManuallyDrop` instead of `mem::forget()` everywhere. - Replace most `mem::transmute()` calls with safer alternatives. - `gst:StreamCollection` API was changed to the builder pattern for construction as the collection must not be changed after construction. - `gst::ProxyPad` default functions are plain functions on `ProxyPad` now instead of trait functions to allow easier usage of them. - Use proper error types in various `TryFrom` impls. - `gst_video::VideoMeta::add()` returns a `Result` now instead of panicking. - Various constructors were renamed from `new_with_XXX()` and `new_from_XXX()` to the more idiomatic `with_XXX()` and `from_XXX()`. - Miniobject bindings are simplified now and there is no `gst::GstRc` type anymore, instead everything is directly implemented on the concrete types. As part of this the `gst::MiniObject` trait was also removed as it was unneeded now. ## [0.15.7] - 2020-06-08 ### Fixed - Allow multiple filter types per process with `gst::Iterator::filter()`. - Check that `VideoInfo` is valid when creating a `VideoFrame`. - Don't potentially dereference a `NULL` pointer when getting the format from an invalid `VideoInfo` or `AudioInfo`. - Don't unmap borrowed `VideoFrameRef`s. ### Added - `gst::ProtectionMeta`, `gst_video::VideoAffineTransformationMeta`, `VideoCropMeta` and `VideoRegionOfInterestMeta` bindings. - Various new `gst_rtp::RTPBuffer` methods. - `gst_audio::audio_buffer_truncate()`, `AudioMeta` and `AudioBuffer` bindings. ## [0.15.6] - 2020-05-28 ### Fixed - Assert that the data passed to `VideoCaptionMeta::add()` is not empty. - Don't store strong references to the object in the bus, appsink and appsrc futures `Stream` / `Sink` adapters. This would keep them alive unnecessarily and would prevent the `Stream` / `Sink` to ever "finish" on its own. - Handle receiving a `None` reply in the change function of `gst::Promise`. This is apparently valid. For backwards compatibility reasons this is currently replaced with an empty structure but in 0.16 the API will explicitly handle `None`. ### Added - `gst::Stream::debug()` and `gst::StreamCollection::debug()` for converting into a structured string with the actual contents of each. - `gst::Structure::from_iter()` and `gst::Caps::from_iter()` to create structures/caps from iterators. - `gst::Event` support for getting/setting the `gst::Stream` in the `StreamStart` event. - `gst_video::calculate_display_ratio()` and `::guess_framerate()`. - Various video related `gst::CapsFeatures` in `gst_video`. - `TryFrom`/`From` impls for converting between `gst::Structure` and `gst_video::VideoConverterConfig`. - Various `glib::Value` trait impls for `SDPMessage`, `StructureRef`, `CapsFeatureRef` and all borrowed variants of miniobjects to be able to work with the borrowed, non-owned variants when handling `glib::Value`s. ## [0.15.5] - 2020-05-03 ### Fixed - Revert: Allow logging any `glib::Object` and not just `gst::Object`. This broke API in subtle ways and needs to wait until 0.16 - Replace `%` in log output with `%%` to prevent accidental C formatting - Add missing manual traits to the documentation ### Added - `BufferRef::peek_memory_mut()` to give a mutable reference to a given memory - Different iterators for iterating over the memories of a buffer - Support for `gst_audio::AudioClippingMeta` - `gst::Plugin::get_plugin_name()` was added - `gst::Element::get_current_clock_time()` and `gst::Element::get_current_running_time() helper functions - `gst::State` and `StateChange` API for calculating next/previous state and convert from/to the components of a state change ### Changed - Use `mem::ManuallyDrop` instead of `mem::forget` everywhere ## [0.15.4] - 2020-03-09 ### Fixed - Allow logging any `glib::Object` and not just `gst::Object` - Fix floating reference handling in `RTSPMedia::take_pipeline()` - Hold `GMutex` guards for the remainder of the function and warn if they're directly dropped - Work around empty/any caps handling bugs in `Caps::fixate()` ### Added - Add `BaseTransform::prepare_output_buffer()` subclassing support - `RTSPServer`, `RTSPClient`, `RTSPMedia` and `RTSPMediaFactory` subclassing support - Handle panicking in `appsrc`/`appsink` callbacks by posting an error message instead of killing the process ## [0.15.3] - 2020-02-15 ### Fixed - `UniqueFlowCombiner::clear()` should take a mutable reference. - `AudioStreamAlign` doesn't require mutable references for getters anymore. - Don't use bool return value of `gst_video_info_set_format()` and `gst_video_info_align()` with GStreamer < 1.11.1 as it returned void back then. We'd otherwise use some random value. - Make `VideoInfo::align()` is available since 1.8. - Fix changing/clearing of `AppSrc`, `AppSink` callbacks and `Bus` sync handler. Before 1.16.3 this was not thread-safe and caused crashes. When running with older versions changing them causes a panic now and unsetting the bus sync handler has not effect. With newer versions it works correctly. ### Added - Add `Clone` impls for `BufferPoolConfig` and `PlayerConfig`. - Add `VideoConverter` bindings. - Add `Future`s variant for `gst::Promise` constructor. - Add `Future`s variant for `gst_video::convert_sample_async()`. - Add `submit_input_buffer()`, `generate_output()`, `before_transform()`, `copy_metadata()` and `transform_meta()` virtual method support for `BaseTransform`. - Add `AppSink` `Stream` adapter and `AppSrc` `Sink` adapter for integrating both into Rust async contexts. ### Changed - More generic implementations of `VideoFrame` / `VideoFrameRef` functions to allow usage in more generic contexts. ## [0.15.2] - 2020-01-30 ### Fixed - Fix another race condition in the `gst::Bus` `Stream` that could cause it to not wake up although a message is available. ## [0.15.1] - 2020-01-23 ### Added - Use static inner lifetime for `VideoCodecState` so that it can be stored safely on the heap. - Getters/setters for `BinFlags` on `gst::Bin`. - `gst::Caps::builder_full()` for building caps with multiple structures conveniently. - `gst::Element::call_async_future()` for asynchronously spawning a closure and returning a `Future` for awaiting its return value. ### Fixed - Various clippy warnings. - Getters/setters for `PadFlags` on `gst::Pad` now provide the correct behaviour. - Take mutex before popping messages in the `gst::Bus` `Stream` to close a small race condition that could cause it to not be woken up. - `gst::ChildProxy` implementers do not have to provide `child_added()` and `child_removed()` functions anymore but these are optional now. - Manually implement `Debug` impls for various generic types where to `Debug` impl should not depend on their type parameters also implementing `Debug`. ## [0.15.0] - 2019-12-18 ### Added - `StructureRef::get_optional()` for returning `None` if the field does not exist instead of `Err` - Bindings for `gstreamer-rtp` library, mostly `RTPBuffer` - Support for writing `Preset`, `TagSetter`, `Clock`, `SystemClock` subclasses - Bindings for `Typefind::get_length()` - Bindings for `BaseSrcImpl::get_times()` - Bindings (incl. subclassing) for `AudioSink` and `AudioSrc` - Missing `Send`/`Sync` impl for various types ### Fixed - Cleanup of cargo features/dependencies to improve build times - Serde serialization with optional values. Attention: This changes the format of the serialization! - `VideoEncoder`/`VideoDecoder` `proxy_getcaps()` can't return `None` - Use non-panicking UTF8 conversion in log handler. We don't want to panic just because some C code printed a non-UTF8 string - Re-rexport all traits from the crate level and also ensure that all traits are actually included in the preludes - Actually export `is_video_overlay_prepare_window_handle_message()` function - Use `FnMut` for the `appsink` callbacks instead of `Fn` - `Promise` change function returns the actual reply to the promise now instead of just passing the promise itself - Memory leak in `Iterator::filter()` - `BinImpl::add()` takes ownership of floating references - `DeviceImpl::create_element()` preserves floating flag - `BinImpl::remove()` takes a strong reference of the element now as the last reference might be owned by the bin and otherwise we would potentially have a use-after-free afterwards - `BaseParseFrame` and `VideoCodecFrame` take a `&mut self` now for various functions that actually change the frame ### Changed - Minimum supported Rust version is 1.39 - Allow passing `None` to `VideoEncoder::finish_frame()` - Various `to_string()` methods were moved into the `Display` trait impl and for some types `to_str()` was added to return a `&'static str` - .gir files were updated to 1.16.2 release - `Sample` constructor uses the builder pattern now - `VideoMeta::add_full()` is simplified and requires parameters - `BasetransformImpl::set_caps()` returns a `Result` instead of `bool` - SDP data type getters for strings return an `Option` now as these can be `None` in practice although not allowed by the SDP spec - Various functions returning `Option`s were changed to return `Results` if `None` actually signalled an error instead of just a missing value ### Removed - "subclassing" and "futures" cargo features. These are enabled by default now ## [0.14.5] - 2019-09-17 ### Added - Support subclassing of `gst::Device`, `gst::DeviceProvider`, `gst_audio::AudioDecoder` and `::AudioEncoder` - Support for `Element::set_clock` and `::provide_clock` virtual methods - `ElementClass::add_metadata` was added - `gst_video::VideoDecoder` and `::VideoEncoder` got support for `get_caps`, `negotiate`, `src/sink_query/event` and the `drain` virtual methods - `Element::num_pads`, `::num_src_pads` and `::num_sink_pads` functions - `gst_video::VideoDecoder` and `::VideoEncoder` got `get_allocator` bindings - `gst::Iterator` implements `IntoIterator` now for providing `std::iter::Iterator>` adapter - Error macros for audio/video decoder subclasses to handle decoding errors more gracefully and only actually error out after many consecutive errors ### Fixed - Macros now also work in Rust 2018 edition without `#[macro_use]` but explicit imports - The log handler unit test runs reliable in parallel with other tests - Manually implement `Debug` for `gst::Iterator` to allow it for any `T` instead of `T: Debug` - `Device::create_element` has correct reference count handling now - Return `NotNegotiated` in the video codec base classes if setting the output state fails instead of `Error` ## [0.14.4] - 2019-08-14 ### Added - Bindings for adding/removing custom log functions - Bindings for `calculate_linear_regression()` - Constants for base class custom flow returns ### Fixed - Ownership of pad in `Element::release_pad()` virtual method implementations ## [0.14.3] - 2019-07-16 ### Added - `Buffer::unset_flags()` for unsetting specific buffer flags - `VideoBufferFlags` flags type and `VideoBufferExt::set_video_flags()`, `unset_video_flags()` and `get_video_flags()` for working with video buffer flags from safe code. ### Fixed - Setting buffer flags does not override arbitrary other flags anymore but only sets the flags in question. This is necessary to not override extension buffer flags like `gst_video::VideoBufferFlags`. ## [0.14.2] - 2019-07-15 ### Added - Support for `ReferenceTimestampMeta` ## [0.14.1] - 2019-07-06 ### Added - Various new WebRTC enum types from 1.14.1/1.16.0 ### Fixed - Correctly generate interlaced `VideoInfo` by using `gst_video_info_set_interlaced_format()` instead of the generic function. - serde serialization unit tests for `gst::format` succeed again now. ### Changed - `Debug` impls for `VideoFormatInfo` and `AudioFormatInfo` now print all the details of the format instead of only the name, and the `Debug` impls for `VideoInfo` and `AudioInfo` also print the format now. ## [0.14.0] - 2019-06-24 ### Added - Bindings for `GLSyncMeta`. - Bindings for setting/getting `TagScope` on a `TagList` - Bindings for `GLDisplayWayland` and `GLDisplayX11` in addition to the already existing `GLDisplayEGL` - Bindings for `Bus::pop_filtered()` and related functions - Bindings for getting/setting `Object`, `Element`, `Bin`, `Pipeline` and `Plugin` flags - Bindings for `VideoCaptionMeta` - `Debug` impl of `Buffer` now also shows the metas of the buffers - Expose flow return in `PadProbeInfo` for overriding the return value - Bindings for `VideoDecoder` and `VideoEncoder`, including subclassing support - Bindings for `Memory`, `Allocator` and `VideoBufferPool` - Bindings for `VideoFormatInfo::pack` and `::unpack` for format conversion - Bindings for `BaseParse`, including subclassing support - Various new arithmetic operation impls for fractions, formatted values and `ClockTime` - Bindings for `VideoInfo::align()` ### Changed - The `SDPMessage` and `SDPMedia` bindings were completely rewritten as they were broken before and caused crashes in various usages. As part of this there's also some more convenience API available on these types, like iterators for example, and API to modify the `SDPMedia` contained in a `SDPMessage`. - Update to GStreamer 1.16. - Regenerate with latest gir. - Run all autogenerated code through rustfmt after generation too. - Updated to latest versions of GLib/GIO/etc crates. - Updated to futures 0.3 / `std::future` - `ProxyPad` default functions moved to an extension trait instead of plain functions on `ProxyPad`, making them more in sync with the default `Pad` functions - GStreamer plugins are now exporting the new 1.14+ plugin symbols if they were configured for GStreamer 1.14+ - Arithmetic operations on formatted values and `ClockTime` do overflow checks now and replace the result with the `NONE` value on overflow - `TryFrom`/`TryInto` traits are used in various places now instead of the previous ad-hoc implementations of them. - Registering element/typefind/device monitor factories requires passing a value of `gst::Rank` now instead of an arbitrary `u32` ### Fixed - Use correct type for destroying pad task closure data. This was previously using the wrong type, causing crashes at runtime. - `DeviceAdded`/`DeviceRemoved` message getters are transfer full so we don't need to take an additional reference that would be leaked. - `AppSink` callbacks are correctly marked as `Send` instead of `Send+Sync`, allowing a wider range of closures to be used for them. - Handle `PadProbeReturn::Handled` return values from pad probes more correctly. - `ToOwned::to_owned()` on miniobjects has to create copies instead of only increasing the reference count. Otherwise it was possible to create multiple mutable and immutable references to the same object at the same time. - Various functions take references to owned miniobjects instead of borrowed references as it was otherwise possible to create multiple mutable or immutable references to the same object at the same time. - `URIHandler::set_uri` does not accept `None` anymore as this is not allowed by the C function. - Comparisons and addition of `TypeFindProbability` and `Rank` work correctly now - Various `Display` implementations were fixed to not cause a stack overflow due to infinite recursion anymore - Various `::to_string()` functions don't take ownership of C strings anymore that they do not own, which caused double frees before ### Removed - MIKEY related bindings from the SDP library. The bindings were broken and until someone needs them these are not available anymore. ## [0.13.0] - 2019-02-22 ### Added - Subclassing infrastructure was moved directly into the bindings, making the `gst-plugin` crate deprecated. This involves many API changes but generally cleans up code and makes it more flexible. Take a look at the `gst-plugins-rs` crate for various examples. - Bindings for GStreamer GL library - Bindings for `CapsFeatures` and `Meta` - Bindings for `ParentBufferMeta, `VideoMeta` and `VideoOverlayCompositionMeta` - Bindings for `VideoOverlayComposition` and `VideoOverlayRectangle` - Bindings for `VideoTimeCode` - Bindings for `NetAddressMeta` - Bindings for registering custom tags - `UniqueFlowCombiner` and `UniqueAdapter` wrappers that make use of the Rust compile-time mutability checks and expose more API in a safe way, and as a side-effect implement `Sync` and `Send` now - `Bus::add_watch_local()` and `gst_video::convert_frame_async_local()` that allows to use a closure that does not implement `Send` but can only be called from the thread owning the main context. - More complete bindings for `Allocation` `Query` - `pbutils` functions for codec descriptions - `TagList::iter()` for iterating over all tags while getting a single value per tag. The old `::iter_tag_list()` function was renamed to `::iter_generic()` and still provides access to each value for a tag - `Bus::iter()` and `Bus::iter_timed()` iterators around the corresponding `::pop*()` functions - Getters for `VideoColorimetry` to access its fields - `Debug` impls for various missing types. - serde serialization of `Value` can also handle `Buffer` now - Extensive comments to all examples with explanations - Transmuxing example showing how to use `typefind`, `multiqueue` and dynamic pads - basic-tutorial-12 was ported and added ### Changed - Rust 1.31 is the minimum supported Rust version now - Update to latest gir code generator and glib bindings - Functions returning e.g. `gst::FlowReturn` or other "combined" enums were changed to return split enums like `Result` to allow usage of the standard Rust error handling. - Various functions and callbacks returning `bool` or `Option<_>` were changed to return a `Result<_, glib::BoolError>` or `Result<_, gst::LoggableError>` or `Result<_, gst::ErrorMessage>` for better integration with Rust's error handling infrastructure. - Some infallible functions returning `bool` were changed to return `()`. - `MiniObject` subclasses are now newtype wrappers around the underlying `GstRc` wrapper. This does not change the API in any breaking way for the current usages, but allows `MiniObject`s to also be implemented in other crates and makes sure `rustdoc` places the documentation in the right places. - `BinExt` extension trait was renamed to `GstBinExt` to prevent conflicts with `gtk::Bin` if both are imported - `Buffer::from_slice()` can't possible return `None` ### Fixed - `gst::tag::Album` is the album tag now instead of artist sortname - Return `0` for the channel mask corresponding to negative `AudioChannelPosition`s. - `PartialOrd` and related traits are implemented via pointer equality on `ClockId` instead of using the compare function. Two clock ids with the same timestamp are not necessarily the same. - Various functions that are actually fallible are now returning an `Option<_>`. - Various `clippy` warnings ## [0.12.2] - 2018-11-26 ### Fixed - PTP clock constructor actually creates a PTP instead of NTP clock ### Added - Bindings for GStreamer Editing Services - Bindings for GStreamer Check testing library - Bindings for the encoding profile API (encodebin) - VideoFrame, VideoInfo, AudioInfo, StructureRef implements Send and Sync now - VideoFrame has a function to get the raw FFI pointer - From impls from the Error/Success enums to the combined enums like FlowReturn - Bin-to-dot file functions were added to the Bin trait - gst_base::Adapter implements SendUnique now ### Changed - All references were updated from GitHub to freedesktop.org GitLab - Fix various links in the README.md - Link to the correct location for the documentation - Remove GitLab badge as that only works with gitlab.com currently ## [0.12.1] - 2018-09-21 ### Added - More complete bindings for the gst_video::VideoOverlay interface, especially gst_video::is_video_overlay_prepare_window_handle_message() ## [0.12.0] - 2018-09-08 ### Added - Bindings for the GStreamer SDP and WebRTC libraries - Generic API for working with tags that is based on string tag names and glib::Value for the tag values - Bindings for Aggregator and AggregatorPad - Bindings for BaseTransform/BaseSrc::get_buffer_pool() - Optional serde implementations for the basic GStreamer data flow and metadata types ### Changed - Use ptr::NonNull in various places - Updated to muldiv 0.2, num-rational 0.2 - Bus::create_watch() can't return None - Remove CallbackGuard as unwinding across FFI boundaries is not undefined behaviour anymore but will directly cause a panic - Changed from the futures to the futures-preview crate as an optional dependency - Various Caps operations take a &CapsRef instead of &Caps - "deep-notify" signal takes the whole ParamSpec as parameter instead of only the signal name - Some structs were changed from empty struct to empty enums - Pad probe code does not take an additional reference to the data anymore, potentially passing writable events/buffers into the probe - ValueExt::compare() is implemented around std::cmp::Ordering now instead of a custom enum that was basically the same ### Fixed - Pad::add_probe() can return None if an IDLE probe was already called and removed in the meantime - Various compiler and clippy warnings ### Removed - std::Iterator impl for gst::Iterator. It was awkward to use because the gst::Iterator could fail at each iteration ## [0.11.6] - 2018-08-27 ### Fixed - Build with NLL/two-phase borrows - Explicitly define [bin] section for discoverer example to fix a cargo warning ### Added - Add unsafe gst::deinit() function - Ord/PartialOrd impls on gst::Seqnum - Getter for current pad mode - gst::Pad::sticky_events_foreach() for iterating over all sticky events in a thread-safe way ## [0.11.5] - 2018-07-24 ### Fixed - `gst::Bus`'s sync handler must unref every message if `gst::BusSyncReply::Drop` is returned, otherwise they are all leaked ## [0.11.4] - 2018-07-19 ### Fixed - `gst::Caps::subtract()` does not leak its arguments anymore - `gst::Caps::get_structure()` gracefully returns `None` if the index is out of bounds instead of a `g_return_val_if_fail()` - `gst::Structure::new()` has to give away ownership of the info structure but didn't. For 0.11 we internally copy, in 0.12 it will take the info structure by value - Typefind tests don't fail anymore if the system has typefind factories without caps ### Added - An additional assertion that ensures that miniobjects are actually writable before creating a mutable reference ## [0.11.3] - 2018-06-08 ### Added - `gst::Bus::remove_watch()` is now available to remove a bus watch again - `fmt::Debug` impls for `AudioInfo` and `VideoInfo` were added - `fmt::Debug` impls for mini objects also print the pointer value now to make it easier to track them in debug logs - `PlayerVisualization` has accessors for the name and description fields now, without which there is no sensible way to use them or to set a player visualization ## [0.11.2] - 2018-05-09 ### Fixed - Work-around various floating reference handling changes between 1.12 and 1.14 to be able to run with both versions without memory leaks or other reference count problems. This affects NetTimeProvider, BufferPool, DeviceMonitor, Stream, StreamCollection, and Player, NetClientClock, NetClock, PtpClock which were already previously fixed. ### Changed - Change the appsrc need-data and all appsink callbacks to not require the Sync bound anymore and change from Fn to FnMut. They can only be called from a single thread at a time. This change is only done for the corresponding callbacks, not the signals. ## [0.11.1] - 2018-04-07 ### Fixed - Fix Structure::to_string() to not run into an infinite recursion but call the method on the contained StructureRef instead of on itself ## [0.11.0] - 2018-03-20 ### Changed - Updated everything to GStreamer 1.14.0 - Event, Message and Query types were refactored to improve usability. Especially newly constructed queries allow to directly use the type-specific functions to be used without first creating a view - VideoFrameRef::copy_to_ref() and ::copy_plane_to_ref() are gone now and the original functions work with refs instead of full frames - PadProbeId and NotifyIds are not Copy/Clone anymore and are taken by value - GstPlayer has GstObject as parent class now ### Added - GstPbutils, GstSdp, GstRtsp and GstRtspServer bindings - GstPromise, GstAudioStreamAlign and various other 1.14 API - GstVideoFilter and GstBufferPool bindings - Element::call_async() - Debug impl For Toc and TocEntry - Various new examples (RTP FEC, RTSP server, tag usage, ...) ### Fixed - Memory leak in gst_video::convert_sample_async() ## [0.10.2] - 2018-02-18 ### Fixed - Fix building of messages with custom fields for types that don't have a GstStructure ### Added - VideoFrameRef::copy_to_ref() and ::copy_plane_to_ref(), which work with VideoFrameRefs instead of full VideoFrames - Getters for the BaseSrc/Sink/Transform configured segment - Document the gstreamer-player-1.0 dependency in the README.md ## [0.10.1] - 2018-01-03 ### Fixed - Don't require &mut self for TagSetterExtManual::add() ### Added - A TagSetter example application - Bindings for gst_video::convert_sample() and ::convert_sample_async() - Bindings for gst_video::VideoRectangle - Debug impl for Sample and ::with_buffer_list() constructor - A borrowing version of VideoFrame: VideoFrameRef - Bindings for GstVideoFilter ### Changed - Deprecated Sample::get_info() in favour of ::get_structure() - Player has gst::Object as another parent class now ## [0.10.0] - 2017-12-22 ### Fixed - Various clippy warnings - Memory leak of the tag list in Toc::merge_tags() - Property getters use Values of the correct type - Event::get_structure(), Message::get_structure() and Query::get_structure() can return None for the structure - Various other nullability fixes all over the API, changing functions to accept Option<> or returning Option<>, or only plain types - Functions taking paths/filenames now actually take Paths instead of &strs - Element::remove_pad() is not giving away a new reference to the pad anymore, which caused a memory leak of all pads ever removed - Precision handling in ClockTime's Display impl - Video/AudioInfo are only Send, not Sync ### Added - Various enums now also derive useful traits like Copy, Clone and Hash in addition to PartialEq, Eq and Debug - TagList::merge() and insert() for combining tag lists - EventType gained many useful functions to work with event types and a PartialOrd impl to check expected event order of event types where it matters - MessageRef/EventRef/QueryRef implement ToOwned - Bindings for Registry and PluginFeature - Event::set_running_time_offset() for adjusting the offset while events pass through the pipeline - Event/Message GroupIds and Seqnums now have a newtype wrapper around u32 instead of the plain value, making usage of them slightly more typesafe. Also add an "invalid" value for both, as exists in latest GStreamer now. - FormattedValue, GenericFormattedValue and related types were implemented now, which allows more convenient and type-safe usage of formatted values (time, bytes, etc) - Bindings for force-keyunit and still-frame events were added - MappedBuffer/BufferMap now implement various other useful traits, including AsRef<[u8]>, AsMut, Deref, DerefMut, Debug, PartialEq and Eq - Add VideoMultiviewFramePacking enum, and use it in Player - Bindings for the GStreamer Net library, including PTP/NTP/network client clocks and the GStreamer NetClock provider for network synchronization of pipelines - IteratorError implements std::error:Error - Plugin::add_dependency() and ::add_dependency_simple() was added - Rank and TypeFindProbability implement PartialOrd/Ord now - Bindings for TypeFind, TypeFindFactory and the typefind helpers - StreamCollection::iter() for iterating over all contained streams - ErrorMessage type that can be used e.g. in a Result for passing an error message from somewhere to upper layers to then be posted on an element the same way gst_element_error!() would've done ### Changed - Sample::new(), TagList::add(), Structure::set() and similar functions take the values (ToSendValue impls) by reference instead of value. They were not consumed by the function before. - The Debug impls of various types, including Event/Buffer/Message/Query/Structure were improved to print all the fields, similar to what GST_PTR_FORMAT would do in C - Switched to lazy_static 1.0 - Gap event and Duration tag are using ClockTimes now, as well as various Player signals - Segment is now based on a generic type FormattedSegment that can take any format (time, bytes, etc) or a GenericFormattedValue for more type-safety and convenience. Also functions for "casting" between a generic segment and a segment with a specific format exist on this now - AppSrc and AppSink now have a builder for the callbacks, making it unnecessary to always provide all callbacks even if only one is actually needed - Various functions that returned bool for errors, are now returning a Result - Player configuration is now a custom type with more convenient API - Player VideoInfo uses a Fraction instead of (u32,u32) for the framerate and pixel-aspect-ratio - VideoFrame API has more consistent API between writable and read-only variants - Buffer::copy_into() was added, and ::copy_region() now takes a BufferCopyFlags parameter instead of always using the default flags - ChildProxy::set_child_property() takes a &ToValue now to follow the API of Object::set_property() and improve usability - Proxy/GhostPad default pad functions use the correct specific pad type now instead of a generic Pad - Bus::add_signal_watch_full() takes a Priority for the priority instead of u32 - Clock::(un)adjust_with_calibration() takes no clock parameter anymore ### Removed - FormatValue was removed in favour of GenericFormattedValue and the connected traits and specific format impls ## [0.9.1] - 2017-11-26 ### Fixed - Export `FlowError`/`FlowSuccess`, `ClockError`/`ClockSuccess`, `PadLinkError`/`PadLinkSuccess` too ## [0.9.0] - 2017-11-26 ### Added - Bindings for (outputting to) the GStreamer logging system - Bindings for the GStreamer base library - Bindings for all the `Pad` functions to override pad behaviour, and pad task functions - Bindings for `StaticCaps` and `StaticPadTemplate` - Bindings for `deep-notify` signal on `Object` - Support for directly creating `Error`/`Warning`/`Info` `Messages` and posting them from an element with context information (file, line, module, etc.) similar to the C `GST_ELEMENT_ERROR` macro - Support for setting custom fields in `Messages`/`Events` during construction - Support for creating Buffers out of anything that is `AsRef<[u8]>` or `AsMut<[u8]>` - Support for using the `Read` trait on `Adapter` - Functions for getting all sink/src/all pads of an `Element`, and all children of a `Bin` - Builder for `Caps` and `Structures` in addition to the existing functions - `AppSrc`/`AppSink` implement `BaseSrc`/`BaseSink` and `URIHandler` - Rust ports of the basic tutorials 1 to 8 from https://gstreamer.freedesktop.org/documentation/tutorials/ - "Getting started" and "Installation" sections to the README.md - "dox" feature for generating documentation for all available configurations ### Fixed - `StackTraceFlags` are only available since 1.12 - Worked around macOS requiring a `NSRunLoop` running on the main thread in all examples and tutorials, to be able to show a window or anything else ### Changed - `ClockTime` is now a wrapper around `Option` to handle the `CLOCK_TIME_NONE` case better. This wrapper implements all the arithmetic and other traits as needed and ensures that no accidental calculations with `CLOCK_TIME_NONE` can happen - "Values with format", like in `Duration`/`Position`/`Convert` queries or `Seek` events now return a `FormatValue` type. This contains the actual `Format` together with the value and does any required conversions. This also makes it harder to accidentally mix e.g. values in bytes and time - `PadProbeId` does not implement `Clone`/`Copy` anymore - Property notify watches return a custom type instead of ulong - `Error`/`Warning`/`Info` `Messages` can only be created with specific kinds of `glib::Error` now. Using arbitrary ones does not work - `Iterator` bindings were completely rewritten and provide the item type as a generic type parameter now, greatly simplifying its usage - All `glib::Values` are now `glib::SendValue` instead, e.g. in `Caps` and `Structures`, as their content must be possible to send to different threads safely - `Message::get_src()` can return `None` - Allow `None` as `Caps` in `AppSrc`/`AppSink` - Allow everything implementing `Into>` to be used as a pad name - Moved `copy()` from `GstRc` directly to `MiniObject` - Success/Error enums (like `FlowReturn`, `PadLinkReturn`, `StateChangeReturn`) now implement an `into_result()` function that splits them into a `Result` with the good and bad cases. Also mark them as `#[must_use]` to make it harder to accidentally ignore errors. - Error enums implement the `Error` trait - Many examples use the `failure` crate for error handling now, cleaning up the error handling code quite a bit - Lots of other code cleanup, compiler/clippy warning cleanup, etc. ## [0.8.2] - 2017-11-11 ### Fixed - Implement StaticType of BufferRef instead of Buffer. Buffer aka GstRc already implements StaticType if BufferRef does, and without this it was not possible to use Buffers in GValues. - Free memory of the appsink/appsrc callbacks with the correct type. It was crashing because of using the wrong type before. - Fix documentation URLs in Cargo.toml. ### Added - Installation instructions and links to documentation for getting started to README.md. ## [0.8.1] - 2017-09-15 ### Added - Implement Send+Sync for Query, Message and Event, and their corresponding Ref types. ### Fixed - Constructor for gst_player::Player now works properly with GStreamer 1.12 when passing a video renderer or signal dispatcher. There was a reference counting bug. - Instead of returning &'static references from functions, return references with a generic, unbound lifetime instead. See https://github.com/rust-lang/rust/pull/42417#issue-233404573 - Various "unused external crate" warnings and clippy warnings everywhere. ### Changed - Remove Cargo.lock from GIT, it's not very useful for library crates. - Run everything through latest rustfmt-nightly. - Use while-let (instead of loop and if-let) and CLOCK_TIME_NONE (instead of u64::MAX) in the examples. ## 0.8.0 - 2017-08-31 - Initial release of the autogenerated GStreamer bindings. Older versions (< 0.8.0) of the bindings can be found [here](https://github.com/arturoc/gstreamer1.0-rs). The API of the two is incompatible. [Unreleased]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.24.0...HEAD [0.24.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.7...0.24.0 [0.23.7]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.6...0.23.7 [0.23.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.5...0.23.6 [0.23.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.4...0.23.5 [0.23.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.3...0.23.4 [0.23.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.2...0.23.3 [0.23.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.1...0.23.2 [0.23.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.23.0...0.23.1 [0.23.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.6...0.23.0 [0.22.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.5...0.22.6 [0.22.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.4...0.22.5 [0.22.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.3...0.22.4 [0.22.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.2...0.22.3 [0.22.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.1...0.22.2 [0.22.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.22.0...0.22.1 [0.22.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.21.3...0.22.0 [0.21.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.21.2...0.21.3 [0.21.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.21.1...0.21.2 [0.21.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.21.0...0.21.1 [0.21.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.7...0.21.0 [0.20.7]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.6...0.20.7 [0.20.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.5...0.20.6 [0.20.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.4...0.20.5 [0.20.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.3...0.20.4 [0.20.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.2...0.20.3 [0.20.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.1...0.20.2 [0.20.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.20.0...0.20.1 [0.20.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.8...0.20.0 [0.19.8]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.7...0.19.8 [0.19.7]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.6...0.19.7 [0.19.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.5...0.19.6 [0.19.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.4...0.19.5 [0.19.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.3...0.19.4 [0.19.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.2...0.19.3 [0.19.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.1...0.19.2 [0.19.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.19.0...0.19.1 [0.19.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.8...0.19.0 [0.18.8]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.7...0.18.8 [0.18.7]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.6...0.18.7 [0.18.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.5...0.18.6 [0.18.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.4...0.18.5 [0.18.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.3...0.18.4 [0.18.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.2...0.18.3 [0.18.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.1...0.18.2 [0.18.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.18.0...0.18.1 [0.18.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.17.4...0.18.0 [0.17.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.17.3...0.17.4 [0.17.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.17.2...0.17.3 [0.17.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.17.1...0.17.2 [0.17.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.17.0...0.17.1 [0.17.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.7...0.17.0 [0.16.7]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.6...0.16.7 [0.16.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.5...0.16.6 [0.16.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.4...0.16.5 [0.16.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.3...0.16.4 [0.16.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.2...0.16.3 [0.16.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.1...0.16.2 [0.16.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.16.0...0.16.1 [0.16.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.7...0.16.0 [0.15.7]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.6...0.15.7 [0.15.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.5...0.15.6 [0.15.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.4...0.15.5 [0.15.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.3...0.15.4 [0.15.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.2...0.15.3 [0.15.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.1...0.15.2 [0.15.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.15.0...0.15.1 [0.15.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.14.2...0.15.0 [0.14.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.14.1...0.14.2 [0.14.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.14.0...0.14.1 [0.14.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.13.0...0.14.0 [0.13.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.12.2...0.13.0 [0.12.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.12.1...0.12.2 [0.12.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.12.0...0.12.1 [0.12.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.6...0.12.0 [0.11.6]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.5...0.11.6 [0.11.5]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.4...0.11.5 [0.11.4]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.3...0.11.4 [0.11.3]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.2...0.11.3 [0.11.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.1...0.11.2 [0.11.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.11.0...0.11.1 [0.11.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.10.2...0.11.0 [0.10.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.10.1...0.10.2 [0.10.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.10.0...0.10.1 [0.10.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.9.1...0.10.0 [0.9.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.9.0...0.9.1 [0.9.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.8.1...0.9.0 [0.8.2]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.8.1...0.8.2 [0.8.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/compare/0.8.0...0.8.1 gstreamer-base-0.24.0/COPYRIGHT000064400000000000000000000022331046102023000141030ustar 00000000000000The gstreamer-rs project is dual-licensed under Apache 2.0 and MIT terms, with the exception of the sys crates which are licensed only under the terms of the MIT license. Copyrights in the gstreamer-rs project are retained by their contributors. No copyright assignment is required to contribute to the gstreamer-rs project. Some files include explicit copyright notices and/or license notices. For full authorship information, see the version control history. Except as otherwise noted (below and/or in individual files), gstreamer-rs is licensed under the Apache License, Version 2.0 or or the MIT license or , at your option. All the sys crates (e.g. gstreamer/sys and gstreamer-base/sys) are licensed only under the terms of the MIT license. This project provides interoperability with various GStreamer libraries but doesn't distribute any parts of them. Distributing compiled libraries and executables that link to those libraries may be subject to terms of the GNU LGPL or other licenses. For more information check the license of each GStreamer library. gstreamer-base-0.24.0/Cargo.lock0000644000000373140000000000100120030ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "atomic_refcell" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41e67cd8309bbd06cd603a9e693a784ac2e5d1e955f11286e355089fcab3047c" [[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bitflags" version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "cfg-expr" version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a2b34126159980f92da2a08bdec0694fd80fb5eb9e48aff25d20a0d8dfa710d" dependencies = [ "smallvec", "target-lexicon", ] [[package]] name = "cfg-if" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "futures-channel" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", "futures-util", ] [[package]] name = "futures-macro" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "futures-task" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-core", "futures-macro", "futures-task", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "gio-sys" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c8130f5810a839d74afc3a929c34a700bf194972bb034f2ecfe639682dd13cc" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", "windows-sys", ] [[package]] name = "gir-format-check" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a5da913a8586ce748f1164c890e1ebe75a7bbc472668f57b7f9fb893d7ac416" [[package]] name = "glib" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "690e8bcf8a819b5911d6ae79879226191d01253a4f602748072603defd5b9553" dependencies = [ "bitflags", "futures-channel", "futures-core", "futures-executor", "futures-task", "futures-util", "gio-sys", "glib-macros", "glib-sys", "gobject-sys", "libc", "memchr", "smallvec", ] [[package]] name = "glib-macros" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e772291ebea14c28eb11bb75741f62f4a4894f25e60ce80100797b6b010ef0f9" dependencies = [ "heck", "proc-macro-crate", "proc-macro2", "quote", "syn", ] [[package]] name = "glib-sys" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2be4c74454fb4a6bd3328320737d0fa3d6939e2d570f5d846da00cb222f6a0" dependencies = [ "libc", "system-deps", ] [[package]] name = "gobject-sys" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab318a786f9abd49d388013b9161fa0ef8218ea6118ee7111c95e62186f7d31f" dependencies = [ "glib-sys", "libc", "system-deps", ] [[package]] name = "gstreamer" version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1394d2bb79b4e7a662329c0afbb0f4be528f9a2289d094a31b4bd308e8c0972a" dependencies = [ "cfg-if", "futures-channel", "futures-core", "futures-util", "glib", "gstreamer-sys", "itertools", "kstring", "libc", "muldiv", "num-integer", "num-rational", "option-operations", "paste", "pin-project-lite", "smallvec", "thiserror", ] [[package]] name = "gstreamer-base" version = "0.24.0" dependencies = [ "atomic_refcell", "cfg-if", "gir-format-check", "glib", "gstreamer", "gstreamer-base-sys", "libc", ] [[package]] name = "gstreamer-base-sys" version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfad00fa63ddd8132306feef9d5095a3636192f09d925adfd0a9be0d82b9ea91" dependencies = [ "glib-sys", "gobject-sys", "gstreamer-sys", "libc", "system-deps", ] [[package]] name = "gstreamer-sys" version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36f46b35f9dc4b5a0dca3f19d2118bb5355c3112f228a99a84ed555f48ce5cf9" dependencies = [ "cfg-if", "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "hashbrown" version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indexmap" version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "itertools" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" dependencies = [ "either", ] [[package]] name = "kstring" version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1" dependencies = [ "static_assertions", ] [[package]] name = "libc" version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "memchr" version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "muldiv" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0" [[package]] name = "num-integer" version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ "num-traits", ] [[package]] name = "num-rational" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ "num-integer", "num-traits", ] [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "option-operations" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c26d27bb1aeab65138e4bf7666045169d1717febcc9ff870166be8348b223d0" dependencies = [ "paste", ] [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pin-project-lite" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "proc-macro-crate" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "serde" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "serde_spanned" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" dependencies = [ "serde", ] [[package]] name = "slab" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "system-deps" version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4be53aa0cba896d2dc615bd42bbc130acdcffa239e0a2d965ea5b3b2a86ffdb" dependencies = [ "cfg-expr", "heck", "pkg-config", "toml", "version-compare", ] [[package]] name = "target-lexicon" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" [[package]] name = "thiserror" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "toml" version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit", ] [[package]] name = "toml_datetime" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.22.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow", ] [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "version-compare" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" dependencies = [ "memchr", ] gstreamer-base-0.24.0/Cargo.toml0000644000000045300000000000100120200ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.83" name = "gstreamer-base" version = "0.24.0" authors = ["Sebastian Dröge "] build = false autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "Rust bindings for GStreamer Base library" homepage = "https://gstreamer.freedesktop.org" documentation = "https://gstreamer.freedesktop.org/documentation/rust/stable/latest/docs/gstreamer_base/" readme = "README.md" keywords = [ "gstreamer", "multimedia", "audio", "video", "gnome", ] categories = [ "api-bindings", "multimedia", ] license = "MIT OR Apache-2.0" repository = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" [package.metadata.docs.rs] all-features = true rustc-args = [ "--cfg", "docsrs", ] rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition", ] [features] default = [] v1_14_1 = ["gstreamer-base-sys/v1_14_1"] v1_16 = [ "gst/v1_16", "gstreamer-base-sys/v1_16", "v1_14_1", ] v1_18 = [ "gst/v1_18", "gstreamer-base-sys/v1_18", "v1_16", ] v1_20 = [ "gst/v1_20", "gstreamer-base-sys/v1_20", "v1_18", ] v1_22 = [ "gst/v1_22", "gstreamer-base-sys/v1_22", "v1_20", ] v1_24 = [ "gst/v1_24", "gstreamer-base-sys/v1_24", "v1_22", ] v1_26 = [ "gst/v1_26", "gstreamer-base-sys/v1_26", "v1_24", ] v1_28 = [ "gst/v1_28", "gstreamer-base-sys/v1_28", "v1_26", ] [lib] name = "gstreamer_base" path = "src/lib.rs" [[test]] name = "check_gir" path = "tests/check_gir.rs" [dependencies.atomic_refcell] version = "0.1" [dependencies.cfg-if] version = "1.0" [dependencies.glib] version = "0.21" [dependencies.gst] version = "0.24" package = "gstreamer" [dependencies.gstreamer-base-sys] version = "0.24" [dependencies.libc] version = "0.2" [dev-dependencies.gir-format-check] version = "0.1" gstreamer-base-0.24.0/Cargo.toml.orig000064400000000000000000000025201046102023000154760ustar 00000000000000[package] name = "gstreamer-base" authors = ["Sebastian Dröge "] description = "Rust bindings for GStreamer Base library" license = "MIT OR Apache-2.0" readme = "README.md" documentation = "https://gstreamer.freedesktop.org/documentation/rust/stable/latest/docs/gstreamer_base/" keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] version.workspace = true categories.workspace = true repository.workspace = true homepage.workspace = true edition.workspace = true rust-version.workspace = true [dependencies] cfg-if = "1.0" libc = "0.2" gstreamer-base-sys.workspace = true glib.workspace = true gst.workspace = true atomic_refcell = "0.1" [dev-dependencies] gir-format-check = "0.1" [features] default = [] v1_14_1 = ["gstreamer-base-sys/v1_14_1"] v1_16 = ["gst/v1_16", "gstreamer-base-sys/v1_16", "v1_14_1"] v1_18 = ["gst/v1_18", "gstreamer-base-sys/v1_18", "v1_16"] v1_20 = ["gst/v1_20", "gstreamer-base-sys/v1_20", "v1_18"] v1_22 = ["gst/v1_22", "gstreamer-base-sys/v1_22", "v1_20"] v1_24 = ["gst/v1_24", "gstreamer-base-sys/v1_24", "v1_22"] v1_26 = ["gst/v1_26", "gstreamer-base-sys/v1_26", "v1_24"] v1_28 = ["gst/v1_28", "gstreamer-base-sys/v1_28", "v1_26"] [package.metadata.docs.rs] all-features = true rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] gstreamer-base-0.24.0/Gir.toml000064400000000000000000000213301046102023000142250ustar 00000000000000[options] girs_directories = ["../gir-files", "../gst-gir-files"] library = "GstBase" version = "1.0" min_cfg_version = "1.14" work_mode = "normal" concurrency = "send+sync" generate_safety_asserts = true single_version_file = true generate_display_trait = false trust_return_value_nullability = true external_libraries = [ "GLib", "GObject", "Gst", ] generate = [ "GstBase.AggregatorStartTimeSelection", "GstBase.PushSrc", ] manual = [ "GLib.Bytes", "GObject.Object", "Gst.AllocationParams", "Gst.Allocator", "Gst.BufferFlags", "Gst.BufferPool", "Gst.ClockTimeDiff", "Gst.Element", "Gst.Event", "Gst.EventType", "Gst.Format", "Gst.Memory", "Gst.Object", "Gst.Pad", "Gst.Segment", "Gst.State", "Gst.StateChangeReturn", "Gst.TagMergeMode", "Gst.TypeFindProbability", "GstBase.BaseParseFrame", ] [[object]] name = "Gst.Buffer" status = "manual" ref_mode = "ref" [[object]] name = "Gst.BufferList" status = "manual" ref_mode = "ref" [[object]] name = "Gst.Caps" status = "manual" ref_mode = "ref" [[object]] name = "Gst.ClockReturn" status = "manual" must_use = true [object.conversion_type] variant = "Result" ok_type = "gst::ClockSuccess" err_type = "gst::ClockError" [[object]] name = "Gst.ClockTime" status = "manual" conversion_type = "Option" [[object]] name = "Gst.FlowReturn" status = "manual" must_use = true [object.conversion_type] variant = "Result" ok_type = "gst::FlowSuccess" err_type = "gst::FlowError" [[object]] name = "Gst.Sample" status = "manual" ref_mode = "ref" [[object]] name = "Gst.Structure" status = "manual" ref_mode = "ref" [[object]] name = "Gst.TagList" status = "manual" ref_mode = "ref" [[object]] name = "GstBase.*" status = "generate" # We'll opt-in for constants at a later time [[object.constant]] pattern = ".+" ignore = true [[object.function]] name = "type_find_helper_for_data" # broken return value manual = true [[object.function]] name = "type_find_helper_for_data_with_extension" # broken return value manual = true [[object.function]] name = "type_find_helper_for_buffer" # broken return value manual = true [[object.function]] name = "type_find_helper_for_buffer_with_extension" # broken return value manual = true [[object.function]] name = "type_find_helper_for_buffer_with_caps" # broken return value manual = true [[object.function]] name = "type_find_helper_for_data_with_caps" # broken return value manual = true [[object.function]] name = "type_find_list_factories_for_caps" # broken return value manual = true [[object.function]] name = "type_find_helper" [object.function.return] nullable_return_is_error = "Could not find type" [[object.function]] name = "type_find_helper_for_extension" [object.function.return] nullable_return_is_error = "Could not find type" [[object]] name = "GstBase.Adapter" status = "generate" final_type = true concurrency = "none" [[object.function]] name = "map" # Unsafe, implemented on `UniqueAdapter` ignore = true [[object.function]] name = "unmap" # Unsafe ignore = true [[object.function]] pattern = "copy.*" # Unsafe manual = true [[object.function]] name = "push" # Move Buffer manual = true [[object.function]] pattern = "take.*" # Unsafe ignore = true [[object.function]] pattern = "get.*" # Unsafe ignore = true [[object.function]] pattern = "masked.*" # Unsafe ignore = true [[object.function]] name = "flush" # Unsafe Buffer manual = true [[object]] name = "GstBase.Aggregator" status = "generate" manual_traits = ["AggregatorExtManual"] [[object.function]] name = "update_segment" # Takes FormattedValue as argument manual = true [[object.function]] name = "get_allocator" manual = true [[object.function]] name = "selected_samples" # Info parameter manual = true [[object.function]] name = "set_latency" [[object.function.parameter]] name = "min_latency" mandatory = true [[object.property]] name = "start-time-selection" version = "1.18" [[object.property]] name = "min-upstream-latency" # clock time instead of u64 manual = true [[object.signal]] name = "samples-selected" # StructureRef instead of Structure manual = true [[object]] name = "GstBase.AggregatorPad" status = "generate" manual_traits = ["AggregatorPadExtManual"] [[object.property]] name = "current-level-time" # ClockTime manual = true [[object]] name = "GstBase.BaseParse" status = "generate" manual_traits = ["BaseParseExtManual"] [[object.function]] name = "add_index_entry" [[object.function.parameter]] name = "ts" mandatory = true [[object.function]] name = "finish_frame" manual = true [[object.function]] name = "set_duration" manual = true [[object.function]] name = "set_latency" [[object.function.parameter]] name = "min_latency" mandatory = true [[object.function]] name = "convert_default" manual = true [[object.function]] name = "set_frame_rate" manual = true # Didn't bind gst_base_parse_frame_{new,init} so not needed [[object.function]] name = "push_frame" ignore = true [[object]] name = "GstBase.BaseParseFrameFlags" status = "generate" [[object.member]] name = "none" ignore = true [[object]] name = "GstBase.BaseSink" status = "generate" manual_traits = ["BaseSinkExtManual"] [[object.function]] name = "get_latency" [object.function.return] mandatory = true [[object.function]] name = "get_processing_deadline" [object.function.return] mandatory = true [[object.function]] name = "get_render_delay" [object.function.return] mandatory = true [[object.function]] name = "query_latency" # Use Result manual = true [[object.function]] name = "is_qos_enabled" # Same as the qos property ignore = true [[object.function]] name = "set_qos_enabled" # Same as the qos property ignore = true [[object.function]] name = "is_async_enabled" # Same as the async property ignore = true [[object.function]] name = "set_async_enabled" # Same as the async property ignore = true [[object.function]] name = "is_last_sample_enabled" # Same as the enable-last-sample property ignore = true [[object.function]] name = "set_last_sample_enabled" # Same as the enable-last-sample property ignore = true [[object.function]] name = "get_drop_out_of_segment" rename = "drops_out_of_segment" [[object.function]] name = "set_processing_deadline" [[object.function.parameter]] name = "processing_deadline" mandatory = true [[object.function]] name = "set_render_delay" [[object.function.parameter]] name = "delay" mandatory = true [[object.function]] name = "wait_clock" [[object.function.parameter]] name = "time" mandatory = true [[object]] name = "GstBase.BaseSrc" status = "generate" manual_traits = ["BaseSrcExtManual"] [[object.function]] name = "get_allocator" manual = true [[object.function]] name = "set_caps" [object.function.return] bool_return_is_error = "Failed to set caps" [[object.function]] name = "submit_buffer_list" # Pass by value, to be added manually ignore = true [[object.function]] name = "query_latency" # Use Result manual = true [[object.function]] name = "new_segment" [object.function.return] bool_return_is_error = "Failed to update segment" [[object]] name = "GstBase.BaseTransform" status = "generate" manual_traits = ["BaseTransformExtManual"] [[object.function]] name = "get_allocator" manual = true [[object.function]] name = "update_qos" [[object.function.parameter]] name = "timestamp" mandatory = true [[object.function]] name = "update_src_caps" [object.function.return] bool_return_is_error = "Failed to update src caps" [[object.function]] name = "is_qos_enabled" # Same as the qos property ignore = true [[object.function]] name = "set_qos_enabled" # Same as the qos property ignore = true [[object]] name = "GstBase.FlowCombiner" # Manual because ref/unref functions were added much later status = "manual" final_type = true concurrency = "none" gstreamer-base-0.24.0/LICENSE-APACHE000064400000000000000000000251371046102023000145440ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. gstreamer-base-0.24.0/LICENSE-MIT000064400000000000000000000017771046102023000142600ustar 00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gstreamer-base-0.24.0/README.md000064400000000000000000000176661046102023000141070ustar 00000000000000# gstreamer-rs [![crates.io](https://img.shields.io/crates/v/gstreamer-base.svg)](https://crates.io/crates/gstreamer-base) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/badges/main/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/commits/main) [GStreamer](https://gstreamer.freedesktop.org/) (Base library) bindings for Rust. Documentation can be found [here](https://gstreamer.freedesktop.org/documentation/rust/stable/latest/docs/gstreamer_base/). These bindings are providing a safe API that can be used to interface with GStreamer, e.g. for writing GStreamer-based applications and GStreamer plugins. The bindings are mostly autogenerated with [gir](https://github.com/gtk-rs/gir/) based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) API metadata provided by the GStreamer project. ## Table of Contents 1. [Installation](#installation) 1. [Linux/BSDs](#installation-linux) 1. [macOS](#installation-macos) 1. [Windows](#installation-windows) 1. [Getting Started](#getting-started) 1. [License](#license) 1. [Contribution](#contribution) ## Installation To build the GStreamer bindings or anything depending on them, you need to have at least GStreamer 1.14 and gst-plugins-base 1.14 installed. In addition, some of the examples/tutorials require various GStreamer plugins to be available, which can be found in gst-plugins-base, gst-plugins-good, gst-plugins-bad, gst-plugins-ugly and/or gst-libav. ### Linux/BSDs You need to install the above mentioned packages with your distributions package manager, or build them from source. On Debian/Ubuntu they can be installed with ```console $ apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ gstreamer1.0-libav libgstrtspserver-1.0-dev libges-1.0-dev ``` The minimum required version of the above libraries is >= 1.14. If you build the gstreamer-player sub-crate, or any of the examples that depend on gstreamer-player, you must ensure that in addition to the above packages, `libgstreamer-plugins-bad1.0-dev` is installed. See the `Cargo.toml` files for the full details, ```console $ apt-get install libgstreamer-plugins-bad1.0-dev ``` Package names on other distributions should be similar. Please submit a pull request with instructions for yours. ### macOS You can install GStreamer and the plugins via [Homebrew](https://brew.sh/) or by installing the [binaries](https://gstreamer.freedesktop.org/data/pkg/osx/) provided by the GStreamer project. We recommend using the official GStreamer binaries over Homebrew, especially as GStreamer in Homebrew is [currently broken](https://github.com/orgs/Homebrew/discussions/3740#discussioncomment-3804964). #### GStreamer Binaries You need to download the *two* `.pkg` files from the GStreamer website and install them, e.g. `gstreamer-1.0-1.20.4-universal.pkg` and `gstreamer-1.0-devel-1.20.4-universal.pkg`. After installation, you also need to set the `PATH` environment variable as follows ```console $ export PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/bin${PATH:+:$PATH}" ``` Also note that the `pkg-config` from GStreamer should be the first one in the `PATH` as other versions have all kinds of quirks that will cause problems. #### Homebrew Homebrew only installs various plugins if explicitly enabled, so some extra `--with-*` flags may be required. ```console $ brew install gstreamer gst-plugins-base gst-plugins-good \ gst-plugins-bad gst-plugins-ugly gst-libav gst-rtsp-server \ gst-editing-services --with-orc --with-libogg --with-opus \ --with-pango --with-theora --with-libvorbis --with-libvpx \ --enable-gtk3 ``` Make sure the version of these libraries is >= 1.14. ### Windows You can install GStreamer and the plugins via [MSYS2](http://www.msys2.org/) with `pacman` or by installing the [binaries](https://gstreamer.freedesktop.org/data/pkg/windows/) provided by the GStreamer project. We recommend using the official GStreamer binaries over MSYS2. #### GStreamer Binaries You need to download the *two* `.msi` files for your platform from the GStreamer website and install them, e.g. `gstreamer-1.0-x86_64-1.20.4.msi` and `gstreamer-1.0-devel-x86_64-1.20.4.msi`. Make sure to select the version that matches your Rust toolchain, i.e. MinGW or MSVC. After installation set the ``PATH` environment variable as follows: ```console # For a UNIX-style shell: $ export PATH="c:/gstreamer/1.0/msvc_x86_64/bin${PATH:+:$PATH}" # For cmd.exe: $ set PATH=C:\gstreamer\1.0\msvc_x86_64\bin;%PATH% ``` Make sure to update the path to where you have actually installed GStreamer and for the corresponding toolchain. Also note that the `pkg-config.exe` from GStreamer should be the first one in the `PATH` as other versions have all kinds of quirks that will cause problems. #### MSYS2 / pacman ```console $ pacman -S glib2-devel pkg-config \ mingw-w64-x86_64-gstreamer mingw-w64-x86_64-gst-plugins-base \ mingw-w64-x86_64-gst-plugins-good mingw-w64-x86_64-gst-plugins-bad \ mingw-w64-x86_64-gst-plugins-ugly mingw-w64-x86_64-gst-libav \ mingw-w64-x86_64-gst-rtsp-server ``` Make sure the version of these libraries is >= 1.14. Note that the version of `pkg-config` included in `MSYS2` is [known to have problems](https://github.com/rust-lang/pkg-config-rs/issues/51#issuecomment-346300858) compiling GStreamer, so you may need to install another version. One option would be [`pkg-config-lite`](https://sourceforge.net/projects/pkgconfiglite/). ## Getting Started The API reference can be found [here](https://gstreamer.freedesktop.org/documentation/rust/stable/latest/docs/gstreamer/), however it is only the Rust API reference and does not explain any of the concepts. For getting started with GStreamer development, the best would be to follow the [documentation](https://gstreamer.freedesktop.org/documentation/) on the GStreamer website, especially the [Application Development Manual](https://gstreamer.freedesktop.org/documentation/application-development/). While being C-centric, it explains all the fundamental concepts of GStreamer and the code examples should be relatively easily translatable to Rust. The API is basically the same, function/struct names are the same and everything is only more convenient (hopefully) and safer. In addition there are [tutorials](https://gstreamer.freedesktop.org/documentation/tutorials/) on the GStreamer website. Many of them were ported to Rust already and the code can be found in the [tutorials](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/tutorials) directory. Some further examples for various aspects of GStreamer and how to use it from Rust can be found in the [examples](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/tree/main/examples) directory. Various GStreamer plugins written in Rust can be found in the [gst-plugins-rs](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs) repository. ## LICENSE gstreamer-rs and all crates contained in here are licensed under either of * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. GStreamer itself is licensed under the Lesser General Public License version 2.1 or (at your option) any later version: https://www.gnu.org/licenses/lgpl-2.1.html ## Contribution Any kinds of contributions are welcome as a pull request. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in gstreamer-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. gstreamer-base-0.24.0/src/adapter.rs000064400000000000000000000307201046102023000153670ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{io, mem, ops}; use glib::translate::*; use crate::{ffi, Adapter}; impl Adapter { #[doc(alias = "gst_adapter_copy")] pub fn copy(&self, offset: usize, dest: &mut [u8]) -> Result<(), glib::BoolError> { assert!( offset .checked_add(dest.len()) .map(|end| end <= self.available()) == Some(true) ); if dest.is_empty() { return Ok(()); } unsafe { let size = dest.len(); ffi::gst_adapter_copy( self.to_glib_none().0, dest.as_mut_ptr() as *mut _, offset, size, ); } Ok(()) } #[doc(alias = "gst_adapter_copy_bytes")] pub fn copy_bytes(&self, offset: usize, size: usize) -> Result { assert!(offset.checked_add(size).map(|end| end <= self.available()) == Some(true)); if size == 0 { return Ok(glib::Bytes::from_static(&[])); } unsafe { Ok(from_glib_full(ffi::gst_adapter_copy_bytes( self.to_glib_none().0, offset, size, ))) } } #[doc(alias = "gst_adapter_flush")] pub fn flush(&self, flush: usize) { assert!(flush <= self.available()); if flush == 0 { return; } unsafe { ffi::gst_adapter_flush(self.to_glib_none().0, flush); } } #[doc(alias = "get_buffer")] #[doc(alias = "gst_adapter_get_buffer")] pub fn buffer(&self, nbytes: usize) -> Result { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Option::<_>::from_glib_full(ffi::gst_adapter_get_buffer(self.to_glib_none().0, nbytes)) .ok_or_else(|| glib::bool_error!("Failed to get buffer")) } } #[doc(alias = "get_buffer_fast")] #[doc(alias = "gst_adapter_get_buffer_fast")] pub fn buffer_fast(&self, nbytes: usize) -> Result { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Option::<_>::from_glib_full(ffi::gst_adapter_get_buffer_fast( self.to_glib_none().0, nbytes, )) .ok_or_else(|| glib::bool_error!("Failed to get buffer")) } } #[doc(alias = "get_buffer_list")] #[doc(alias = "gst_adapter_get_buffer_list")] pub fn buffer_list(&self, nbytes: usize) -> Result { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Option::<_>::from_glib_full(ffi::gst_adapter_get_buffer_list( self.to_glib_none().0, nbytes, )) .ok_or_else(|| glib::bool_error!("Failed to get buffer list")) } } #[doc(alias = "get_list")] #[doc(alias = "gst_adapter_get_list")] pub fn list(&self, nbytes: usize) -> Result, glib::BoolError> { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Ok(FromGlibPtrContainer::from_glib_full( ffi::gst_adapter_get_list(self.to_glib_none().0, nbytes), )) } } #[doc(alias = "gst_adapter_masked_scan_uint32")] pub fn masked_scan_uint32( &self, mask: u32, pattern: u32, offset: usize, size: usize, ) -> Result, glib::BoolError> { assert!(offset.checked_add(size).map(|end| end <= self.available()) == Some(true)); assert!(size != 0); assert!(((!mask) & pattern) == 0); unsafe { let ret = ffi::gst_adapter_masked_scan_uint32( self.to_glib_none().0, mask, pattern, offset, size, ); if ret == -1 { Ok(None) } else { assert!(ret >= 0); Ok(Some(ret as usize)) } } } #[doc(alias = "gst_adapter_masked_scan_uint32_peek")] pub fn masked_scan_uint32_peek( &self, mask: u32, pattern: u32, offset: usize, size: usize, ) -> Result, glib::BoolError> { assert!(offset.checked_add(size).map(|end| end <= self.available()) == Some(true)); assert!(size != 0); assert!(((!mask) & pattern) == 0); unsafe { let mut value = mem::MaybeUninit::uninit(); let ret = ffi::gst_adapter_masked_scan_uint32_peek( self.to_glib_none().0, mask, pattern, offset, size, value.as_mut_ptr(), ); if ret == -1 { Ok(None) } else { assert!(ret >= 0); let value = value.assume_init(); Ok(Some((ret as usize, value))) } } } #[doc(alias = "gst_adapter_take_buffer")] pub fn take_buffer(&self, nbytes: usize) -> Result { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Option::<_>::from_glib_full(ffi::gst_adapter_take_buffer(self.to_glib_none().0, nbytes)) .ok_or_else(|| glib::bool_error!("Failed to take buffer")) } } #[doc(alias = "gst_adapter_take_buffer_fast")] pub fn take_buffer_fast(&self, nbytes: usize) -> Result { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Option::<_>::from_glib_full(ffi::gst_adapter_take_buffer_fast( self.to_glib_none().0, nbytes, )) .ok_or_else(|| glib::bool_error!("Failed to take buffer")) } } #[doc(alias = "gst_adapter_take_buffer_list")] pub fn take_buffer_list(&self, nbytes: usize) -> Result { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Option::<_>::from_glib_full(ffi::gst_adapter_take_buffer_list( self.to_glib_none().0, nbytes, )) .ok_or_else(|| glib::bool_error!("Failed to take buffer list")) } } #[doc(alias = "gst_adapter_take_list")] pub fn take_list(&self, nbytes: usize) -> Result, glib::BoolError> { assert!(nbytes <= self.available()); assert!(nbytes != 0); unsafe { Ok(FromGlibPtrContainer::from_glib_full( ffi::gst_adapter_take_list(self.to_glib_none().0, nbytes), )) } } #[doc(alias = "gst_adapter_push")] pub fn push(&self, buf: gst::Buffer) { unsafe { ffi::gst_adapter_push(self.to_glib_none().0, buf.into_glib_ptr()); } } } impl io::Read for Adapter { fn read(&mut self, buf: &mut [u8]) -> Result { let mut len = self.available(); if len == 0 { return Err(io::Error::new( io::ErrorKind::WouldBlock, format!( "Missing data: requesting {} but only got {}.", buf.len(), len ), )); } if buf.len() < len { len = buf.len(); } self.copy(0, &mut buf[0..len]).map_err(io::Error::other)?; self.flush(len); Ok(len) } } #[derive(Debug)] pub struct UniqueAdapter(Adapter); unsafe impl Send for UniqueAdapter {} unsafe impl Sync for UniqueAdapter {} impl UniqueAdapter { pub fn new() -> Self { Self(Adapter::new()) } pub fn available(&self) -> usize { self.0.available() } pub fn available_fast(&self) -> usize { self.0.available_fast() } pub fn clear(&mut self) { self.0.clear(); } pub fn copy_bytes(&self, offset: usize, size: usize) -> Result { self.0.copy_bytes(offset, size) } pub fn distance_from_discont(&self) -> u64 { self.0.distance_from_discont() } pub fn dts_at_discont(&self) -> Option { self.0.dts_at_discont() } pub fn flush(&mut self, flush: usize) { self.0.flush(flush); } #[doc(alias = "get_buffer")] pub fn buffer(&self, nbytes: usize) -> Result { self.0.buffer(nbytes) } #[doc(alias = "get_buffer_fast")] pub fn buffer_fast(&self, nbytes: usize) -> Result { self.0.buffer_fast(nbytes) } #[doc(alias = "get_buffer_list")] pub fn buffer_list(&self, nbytes: usize) -> Result { self.0.buffer_list(nbytes) } #[doc(alias = "get_list")] pub fn list(&self, nbytes: usize) -> Result, glib::BoolError> { self.0.list(nbytes) } pub fn masked_scan_uint32( &self, mask: u32, pattern: u32, offset: usize, size: usize, ) -> Result, glib::BoolError> { self.0.masked_scan_uint32(mask, pattern, offset, size) } pub fn masked_scan_uint32_peek( &self, mask: u32, pattern: u32, offset: usize, size: usize, ) -> Result, glib::BoolError> { self.0.masked_scan_uint32_peek(mask, pattern, offset, size) } pub fn offset_at_discont(&self) -> u64 { self.0.offset_at_discont() } pub fn prev_dts(&self) -> (Option, u64) { self.0.prev_dts() } pub fn prev_dts_at_offset(&self, offset: usize) -> (Option, u64) { self.0.prev_dts_at_offset(offset) } pub fn prev_offset(&self) -> (u64, u64) { self.0.prev_offset() } pub fn prev_pts(&self) -> (Option, u64) { self.0.prev_pts() } pub fn prev_pts_at_offset(&self, offset: usize) -> (Option, u64) { self.0.prev_pts_at_offset(offset) } pub fn pts_at_discont(&self) -> Option { self.0.pts_at_discont() } pub fn take_buffer(&mut self, nbytes: usize) -> Result { self.0.take_buffer(nbytes) } pub fn take_buffer_fast(&mut self, nbytes: usize) -> Result { self.0.take_buffer_fast(nbytes) } pub fn take_buffer_list(&mut self, nbytes: usize) -> Result { self.0.take_buffer_list(nbytes) } pub fn take_list(&mut self, nbytes: usize) -> Result, glib::BoolError> { self.0.take_list(nbytes) } pub fn copy(&self, offset: usize, dest: &mut [u8]) -> Result<(), glib::BoolError> { self.0.copy(offset, dest) } pub fn push(&mut self, buf: gst::Buffer) { self.0.push(buf); } #[doc(alias = "gst_adapter_map")] pub fn map(&mut self, nbytes: usize) -> Result, glib::error::BoolError> { assert!(nbytes <= self.available()); assert!(nbytes != 0); use std::slice; unsafe { let ptr = ffi::gst_adapter_map(self.0.to_glib_none().0, nbytes); if ptr.is_null() { Err(glib::bool_error!("size bytes are not available")) } else { Ok(UniqueAdapterMap( self, slice::from_raw_parts(ptr as *const u8, nbytes), )) } } } } #[derive(Debug)] pub struct UniqueAdapterMap<'a>(&'a UniqueAdapter, &'a [u8]); impl Drop for UniqueAdapterMap<'_> { #[inline] fn drop(&mut self) { unsafe { ffi::gst_adapter_unmap((self.0).0.to_glib_none().0); } } } impl ops::Deref for UniqueAdapterMap<'_> { type Target = [u8]; #[inline] fn deref(&self) -> &[u8] { self.1 } } impl AsRef<[u8]> for UniqueAdapterMap<'_> { #[inline] fn as_ref(&self) -> &[u8] { self.1 } } impl Default for UniqueAdapter { #[inline] fn default() -> Self { Self::new() } } impl io::Read for UniqueAdapter { #[inline] fn read(&mut self, buf: &mut [u8]) -> Result { self.0.read(buf) } } gstreamer-base-0.24.0/src/aggregator.rs000064400000000000000000000157151046102023000161000ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] use std::boxed::Box as Box_; #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] use std::mem::transmute; use std::{mem, ptr}; #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] use glib::signal::{connect_raw, SignalHandlerId}; use glib::{prelude::*, translate::*}; use gst::{format::FormattedValue, prelude::*}; use crate::{ffi, Aggregator, AggregatorPad}; pub trait AggregatorExtManual: IsA + 'static { #[doc(alias = "get_allocator")] #[doc(alias = "gst_aggregator_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); let mut params = mem::MaybeUninit::uninit(); ffi::gst_aggregator_get_allocator( self.as_ref().to_glib_none().0, &mut allocator, params.as_mut_ptr(), ); (from_glib_full(allocator), params.assume_init().into()) } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "min-upstream-latency")] fn min_upstream_latency(&self) -> gst::ClockTime { self.as_ref().property("min-upstream-latency") } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "min-upstream-latency")] fn set_min_upstream_latency(&self, min_upstream_latency: gst::ClockTime) { self.as_ref() .set_property("min-upstream-latency", min_upstream_latency); } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "min-upstream-latency")] fn connect_min_upstream_latency_notify( &self, f: F, ) -> SignalHandlerId { unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::min-upstream-latency\0".as_ptr() as *const _, Some(transmute::<*const (), unsafe extern "C" fn()>( notify_min_upstream_latency_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_aggregator_update_segment")] fn update_segment( &self, segment: &gst::FormattedSegment, ) { unsafe { ffi::gst_aggregator_update_segment( self.as_ref().to_glib_none().0, mut_override(segment.to_glib_none().0), ) } } fn set_position(&self, position: impl FormattedValue) { unsafe { let ptr: *mut ffi::GstAggregator = self.as_ref().to_glib_none().0; let ptr = &mut *ptr; let _guard = self.as_ref().object_lock(); // gstaggregator.c asserts that the src pad is always of type GST_TYPE_AGGREGATOR_PAD, // so the pointer cast here should be safe. let srcpad = &mut *(ptr.srcpad as *mut ffi::GstAggregatorPad); assert_eq!(srcpad.segment.format, position.format().into_glib()); srcpad.segment.position = position.into_raw_value() as u64; } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_aggregator_selected_samples")] fn selected_samples( &self, pts: impl Into>, dts: impl Into>, duration: impl Into>, info: Option<&gst::StructureRef>, ) { unsafe { ffi::gst_aggregator_selected_samples( self.as_ref().to_glib_none().0, pts.into().into_glib(), dts.into().into_glib(), duration.into().into_glib(), info.as_ref() .map(|s| s.as_ptr() as *mut _) .unwrap_or(ptr::null_mut()), ); } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn connect_samples_selected< F: Fn( &Self, &gst::Segment, Option, Option, Option, Option<&gst::StructureRef>, ) + Send + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn samples_selected_trampoline< P, F: Fn( &P, &gst::Segment, Option, Option, Option, Option<&gst::StructureRef>, ) + Send + 'static, >( this: *mut ffi::GstAggregator, segment: *mut gst::ffi::GstSegment, pts: gst::ffi::GstClockTime, dts: gst::ffi::GstClockTime, duration: gst::ffi::GstClockTime, info: *mut gst::ffi::GstStructure, f: glib::ffi::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f( Aggregator::from_glib_borrow(this).unsafe_cast_ref(), gst::Segment::from_glib_ptr_borrow(segment), from_glib(pts), from_glib(dts), from_glib(duration), if info.is_null() { None } else { Some(gst::StructureRef::from_glib_borrow(info)) }, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"samples-selected\0".as_ptr() as *const _, Some(transmute::<*const (), unsafe extern "C" fn()>( samples_selected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn src_pad(&self) -> &AggregatorPad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstAggregator); &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const AggregatorPad) } } } impl> AggregatorExtManual for O {} #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] unsafe extern "C" fn notify_min_upstream_latency_trampoline( this: *mut ffi::GstAggregator, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); f(Aggregator::from_glib_borrow(this).unsafe_cast_ref()) } gstreamer-base-0.24.0/src/aggregator_pad.rs000064400000000000000000000037341046102023000167220ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*}; use gst::prelude::*; use crate::{ffi, AggregatorPad}; pub trait AggregatorPadExtManual: IsA + 'static { #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let ptr: &ffi::GstAggregatorPad = &*(self.as_ptr() as *const _); let _guard = self.as_ref().object_lock(); from_glib_none(&ptr.segment as *const gst::ffi::GstSegment) } } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "current-level-time")] fn current_level_time(&self) -> Option { ObjectExt::property(self.as_ref(), "current-level-time") } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "current-level-time")] fn connect_current_level_time_notify( &self, f: F, ) -> glib::SignalHandlerId { unsafe extern "C" fn notify_current_level_time_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregatorPad, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box = Box::new(f); glib::signal::connect_raw( self.as_ptr() as *mut _, c"notify::current-level-time".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_current_level_time_trampoline:: as *const (), )), Box::into_raw(f), ) } } } impl> AggregatorPadExtManual for O {} gstreamer-base-0.24.0/src/auto/adapter.rs000064400000000000000000000077351046102023000163510ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::translate::*; glib::wrapper! { #[doc(alias = "GstAdapter")] pub struct Adapter(Object); match fn { type_ => || ffi::gst_adapter_get_type(), } } impl Adapter { #[doc(alias = "gst_adapter_new")] pub fn new() -> Adapter { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gst_adapter_new()) } } #[doc(alias = "gst_adapter_available")] pub fn available(&self) -> usize { unsafe { ffi::gst_adapter_available(self.to_glib_none().0) } } #[doc(alias = "gst_adapter_available_fast")] pub fn available_fast(&self) -> usize { unsafe { ffi::gst_adapter_available_fast(self.to_glib_none().0) } } #[doc(alias = "gst_adapter_clear")] pub fn clear(&self) { unsafe { ffi::gst_adapter_clear(self.to_glib_none().0); } } #[doc(alias = "gst_adapter_distance_from_discont")] pub fn distance_from_discont(&self) -> u64 { unsafe { ffi::gst_adapter_distance_from_discont(self.to_glib_none().0) } } #[doc(alias = "gst_adapter_dts_at_discont")] pub fn dts_at_discont(&self) -> Option { unsafe { from_glib(ffi::gst_adapter_dts_at_discont(self.to_glib_none().0)) } } #[doc(alias = "gst_adapter_offset_at_discont")] pub fn offset_at_discont(&self) -> u64 { unsafe { ffi::gst_adapter_offset_at_discont(self.to_glib_none().0) } } #[doc(alias = "gst_adapter_prev_dts")] pub fn prev_dts(&self) -> (Option, u64) { unsafe { let mut distance = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_adapter_prev_dts( self.to_glib_none().0, distance.as_mut_ptr(), )); (ret, distance.assume_init()) } } #[doc(alias = "gst_adapter_prev_dts_at_offset")] pub fn prev_dts_at_offset(&self, offset: usize) -> (Option, u64) { unsafe { let mut distance = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_adapter_prev_dts_at_offset( self.to_glib_none().0, offset, distance.as_mut_ptr(), )); (ret, distance.assume_init()) } } #[doc(alias = "gst_adapter_prev_offset")] pub fn prev_offset(&self) -> (u64, u64) { unsafe { let mut distance = std::mem::MaybeUninit::uninit(); let ret = ffi::gst_adapter_prev_offset(self.to_glib_none().0, distance.as_mut_ptr()); (ret, distance.assume_init()) } } #[doc(alias = "gst_adapter_prev_pts")] pub fn prev_pts(&self) -> (Option, u64) { unsafe { let mut distance = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_adapter_prev_pts( self.to_glib_none().0, distance.as_mut_ptr(), )); (ret, distance.assume_init()) } } #[doc(alias = "gst_adapter_prev_pts_at_offset")] pub fn prev_pts_at_offset(&self, offset: usize) -> (Option, u64) { unsafe { let mut distance = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_adapter_prev_pts_at_offset( self.to_glib_none().0, offset, distance.as_mut_ptr(), )); (ret, distance.assume_init()) } } #[doc(alias = "gst_adapter_pts_at_discont")] pub fn pts_at_discont(&self) -> Option { unsafe { from_glib(ffi::gst_adapter_pts_at_discont(self.to_glib_none().0)) } } } impl Default for Adapter { fn default() -> Self { Self::new() } } gstreamer-base-0.24.0/src/auto/aggregator.rs000064400000000000000000000265761046102023000170570ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] use crate::{AggregatorPad, AggregatorStartTimeSelection}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GstAggregator")] pub struct Aggregator(Object) @extends gst::Element, gst::Object; match fn { type_ => || ffi::gst_aggregator_get_type(), } } impl Aggregator { pub const NONE: Option<&'static Aggregator> = None; } unsafe impl Send for Aggregator {} unsafe impl Sync for Aggregator {} pub trait AggregatorExt: IsA + 'static { #[doc(alias = "gst_aggregator_finish_buffer")] fn finish_buffer(&self, buffer: gst::Buffer) -> Result { unsafe { try_from_glib(ffi::gst_aggregator_finish_buffer( self.as_ref().to_glib_none().0, buffer.into_glib_ptr(), )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_aggregator_finish_buffer_list")] fn finish_buffer_list( &self, bufferlist: gst::BufferList, ) -> Result { unsafe { try_from_glib(ffi::gst_aggregator_finish_buffer_list( self.as_ref().to_glib_none().0, bufferlist.into_glib_ptr(), )) } } #[doc(alias = "gst_aggregator_get_buffer_pool")] #[doc(alias = "get_buffer_pool")] fn buffer_pool(&self) -> Option { unsafe { from_glib_full(ffi::gst_aggregator_get_buffer_pool( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_22")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] #[doc(alias = "gst_aggregator_get_force_live")] #[doc(alias = "get_force_live")] fn is_force_live(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_get_force_live( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_20")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_aggregator_get_ignore_inactive_pads")] #[doc(alias = "get_ignore_inactive_pads")] fn ignores_inactive_pads(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_get_ignore_inactive_pads( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_aggregator_get_latency")] #[doc(alias = "get_latency")] fn latency(&self) -> Option { unsafe { from_glib(ffi::gst_aggregator_get_latency( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_aggregator_negotiate")] fn negotiate(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_negotiate( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_aggregator_peek_next_sample")] fn peek_next_sample(&self, pad: &impl IsA) -> Option { unsafe { from_glib_full(ffi::gst_aggregator_peek_next_sample( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_26")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))] #[doc(alias = "gst_aggregator_push_src_event")] fn push_src_event(&self, event: gst::Event) -> bool { unsafe { from_glib(ffi::gst_aggregator_push_src_event( self.as_ref().to_glib_none().0, event.into_glib_ptr(), )) } } #[cfg(feature = "v1_22")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] #[doc(alias = "gst_aggregator_set_force_live")] fn set_force_live(&self, force_live: bool) { unsafe { ffi::gst_aggregator_set_force_live( self.as_ref().to_glib_none().0, force_live.into_glib(), ); } } #[cfg(feature = "v1_20")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_aggregator_set_ignore_inactive_pads")] fn set_ignore_inactive_pads(&self, ignore: bool) { unsafe { ffi::gst_aggregator_set_ignore_inactive_pads( self.as_ref().to_glib_none().0, ignore.into_glib(), ); } } #[doc(alias = "gst_aggregator_set_latency")] #[doc(alias = "latency")] fn set_latency( &self, min_latency: gst::ClockTime, max_latency: impl Into>, ) { unsafe { ffi::gst_aggregator_set_latency( self.as_ref().to_glib_none().0, min_latency.into_glib(), max_latency.into().into_glib(), ); } } #[doc(alias = "gst_aggregator_set_src_caps")] fn set_src_caps(&self, caps: &gst::Caps) { unsafe { ffi::gst_aggregator_set_src_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0); } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "gst_aggregator_simple_get_next_time")] fn simple_get_next_time(&self) -> Option { unsafe { from_glib(ffi::gst_aggregator_simple_get_next_time( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "emit-signals")] fn emits_signals(&self) -> bool { ObjectExt::property(self.as_ref(), "emit-signals") } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "emit-signals")] fn set_emit_signals(&self, emit_signals: bool) { ObjectExt::set_property(self.as_ref(), "emit-signals", emit_signals) } #[doc(alias = "start-time")] fn start_time(&self) -> u64 { ObjectExt::property(self.as_ref(), "start-time") } #[doc(alias = "start-time")] fn set_start_time(&self, start_time: u64) { ObjectExt::set_property(self.as_ref(), "start-time", start_time) } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "start-time-selection")] fn start_time_selection(&self) -> AggregatorStartTimeSelection { ObjectExt::property(self.as_ref(), "start-time-selection") } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "start-time-selection")] fn set_start_time_selection(&self, start_time_selection: AggregatorStartTimeSelection) { ObjectExt::set_property(self.as_ref(), "start-time-selection", start_time_selection) } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "emit-signals")] fn connect_emit_signals_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_emit_signals_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregator, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Aggregator::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::emit-signals".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_emit_signals_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "latency")] fn connect_latency_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_latency_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregator, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Aggregator::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::latency".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_latency_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "start-time")] fn connect_start_time_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_start_time_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregator, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Aggregator::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::start-time".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_start_time_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "start-time-selection")] fn connect_start_time_selection_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_start_time_selection_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregator, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Aggregator::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::start-time-selection".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_start_time_selection_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> AggregatorExt for O {} gstreamer-base-0.24.0/src/auto/aggregator_pad.rs000064400000000000000000000175111046102023000176700ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::{ object::ObjectType as _, prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GstAggregatorPad")] pub struct AggregatorPad(Object) @extends gst::Pad, gst::Object; match fn { type_ => || ffi::gst_aggregator_pad_get_type(), } } impl AggregatorPad { pub const NONE: Option<&'static AggregatorPad> = None; } unsafe impl Send for AggregatorPad {} unsafe impl Sync for AggregatorPad {} pub trait AggregatorPadExt: IsA + 'static { #[doc(alias = "gst_aggregator_pad_drop_buffer")] fn drop_buffer(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_pad_drop_buffer( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_14_1")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_14_1")))] #[doc(alias = "gst_aggregator_pad_has_buffer")] fn has_buffer(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_pad_has_buffer( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_aggregator_pad_is_eos")] fn is_eos(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_pad_is_eos( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_20")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_aggregator_pad_is_inactive")] fn is_inactive(&self) -> bool { unsafe { from_glib(ffi::gst_aggregator_pad_is_inactive( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_aggregator_pad_peek_buffer")] fn peek_buffer(&self) -> Option { unsafe { from_glib_full(ffi::gst_aggregator_pad_peek_buffer( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_aggregator_pad_pop_buffer")] fn pop_buffer(&self) -> Option { unsafe { from_glib_full(ffi::gst_aggregator_pad_pop_buffer( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "current-level-buffers")] fn current_level_buffers(&self) -> u64 { ObjectExt::property(self.as_ref(), "current-level-buffers") } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "current-level-bytes")] fn current_level_bytes(&self) -> u64 { ObjectExt::property(self.as_ref(), "current-level-bytes") } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "emit-signals")] fn emits_signals(&self) -> bool { ObjectExt::property(self.as_ref(), "emit-signals") } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "emit-signals")] fn set_emit_signals(&self, emit_signals: bool) { ObjectExt::set_property(self.as_ref(), "emit-signals", emit_signals) } #[doc(alias = "buffer-consumed")] fn connect_buffer_consumed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn buffer_consumed_trampoline< P: IsA, F: Fn(&P, &gst::Buffer) + Send + Sync + 'static, >( this: *mut ffi::GstAggregatorPad, object: *mut gst::ffi::GstBuffer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( AggregatorPad::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(object), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"buffer-consumed".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( buffer_consumed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "current-level-buffers")] fn connect_current_level_buffers_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_current_level_buffers_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregatorPad, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::current-level-buffers".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_current_level_buffers_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "current-level-bytes")] fn connect_current_level_bytes_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_current_level_bytes_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregatorPad, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::current-level-bytes".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_current_level_bytes_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "emit-signals")] fn connect_emit_signals_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_emit_signals_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstAggregatorPad, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::emit-signals".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_emit_signals_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> AggregatorPadExt for O {} gstreamer-base-0.24.0/src/auto/base_parse.rs000064400000000000000000000160761046102023000170330ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GstBaseParse")] pub struct BaseParse(Object) @extends gst::Element, gst::Object; match fn { type_ => || ffi::gst_base_parse_get_type(), } } impl BaseParse { pub const NONE: Option<&'static BaseParse> = None; } unsafe impl Send for BaseParse {} unsafe impl Sync for BaseParse {} pub trait BaseParseExt: IsA + 'static { #[doc(alias = "gst_base_parse_add_index_entry")] fn add_index_entry(&self, offset: u64, ts: gst::ClockTime, key: bool, force: bool) -> bool { unsafe { from_glib(ffi::gst_base_parse_add_index_entry( self.as_ref().to_glib_none().0, offset, ts.into_glib(), key.into_glib(), force.into_glib(), )) } } #[doc(alias = "gst_base_parse_drain")] fn drain(&self) { unsafe { ffi::gst_base_parse_drain(self.as_ref().to_glib_none().0); } } #[doc(alias = "gst_base_parse_merge_tags")] fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) { unsafe { ffi::gst_base_parse_merge_tags( self.as_ref().to_glib_none().0, tags.to_glib_none().0, mode.into_glib(), ); } } #[doc(alias = "gst_base_parse_set_average_bitrate")] fn set_average_bitrate(&self, bitrate: u32) { unsafe { ffi::gst_base_parse_set_average_bitrate(self.as_ref().to_glib_none().0, bitrate); } } #[doc(alias = "gst_base_parse_set_has_timing_info")] fn set_has_timing_info(&self, has_timing: bool) { unsafe { ffi::gst_base_parse_set_has_timing_info( self.as_ref().to_glib_none().0, has_timing.into_glib(), ); } } #[doc(alias = "gst_base_parse_set_infer_ts")] fn set_infer_ts(&self, infer_ts: bool) { unsafe { ffi::gst_base_parse_set_infer_ts(self.as_ref().to_glib_none().0, infer_ts.into_glib()); } } #[doc(alias = "gst_base_parse_set_latency")] fn set_latency( &self, min_latency: gst::ClockTime, max_latency: impl Into>, ) { unsafe { ffi::gst_base_parse_set_latency( self.as_ref().to_glib_none().0, min_latency.into_glib(), max_latency.into().into_glib(), ); } } #[doc(alias = "gst_base_parse_set_min_frame_size")] fn set_min_frame_size(&self, min_size: u32) { unsafe { ffi::gst_base_parse_set_min_frame_size(self.as_ref().to_glib_none().0, min_size); } } #[doc(alias = "gst_base_parse_set_passthrough")] fn set_passthrough(&self, passthrough: bool) { unsafe { ffi::gst_base_parse_set_passthrough( self.as_ref().to_glib_none().0, passthrough.into_glib(), ); } } #[doc(alias = "gst_base_parse_set_pts_interpolation")] fn set_pts_interpolation(&self, pts_interpolate: bool) { unsafe { ffi::gst_base_parse_set_pts_interpolation( self.as_ref().to_glib_none().0, pts_interpolate.into_glib(), ); } } #[doc(alias = "gst_base_parse_set_syncable")] fn set_syncable(&self, syncable: bool) { unsafe { ffi::gst_base_parse_set_syncable(self.as_ref().to_glib_none().0, syncable.into_glib()); } } #[doc(alias = "gst_base_parse_set_ts_at_offset")] fn set_ts_at_offset(&self, offset: usize) { unsafe { ffi::gst_base_parse_set_ts_at_offset(self.as_ref().to_glib_none().0, offset); } } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "disable-clip")] fn is_disable_clip(&self) -> bool { ObjectExt::property(self.as_ref(), "disable-clip") } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "disable-clip")] fn set_disable_clip(&self, disable_clip: bool) { ObjectExt::set_property(self.as_ref(), "disable-clip", disable_clip) } #[doc(alias = "disable-passthrough")] fn is_disable_passthrough(&self) -> bool { ObjectExt::property(self.as_ref(), "disable-passthrough") } #[doc(alias = "disable-passthrough")] fn set_disable_passthrough(&self, disable_passthrough: bool) { ObjectExt::set_property(self.as_ref(), "disable-passthrough", disable_passthrough) } #[cfg(feature = "v1_28")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))] #[doc(alias = "disable-clip")] fn connect_disable_clip_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_disable_clip_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseParse, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseParse::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::disable-clip".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_disable_clip_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "disable-passthrough")] fn connect_disable_passthrough_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_disable_passthrough_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseParse, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseParse::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::disable-passthrough".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_disable_passthrough_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> BaseParseExt for O {} gstreamer-base-0.24.0/src/auto/base_sink.rs000064400000000000000000000535651046102023000166710ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GstBaseSink")] pub struct BaseSink(Object) @extends gst::Element, gst::Object; match fn { type_ => || ffi::gst_base_sink_get_type(), } } impl BaseSink { pub const NONE: Option<&'static BaseSink> = None; } unsafe impl Send for BaseSink {} unsafe impl Sync for BaseSink {} pub trait BaseSinkExt: IsA + 'static { //#[doc(alias = "gst_base_sink_do_preroll")] //fn do_preroll(&self, obj: /*Ignored*/&gst::MiniObject) -> Result { // unsafe { TODO: call ffi:gst_base_sink_do_preroll() } //} #[doc(alias = "gst_base_sink_get_blocksize")] #[doc(alias = "get_blocksize")] fn blocksize(&self) -> u32 { unsafe { ffi::gst_base_sink_get_blocksize(self.as_ref().to_glib_none().0) } } #[doc(alias = "gst_base_sink_get_drop_out_of_segment")] #[doc(alias = "get_drop_out_of_segment")] fn drops_out_of_segment(&self) -> bool { unsafe { from_glib(ffi::gst_base_sink_get_drop_out_of_segment( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_sink_get_last_sample")] #[doc(alias = "get_last_sample")] #[doc(alias = "last-sample")] fn last_sample(&self) -> Option { unsafe { from_glib_full(ffi::gst_base_sink_get_last_sample( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_sink_get_latency")] #[doc(alias = "get_latency")] fn latency(&self) -> gst::ClockTime { unsafe { try_from_glib(ffi::gst_base_sink_get_latency( self.as_ref().to_glib_none().0, )) .expect("mandatory glib value is None") } } #[doc(alias = "gst_base_sink_get_max_bitrate")] #[doc(alias = "get_max_bitrate")] #[doc(alias = "max-bitrate")] fn max_bitrate(&self) -> u64 { unsafe { ffi::gst_base_sink_get_max_bitrate(self.as_ref().to_glib_none().0) } } #[doc(alias = "gst_base_sink_get_max_lateness")] #[doc(alias = "get_max_lateness")] #[doc(alias = "max-lateness")] fn max_lateness(&self) -> i64 { unsafe { ffi::gst_base_sink_get_max_lateness(self.as_ref().to_glib_none().0) } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "gst_base_sink_get_processing_deadline")] #[doc(alias = "get_processing_deadline")] #[doc(alias = "processing-deadline")] fn processing_deadline(&self) -> gst::ClockTime { unsafe { try_from_glib(ffi::gst_base_sink_get_processing_deadline( self.as_ref().to_glib_none().0, )) .expect("mandatory glib value is None") } } #[doc(alias = "gst_base_sink_get_render_delay")] #[doc(alias = "get_render_delay")] #[doc(alias = "render-delay")] fn render_delay(&self) -> gst::ClockTime { unsafe { try_from_glib(ffi::gst_base_sink_get_render_delay( self.as_ref().to_glib_none().0, )) .expect("mandatory glib value is None") } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_base_sink_get_stats")] #[doc(alias = "get_stats")] fn stats(&self) -> gst::Structure { unsafe { from_glib_full(ffi::gst_base_sink_get_stats(self.as_ref().to_glib_none().0)) } } #[doc(alias = "gst_base_sink_get_sync")] #[doc(alias = "get_sync")] #[doc(alias = "sync")] fn is_sync(&self) -> bool { unsafe { from_glib(ffi::gst_base_sink_get_sync(self.as_ref().to_glib_none().0)) } } #[doc(alias = "gst_base_sink_get_throttle_time")] #[doc(alias = "get_throttle_time")] #[doc(alias = "throttle-time")] fn throttle_time(&self) -> u64 { unsafe { ffi::gst_base_sink_get_throttle_time(self.as_ref().to_glib_none().0) } } #[doc(alias = "gst_base_sink_get_ts_offset")] #[doc(alias = "get_ts_offset")] #[doc(alias = "ts-offset")] fn ts_offset(&self) -> gst::ClockTimeDiff { unsafe { ffi::gst_base_sink_get_ts_offset(self.as_ref().to_glib_none().0) } } #[doc(alias = "gst_base_sink_set_blocksize")] #[doc(alias = "blocksize")] fn set_blocksize(&self, blocksize: u32) { unsafe { ffi::gst_base_sink_set_blocksize(self.as_ref().to_glib_none().0, blocksize); } } #[doc(alias = "gst_base_sink_set_drop_out_of_segment")] fn set_drop_out_of_segment(&self, drop_out_of_segment: bool) { unsafe { ffi::gst_base_sink_set_drop_out_of_segment( self.as_ref().to_glib_none().0, drop_out_of_segment.into_glib(), ); } } #[doc(alias = "gst_base_sink_set_max_bitrate")] #[doc(alias = "max-bitrate")] fn set_max_bitrate(&self, max_bitrate: u64) { unsafe { ffi::gst_base_sink_set_max_bitrate(self.as_ref().to_glib_none().0, max_bitrate); } } #[doc(alias = "gst_base_sink_set_max_lateness")] #[doc(alias = "max-lateness")] fn set_max_lateness(&self, max_lateness: i64) { unsafe { ffi::gst_base_sink_set_max_lateness(self.as_ref().to_glib_none().0, max_lateness); } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "gst_base_sink_set_processing_deadline")] #[doc(alias = "processing-deadline")] fn set_processing_deadline(&self, processing_deadline: gst::ClockTime) { unsafe { ffi::gst_base_sink_set_processing_deadline( self.as_ref().to_glib_none().0, processing_deadline.into_glib(), ); } } #[doc(alias = "gst_base_sink_set_render_delay")] #[doc(alias = "render-delay")] fn set_render_delay(&self, delay: gst::ClockTime) { unsafe { ffi::gst_base_sink_set_render_delay(self.as_ref().to_glib_none().0, delay.into_glib()); } } #[doc(alias = "gst_base_sink_set_sync")] #[doc(alias = "sync")] fn set_sync(&self, sync: bool) { unsafe { ffi::gst_base_sink_set_sync(self.as_ref().to_glib_none().0, sync.into_glib()); } } #[doc(alias = "gst_base_sink_set_throttle_time")] #[doc(alias = "throttle-time")] fn set_throttle_time(&self, throttle: u64) { unsafe { ffi::gst_base_sink_set_throttle_time(self.as_ref().to_glib_none().0, throttle); } } #[doc(alias = "gst_base_sink_set_ts_offset")] #[doc(alias = "ts-offset")] fn set_ts_offset(&self, offset: gst::ClockTimeDiff) { unsafe { ffi::gst_base_sink_set_ts_offset(self.as_ref().to_glib_none().0, offset); } } #[doc(alias = "gst_base_sink_wait")] fn wait( &self, time: impl Into>, ) -> (Result, gst::ClockTimeDiff) { unsafe { let mut jitter = std::mem::MaybeUninit::uninit(); let ret = try_from_glib(ffi::gst_base_sink_wait( self.as_ref().to_glib_none().0, time.into().into_glib(), jitter.as_mut_ptr(), )); (ret, jitter.assume_init()) } } #[doc(alias = "gst_base_sink_wait_clock")] fn wait_clock( &self, time: gst::ClockTime, ) -> ( Result, gst::ClockTimeDiff, ) { unsafe { let mut jitter = std::mem::MaybeUninit::uninit(); let ret = try_from_glib(ffi::gst_base_sink_wait_clock( self.as_ref().to_glib_none().0, time.into_glib(), jitter.as_mut_ptr(), )); (ret, jitter.assume_init()) } } #[doc(alias = "gst_base_sink_wait_preroll")] fn wait_preroll(&self) -> Result { unsafe { try_from_glib(ffi::gst_base_sink_wait_preroll( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "async")] fn is_async(&self) -> bool { ObjectExt::property(self.as_ref(), "async") } #[doc(alias = "async")] fn set_async(&self, async_: bool) { ObjectExt::set_property(self.as_ref(), "async", async_) } #[doc(alias = "enable-last-sample")] fn enables_last_sample(&self) -> bool { ObjectExt::property(self.as_ref(), "enable-last-sample") } #[doc(alias = "enable-last-sample")] fn set_enable_last_sample(&self, enable_last_sample: bool) { ObjectExt::set_property(self.as_ref(), "enable-last-sample", enable_last_sample) } fn is_qos(&self) -> bool { ObjectExt::property(self.as_ref(), "qos") } fn set_qos(&self, qos: bool) { ObjectExt::set_property(self.as_ref(), "qos", qos) } #[doc(alias = "async")] fn connect_async_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_async_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::async".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_async_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "blocksize")] fn connect_blocksize_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_blocksize_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::blocksize".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_blocksize_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "enable-last-sample")] fn connect_enable_last_sample_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_enable_last_sample_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::enable-last-sample".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_enable_last_sample_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "last-sample")] fn connect_last_sample_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_last_sample_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::last-sample".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_last_sample_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "max-bitrate")] fn connect_max_bitrate_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_max_bitrate_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::max-bitrate".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_bitrate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "max-lateness")] fn connect_max_lateness_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_max_lateness_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::max-lateness".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_max_lateness_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "processing-deadline")] fn connect_processing_deadline_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_processing_deadline_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::processing-deadline".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_processing_deadline_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "qos")] fn connect_qos_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_qos_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::qos".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_qos_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "render-delay")] fn connect_render_delay_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_render_delay_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::render-delay".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_render_delay_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "stats")] fn connect_stats_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_stats_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::stats".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_stats_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "sync")] fn connect_sync_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_sync_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::sync".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_sync_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "throttle-time")] fn connect_throttle_time_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_throttle_time_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::throttle-time".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_throttle_time_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "ts-offset")] fn connect_ts_offset_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_ts_offset_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSink, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSink::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::ts-offset".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_ts_offset_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> BaseSinkExt for O {} gstreamer-base-0.24.0/src/auto/base_src.rs000064400000000000000000000300171046102023000164770ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT #![allow(deprecated)] use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GstBaseSrc")] pub struct BaseSrc(Object) @extends gst::Element, gst::Object; match fn { type_ => || ffi::gst_base_src_get_type(), } } impl BaseSrc { pub const NONE: Option<&'static BaseSrc> = None; } unsafe impl Send for BaseSrc {} unsafe impl Sync for BaseSrc {} pub trait BaseSrcExt: IsA + 'static { #[doc(alias = "gst_base_src_get_blocksize")] #[doc(alias = "get_blocksize")] fn blocksize(&self) -> u32 { unsafe { ffi::gst_base_src_get_blocksize(self.as_ref().to_glib_none().0) } } #[doc(alias = "gst_base_src_get_buffer_pool")] #[doc(alias = "get_buffer_pool")] fn buffer_pool(&self) -> Option { unsafe { from_glib_full(ffi::gst_base_src_get_buffer_pool( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_src_get_do_timestamp")] #[doc(alias = "get_do_timestamp")] #[doc(alias = "do-timestamp")] fn does_timestamp(&self) -> bool { unsafe { from_glib(ffi::gst_base_src_get_do_timestamp( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_src_is_async")] fn is_async(&self) -> bool { unsafe { from_glib(ffi::gst_base_src_is_async(self.as_ref().to_glib_none().0)) } } #[doc(alias = "gst_base_src_is_live")] fn is_live(&self) -> bool { unsafe { from_glib(ffi::gst_base_src_is_live(self.as_ref().to_glib_none().0)) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_base_src_negotiate")] fn negotiate(&self) -> bool { unsafe { from_glib(ffi::gst_base_src_negotiate(self.as_ref().to_glib_none().0)) } } #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")] #[allow(deprecated)] #[doc(alias = "gst_base_src_new_seamless_segment")] fn new_seamless_segment(&self, start: i64, stop: i64, time: i64) -> bool { unsafe { from_glib(ffi::gst_base_src_new_seamless_segment( self.as_ref().to_glib_none().0, start, stop, time, )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_base_src_new_segment")] fn new_segment(&self, segment: &gst::Segment) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_base_src_new_segment( self.as_ref().to_glib_none().0, segment.to_glib_none().0 ), "Failed to update segment" ) } } #[cfg(feature = "v1_24")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] #[doc(alias = "gst_base_src_push_segment")] fn push_segment(&self, segment: &gst::Segment) -> bool { unsafe { from_glib(ffi::gst_base_src_push_segment( self.as_ref().to_glib_none().0, segment.to_glib_none().0, )) } } #[doc(alias = "gst_base_src_set_async")] fn set_async(&self, async_: bool) { unsafe { ffi::gst_base_src_set_async(self.as_ref().to_glib_none().0, async_.into_glib()); } } #[doc(alias = "gst_base_src_set_automatic_eos")] #[doc(alias = "automatic-eos")] fn set_automatic_eos(&self, automatic_eos: bool) { unsafe { ffi::gst_base_src_set_automatic_eos( self.as_ref().to_glib_none().0, automatic_eos.into_glib(), ); } } #[doc(alias = "gst_base_src_set_blocksize")] #[doc(alias = "blocksize")] fn set_blocksize(&self, blocksize: u32) { unsafe { ffi::gst_base_src_set_blocksize(self.as_ref().to_glib_none().0, blocksize); } } #[doc(alias = "gst_base_src_set_caps")] fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_base_src_set_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0), "Failed to set caps" ) } } #[doc(alias = "gst_base_src_set_do_timestamp")] #[doc(alias = "do-timestamp")] fn set_do_timestamp(&self, timestamp: bool) { unsafe { ffi::gst_base_src_set_do_timestamp( self.as_ref().to_glib_none().0, timestamp.into_glib(), ); } } #[doc(alias = "gst_base_src_set_dynamic_size")] fn set_dynamic_size(&self, dynamic: bool) { unsafe { ffi::gst_base_src_set_dynamic_size(self.as_ref().to_glib_none().0, dynamic.into_glib()); } } #[doc(alias = "gst_base_src_set_format")] fn set_format(&self, format: gst::Format) { unsafe { ffi::gst_base_src_set_format(self.as_ref().to_glib_none().0, format.into_glib()); } } #[doc(alias = "gst_base_src_set_live")] fn set_live(&self, live: bool) { unsafe { ffi::gst_base_src_set_live(self.as_ref().to_glib_none().0, live.into_glib()); } } #[doc(alias = "gst_base_src_start_complete")] fn start_complete(&self, ret: impl Into) { unsafe { ffi::gst_base_src_start_complete( self.as_ref().to_glib_none().0, ret.into().into_glib(), ); } } #[doc(alias = "gst_base_src_start_wait")] fn start_wait(&self) -> Result { unsafe { try_from_glib(ffi::gst_base_src_start_wait(self.as_ref().to_glib_none().0)) } } #[doc(alias = "gst_base_src_wait_playing")] fn wait_playing(&self) -> Result { unsafe { try_from_glib(ffi::gst_base_src_wait_playing( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_24")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] #[doc(alias = "automatic-eos")] fn is_automatic_eos(&self) -> bool { ObjectExt::property(self.as_ref(), "automatic-eos") } #[doc(alias = "num-buffers")] fn num_buffers(&self) -> i32 { ObjectExt::property(self.as_ref(), "num-buffers") } #[doc(alias = "num-buffers")] fn set_num_buffers(&self, num_buffers: i32) { ObjectExt::set_property(self.as_ref(), "num-buffers", num_buffers) } fn is_typefind(&self) -> bool { ObjectExt::property(self.as_ref(), "typefind") } fn set_typefind(&self, typefind: bool) { ObjectExt::set_property(self.as_ref(), "typefind", typefind) } #[cfg(feature = "v1_24")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] #[doc(alias = "automatic-eos")] fn connect_automatic_eos_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_automatic_eos_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSrc, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::automatic-eos".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_automatic_eos_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "blocksize")] fn connect_blocksize_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_blocksize_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSrc, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::blocksize".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_blocksize_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "do-timestamp")] fn connect_do_timestamp_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_do_timestamp_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSrc, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::do-timestamp".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_do_timestamp_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "num-buffers")] fn connect_num_buffers_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_num_buffers_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSrc, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::num-buffers".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_num_buffers_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "typefind")] fn connect_typefind_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_typefind_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseSrc, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::typefind".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_typefind_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> BaseSrcExt for O {} gstreamer-base-0.24.0/src/auto/base_transform.rs000064400000000000000000000130121046102023000177170ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GstBaseTransform")] pub struct BaseTransform(Object) @extends gst::Element, gst::Object; match fn { type_ => || ffi::gst_base_transform_get_type(), } } impl BaseTransform { pub const NONE: Option<&'static BaseTransform> = None; } unsafe impl Send for BaseTransform {} unsafe impl Sync for BaseTransform {} pub trait BaseTransformExt: IsA + 'static { #[doc(alias = "gst_base_transform_get_buffer_pool")] #[doc(alias = "get_buffer_pool")] fn buffer_pool(&self) -> Option { unsafe { from_glib_full(ffi::gst_base_transform_get_buffer_pool( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_transform_is_in_place")] fn is_in_place(&self) -> bool { unsafe { from_glib(ffi::gst_base_transform_is_in_place( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_transform_is_passthrough")] fn is_passthrough(&self) -> bool { unsafe { from_glib(ffi::gst_base_transform_is_passthrough( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_base_transform_reconfigure")] fn reconfigure(&self) -> bool { unsafe { from_glib(ffi::gst_base_transform_reconfigure( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "gst_base_transform_reconfigure_sink")] fn reconfigure_sink(&self) { unsafe { ffi::gst_base_transform_reconfigure_sink(self.as_ref().to_glib_none().0); } } #[doc(alias = "gst_base_transform_reconfigure_src")] fn reconfigure_src(&self) { unsafe { ffi::gst_base_transform_reconfigure_src(self.as_ref().to_glib_none().0); } } #[doc(alias = "gst_base_transform_set_gap_aware")] fn set_gap_aware(&self, gap_aware: bool) { unsafe { ffi::gst_base_transform_set_gap_aware( self.as_ref().to_glib_none().0, gap_aware.into_glib(), ); } } #[doc(alias = "gst_base_transform_set_in_place")] fn set_in_place(&self, in_place: bool) { unsafe { ffi::gst_base_transform_set_in_place( self.as_ref().to_glib_none().0, in_place.into_glib(), ); } } #[doc(alias = "gst_base_transform_set_passthrough")] fn set_passthrough(&self, passthrough: bool) { unsafe { ffi::gst_base_transform_set_passthrough( self.as_ref().to_glib_none().0, passthrough.into_glib(), ); } } #[doc(alias = "gst_base_transform_set_prefer_passthrough")] fn set_prefer_passthrough(&self, prefer_passthrough: bool) { unsafe { ffi::gst_base_transform_set_prefer_passthrough( self.as_ref().to_glib_none().0, prefer_passthrough.into_glib(), ); } } #[doc(alias = "gst_base_transform_update_qos")] fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime) { unsafe { ffi::gst_base_transform_update_qos( self.as_ref().to_glib_none().0, proportion, diff, timestamp.into_glib(), ); } } #[doc(alias = "gst_base_transform_update_src_caps")] fn update_src_caps(&self, updated_caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_base_transform_update_src_caps( self.as_ref().to_glib_none().0, updated_caps.to_glib_none().0 ), "Failed to update src caps" ) } } fn is_qos(&self) -> bool { ObjectExt::property(self.as_ref(), "qos") } fn set_qos(&self, qos: bool) { ObjectExt::set_property(self.as_ref(), "qos", qos) } #[doc(alias = "qos")] fn connect_qos_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_qos_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseTransform, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BaseTransform::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, c"notify::qos".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_qos_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> BaseTransformExt for O {} gstreamer-base-0.24.0/src/auto/enums.rs000064400000000000000000000100021046102023000160350ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] use glib::{prelude::*, translate::*}; #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GstAggregatorStartTimeSelection")] pub enum AggregatorStartTimeSelection { #[doc(alias = "GST_AGGREGATOR_START_TIME_SELECTION_ZERO")] Zero, #[doc(alias = "GST_AGGREGATOR_START_TIME_SELECTION_FIRST")] First, #[doc(alias = "GST_AGGREGATOR_START_TIME_SELECTION_SET")] Set, #[doc(hidden)] __Unknown(i32), } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(hidden)] impl IntoGlib for AggregatorStartTimeSelection { type GlibType = ffi::GstAggregatorStartTimeSelection; #[inline] fn into_glib(self) -> ffi::GstAggregatorStartTimeSelection { match self { Self::Zero => ffi::GST_AGGREGATOR_START_TIME_SELECTION_ZERO, Self::First => ffi::GST_AGGREGATOR_START_TIME_SELECTION_FIRST, Self::Set => ffi::GST_AGGREGATOR_START_TIME_SELECTION_SET, Self::__Unknown(value) => value, } } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] #[doc(hidden)] impl FromGlib for AggregatorStartTimeSelection { #[inline] unsafe fn from_glib(value: ffi::GstAggregatorStartTimeSelection) -> Self { skip_assert_initialized!(); match value { ffi::GST_AGGREGATOR_START_TIME_SELECTION_ZERO => Self::Zero, ffi::GST_AGGREGATOR_START_TIME_SELECTION_FIRST => Self::First, ffi::GST_AGGREGATOR_START_TIME_SELECTION_SET => Self::Set, value => Self::__Unknown(value), } } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] impl StaticType for AggregatorStartTimeSelection { #[inline] #[doc(alias = "gst_aggregator_start_time_selection_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::gst_aggregator_start_time_selection_get_type()) } } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] impl glib::HasParamSpec for AggregatorStartTimeSelection { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] impl glib::value::ValueType for AggregatorStartTimeSelection { type Type = Self; } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] unsafe impl<'a> glib::value::FromValue<'a> for AggregatorStartTimeSelection { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { skip_assert_initialized!(); from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] impl ToValue for AggregatorStartTimeSelection { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] impl From for glib::Value { #[inline] fn from(v: AggregatorStartTimeSelection) -> Self { skip_assert_initialized!(); ToValue::to_value(&v) } } gstreamer-base-0.24.0/src/auto/flags.rs000064400000000000000000000027741046102023000160230ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::{bitflags::bitflags, translate::*}; bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GstBaseParseFrameFlags")] pub struct BaseParseFrameFlags: u32 { #[doc(alias = "GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME")] const NEW_FRAME = ffi::GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME as _; #[doc(alias = "GST_BASE_PARSE_FRAME_FLAG_NO_FRAME")] const NO_FRAME = ffi::GST_BASE_PARSE_FRAME_FLAG_NO_FRAME as _; #[doc(alias = "GST_BASE_PARSE_FRAME_FLAG_CLIP")] const CLIP = ffi::GST_BASE_PARSE_FRAME_FLAG_CLIP as _; #[doc(alias = "GST_BASE_PARSE_FRAME_FLAG_DROP")] const DROP = ffi::GST_BASE_PARSE_FRAME_FLAG_DROP as _; #[doc(alias = "GST_BASE_PARSE_FRAME_FLAG_QUEUE")] const QUEUE = ffi::GST_BASE_PARSE_FRAME_FLAG_QUEUE as _; } } #[doc(hidden)] impl IntoGlib for BaseParseFrameFlags { type GlibType = ffi::GstBaseParseFrameFlags; #[inline] fn into_glib(self) -> ffi::GstBaseParseFrameFlags { self.bits() } } #[doc(hidden)] impl FromGlib for BaseParseFrameFlags { #[inline] unsafe fn from_glib(value: ffi::GstBaseParseFrameFlags) -> Self { skip_assert_initialized!(); Self::from_bits_truncate(value) } } gstreamer-base-0.24.0/src/auto/functions.rs000064400000000000000000000041531046102023000167300ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::ffi; use glib::{prelude::*, translate::*}; #[doc(alias = "gst_type_find_helper")] pub fn type_find_helper(src: &impl IsA, size: u64) -> Result { assert_initialized_main_thread!(); unsafe { Option::<_>::from_glib_full(ffi::gst_type_find_helper( src.as_ref().to_glib_none().0, size, )) .ok_or_else(|| glib::bool_error!("Could not find type")) } } #[doc(alias = "gst_type_find_helper_for_extension")] pub fn type_find_helper_for_extension( obj: Option<&impl IsA>, extension: &str, ) -> Result { assert_initialized_main_thread!(); unsafe { Option::<_>::from_glib_full(ffi::gst_type_find_helper_for_extension( obj.map(|p| p.as_ref()).to_glib_none().0, extension.to_glib_none().0, )) .ok_or_else(|| glib::bool_error!("Could not find type")) } } //#[doc(alias = "gst_type_find_helper_get_range")] //pub fn type_find_helper_get_range, u64, u32) -> Result>(obj: &impl IsA, parent: Option<&impl IsA>, func: P, size: u64, extension: Option<&str>) -> (Option, gst::TypeFindProbability) { // unsafe { TODO: call ffi:gst_type_find_helper_get_range() } //} //#[cfg(feature = "v1_14_3")] //#[cfg_attr(docsrs, doc(cfg(feature = "v1_14_3")))] //#[doc(alias = "gst_type_find_helper_get_range_full")] //pub fn type_find_helper_get_range_full, u64, u32) -> Result>(obj: &impl IsA, parent: Option<&impl IsA>, func: P, size: u64, extension: Option<&str>) -> (Result, gst::Caps, gst::TypeFindProbability) { // unsafe { TODO: call ffi:gst_type_find_helper_get_range_full() } //} gstreamer-base-0.24.0/src/auto/mod.rs000064400000000000000000000022341046102023000154750ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT mod adapter; pub use self::adapter::Adapter; mod aggregator; pub use self::aggregator::Aggregator; mod aggregator_pad; pub use self::aggregator_pad::AggregatorPad; mod base_parse; pub use self::base_parse::BaseParse; mod base_sink; pub use self::base_sink::BaseSink; mod base_src; pub use self::base_src::BaseSrc; mod base_transform; pub use self::base_transform::BaseTransform; mod push_src; pub use self::push_src::PushSrc; mod enums; #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] pub use self::enums::AggregatorStartTimeSelection; mod flags; pub use self::flags::BaseParseFrameFlags; pub(crate) mod functions; pub(crate) mod traits { pub use super::aggregator::AggregatorExt; pub use super::aggregator_pad::AggregatorPadExt; pub use super::base_parse::BaseParseExt; pub use super::base_sink::BaseSinkExt; pub use super::base_src::BaseSrcExt; pub use super::base_transform::BaseTransformExt; } gstreamer-base-0.24.0/src/auto/push_src.rs000064400000000000000000000011571046102023000165470ustar 00000000000000// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::{ffi, BaseSrc}; glib::wrapper! { #[doc(alias = "GstPushSrc")] pub struct PushSrc(Object) @extends BaseSrc, gst::Element, gst::Object; match fn { type_ => || ffi::gst_push_src_get_type(), } } impl PushSrc { pub const NONE: Option<&'static PushSrc> = None; } unsafe impl Send for PushSrc {} unsafe impl Sync for PushSrc {} gstreamer-base-0.24.0/src/auto/versions.txt000064400000000000000000000003421046102023000167570ustar 00000000000000Generated by gir (https://github.com/gtk-rs/gir @ 19ccbbc9a3d1) from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a) from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ fddf588f73ea) gstreamer-base-0.24.0/src/base_parse.rs000064400000000000000000000110241046102023000160470ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::mem; use glib::{prelude::*, translate::*}; use gst::{ format::{FormattedValue, SpecificFormattedValueFullRange}, prelude::*, }; use crate::{ffi, BaseParse, BaseParseFrame}; pub trait BaseParseExtManual: IsA + 'static { #[doc(alias = "get_sink_pad")] fn sink_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseParse); &*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad) } } #[doc(alias = "get_src_pad")] fn src_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseParse); &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad) } } fn segment(&self) -> gst::Segment { unsafe { let ptr: &ffi::GstBaseParse = &*(self.as_ptr() as *const _); let sinkpad = self.sink_pad(); let _guard = sinkpad.stream_lock(); from_glib_none(&ptr.segment as *const gst::ffi::GstSegment) } } fn lost_sync(&self) -> bool { unsafe { let ptr: &ffi::GstBaseParse = &*(self.as_ptr() as *const _); let sinkpad = self.sink_pad(); let _guard = sinkpad.stream_lock(); ptr.flags & ffi::GST_BASE_PARSE_FLAG_LOST_SYNC as u32 != 0 } } fn is_draining(&self) -> bool { unsafe { let ptr: &ffi::GstBaseParse = &*(self.as_ptr() as *const _); let sinkpad = self.sink_pad(); let _guard = sinkpad.stream_lock(); ptr.flags & ffi::GST_BASE_PARSE_FLAG_DRAINING as u32 != 0 } } #[doc(alias = "gst_base_parse_set_duration")] fn set_duration(&self, duration: impl FormattedValue, interval: u32) { unsafe { ffi::gst_base_parse_set_duration( self.as_ref().to_glib_none().0, duration.format().into_glib(), duration.into_raw_value(), interval as i32, ); } } #[doc(alias = "gst_base_parse_set_frame_rate")] fn set_frame_rate(&self, fps: gst::Fraction, lead_in: u32, lead_out: u32) { let (fps_num, fps_den) = fps.into(); unsafe { ffi::gst_base_parse_set_frame_rate( self.as_ref().to_glib_none().0, fps_num as u32, fps_den as u32, lead_in, lead_out, ); } } #[doc(alias = "gst_base_parse_convert_default")] fn convert_default( &self, src_val: impl FormattedValue, ) -> Option { unsafe { let mut dest_val = mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_base_parse_convert_default( self.as_ref().to_glib_none().0, src_val.format().into_glib(), src_val.into_raw_value(), U::default_format().into_glib(), dest_val.as_mut_ptr(), )); if ret { Some(U::from_raw(U::default_format(), dest_val.assume_init())) } else { None } } } fn convert_default_generic( &self, src_val: impl FormattedValue, dest_format: gst::Format, ) -> Option { unsafe { let mut dest_val = mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_base_parse_convert_default( self.as_ref().to_glib_none().0, src_val.format().into_glib(), src_val.into_raw_value(), dest_format.into_glib(), dest_val.as_mut_ptr(), )); if ret { Some(gst::GenericFormattedValue::new( dest_format, dest_val.assume_init(), )) } else { None } } } #[doc(alias = "gst_base_parse_finish_frame")] fn finish_frame( &self, frame: BaseParseFrame, size: u32, ) -> Result { unsafe { try_from_glib(ffi::gst_base_parse_finish_frame( self.as_ref().to_glib_none().0, frame.to_glib_none().0, i32::try_from(size).expect("size higher than i32::MAX"), )) } } } impl> BaseParseExtManual for O {} gstreamer-base-0.24.0/src/base_parse_frame.rs000064400000000000000000000124661046102023000172340ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{fmt, marker::PhantomData, ptr}; use glib::translate::*; use crate::{ffi, BaseParse, BaseParseFrameFlags}; pub struct BaseParseFrame<'a>( ptr::NonNull, PhantomData<&'a BaseParse>, ); unsafe impl Send for BaseParseFrame<'_> {} unsafe impl Sync for BaseParseFrame<'_> {} #[derive(Debug)] pub enum Overhead { None, Frame, Bytes(u32), } #[doc(hidden)] impl IntoGlib for Overhead { type GlibType = i32; #[inline] fn into_glib(self) -> i32 { match self { Self::None => 0, Self::Frame => -1, Self::Bytes(b) => i32::try_from(b).expect("overhead is higher than i32::MAX"), } } } impl FromGlib for Overhead { #[inline] unsafe fn from_glib(val: i32) -> Self { skip_assert_initialized!(); match val { 0 => Self::None, 1 => Self::Frame, b if b > 0 => Self::Bytes(val as u32), _ => panic!("overheader is lower than -1"), } } } #[doc(hidden)] impl<'a> ::glib::translate::ToGlibPtr<'a, *mut ffi::GstBaseParseFrame> for BaseParseFrame<'a> { type Storage = PhantomData<&'a Self>; #[inline] fn to_glib_none(&'a self) -> ::glib::translate::Stash<'a, *mut ffi::GstBaseParseFrame, Self> { Stash(self.0.as_ptr(), PhantomData) } fn to_glib_full(&self) -> *mut ffi::GstBaseParseFrame { unimplemented!() } } impl fmt::Debug for BaseParseFrame<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut b = f.debug_struct("BaseParseFrame"); b.field("buffer", &self.buffer()) .field("output_buffer", &self.output_buffer()) .field("flags", &self.flags()) .field("offset", &self.offset()) .field("overhead", &self.overhead()); b.finish() } } impl<'a> BaseParseFrame<'a> { #[inline] pub(crate) unsafe fn new(frame: *mut ffi::GstBaseParseFrame, _parse: &'a BaseParse) -> Self { skip_assert_initialized!(); debug_assert!(!frame.is_null()); Self(ptr::NonNull::new_unchecked(frame), PhantomData) } #[doc(alias = "get_buffer")] #[inline] pub fn buffer(&self) -> Option<&gst::BufferRef> { unsafe { let ptr = (*self.to_glib_none().0).buffer; if ptr.is_null() { None } else { Some(gst::BufferRef::from_ptr(ptr)) } } } #[doc(alias = "get_buffer_mut")] pub fn buffer_mut(&mut self) -> Option<&mut gst::BufferRef> { unsafe { let ptr = (*self.to_glib_none().0).buffer; if ptr.is_null() { None } else { let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( ptr as *const gst::ffi::GstMiniObject, )); assert!(writable); Some(gst::BufferRef::from_mut_ptr(ptr)) } } } #[doc(alias = "get_output_buffer")] #[inline] pub fn output_buffer(&self) -> Option<&gst::BufferRef> { unsafe { let ptr = (*self.to_glib_none().0).out_buffer; if ptr.is_null() { None } else { Some(gst::BufferRef::from_ptr(ptr)) } } } #[doc(alias = "get_output_buffer_mut")] pub fn output_buffer_mut(&mut self) -> Option<&mut gst::BufferRef> { unsafe { let ptr = (*self.to_glib_none().0).out_buffer; if ptr.is_null() { None } else { let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( ptr as *const gst::ffi::GstMiniObject, )); assert!(writable); Some(gst::BufferRef::from_mut_ptr(ptr)) } } } pub fn set_output_buffer(&mut self, output_buffer: gst::Buffer) { unsafe { assert!(output_buffer.is_writable()); let prev = (*self.to_glib_none().0).out_buffer; if !prev.is_null() { gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); } (*self.to_glib_none().0).out_buffer = output_buffer.into_glib_ptr(); } } #[doc(alias = "get_flags")] #[inline] pub fn flags(&self) -> BaseParseFrameFlags { let flags = unsafe { (*self.to_glib_none().0).flags }; BaseParseFrameFlags::from_bits_truncate(flags) } #[inline] pub fn set_flags(&mut self, flags: BaseParseFrameFlags) { unsafe { (*self.to_glib_none().0).flags |= flags.bits() } } #[inline] pub fn unset_flags(&mut self, flags: BaseParseFrameFlags) { unsafe { (*self.to_glib_none().0).flags &= !flags.bits() } } #[doc(alias = "get_offset")] #[inline] pub fn offset(&self) -> u64 { unsafe { (*self.to_glib_none().0).offset } } #[doc(alias = "get_overhead")] #[inline] pub fn overhead(&self) -> Overhead { unsafe { from_glib((*self.to_glib_none().0).overhead) } } #[inline] pub fn set_overhead(&mut self, overhead: Overhead) { unsafe { (*self.to_glib_none().0).overhead = overhead.into_glib(); } } } gstreamer-base-0.24.0/src/base_sink.rs000064400000000000000000000041621046102023000157060ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::mem; use glib::{prelude::*, translate::*}; use gst::prelude::*; use crate::{ffi, BaseSink}; pub trait BaseSinkExtManual: IsA + 'static { #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let sink: &ffi::GstBaseSink = &*(self.as_ptr() as *const _); let sinkpad = self.sink_pad(); let _guard = sinkpad.stream_lock(); from_glib_none(&sink.segment as *const gst::ffi::GstSegment) } } #[doc(alias = "gst_base_sink_query_latency")] fn query_latency( &self, ) -> Result<(bool, bool, Option, Option), glib::BoolError> { unsafe { let mut live = mem::MaybeUninit::uninit(); let mut upstream_live = mem::MaybeUninit::uninit(); let mut min_latency = mem::MaybeUninit::uninit(); let mut max_latency = mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_base_sink_query_latency( self.as_ref().to_glib_none().0, live.as_mut_ptr(), upstream_live.as_mut_ptr(), min_latency.as_mut_ptr(), max_latency.as_mut_ptr(), )); let live = live.assume_init(); let upstream_live = upstream_live.assume_init(); let min_latency = min_latency.assume_init(); let max_latency = max_latency.assume_init(); if ret { Ok(( from_glib(live), from_glib(upstream_live), from_glib(min_latency), from_glib(max_latency), )) } else { Err(glib::bool_error!("Failed to query latency")) } } } fn sink_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseSink); &*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad) } } } impl> BaseSinkExtManual for O {} gstreamer-base-0.24.0/src/base_src.rs000064400000000000000000000047231046102023000155340ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr}; use glib::{prelude::*, translate::*}; use gst::prelude::*; use crate::{ffi, BaseSrc}; pub trait BaseSrcExtManual: IsA + 'static { #[doc(alias = "get_allocator")] #[doc(alias = "gst_base_src_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); let mut params = mem::MaybeUninit::uninit(); ffi::gst_base_src_get_allocator( self.as_ref().to_glib_none().0, &mut allocator, params.as_mut_ptr(), ); (from_glib_full(allocator), params.assume_init().into()) } } #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let src: &ffi::GstBaseSrc = &*(self.as_ptr() as *const _); let srcpad = self.src_pad(); let _guard = srcpad.stream_lock(); let _guard = self.as_ref().object_lock(); from_glib_none(&src.segment as *const _) } } #[doc(alias = "gst_base_src_query_latency")] fn query_latency( &self, ) -> Result<(bool, Option, Option), glib::BoolError> { unsafe { let mut live = mem::MaybeUninit::uninit(); let mut min_latency = mem::MaybeUninit::uninit(); let mut max_latency = mem::MaybeUninit::uninit(); let ret = from_glib(ffi::gst_base_src_query_latency( self.as_ref().to_glib_none().0, live.as_mut_ptr(), min_latency.as_mut_ptr(), max_latency.as_mut_ptr(), )); let live = live.assume_init(); let min_latency = min_latency.assume_init(); let max_latency = max_latency.assume_init(); if ret { Ok(( from_glib(live), from_glib(min_latency), from_glib(max_latency), )) } else { Err(glib::bool_error!("Failed to query latency")) } } } fn src_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseSrc); &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad) } } } impl> BaseSrcExtManual for O {} gstreamer-base-0.24.0/src/base_transform.rs000064400000000000000000000032011046102023000167460ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr}; use glib::{prelude::*, translate::*}; use gst::prelude::*; use crate::{ffi, BaseTransform}; pub trait BaseTransformExtManual: IsA + 'static { #[doc(alias = "get_allocator")] #[doc(alias = "gst_base_transform_get_allocator")] fn allocator(&self) -> (Option, gst::AllocationParams) { unsafe { let mut allocator = ptr::null_mut(); let mut params = mem::MaybeUninit::uninit(); ffi::gst_base_transform_get_allocator( self.as_ref().to_glib_none().0, &mut allocator, params.as_mut_ptr(), ); (from_glib_full(allocator), params.assume_init().into()) } } #[doc(alias = "get_segment")] fn segment(&self) -> gst::Segment { unsafe { let trans: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _); let sinkpad = self.sink_pad(); let _guard = sinkpad.stream_lock(); from_glib_none(&trans.segment as *const _) } } fn sink_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseTransform); &*(&elt.sinkpad as *const *mut gst::ffi::GstPad as *const gst::Pad) } } fn src_pad(&self) -> &gst::Pad { unsafe { let elt = &*(self.as_ptr() as *const ffi::GstBaseTransform); &*(&elt.srcpad as *const *mut gst::ffi::GstPad as *const gst::Pad) } } } impl> BaseTransformExtManual for O {} gstreamer-base-0.24.0/src/flow_combiner.rs000064400000000000000000000071001046102023000165700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[doc(alias = "GstFlowCombiner")] pub struct FlowCombiner(Shared); match fn { ref => |ptr| ffi::gst_flow_combiner_ref(ptr), unref => |ptr| ffi::gst_flow_combiner_unref(ptr), type_ => || ffi::gst_flow_combiner_get_type(), } } impl FlowCombiner { #[doc(alias = "gst_flow_combiner_new")] pub fn new() -> Self { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gst_flow_combiner_new()) } } #[doc(alias = "gst_flow_combiner_add_pad")] pub fn add_pad>(&self, pad: &P) { unsafe { ffi::gst_flow_combiner_add_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0); } } #[doc(alias = "gst_flow_combiner_clear")] pub fn clear(&self) { unsafe { ffi::gst_flow_combiner_clear(self.to_glib_none().0); } } #[doc(alias = "gst_flow_combiner_remove_pad")] pub fn remove_pad>(&self, pad: &P) { unsafe { ffi::gst_flow_combiner_remove_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0); } } #[doc(alias = "gst_flow_combiner_reset")] pub fn reset(&self) { unsafe { ffi::gst_flow_combiner_reset(self.to_glib_none().0); } } #[doc(alias = "gst_flow_combiner_update_flow")] pub fn update_flow>( &self, fret: FRet, ) -> Result { let fret: gst::FlowReturn = fret.into(); unsafe { try_from_glib(ffi::gst_flow_combiner_update_flow( self.to_glib_none().0, fret.into_glib(), )) } } #[doc(alias = "gst_flow_combiner_update_pad_flow")] pub fn update_pad_flow, FRet: Into>( &self, pad: &P, fret: FRet, ) -> Result { let fret: gst::FlowReturn = fret.into(); unsafe { try_from_glib(ffi::gst_flow_combiner_update_pad_flow( self.to_glib_none().0, pad.as_ref().to_glib_none().0, fret.into_glib(), )) } } } impl Default for FlowCombiner { fn default() -> Self { Self::new() } } #[derive(Debug)] pub struct UniqueFlowCombiner(FlowCombiner); unsafe impl Sync for UniqueFlowCombiner {} unsafe impl Send for UniqueFlowCombiner {} impl UniqueFlowCombiner { pub fn new() -> Self { Self(FlowCombiner::new()) } pub fn add_pad>(&mut self, pad: &P) { self.0.add_pad(pad); } pub fn clear(&mut self) { self.0.clear(); } pub fn remove_pad>(&mut self, pad: &P) { self.0.remove_pad(pad); } pub fn reset(&mut self) { self.0.reset(); } pub fn update_flow( &mut self, fret: Result, ) -> Result { self.0.update_flow(fret) } pub fn update_pad_flow>( &mut self, pad: &P, fret: Result, ) -> Result { self.0.update_pad_flow(pad, fret) } } impl Default for UniqueFlowCombiner { fn default() -> Self { Self::new() } } gstreamer-base-0.24.0/src/functions.rs000064400000000000000000000130061046102023000157550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::mem; pub use crate::auto::functions::*; use crate::ffi; use glib::{prelude::*, translate::*}; #[doc(alias = "gst_type_find_helper_for_data")] pub fn type_find_helper_for_data( obj: Option<&impl IsA>, data: impl AsRef<[u8]>, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { assert_initialized_main_thread!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let data = data.as_ref(); let (ptr, len) = (data.as_ptr(), data.len()); let ret = ffi::gst_type_find_helper_for_data( obj.map(|p| p.as_ref()).to_glib_none().0, mut_override(ptr), len, prob.as_mut_ptr(), ); if ret.is_null() { Err(glib::bool_error!("No type could be found")) } else { Ok((from_glib_full(ret), from_glib(prob.assume_init()))) } } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "gst_type_find_helper_for_data_with_extension")] pub fn type_find_helper_for_data_with_extension( obj: Option<&impl IsA>, data: impl AsRef<[u8]>, extension: Option<&str>, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { assert_initialized_main_thread!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let data = data.as_ref(); let (ptr, len) = (data.as_ptr(), data.len()); let ret = ffi::gst_type_find_helper_for_data_with_extension( obj.map(|p| p.as_ref()).to_glib_none().0, mut_override(ptr), len, extension.to_glib_none().0, prob.as_mut_ptr(), ); if ret.is_null() { Err(glib::bool_error!("No type could be found")) } else { Ok((from_glib_full(ret), from_glib(prob.assume_init()))) } } } #[doc(alias = "gst_type_find_helper_for_buffer")] pub fn type_find_helper_for_buffer>( obj: Option<&P>, buf: &gst::BufferRef, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { skip_assert_initialized!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = ffi::gst_type_find_helper_for_buffer( obj.map(|p| p.as_ref()).to_glib_none().0, mut_override(buf.as_ptr()), prob.as_mut_ptr(), ); if ret.is_null() { Err(glib::bool_error!("No type could be found")) } else { Ok((from_glib_full(ret), from_glib(prob.assume_init()))) } } } #[cfg(feature = "v1_16")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] #[doc(alias = "gst_type_find_helper_for_buffer_with_extension")] pub fn type_find_helper_for_buffer_with_extension>( obj: Option<&P>, buf: &gst::BufferRef, extension: Option<&str>, ) -> Result<(gst::Caps, gst::TypeFindProbability), glib::error::BoolError> { skip_assert_initialized!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = ffi::gst_type_find_helper_for_buffer_with_extension( obj.map(|p| p.as_ref()).to_glib_none().0, mut_override(buf.as_ptr()), extension.to_glib_none().0, prob.as_mut_ptr(), ); if ret.is_null() { Err(glib::bool_error!("No type could be found")) } else { Ok((from_glib_full(ret), from_glib(prob.assume_init()))) } } } #[cfg(feature = "v1_22")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] #[doc(alias = "gst_type_find_helper_for_buffer_with_caps")] pub fn type_find_helper_for_buffer_with_caps( obj: Option<&impl IsA>, buf: &gst::BufferRef, caps: &gst::CapsRef, ) -> (Option, gst::TypeFindProbability) { skip_assert_initialized!(); unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::gst_type_find_helper_for_buffer_with_caps( obj.map(|p| p.as_ref()).to_glib_none().0, mut_override(buf.as_ptr()), mut_override(caps.as_ptr()), prob.as_mut_ptr(), )); (ret, from_glib(prob.assume_init())) } } #[cfg(feature = "v1_22")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] #[doc(alias = "gst_type_find_helper_for_data_with_caps")] pub fn type_find_helper_for_data_with_caps( obj: Option<&impl IsA>, data: &[u8], caps: &gst::CapsRef, ) -> (Option, gst::TypeFindProbability) { skip_assert_initialized!(); let size = data.len() as _; unsafe { let mut prob = mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::gst_type_find_helper_for_data_with_caps( obj.map(|p| p.as_ref()).to_glib_none().0, data.to_glib_none().0, size, mut_override(caps.as_ptr()), prob.as_mut_ptr(), )); (ret, from_glib(prob.assume_init())) } } #[cfg(feature = "v1_22")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] #[doc(alias = "gst_type_find_list_factories_for_caps")] pub fn type_find_list_factories_for_caps( obj: Option<&impl IsA>, caps: &gst::CapsRef, ) -> glib::List { skip_assert_initialized!(); unsafe { glib::collections::List::from_glib_full(ffi::gst_type_find_list_factories_for_caps( obj.map(|p| p.as_ref()).to_glib_none().0, mut_override(caps.as_ptr()), )) } } gstreamer-base-0.24.0/src/lib.rs000064400000000000000000000032261046102023000145160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::missing_safety_doc)] #![allow(clippy::manual_c_str_literals)] #![doc = include_str!("../README.md")] pub use glib; pub use gst; pub use gstreamer_base_sys as ffi; macro_rules! assert_initialized_main_thread { () => { if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) { gst::assert_initialized(); } }; } macro_rules! skip_assert_initialized { () => {}; } #[allow(unused_imports)] mod auto; pub use crate::auto::*; pub mod functions; pub use crate::functions::*; mod adapter; pub use crate::adapter::*; mod flow_combiner; pub use crate::flow_combiner::*; mod aggregator; mod aggregator_pad; mod base_parse; mod base_sink; mod base_src; mod base_transform; pub mod base_parse_frame; pub use crate::base_parse_frame::BaseParseFrame; pub const BASE_TRANSFORM_FLOW_DROPPED: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess; pub const BASE_PARSE_FLOW_DROPPED: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess; pub const AGGREGATOR_FLOW_NEED_DATA: gst::FlowError = gst::FlowError::CustomError; // Re-export all the traits in a prelude module, so that applications // can always "use gst_base::prelude::*" without getting conflicts pub mod prelude { #[doc(hidden)] pub use gst::prelude::*; pub use crate::{ aggregator::AggregatorExtManual, aggregator_pad::AggregatorPadExtManual, auto::traits::*, base_parse::BaseParseExtManual, base_sink::BaseSinkExtManual, base_src::BaseSrcExtManual, base_transform::BaseTransformExtManual, }; } pub mod subclass; gstreamer-base-0.24.0/src/subclass/aggregator.rs000064400000000000000000001005371046102023000177140ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, translate::*}; use gst::subclass::prelude::*; use crate::{ffi, Aggregator, AggregatorPad}; pub trait AggregatorImpl: ElementImpl + ObjectSubclass> { fn flush(&self) -> Result { self.parent_flush() } fn clip(&self, aggregator_pad: &AggregatorPad, buffer: gst::Buffer) -> Option { self.parent_clip(aggregator_pad, buffer) } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn finish_buffer_list( &self, buffer_list: gst::BufferList, ) -> Result { self.parent_finish_buffer_list(buffer_list) } fn finish_buffer(&self, buffer: gst::Buffer) -> Result { self.parent_finish_buffer(buffer) } fn sink_event(&self, aggregator_pad: &AggregatorPad, event: gst::Event) -> bool { self.parent_sink_event(aggregator_pad, event) } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn sink_event_pre_queue( &self, aggregator_pad: &AggregatorPad, event: gst::Event, ) -> Result { self.parent_sink_event_pre_queue(aggregator_pad, event) } fn sink_query(&self, aggregator_pad: &AggregatorPad, query: &mut gst::QueryRef) -> bool { self.parent_sink_query(aggregator_pad, query) } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn sink_query_pre_queue( &self, aggregator_pad: &AggregatorPad, query: &mut gst::QueryRef, ) -> bool { self.parent_sink_query_pre_queue(aggregator_pad, query) } fn src_event(&self, event: gst::Event) -> bool { self.parent_src_event(event) } fn src_query(&self, query: &mut gst::QueryRef) -> bool { self.parent_src_query(query) } fn src_activate(&self, mode: gst::PadMode, active: bool) -> Result<(), gst::LoggableError> { self.parent_src_activate(mode, active) } fn aggregate(&self, timeout: bool) -> Result { self.parent_aggregate(timeout) } fn start(&self) -> Result<(), gst::ErrorMessage> { self.parent_start() } fn stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_stop() } fn next_time(&self) -> Option { self.parent_next_time() } fn create_new_pad( &self, templ: &gst::PadTemplate, req_name: Option<&str>, caps: Option<&gst::Caps>, ) -> Option { self.parent_create_new_pad(templ, req_name, caps) } fn update_src_caps(&self, caps: &gst::Caps) -> Result { self.parent_update_src_caps(caps) } fn fixate_src_caps(&self, caps: gst::Caps) -> gst::Caps { self.parent_fixate_src_caps(caps) } fn negotiated_src_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { self.parent_negotiated_src_caps(caps) } fn propose_allocation( &self, pad: &AggregatorPad, decide_query: Option<&gst::query::Allocation>, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(pad, decide_query, query) } fn decide_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(query) } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn negotiate(&self) -> bool { self.parent_negotiate() } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn peek_next_sample(&self, pad: &AggregatorPad) -> Option { self.parent_peek_next_sample(pad) } } pub trait AggregatorImplExt: AggregatorImpl { fn parent_flush(&self) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .flush .map(|f| { try_from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) }) .unwrap_or(Ok(gst::FlowSuccess::Ok)) } } fn parent_clip( &self, aggregator_pad: &AggregatorPad, buffer: gst::Buffer, ) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; match (*parent_class).clip { None => Some(buffer), Some(ref func) => from_glib_full(func( self.obj().unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, buffer.into_glib_ptr(), )), } } } fn parent_finish_buffer( &self, buffer: gst::Buffer, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .finish_buffer .expect("Missing parent function `finish_buffer`"); try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer.into_glib_ptr(), )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn parent_finish_buffer_list( &self, buffer_list: gst::BufferList, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .finish_buffer_list .expect("Missing parent function `finish_buffer_list`"); try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer_list.into_glib_ptr(), )) } } fn parent_sink_event(&self, aggregator_pad: &AggregatorPad, event: gst::Event) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .sink_event .expect("Missing parent function `sink_event`"); from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, event.into_glib_ptr(), )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn parent_sink_event_pre_queue( &self, aggregator_pad: &AggregatorPad, event: gst::Event, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .sink_event_pre_queue .expect("Missing parent function `sink_event_pre_queue`"); try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, event.into_glib_ptr(), )) } } fn parent_sink_query(&self, aggregator_pad: &AggregatorPad, query: &mut gst::QueryRef) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .sink_query .expect("Missing parent function `sink_query`"); from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, query.as_mut_ptr(), )) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn parent_sink_query_pre_queue( &self, aggregator_pad: &AggregatorPad, query: &mut gst::QueryRef, ) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .sink_query_pre_queue .expect("Missing parent function `sink_query`"); from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, query.as_mut_ptr(), )) } } fn parent_src_event(&self, event: gst::Event) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .src_event .expect("Missing parent function `src_event`"); from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, event.into_glib_ptr(), )) } } fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .src_query .expect("Missing parent function `src_query`"); from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, query.as_mut_ptr(), )) } } fn parent_src_activate( &self, mode: gst::PadMode, active: bool, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; match (*parent_class).src_activate { None => Ok(()), Some(f) => gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, mode.into_glib(), active.into_glib() ), gst::CAT_RUST, "Parent function `src_activate` failed" ), } } } fn parent_aggregate(&self, timeout: bool) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .aggregate .expect("Missing parent function `aggregate`"); try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, timeout.into_glib(), )) } } fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .start .map(|f| { if from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::Failed, ["Parent function `start` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .stop .map(|f| { if from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::Failed, ["Parent function `stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_next_time(&self) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .get_next_time .map(|f| { from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) }) .unwrap_or(gst::ClockTime::NONE) } } fn parent_create_new_pad( &self, templ: &gst::PadTemplate, req_name: Option<&str>, caps: Option<&gst::Caps>, ) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .create_new_pad .expect("Missing parent function `create_new_pad`"); from_glib_full(f( self.obj().unsafe_cast_ref::().to_glib_none().0, templ.to_glib_none().0, req_name.to_glib_none().0, caps.to_glib_none().0, )) } } fn parent_update_src_caps(&self, caps: &gst::Caps) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .update_src_caps .expect("Missing parent function `update_src_caps`"); let mut out_caps = ptr::null_mut(); gst::FlowSuccess::try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.as_mut_ptr(), &mut out_caps, )) .map(|_| from_glib_full(out_caps)) } } fn parent_fixate_src_caps(&self, caps: gst::Caps) -> gst::Caps { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; let f = (*parent_class) .fixate_src_caps .expect("Missing parent function `fixate_src_caps`"); from_glib_full(f( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.into_glib_ptr(), )) } } fn parent_negotiated_src_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .negotiated_src_caps .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.to_glib_none().0 ), gst::CAT_RUST, "Parent function `negotiated_src_caps` failed" ) }) .unwrap_or(Ok(())) } } fn parent_propose_allocation( &self, pad: &AggregatorPad, decide_query: Option<&gst::query::Allocation>, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .propose_allocation .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, pad.to_glib_none().0, decide_query .as_ref() .map(|q| q.as_mut_ptr()) .unwrap_or(ptr::null_mut()), query.as_mut_ptr() ), gst::CAT_RUST, "Parent function `propose_allocation` failed", ) }) .unwrap_or(Ok(())) } } fn parent_decide_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .decide_allocation .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, query.as_mut_ptr(), ), gst::CAT_RUST, "Parent function `decide_allocation` failed", ) }) .unwrap_or(Ok(())) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn parent_negotiate(&self) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .negotiate .map(|f| { from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) }) .unwrap_or(true) } } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] fn parent_peek_next_sample(&self, pad: &AggregatorPad) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorClass; (*parent_class) .peek_next_sample .map(|f| { from_glib_full(f( self.obj().unsafe_cast_ref::().to_glib_none().0, pad.to_glib_none().0, )) }) .unwrap_or(None) } } } impl AggregatorImplExt for T {} unsafe impl IsSubclassable for Aggregator { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.flush = Some(aggregator_flush::); klass.clip = Some(aggregator_clip::); klass.finish_buffer = Some(aggregator_finish_buffer::); klass.sink_event = Some(aggregator_sink_event::); klass.sink_query = Some(aggregator_sink_query::); klass.src_event = Some(aggregator_src_event::); klass.src_query = Some(aggregator_src_query::); klass.src_activate = Some(aggregator_src_activate::); klass.aggregate = Some(aggregator_aggregate::); klass.start = Some(aggregator_start::); klass.stop = Some(aggregator_stop::); klass.get_next_time = Some(aggregator_get_next_time::); klass.create_new_pad = Some(aggregator_create_new_pad::); klass.update_src_caps = Some(aggregator_update_src_caps::); klass.fixate_src_caps = Some(aggregator_fixate_src_caps::); klass.negotiated_src_caps = Some(aggregator_negotiated_src_caps::); klass.propose_allocation = Some(aggregator_propose_allocation::); klass.decide_allocation = Some(aggregator_decide_allocation::); #[cfg(feature = "v1_18")] { klass.sink_event_pre_queue = Some(aggregator_sink_event_pre_queue::); klass.sink_query_pre_queue = Some(aggregator_sink_query_pre_queue::); klass.negotiate = Some(aggregator_negotiate::); klass.peek_next_sample = Some(aggregator_peek_next_sample::); klass.finish_buffer_list = Some(aggregator_finish_buffer_list::); } } } unsafe extern "C" fn aggregator_flush( ptr: *mut ffi::GstAggregator, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.flush().into() }).into_glib() } unsafe extern "C" fn aggregator_clip( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, buffer: *mut gst::ffi::GstBuffer, ) -> *mut gst::ffi::GstBuffer { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let ret = gst::panic_to_error!(imp, None, { imp.clip(&from_glib_borrow(aggregator_pad), from_glib_full(buffer)) }); ret.map(|r| r.into_glib_ptr()).unwrap_or(ptr::null_mut()) } unsafe extern "C" fn aggregator_finish_buffer( ptr: *mut ffi::GstAggregator, buffer: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.finish_buffer(from_glib_full(buffer)).into() }) .into_glib() } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] unsafe extern "C" fn aggregator_finish_buffer_list( ptr: *mut ffi::GstAggregator, buffer_list: *mut gst::ffi::GstBufferList, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.finish_buffer_list(from_glib_full(buffer_list)).into() }) .into_glib() } unsafe extern "C" fn aggregator_sink_event( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, event: *mut gst::ffi::GstEvent, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.sink_event(&from_glib_borrow(aggregator_pad), from_glib_full(event)) }) .into_glib() } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] unsafe extern "C" fn aggregator_sink_event_pre_queue( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, event: *mut gst::ffi::GstEvent, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.sink_event_pre_queue(&from_glib_borrow(aggregator_pad), from_glib_full(event)) .into() }) .into_glib() } unsafe extern "C" fn aggregator_sink_query( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.sink_query( &from_glib_borrow(aggregator_pad), gst::QueryRef::from_mut_ptr(query), ) }) .into_glib() } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] unsafe extern "C" fn aggregator_sink_query_pre_queue( ptr: *mut ffi::GstAggregator, aggregator_pad: *mut ffi::GstAggregatorPad, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.sink_query_pre_queue( &from_glib_borrow(aggregator_pad), gst::QueryRef::from_mut_ptr(query), ) }) .into_glib() } unsafe extern "C" fn aggregator_src_event( ptr: *mut ffi::GstAggregator, event: *mut gst::ffi::GstEvent, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib() } unsafe extern "C" fn aggregator_src_query( ptr: *mut ffi::GstAggregator, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.src_query(gst::QueryRef::from_mut_ptr(query)) }) .into_glib() } unsafe extern "C" fn aggregator_src_activate( ptr: *mut ffi::GstAggregator, mode: gst::ffi::GstPadMode, active: glib::ffi::gboolean, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.src_activate(from_glib(mode), from_glib(active)) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn aggregator_aggregate( ptr: *mut ffi::GstAggregator, timeout: glib::ffi::gboolean, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.aggregate(from_glib(timeout)).into() }) .into_glib() } unsafe extern "C" fn aggregator_start( ptr: *mut ffi::GstAggregator, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.start() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn aggregator_stop( ptr: *mut ffi::GstAggregator, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn aggregator_get_next_time( ptr: *mut ffi::GstAggregator, ) -> gst::ffi::GstClockTime { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::ClockTime::NONE, { imp.next_time() }).into_glib() } unsafe extern "C" fn aggregator_create_new_pad( ptr: *mut ffi::GstAggregator, templ: *mut gst::ffi::GstPadTemplate, req_name: *const libc::c_char, caps: *const gst::ffi::GstCaps, ) -> *mut ffi::GstAggregatorPad { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, None, { let req_name: Borrowed> = from_glib_borrow(req_name); imp.create_new_pad( &from_glib_borrow(templ), req_name.as_ref().as_ref().map(|s| s.as_str()), Option::::from_glib_borrow(caps) .as_ref() .as_ref(), ) }) .into_glib_ptr() } unsafe extern "C" fn aggregator_update_src_caps( ptr: *mut ffi::GstAggregator, caps: *mut gst::ffi::GstCaps, res: *mut *mut gst::ffi::GstCaps, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); *res = ptr::null_mut(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { match imp.update_src_caps(&from_glib_borrow(caps)) { Ok(res_caps) => { *res = res_caps.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => err.into(), } }) .into_glib() } unsafe extern "C" fn aggregator_fixate_src_caps( ptr: *mut ffi::GstAggregator, caps: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::Caps::new_empty(), { imp.fixate_src_caps(from_glib_full(caps)) }) .into_glib_ptr() } unsafe extern "C" fn aggregator_negotiated_src_caps( ptr: *mut ffi::GstAggregator, caps: *mut gst::ffi::GstCaps, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.negotiated_src_caps(&from_glib_borrow(caps)) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn aggregator_propose_allocation( ptr: *mut ffi::GstAggregator, pad: *mut ffi::GstAggregatorPad, decide_query: *mut gst::ffi::GstQuery, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let decide_query = if decide_query.is_null() { None } else { match gst::QueryRef::from_ptr(decide_query).view() { gst::QueryView::Allocation(allocation) => Some(allocation), _ => unreachable!(), } }; let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { gst::QueryViewMut::Allocation(allocation) => allocation, _ => unreachable!(), }; gst::panic_to_error!(imp, false, { match imp.propose_allocation(&from_glib_borrow(pad), decide_query, query) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn aggregator_decide_allocation( ptr: *mut ffi::GstAggregator, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { gst::QueryViewMut::Allocation(allocation) => allocation, _ => unreachable!(), }; gst::panic_to_error!(imp, false, { match imp.decide_allocation(query) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] unsafe extern "C" fn aggregator_negotiate( ptr: *mut ffi::GstAggregator, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.negotiate() }).into_glib() } #[cfg(feature = "v1_18")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))] unsafe extern "C" fn aggregator_peek_next_sample( ptr: *mut ffi::GstAggregator, pad: *mut ffi::GstAggregatorPad, ) -> *mut gst::ffi::GstSample { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, None, { imp.peek_next_sample(&from_glib_borrow(pad)) }) .into_glib_ptr() } gstreamer-base-0.24.0/src/subclass/aggregator_pad.rs000064400000000000000000000061731046102023000205410ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*}; use gst::subclass::prelude::*; use crate::{ffi, Aggregator, AggregatorPad}; pub trait AggregatorPadImpl: PadImpl + ObjectSubclass> { fn flush(&self, aggregator: &Aggregator) -> Result { self.parent_flush(aggregator) } fn skip_buffer(&self, aggregator: &Aggregator, buffer: &gst::Buffer) -> bool { self.parent_skip_buffer(aggregator, buffer) } } pub trait AggregatorPadImplExt: AggregatorPadImpl { fn parent_flush(&self, aggregator: &Aggregator) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorPadClass; (*parent_class) .flush .map(|f| { try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, aggregator.to_glib_none().0, )) }) .unwrap_or(Ok(gst::FlowSuccess::Ok)) } } fn parent_skip_buffer(&self, aggregator: &Aggregator, buffer: &gst::Buffer) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorPadClass; (*parent_class) .skip_buffer .map(|f| { from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, aggregator.to_glib_none().0, buffer.to_glib_none().0, )) }) .unwrap_or(false) } } } impl AggregatorPadImplExt for T {} unsafe impl IsSubclassable for AggregatorPad { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.flush = Some(aggregator_pad_flush::); klass.skip_buffer = Some(aggregator_pad_skip_buffer::); } } unsafe extern "C" fn aggregator_pad_flush( ptr: *mut ffi::GstAggregatorPad, aggregator: *mut ffi::GstAggregator, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let res: gst::FlowReturn = imp.flush(&from_glib_borrow(aggregator)).into(); res.into_glib() } unsafe extern "C" fn aggregator_pad_skip_buffer( ptr: *mut ffi::GstAggregatorPad, aggregator: *mut ffi::GstAggregator, buffer: *mut gst::ffi::GstBuffer, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.skip_buffer(&from_glib_borrow(aggregator), &from_glib_borrow(buffer)) .into_glib() } gstreamer-base-0.24.0/src/subclass/base_parse.rs000064400000000000000000000211171046102023000176720ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::mem; use glib::translate::*; use gst::subclass::prelude::*; use crate::{ffi, prelude::*, BaseParse, BaseParseFrame}; pub trait BaseParseImpl: ElementImpl + ObjectSubclass> { fn start(&self) -> Result<(), gst::ErrorMessage> { self.parent_start() } fn stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_stop() } fn set_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { self.parent_set_sink_caps(caps) } fn handle_frame( &self, frame: BaseParseFrame, ) -> Result<(gst::FlowSuccess, u32), gst::FlowError> { self.parent_handle_frame(frame) } fn convert( &self, src_val: impl gst::format::FormattedValue, dest_format: gst::Format, ) -> Option { self.parent_convert(src_val, dest_format) } } pub trait BaseParseImplExt: BaseParseImpl { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass; (*parent_class) .start .map(|f| { if from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `start` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass; (*parent_class) .stop .map(|f| { if from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_set_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass; (*parent_class) .set_sink_caps .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.to_glib_none().0, ), gst::CAT_RUST, "Parent function `set_sink_caps` failed", ) }) .unwrap_or(Ok(())) } } fn parent_handle_frame( &self, frame: BaseParseFrame, ) -> Result<(gst::FlowSuccess, u32), gst::FlowError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass; let mut skipsize = 0; (*parent_class) .handle_frame .map(|f| { let res = try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, frame.to_glib_none().0, &mut skipsize, )); (res.unwrap(), skipsize as u32) }) .ok_or(gst::FlowError::Error) } } fn parent_convert( &self, src_val: impl gst::format::FormattedValue, dest_format: gst::Format, ) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass; let res = (*parent_class).convert.map(|f| { let mut dest_val = mem::MaybeUninit::uninit(); let res = from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, src_val.format().into_glib(), src_val.into_raw_value(), dest_format.into_glib(), dest_val.as_mut_ptr(), )); (res, dest_val) }); match res { Some((true, dest_val)) => Some(gst::GenericFormattedValue::new( dest_format, dest_val.assume_init(), )), _ => None, } } } } impl BaseParseImplExt for T {} unsafe impl IsSubclassable for BaseParse { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.start = Some(base_parse_start::); klass.stop = Some(base_parse_stop::); klass.set_sink_caps = Some(base_parse_set_sink_caps::); klass.handle_frame = Some(base_parse_handle_frame::); klass.convert = Some(base_parse_convert::); } } unsafe extern "C" fn base_parse_start( ptr: *mut ffi::GstBaseParse, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.start() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_parse_stop( ptr: *mut ffi::GstBaseParse, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_parse_set_sink_caps( ptr: *mut ffi::GstBaseParse, caps: *mut gst::ffi::GstCaps, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let caps: Borrowed = from_glib_borrow(caps); gst::panic_to_error!(imp, false, { match imp.set_sink_caps(&caps) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_parse_handle_frame( ptr: *mut ffi::GstBaseParse, frame: *mut ffi::GstBaseParseFrame, skipsize: *mut i32, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let instance = imp.obj(); let instance = instance.unsafe_cast_ref::(); let wrap_frame = BaseParseFrame::new(frame, instance); let res = gst::panic_to_error!(imp, Err(gst::FlowError::Error), { imp.handle_frame(wrap_frame) }); match res { Ok((flow, skip)) => { *skipsize = i32::try_from(skip).expect("skip is higher than i32::MAX"); gst::FlowReturn::from_ok(flow) } Err(flow) => gst::FlowReturn::from_error(flow), } .into_glib() } unsafe extern "C" fn base_parse_convert( ptr: *mut ffi::GstBaseParse, source_format: gst::ffi::GstFormat, source_value: i64, dest_format: gst::ffi::GstFormat, dest_value: *mut i64, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let source = gst::GenericFormattedValue::new(from_glib(source_format), source_value); let res = gst::panic_to_error!(imp, None, { imp.convert(source, from_glib(dest_format)) }); match res { Some(dest) => { *dest_value = dest.into_raw_value(); true } _ => false, } .into_glib() } gstreamer-base-0.24.0/src/subclass/base_sink.rs000064400000000000000000000445771046102023000175430ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, translate::*}; use gst::subclass::prelude::*; use crate::{ffi, BaseSink}; pub trait BaseSinkImpl: ElementImpl + ObjectSubclass> { fn start(&self) -> Result<(), gst::ErrorMessage> { self.parent_start() } fn stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_stop() } fn render(&self, buffer: &gst::Buffer) -> Result { self.parent_render(buffer) } fn prepare(&self, buffer: &gst::Buffer) -> Result { self.parent_prepare(buffer) } fn render_list(&self, list: &gst::BufferList) -> Result { self.parent_render_list(list) } fn prepare_list(&self, list: &gst::BufferList) -> Result { self.parent_prepare_list(list) } fn query(&self, query: &mut gst::QueryRef) -> bool { BaseSinkImplExt::parent_query(self, query) } fn event(&self, event: gst::Event) -> bool { self.parent_event(event) } fn caps(&self, filter: Option<&gst::Caps>) -> Option { self.parent_caps(filter) } fn set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { self.parent_set_caps(caps) } fn fixate(&self, caps: gst::Caps) -> gst::Caps { self.parent_fixate(caps) } fn unlock(&self) -> Result<(), gst::ErrorMessage> { self.parent_unlock() } fn unlock_stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_unlock_stop() } fn propose_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(query) } } pub trait BaseSinkImplExt: BaseSinkImpl { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .start .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `start` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .stop .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_render(&self, buffer: &gst::Buffer) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .render .map(|f| { try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer.to_glib_none().0, )) }) .unwrap_or(Ok(gst::FlowSuccess::Ok)) } } fn parent_prepare(&self, buffer: &gst::Buffer) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .prepare .map(|f| { try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer.to_glib_none().0, )) }) .unwrap_or(Ok(gst::FlowSuccess::Ok)) } } fn parent_render_list( &self, list: &gst::BufferList, ) -> Result; fn parent_prepare_list( &self, list: &gst::BufferList, ) -> Result; fn parent_query(&self, query: &mut gst::QueryRef) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .query .map(|f| { from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, query.as_mut_ptr(), )) }) .unwrap_or(false) } } fn parent_event(&self, event: gst::Event) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .event .map(|f| { from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, event.into_glib_ptr(), )) }) .unwrap_or(true) } } fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .get_caps .map(|f| { from_glib_full(f( self.obj().unsafe_cast_ref::().to_glib_none().0, filter.to_glib_none().0, )) }) .unwrap_or(None) } } fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .set_caps .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.to_glib_none().0 ), gst::CAT_RUST, "Parent function `set_caps` failed" ) }) .unwrap_or(Ok(())) } } fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; match (*parent_class).fixate { Some(fixate) => from_glib_full(fixate( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.into_glib_ptr(), )), None => caps, } } } fn parent_unlock(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .unlock .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::Failed, ["Parent function `unlock` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .unlock_stop .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::Failed, ["Parent function `unlock_stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_propose_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .propose_allocation .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, query.as_mut_ptr(), ), gst::CAT_RUST, "Parent function `propose_allocation` failed", ) }) .unwrap_or(Ok(())) } } } impl BaseSinkImplExt for T { fn parent_render_list( &self, list: &gst::BufferList, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .render_list .map(|f| { try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, list.to_glib_none().0, )) }) .unwrap_or_else(|| { for buffer in list.iter() { self.render(&from_glib_borrow(buffer.as_ptr()))?; } Ok(gst::FlowSuccess::Ok) }) } } fn parent_prepare_list( &self, list: &gst::BufferList, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass; (*parent_class) .prepare_list .map(|f| { try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, list.to_glib_none().0, )) }) .unwrap_or_else(|| { for buffer in list.iter() { self.prepare(&from_glib_borrow(buffer.as_ptr()))?; } Ok(gst::FlowSuccess::Ok) }) } } } unsafe impl IsSubclassable for BaseSink { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.start = Some(base_sink_start::); klass.stop = Some(base_sink_stop::); klass.render = Some(base_sink_render::); klass.render_list = Some(base_sink_render_list::); klass.prepare = Some(base_sink_prepare::); klass.prepare_list = Some(base_sink_prepare_list::); klass.query = Some(base_sink_query::); klass.event = Some(base_sink_event::); klass.get_caps = Some(base_sink_get_caps::); klass.set_caps = Some(base_sink_set_caps::); klass.fixate = Some(base_sink_fixate::); klass.unlock = Some(base_sink_unlock::); klass.unlock_stop = Some(base_sink_unlock_stop::); klass.propose_allocation = Some(base_sink_propose_allocation::); } } unsafe extern "C" fn base_sink_start( ptr: *mut ffi::GstBaseSink, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.start() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_sink_stop( ptr: *mut ffi::GstBaseSink, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_sink_render( ptr: *mut ffi::GstBaseSink, buffer: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let buffer = from_glib_borrow(buffer); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.render(&buffer).into() }).into_glib() } unsafe extern "C" fn base_sink_prepare( ptr: *mut ffi::GstBaseSink, buffer: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let buffer = from_glib_borrow(buffer); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.prepare(&buffer).into() }).into_glib() } unsafe extern "C" fn base_sink_render_list( ptr: *mut ffi::GstBaseSink, list: *mut gst::ffi::GstBufferList, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let list = from_glib_borrow(list); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.render_list(&list).into() }) .into_glib() } unsafe extern "C" fn base_sink_prepare_list( ptr: *mut ffi::GstBaseSink, list: *mut gst::ffi::GstBufferList, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let list = from_glib_borrow(list); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.prepare_list(&list).into() }) .into_glib() } unsafe extern "C" fn base_sink_query( ptr: *mut ffi::GstBaseSink, query_ptr: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let query = gst::QueryRef::from_mut_ptr(query_ptr); gst::panic_to_error!(imp, false, { BaseSinkImpl::query(imp, query) }).into_glib() } unsafe extern "C" fn base_sink_event( ptr: *mut ffi::GstBaseSink, event_ptr: *mut gst::ffi::GstEvent, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.event(from_glib_full(event_ptr)) }).into_glib() } unsafe extern "C" fn base_sink_get_caps( ptr: *mut ffi::GstBaseSink, filter: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let filter = Option::::from_glib_borrow(filter); gst::panic_to_error!(imp, None, { imp.caps(filter.as_ref().as_ref()) }) .map(|caps| caps.into_glib_ptr()) .unwrap_or(ptr::null_mut()) } unsafe extern "C" fn base_sink_set_caps( ptr: *mut ffi::GstBaseSink, caps: *mut gst::ffi::GstCaps, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let caps = from_glib_borrow(caps); gst::panic_to_error!(imp, false, { match imp.set_caps(&caps) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_sink_fixate( ptr: *mut ffi::GstBaseSink, caps: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let caps = from_glib_full(caps); gst::panic_to_error!(imp, gst::Caps::new_empty(), { imp.fixate(caps) }).into_glib_ptr() } unsafe extern "C" fn base_sink_unlock( ptr: *mut ffi::GstBaseSink, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.unlock() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_sink_unlock_stop( ptr: *mut ffi::GstBaseSink, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.unlock_stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_sink_propose_allocation( ptr: *mut ffi::GstBaseSink, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { gst::QueryViewMut::Allocation(allocation) => allocation, _ => unreachable!(), }; gst::panic_to_error!(imp, false, { match imp.propose_allocation(query) { Ok(()) => true, Err(err) => { err.log_with_imp_and_level(imp, gst::DebugLevel::Info); false } } }) .into_glib() } gstreamer-base-0.24.0/src/subclass/base_src.rs000064400000000000000000001014601046102023000173470ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr}; use atomic_refcell::AtomicRefCell; use glib::{prelude::*, translate::*}; use gst::{prelude::*, subclass::prelude::*}; use crate::{ffi, prelude::*, BaseSrc}; #[derive(Default)] pub(super) struct InstanceData { pub(super) pending_buffer_list: AtomicRefCell>, } #[derive(Debug)] pub enum CreateSuccess { FilledBuffer, NewBuffer(gst::Buffer), NewBufferList(gst::BufferList), } pub trait BaseSrcImpl: ElementImpl + ObjectSubclass> { fn start(&self) -> Result<(), gst::ErrorMessage> { self.parent_start() } fn stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_stop() } fn is_seekable(&self) -> bool { self.parent_is_seekable() } fn size(&self) -> Option { self.parent_size() } #[doc(alias = "get_times")] fn times(&self, buffer: &gst::BufferRef) -> (Option, Option) { self.parent_times(buffer) } fn fill( &self, offset: u64, length: u32, buffer: &mut gst::BufferRef, ) -> Result { self.parent_fill(offset, length, buffer) } fn alloc(&self, offset: u64, length: u32) -> Result { self.parent_alloc(offset, length) } fn create( &self, offset: u64, buffer: Option<&mut gst::BufferRef>, length: u32, ) -> Result { self.parent_create(offset, buffer, length) } fn do_seek(&self, segment: &mut gst::Segment) -> bool { self.parent_do_seek(segment) } fn query(&self, query: &mut gst::QueryRef) -> bool { BaseSrcImplExt::parent_query(self, query) } fn event(&self, event: &gst::Event) -> bool { self.parent_event(event) } fn caps(&self, filter: Option<&gst::Caps>) -> Option { self.parent_caps(filter) } fn negotiate(&self) -> Result<(), gst::LoggableError> { self.parent_negotiate() } fn set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { self.parent_set_caps(caps) } fn fixate(&self, caps: gst::Caps) -> gst::Caps { self.parent_fixate(caps) } fn unlock(&self) -> Result<(), gst::ErrorMessage> { self.parent_unlock() } fn unlock_stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_unlock_stop() } fn decide_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(query) } } pub trait BaseSrcImplExt: BaseSrcImpl { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .start .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `start` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .stop .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_is_seekable(&self) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .is_seekable .map(|f| from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0))) .unwrap_or(false) } } fn parent_size(&self) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .get_size .map(|f| { let mut size = mem::MaybeUninit::uninit(); if from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, size.as_mut_ptr(), )) { Some(size.assume_init()) } else { None } }) .unwrap_or(None) } } fn parent_times( &self, buffer: &gst::BufferRef, ) -> (Option, Option) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .get_times .map(|f| { let mut start = mem::MaybeUninit::uninit(); let mut stop = mem::MaybeUninit::uninit(); f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer.as_mut_ptr(), start.as_mut_ptr(), stop.as_mut_ptr(), ); ( from_glib(start.assume_init()), from_glib(stop.assume_init()), ) }) .unwrap_or((gst::ClockTime::NONE, gst::ClockTime::NONE)) } } fn parent_fill( &self, offset: u64, length: u32, buffer: &mut gst::BufferRef, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .fill .map(|f| { try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, offset, length, buffer.as_mut_ptr(), )) }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } fn parent_alloc(&self, offset: u64, length: u32) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .alloc .map(|f| { let mut buffer_ptr: *mut gst::ffi::GstBuffer = ptr::null_mut(); // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer; gst::FlowSuccess::try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, offset, length, buffer_ref, )) .map(|_| from_glib_full(buffer_ptr)) }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } fn parent_create( &self, offset: u64, mut buffer: Option<&mut gst::BufferRef>, length: u32, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .create .map(|f| { let instance = self.obj(); let instance = instance.unsafe_cast_ref::(); let orig_buffer_ptr = buffer .as_mut() .map(|b| b.as_mut_ptr()) .unwrap_or(ptr::null_mut()); let mut buffer_ptr = orig_buffer_ptr; // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer; let instance_data = self.instance_data::(BaseSrc::static_type()).unwrap(); if let Err(err) = gst::FlowSuccess::try_from_glib( f( instance.to_glib_none().0, offset, length, buffer_ref, ) ) { *instance_data.pending_buffer_list.borrow_mut() = None; return Err(err); } let pending_buffer_list = instance_data.pending_buffer_list.borrow_mut().take(); if pending_buffer_list.is_some() && (buffer.is_some() || instance.src_pad().mode() == gst::PadMode::Pull) { panic!("Buffer lists can only be returned in push mode"); } if buffer_ptr.is_null() && pending_buffer_list.is_none() { gst::error!( gst::CAT_RUST, obj = instance, "No buffer and no buffer list returned" ); return Err(gst::FlowError::Error); } if !buffer_ptr.is_null() && pending_buffer_list.is_some() { gst::error!( gst::CAT_RUST, obj = instance, "Both buffer and buffer list returned" ); return Err(gst::FlowError::Error); } if let Some(passed_buffer) = buffer { if buffer_ptr != orig_buffer_ptr { let new_buffer = gst::Buffer::from_glib_full(buffer_ptr); gst::debug!( gst::CAT_PERFORMANCE, obj = instance, "Returned new buffer from parent create function, copying into passed buffer" ); let mut map = match passed_buffer.map_writable() { Ok(map) => map, Err(_) => { gst::error!( gst::CAT_RUST, obj = instance, "Failed to map passed buffer writable" ); return Err(gst::FlowError::Error); } }; let copied_size = new_buffer.copy_to_slice(0, &mut map); drop(map); if let Err(copied_size) = copied_size { passed_buffer.set_size(copied_size); } match new_buffer.copy_into(passed_buffer, gst::BUFFER_COPY_METADATA, ..) { Ok(_) => Ok(CreateSuccess::FilledBuffer), Err(_) => { gst::error!( gst::CAT_RUST, obj = instance, "Failed to copy buffer metadata" ); Err(gst::FlowError::Error) } } } else { Ok(CreateSuccess::FilledBuffer) } } else if let Some(buffer_list) = pending_buffer_list { Ok(CreateSuccess::NewBufferList(buffer_list)) } else { Ok(CreateSuccess::NewBuffer(from_glib_full(buffer_ptr))) } }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } fn parent_do_seek(&self, segment: &mut gst::Segment) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .do_seek .map(|f| { from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, segment.to_glib_none_mut().0, )) }) .unwrap_or(false) } } fn parent_query(&self, query: &mut gst::QueryRef) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .query .map(|f| { from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, query.as_mut_ptr(), )) }) .unwrap_or(false) } } fn parent_event(&self, event: &gst::Event) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .event .map(|f| { from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, event.to_glib_none().0, )) }) .unwrap_or(false) } } fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .get_caps .map(|f| { from_glib_full(f( self.obj().unsafe_cast_ref::().to_glib_none().0, filter.to_glib_none().0, )) }) .unwrap_or(None) } } fn parent_negotiate(&self) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .negotiate .map(|f| { gst::result_from_gboolean!( f(self.obj().unsafe_cast_ref::().to_glib_none().0), gst::CAT_RUST, "Parent function `negotiate` failed" ) }) .unwrap_or(Ok(())) } } fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .set_caps .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.to_glib_none().0 ), gst::CAT_RUST, "Parent function `set_caps` failed" ) }) .unwrap_or(Ok(())) } } fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; match (*parent_class).fixate { Some(fixate) => from_glib_full(fixate( self.obj().unsafe_cast_ref::().to_glib_none().0, caps.into_glib_ptr(), )), None => caps, } } } fn parent_unlock(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .unlock .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::Failed, ["Parent function `unlock` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .unlock_stop .map(|f| { if from_glib(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::Failed, ["Parent function `unlock_stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_decide_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass; (*parent_class) .decide_allocation .map(|f| { gst::result_from_gboolean!( f( self.obj().unsafe_cast_ref::().to_glib_none().0, query.as_mut_ptr(), ), gst::CAT_RUST, "Parent function `decide_allocation` failed", ) }) .unwrap_or(Ok(())) } } } impl BaseSrcImplExt for T {} unsafe impl IsSubclassable for BaseSrc { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.start = Some(base_src_start::); klass.stop = Some(base_src_stop::); klass.is_seekable = Some(base_src_is_seekable::); klass.get_size = Some(base_src_get_size::); klass.get_times = Some(base_src_get_times::); klass.fill = Some(base_src_fill::); klass.alloc = Some(base_src_alloc::); klass.create = Some(base_src_create::); klass.do_seek = Some(base_src_do_seek::); klass.query = Some(base_src_query::); klass.event = Some(base_src_event::); klass.get_caps = Some(base_src_get_caps::); klass.negotiate = Some(base_src_negotiate::); klass.set_caps = Some(base_src_set_caps::); klass.fixate = Some(base_src_fixate::); klass.unlock = Some(base_src_unlock::); klass.unlock_stop = Some(base_src_unlock_stop::); klass.decide_allocation = Some(base_src_decide_allocation::); } fn instance_init(instance: &mut glib::subclass::InitializingObject) { Self::parent_instance_init(instance); instance.set_instance_data(BaseSrc::static_type(), InstanceData::default()); } } unsafe extern "C" fn base_src_start( ptr: *mut ffi::GstBaseSrc, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.start() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_src_stop( ptr: *mut ffi::GstBaseSrc, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_src_is_seekable( ptr: *mut ffi::GstBaseSrc, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.is_seekable() }).into_glib() } unsafe extern "C" fn base_src_get_size( ptr: *mut ffi::GstBaseSrc, size: *mut u64, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.size() { Some(s) => { *size = s; true } None => false, } }) .into_glib() } unsafe extern "C" fn base_src_get_times( ptr: *mut ffi::GstBaseSrc, buffer: *mut gst::ffi::GstBuffer, start: *mut gst::ffi::GstClockTime, stop: *mut gst::ffi::GstClockTime, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let buffer = gst::BufferRef::from_ptr(buffer); *start = gst::ffi::GST_CLOCK_TIME_NONE; *stop = gst::ffi::GST_CLOCK_TIME_NONE; gst::panic_to_error!(imp, (), { let (start_, stop_) = imp.times(buffer); *start = start_.into_glib(); *stop = stop_.into_glib(); }); } unsafe extern "C" fn base_src_fill( ptr: *mut ffi::GstBaseSrc, offset: u64, length: u32, buffer: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let buffer = gst::BufferRef::from_mut_ptr(buffer); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.fill(offset, length, buffer).into() }) .into_glib() } unsafe extern "C" fn base_src_alloc( ptr: *mut ffi::GstBaseSrc, offset: u64, length: u32, buffer_ptr: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; gst::panic_to_error!(imp, gst::FlowReturn::Error, { match imp.alloc(offset, length) { Ok(buffer) => { *buffer_ptr = buffer.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => gst::FlowReturn::from(err), } }) .into_glib() } #[allow(clippy::needless_option_as_deref)] unsafe extern "C" fn base_src_create( ptr: *mut ffi::GstBaseSrc, offset: u64, length: u32, buffer_ptr: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let instance = imp.obj(); let instance = instance.unsafe_cast_ref::(); // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; let mut buffer = if (*buffer_ptr).is_null() { None } else { Some(gst::BufferRef::from_mut_ptr(*buffer_ptr)) }; let instance_data = imp .instance_data::(BaseSrc::static_type()) .unwrap(); // If there is a pending buffer list at this point then unset it. if instance.type_() == T::Type::static_type() { *instance_data.pending_buffer_list.borrow_mut() = None; } let res = gst::panic_to_error!(imp, gst::FlowReturn::Error, { match imp.create(offset, buffer.as_deref_mut(), length) { Ok(CreateSuccess::NewBuffer(new_buffer)) => { if let Some(passed_buffer) = buffer { if passed_buffer.as_ptr() != new_buffer.as_ptr() { gst::debug!( gst::CAT_PERFORMANCE, obj = instance, "Returned new buffer from create function, copying into passed buffer" ); let mut map = match passed_buffer.map_writable() { Ok(map) => map, Err(_) => { gst::error!( gst::CAT_RUST, obj = instance, "Failed to map passed buffer writable" ); return gst::FlowReturn::Error; } }; let copied_size = new_buffer.copy_to_slice(0, &mut map); drop(map); if let Err(copied_size) = copied_size { passed_buffer.set_size(copied_size); } match new_buffer.copy_into(passed_buffer, gst::BUFFER_COPY_METADATA, ..) { Ok(_) => gst::FlowReturn::Ok, Err(_) => { gst::error!( gst::CAT_RUST, obj = instance, "Failed to copy buffer metadata" ); gst::FlowReturn::Error } } } else { gst::FlowReturn::Ok } } else { *buffer_ptr = new_buffer.into_glib_ptr(); gst::FlowReturn::Ok } } Ok(CreateSuccess::NewBufferList(new_buffer_list)) => { if buffer.is_some() || instance.src_pad().mode() == gst::PadMode::Pull { panic!("Buffer lists can only be returned in push mode"); } *buffer_ptr = ptr::null_mut(); // If this is the final type then submit the buffer list. This can only be done // once so can only really be done here. // FIXME: This won't work if a non-Rust subclass of a Rust subclass is created. if instance.type_() == T::Type::static_type() { ffi::gst_base_src_submit_buffer_list( instance.to_glib_none().0, new_buffer_list.into_glib_ptr(), ); } else { *instance_data.pending_buffer_list.borrow_mut() = Some(new_buffer_list); } gst::FlowReturn::Ok } Ok(CreateSuccess::FilledBuffer) => gst::FlowReturn::Ok, Err(err) => gst::FlowReturn::from(err), } }) .into_glib(); // If there is a pending buffer list at this point then unset it. if instance.type_() == T::Type::static_type() { *instance_data.pending_buffer_list.borrow_mut() = None; } res } unsafe extern "C" fn base_src_do_seek( ptr: *mut ffi::GstBaseSrc, segment: *mut gst::ffi::GstSegment, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { let mut s = from_glib_none(segment); let res = imp.do_seek(&mut s); ptr::write(segment, *(s.to_glib_none().0)); res }) .into_glib() } unsafe extern "C" fn base_src_query( ptr: *mut ffi::GstBaseSrc, query_ptr: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let query = gst::QueryRef::from_mut_ptr(query_ptr); gst::panic_to_error!(imp, false, { BaseSrcImpl::query(imp, query) }).into_glib() } unsafe extern "C" fn base_src_event( ptr: *mut ffi::GstBaseSrc, event_ptr: *mut gst::ffi::GstEvent, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.event(&from_glib_borrow(event_ptr)) }).into_glib() } unsafe extern "C" fn base_src_get_caps( ptr: *mut ffi::GstBaseSrc, filter: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let filter = Option::::from_glib_borrow(filter); gst::panic_to_error!(imp, None, { imp.caps(filter.as_ref().as_ref()) }) .map(|caps| caps.into_glib_ptr()) .unwrap_or(ptr::null_mut()) } unsafe extern "C" fn base_src_negotiate( ptr: *mut ffi::GstBaseSrc, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.negotiate() { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_src_set_caps( ptr: *mut ffi::GstBaseSrc, caps: *mut gst::ffi::GstCaps, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let caps = from_glib_borrow(caps); gst::panic_to_error!(imp, false, { match imp.set_caps(&caps) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_src_fixate( ptr: *mut ffi::GstBaseSrc, caps: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let caps = from_glib_full(caps); gst::panic_to_error!(imp, gst::Caps::new_empty(), { imp.fixate(caps) }).into_glib_ptr() } unsafe extern "C" fn base_src_unlock( ptr: *mut ffi::GstBaseSrc, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.unlock() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_src_unlock_stop( ptr: *mut ffi::GstBaseSrc, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.unlock_stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_src_decide_allocation( ptr: *mut ffi::GstBaseSrc, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { gst::QueryViewMut::Allocation(allocation) => allocation, _ => unreachable!(), }; gst::panic_to_error!(imp, false, { match imp.decide_allocation(query) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } gstreamer-base-0.24.0/src/subclass/base_transform.rs000064400000000000000000001335541046102023000206040ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr}; use glib::translate::*; use gst::subclass::prelude::*; use crate::{ffi, prelude::*, BaseTransform}; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum BaseTransformMode { AlwaysInPlace, NeverInPlace, Both, } pub trait BaseTransformImpl: ElementImpl + ObjectSubclass> { const MODE: BaseTransformMode; const PASSTHROUGH_ON_SAME_CAPS: bool; const TRANSFORM_IP_ON_PASSTHROUGH: bool; fn start(&self) -> Result<(), gst::ErrorMessage> { self.parent_start() } fn stop(&self) -> Result<(), gst::ErrorMessage> { self.parent_stop() } fn transform_caps( &self, direction: gst::PadDirection, caps: &gst::Caps, filter: Option<&gst::Caps>, ) -> Option { self.parent_transform_caps(direction, caps, filter) } fn fixate_caps( &self, direction: gst::PadDirection, caps: &gst::Caps, othercaps: gst::Caps, ) -> gst::Caps { self.parent_fixate_caps(direction, caps, othercaps) } fn set_caps(&self, incaps: &gst::Caps, outcaps: &gst::Caps) -> Result<(), gst::LoggableError> { self.parent_set_caps(incaps, outcaps) } fn accept_caps(&self, direction: gst::PadDirection, caps: &gst::Caps) -> bool { self.parent_accept_caps(direction, caps) } fn query(&self, direction: gst::PadDirection, query: &mut gst::QueryRef) -> bool { BaseTransformImplExt::parent_query(self, direction, query) } fn transform_size( &self, direction: gst::PadDirection, caps: &gst::Caps, size: usize, othercaps: &gst::Caps, ) -> Option { self.parent_transform_size(direction, caps, size, othercaps) } fn unit_size(&self, caps: &gst::Caps) -> Option { self.parent_unit_size(caps) } fn sink_event(&self, event: gst::Event) -> bool { self.parent_sink_event(event) } fn src_event(&self, event: gst::Event) -> bool { self.parent_src_event(event) } fn prepare_output_buffer( &self, inbuf: InputBuffer, ) -> Result { self.parent_prepare_output_buffer(inbuf) } fn transform( &self, inbuf: &gst::Buffer, outbuf: &mut gst::BufferRef, ) -> Result { self.parent_transform(inbuf, outbuf) } fn transform_ip(&self, buf: &mut gst::BufferRef) -> Result { self.parent_transform_ip(buf) } fn transform_ip_passthrough( &self, buf: &gst::Buffer, ) -> Result { self.parent_transform_ip_passthrough(buf) } fn propose_allocation( &self, decide_query: Option<&gst::query::Allocation>, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { self.parent_propose_allocation(decide_query, query) } fn decide_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { self.parent_decide_allocation(query) } fn copy_metadata( &self, inbuf: &gst::BufferRef, outbuf: &mut gst::BufferRef, ) -> Result<(), gst::LoggableError> { self.parent_copy_metadata(inbuf, outbuf) } fn transform_meta<'a>( &self, outbuf: &mut gst::BufferRef, meta: gst::MetaRef<'a, gst::Meta>, inbuf: &'a gst::BufferRef, ) -> bool { self.parent_transform_meta(outbuf, meta, inbuf) } fn before_transform(&self, inbuf: &gst::BufferRef) { self.parent_before_transform(inbuf); } fn submit_input_buffer( &self, is_discont: bool, inbuf: gst::Buffer, ) -> Result { self.parent_submit_input_buffer(is_discont, inbuf) } fn generate_output(&self) -> Result { self.parent_generate_output() } } pub trait BaseTransformImplExt: BaseTransformImpl { fn parent_start(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .start .map(|f| { if from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `start` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_stop(&self) -> Result<(), gst::ErrorMessage> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .stop .map(|f| { if from_glib(f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0)) { Ok(()) } else { Err(gst::error_msg!( gst::CoreError::StateChange, ["Parent function `stop` failed"] )) } }) .unwrap_or(Ok(())) } } fn parent_transform_caps( &self, direction: gst::PadDirection, caps: &gst::Caps, filter: Option<&gst::Caps>, ) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .transform_caps .map(|f| { from_glib_full(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, direction.into_glib(), caps.to_glib_none().0, filter.to_glib_none().0, )) }) .unwrap_or(None) } } fn parent_fixate_caps( &self, direction: gst::PadDirection, caps: &gst::Caps, othercaps: gst::Caps, ) -> gst::Caps { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; match (*parent_class).fixate_caps { Some(f) => from_glib_full(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, direction.into_glib(), caps.to_glib_none().0, othercaps.into_glib_ptr(), )), None => othercaps, } } } fn parent_set_caps( &self, incaps: &gst::Caps, outcaps: &gst::Caps, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .set_caps .map(|f| { gst::result_from_gboolean!( f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, incaps.to_glib_none().0, outcaps.to_glib_none().0, ), gst::CAT_RUST, "Parent function `set_caps` failed" ) }) .unwrap_or(Ok(())) } } fn parent_accept_caps(&self, direction: gst::PadDirection, caps: &gst::Caps) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .accept_caps .map(|f| { from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, direction.into_glib(), caps.to_glib_none().0, )) }) .unwrap_or(false) } } fn parent_query(&self, direction: gst::PadDirection, query: &mut gst::QueryRef) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .query .map(|f| { from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, direction.into_glib(), query.as_mut_ptr(), )) }) .unwrap_or(false) } } fn parent_transform_size( &self, direction: gst::PadDirection, caps: &gst::Caps, size: usize, othercaps: &gst::Caps, ) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .transform_size .map(|f| { let mut othersize = mem::MaybeUninit::uninit(); let res: bool = from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, direction.into_glib(), caps.to_glib_none().0, size, othercaps.to_glib_none().0, othersize.as_mut_ptr(), )); if res { Some(othersize.assume_init()) } else { None } }) .unwrap_or(None) } } fn parent_unit_size(&self, caps: &gst::Caps) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; let f = (*parent_class).get_unit_size.unwrap_or_else(|| { if !self.obj().unsafe_cast_ref::().is_in_place() { unimplemented!(concat!( "Missing parent function `get_unit_size`. Required because ", "transform doesn't operate in-place" )) } else { unreachable!(concat!( "parent `get_unit_size` called while transform operates in-place" )) } }); let mut size = mem::MaybeUninit::uninit(); if from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, caps.to_glib_none().0, size.as_mut_ptr(), )) { Some(size.assume_init()) } else { None } } } fn parent_sink_event(&self, event: gst::Event) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .sink_event .map(|f| { from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, event.into_glib_ptr(), )) }) .unwrap_or(true) } } fn parent_src_event(&self, event: gst::Event) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .src_event .map(|f| { from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, event.into_glib_ptr(), )) }) .unwrap_or(true) } } fn parent_prepare_output_buffer( &self, inbuf: InputBuffer, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; let buf = match inbuf { InputBuffer::Readable(inbuf_r) => inbuf_r.as_ptr(), InputBuffer::Writable(inbuf_w) => inbuf_w.as_mut_ptr(), }; (*parent_class) .prepare_output_buffer .map(|f| { let mut outbuf: *mut gst::ffi::GstBuffer = ptr::null_mut(); // FIXME: Wrong signature in FFI gst::FlowSuccess::try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, buf as *mut gst::ffi::GstBuffer, (&mut outbuf) as *mut *mut gst::ffi::GstBuffer as *mut gst::ffi::GstBuffer, )) .map(|_| { if ptr::eq(outbuf, buf as *mut _) { PrepareOutputBufferSuccess::InputBuffer } else { PrepareOutputBufferSuccess::Buffer(from_glib_full(outbuf)) } }) .inspect_err(|_err| { if !ptr::eq(outbuf, buf as *mut _) { drop(Option::::from_glib_full(outbuf)); } }) }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } fn parent_transform( &self, inbuf: &gst::Buffer, outbuf: &mut gst::BufferRef, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .transform .map(|f| { try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, inbuf.to_glib_none().0, outbuf.as_mut_ptr(), )) }) .unwrap_or_else(|| { if !self.obj().unsafe_cast_ref::().is_in_place() { Err(gst::FlowError::NotSupported) } else { unreachable!(concat!( "parent `transform` called while transform operates in-place" )); } }) } } fn parent_transform_ip( &self, buf: &mut gst::BufferRef, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; let f = (*parent_class).transform_ip.unwrap_or_else(|| { if self.obj().unsafe_cast_ref::().is_in_place() { panic!(concat!( "Missing parent function `transform_ip`. Required because ", "transform operates in-place" )); } else { unreachable!(concat!( "parent `transform` called while transform doesn't operate in-place" )); } }); try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, buf.as_mut_ptr() as *mut _, )) } } fn parent_transform_ip_passthrough( &self, buf: &gst::Buffer, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; let f = (*parent_class).transform_ip.unwrap_or_else(|| { if self.obj().unsafe_cast_ref::().is_in_place() { panic!(concat!( "Missing parent function `transform_ip`. Required because ", "transform operates in-place (passthrough mode)" )); } else { unreachable!(concat!( "parent `transform_ip` called ", "while transform doesn't operate in-place (passthrough mode)" )); } }); // FIXME: Wrong signature in FFI let buf: *mut gst::ffi::GstBuffer = buf.to_glib_none().0; try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, buf as *mut _, )) } } fn parent_propose_allocation( &self, decide_query: Option<&gst::query::Allocation>, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .propose_allocation .map(|f| { gst::result_from_gboolean!( f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, decide_query .as_ref() .map(|q| q.as_mut_ptr()) .unwrap_or(ptr::null_mut()), query.as_mut_ptr(), ), gst::CAT_RUST, "Parent function `propose_allocation` failed", ) }) .unwrap_or(Ok(())) } } fn parent_decide_allocation( &self, query: &mut gst::query::Allocation, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .decide_allocation .map(|f| { gst::result_from_gboolean!( f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, query.as_mut_ptr(), ), gst::CAT_RUST, "Parent function `decide_allocation` failed," ) }) .unwrap_or(Ok(())) } } fn parent_copy_metadata( &self, inbuf: &gst::BufferRef, outbuf: &mut gst::BufferRef, ) -> Result<(), gst::LoggableError> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; if let Some(ref f) = (*parent_class).copy_metadata { gst::result_from_gboolean!( f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, inbuf.as_ptr() as *mut _, outbuf.as_mut_ptr() ), gst::CAT_RUST, "Parent function `copy_metadata` failed" ) } else { Ok(()) } } } fn parent_transform_meta<'a>( &self, outbuf: &mut gst::BufferRef, meta: gst::MetaRef<'a, gst::Meta>, inbuf: &'a gst::BufferRef, ) -> bool { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; (*parent_class) .transform_meta .map(|f| { from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, outbuf.as_mut_ptr(), meta.as_ptr() as *mut _, inbuf.as_ptr() as *mut _, )) }) .unwrap_or(false) } } fn parent_before_transform(&self, inbuf: &gst::BufferRef) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; if let Some(ref f) = (*parent_class).before_transform { f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, inbuf.as_ptr() as *mut _, ); } } } fn parent_submit_input_buffer( &self, is_discont: bool, inbuf: gst::Buffer, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; let f = (*parent_class) .submit_input_buffer .expect("Missing parent function `submit_input_buffer`"); try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, is_discont.into_glib(), inbuf.into_glib_ptr(), )) } } fn parent_generate_output(&self) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseTransformClass; let f = (*parent_class) .generate_output .expect("Missing parent function `generate_output`"); let mut outbuf = ptr::null_mut(); let res = gst::FlowSuccess::try_from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, &mut outbuf, )); let outbuf = Option::::from_glib_full(outbuf); res.map(move |res| match (res, outbuf) { (crate::BASE_TRANSFORM_FLOW_DROPPED, _) => GenerateOutputSuccess::Dropped, (gst::FlowSuccess::Ok, Some(outbuf)) => GenerateOutputSuccess::Buffer(outbuf), _ => GenerateOutputSuccess::NoOutput, }) } } fn take_queued_buffer(&self) -> Option where Self: ObjectSubclass, ::ParentType: IsA, { unsafe { let instance = self.obj(); let ptr: *mut ffi::GstBaseTransform = instance.unsafe_cast_ref::().to_glib_none().0; let sinkpad: Borrowed = from_glib_borrow((*ptr).sinkpad); let _stream_lock = sinkpad.stream_lock(); let buffer = (*ptr).queued_buf; (*ptr).queued_buf = ptr::null_mut(); from_glib_full(buffer) } } fn queued_buffer(&self) -> Option where Self: ObjectSubclass, ::ParentType: IsA, { unsafe { let instance = self.obj(); let ptr: *mut ffi::GstBaseTransform = instance.unsafe_cast_ref::().to_glib_none().0; let sinkpad: Borrowed = from_glib_borrow((*ptr).sinkpad); let _stream_lock = sinkpad.stream_lock(); let buffer = (*ptr).queued_buf; from_glib_none(buffer) } } } impl BaseTransformImplExt for T {} unsafe impl IsSubclassable for BaseTransform { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.start = Some(base_transform_start::); klass.stop = Some(base_transform_stop::); klass.transform_caps = Some(base_transform_transform_caps::); klass.fixate_caps = Some(base_transform_fixate_caps::); klass.set_caps = Some(base_transform_set_caps::); klass.accept_caps = Some(base_transform_accept_caps::); klass.query = Some(base_transform_query::); klass.transform_size = Some(base_transform_transform_size::); klass.get_unit_size = Some(base_transform_get_unit_size::); klass.prepare_output_buffer = Some(base_transform_prepare_output_buffer::); klass.sink_event = Some(base_transform_sink_event::); klass.src_event = Some(base_transform_src_event::); klass.transform_meta = Some(base_transform_transform_meta::); klass.propose_allocation = Some(base_transform_propose_allocation::); klass.decide_allocation = Some(base_transform_decide_allocation::); klass.copy_metadata = Some(base_transform_copy_metadata::); klass.before_transform = Some(base_transform_before_transform::); klass.submit_input_buffer = Some(base_transform_submit_input_buffer::); klass.generate_output = Some(base_transform_generate_output::); klass.passthrough_on_same_caps = T::PASSTHROUGH_ON_SAME_CAPS.into_glib(); klass.transform_ip_on_passthrough = T::TRANSFORM_IP_ON_PASSTHROUGH.into_glib(); match T::MODE { BaseTransformMode::AlwaysInPlace => { klass.transform = None; klass.transform_ip = Some(base_transform_transform_ip::); } BaseTransformMode::NeverInPlace => { klass.transform = Some(base_transform_transform::); klass.transform_ip = None; } BaseTransformMode::Both => { klass.transform = Some(base_transform_transform::); klass.transform_ip = Some(base_transform_transform_ip::); } } } } #[derive(Debug)] pub enum GenerateOutputSuccess { Buffer(gst::Buffer), NoOutput, Dropped, } #[derive(Debug)] pub enum PrepareOutputBufferSuccess { Buffer(gst::Buffer), InputBuffer, } #[derive(Debug)] pub enum InputBuffer<'a> { Writable(&'a mut gst::BufferRef), Readable(&'a gst::BufferRef), } unsafe extern "C" fn base_transform_start( ptr: *mut ffi::GstBaseTransform, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.start() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_transform_stop( ptr: *mut ffi::GstBaseTransform, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.stop() { Ok(()) => true, Err(err) => { imp.post_error_message(err); false } } }) .into_glib() } unsafe extern "C" fn base_transform_transform_caps( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, filter: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, None, { let filter: Borrowed> = from_glib_borrow(filter); imp.transform_caps( from_glib(direction), &from_glib_borrow(caps), filter.as_ref().as_ref(), ) }) .map(|caps| caps.into_glib_ptr()) .unwrap_or(std::ptr::null_mut()) } unsafe extern "C" fn base_transform_fixate_caps( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, othercaps: *mut gst::ffi::GstCaps, ) -> *mut gst::ffi::GstCaps { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::Caps::new_empty(), { imp.fixate_caps( from_glib(direction), &from_glib_borrow(caps), from_glib_full(othercaps), ) }) .into_glib_ptr() } unsafe extern "C" fn base_transform_set_caps( ptr: *mut ffi::GstBaseTransform, incaps: *mut gst::ffi::GstCaps, outcaps: *mut gst::ffi::GstCaps, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.set_caps(&from_glib_borrow(incaps), &from_glib_borrow(outcaps)) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_transform_accept_caps( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.accept_caps(from_glib(direction), &from_glib_borrow(caps)) }) .into_glib() } unsafe extern "C" fn base_transform_query( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { BaseTransformImpl::query( imp, from_glib(direction), gst::QueryRef::from_mut_ptr(query), ) }) .into_glib() } unsafe extern "C" fn base_transform_transform_size( ptr: *mut ffi::GstBaseTransform, direction: gst::ffi::GstPadDirection, caps: *mut gst::ffi::GstCaps, size: usize, othercaps: *mut gst::ffi::GstCaps, othersize: *mut usize, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.transform_size( from_glib(direction), &from_glib_borrow(caps), size, &from_glib_borrow(othercaps), ) { Some(s) => { *othersize = s; true } None => false, } }) .into_glib() } unsafe extern "C" fn base_transform_get_unit_size( ptr: *mut ffi::GstBaseTransform, caps: *mut gst::ffi::GstCaps, size: *mut usize, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { match imp.unit_size(&from_glib_borrow(caps)) { Some(s) => { *size = s; true } None => false, } }) .into_glib() } unsafe extern "C" fn base_transform_prepare_output_buffer( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, outbuf: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); // FIXME: Wrong signature in FFI let outbuf = outbuf as *mut *mut gst::ffi::GstBuffer; let is_passthrough: bool = from_glib(ffi::gst_base_transform_is_passthrough(ptr)); let is_in_place: bool = from_glib(ffi::gst_base_transform_is_in_place(ptr)); let writable = is_in_place && !is_passthrough && gst::ffi::gst_mini_object_is_writable(inbuf as *mut _) != glib::ffi::GFALSE; let buffer = match writable { false => InputBuffer::Readable(gst::BufferRef::from_ptr(inbuf)), true => InputBuffer::Writable(gst::BufferRef::from_mut_ptr(inbuf)), }; *outbuf = ptr::null_mut(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { match imp.prepare_output_buffer(buffer) { Ok(PrepareOutputBufferSuccess::InputBuffer) => { assert!( is_passthrough || is_in_place, "Returning InputBuffer only allowed for passthrough or in-place mode" ); *outbuf = inbuf; gst::FlowReturn::Ok } Ok(PrepareOutputBufferSuccess::Buffer(buf)) => { assert!( !is_passthrough, "Returning Buffer not allowed for passthrough mode" ); *outbuf = buf.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => err.into(), } }) .into_glib() } unsafe extern "C" fn base_transform_sink_event( ptr: *mut ffi::GstBaseTransform, event: *mut gst::ffi::GstEvent, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.sink_event(from_glib_full(event)) }).into_glib() } unsafe extern "C" fn base_transform_src_event( ptr: *mut ffi::GstBaseTransform, event: *mut gst::ffi::GstEvent, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib() } unsafe extern "C" fn base_transform_transform( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, outbuf: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.transform( &from_glib_borrow(inbuf), gst::BufferRef::from_mut_ptr(outbuf), ) .into() }) .into_glib() } unsafe extern "C" fn base_transform_transform_ip( ptr: *mut ffi::GstBaseTransform, buf: *mut *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); // FIXME: Wrong signature in FFI let buf = buf as *mut gst::ffi::GstBuffer; gst::panic_to_error!(imp, gst::FlowReturn::Error, { if from_glib(ffi::gst_base_transform_is_passthrough(ptr)) { imp.transform_ip_passthrough(&from_glib_borrow(buf)).into() } else { imp.transform_ip(gst::BufferRef::from_mut_ptr(buf)).into() } }) .into_glib() } unsafe extern "C" fn base_transform_transform_meta( ptr: *mut ffi::GstBaseTransform, outbuf: *mut gst::ffi::GstBuffer, meta: *mut gst::ffi::GstMeta, inbuf: *mut gst::ffi::GstBuffer, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let inbuf = gst::BufferRef::from_ptr(inbuf); gst::panic_to_error!(imp, false, { imp.transform_meta( gst::BufferRef::from_mut_ptr(outbuf), gst::Meta::from_ptr(inbuf, meta), inbuf, ) }) .into_glib() } unsafe extern "C" fn base_transform_propose_allocation( ptr: *mut ffi::GstBaseTransform, decide_query: *mut gst::ffi::GstQuery, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let decide_query = if decide_query.is_null() { None } else { match gst::QueryRef::from_ptr(decide_query).view() { gst::QueryView::Allocation(allocation) => Some(allocation), _ => unreachable!(), } }; let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { gst::QueryViewMut::Allocation(allocation) => allocation, _ => unreachable!(), }; gst::panic_to_error!(imp, false, { match imp.propose_allocation(decide_query, query) { Ok(()) => true, Err(err) => { err.log_with_imp_and_level(imp, gst::DebugLevel::Info); false } } }) .into_glib() } unsafe extern "C" fn base_transform_decide_allocation( ptr: *mut ffi::GstBaseTransform, query: *mut gst::ffi::GstQuery, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let query = match gst::QueryRef::from_mut_ptr(query).view_mut() { gst::QueryViewMut::Allocation(allocation) => allocation, _ => unreachable!(), }; gst::panic_to_error!(imp, false, { match imp.decide_allocation(query) { Ok(()) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_transform_copy_metadata( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, outbuf: *mut gst::ffi::GstBuffer, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); if gst::ffi::gst_mini_object_is_writable(outbuf as *mut _) == glib::ffi::GFALSE { let instance = imp.obj(); let obj = instance.unsafe_cast_ref::(); gst::warning!(gst::CAT_RUST, obj = obj, "buffer {:?} not writable", outbuf); return glib::ffi::GFALSE; } gst::panic_to_error!(imp, true, { match imp.copy_metadata( gst::BufferRef::from_ptr(inbuf), gst::BufferRef::from_mut_ptr(outbuf), ) { Ok(_) => true, Err(err) => { err.log_with_imp(imp); false } } }) .into_glib() } unsafe extern "C" fn base_transform_before_transform( ptr: *mut ffi::GstBaseTransform, inbuf: *mut gst::ffi::GstBuffer, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, (), { imp.before_transform(gst::BufferRef::from_ptr(inbuf)); }) } unsafe extern "C" fn base_transform_submit_input_buffer( ptr: *mut ffi::GstBaseTransform, is_discont: glib::ffi::gboolean, buf: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.submit_input_buffer(from_glib(is_discont), from_glib_full(buf)) .into() }) .into_glib() } unsafe extern "C" fn base_transform_generate_output( ptr: *mut ffi::GstBaseTransform, buf: *mut *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); *buf = ptr::null_mut(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { match imp.generate_output() { Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(), Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok, Ok(GenerateOutputSuccess::Buffer(outbuf)) => { *buf = outbuf.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => err.into(), } }) .into_glib() } #[cfg(test)] mod tests { use super::*; pub mod imp { use super::*; use std::sync::atomic::{self, AtomicBool}; #[derive(Default)] pub struct TestTransform { drop_next: AtomicBool, } #[glib::object_subclass] impl ObjectSubclass for TestTransform { const NAME: &'static str = "TestTransform"; type Type = super::TestTransform; type ParentType = crate::BaseTransform; } impl ObjectImpl for TestTransform {} impl GstObjectImpl for TestTransform {} impl ElementImpl for TestTransform { fn metadata() -> Option<&'static gst::subclass::ElementMetadata> { static ELEMENT_METADATA: std::sync::OnceLock = std::sync::OnceLock::new(); Some(ELEMENT_METADATA.get_or_init(|| { gst::subclass::ElementMetadata::new( "Test Transform", "Generic", "Does nothing", "Sebastian Dröge ", ) })) } fn pad_templates() -> &'static [gst::PadTemplate] { static PAD_TEMPLATES: std::sync::OnceLock> = std::sync::OnceLock::new(); PAD_TEMPLATES.get_or_init(|| { let caps = gst::Caps::new_any(); vec![ gst::PadTemplate::new( "src", gst::PadDirection::Src, gst::PadPresence::Always, &caps, ) .unwrap(), gst::PadTemplate::new( "sink", gst::PadDirection::Sink, gst::PadPresence::Always, &caps, ) .unwrap(), ] }) } } impl BaseTransformImpl for TestTransform { const MODE: BaseTransformMode = BaseTransformMode::AlwaysInPlace; const PASSTHROUGH_ON_SAME_CAPS: bool = false; const TRANSFORM_IP_ON_PASSTHROUGH: bool = false; fn transform_ip( &self, _buf: &mut gst::BufferRef, ) -> Result { if self.drop_next.load(atomic::Ordering::SeqCst) { self.drop_next.store(false, atomic::Ordering::SeqCst); Ok(crate::BASE_TRANSFORM_FLOW_DROPPED) } else { self.drop_next.store(true, atomic::Ordering::SeqCst); Ok(gst::FlowSuccess::Ok) } } } } glib::wrapper! { pub struct TestTransform(ObjectSubclass) @extends crate::BaseTransform, gst::Element, gst::Object; } impl TestTransform { pub fn new(name: Option<&str>) -> Self { glib::Object::builder().property("name", name).build() } } #[test] fn test_transform_subclass() { gst::init().unwrap(); let element = TestTransform::new(Some("test")); assert_eq!(element.name(), "test"); let pipeline = gst::Pipeline::new(); let src = gst::ElementFactory::make("audiotestsrc") .property("num-buffers", 100i32) .build() .unwrap(); let sink = gst::ElementFactory::make("fakesink").build().unwrap(); pipeline .add_many([&src, element.upcast_ref(), &sink]) .unwrap(); gst::Element::link_many([&src, element.upcast_ref(), &sink]).unwrap(); pipeline.set_state(gst::State::Playing).unwrap(); let bus = pipeline.bus().unwrap(); let eos = bus.timed_pop_filtered(gst::ClockTime::NONE, &[gst::MessageType::Eos]); assert!(eos.is_some()); let stats = sink.property::("stats"); assert_eq!(stats.get::("rendered").unwrap(), 50); pipeline.set_state(gst::State::Null).unwrap(); } } gstreamer-base-0.24.0/src/subclass/mod.rs000064400000000000000000000016201046102023000163420ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #![allow(clippy::cast_ptr_alignment)] mod base_parse; mod base_sink; // Public to namespace CreateSuccess pub mod base_src; // Public to namespace GenerateOutputSuccess and PrepareOutputBufferSuccess, pub mod base_transform; mod push_src; pub use self::base_transform::BaseTransformMode; mod aggregator; mod aggregator_pad; pub mod prelude { #[doc(hidden)] pub use gst::subclass::prelude::*; pub use super::{ aggregator::{AggregatorImpl, AggregatorImplExt}, aggregator_pad::{AggregatorPadImpl, AggregatorPadImplExt}, base_parse::{BaseParseImpl, BaseParseImplExt}, base_sink::{BaseSinkImpl, BaseSinkImplExt}, base_src::{BaseSrcImpl, BaseSrcImplExt}, base_transform::{BaseTransformImpl, BaseTransformImplExt}, push_src::{PushSrcImpl, PushSrcImplExt}, }; } gstreamer-base-0.24.0/src/subclass/push_src.rs000064400000000000000000000315241046102023000174170ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, subclass::prelude::*, translate::*}; use gst::{prelude::*, subclass::prelude::*}; use super::base_src::{BaseSrcImpl, CreateSuccess}; use crate::{ffi, prelude::*, PushSrc}; pub trait PushSrcImpl: BaseSrcImpl + ObjectSubclass> { fn fill(&self, buffer: &mut gst::BufferRef) -> Result { PushSrcImplExt::parent_fill(self, buffer) } fn alloc(&self) -> Result { PushSrcImplExt::parent_alloc(self) } fn create(&self, buffer: Option<&mut gst::BufferRef>) -> Result { PushSrcImplExt::parent_create(self, buffer) } } pub trait PushSrcImplExt: PushSrcImpl { fn parent_fill(&self, buffer: &mut gst::BufferRef) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstPushSrcClass; (*parent_class) .fill .map(|f| { try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer.as_mut_ptr(), )) }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } fn parent_alloc(&self) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstPushSrcClass; (*parent_class) .alloc .map(|f| { let mut buffer_ptr: *mut gst::ffi::GstBuffer = ptr::null_mut(); // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer; gst::FlowSuccess::try_from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer_ref, )) .map(|_| from_glib_full(buffer_ref)) }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } fn parent_create( &self, mut buffer: Option<&mut gst::BufferRef>, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstPushSrcClass; (*parent_class) .create .map(|f| { let instance = self.obj(); let instance = instance.unsafe_cast_ref::(); let orig_buffer_ptr = buffer .as_mut() .map(|b| b.as_mut_ptr()) .unwrap_or(ptr::null_mut()); let mut buffer_ptr = orig_buffer_ptr; // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer; let instance_data = self.instance_data::(crate::BaseSrc::static_type()).unwrap(); if let Err(err) = gst::FlowSuccess::try_from_glib( f( instance.to_glib_none().0, buffer_ref, ) ) { *instance_data.pending_buffer_list.borrow_mut() = None; return Err(err); } let pending_buffer_list = instance_data.pending_buffer_list.borrow_mut().take(); if pending_buffer_list.is_some() && (buffer.is_some() || instance.src_pad().mode() == gst::PadMode::Pull) { panic!("Buffer lists can only be returned in push mode"); } let pending_buffer_list = instance_data.pending_buffer_list.borrow_mut().take(); if buffer_ptr.is_null() && pending_buffer_list.is_none() { gst::error!( gst::CAT_RUST, obj = instance, "No buffer and no buffer list returned" ); return Err(gst::FlowError::Error); } if !buffer_ptr.is_null() && pending_buffer_list.is_some() { gst::error!( gst::CAT_RUST, obj = instance, "Both buffer and buffer list returned" ); return Err(gst::FlowError::Error); } if let Some(passed_buffer) = buffer { if buffer_ptr != orig_buffer_ptr { let new_buffer = gst::Buffer::from_glib_full(buffer_ptr); gst::debug!( gst::CAT_PERFORMANCE, obj = instance, "Returned new buffer from parent create function, copying into passed buffer" ); let mut map = match passed_buffer.map_writable() { Ok(map) => map, Err(_) => { gst::error!( gst::CAT_RUST, obj = instance, "Failed to map passed buffer writable" ); return Err(gst::FlowError::Error); } }; let copied_size = new_buffer.copy_to_slice(0, &mut map); drop(map); if let Err(copied_size) = copied_size { passed_buffer.set_size(copied_size); } match new_buffer.copy_into(passed_buffer, gst::BUFFER_COPY_METADATA, ..) { Ok(_) => Ok(CreateSuccess::FilledBuffer), Err(_) => { gst::error!( gst::CAT_RUST, obj = instance, "Failed to copy buffer metadata" ); Err(gst::FlowError::Error) } } } else { Ok(CreateSuccess::FilledBuffer) } } else if let Some(buffer_list) = pending_buffer_list { Ok(CreateSuccess::NewBufferList(buffer_list)) } else { Ok(CreateSuccess::NewBuffer(from_glib_full(buffer_ptr))) } }) .unwrap_or(Err(gst::FlowError::NotSupported)) } } } impl PushSrcImplExt for T {} unsafe impl IsSubclassable for PushSrc { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); klass.fill = Some(push_src_fill::); klass.alloc = Some(push_src_alloc::); klass.create = Some(push_src_create::); } } unsafe extern "C" fn push_src_fill( ptr: *mut ffi::GstPushSrc, buffer: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let buffer = gst::BufferRef::from_mut_ptr(buffer); gst::panic_to_error!(imp, gst::FlowReturn::Error, { PushSrcImpl::fill(imp, buffer).into() }) .into_glib() } unsafe extern "C" fn push_src_alloc( ptr: *mut ffi::GstPushSrc, buffer_ptr: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; gst::panic_to_error!(imp, gst::FlowReturn::Error, { match PushSrcImpl::alloc(imp) { Ok(buffer) => { *buffer_ptr = buffer.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => gst::FlowReturn::from(err), } }) .into_glib() } #[allow(clippy::needless_option_as_deref)] unsafe extern "C" fn push_src_create( ptr: *mut ffi::GstPushSrc, buffer_ptr: *mut gst::ffi::GstBuffer, ) -> gst::ffi::GstFlowReturn { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); // FIXME: Wrong signature in -sys bindings // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3 let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer; let mut buffer = if (*buffer_ptr).is_null() { None } else { Some(gst::BufferRef::from_mut_ptr(*buffer_ptr)) }; let instance_data = imp .instance_data::(crate::BaseSrc::static_type()) .unwrap(); gst::panic_to_error!(imp, gst::FlowReturn::Error, { match PushSrcImpl::create(imp, buffer.as_deref_mut()) { Ok(CreateSuccess::NewBuffer(new_buffer)) => { // Clear any pending buffer list *instance_data.pending_buffer_list.borrow_mut() = None; if let Some(passed_buffer) = buffer { if passed_buffer.as_ptr() != new_buffer.as_ptr() { gst::debug!( gst::CAT_PERFORMANCE, imp = imp, "Returned new buffer from create function, copying into passed buffer" ); let mut map = match passed_buffer.map_writable() { Ok(map) => map, Err(_) => { gst::error!( gst::CAT_RUST, imp = imp, "Failed to map passed buffer writable" ); return gst::FlowReturn::Error; } }; let copied_size = new_buffer.copy_to_slice(0, &mut map); drop(map); if let Err(copied_size) = copied_size { passed_buffer.set_size(copied_size); } match new_buffer.copy_into(passed_buffer, gst::BUFFER_COPY_METADATA, ..) { Ok(_) => gst::FlowReturn::Ok, Err(_) => { gst::error!( gst::CAT_RUST, imp = imp, "Failed to copy buffer metadata" ); gst::FlowReturn::Error } } } else { gst::FlowReturn::Ok } } else { *buffer_ptr = new_buffer.into_glib_ptr(); gst::FlowReturn::Ok } } Ok(CreateSuccess::NewBufferList(new_buffer_list)) => { if buffer.is_some() || imp.obj().unsafe_cast_ref::().src_pad().mode() == gst::PadMode::Pull { panic!("Buffer lists can only be returned in push mode"); } *buffer_ptr = ptr::null_mut(); // Store it in the instance data so that in the end base_src_create() can // submit it. *instance_data.pending_buffer_list.borrow_mut() = Some(new_buffer_list); gst::FlowReturn::Ok } Ok(CreateSuccess::FilledBuffer) => { // Clear any pending buffer list *instance_data.pending_buffer_list.borrow_mut() = None; gst::FlowReturn::Ok } Err(err) => gst::FlowReturn::from(err), } }) .into_glib() } gstreamer-base-0.24.0/tests/check_gir.rs000064400000000000000000000003461046102023000162410ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[test] fn check_gir_file() { let res = gir_format_check::check_gir_file("Gir.toml"); println!("{res}"); assert_eq!(res.nb_errors, 0); }