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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use ffi::*;
use std::ptr;
use std::mem;
use std::os::raw::c_void;
use std::ops::{Deref, DerefMut};
use ::Buffer;
use ::Object;
use reference::Reference;
pub struct BufferPool{
pool: Object
}
unsafe impl Sync for BufferPool {}
unsafe impl Send for BufferPool {}
impl BufferPool{
pub fn new() -> Option<BufferPool>{
unsafe{
let pool = gst_buffer_pool_new();
if pool!=ptr::null_mut(){
gst_object_ref_sink(pool as *mut c_void);
Some(BufferPool{ pool: Object::new(pool as *mut GstObject).unwrap() })
}else{
None
}
}
}
pub fn set_params(&mut self, caps: &::Caps, size: u32, min_buffers: u32, max_buffers: u32){
unsafe{
let config = gst_buffer_pool_get_config(self.gst_bufferpool_mut());
gst_buffer_pool_config_set_params(config, mem::transmute(caps.gst_caps()), size, min_buffers, max_buffers);
gst_buffer_pool_set_config(self.gst_bufferpool_mut(), config);
}
}
pub fn acquire_buffer(&mut self) -> Option<Buffer>{
let mut buffer: *mut GstBuffer = ptr::null_mut();
unsafe{
let ret = gst_buffer_pool_acquire_buffer(self.gst_bufferpool_mut(), &mut buffer, ptr::null_mut());
if buffer!=ptr::null_mut() && ret==GST_FLOW_OK{
Buffer::new(buffer)
}else{
None
}
}
}
pub fn active(&self) -> bool{
unsafe{
gst_buffer_pool_is_active(self.gst_bufferpool() as *mut GstBufferPool) != 0
}
}
pub fn set_active(&mut self, active: bool) -> Result<(),()>{
unsafe{
if gst_buffer_pool_set_active(self.gst_bufferpool_mut(), if active{1} else {0}) != 0{
Ok(())
}else{
Err(())
}
}
}
pub unsafe fn gst_bufferpool(&self) -> *const GstBufferPool{
self.pool.gst_object() as *const GstBufferPool
}
pub unsafe fn gst_bufferpool_mut(&mut self) -> *mut GstBufferPool{
self.pool.gst_object_mut() as *mut GstBufferPool
}
}
impl ::Transfer<GstBufferPool> for BufferPool{
unsafe fn transfer(self) -> *mut GstBufferPool{
self.pool.transfer() as *mut GstBufferPool
}
}
impl Reference for BufferPool{
fn reference(&self) -> BufferPool{
BufferPool{ pool: self.pool.reference() }
}
}
impl AsRef<Object> for BufferPool{
fn as_ref(&self) -> &Object{
&self.pool
}
}
impl AsMut<Object> for BufferPool{
fn as_mut(&mut self) -> &mut Object{
&mut self.pool
}
}
impl From<BufferPool> for Object{
fn from(b: BufferPool) -> Object{
b.pool
}
}
impl Deref for BufferPool{
type Target = Object;
fn deref(&self) -> &Object{
&self.pool
}
}
impl DerefMut for BufferPool{
fn deref_mut(&mut self) -> &mut Object{
&mut self.pool
}
}