Add initial bindings for GStreamer base library

https://github.com/sdroege/gstreamer-rs/issues/7
This commit is contained in:
Sebastian Dröge 2017-09-09 16:54:02 +03:00
parent 3b0e6843e2
commit 160fd103c0
19 changed files with 1863 additions and 0 deletions

View file

@ -4,6 +4,7 @@ members = [
"gstreamer",
"gstreamer-app",
"gstreamer-audio",
"gstreamer-base",
"gstreamer-player",
"gstreamer-video",
"examples",

97
Gir_GstBase.toml Normal file
View file

@ -0,0 +1,97 @@
[options]
girs_dir = "gir-files"
library = "GstBase"
version = "1.0"
min_cfg_version = "1.8"
target_path = "gstreamer-base"
work_mode = "normal"
concurrency = "send+sync"
generate_safety_asserts = true
external_libraries = [
"GLib",
"GObject",
"Gst",
]
generate = [
"GstBase.BaseSrc",
"GstBase.BaseSink",
"GstBase.BaseTransform",
"GstBase.PushSrc",
]
manual = [
"GObject.Object",
"GLib.Bytes",
"Gst.Object",
"Gst.Element",
"Gst.ClockTime",
"Gst.ClockTimeDiff",
"Gst.ClockReturn",
"Gst.FlowReturn",
"Gst.Format",
"Gst.Pad",
]
[[object]]
name = "GstBase.Adapter"
status = "generate"
trait = false
concurrency = "none"
[[object.function]]
name = "map"
# Unsafe
ignore = true
[[object.function]]
name = "unmap"
# Unsafe
ignore = true
[[object.function]]
name = "copy"
# Unsafe
ignore = true
[[object.function]]
name = "push"
# Move Buffer
ignore = true
[[object.function]]
name = "take"
# Useless copying of data
ignore = true
[[object]]
name = "GstBase.FlowCombiner"
status = "generate"
trait = false
concurrency = "none"
[[object]]
name = "Gst.Structure"
status = "manual"
ref_mode = "ref-mut"
[[object]]
name = "Gst.Caps"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Buffer"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.BufferList"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Sample"
status = "manual"
ref_mode = "ref"

View file

@ -0,0 +1,14 @@
# 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.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://github.com/sdroege/gstreamer-rs/compare/0.8.0...HEAD

37
gstreamer-base/Cargo.toml Normal file
View file

@ -0,0 +1,37 @@
[package]
name = "gstreamer-base"
version = "0.9.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
categories = ["api-bindings", "multimedia"]
description = "Rust bindings for GStreamer Base library"
repository = "https://github.com/sdroege/gstreamer-rs"
license = "MIT/Apache-2.0"
readme = "README.md"
homepage = "https://gstreamer.freedesktop.org"
documentation = "https://sdroege.github.io/rustdoc/gstreamer/gstreamer-base"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs"
[dependencies]
bitflags = "0.9"
libc = "0.2"
glib-sys = { git = "https://github.com/gtk-rs/sys" }
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
gstreamer-sys = { git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_8"] }
gstreamer-base-sys = { git = "https://github.com/sdroege/gstreamer-sys", features = ["v1_8"] }
glib = { git = "https://github.com/gtk-rs/glib" }
gstreamer = { path = "../gstreamer" }
[build-dependencies.rustdoc-stripper]
version = "0.1"
optional = true
[features]
v1_10 = ["gstreamer-sys/v1_10", "gstreamer-base-sys/v1_10"]
v1_12 = ["gstreamer-sys/v1_12", "gstreamer-base-sys/v1_12", "v1_10"]
embed-lgpl-docs = ["rustdoc-stripper"]
purge-lgpl-docs = ["rustdoc-stripper"]
default-features = []
[badges]
travis-ci = { repository = "sdroege/gstreamer-rs", branch = "master" }

View file

@ -0,0 +1,201 @@
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.

View file

@ -0,0 +1,23 @@
Permission 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.

40
gstreamer-base/README.md Normal file
View file

@ -0,0 +1,40 @@
# gstreamer-rs [![crates.io](https://img.shields.io/crates/v/gstreamer-app.svg)](https://crates.io/crates/gstreamer-app) [![Build Status](https://travis-ci.org/sdroege/gstreamer-rs.svg?branch=master)](https://travis-ci.org/sdroege/gstreamer-rs)
[GStreamer](https://gstreamer.freedesktop.org/) (Base library) bindings for Rust.
Documentation can be found [here](https://sdroege.github.io/rustdoc/gstreamer/gstreamer/).
These bindings are providing a safe API that can be used to interface with
GStreamer, e.g. for writing GStreamer-based applications.
For background and motivation, see the [announcement blogpost](https://coaxion.net/blog/2017/07/writing-gstreamer-applications-in-rust/).
The bindings (since 0.8.0) are 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. Older versions before 0.8.0 were manually
written and the repository can be found [here](https://github.com/arturoc/gstreamer1.0-rs).
The API of the two is incompatible.
A crate for writing GStreamer plugins in Rust can be found here: https://github.com/sdroege/gst-plugin-rs
## 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.

34
gstreamer-base/build.rs Normal file
View file

@ -0,0 +1,34 @@
fn main() {
manage_docs();
}
#[cfg(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs"))]
fn manage_docs() {
extern crate stripper_lib;
use std::io;
let path = "src";
let ignores: &[&str] = &[];
stripper_lib::loop_over_files(
path.as_ref(),
&mut |w, s| stripper_lib::strip_comments(w, s, &mut io::sink(), true),
&ignores,
false,
);
#[cfg(feature = "embed-lgpl-docs")]
{
let docs = include_str!("../docs/gstreamer-base/docs.md");
let mut infos = stripper_lib::parse_cmts(docs.lines(), true);
stripper_lib::loop_over_files(
path.as_ref(),
&mut |w, s| stripper_lib::regenerate_comments(w, s, &mut infos, true, true),
&ignores,
false,
);
}
}
#[cfg(not(any(feature = "embed-lgpl-docs", feature = "purge-lgpl-docs")))]
fn manage_docs() {}

View file

@ -0,0 +1,32 @@
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ffi;
use glib::translate::*;
use gst;
use Adapter;
impl Adapter {
pub fn copy(&self, offset: usize, dest: &mut [u8]) {
unsafe {
let size = dest.len();
ffi::gst_adapter_copy(
self.to_glib_none().0,
dest.as_mut_ptr() as *mut _,
offset,
size,
);
}
}
pub fn push(&self, buf: gst::Buffer) {
unsafe {
ffi::gst_adapter_push(self.to_glib_none().0, buf.into_ptr());
}
}
}

View file

@ -0,0 +1,194 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct Adapter(Object<ffi::GstAdapter>);
match fn {
get_type => || ffi::gst_adapter_get_type(),
}
}
impl Adapter {
pub fn new() -> Adapter {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_adapter_new())
}
}
pub fn available(&self) -> usize {
unsafe {
ffi::gst_adapter_available(self.to_glib_none().0)
}
}
pub fn available_fast(&self) -> usize {
unsafe {
ffi::gst_adapter_available_fast(self.to_glib_none().0)
}
}
pub fn clear(&self) {
unsafe {
ffi::gst_adapter_clear(self.to_glib_none().0);
}
}
pub fn copy_bytes(&self, offset: usize, size: usize) -> Option<glib::Bytes> {
unsafe {
from_glib_full(ffi::gst_adapter_copy_bytes(self.to_glib_none().0, offset, size))
}
}
pub fn distance_from_discont(&self) -> u64 {
unsafe {
ffi::gst_adapter_distance_from_discont(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_10")]
pub fn dts_at_discont(&self) -> gst::ClockTime {
unsafe {
ffi::gst_adapter_dts_at_discont(self.to_glib_none().0)
}
}
pub fn flush(&self, flush: usize) {
unsafe {
ffi::gst_adapter_flush(self.to_glib_none().0, flush);
}
}
pub fn get_buffer(&self, nbytes: usize) -> Option<gst::Buffer> {
unsafe {
from_glib_full(ffi::gst_adapter_get_buffer(self.to_glib_none().0, nbytes))
}
}
pub fn get_buffer_fast(&self, nbytes: usize) -> Option<gst::Buffer> {
unsafe {
from_glib_full(ffi::gst_adapter_get_buffer_fast(self.to_glib_none().0, nbytes))
}
}
pub fn get_buffer_list(&self, nbytes: usize) -> Option<gst::BufferList> {
unsafe {
from_glib_full(ffi::gst_adapter_get_buffer_list(self.to_glib_none().0, nbytes))
}
}
pub fn get_list(&self, nbytes: usize) -> Vec<gst::Buffer> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_adapter_get_list(self.to_glib_none().0, nbytes))
}
}
pub fn masked_scan_uint32(&self, mask: u32, pattern: u32, offset: usize, size: usize) -> isize {
unsafe {
ffi::gst_adapter_masked_scan_uint32(self.to_glib_none().0, mask, pattern, offset, size)
}
}
pub fn masked_scan_uint32_peek(&self, mask: u32, pattern: u32, offset: usize, size: usize) -> (isize, u32) {
unsafe {
let mut value = mem::uninitialized();
let ret = ffi::gst_adapter_masked_scan_uint32_peek(self.to_glib_none().0, mask, pattern, offset, size, &mut value);
(ret, value)
}
}
#[cfg(feature = "v1_10")]
pub fn offset_at_discont(&self) -> u64 {
unsafe {
ffi::gst_adapter_offset_at_discont(self.to_glib_none().0)
}
}
pub fn prev_dts(&self) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_dts(self.to_glib_none().0, &mut distance);
(ret, distance)
}
}
pub fn prev_dts_at_offset(&self, offset: usize) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_dts_at_offset(self.to_glib_none().0, offset, &mut distance);
(ret, distance)
}
}
#[cfg(feature = "v1_10")]
pub fn prev_offset(&self) -> (u64, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_offset(self.to_glib_none().0, &mut distance);
(ret, distance)
}
}
pub fn prev_pts(&self) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_pts(self.to_glib_none().0, &mut distance);
(ret, distance)
}
}
pub fn prev_pts_at_offset(&self, offset: usize) -> (gst::ClockTime, u64) {
unsafe {
let mut distance = mem::uninitialized();
let ret = ffi::gst_adapter_prev_pts_at_offset(self.to_glib_none().0, offset, &mut distance);
(ret, distance)
}
}
#[cfg(feature = "v1_10")]
pub fn pts_at_discont(&self) -> gst::ClockTime {
unsafe {
ffi::gst_adapter_pts_at_discont(self.to_glib_none().0)
}
}
pub fn take_buffer(&self, nbytes: usize) -> Option<gst::Buffer> {
unsafe {
from_glib_full(ffi::gst_adapter_take_buffer(self.to_glib_none().0, nbytes))
}
}
pub fn take_buffer_fast(&self, nbytes: usize) -> Option<gst::Buffer> {
unsafe {
from_glib_full(ffi::gst_adapter_take_buffer_fast(self.to_glib_none().0, nbytes))
}
}
pub fn take_buffer_list(&self, nbytes: usize) -> Option<gst::BufferList> {
unsafe {
from_glib_full(ffi::gst_adapter_take_buffer_list(self.to_glib_none().0, nbytes))
}
}
pub fn take_list(&self, nbytes: usize) -> Vec<gst::Buffer> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_adapter_take_list(self.to_glib_none().0, nbytes))
}
}
}
impl Default for Adapter {
fn default() -> Self {
Self::new()
}
}

View file

@ -0,0 +1,521 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct BaseSink(Object<ffi::GstBaseSink>): [
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_base_sink_get_type(),
}
}
unsafe impl Send for BaseSink {}
unsafe impl Sync for BaseSink {}
pub trait BaseSinkExt {
//fn do_preroll(&self, obj: /*Ignored*/&gst::MiniObject) -> gst::FlowReturn;
fn get_blocksize(&self) -> u32;
#[cfg(feature = "v1_12")]
fn get_drop_out_of_segment(&self) -> bool;
fn get_last_sample(&self) -> Option<gst::Sample>;
fn get_latency(&self) -> gst::ClockTime;
fn get_max_bitrate(&self) -> u64;
fn get_max_lateness(&self) -> i64;
fn get_render_delay(&self) -> gst::ClockTime;
fn get_sync(&self) -> bool;
fn get_throttle_time(&self) -> u64;
fn get_ts_offset(&self) -> gst::ClockTimeDiff;
fn is_async_enabled(&self) -> bool;
fn is_last_sample_enabled(&self) -> bool;
fn is_qos_enabled(&self) -> bool;
fn query_latency(&self) -> Option<(bool, bool, gst::ClockTime, gst::ClockTime)>;
fn set_async_enabled(&self, enabled: bool);
fn set_blocksize(&self, blocksize: u32);
#[cfg(feature = "v1_12")]
fn set_drop_out_of_segment(&self, drop_out_of_segment: bool);
fn set_last_sample_enabled(&self, enabled: bool);
fn set_max_bitrate(&self, max_bitrate: u64);
fn set_max_lateness(&self, max_lateness: i64);
fn set_qos_enabled(&self, enabled: bool);
fn set_render_delay(&self, delay: gst::ClockTime);
fn set_sync(&self, sync: bool);
fn set_throttle_time(&self, throttle: u64);
fn set_ts_offset(&self, offset: gst::ClockTimeDiff);
fn wait(&self, time: gst::ClockTime) -> (gst::FlowReturn, gst::ClockTimeDiff);
fn wait_clock(&self, time: gst::ClockTime) -> (gst::ClockReturn, gst::ClockTimeDiff);
fn wait_preroll(&self) -> gst::FlowReturn;
fn get_property_async(&self) -> bool;
fn set_property_async(&self, async: bool);
fn get_property_enable_last_sample(&self) -> bool;
fn set_property_enable_last_sample(&self, enable_last_sample: bool);
fn get_property_qos(&self) -> bool;
fn set_property_qos(&self, qos: bool);
fn connect_property_async_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_enable_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_max_bitrate_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_max_lateness_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_render_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_sync_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_throttle_time_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_ts_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<BaseSink> + IsA<glib::object::Object>> BaseSinkExt for O {
//fn do_preroll(&self, obj: /*Ignored*/&gst::MiniObject) -> gst::FlowReturn {
// unsafe { TODO: call ffi::gst_base_sink_do_preroll() }
//}
fn get_blocksize(&self) -> u32 {
unsafe {
ffi::gst_base_sink_get_blocksize(self.to_glib_none().0)
}
}
#[cfg(feature = "v1_12")]
fn get_drop_out_of_segment(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_sink_get_drop_out_of_segment(self.to_glib_none().0))
}
}
fn get_last_sample(&self) -> Option<gst::Sample> {
unsafe {
from_glib_full(ffi::gst_base_sink_get_last_sample(self.to_glib_none().0))
}
}
fn get_latency(&self) -> gst::ClockTime {
unsafe {
ffi::gst_base_sink_get_latency(self.to_glib_none().0)
}
}
fn get_max_bitrate(&self) -> u64 {
unsafe {
ffi::gst_base_sink_get_max_bitrate(self.to_glib_none().0)
}
}
fn get_max_lateness(&self) -> i64 {
unsafe {
ffi::gst_base_sink_get_max_lateness(self.to_glib_none().0)
}
}
fn get_render_delay(&self) -> gst::ClockTime {
unsafe {
ffi::gst_base_sink_get_render_delay(self.to_glib_none().0)
}
}
fn get_sync(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_sink_get_sync(self.to_glib_none().0))
}
}
fn get_throttle_time(&self) -> u64 {
unsafe {
ffi::gst_base_sink_get_throttle_time(self.to_glib_none().0)
}
}
fn get_ts_offset(&self) -> gst::ClockTimeDiff {
unsafe {
ffi::gst_base_sink_get_ts_offset(self.to_glib_none().0)
}
}
fn is_async_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_sink_is_async_enabled(self.to_glib_none().0))
}
}
fn is_last_sample_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_sink_is_last_sample_enabled(self.to_glib_none().0))
}
}
fn is_qos_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_sink_is_qos_enabled(self.to_glib_none().0))
}
}
fn query_latency(&self) -> Option<(bool, bool, gst::ClockTime, gst::ClockTime)> {
unsafe {
let mut live = mem::uninitialized();
let mut upstream_live = mem::uninitialized();
let mut min_latency = mem::uninitialized();
let mut max_latency = mem::uninitialized();
let ret = from_glib(ffi::gst_base_sink_query_latency(self.to_glib_none().0, &mut live, &mut upstream_live, &mut min_latency, &mut max_latency));
if ret { Some((from_glib(live), from_glib(upstream_live), min_latency, max_latency)) } else { None }
}
}
fn set_async_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_base_sink_set_async_enabled(self.to_glib_none().0, enabled.to_glib());
}
}
fn set_blocksize(&self, blocksize: u32) {
unsafe {
ffi::gst_base_sink_set_blocksize(self.to_glib_none().0, blocksize);
}
}
#[cfg(feature = "v1_12")]
fn set_drop_out_of_segment(&self, drop_out_of_segment: bool) {
unsafe {
ffi::gst_base_sink_set_drop_out_of_segment(self.to_glib_none().0, drop_out_of_segment.to_glib());
}
}
fn set_last_sample_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_base_sink_set_last_sample_enabled(self.to_glib_none().0, enabled.to_glib());
}
}
fn set_max_bitrate(&self, max_bitrate: u64) {
unsafe {
ffi::gst_base_sink_set_max_bitrate(self.to_glib_none().0, max_bitrate);
}
}
fn set_max_lateness(&self, max_lateness: i64) {
unsafe {
ffi::gst_base_sink_set_max_lateness(self.to_glib_none().0, max_lateness);
}
}
fn set_qos_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_base_sink_set_qos_enabled(self.to_glib_none().0, enabled.to_glib());
}
}
fn set_render_delay(&self, delay: gst::ClockTime) {
unsafe {
ffi::gst_base_sink_set_render_delay(self.to_glib_none().0, delay);
}
}
fn set_sync(&self, sync: bool) {
unsafe {
ffi::gst_base_sink_set_sync(self.to_glib_none().0, sync.to_glib());
}
}
fn set_throttle_time(&self, throttle: u64) {
unsafe {
ffi::gst_base_sink_set_throttle_time(self.to_glib_none().0, throttle);
}
}
fn set_ts_offset(&self, offset: gst::ClockTimeDiff) {
unsafe {
ffi::gst_base_sink_set_ts_offset(self.to_glib_none().0, offset);
}
}
fn wait(&self, time: gst::ClockTime) -> (gst::FlowReturn, gst::ClockTimeDiff) {
unsafe {
let mut jitter = mem::uninitialized();
let ret = from_glib(ffi::gst_base_sink_wait(self.to_glib_none().0, time, &mut jitter));
(ret, jitter)
}
}
fn wait_clock(&self, time: gst::ClockTime) -> (gst::ClockReturn, gst::ClockTimeDiff) {
unsafe {
let mut jitter = mem::uninitialized();
let ret = from_glib(ffi::gst_base_sink_wait_clock(self.to_glib_none().0, time, &mut jitter));
(ret, jitter)
}
}
fn wait_preroll(&self) -> gst::FlowReturn {
unsafe {
from_glib(ffi::gst_base_sink_wait_preroll(self.to_glib_none().0))
}
}
fn get_property_async(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "async".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_async(&self, async: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "async".to_glib_none().0, Value::from(&async).to_glib_none().0);
}
}
fn get_property_enable_last_sample(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "enable-last-sample".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_enable_last_sample(&self, enable_last_sample: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "enable-last-sample".to_glib_none().0, Value::from(&enable_last_sample).to_glib_none().0);
}
}
fn get_property_qos(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "qos".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_qos(&self, qos: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "qos".to_glib_none().0, Value::from(&qos).to_glib_none().0);
}
}
fn connect_property_async_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::async",
transmute(notify_async_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::blocksize",
transmute(notify_blocksize_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_enable_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::enable-last-sample",
transmute(notify_enable_last_sample_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::last-sample",
transmute(notify_last_sample_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_max_bitrate_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::max-bitrate",
transmute(notify_max_bitrate_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_max_lateness_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::max-lateness",
transmute(notify_max_lateness_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::qos",
transmute(notify_qos_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_render_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::render-delay",
transmute(notify_render_delay_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_sync_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::sync",
transmute(notify_sync_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_throttle_time_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::throttle-time",
transmute(notify_throttle_time_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_ts_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::ts-offset",
transmute(notify_ts_offset_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_async_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_blocksize_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_enable_last_sample_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_last_sample_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_max_bitrate_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_max_lateness_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_qos_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_render_delay_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_sync_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_throttle_time_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_ts_offset_trampoline<P>(this: *mut ffi::GstBaseSink, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSink> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSink::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -0,0 +1,293 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct BaseSrc(Object<ffi::GstBaseSrc>): [
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_base_src_get_type(),
}
}
unsafe impl Send for BaseSrc {}
unsafe impl Sync for BaseSrc {}
pub trait BaseSrcExt {
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams);
fn get_blocksize(&self) -> u32;
//fn get_buffer_pool(&self) -> /*Ignored*/Option<gst::BufferPool>;
fn get_do_timestamp(&self) -> bool;
fn is_async(&self) -> bool;
fn is_live(&self) -> bool;
fn new_seamless_segment(&self, start: i64, stop: i64, time: i64) -> bool;
fn query_latency(&self) -> Option<(bool, gst::ClockTime, gst::ClockTime)>;
fn set_async(&self, async: bool);
fn set_automatic_eos(&self, automatic_eos: bool);
fn set_blocksize(&self, blocksize: u32);
fn set_caps(&self, caps: &gst::Caps) -> bool;
fn set_do_timestamp(&self, timestamp: bool);
fn set_dynamic_size(&self, dynamic: bool);
fn set_format(&self, format: gst::Format);
fn set_live(&self, live: bool);
fn start_complete(&self, ret: gst::FlowReturn);
fn start_wait(&self) -> gst::FlowReturn;
fn wait_playing(&self) -> gst::FlowReturn;
fn get_property_num_buffers(&self) -> i32;
fn set_property_num_buffers(&self, num_buffers: i32);
fn get_property_typefind(&self) -> bool;
fn set_property_typefind(&self, typefind: bool);
fn connect_property_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_do_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_num_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_property_typefind_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<BaseSrc> + IsA<glib::object::Object>> BaseSrcExt for O {
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) {
// unsafe { TODO: call ffi::gst_base_src_get_allocator() }
//}
fn get_blocksize(&self) -> u32 {
unsafe {
ffi::gst_base_src_get_blocksize(self.to_glib_none().0)
}
}
//fn get_buffer_pool(&self) -> /*Ignored*/Option<gst::BufferPool> {
// unsafe { TODO: call ffi::gst_base_src_get_buffer_pool() }
//}
fn get_do_timestamp(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_src_get_do_timestamp(self.to_glib_none().0))
}
}
fn is_async(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_src_is_async(self.to_glib_none().0))
}
}
fn is_live(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_src_is_live(self.to_glib_none().0))
}
}
fn new_seamless_segment(&self, start: i64, stop: i64, time: i64) -> bool {
unsafe {
from_glib(ffi::gst_base_src_new_seamless_segment(self.to_glib_none().0, start, stop, time))
}
}
fn query_latency(&self) -> Option<(bool, gst::ClockTime, gst::ClockTime)> {
unsafe {
let mut live = mem::uninitialized();
let mut min_latency = mem::uninitialized();
let mut max_latency = mem::uninitialized();
let ret = from_glib(ffi::gst_base_src_query_latency(self.to_glib_none().0, &mut live, &mut min_latency, &mut max_latency));
if ret { Some((from_glib(live), min_latency, max_latency)) } else { None }
}
}
fn set_async(&self, async: bool) {
unsafe {
ffi::gst_base_src_set_async(self.to_glib_none().0, async.to_glib());
}
}
fn set_automatic_eos(&self, automatic_eos: bool) {
unsafe {
ffi::gst_base_src_set_automatic_eos(self.to_glib_none().0, automatic_eos.to_glib());
}
}
fn set_blocksize(&self, blocksize: u32) {
unsafe {
ffi::gst_base_src_set_blocksize(self.to_glib_none().0, blocksize);
}
}
fn set_caps(&self, caps: &gst::Caps) -> bool {
unsafe {
from_glib(ffi::gst_base_src_set_caps(self.to_glib_none().0, caps.to_glib_none().0))
}
}
fn set_do_timestamp(&self, timestamp: bool) {
unsafe {
ffi::gst_base_src_set_do_timestamp(self.to_glib_none().0, timestamp.to_glib());
}
}
fn set_dynamic_size(&self, dynamic: bool) {
unsafe {
ffi::gst_base_src_set_dynamic_size(self.to_glib_none().0, dynamic.to_glib());
}
}
fn set_format(&self, format: gst::Format) {
unsafe {
ffi::gst_base_src_set_format(self.to_glib_none().0, format.to_glib());
}
}
fn set_live(&self, live: bool) {
unsafe {
ffi::gst_base_src_set_live(self.to_glib_none().0, live.to_glib());
}
}
fn start_complete(&self, ret: gst::FlowReturn) {
unsafe {
ffi::gst_base_src_start_complete(self.to_glib_none().0, ret.to_glib());
}
}
fn start_wait(&self) -> gst::FlowReturn {
unsafe {
from_glib(ffi::gst_base_src_start_wait(self.to_glib_none().0))
}
}
fn wait_playing(&self) -> gst::FlowReturn {
unsafe {
from_glib(ffi::gst_base_src_wait_playing(self.to_glib_none().0))
}
}
fn get_property_num_buffers(&self) -> i32 {
let mut value = Value::from(&0);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "num-buffers".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_num_buffers(&self, num_buffers: i32) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "num-buffers".to_glib_none().0, Value::from(&num_buffers).to_glib_none().0);
}
}
fn get_property_typefind(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "typefind".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_typefind(&self, typefind: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "typefind".to_glib_none().0, Value::from(&typefind).to_glib_none().0);
}
}
fn connect_property_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::blocksize",
transmute(notify_blocksize_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_do_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::do-timestamp",
transmute(notify_do_timestamp_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_num_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::num-buffers",
transmute(notify_num_buffers_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_property_typefind_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::typefind",
transmute(notify_typefind_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_blocksize_trampoline<P>(this: *mut ffi::GstBaseSrc, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSrc> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSrc::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_do_timestamp_trampoline<P>(this: *mut ffi::GstBaseSrc, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSrc> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSrc::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_num_buffers_trampoline<P>(this: *mut ffi::GstBaseSrc, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSrc> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSrc::from_glib_borrow(this).downcast_unchecked())
}
unsafe extern "C" fn notify_typefind_trampoline<P>(this: *mut ffi::GstBaseSrc, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseSrc> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseSrc::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -0,0 +1,180 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct BaseTransform(Object<ffi::GstBaseTransform>): [
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_base_transform_get_type(),
}
}
unsafe impl Send for BaseTransform {}
unsafe impl Sync for BaseTransform {}
pub trait BaseTransformExt {
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams);
//fn get_buffer_pool(&self) -> /*Ignored*/Option<gst::BufferPool>;
fn is_in_place(&self) -> bool;
fn is_passthrough(&self) -> bool;
fn is_qos_enabled(&self) -> bool;
fn reconfigure_sink(&self);
fn reconfigure_src(&self);
fn set_gap_aware(&self, gap_aware: bool);
fn set_in_place(&self, in_place: bool);
fn set_passthrough(&self, passthrough: bool);
fn set_prefer_passthrough(&self, prefer_passthrough: bool);
fn set_qos_enabled(&self, enabled: bool);
fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime);
fn update_src_caps(&self, updated_caps: &gst::Caps) -> bool;
fn get_property_qos(&self) -> bool;
fn set_property_qos(&self, qos: bool);
fn connect_property_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<BaseTransform> + IsA<glib::object::Object>> BaseTransformExt for O {
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) {
// unsafe { TODO: call ffi::gst_base_transform_get_allocator() }
//}
//fn get_buffer_pool(&self) -> /*Ignored*/Option<gst::BufferPool> {
// unsafe { TODO: call ffi::gst_base_transform_get_buffer_pool() }
//}
fn is_in_place(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_transform_is_in_place(self.to_glib_none().0))
}
}
fn is_passthrough(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_transform_is_passthrough(self.to_glib_none().0))
}
}
fn is_qos_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gst_base_transform_is_qos_enabled(self.to_glib_none().0))
}
}
fn reconfigure_sink(&self) {
unsafe {
ffi::gst_base_transform_reconfigure_sink(self.to_glib_none().0);
}
}
fn reconfigure_src(&self) {
unsafe {
ffi::gst_base_transform_reconfigure_src(self.to_glib_none().0);
}
}
fn set_gap_aware(&self, gap_aware: bool) {
unsafe {
ffi::gst_base_transform_set_gap_aware(self.to_glib_none().0, gap_aware.to_glib());
}
}
fn set_in_place(&self, in_place: bool) {
unsafe {
ffi::gst_base_transform_set_in_place(self.to_glib_none().0, in_place.to_glib());
}
}
fn set_passthrough(&self, passthrough: bool) {
unsafe {
ffi::gst_base_transform_set_passthrough(self.to_glib_none().0, passthrough.to_glib());
}
}
fn set_prefer_passthrough(&self, prefer_passthrough: bool) {
unsafe {
ffi::gst_base_transform_set_prefer_passthrough(self.to_glib_none().0, prefer_passthrough.to_glib());
}
}
fn set_qos_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_base_transform_set_qos_enabled(self.to_glib_none().0, enabled.to_glib());
}
}
fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime) {
unsafe {
ffi::gst_base_transform_update_qos(self.to_glib_none().0, proportion, diff, timestamp);
}
}
fn update_src_caps(&self, updated_caps: &gst::Caps) -> bool {
unsafe {
from_glib(ffi::gst_base_transform_update_src_caps(self.to_glib_none().0, updated_caps.to_glib_none().0))
}
}
fn get_property_qos(&self) -> bool {
let mut value = Value::from(&false);
unsafe {
gobject_ffi::g_object_get_property(self.to_glib_none().0, "qos".to_glib_none().0, value.to_glib_none_mut().0);
}
value.get().unwrap()
}
fn set_property_qos(&self, qos: bool) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "qos".to_glib_none().0, Value::from(&qos).to_glib_none().0);
}
}
fn connect_property_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::qos",
transmute(notify_qos_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_qos_trampoline<P>(this: *mut ffi::GstBaseTransform, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<BaseTransform> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&BaseTransform::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -0,0 +1,7 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib::translate::*;
use std;

View file

@ -0,0 +1,6 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib::translate::*;

View file

@ -0,0 +1,72 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
match fn {
ref => |ptr| ffi::gst_flow_combiner_ref(ptr),
unref => |ptr| ffi::gst_flow_combiner_unref(ptr),
get_type => || ffi::gst_flow_combiner_get_type(),
}
}
impl FlowCombiner {
pub fn new() -> FlowCombiner {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_flow_combiner_new())
}
}
pub fn add_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
unsafe {
ffi::gst_flow_combiner_add_pad(self.to_glib_none().0, pad.to_glib_none().0);
}
}
pub fn clear(&self) {
unsafe {
ffi::gst_flow_combiner_clear(self.to_glib_none().0);
}
}
pub fn remove_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
unsafe {
ffi::gst_flow_combiner_remove_pad(self.to_glib_none().0, pad.to_glib_none().0);
}
}
pub fn reset(&self) {
unsafe {
ffi::gst_flow_combiner_reset(self.to_glib_none().0);
}
}
pub fn update_flow(&self, fret: gst::FlowReturn) -> gst::FlowReturn {
unsafe {
from_glib(ffi::gst_flow_combiner_update_flow(self.to_glib_none().0, fret.to_glib()))
}
}
pub fn update_pad_flow<P: IsA<gst::Pad>>(&self, pad: &P, fret: gst::FlowReturn) -> gst::FlowReturn {
unsafe {
from_glib(ffi::gst_flow_combiner_update_pad_flow(self.to_glib_none().0, pad.to_glib_none().0, fret.to_glib()))
}
}
}
impl Default for FlowCombiner {
fn default() -> Self {
Self::new()
}
}

View file

@ -0,0 +1,30 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
mod adapter;
pub use self::adapter::Adapter;
mod base_sink;
pub use self::base_sink::BaseSink;
pub use self::base_sink::BaseSinkExt;
mod base_src;
pub use self::base_src::BaseSrc;
pub use self::base_src::BaseSrcExt;
mod base_transform;
pub use self::base_transform::BaseTransform;
pub use self::base_transform::BaseTransformExt;
mod push_src;
pub use self::push_src::PushSrc;
mod flow_combiner;
pub use self::flow_combiner::FlowCombiner;
#[doc(hidden)]
pub mod traits {
pub use super::BaseSinkExt;
pub use super::BaseSrcExt;
pub use super::BaseTransformExt;
}

View file

@ -0,0 +1,29 @@
// This file was generated by gir (6a48033) from gir-files (???)
// DO NOT EDIT
use BaseSrc;
use ffi;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct PushSrc(Object<ffi::GstPushSrc>): [
BaseSrc,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_push_src_get_type(),
}
}
impl PushSrc {}
unsafe impl Send for PushSrc {}
unsafe impl Sync for PushSrc {}

52
gstreamer-base/src/lib.rs Normal file
View file

@ -0,0 +1,52 @@
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate libc;
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern crate gstreamer_sys as gst_ffi;
extern crate gstreamer_base_sys as ffi;
extern crate gstreamer as gst;
#[macro_use]
extern crate glib;
macro_rules! callback_guard {
() => (
let _guard = ::glib::CallbackGuard::new();
)
}
macro_rules! assert_initialized_main_thread {
() => (
if unsafe {::gst_ffi::gst_is_initialized()} != ::glib_ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
)
}
pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue, Value};
#[cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
mod auto;
pub use auto::*;
mod adapter;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts
pub mod prelude {
pub use glib::prelude::*;
pub use gst::prelude::*;
pub use auto::traits::*;
}