gstreamer-gl: Update manual code to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-22 12:28:12 +02:00
parent 01f5138e76
commit e7d6167409
11 changed files with 100 additions and 132 deletions

View file

@ -12,35 +12,32 @@ homepage = "https://gstreamer.freedesktop.org"
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_gl/" documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_gl/"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"] keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs" build = "build.rs"
edition = "2018"
[dependencies] [dependencies]
bitflags = "1.0" bitflags = "1.0"
byteorder = "1" byteorder = "1"
libc = "0.2" libc = "0.2"
once_cell = "1.0" once_cell = "1.0"
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" } ffi = { package = "gstreamer-gl-sys", path = "../gstreamer-gl/sys" }
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_14"] }
gstreamer-video-sys = { path = "../gstreamer-video/sys", features = ["v1_14"] }
gstreamer-gl-sys = { path = "../gstreamer-gl/sys" }
glib = { git = "https://github.com/gtk-rs/gtk-rs" } glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer = { path = "../gstreamer", features = ["v1_14"] } gst = { package = "gstreamer", path = "../gstreamer", features = ["v1_14"] }
gstreamer-base = { path = "../gstreamer-base", features = ["v1_14"] } gst-base = { package = "gstreamer-base", path = "../gstreamer-base", features = ["v1_14"] }
gstreamer-video = { path = "../gstreamer-video", features = ["v1_14"] } gst-video = { package = "gstreamer-video", path = "../gstreamer-video", features = ["v1_14"] }
[build-dependencies] [build-dependencies]
gstreamer-rs-lgpl-docs = { path = "../docs", optional = true } gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
[features] [features]
default = [] default = []
dox = ["v1_18", "gstreamer-gl-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-base/dox", "gstreamer-video/dox"] dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox", "gst-base/dox", "gst-video/dox"]
egl = ["gstreamer-gl-sys/egl"] egl = ["ffi/egl"]
x11 = ["gstreamer-gl-sys/x11"] x11 = ["ffi/x11"]
wayland = ["gstreamer-gl-sys/wayland"] wayland = ["ffi/wayland"]
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"] embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"] purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
v1_16 = ["gstreamer/v1_16", "gstreamer-base/v1_16", "gstreamer-video/v1_16", "gstreamer-gl-sys/v1_16"] v1_16 = ["gst/v1_16", "gst-base/v1_16", "gst-video/v1_16", "ffi/v1_16"]
v1_18 = ["gstreamer/v1_18", "gstreamer-base/v1_18", "gstreamer-video/v1_18", "gstreamer-gl-sys/v1_18", "v1_16"] v1_18 = ["gst/v1_18", "gst-base/v1_18", "gst-video/v1_18", "ffi/v1_18", "v1_16"]
[package.metadata.docs.rs] [package.metadata.docs.rs]
features = ["dox", "embed-lgpl-docs"] features = ["dox", "embed-lgpl-docs"]

View file

@ -7,13 +7,12 @@
// except according to those terms. // except according to those terms.
use gst::CapsFeatures; use gst::CapsFeatures;
use gst_gl_sys;
use std::ffi::CStr; use std::ffi::CStr;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
pub static CAPS_FEATURE_MEMORY_GL_MEMORY: Lazy<&'static str> = Lazy::new(|| unsafe { pub static CAPS_FEATURE_MEMORY_GL_MEMORY: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(gst_gl_sys::GST_CAPS_FEATURE_MEMORY_GL_MEMORY) CStr::from_ptr(ffi::GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
.to_str() .to_str()
.unwrap() .unwrap()
}); });

View file

@ -6,12 +6,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::GLDisplay;
use glib::translate::*; use glib::translate::*;
use glib::IsA; use glib::IsA;
use gst::ContextRef; use gst::ContextRef;
use gst_gl_sys;
use std::ptr; use std::ptr;
use GLDisplay;
pub trait ContextGLExt { pub trait ContextGLExt {
fn get_gl_display(&self) -> Option<GLDisplay>; fn get_gl_display(&self) -> Option<GLDisplay>;
@ -22,7 +21,7 @@ impl ContextGLExt for ContextRef {
fn get_gl_display(&self) -> Option<GLDisplay> { fn get_gl_display(&self) -> Option<GLDisplay> {
unsafe { unsafe {
let mut display = ptr::null_mut(); let mut display = ptr::null_mut();
if from_glib(gst_gl_sys::gst_context_get_gl_display( if from_glib(ffi::gst_context_get_gl_display(
self.as_mut_ptr(), self.as_mut_ptr(),
&mut display, &mut display,
)) { )) {
@ -35,10 +34,7 @@ impl ContextGLExt for ContextRef {
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T) { fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T) {
unsafe { unsafe {
gst_gl_sys::gst_context_set_gl_display( ffi::gst_context_set_gl_display(self.as_mut_ptr(), display.as_ref().to_glib_none().0);
self.as_mut_ptr(),
display.as_ref().to_glib_none().0,
);
} }
} }
} }

View file

@ -6,14 +6,13 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::GLContext;
use crate::GLDisplay;
use crate::GLPlatform;
use crate::GLAPI;
use glib::translate::*; use glib::translate::*;
use glib::IsA; use glib::IsA;
use gst_gl_sys;
use libc::uintptr_t; use libc::uintptr_t;
use GLContext;
use GLDisplay;
use GLPlatform;
use GLAPI;
impl GLContext { impl GLContext {
pub unsafe fn new_wrapped<T: IsA<GLDisplay>>( pub unsafe fn new_wrapped<T: IsA<GLDisplay>>(
@ -22,7 +21,7 @@ impl GLContext {
context_type: GLPlatform, context_type: GLPlatform,
available_apis: GLAPI, available_apis: GLAPI,
) -> Option<GLContext> { ) -> Option<GLContext> {
from_glib_full(gst_gl_sys::gst_gl_context_new_wrapped( from_glib_full(ffi::gst_gl_context_new_wrapped(
display.as_ref().to_glib_none().0, display.as_ref().to_glib_none().0,
handle, handle,
context_type.to_glib(), context_type.to_glib(),
@ -32,9 +31,7 @@ impl GLContext {
pub fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t { pub fn get_current_gl_context(context_type: GLPlatform) -> uintptr_t {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe { ffi::gst_gl_context_get_current_gl_context(context_type.to_glib()) as uintptr_t }
gst_gl_sys::gst_gl_context_get_current_gl_context(context_type.to_glib()) as uintptr_t
}
} }
pub fn get_proc_address_with_platform( pub fn get_proc_address_with_platform(
@ -44,7 +41,7 @@ impl GLContext {
) -> uintptr_t { ) -> uintptr_t {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
gst_gl_sys::gst_gl_context_get_proc_address_with_platform( ffi::gst_gl_context_get_proc_address_with_platform(
context_type.to_glib(), context_type.to_glib(),
gl_api.to_glib(), gl_api.to_glib(),
name.to_glib_none().0, name.to_glib_none().0,
@ -61,14 +58,12 @@ pub trait GLContextExtManual: 'static {
impl<O: IsA<GLContext>> GLContextExtManual for O { impl<O: IsA<GLContext>> GLContextExtManual for O {
fn get_gl_context(&self) -> uintptr_t { fn get_gl_context(&self) -> uintptr_t {
unsafe { unsafe { ffi::gst_gl_context_get_gl_context(self.as_ref().to_glib_none().0) as uintptr_t }
gst_gl_sys::gst_gl_context_get_gl_context(self.as_ref().to_glib_none().0) as uintptr_t
}
} }
fn get_proc_address(&self, name: &str) -> uintptr_t { fn get_proc_address(&self, name: &str) -> uintptr_t {
unsafe { unsafe {
gst_gl_sys::gst_gl_context_get_proc_address( ffi::gst_gl_context_get_proc_address(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
name.to_glib_none().0, name.to_glib_none().0,
) as uintptr_t ) as uintptr_t

View file

@ -6,13 +6,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use gst_gl_sys;
use std::ffi::CStr; use std::ffi::CStr;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
pub static GL_DISPLAY_CONTEXT_TYPE: Lazy<&'static str> = Lazy::new(|| unsafe { pub static GL_DISPLAY_CONTEXT_TYPE: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(gst_gl_sys::GST_GL_DISPLAY_CONTEXT_TYPE) CStr::from_ptr(ffi::GST_GL_DISPLAY_CONTEXT_TYPE)
.to_str() .to_str()
.unwrap() .unwrap()
}); });

View file

@ -6,27 +6,28 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::GLDisplayEGL;
use crate::GLDisplayType;
use glib::ffi::gpointer;
use glib::translate::*; use glib::translate::*;
use glib_sys::gpointer;
use gst_gl_sys;
use libc::uintptr_t; use libc::uintptr_t;
use GLDisplayEGL;
use GLDisplayType;
impl GLDisplayEGL { impl GLDisplayEGL {
pub unsafe fn with_egl_display( pub unsafe fn with_egl_display(
display: uintptr_t, display: uintptr_t,
) -> Result<GLDisplayEGL, glib::error::BoolError> { ) -> Result<GLDisplayEGL, glib::error::BoolError> {
let result = from_glib_full(gst_gl_sys::gst_gl_display_egl_new_with_egl_display( let result = from_glib_full(ffi::gst_gl_display_egl_new_with_egl_display(
display as gpointer, display as gpointer,
)); ));
match result { match result {
Some(d) => Ok(d), Some(d) => Ok(d),
None => Err(glib_bool_error!("Failed to create new EGL GL display")), None => Err(glib::glib_bool_error!(
"Failed to create new EGL GL display"
)),
} }
} }
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer { pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
gst_gl_sys::gst_gl_display_egl_get_from_native(display_type.to_glib(), display) ffi::gst_gl_display_egl_get_from_native(display_type.to_glib(), display)
} }
} }

View file

@ -6,22 +6,23 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::GLDisplayWayland;
use glib::ffi::gpointer;
use glib::translate::*; use glib::translate::*;
use glib_sys::gpointer;
use gst_gl_sys;
use libc::uintptr_t; use libc::uintptr_t;
use GLDisplayWayland;
impl GLDisplayWayland { impl GLDisplayWayland {
pub unsafe fn with_display( pub unsafe fn with_display(
display: uintptr_t, display: uintptr_t,
) -> Result<GLDisplayWayland, glib::error::BoolError> { ) -> Result<GLDisplayWayland, glib::error::BoolError> {
let result = from_glib_full(gst_gl_sys::gst_gl_display_wayland_new_with_display( let result = from_glib_full(ffi::gst_gl_display_wayland_new_with_display(
display as gpointer, display as gpointer,
)); ));
match result { match result {
Some(d) => Ok(d), Some(d) => Ok(d),
None => Err(glib_bool_error!("Failed to create new Wayland GL display")), None => Err(glib::glib_bool_error!(
"Failed to create new Wayland GL display"
)),
} }
} }
} }

View file

@ -6,20 +6,21 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use crate::GLDisplayX11;
use glib::ffi::gpointer;
use glib::translate::*; use glib::translate::*;
use glib_sys::gpointer;
use gst_gl_sys;
use libc::uintptr_t; use libc::uintptr_t;
use GLDisplayX11;
impl GLDisplayX11 { impl GLDisplayX11 {
pub unsafe fn with_display(display: uintptr_t) -> Result<GLDisplayX11, glib::error::BoolError> { pub unsafe fn with_display(display: uintptr_t) -> Result<GLDisplayX11, glib::error::BoolError> {
let result = from_glib_full(gst_gl_sys::gst_gl_display_x11_new_with_display( let result = from_glib_full(ffi::gst_gl_display_x11_new_with_display(
display as gpointer, display as gpointer,
)); ));
match result { match result {
Some(d) => Ok(d), Some(d) => Ok(d),
None => Err(glib_bool_error!("Failed to create new X11 GL display")), None => Err(glib::glib_bool_error!(
"Failed to create new X11 GL display"
)),
} }
} }
} }

View file

@ -1,15 +1,12 @@
use std::fmt; use std::fmt;
use glib;
use glib::translate::*; use glib::translate::*;
use gst;
use gst::prelude::*; use gst::prelude::*;
use gst_gl_sys;
use GLContext; use crate::GLContext;
#[repr(transparent)] #[repr(transparent)]
pub struct GLSyncMeta(gst_gl_sys::GstGLSyncMeta); pub struct GLSyncMeta(ffi::GstGLSyncMeta);
unsafe impl Send for GLSyncMeta {} unsafe impl Send for GLSyncMeta {}
unsafe impl Sync for GLSyncMeta {} unsafe impl Sync for GLSyncMeta {}
@ -21,7 +18,7 @@ impl GLSyncMeta {
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> { ) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
let meta = gst_gl_sys::gst_buffer_add_gl_sync_meta( let meta = ffi::gst_buffer_add_gl_sync_meta(
context.as_ref().to_glib_none().0, context.as_ref().to_glib_none().0,
buffer.as_mut_ptr(), buffer.as_mut_ptr(),
); );
@ -35,7 +32,7 @@ impl GLSyncMeta {
pub fn set_sync_point<C: IsA<GLContext>>(&self, context: &C) { pub fn set_sync_point<C: IsA<GLContext>>(&self, context: &C) {
unsafe { unsafe {
gst_gl_sys::gst_gl_sync_meta_set_sync_point( ffi::gst_gl_sync_meta_set_sync_point(
&self.0 as *const _ as *mut _, &self.0 as *const _ as *mut _,
context.as_ref().to_glib_none().0, context.as_ref().to_glib_none().0,
); );
@ -44,7 +41,7 @@ impl GLSyncMeta {
pub fn wait<C: IsA<GLContext>>(&self, context: &C) { pub fn wait<C: IsA<GLContext>>(&self, context: &C) {
unsafe { unsafe {
gst_gl_sys::gst_gl_sync_meta_wait( ffi::gst_gl_sync_meta_wait(
&self.0 as *const _ as *mut _, &self.0 as *const _ as *mut _,
context.as_ref().to_glib_none().0, context.as_ref().to_glib_none().0,
); );
@ -53,7 +50,7 @@ impl GLSyncMeta {
pub fn wait_cpu<C: IsA<GLContext>>(&self, context: &C) { pub fn wait_cpu<C: IsA<GLContext>>(&self, context: &C) {
unsafe { unsafe {
gst_gl_sys::gst_gl_sync_meta_wait_cpu( ffi::gst_gl_sync_meta_wait_cpu(
&self.0 as *const _ as *mut _, &self.0 as *const _ as *mut _,
context.as_ref().to_glib_none().0, context.as_ref().to_glib_none().0,
); );
@ -62,10 +59,10 @@ impl GLSyncMeta {
} }
unsafe impl MetaAPI for GLSyncMeta { unsafe impl MetaAPI for GLSyncMeta {
type GstType = gst_gl_sys::GstGLSyncMeta; type GstType = ffi::GstGLSyncMeta;
fn get_meta_api() -> glib::Type { fn get_meta_api() -> glib::Type {
unsafe { from_glib(gst_gl_sys::gst_gl_sync_meta_api_get_type()) } unsafe { from_glib(ffi::gst_gl_sync_meta_api_get_type()) }
} }
} }

View file

@ -6,15 +6,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use glib_sys;
use gst_gl_sys;
use gst_sys;
use gst_video_sys;
use glib::translate::{from_glib, ToGlibPtr}; use glib::translate::{from_glib, ToGlibPtr};
use gst;
use gst_video::video_frame::Readable; use gst_video::video_frame::Readable;
use gst_video::*;
use byteorder::{NativeEndian, ReadBytesExt}; use byteorder::{NativeEndian, ReadBytesExt};
use std::mem; use std::mem;
@ -22,32 +15,32 @@ use std::mem;
pub trait VideoFrameGLExt { pub trait VideoFrameGLExt {
fn from_buffer_readable_gl( fn from_buffer_readable_gl(
buffer: gst::Buffer, buffer: gst::Buffer,
info: &VideoInfo, info: &gst_video::VideoInfo,
) -> Result<VideoFrame<Readable>, gst::Buffer>; ) -> Result<gst_video::VideoFrame<Readable>, gst::Buffer>;
fn from_buffer_ref_readable_gl<'a, 'b>( fn from_buffer_ref_readable_gl<'a, 'b>(
buffer: &'a gst::BufferRef, buffer: &'a gst::BufferRef,
info: &'b VideoInfo, info: &'b gst_video::VideoInfo,
) -> Result<VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError>; ) -> Result<gst_video::VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError>;
fn get_texture_id(&self, idx: u32) -> Option<u32>; fn get_texture_id(&self, idx: u32) -> Option<u32>;
} }
impl VideoFrameGLExt for VideoFrame<Readable> { impl VideoFrameGLExt for gst_video::VideoFrame<Readable> {
fn from_buffer_readable_gl( fn from_buffer_readable_gl(
buffer: gst::Buffer, buffer: gst::Buffer,
info: &VideoInfo, info: &gst_video::VideoInfo,
) -> Result<VideoFrame<Readable>, gst::Buffer> { ) -> Result<gst_video::VideoFrame<Readable>, gst::Buffer> {
skip_assert_initialized!(); skip_assert_initialized!();
VideoFrameRef::<&gst::BufferRef>::from_buffer_readable_gl(buffer, info) gst_video::VideoFrameRef::<&gst::BufferRef>::from_buffer_readable_gl(buffer, info)
} }
fn from_buffer_ref_readable_gl<'a, 'b>( fn from_buffer_ref_readable_gl<'a, 'b>(
buffer: &'a gst::BufferRef, buffer: &'a gst::BufferRef,
info: &'b VideoInfo, info: &'b gst_video::VideoInfo,
) -> Result<VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError> { ) -> Result<gst_video::VideoFrameRef<&'a gst::BufferRef>, glib::error::BoolError> {
skip_assert_initialized!(); skip_assert_initialized!();
VideoFrameRef::<&gst::BufferRef>::from_buffer_ref_readable_gl(buffer, info) gst_video::VideoFrameRef::<&gst::BufferRef>::from_buffer_ref_readable_gl(buffer, info)
} }
fn get_texture_id(&self, idx: u32) -> Option<u32> { fn get_texture_id(&self, idx: u32) -> Option<u32> {
@ -55,11 +48,11 @@ impl VideoFrameGLExt for VideoFrame<Readable> {
} }
} }
impl<'a> VideoFrameGLExt for VideoFrameRef<&'a gst::BufferRef> { impl<'a> VideoFrameGLExt for gst_video::VideoFrameRef<&'a gst::BufferRef> {
fn from_buffer_readable_gl( fn from_buffer_readable_gl(
buffer: gst::Buffer, buffer: gst::Buffer,
info: &VideoInfo, info: &gst_video::VideoInfo,
) -> Result<VideoFrame<Readable>, gst::Buffer> { ) -> Result<gst_video::VideoFrame<Readable>, gst::Buffer> {
skip_assert_initialized!(); skip_assert_initialized!();
let n_mem = match buffer_n_gl_memory(buffer.as_ref()) { let n_mem = match buffer_n_gl_memory(buffer.as_ref()) {
@ -76,60 +69,62 @@ impl<'a> VideoFrameGLExt for VideoFrameRef<&'a gst::BufferRef> {
unsafe { unsafe {
let mut frame = mem::MaybeUninit::zeroed(); let mut frame = mem::MaybeUninit::zeroed();
let res: bool = from_glib(gst_video_sys::gst_video_frame_map( let res: bool = from_glib(gst_video::ffi::gst_video_frame_map(
frame.as_mut_ptr(), frame.as_mut_ptr(),
info.to_glib_none().0 as *mut _, info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0, buffer.to_glib_none().0,
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF gst_video::ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_sys::GST_MAP_READ | gst::ffi::GST_MAP_READ
| gst_gl_sys::GST_MAP_GL as u32, | ffi::GST_MAP_GL as u32,
)); ));
if !res { if !res {
Err(buffer) Err(buffer)
} else { } else {
Ok(VideoFrame::from_glib_full(frame.assume_init())) Ok(gst_video::VideoFrame::from_glib_full(frame.assume_init()))
} }
} }
} }
fn from_buffer_ref_readable_gl<'b, 'c>( fn from_buffer_ref_readable_gl<'b, 'c>(
buffer: &'b gst::BufferRef, buffer: &'b gst::BufferRef,
info: &'c VideoInfo, info: &'c gst_video::VideoInfo,
) -> Result<VideoFrameRef<&'b gst::BufferRef>, glib::error::BoolError> { ) -> Result<gst_video::VideoFrameRef<&'b gst::BufferRef>, glib::error::BoolError> {
skip_assert_initialized!(); skip_assert_initialized!();
let n_mem = match buffer_n_gl_memory(buffer) { let n_mem = match buffer_n_gl_memory(buffer) {
Some(n) => n, Some(n) => n,
None => return Err(glib_bool_error!("Memory is not a GstGLMemory")), None => return Err(glib::glib_bool_error!("Memory is not a GstGLMemory")),
}; };
// FIXME: planes are not memories, in multiview use case, // FIXME: planes are not memories, in multiview use case,
// number of memories = planes * views, but the raw memory is // number of memories = planes * views, but the raw memory is
// not exposed in videoframe // not exposed in videoframe
if n_mem != info.n_planes() { if n_mem != info.n_planes() {
return Err(glib_bool_error!( return Err(glib::glib_bool_error!(
"Number of planes and memories is not matching" "Number of planes and memories is not matching"
)); ));
} }
unsafe { unsafe {
let mut frame = mem::MaybeUninit::zeroed(); let mut frame = mem::MaybeUninit::zeroed();
let res: bool = from_glib(gst_video_sys::gst_video_frame_map( let res: bool = from_glib(gst_video::ffi::gst_video_frame_map(
frame.as_mut_ptr(), frame.as_mut_ptr(),
info.to_glib_none().0 as *mut _, info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(), buffer.as_mut_ptr(),
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF gst_video::ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
| gst_sys::GST_MAP_READ | gst::ffi::GST_MAP_READ
| gst_gl_sys::GST_MAP_GL as u32, | ffi::GST_MAP_GL as u32,
)); ));
if !res { if !res {
Err(glib_bool_error!( Err(glib::glib_bool_error!(
"Failed to fill in the values of GstVideoFrame" "Failed to fill in the values of GstVideoFrame"
)) ))
} else { } else {
Ok(VideoFrameRef::from_glib_full(frame.assume_init())) Ok(gst_video::VideoFrameRef::from_glib_full(
frame.assume_init(),
))
} }
} }
} }
@ -157,10 +152,10 @@ fn buffer_n_gl_memory(buffer: &gst::BufferRef) -> Option<u32> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
let buf = buffer.as_mut_ptr(); let buf = buffer.as_mut_ptr();
let num = gst_sys::gst_buffer_n_memory(buf); let num = gst::ffi::gst_buffer_n_memory(buf);
for i in 0..num - 1 { for i in 0..num - 1 {
let mem = gst_sys::gst_buffer_peek_memory(buf, i); let mem = gst::ffi::gst_buffer_peek_memory(buf, i);
if gst_gl_sys::gst_is_gl_memory(mem) != glib_sys::GTRUE { if ffi::gst_is_gl_memory(mem) != glib::ffi::GTRUE {
return None; return None;
} }
} }

View file

@ -9,24 +9,11 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))] #![cfg_attr(feature = "dox", feature(doc_cfg))]
#[macro_use] pub use ffi;
extern crate bitflags;
extern crate byteorder;
extern crate libc;
extern crate once_cell;
#[macro_use]
extern crate glib;
extern crate glib_sys;
extern crate gobject_sys;
extern crate gstreamer as gst;
extern crate gstreamer_gl_sys as gst_gl_sys;
extern crate gstreamer_sys as gst_sys;
extern crate gstreamer_video as gst_video;
extern crate gstreamer_video_sys as gst_video_sys;
macro_rules! assert_initialized_main_thread { macro_rules! assert_initialized_main_thread {
() => { () => {
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE { if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first."); panic!("GStreamer has not been initialized. Call `gst::init` first.");
} }
}; };
@ -40,16 +27,16 @@ macro_rules! skip_assert_initialized {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
#[allow(clippy::match_same_arms)] #[allow(clippy::match_same_arms)]
mod auto; mod auto;
pub use auto::*; pub use crate::auto::*;
mod caps_features; mod caps_features;
pub use caps_features::{CAPS_FEATURES_MEMORY_GL_MEMORY, CAPS_FEATURE_MEMORY_GL_MEMORY}; pub use crate::caps_features::{CAPS_FEATURES_MEMORY_GL_MEMORY, CAPS_FEATURE_MEMORY_GL_MEMORY};
mod context; mod context;
pub use context::ContextGLExt; pub use crate::context::ContextGLExt;
mod gl_context; mod gl_context;
pub use gl_context::GLContextExtManual; pub use crate::gl_context::GLContextExtManual;
mod gl_display; mod gl_display;
pub use gl_display::GL_DISPLAY_CONTEXT_TYPE; pub use crate::gl_display::GL_DISPLAY_CONTEXT_TYPE;
#[cfg(any(feature = "egl", feature = "dox"))] #[cfg(any(feature = "egl", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "egl")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "egl")))]
mod gl_display_egl; mod gl_display_egl;
@ -60,9 +47,9 @@ mod gl_display_wayland;
#[cfg_attr(feature = "dox", doc(cfg(feature = "x11")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "x11")))]
mod gl_display_x11; mod gl_display_x11;
mod gl_video_frame; mod gl_video_frame;
pub use gl_video_frame::VideoFrameGLExt; pub use crate::gl_video_frame::VideoFrameGLExt;
mod gl_sync_meta; mod gl_sync_meta;
pub use gl_sync_meta::*; pub use crate::gl_sync_meta::*;
// Re-export all the traits in a prelude module, so that applications // Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts // can always "use gst::prelude::*" without getting conflicts
@ -70,9 +57,9 @@ pub mod prelude {
pub use glib::prelude::*; pub use glib::prelude::*;
pub use gst::prelude::*; pub use gst::prelude::*;
pub use auto::traits::*; pub use crate::auto::traits::*;
pub use context::ContextGLExt; pub use crate::context::ContextGLExt;
pub use gl_context::GLContextExtManual; pub use crate::gl_context::GLContextExtManual;
pub use gl_video_frame::VideoFrameGLExt; pub use crate::gl_video_frame::VideoFrameGLExt;
} }