1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#![crate_type = "lib"]
#![crate_name = "gst"]
pub use self::appsink::AppSink;
pub use self::appsrc::AppSrc;
pub use self::sample::Sample;
pub use self::caps::Caps;
pub use self::buffer::Buffer;
pub use self::mapinfo::MapInfo;
pub use self::mapinfo::Map;
pub use self::element::Element;
pub use self::bus::Bus;
pub use self::bin::Bin;
pub use self::pipeline::Pipeline;
pub use self::playbin::PlayBin;
pub use self::message::Message;
pub use self::mainloop::MainLoop;
pub use self::error::Error;
pub use self::error::Result;
pub use self::videoframe::VideoFrame;
pub use self::videoframe::VideoPlane;
pub use self::videoframe::VideoComponent;
pub use self::videoinfo::VideoInfo;
pub use self::buffer_pool::BufferPool;
pub use self::pad::Pad;
pub use self::structure::Structure;
pub use self::iterator::Iter;
pub use self::reference::{Ref, Reference};
pub use self::miniobject::MiniObject;
pub use self::object::Object;
use ffi::*;
use std::ptr;
use std::mem;
use std::ffi::CString;
use std::str;
use std::ffi::CStr;
use std::os::raw::c_char;
#[macro_use] mod util;
pub mod ffi;
pub mod appsink;
mod appsrc;
mod sample;
mod caps;
mod buffer;
mod element;
pub mod bus;
mod bin;
mod pipeline;
mod playbin;
mod message;
pub mod mainloop;
mod error;
mod videoframe;
mod videoinfo;
mod mapinfo;
mod buffer_pool;
mod pad;
mod structure;
mod iterator;
mod reference;
mod miniobject;
mod object;
#[cfg(target_os="linux")]
mod link_linux;
#[cfg(target_os="macos")]
mod link_osx;
#[cfg(target_os="windows")]
mod link_windows;
pub fn init(){
unsafe{
gst_init(ptr::null::<i32>() as *mut i32, ptr::null_mut::<c_char>() as *mut *mut *mut c_char);
}
}
pub fn filename_to_uri(filename: &str) -> Result<String>{
let cfilename = CString::new(filename).unwrap();
unsafe{
if gst_uri_is_valid(cfilename.as_ptr())==1{
return Ok(filename.to_string())
}
let err: *mut GError = ptr::null_mut();
let c_uri = gst_filename_to_uri(cfilename.as_ptr(), mem::transmute(&err));
if err != ptr::null_mut(){
Err(Error::new(0, 0, from_c_str!(mem::transmute((*err).message))))
}else{
let uri = from_c_str!(mem::transmute(c_uri)).to_string();
g_free(mem::transmute(c_uri));
Ok(uri)
}
}
}
pub fn uri_get_protocol(uri: &str) -> Result<String>{
let curi = CString::new(uri).unwrap();
unsafe{
if gst_uri_is_valid(curi.as_ptr())==1{
Ok(from_c_str!(mem::transmute(gst_uri_get_protocol(curi.as_ptr()))).to_string())
}else{
Err(Error::new(0,0,"not a valid URI"))
}
}
}
pub trait Transfer<PtrType=GstElement>{
unsafe fn transfer(self) -> *mut PtrType;
}
pub trait FromGValue{
fn from_gvalue(value: &GValue) -> Option<Self> where Self:Sized;
}