mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-05-20 09:18:15 +00:00
Add location property handling
This commit is contained in:
parent
833148cef6
commit
0b67ffc9c7
|
@ -5,6 +5,7 @@ authors = ["Sebastian Dröge <sebastian@centricular.com>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
libc = "0.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gcc = "0.3"
|
gcc = "0.3"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
#![crate_type="dylib"]
|
#![crate_type="dylib"]
|
||||||
|
|
||||||
|
extern crate libc;
|
||||||
|
|
||||||
pub mod rsfilesrc;
|
pub mod rsfilesrc;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
extern void * filesrc_new (void);
|
extern void * filesrc_new (void);
|
||||||
extern void filesrc_drop (void * filesrc);
|
extern void filesrc_drop (void * filesrc);
|
||||||
extern int filesrc_fill (void * filesrc);
|
extern int filesrc_fill (void * filesrc);
|
||||||
|
extern void filesrc_set_location (void * filesrc, const gchar *location);
|
||||||
|
extern gchar * filesrc_get_location (void * filesrc);
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_rsfile_src_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_rsfile_src_debug);
|
||||||
#define GST_CAT_DEFAULT gst_rsfile_src_debug
|
#define GST_CAT_DEFAULT gst_rsfile_src_debug
|
||||||
|
@ -89,7 +91,6 @@ gst_rsfile_src_finalize (GObject * object)
|
||||||
GstRsfileSrc *src = GST_RSFILE_SRC (object);
|
GstRsfileSrc *src = GST_RSFILE_SRC (object);
|
||||||
|
|
||||||
filesrc_drop (src->instance);
|
filesrc_drop (src->instance);
|
||||||
g_free (src->location);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
@ -102,9 +103,7 @@ gst_rsfile_src_set_property (GObject * object, guint prop_id,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
if (src->location)
|
filesrc_set_location (src->instance, g_value_get_string (value));
|
||||||
g_free (src->location);
|
|
||||||
src->location = g_value_dup_string (value);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -120,7 +119,7 @@ gst_rsfile_src_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
g_value_set_string (value, src->location);
|
g_value_take_string (value, filesrc_get_location (src->instance));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use libc::{c_char};
|
||||||
|
use std::ffi::{CStr, CString};
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn filesrc_new() -> *mut FileSrc {
|
pub extern "C" fn filesrc_new() -> *mut FileSrc {
|
||||||
let instance = Box::new(FileSrc::new());
|
let instance = Box::new(FileSrc::new());
|
||||||
|
@ -9,12 +13,35 @@ pub extern "C" fn filesrc_drop(ptr: *mut FileSrc) {
|
||||||
unsafe { Box::from_raw(ptr) };
|
unsafe { Box::from_raw(ptr) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn filesrc_set_location(ptr: *mut FileSrc, location_ptr: *const c_char) {
|
||||||
|
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||||
|
|
||||||
|
if location_ptr.is_null() {
|
||||||
|
filesrc.location = None;
|
||||||
|
} else {
|
||||||
|
let location = unsafe { CStr::from_ptr(location_ptr) };
|
||||||
|
filesrc.location = Some(String::from(location.to_str().unwrap()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn filesrc_get_location(ptr: *mut FileSrc) -> *mut c_char {
|
||||||
|
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||||
|
|
||||||
|
match filesrc.location {
|
||||||
|
Some(ref location) =>
|
||||||
|
CString::new(location.clone().into_bytes()).unwrap().into_raw(),
|
||||||
|
None =>
|
||||||
|
ptr::null_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn filesrc_fill(ptr: *mut FileSrc) {
|
pub extern "C" fn filesrc_fill(ptr: *mut FileSrc) {
|
||||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||||
|
|
||||||
println!("fill");
|
println!("fill {:?}", filesrc);
|
||||||
filesrc.location = Some(String::from("bla"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
Loading…
Reference in a new issue