Add GstGL bindings

This commit is contained in:
Víctor Manuel Jáquez Leal 2018-11-27 22:52:42 +01:00
parent e0953efd12
commit 2c13a75330
31 changed files with 4794 additions and 0 deletions

View file

@ -13,4 +13,5 @@ ignore = [
"gstreamer-video/src/auto",
"gstreamer-webrtc/src/auto",
"gstreamer-editing-services/src/auto",
"gstreamer-gl/src/auto",
]

View file

@ -15,6 +15,7 @@ members = [
"gstreamer-webrtc",
"gstreamer-check",
"gstreamer-editing-services",
"gstreamer-gl",
"examples",
"tutorials",
]

367
Gir_GstGL.toml Normal file
View file

@ -0,0 +1,367 @@
[options]
girs_dir = "gir-files"
library = "GstGL"
version = "1.0"
min_cfg_version = "1.14"
target_path = "gstreamer-gl"
work_mode = "normal"
concurrency = "send+sync"
generate_safety_asserts = true
single_version_file = true
external_libraries = [
"GLib",
"GObject",
"Gst",
"GstBase",
"GstVideo",
]
generate = [
# BitFlags
"GstGL.GLAPI",
"GstGL.GLDisplayType",
"GstGL.GLPlatform",
"GstGL.GLSLProfile",
# Enums
"GstGL.GLFormat",
"GstGL.GLQueryType",
"GstGL.GLSLVersion",
"GstGL.GLTextureTarget",
"GstGL.GLStereoDownmix",
"GstGL.GLUploadReturn",
# Enums Errors
#"GstGL.GLBaseMemoryError",
"GstGL.GLContextError",
"GstGL.GLSLError",
"GstGL.GLWindowError",
# Records
#"GstGL.GLAllocationParams",
#"GstGL.GLRenderbufferAllocationParams",
#"GstGL.GLVideoAllocationParams",
# Objects
"GstGL.GLBaseFilter",
#"GstGL.GLBufferPool",
"GstGL.GLFramebuffer",
#"GstGL.GLBaseMemory",
#"GstGL.GLBaseMemoryAllocator",
#"GstGL.GLMemoryPBOAllocator",
#"GstGL.GLRenderbufferAllocator",
]
manual = [
"GLib.Error",
"GLib.Thread",
"GObject.Object",
"Gst.Object",
"Gst.FlowReturn",
"Gst.PadDirection",
"GstVideo.VideoMultiviewFlags",
"GstVideo.VideoMultiviewMode",
]
[[object]]
name = "Gst.Structure"
status = "manual"
ref_mode = "ref-mut"
[[object]]
name = "Gst.Buffer"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Caps"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.Query"
status = "manual"
ref_mode = "ref"
[[object]]
name = "GstGL.GLBuffer"
status = "manual"
ref_mode = "ref"
[[object]]
name = "GstGL.GLQuery"
status = "manual"
ref_mode = "ref"
[[object]]
name = "GstGL.GLContext"
status = "generate"
[[object.function]]
name = "new_wrapped"
# input handle
ignore = true
[[object.function]]
name = "get_gl_context"
# return handle
ignore = true
[[object.function]]
name = "get_current_gl_context"
# return handle
ignore = true
[[object.function]]
name = "get_proc_address"
ignore = true
[[object.function]]
name = "default_get_proc_address"
ignore = true
[[object.function]]
name = "get_proc_address_with_platform"
ignore = true
[[object.function]]
name = "thread_add"
# unimplemented GLContextThreadFunc
ignore = true
[[object.function]]
name = "get_thread"
# glib::Thread not found in `glib`
ignore = true
[[object.function]]
name = "get_gl_context_for_thread"
# glib::Thread not found in `glib`
ignore = true
[[object.function]]
name = "error_quark"
# bad error domian definition in gir
ignore = true
[[object.function]]
name = "activate"
[object.function.return]
bool_return_is_error = "Failed to activate OpenGL context"
[[object.function]]
name = "get_display"
[object.function.return]
nullable = false
[[object]]
name = "GstGL.GLDisplay"
status = "generate"
[[object.function]]
name = "find_window"
# unimplemented pointer
ignore = true
[[object.function]]
name = "get_handle"
# return handle
ignore = true
[[object.function]]
name = "get_gl_context_for_thread"
# glib::Thread not found in `glib`
ignore = true
[[object.function]]
name = "add_context"
[object.function.return]
bool_return_is_error = "Failed to add OpenGL context"
[[object.function]]
name = "remove_window"
[object.function.return]
bool_return_is_error = "Failed to remove window"
[[object]]
name = "GstGL.GLDisplayEGL"
status = "generate"
trait = false
cfg_condition = "feature = \"egl\""
[[object]]
name = "GstGL.GLWindow"
status = "generate"
[[object.function]]
name = "get_window_handle"
# return native handle
ignore = true
[[object.function]]
name = "send_message"
# callback
ignore = true
[[object.function]]
name = "send_message_async"
# callback
ignore = true
[[object.function]]
name = "set_close_callback"
# callback
ignore = true
[[object.function]]
name = "set_draw_callback"
# callback
ignore = true
[[object.function]]
name = "set_resize_callback"
# callback
ignore = true
[[object.function]]
name = "set_window_handle"
# handle
ignore = true
[[object.function]]
name = "get_display"
# handle
ignore = true
[[object.function]]
name = "error_quark"
# bad error domian definition in gir
ignore = true
[[object]]
name = "GstGL.GLColorConvert"
status = "generate"
trait = false
[[object.function]]
name = "decide_allocation"
# correct mutability
ignore = true
[[object.function]]
name = "fixate_caps"
# correct reference ownership
ignore = true
[[object.function]]
name = "perform"
# transfer gst::Buffer not reference
ignore = true
[[object]]
name = "GstGL.GLOverlayCompositor"
status = "generate"
trait = false
[[object.function]]
name = "upload_overlays"
# correct mutability
ignore = true
[[object]]
name = "GstGL.GLSLStage"
status = "generate"
trait = false
[[object]]
name = "GstGL.GLShader"
status = "generate"
trait = false
[[object.function]]
name = "set_uniform_matrix_2fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_2x3fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_2x4fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_3fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_3x2fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_3x4fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_4fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_4x2fv"
# array with size
ignore = true
[[object.function]]
name = "set_uniform_matrix_4x3fv"
# array with size
ignore = true
[[object]]
name = "GstGL.GLUpload"
status = "generate"
trait = false
[[object.function]]
name = "perform_with_buffer"
# Result<Buffer, GLUploadReturn>
ignore = true
[[object.function]]
name = "propose_allocation"
# fix mutability
ignore = true
[[object.function]]
name = "get_input_template_caps"
[object.function.return]
nullable = false
[[object]]
name = "GstGL.GLViewConvert"
status = "generate"
trait = false
[[object.function]]
name = "fixate_caps"
# correct reference ownership
ignore = true
[[object.function]]
name = "get_output"
# Result<Buffer, FlowReturn>
ignore = true
[[object.function]]
name = "tranform_caps"
[object.function.return]
nullable = false
[[object.function]]
name = "submit_input_buffer"
# Buffer ownership transfer
ignore = true

1509
docs/gstreamer-gl/docs.md Normal file

File diff suppressed because it is too large Load diff

41
gstreamer-gl/Cargo.toml Normal file
View file

@ -0,0 +1,41 @@
[package]
name = "gstreamer-gl"
version = "0.13.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>",
"Víctor M. Jáquez L. <vjaquez@igalia.com>"]
categories = ["api-bindings", "multimedia"]
description = "Rust bindings for GStreamer GL 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_gl"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs"
[dependencies]
bitflags = "1.0"
byteorder = "1"
libc = "0.2"
lazy_static = "1.0"
glib-sys = { git = "https://github.com/gtk-rs/sys" }
gobject-sys = { git = "https://github.com/gtk-rs/sys" }
gstreamer-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys" }
gstreamer-base-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys", features = ["v1_14"] }
gstreamer-video-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys", features = ["v1_14"] }
gstreamer-gl-sys = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys" }
glib = { git = "https://github.com/gtk-rs/glib" }
gstreamer = { path = "../gstreamer", features = ["v1_14"] }
gstreamer-base = { path = "../gstreamer-base", features = ["v1_14"] }
gstreamer-video = { path = "../gstreamer-video", features = ["v1_14"] }
[build-dependencies.rustdoc-stripper]
version = "0.1"
optional = true
[features]
default-features = []
dox = ["gstreamer-gl-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-base/dox"]
egl = ["gstreamer-gl-sys/egl"]
embed-lgpl-docs = ["rustdoc-stripper"]
purge-lgpl-docs = ["rustdoc-stripper"]

201
gstreamer-gl/LICENSE-APACHE Normal file
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.

23
gstreamer-gl/LICENSE-MIT Normal file
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.

34
gstreamer-gl/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-gl/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,529 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use ffi;
use glib::Quark;
use glib::StaticType;
use glib::Type;
use glib::error::ErrorDomain;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::FromValueOptional;
use glib::value::SetValue;
use glib::value::Value;
use gobject_ffi;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLContextError {
Failed,
WrongConfig,
WrongApi,
OldLibs,
CreateContext,
ResourceUnavailable,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLContextError {
type GlibType = ffi::GstGLContextError;
fn to_glib(&self) -> ffi::GstGLContextError {
match *self {
GLContextError::Failed => ffi::GST_GL_CONTEXT_ERROR_FAILED,
GLContextError::WrongConfig => ffi::GST_GL_CONTEXT_ERROR_WRONG_CONFIG,
GLContextError::WrongApi => ffi::GST_GL_CONTEXT_ERROR_WRONG_API,
GLContextError::OldLibs => ffi::GST_GL_CONTEXT_ERROR_OLD_LIBS,
GLContextError::CreateContext => ffi::GST_GL_CONTEXT_ERROR_CREATE_CONTEXT,
GLContextError::ResourceUnavailable => ffi::GST_GL_CONTEXT_ERROR_RESOURCE_UNAVAILABLE,
GLContextError::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLContextError> for GLContextError {
fn from_glib(value: ffi::GstGLContextError) -> Self {
skip_assert_initialized!();
match value {
0 => GLContextError::Failed,
1 => GLContextError::WrongConfig,
2 => GLContextError::WrongApi,
3 => GLContextError::OldLibs,
4 => GLContextError::CreateContext,
5 => GLContextError::ResourceUnavailable,
value => GLContextError::__Unknown(value),
}
}
}
impl ErrorDomain for GLContextError {
fn domain() -> Quark {
skip_assert_initialized!();
unsafe { from_glib(ffi::gst_gl_context_error_quark()) }
}
fn code(self) -> i32 {
self.to_glib()
}
fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code {
0 => Some(GLContextError::Failed),
1 => Some(GLContextError::WrongConfig),
2 => Some(GLContextError::WrongApi),
3 => Some(GLContextError::OldLibs),
4 => Some(GLContextError::CreateContext),
5 => Some(GLContextError::ResourceUnavailable),
_ => Some(GLContextError::Failed),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLFormat {
Luminance,
Alpha,
LuminanceAlpha,
Red,
R8,
Rg,
Rg8,
Rgb,
Rgb8,
Rgb565,
Rgba,
Rgba8,
DepthComponent16,
Depth24Stencil8,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLFormat {
type GlibType = ffi::GstGLFormat;
fn to_glib(&self) -> ffi::GstGLFormat {
match *self {
GLFormat::Luminance => ffi::GST_GL_LUMINANCE,
GLFormat::Alpha => ffi::GST_GL_ALPHA,
GLFormat::LuminanceAlpha => ffi::GST_GL_LUMINANCE_ALPHA,
GLFormat::Red => ffi::GST_GL_RED,
GLFormat::R8 => ffi::GST_GL_R8,
GLFormat::Rg => ffi::GST_GL_RG,
GLFormat::Rg8 => ffi::GST_GL_RG8,
GLFormat::Rgb => ffi::GST_GL_RGB,
GLFormat::Rgb8 => ffi::GST_GL_RGB8,
GLFormat::Rgb565 => ffi::GST_GL_RGB565,
GLFormat::Rgba => ffi::GST_GL_RGBA,
GLFormat::Rgba8 => ffi::GST_GL_RGBA8,
GLFormat::DepthComponent16 => ffi::GST_GL_DEPTH_COMPONENT16,
GLFormat::Depth24Stencil8 => ffi::GST_GL_DEPTH24_STENCIL8,
GLFormat::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLFormat> for GLFormat {
fn from_glib(value: ffi::GstGLFormat) -> Self {
skip_assert_initialized!();
match value {
6409 => GLFormat::Luminance,
6406 => GLFormat::Alpha,
6410 => GLFormat::LuminanceAlpha,
6403 => GLFormat::Red,
33321 => GLFormat::R8,
33319 => GLFormat::Rg,
33323 => GLFormat::Rg8,
6407 => GLFormat::Rgb,
32849 => GLFormat::Rgb8,
36194 => GLFormat::Rgb565,
6408 => GLFormat::Rgba,
32856 => GLFormat::Rgba8,
33189 => GLFormat::DepthComponent16,
35056 => GLFormat::Depth24Stencil8,
value => GLFormat::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLQueryType {
None,
TimeElapsed,
Timestamp,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLQueryType {
type GlibType = ffi::GstGLQueryType;
fn to_glib(&self) -> ffi::GstGLQueryType {
match *self {
GLQueryType::None => ffi::GST_GL_QUERY_NONE,
GLQueryType::TimeElapsed => ffi::GST_GL_QUERY_TIME_ELAPSED,
GLQueryType::Timestamp => ffi::GST_GL_QUERY_TIMESTAMP,
GLQueryType::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLQueryType> for GLQueryType {
fn from_glib(value: ffi::GstGLQueryType) -> Self {
skip_assert_initialized!();
match value {
0 => GLQueryType::None,
1 => GLQueryType::TimeElapsed,
2 => GLQueryType::Timestamp,
value => GLQueryType::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLSLError {
Compile,
Link,
Program,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLSLError {
type GlibType = ffi::GstGLSLError;
fn to_glib(&self) -> ffi::GstGLSLError {
match *self {
GLSLError::Compile => ffi::GST_GLSL_ERROR_COMPILE,
GLSLError::Link => ffi::GST_GLSL_ERROR_LINK,
GLSLError::Program => ffi::GST_GLSL_ERROR_PROGRAM,
GLSLError::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLSLError> for GLSLError {
fn from_glib(value: ffi::GstGLSLError) -> Self {
skip_assert_initialized!();
match value {
0 => GLSLError::Compile,
1 => GLSLError::Link,
2 => GLSLError::Program,
value => GLSLError::__Unknown(value),
}
}
}
impl ErrorDomain for GLSLError {
fn domain() -> Quark {
skip_assert_initialized!();
unsafe { from_glib(ffi::gst_glsl_error_quark()) }
}
fn code(self) -> i32 {
self.to_glib()
}
fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code {
0 => Some(GLSLError::Compile),
1 => Some(GLSLError::Link),
2 => Some(GLSLError::Program),
value => Some(GLSLError::__Unknown(value)),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLSLVersion {
None,
_100,
_110,
_120,
_130,
_140,
_150,
_300,
_310,
_320,
_330,
_400,
_410,
_420,
_430,
_440,
_450,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLSLVersion {
type GlibType = ffi::GstGLSLVersion;
fn to_glib(&self) -> ffi::GstGLSLVersion {
match *self {
GLSLVersion::None => ffi::GST_GLSL_VERSION_NONE,
GLSLVersion::_100 => ffi::GST_GLSL_VERSION_100,
GLSLVersion::_110 => ffi::GST_GLSL_VERSION_110,
GLSLVersion::_120 => ffi::GST_GLSL_VERSION_120,
GLSLVersion::_130 => ffi::GST_GLSL_VERSION_130,
GLSLVersion::_140 => ffi::GST_GLSL_VERSION_140,
GLSLVersion::_150 => ffi::GST_GLSL_VERSION_150,
GLSLVersion::_300 => ffi::GST_GLSL_VERSION_300,
GLSLVersion::_310 => ffi::GST_GLSL_VERSION_310,
GLSLVersion::_320 => ffi::GST_GLSL_VERSION_320,
GLSLVersion::_330 => ffi::GST_GLSL_VERSION_330,
GLSLVersion::_400 => ffi::GST_GLSL_VERSION_400,
GLSLVersion::_410 => ffi::GST_GLSL_VERSION_410,
GLSLVersion::_420 => ffi::GST_GLSL_VERSION_420,
GLSLVersion::_430 => ffi::GST_GLSL_VERSION_430,
GLSLVersion::_440 => ffi::GST_GLSL_VERSION_440,
GLSLVersion::_450 => ffi::GST_GLSL_VERSION_450,
GLSLVersion::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLSLVersion> for GLSLVersion {
fn from_glib(value: ffi::GstGLSLVersion) -> Self {
skip_assert_initialized!();
match value {
0 => GLSLVersion::None,
100 => GLSLVersion::_100,
110 => GLSLVersion::_110,
120 => GLSLVersion::_120,
130 => GLSLVersion::_130,
140 => GLSLVersion::_140,
150 => GLSLVersion::_150,
300 => GLSLVersion::_300,
310 => GLSLVersion::_310,
320 => GLSLVersion::_320,
330 => GLSLVersion::_330,
400 => GLSLVersion::_400,
410 => GLSLVersion::_410,
420 => GLSLVersion::_420,
430 => GLSLVersion::_430,
440 => GLSLVersion::_440,
450 => GLSLVersion::_450,
value => GLSLVersion::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLStereoDownmix {
GreenMagentaDubois,
RedCyanDubois,
AmberBlueDubois,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLStereoDownmix {
type GlibType = ffi::GstGLStereoDownmix;
fn to_glib(&self) -> ffi::GstGLStereoDownmix {
match *self {
GLStereoDownmix::GreenMagentaDubois => ffi::GST_GL_STEREO_DOWNMIX_ANAGLYPH_GREEN_MAGENTA_DUBOIS,
GLStereoDownmix::RedCyanDubois => ffi::GST_GL_STEREO_DOWNMIX_ANAGLYPH_RED_CYAN_DUBOIS,
GLStereoDownmix::AmberBlueDubois => ffi::GST_GL_STEREO_DOWNMIX_ANAGLYPH_AMBER_BLUE_DUBOIS,
GLStereoDownmix::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLStereoDownmix> for GLStereoDownmix {
fn from_glib(value: ffi::GstGLStereoDownmix) -> Self {
skip_assert_initialized!();
match value {
0 => GLStereoDownmix::GreenMagentaDubois,
1 => GLStereoDownmix::RedCyanDubois,
2 => GLStereoDownmix::AmberBlueDubois,
value => GLStereoDownmix::__Unknown(value),
}
}
}
impl StaticType for GLStereoDownmix {
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_gl_stereo_downmix_mode_get_type()) }
}
}
impl<'a> FromValueOptional<'a> for GLStereoDownmix {
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for GLStereoDownmix {
unsafe fn from_value(value: &Value) -> Self {
from_glib(gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}
impl SetValue for GLStereoDownmix {
unsafe fn set_value(value: &mut Value, this: &Self) {
gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLTextureTarget {
None,
_2d,
Rectangle,
ExternalOes,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLTextureTarget {
type GlibType = ffi::GstGLTextureTarget;
fn to_glib(&self) -> ffi::GstGLTextureTarget {
match *self {
GLTextureTarget::None => ffi::GST_GL_TEXTURE_TARGET_NONE,
GLTextureTarget::_2d => ffi::GST_GL_TEXTURE_TARGET_2D,
GLTextureTarget::Rectangle => ffi::GST_GL_TEXTURE_TARGET_RECTANGLE,
GLTextureTarget::ExternalOes => ffi::GST_GL_TEXTURE_TARGET_EXTERNAL_OES,
GLTextureTarget::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLTextureTarget> for GLTextureTarget {
fn from_glib(value: ffi::GstGLTextureTarget) -> Self {
skip_assert_initialized!();
match value {
0 => GLTextureTarget::None,
1 => GLTextureTarget::_2d,
2 => GLTextureTarget::Rectangle,
3 => GLTextureTarget::ExternalOes,
value => GLTextureTarget::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLUploadReturn {
Done,
Error,
Unsupported,
Reconfigure,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLUploadReturn {
type GlibType = ffi::GstGLUploadReturn;
fn to_glib(&self) -> ffi::GstGLUploadReturn {
match *self {
GLUploadReturn::Done => ffi::GST_GL_UPLOAD_DONE,
GLUploadReturn::Error => ffi::GST_GL_UPLOAD_ERROR,
GLUploadReturn::Unsupported => ffi::GST_GL_UPLOAD_UNSUPPORTED,
GLUploadReturn::Reconfigure => ffi::GST_GL_UPLOAD_RECONFIGURE,
GLUploadReturn::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLUploadReturn> for GLUploadReturn {
fn from_glib(value: ffi::GstGLUploadReturn) -> Self {
skip_assert_initialized!();
match value {
1 => GLUploadReturn::Done,
-1 => GLUploadReturn::Error,
-2 => GLUploadReturn::Unsupported,
-3 => GLUploadReturn::Reconfigure,
value => GLUploadReturn::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum GLWindowError {
Failed,
OldLibs,
ResourceUnavailable,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for GLWindowError {
type GlibType = ffi::GstGLWindowError;
fn to_glib(&self) -> ffi::GstGLWindowError {
match *self {
GLWindowError::Failed => ffi::GST_GL_WINDOW_ERROR_FAILED,
GLWindowError::OldLibs => ffi::GST_GL_WINDOW_ERROR_OLD_LIBS,
GLWindowError::ResourceUnavailable => ffi::GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE,
GLWindowError::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLWindowError> for GLWindowError {
fn from_glib(value: ffi::GstGLWindowError) -> Self {
skip_assert_initialized!();
match value {
0 => GLWindowError::Failed,
1 => GLWindowError::OldLibs,
2 => GLWindowError::ResourceUnavailable,
value => GLWindowError::__Unknown(value),
}
}
}
impl ErrorDomain for GLWindowError {
fn domain() -> Quark {
skip_assert_initialized!();
unsafe { from_glib(ffi::gst_gl_window_error_quark()) }
}
fn code(self) -> i32 {
self.to_glib()
}
fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code {
0 => Some(GLWindowError::Failed),
1 => Some(GLWindowError::OldLibs),
2 => Some(GLWindowError::ResourceUnavailable),
_ => Some(GLWindowError::Failed),
}
}
}

View file

@ -0,0 +1,123 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use ffi;
use glib::translate::*;
bitflags! {
pub struct GLAPI: u32 {
const NONE = 0;
const OPENGL = 1;
const OPENGL3 = 2;
const GLES1 = 32768;
const GLES2 = 65536;
const ANY = 4294967295;
}
}
#[doc(hidden)]
impl ToGlib for GLAPI {
type GlibType = ffi::GstGLAPI;
fn to_glib(&self) -> ffi::GstGLAPI {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLAPI> for GLAPI {
fn from_glib(value: ffi::GstGLAPI) -> GLAPI {
skip_assert_initialized!();
GLAPI::from_bits_truncate(value)
}
}
bitflags! {
pub struct GLDisplayType: u32 {
const NONE = 0;
const X11 = 1;
const WAYLAND = 2;
const COCOA = 4;
const WIN32 = 8;
const DISPMANX = 16;
const EGL = 32;
const VIV_FB = 64;
const GBM = 128;
const ANY = 4294967295;
}
}
#[doc(hidden)]
impl ToGlib for GLDisplayType {
type GlibType = ffi::GstGLDisplayType;
fn to_glib(&self) -> ffi::GstGLDisplayType {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLDisplayType> for GLDisplayType {
fn from_glib(value: ffi::GstGLDisplayType) -> GLDisplayType {
skip_assert_initialized!();
GLDisplayType::from_bits_truncate(value)
}
}
bitflags! {
pub struct GLPlatform: u32 {
const NONE = 0;
const EGL = 1;
const GLX = 2;
const WGL = 4;
const CGL = 8;
const EAGL = 16;
const ANY = 4294967295;
}
}
#[doc(hidden)]
impl ToGlib for GLPlatform {
type GlibType = ffi::GstGLPlatform;
fn to_glib(&self) -> ffi::GstGLPlatform {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLPlatform> for GLPlatform {
fn from_glib(value: ffi::GstGLPlatform) -> GLPlatform {
skip_assert_initialized!();
GLPlatform::from_bits_truncate(value)
}
}
bitflags! {
pub struct GLSLProfile: u32 {
const NONE = 0;
const ES = 1;
const CORE = 2;
const COMPATIBILITY = 4;
const ANY = 4294967295;
}
}
#[doc(hidden)]
impl ToGlib for GLSLProfile {
type GlibType = ffi::GstGLSLProfile;
fn to_glib(&self) -> ffi::GstGLSLProfile {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstGLSLProfile> for GLSLProfile {
fn from_glib(value: ffi::GstGLSLProfile) -> GLSLProfile {
skip_assert_initialized!();
GLSLProfile::from_bits_truncate(value)
}
}

View file

@ -0,0 +1,65 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
use ffi;
use glib;
use glib::StaticType;
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 GLBaseFilter(Object<ffi::GstGLBaseFilter, ffi::GstGLBaseFilterClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_base_filter_get_type(),
}
}
unsafe impl Send for GLBaseFilter {}
unsafe impl Sync for GLBaseFilter {}
pub trait GLBaseFilterExt {
fn get_property_context(&self) -> Option<GLContext>;
fn connect_property_context_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<GLBaseFilter> + IsA<glib::object::Object>> GLBaseFilterExt for O {
fn get_property_context(&self) -> Option<GLContext> {
unsafe {
let mut value = Value::from_type(<GLContext as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "context".to_glib_none().0, value.to_glib_none_mut().0);
value.get()
}
}
fn connect_property_context_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::context",
transmute(notify_context_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_context_trampoline<P>(this: *mut ffi::GstGLBaseFilter, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<GLBaseFilter> {
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&GLBaseFilter::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -0,0 +1,48 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
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 GLColorConvert(Object<ffi::GstGLColorConvert, ffi::GstGLColorConvertClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_color_convert_get_type(),
}
}
impl GLColorConvert {
pub fn new(context: &GLContext) -> GLColorConvert {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_gl_color_convert_new(context.to_glib_none().0))
}
}
pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> bool {
unsafe {
from_glib(ffi::gst_gl_color_convert_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0))
}
}
pub fn transform_caps(context: &GLContext, direction: gst::PadDirection, caps: &gst::Caps, filter: &gst::Caps) -> Option<gst::Caps> {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_gl_color_convert_transform_caps(context.to_glib_none().0, direction.to_glib(), caps.to_glib_none().0, filter.to_glib_none().0))
}
}
}
unsafe impl Send for GLColorConvert {}
unsafe impl Sync for GLColorConvert {}

View file

@ -0,0 +1,244 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use Error;
use GLAPI;
use GLDisplay;
use GLPlatform;
use GLSLProfile;
use GLSLVersion;
use GLWindow;
use ffi;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct GLContext(Object<ffi::GstGLContext, ffi::GstGLContextClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_context_get_type(),
}
}
impl GLContext {
pub fn new<P: IsA<GLDisplay>>(display: &P) -> GLContext {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_gl_context_new(display.to_glib_none().0))
}
}
pub fn get_current() -> Option<GLContext> {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::gst_gl_context_get_current())
}
}
pub fn get_current_gl_api(platform: GLPlatform) -> (GLAPI, u32, u32) {
assert_initialized_main_thread!();
unsafe {
let mut major = mem::uninitialized();
let mut minor = mem::uninitialized();
let ret = from_glib(ffi::gst_gl_context_get_current_gl_api(platform.to_glib(), &mut major, &mut minor));
(ret, major, minor)
}
}
}
unsafe impl Send for GLContext {}
unsafe impl Sync for GLContext {}
pub trait GLContextExt {
fn activate(&self, activate: bool) -> Result<(), glib::error::BoolError>;
fn can_share(&self, other_context: &GLContext) -> bool;
fn check_feature(&self, feature: &str) -> bool;
fn check_framebuffer_status(&self, fbo_target: u32) -> bool;
fn check_gl_version(&self, api: GLAPI, maj: i32, min: i32) -> bool;
fn clear_framebuffer(&self);
fn clear_shader(&self);
fn create<'a, P: Into<Option<&'a GLContext>>>(&self, other_context: P) -> Result<(), Error>;
fn destroy(&self);
fn fill_info(&self) -> Result<(), Error>;
fn get_display(&self) -> GLDisplay;
fn get_gl_api(&self) -> GLAPI;
fn get_gl_platform(&self) -> GLPlatform;
fn get_gl_platform_version(&self) -> (i32, i32);
fn get_gl_version(&self) -> (i32, i32);
fn get_window(&self) -> Option<GLWindow>;
fn is_shared(&self) -> bool;
fn set_shared_with(&self, share: &GLContext);
fn set_window(&self, window: &GLWindow) -> bool;
fn supports_glsl_profile_version(&self, version: GLSLVersion, profile: GLSLProfile) -> bool;
fn swap_buffers(&self);
}
impl<O: IsA<GLContext>> GLContextExt for O {
fn activate(&self, activate: bool) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_gl_context_activate(self.to_glib_none().0, activate.to_glib()), "Failed to activate OpenGL context")
}
}
fn can_share(&self, other_context: &GLContext) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_can_share(self.to_glib_none().0, other_context.to_glib_none().0))
}
}
fn check_feature(&self, feature: &str) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_check_feature(self.to_glib_none().0, feature.to_glib_none().0))
}
}
fn check_framebuffer_status(&self, fbo_target: u32) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_check_framebuffer_status(self.to_glib_none().0, fbo_target))
}
}
fn check_gl_version(&self, api: GLAPI, maj: i32, min: i32) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_check_gl_version(self.to_glib_none().0, api.to_glib(), maj, min))
}
}
fn clear_framebuffer(&self) {
unsafe {
ffi::gst_gl_context_clear_framebuffer(self.to_glib_none().0);
}
}
fn clear_shader(&self) {
unsafe {
ffi::gst_gl_context_clear_shader(self.to_glib_none().0);
}
}
fn create<'a, P: Into<Option<&'a GLContext>>>(&self, other_context: P) -> Result<(), Error> {
let other_context = other_context.into();
let other_context = other_context.to_glib_none();
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_gl_context_create(self.to_glib_none().0, other_context.0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn destroy(&self) {
unsafe {
ffi::gst_gl_context_destroy(self.to_glib_none().0);
}
}
fn fill_info(&self) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_gl_context_fill_info(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn get_display(&self) -> GLDisplay {
unsafe {
from_glib_full(ffi::gst_gl_context_get_display(self.to_glib_none().0))
}
}
fn get_gl_api(&self) -> GLAPI {
unsafe {
from_glib(ffi::gst_gl_context_get_gl_api(self.to_glib_none().0))
}
}
fn get_gl_platform(&self) -> GLPlatform {
unsafe {
from_glib(ffi::gst_gl_context_get_gl_platform(self.to_glib_none().0))
}
}
fn get_gl_platform_version(&self) -> (i32, i32) {
unsafe {
let mut major = mem::uninitialized();
let mut minor = mem::uninitialized();
ffi::gst_gl_context_get_gl_platform_version(self.to_glib_none().0, &mut major, &mut minor);
(major, minor)
}
}
fn get_gl_version(&self) -> (i32, i32) {
unsafe {
let mut maj = mem::uninitialized();
let mut min = mem::uninitialized();
ffi::gst_gl_context_get_gl_version(self.to_glib_none().0, &mut maj, &mut min);
(maj, min)
}
}
fn get_window(&self) -> Option<GLWindow> {
unsafe {
from_glib_full(ffi::gst_gl_context_get_window(self.to_glib_none().0))
}
}
fn is_shared(&self) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_is_shared(self.to_glib_none().0))
}
}
fn set_shared_with(&self, share: &GLContext) {
unsafe {
ffi::gst_gl_context_set_shared_with(self.to_glib_none().0, share.to_glib_none().0);
}
}
fn set_window(&self, window: &GLWindow) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_set_window(self.to_glib_none().0, window.to_glib_full()))
}
}
fn supports_glsl_profile_version(&self, version: GLSLVersion, profile: GLSLProfile) -> bool {
unsafe {
from_glib(ffi::gst_gl_context_supports_glsl_profile_version(self.to_glib_none().0, version.to_glib(), profile.to_glib()))
}
}
fn swap_buffers(&self) {
unsafe {
ffi::gst_gl_context_swap_buffers(self.to_glib_none().0);
}
}
}

View file

@ -0,0 +1,139 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use Error;
use GLAPI;
use GLContext;
use GLDisplayType;
use GLWindow;
use ffi;
use glib;
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 GLDisplay(Object<ffi::GstGLDisplay, ffi::GstGLDisplayClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_display_get_type(),
}
}
impl GLDisplay {
pub fn new() -> GLDisplay {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_gl_display_new())
}
}
}
impl Default for GLDisplay {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for GLDisplay {}
unsafe impl Sync for GLDisplay {}
pub trait GLDisplayExt {
fn add_context(&self, context: &GLContext) -> Result<(), glib::error::BoolError>;
fn create_context(&self, other_context: &GLContext) -> Result<GLContext, Error>;
fn create_window(&self) -> Option<GLWindow>;
fn filter_gl_api(&self, gl_api: GLAPI);
fn get_gl_api(&self) -> GLAPI;
fn get_gl_api_unlocked(&self) -> GLAPI;
fn get_handle_type(&self) -> GLDisplayType;
fn remove_window(&self, window: &GLWindow) -> Result<(), glib::error::BoolError>;
fn connect_create_context<F: Fn(&Self, &GLContext) -> GLContext + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<GLDisplay> + IsA<glib::object::Object>> GLDisplayExt for O {
fn add_context(&self, context: &GLContext) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_gl_display_add_context(self.to_glib_none().0, context.to_glib_none().0), "Failed to add OpenGL context")
}
}
fn create_context(&self, other_context: &GLContext) -> Result<GLContext, Error> {
unsafe {
let mut p_context = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::gst_gl_display_create_context(self.to_glib_none().0, other_context.to_glib_none().0, &mut p_context, &mut error);
if error.is_null() { Ok(from_glib_full(p_context)) } else { Err(from_glib_full(error)) }
}
}
fn create_window(&self) -> Option<GLWindow> {
unsafe {
from_glib_full(ffi::gst_gl_display_create_window(self.to_glib_none().0))
}
}
fn filter_gl_api(&self, gl_api: GLAPI) {
unsafe {
ffi::gst_gl_display_filter_gl_api(self.to_glib_none().0, gl_api.to_glib());
}
}
fn get_gl_api(&self) -> GLAPI {
unsafe {
from_glib(ffi::gst_gl_display_get_gl_api(self.to_glib_none().0))
}
}
fn get_gl_api_unlocked(&self) -> GLAPI {
unsafe {
from_glib(ffi::gst_gl_display_get_gl_api_unlocked(self.to_glib_none().0))
}
}
fn get_handle_type(&self) -> GLDisplayType {
unsafe {
from_glib(ffi::gst_gl_display_get_handle_type(self.to_glib_none().0))
}
}
fn remove_window(&self, window: &GLWindow) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_gl_display_remove_window(self.to_glib_none().0, window.to_glib_none().0), "Failed to remove window")
}
}
fn connect_create_context<F: Fn(&Self, &GLContext) -> GLContext + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &GLContext) -> GLContext + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "create-context",
transmute(create_context_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn create_context_trampoline<P>(this: *mut ffi::GstGLDisplay, context: *mut ffi::GstGLContext, f: glib_ffi::gpointer) -> *mut ffi::GstGLContext
where P: IsA<GLDisplay> {
let f: &&(Fn(&P, &GLContext) -> GLContext + Send + Sync + 'static) = transmute(f);
f(&GLDisplay::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(context)).to_glib_full()
}

View file

@ -0,0 +1,50 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLDisplay;
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 GLDisplayEGL(Object<ffi::GstGLDisplayEGL, ffi::GstGLDisplayEGLClass>): [
GLDisplay,
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_display_egl_get_type(),
}
}
impl GLDisplayEGL {
pub fn new() -> GLDisplayEGL {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_gl_display_egl_new())
}
}
//pub fn new_with_egl_display<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(display: P) -> GLDisplayEGL {
// unsafe { TODO: call ffi::gst_gl_display_egl_new_with_egl_display() }
//}
//pub fn get_from_native(type_: GLDisplayType, display: /*Unimplemented*/Fundamental: UIntPtr) -> /*Unimplemented*/Option<Fundamental: Pointer> {
// unsafe { TODO: call ffi::gst_gl_display_egl_get_from_native() }
//}
}
impl Default for GLDisplayEGL {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for GLDisplayEGL {}
unsafe impl Sync for GLDisplayEGL {}

View file

@ -0,0 +1,86 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct GLFramebuffer(Object<ffi::GstGLFramebuffer, ffi::GstGLFramebufferClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_framebuffer_get_type(),
}
}
impl GLFramebuffer {
pub fn new(context: &GLContext) -> GLFramebuffer {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_gl_framebuffer_new(context.to_glib_none().0))
}
}
pub fn new_with_default_depth(context: &GLContext, width: u32, height: u32) -> GLFramebuffer {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_gl_framebuffer_new_with_default_depth(context.to_glib_none().0, width, height))
}
}
}
unsafe impl Send for GLFramebuffer {}
unsafe impl Sync for GLFramebuffer {}
pub trait GLFramebufferExt {
//fn attach(&self, attachment_point: u32, mem: /*Ignored*/&mut GLBaseMemory);
fn bind(&self);
//fn draw_to_texture<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, mem: /*Ignored*/&mut GLMemory, func: /*Unknown conversion*//*Unimplemented*/GLFramebufferFunc, user_data: P) -> bool;
fn get_effective_dimensions(&self) -> (u32, u32);
fn get_id(&self) -> u32;
}
impl<O: IsA<GLFramebuffer>> GLFramebufferExt for O {
//fn attach(&self, attachment_point: u32, mem: /*Ignored*/&mut GLBaseMemory) {
// unsafe { TODO: call ffi::gst_gl_framebuffer_attach() }
//}
fn bind(&self) {
unsafe {
ffi::gst_gl_framebuffer_bind(self.to_glib_none().0);
}
}
//fn draw_to_texture<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, mem: /*Ignored*/&mut GLMemory, func: /*Unknown conversion*//*Unimplemented*/GLFramebufferFunc, user_data: P) -> bool {
// unsafe { TODO: call ffi::gst_gl_framebuffer_draw_to_texture() }
//}
fn get_effective_dimensions(&self) -> (u32, u32) {
unsafe {
let mut width = mem::uninitialized();
let mut height = mem::uninitialized();
ffi::gst_gl_framebuffer_get_effective_dimensions(self.to_glib_none().0, &mut width, &mut height);
(width, height)
}
}
fn get_id(&self) -> u32 {
unsafe {
ffi::gst_gl_framebuffer_get_id(self.to_glib_none().0)
}
}
}

View file

@ -0,0 +1,54 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
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 GLOverlayCompositor(Object<ffi::GstGLOverlayCompositor, ffi::GstGLOverlayCompositorClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_overlay_compositor_get_type(),
}
}
impl GLOverlayCompositor {
pub fn new(context: &GLContext) -> GLOverlayCompositor {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_gl_overlay_compositor_new(context.to_glib_none().0))
}
}
pub fn draw_overlays(&self) {
unsafe {
ffi::gst_gl_overlay_compositor_draw_overlays(self.to_glib_none().0);
}
}
pub fn free_overlays(&self) {
unsafe {
ffi::gst_gl_overlay_compositor_free_overlays(self.to_glib_none().0);
}
}
pub fn add_caps(caps: &gst::Caps) -> Option<gst::Caps> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_gl_overlay_compositor_add_caps(caps.to_glib_none().0))
}
}
}
unsafe impl Send for GLOverlayCompositor {}
unsafe impl Sync for GLOverlayCompositor {}

View file

@ -0,0 +1,273 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use Error;
use GLContext;
use GLSLStage;
use ffi;
use glib::StaticType;
use glib::Value;
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 GLShader(Object<ffi::GstGLShader, ffi::GstGLShaderClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_shader_get_type(),
}
}
impl GLShader {
pub fn new(context: &GLContext) -> GLShader {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_gl_shader_new(context.to_glib_none().0))
}
}
pub fn new_default(context: &GLContext) -> Result<GLShader, Error> {
skip_assert_initialized!();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::gst_gl_shader_new_default(context.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
//pub fn new_link_with_stages(context: &GLContext, error: &mut Error, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> GLShader {
// unsafe { TODO: call ffi::gst_gl_shader_new_link_with_stages() }
//}
//pub fn new_with_stages(context: &GLContext, error: &mut Error, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> GLShader {
// unsafe { TODO: call ffi::gst_gl_shader_new_with_stages() }
//}
pub fn attach(&self, stage: &GLSLStage) -> bool {
unsafe {
from_glib(ffi::gst_gl_shader_attach(self.to_glib_none().0, stage.to_glib_none().0))
}
}
pub fn attach_unlocked(&self, stage: &GLSLStage) -> bool {
unsafe {
from_glib(ffi::gst_gl_shader_attach_unlocked(self.to_glib_none().0, stage.to_glib_none().0))
}
}
pub fn bind_attribute_location(&self, index: u32, name: &str) {
unsafe {
ffi::gst_gl_shader_bind_attribute_location(self.to_glib_none().0, index, name.to_glib_none().0);
}
}
pub fn bind_frag_data_location(&self, index: u32, name: &str) {
unsafe {
ffi::gst_gl_shader_bind_frag_data_location(self.to_glib_none().0, index, name.to_glib_none().0);
}
}
pub fn compile_attach_stage(&self, stage: &GLSLStage) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_gl_shader_compile_attach_stage(self.to_glib_none().0, stage.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn detach(&self, stage: &GLSLStage) {
unsafe {
ffi::gst_gl_shader_detach(self.to_glib_none().0, stage.to_glib_none().0);
}
}
pub fn detach_unlocked(&self, stage: &GLSLStage) {
unsafe {
ffi::gst_gl_shader_detach_unlocked(self.to_glib_none().0, stage.to_glib_none().0);
}
}
pub fn get_attribute_location(&self, name: &str) -> i32 {
unsafe {
ffi::gst_gl_shader_get_attribute_location(self.to_glib_none().0, name.to_glib_none().0)
}
}
pub fn get_program_handle(&self) -> i32 {
unsafe {
ffi::gst_gl_shader_get_program_handle(self.to_glib_none().0)
}
}
pub fn is_linked(&self) -> bool {
unsafe {
from_glib(ffi::gst_gl_shader_is_linked(self.to_glib_none().0))
}
}
pub fn link(&self) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_gl_shader_link(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn release(&self) {
unsafe {
ffi::gst_gl_shader_release(self.to_glib_none().0);
}
}
pub fn release_unlocked(&self) {
unsafe {
ffi::gst_gl_shader_release_unlocked(self.to_glib_none().0);
}
}
pub fn set_uniform_1f(&self, name: &str, value: f32) {
unsafe {
ffi::gst_gl_shader_set_uniform_1f(self.to_glib_none().0, name.to_glib_none().0, value);
}
}
pub fn set_uniform_1fv(&self, name: &str, value: &[f32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_1fv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_1i(&self, name: &str, value: i32) {
unsafe {
ffi::gst_gl_shader_set_uniform_1i(self.to_glib_none().0, name.to_glib_none().0, value);
}
}
pub fn set_uniform_1iv(&self, name: &str, value: &[i32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_1iv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_2f(&self, name: &str, v0: f32, v1: f32) {
unsafe {
ffi::gst_gl_shader_set_uniform_2f(self.to_glib_none().0, name.to_glib_none().0, v0, v1);
}
}
pub fn set_uniform_2fv(&self, name: &str, value: &[f32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_2fv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_2i(&self, name: &str, v0: i32, v1: i32) {
unsafe {
ffi::gst_gl_shader_set_uniform_2i(self.to_glib_none().0, name.to_glib_none().0, v0, v1);
}
}
pub fn set_uniform_2iv(&self, name: &str, value: &[i32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_2iv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_3f(&self, name: &str, v0: f32, v1: f32, v2: f32) {
unsafe {
ffi::gst_gl_shader_set_uniform_3f(self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2);
}
}
pub fn set_uniform_3fv(&self, name: &str, value: &[f32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_3fv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_3i(&self, name: &str, v0: i32, v1: i32, v2: i32) {
unsafe {
ffi::gst_gl_shader_set_uniform_3i(self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2);
}
}
pub fn set_uniform_3iv(&self, name: &str, value: &[i32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_3iv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_4f(&self, name: &str, v0: f32, v1: f32, v2: f32, v3: f32) {
unsafe {
ffi::gst_gl_shader_set_uniform_4f(self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2, v3);
}
}
pub fn set_uniform_4fv(&self, name: &str, value: &[f32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_4fv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn set_uniform_4i(&self, name: &str, v0: i32, v1: i32, v2: i32, v3: i32) {
unsafe {
ffi::gst_gl_shader_set_uniform_4i(self.to_glib_none().0, name.to_glib_none().0, v0, v1, v2, v3);
}
}
pub fn set_uniform_4iv(&self, name: &str, value: &[i32]) {
let count = value.len() as u32;
unsafe {
ffi::gst_gl_shader_set_uniform_4iv(self.to_glib_none().0, name.to_glib_none().0, count, value.to_glib_none().0);
}
}
pub fn use_(&self) {
unsafe {
ffi::gst_gl_shader_use(self.to_glib_none().0);
}
}
pub fn get_property_linked(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "linked".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
pub fn connect_property_linked_notify<F: Fn(&GLShader) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&GLShader) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::linked",
transmute(notify_linked_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe impl Send for GLShader {}
unsafe impl Sync for GLShader {}
unsafe extern "C" fn notify_linked_trampoline(this: *mut ffi::GstGLShader, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
let f: &&(Fn(&GLShader) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}

View file

@ -0,0 +1,69 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
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 GLUpload(Object<ffi::GstGLUpload, ffi::GstGLUploadClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_upload_get_type(),
}
}
impl GLUpload {
pub fn new(context: &GLContext) -> GLUpload {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_gl_upload_new(context.to_glib_none().0))
}
}
pub fn get_caps(&self) -> (gst::Caps, gst::Caps) {
unsafe {
let mut in_caps = ptr::null_mut();
let mut out_caps = ptr::null_mut();
ffi::gst_gl_upload_get_caps(self.to_glib_none().0, &mut in_caps, &mut out_caps);
(from_glib_full(in_caps), from_glib_full(out_caps))
}
}
pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> bool {
unsafe {
from_glib(ffi::gst_gl_upload_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0))
}
}
pub fn set_context(&self, context: &GLContext) {
unsafe {
ffi::gst_gl_upload_set_context(self.to_glib_none().0, context.to_glib_none().0);
}
}
pub fn transform_caps(&self, context: &GLContext, direction: gst::PadDirection, caps: &gst::Caps, filter: &gst::Caps) -> Option<gst::Caps> {
unsafe {
from_glib_full(ffi::gst_gl_upload_transform_caps(self.to_glib_none().0, context.to_glib_none().0, direction.to_glib(), caps.to_glib_none().0, filter.to_glib_none().0))
}
}
pub fn get_input_template_caps() -> gst::Caps {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_gl_upload_get_input_template_caps())
}
}
}
unsafe impl Send for GLUpload {}
unsafe impl Sync for GLUpload {}

View file

@ -0,0 +1,214 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
use GLStereoDownmix;
use ffi;
use glib::StaticType;
use glib::Value;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use gst_video;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct GLViewConvert(Object<ffi::GstGLViewConvert, ffi::GstGLViewConvertClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_view_convert_get_type(),
}
}
impl GLViewConvert {
pub fn new() -> GLViewConvert {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_gl_view_convert_new())
}
}
pub fn perform(&self, inbuf: &gst::Buffer) -> Option<gst::Buffer> {
unsafe {
from_glib_full(ffi::gst_gl_view_convert_perform(self.to_glib_none().0, inbuf.to_glib_none().0))
}
}
pub fn reset(&self) {
unsafe {
ffi::gst_gl_view_convert_reset(self.to_glib_none().0);
}
}
pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> bool {
unsafe {
from_glib(ffi::gst_gl_view_convert_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0))
}
}
pub fn set_context(&self, context: &GLContext) {
unsafe {
ffi::gst_gl_view_convert_set_context(self.to_glib_none().0, context.to_glib_none().0);
}
}
pub fn transform_caps(&self, direction: gst::PadDirection, caps: &gst::Caps, filter: &gst::Caps) -> Option<gst::Caps> {
unsafe {
from_glib_full(ffi::gst_gl_view_convert_transform_caps(self.to_glib_none().0, direction.to_glib(), caps.to_glib_none().0, filter.to_glib_none().0))
}
}
pub fn get_property_downmix_mode(&self) -> GLStereoDownmix {
unsafe {
let mut value = Value::from_type(<GLStereoDownmix as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "downmix-mode".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
pub fn set_property_downmix_mode(&self, downmix_mode: GLStereoDownmix) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "downmix-mode".to_glib_none().0, Value::from(&downmix_mode).to_glib_none().0);
}
}
pub fn get_property_input_flags_override(&self) -> gst_video::VideoMultiviewFlags {
unsafe {
let mut value = Value::from_type(<gst_video::VideoMultiviewFlags as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "input-flags-override".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
pub fn set_property_input_flags_override(&self, input_flags_override: gst_video::VideoMultiviewFlags) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "input-flags-override".to_glib_none().0, Value::from(&input_flags_override).to_glib_none().0);
}
}
pub fn get_property_input_mode_override(&self) -> gst_video::VideoMultiviewMode {
unsafe {
let mut value = Value::from_type(<gst_video::VideoMultiviewMode as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "input-mode-override".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
pub fn set_property_input_mode_override(&self, input_mode_override: gst_video::VideoMultiviewMode) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "input-mode-override".to_glib_none().0, Value::from(&input_mode_override).to_glib_none().0);
}
}
pub fn get_property_output_flags_override(&self) -> gst_video::VideoMultiviewFlags {
unsafe {
let mut value = Value::from_type(<gst_video::VideoMultiviewFlags as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "output-flags-override".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
pub fn set_property_output_flags_override(&self, output_flags_override: gst_video::VideoMultiviewFlags) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "output-flags-override".to_glib_none().0, Value::from(&output_flags_override).to_glib_none().0);
}
}
pub fn get_property_output_mode_override(&self) -> gst_video::VideoMultiviewMode {
unsafe {
let mut value = Value::from_type(<gst_video::VideoMultiviewMode as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "output-mode-override".to_glib_none().0, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
pub fn set_property_output_mode_override(&self, output_mode_override: gst_video::VideoMultiviewMode) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "output-mode-override".to_glib_none().0, Value::from(&output_mode_override).to_glib_none().0);
}
}
pub fn connect_property_downmix_mode_notify<F: Fn(&GLViewConvert) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&GLViewConvert) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::downmix-mode",
transmute(notify_downmix_mode_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_property_input_flags_override_notify<F: Fn(&GLViewConvert) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&GLViewConvert) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::input-flags-override",
transmute(notify_input_flags_override_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_property_input_mode_override_notify<F: Fn(&GLViewConvert) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&GLViewConvert) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::input-mode-override",
transmute(notify_input_mode_override_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_property_output_flags_override_notify<F: Fn(&GLViewConvert) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&GLViewConvert) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::output-flags-override",
transmute(notify_output_flags_override_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_property_output_mode_override_notify<F: Fn(&GLViewConvert) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&GLViewConvert) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::output-mode-override",
transmute(notify_output_mode_override_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
impl Default for GLViewConvert {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for GLViewConvert {}
unsafe impl Sync for GLViewConvert {}
unsafe extern "C" fn notify_downmix_mode_trampoline(this: *mut ffi::GstGLViewConvert, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
let f: &&(Fn(&GLViewConvert) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}
unsafe extern "C" fn notify_input_flags_override_trampoline(this: *mut ffi::GstGLViewConvert, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
let f: &&(Fn(&GLViewConvert) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}
unsafe extern "C" fn notify_input_mode_override_trampoline(this: *mut ffi::GstGLViewConvert, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
let f: &&(Fn(&GLViewConvert) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}
unsafe extern "C" fn notify_output_flags_override_trampoline(this: *mut ffi::GstGLViewConvert, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
let f: &&(Fn(&GLViewConvert) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}
unsafe extern "C" fn notify_output_mode_override_trampoline(this: *mut ffi::GstGLViewConvert, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer) {
let f: &&(Fn(&GLViewConvert) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}

View file

@ -0,0 +1,187 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use GLContext;
use GLDisplay;
use ffi;
use glib;
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 libc;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct GLWindow(Object<ffi::GstGLWindow, ffi::GstGLWindowClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_gl_window_get_type(),
}
}
impl GLWindow {
pub fn new<P: IsA<GLDisplay>>(display: &P) -> GLWindow {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_gl_window_new(display.to_glib_none().0))
}
}
}
unsafe impl Send for GLWindow {}
unsafe impl Sync for GLWindow {}
pub trait GLWindowExt {
fn draw(&self);
fn get_context(&self) -> Option<GLContext>;
fn get_surface_dimensions(&self) -> (u32, u32);
fn handle_events(&self, handle_events: bool);
fn queue_resize(&self);
fn quit(&self);
fn resize(&self, width: u32, height: u32);
fn run(&self);
fn send_key_event(&self, event_type: &str, key_str: &str);
fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64);
fn set_preferred_size(&self, width: i32, height: i32);
fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> bool;
fn show(&self);
fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<GLWindow> + IsA<glib::object::Object>> GLWindowExt for O {
fn draw(&self) {
unsafe {
ffi::gst_gl_window_draw(self.to_glib_none().0);
}
}
fn get_context(&self) -> Option<GLContext> {
unsafe {
from_glib_full(ffi::gst_gl_window_get_context(self.to_glib_none().0))
}
}
fn get_surface_dimensions(&self) -> (u32, u32) {
unsafe {
let mut width = mem::uninitialized();
let mut height = mem::uninitialized();
ffi::gst_gl_window_get_surface_dimensions(self.to_glib_none().0, &mut width, &mut height);
(width, height)
}
}
fn handle_events(&self, handle_events: bool) {
unsafe {
ffi::gst_gl_window_handle_events(self.to_glib_none().0, handle_events.to_glib());
}
}
fn queue_resize(&self) {
unsafe {
ffi::gst_gl_window_queue_resize(self.to_glib_none().0);
}
}
fn quit(&self) {
unsafe {
ffi::gst_gl_window_quit(self.to_glib_none().0);
}
}
fn resize(&self, width: u32, height: u32) {
unsafe {
ffi::gst_gl_window_resize(self.to_glib_none().0, width, height);
}
}
fn run(&self) {
unsafe {
ffi::gst_gl_window_run(self.to_glib_none().0);
}
}
fn send_key_event(&self, event_type: &str, key_str: &str) {
unsafe {
ffi::gst_gl_window_send_key_event(self.to_glib_none().0, event_type.to_glib_none().0, key_str.to_glib_none().0);
}
}
fn send_mouse_event(&self, event_type: &str, button: i32, posx: f64, posy: f64) {
unsafe {
ffi::gst_gl_window_send_mouse_event(self.to_glib_none().0, event_type.to_glib_none().0, button, posx, posy);
}
}
fn set_preferred_size(&self, width: i32, height: i32) {
unsafe {
ffi::gst_gl_window_set_preferred_size(self.to_glib_none().0, width, height);
}
}
fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> bool {
unsafe {
from_glib(ffi::gst_gl_window_set_render_rectangle(self.to_glib_none().0, x, y, width, height))
}
}
fn show(&self) {
unsafe {
ffi::gst_gl_window_show(self.to_glib_none().0);
}
}
fn connect_key_event<F: Fn(&Self, &str, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &str, &str) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "key-event",
transmute(key_event_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
fn connect_mouse_event<F: Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self, &str, i32, f64, f64) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "mouse-event",
transmute(mouse_event_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn key_event_trampoline<P>(this: *mut ffi::GstGLWindow, id: *mut libc::c_char, key: *mut libc::c_char, f: glib_ffi::gpointer)
where P: IsA<GLWindow> {
let f: &&(Fn(&P, &str, &str) + Send + Sync + 'static) = transmute(f);
f(&GLWindow::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(id), &String::from_glib_none(key))
}
unsafe extern "C" fn mouse_event_trampoline<P>(this: *mut ffi::GstGLWindow, id: *mut libc::c_char, button: libc::c_int, x: libc::c_double, y: libc::c_double, f: glib_ffi::gpointer)
where P: IsA<GLWindow> {
let f: &&(Fn(&P, &str, i32, f64, f64) + Send + Sync + 'static) = transmute(f);
f(&GLWindow::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(id), button, x, y)
}

View file

@ -0,0 +1,106 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use Error;
use GLContext;
use GLSLProfile;
use GLSLVersion;
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 GLSLStage(Object<ffi::GstGLSLStage, ffi::GstGLSLStageClass>): [
gst::Object => gst_ffi::GstObject,
];
match fn {
get_type => || ffi::gst_glsl_stage_get_type(),
}
}
impl GLSLStage {
pub fn new(context: &GLContext, type_: u32) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new(context.to_glib_none().0, type_))
}
}
pub fn new_default_fragment(context: &GLContext) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_default_fragment(context.to_glib_none().0))
}
}
pub fn new_default_vertex(context: &GLContext) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_default_vertex(context.to_glib_none().0))
}
}
pub fn new_with_string(context: &GLContext, type_: u32, version: GLSLVersion, profile: GLSLProfile, str: &str) -> GLSLStage {
skip_assert_initialized!();
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_with_string(context.to_glib_none().0, type_, version.to_glib(), profile.to_glib(), str.to_glib_none().0))
}
}
pub fn new_with_strings(context: &GLContext, type_: u32, version: GLSLVersion, profile: GLSLProfile, str: &[&str]) -> GLSLStage {
skip_assert_initialized!();
let n_strings = str.len() as i32;
unsafe {
from_glib_none(ffi::gst_glsl_stage_new_with_strings(context.to_glib_none().0, type_, version.to_glib(), profile.to_glib(), n_strings, str.to_glib_none().0))
}
}
pub fn compile(&self) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_glsl_stage_compile(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn get_handle(&self) -> u32 {
unsafe {
ffi::gst_glsl_stage_get_handle(self.to_glib_none().0)
}
}
pub fn get_profile(&self) -> GLSLProfile {
unsafe {
from_glib(ffi::gst_glsl_stage_get_profile(self.to_glib_none().0))
}
}
pub fn get_shader_type(&self) -> u32 {
unsafe {
ffi::gst_glsl_stage_get_shader_type(self.to_glib_none().0)
}
}
pub fn get_version(&self) -> GLSLVersion {
unsafe {
from_glib(ffi::gst_glsl_stage_get_version(self.to_glib_none().0))
}
}
pub fn set_strings(&self, version: GLSLVersion, profile: GLSLProfile, str: &[&str]) -> bool {
let n_strings = str.len() as i32;
unsafe {
from_glib(ffi::gst_glsl_stage_set_strings(self.to_glib_none().0, version.to_glib(), profile.to_glib(), n_strings, str.to_glib_none().0))
}
}
}
unsafe impl Send for GLSLStage {}
unsafe impl Sync for GLSLStage {}

View file

@ -0,0 +1,72 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
mod gl_base_filter;
pub use self::gl_base_filter::GLBaseFilter;
pub use self::gl_base_filter::GLBaseFilterExt;
mod gl_color_convert;
pub use self::gl_color_convert::GLColorConvert;
mod gl_context;
pub use self::gl_context::GLContext;
pub use self::gl_context::GLContextExt;
mod gl_display;
pub use self::gl_display::GLDisplay;
pub use self::gl_display::GLDisplayExt;
#[cfg(any(feature = "egl", feature = "dox"))]
mod gl_display_egl;
#[cfg(any(feature = "egl", feature = "dox"))]
pub use self::gl_display_egl::GLDisplayEGL;
mod gl_framebuffer;
pub use self::gl_framebuffer::GLFramebuffer;
pub use self::gl_framebuffer::GLFramebufferExt;
mod gl_overlay_compositor;
pub use self::gl_overlay_compositor::GLOverlayCompositor;
mod glsl_stage;
pub use self::glsl_stage::GLSLStage;
mod gl_shader;
pub use self::gl_shader::GLShader;
mod gl_upload;
pub use self::gl_upload::GLUpload;
mod gl_view_convert;
pub use self::gl_view_convert::GLViewConvert;
mod gl_window;
pub use self::gl_window::GLWindow;
pub use self::gl_window::GLWindowExt;
mod enums;
pub use self::enums::GLContextError;
pub use self::enums::GLFormat;
pub use self::enums::GLQueryType;
pub use self::enums::GLSLError;
pub use self::enums::GLSLVersion;
pub use self::enums::GLStereoDownmix;
pub use self::enums::GLTextureTarget;
pub use self::enums::GLUploadReturn;
pub use self::enums::GLWindowError;
mod flags;
pub use self::flags::GLAPI;
pub use self::flags::GLDisplayType;
pub use self::flags::GLPlatform;
pub use self::flags::GLSLProfile;
#[doc(hidden)]
pub mod traits {
pub use super::GLBaseFilterExt;
pub use super::GLContextExt;
pub use super::GLDisplayExt;
pub use super::GLFramebufferExt;
pub use super::GLWindowExt;
}

View file

@ -0,0 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
from gir-files (https://github.com/gtk-rs/gir-files @ ???)

View file

@ -0,0 +1,21 @@
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.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 gst::CapsFeatures;
use std::ffi::CStr;
lazy_static! {
pub static ref CAPS_FEATURE_MEMORY_GL_MEMORY: &'static str = unsafe {
CStr::from_ptr(ffi::GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
.to_str()
.unwrap()
};
pub static ref CAPS_FEATURES_MEMORY_GL_MEMORY: CapsFeatures =
CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_GL_MEMORY]);
}

View file

@ -0,0 +1,41 @@
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.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 glib::IsA;
use gst::{ContextRef, MiniObject};
use std::ptr;
use GLDisplay;
pub trait ContextGLExt {
fn get_gl_display(&self) -> Option<GLDisplay>;
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T);
}
impl ContextGLExt for ContextRef {
fn get_gl_display(&self) -> Option<GLDisplay> {
unsafe {
let mut display = ptr::null_mut();
if from_glib(ffi::gst_context_get_gl_display(
self.as_mut_ptr(),
&mut display,
)) {
Some(from_glib_full(display))
} else {
None
}
}
}
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T) {
unsafe {
ffi::gst_context_set_gl_display(self.as_mut_ptr(), display.to_glib_none().0);
}
}
}

View file

@ -0,0 +1,77 @@
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.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 glib::IsA;
use libc::uintptr_t;
use GLContext;
use GLDisplay;
use GLPlatform;
use GLAPI;
impl GLContext {
pub unsafe fn new_wrapped<T: IsA<GLDisplay>>(
display: &T,
handle: uintptr_t,
context_type: GLPlatform,
available_apis: GLAPI,
) -> Option<GLContext> {
from_glib_full(ffi::gst_gl_context_new_wrapped(
display.to_glib_none().0,
handle,
context_type.to_glib(),
available_apis.to_glib(),
))
}
}
pub trait GLContextExtManual {
fn get_gl_context(&self) -> uintptr_t;
fn get_proc_address(&self, name: &str) -> uintptr_t;
fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t;
fn get_proc_address_with_platform(
context_type: GLPlatform,
gl_api: GLAPI,
name: &str,
) -> uintptr_t;
}
impl<O: IsA<GLContext>> GLContextExtManual for O {
fn get_gl_context(&self) -> uintptr_t {
unsafe { ffi::gst_gl_context_get_gl_context(self.to_glib_none().0) as uintptr_t }
}
fn get_proc_address(&self, name: &str) -> uintptr_t {
unsafe {
ffi::gst_gl_context_get_proc_address(self.to_glib_none().0, name.to_glib_none().0)
as uintptr_t
}
}
fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t {
unsafe { ffi::gst_gl_context_get_current_gl_context(context_type.to_glib()) as uintptr_t }
}
fn get_proc_address_with_platform(
context_type: GLPlatform,
gl_api: GLAPI,
name: &str,
) -> uintptr_t {
unsafe {
ffi::gst_gl_context_get_proc_address_with_platform(
context_type.to_glib(),
gl_api.to_glib(),
name.to_glib_none().0,
) as uintptr_t
}
}
}

View file

@ -0,0 +1,18 @@
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.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 std::ffi::CStr;
lazy_static! {
pub static ref GL_DISPLAY_CONTEXT_TYPE: &'static str = unsafe {
CStr::from_ptr(ffi::GST_GL_DISPLAY_CONTEXT_TYPE)
.to_str()
.unwrap()
};
}

View file

@ -0,0 +1,26 @@
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.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 glib_ffi::gpointer;
use libc::uintptr_t;
use GLDisplayEGL;
use GLDisplayType;
impl GLDisplayEGL {
pub unsafe fn new_with_egl_display(display: uintptr_t) -> Option<GLDisplayEGL> {
from_glib_full(ffi::gst_gl_display_egl_new_with_egl_display(
display as gpointer,
))
}
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
ffi::gst_gl_display_egl_get_from_native(display_type.to_glib(), display)
}
}

View file

@ -0,0 +1,101 @@
// Copyright (C) 2018 Víctor Jáquez <vjaquez@igalia.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_ffi;
use gst_ffi;
use gst_video_ffi;
use glib::translate::{from_glib, ToGlibPtr};
use gst;
use gst::MiniObject;
use gst_video::video_frame::Readable;
use gst_video::*;
use byteorder::{NativeEndian, ReadBytesExt};
use std::mem;
pub trait VideoFrameGLExt {
fn from_buffer_readable_gl(
buffer: gst::Buffer,
info: &VideoInfo,
) -> Result<VideoFrame<Readable>, gst::Buffer>;
fn get_texture_id(&self, idx: u32) -> Option<u32>;
}
impl VideoFrameGLExt for VideoFrame<Readable> {
fn from_buffer_readable_gl(
buffer: gst::Buffer,
info: &VideoInfo,
) -> Result<VideoFrame<Readable>, gst::Buffer> {
skip_assert_initialized!();
let n_mem = match buffer_n_gl_memory(buffer.as_ref()) {
Some(n) => n,
None => return Err(buffer),
};
// FIXME: planes are not memories, in multiview use case,
// number of memories = planes * views, but the raw memory is
// not exposed in videoframe
if n_mem != info.n_planes() {
return Err(buffer);
}
unsafe {
let mut frame = mem::zeroed();
let res: bool = from_glib(gst_video_ffi::gst_video_frame_map(
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
gst_video_ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_ffi::GST_MAP_READ
| ffi::GST_MAP_GL as u32,
));
if !res {
Err(buffer)
} else {
Ok(VideoFrame::from_glib_full(frame))
}
}
}
fn get_texture_id(&self, idx: u32) -> Option<u32> {
let len = buffer_n_gl_memory(self.buffer())?;
if idx >= len {
return None;
}
// FIXME: planes are not memories
if idx > self.n_planes() {
return None;
}
let mut data = self.plane_data(idx)?;
let id = &data.read_u32::<NativeEndian>().ok()?;
Some(*id)
}
}
fn buffer_n_gl_memory(buffer: &gst::BufferRef) -> Option<u32> {
unsafe {
let buf = buffer.as_mut_ptr();
let num = gst_ffi::gst_buffer_n_memory(buf);
for i in 0..num - 1 {
let mem = gst_ffi::gst_buffer_peek_memory(buf, i);
if ffi::gst_is_gl_memory(mem) != glib_ffi::GTRUE {
return None;
}
}
Some(num as u32)
}
}

72
gstreamer-gl/src/lib.rs Normal file
View file

@ -0,0 +1,72 @@
// Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
// 2018 Víctor M. Jáquez L. <vjaquez@igalia.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.
#[macro_use]
extern crate bitflags;
extern crate byteorder;
#[macro_use]
extern crate lazy_static;
extern crate libc;
#[macro_use]
extern crate glib;
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern crate gstreamer as gst;
extern crate gstreamer_base as gst_base;
extern crate gstreamer_gl_sys as ffi;
extern crate gstreamer_sys as gst_ffi;
extern crate gstreamer_video as gst_video;
extern crate gstreamer_video_sys as gst_video_ffi;
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.");
}
};
}
macro_rules! skip_assert_initialized {
() => {};
}
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 caps_features;
pub use caps_features::{CAPS_FEATURES_MEMORY_GL_MEMORY, CAPS_FEATURE_MEMORY_GL_MEMORY};
mod context;
pub use context::ContextGLExt;
mod gl_context;
pub use gl_context::GLContextExtManual;
mod gl_display;
pub use gl_display::GL_DISPLAY_CONTEXT_TYPE;
#[cfg(any(feature = "egl", feature = "dox"))]
mod gl_display_egl;
mod gl_video_frame;
pub use gl_video_frame::VideoFrameGLExt;
// 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::*;
pub use context::ContextGLExt;
pub use gl_context::GLContextExtManual;
pub use gl_video_frame::VideoFrameGLExt;
}