mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-20 17:16:39 +00:00
Add all other needed functions
This commit is contained in:
parent
0b67ffc9c7
commit
d9657423a4
2 changed files with 75 additions and 26 deletions
|
@ -1,11 +1,17 @@
|
|||
#include "rsfilesrc.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Declarations for Rust code */
|
||||
extern void * filesrc_new (void);
|
||||
extern void filesrc_drop (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);
|
||||
extern GstFlowReturn filesrc_fill (void * filesrc);
|
||||
extern void filesrc_set_location (void * filesrc, const char *location);
|
||||
extern char * filesrc_get_location (void * filesrc);
|
||||
extern uint64_t filesrc_get_size (void * filesrc);
|
||||
extern gboolean filesrc_is_seekable (void * filesrc);
|
||||
extern gboolean filesrc_start (void * filesrc);
|
||||
extern gboolean filesrc_stop (void * filesrc);
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_rsfile_src_debug);
|
||||
#define GST_CAT_DEFAULT gst_rsfile_src_debug
|
||||
|
@ -133,12 +139,7 @@ gst_rsfile_src_fill (GstBaseSrc * basesrc, guint64 offset, guint length,
|
|||
{
|
||||
GstRsfileSrc *src = GST_RSFILE_SRC (basesrc);
|
||||
|
||||
g_print ("foo %p\n", src->instance);
|
||||
filesrc_fill (src->instance);
|
||||
|
||||
gst_buffer_memset (buf, 0, 0, gst_buffer_get_size (buf));
|
||||
|
||||
return GST_FLOW_OK;
|
||||
return filesrc_fill (src->instance);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -146,7 +147,7 @@ gst_rsfile_src_is_seekable (GstBaseSrc * basesrc)
|
|||
{
|
||||
GstRsfileSrc *src = GST_RSFILE_SRC (basesrc);
|
||||
|
||||
return TRUE;
|
||||
return filesrc_is_seekable (src->instance);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -154,7 +155,7 @@ gst_rsfile_src_get_size (GstBaseSrc * basesrc, guint64 * size)
|
|||
{
|
||||
GstRsfileSrc *src = GST_RSFILE_SRC (basesrc);
|
||||
|
||||
*size = -1;
|
||||
*size = filesrc_get_size (src->instance);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ gst_rsfile_src_start (GstBaseSrc * basesrc)
|
|||
{
|
||||
GstRsfileSrc *src = GST_RSFILE_SRC (basesrc);
|
||||
|
||||
return TRUE;
|
||||
return filesrc_start (src->instance);
|
||||
}
|
||||
|
||||
/* unmap and close the rsfile */
|
||||
|
@ -174,7 +175,7 @@ gst_rsfile_src_stop (GstBaseSrc * basesrc)
|
|||
{
|
||||
GstRsfileSrc *src = GST_RSFILE_SRC (basesrc);
|
||||
|
||||
return TRUE;
|
||||
return filesrc_stop (src->instance);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,40 @@
|
|||
use libc::{c_char};
|
||||
use std::ffi::{CStr, CString};
|
||||
use std::ptr;
|
||||
use std::u64;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FileSrc {
|
||||
location: Option<String>,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum GstFlowReturn {
|
||||
Ok = 0,
|
||||
NotLinked = -1,
|
||||
Flushing = -2,
|
||||
Eos = -3,
|
||||
NotNegotiated = -4,
|
||||
Error = -5,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum GBoolean {
|
||||
False = 0,
|
||||
True = 1,
|
||||
}
|
||||
|
||||
impl FileSrc {
|
||||
fn new() -> FileSrc {
|
||||
FileSrc { location: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for FileSrc {
|
||||
fn drop(&mut self) {
|
||||
println!("drop");
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn filesrc_new() -> *mut FileSrc {
|
||||
|
@ -38,25 +72,39 @@ pub extern "C" fn filesrc_get_location(ptr: *mut FileSrc) -> *mut c_char {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn filesrc_fill(ptr: *mut FileSrc) {
|
||||
pub extern "C" fn filesrc_fill(ptr: *mut FileSrc) -> GstFlowReturn {
|
||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||
|
||||
println!("fill {:?}", filesrc);
|
||||
println!("{:?}", filesrc);
|
||||
|
||||
return GstFlowReturn::Ok;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FileSrc {
|
||||
location: Option<String>,
|
||||
#[no_mangle]
|
||||
pub extern "C" fn filesrc_get_size(ptr: *mut FileSrc) -> u64 {
|
||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||
|
||||
return u64::MAX;
|
||||
}
|
||||
|
||||
impl FileSrc {
|
||||
fn new() -> FileSrc {
|
||||
FileSrc { location: None }
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn filesrc_start(ptr: *mut FileSrc) -> GBoolean {
|
||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||
|
||||
return GBoolean::True;
|
||||
}
|
||||
|
||||
impl Drop for FileSrc {
|
||||
fn drop(&mut self) {
|
||||
println!("drop");
|
||||
}
|
||||
#[no_mangle]
|
||||
pub extern "C" fn filesrc_stop(ptr: *mut FileSrc) -> GBoolean {
|
||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||
|
||||
return GBoolean::True;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn filesrc_is_seekable(ptr: *mut FileSrc) -> GBoolean {
|
||||
let filesrc: &mut FileSrc = unsafe { &mut *ptr };
|
||||
|
||||
return GBoolean::True;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue