Remove Rs prefix from everything

We have proper namespaces in Rust
This commit is contained in:
Sebastian Dröge 2017-11-20 13:22:26 +02:00
parent 656dc990f8
commit 22ab56895d
14 changed files with 273 additions and 267 deletions

View file

@ -98,7 +98,7 @@ static PROPERTIES: [Property; 4] = [
];
impl AudioEcho {
fn new(_transform: &RsBaseTransform) -> Self {
fn new(_transform: &BaseTransform) -> Self {
Self {
cat: gst::DebugCategory::new(
"rsaudiofx",
@ -110,7 +110,7 @@ impl AudioEcho {
}
}
fn class_init(klass: &mut RsBaseTransformClass) {
fn class_init(klass: &mut BaseTransformClass) {
klass.set_metadata(
"Audio echo",
"Filter/Effect/Audio",
@ -154,7 +154,7 @@ impl AudioEcho {
klass.configure(BaseTransformMode::AlwaysInPlace, false, false);
}
fn init(element: &RsBaseTransform) -> Box<BaseTransformImpl<RsBaseTransform>> {
fn init(element: &BaseTransform) -> Box<BaseTransformImpl<BaseTransform>> {
let imp = Self::new(element);
Box::new(imp)
}
@ -176,7 +176,7 @@ impl AudioEcho {
}
}
impl ObjectImpl<RsBaseTransform> for AudioEcho {
impl ObjectImpl<BaseTransform> for AudioEcho {
fn set_property(&self, _obj: &glib::Object, id: u32, value: &glib::Value) {
let prop = &PROPERTIES[id as usize];
@ -230,14 +230,10 @@ impl ObjectImpl<RsBaseTransform> for AudioEcho {
}
}
impl ElementImpl<RsBaseTransform> for AudioEcho {}
impl ElementImpl<BaseTransform> for AudioEcho {}
impl BaseTransformImpl<RsBaseTransform> for AudioEcho {
fn transform_ip(
&self,
_element: &RsBaseTransform,
buf: &mut gst::BufferRef,
) -> gst::FlowReturn {
impl BaseTransformImpl<BaseTransform> for AudioEcho {
fn transform_ip(&self, _element: &BaseTransform, buf: &mut gst::BufferRef) -> gst::FlowReturn {
let mut settings = *self.settings.lock().unwrap();
settings.delay = cmp::min(settings.max_delay, settings.delay);
@ -267,12 +263,7 @@ impl BaseTransformImpl<RsBaseTransform> for AudioEcho {
gst::FlowReturn::Ok
}
fn set_caps(
&self,
_element: &RsBaseTransform,
incaps: &gst::Caps,
outcaps: &gst::Caps,
) -> bool {
fn set_caps(&self, _element: &BaseTransform, incaps: &gst::Caps, outcaps: &gst::Caps) -> bool {
if incaps != outcaps {
return false;
}
@ -294,7 +285,7 @@ impl BaseTransformImpl<RsBaseTransform> for AudioEcho {
true
}
fn stop(&self, _element: &RsBaseTransform) -> bool {
fn stop(&self, _element: &BaseTransform) -> bool {
// Drop state
let _ = self.state.lock().unwrap().take();
@ -304,16 +295,16 @@ impl BaseTransformImpl<RsBaseTransform> for AudioEcho {
struct AudioEchoStatic;
impl ImplTypeStatic<RsBaseTransform> for AudioEchoStatic {
impl ImplTypeStatic<BaseTransform> for AudioEchoStatic {
fn get_name(&self) -> &str {
"AudioEcho"
}
fn new(&self, element: &RsBaseTransform) -> Box<BaseTransformImpl<RsBaseTransform>> {
fn new(&self, element: &BaseTransform) -> Box<BaseTransformImpl<BaseTransform>> {
AudioEcho::init(element)
}
fn class_init(&self, klass: &mut RsBaseTransformClass) {
fn class_init(&self, klass: &mut BaseTransformClass) {
AudioEcho::class_init(klass);
}
}

View file

@ -33,7 +33,7 @@ pub struct FileSink {
}
impl FileSink {
pub fn new(_sink: &RsBaseSink) -> FileSink {
pub fn new(_sink: &BaseSink) -> FileSink {
FileSink {
streaming_state: StreamingState::Stopped,
cat: gst::DebugCategory::new(
@ -44,7 +44,7 @@ impl FileSink {
}
}
pub fn new_boxed(sink: &RsBaseSink) -> Box<SinkImpl> {
pub fn new_boxed(sink: &BaseSink) -> Box<SinkImpl> {
Box::new(FileSink::new(sink))
}
}
@ -64,7 +64,7 @@ impl SinkImpl for FileSink {
Box::new(validate_uri)
}
fn start(&mut self, sink: &RsBaseSink, uri: Url) -> Result<(), ErrorMessage> {
fn start(&mut self, sink: &BaseSink, uri: Url) -> Result<(), ErrorMessage> {
if let StreamingState::Started { .. } = self.streaming_state {
return Err(error_msg!(
gst::LibraryError::Failed,
@ -113,13 +113,13 @@ impl SinkImpl for FileSink {
Ok(())
}
fn stop(&mut self, _sink: &RsBaseSink) -> Result<(), ErrorMessage> {
fn stop(&mut self, _sink: &BaseSink) -> Result<(), ErrorMessage> {
self.streaming_state = StreamingState::Stopped;
Ok(())
}
fn render(&mut self, sink: &RsBaseSink, buffer: &gst::BufferRef) -> Result<(), FlowError> {
fn render(&mut self, sink: &BaseSink, buffer: &gst::BufferRef) -> Result<(), FlowError> {
let cat = self.cat;
let streaming_state = &mut self.streaming_state;

View file

@ -31,7 +31,7 @@ pub struct FileSrc {
}
impl FileSrc {
pub fn new(_src: &RsBaseSrc) -> FileSrc {
pub fn new(_src: &BaseSrc) -> FileSrc {
FileSrc {
streaming_state: StreamingState::Stopped,
cat: gst::DebugCategory::new(
@ -42,7 +42,7 @@ impl FileSrc {
}
}
pub fn new_boxed(src: &RsBaseSrc) -> Box<SourceImpl> {
pub fn new_boxed(src: &BaseSrc) -> Box<SourceImpl> {
Box::new(FileSrc::new(src))
}
}
@ -62,11 +62,11 @@ impl SourceImpl for FileSrc {
Box::new(validate_uri)
}
fn is_seekable(&self, _src: &RsBaseSrc) -> bool {
fn is_seekable(&self, _src: &BaseSrc) -> bool {
true
}
fn get_size(&self, _src: &RsBaseSrc) -> Option<u64> {
fn get_size(&self, _src: &BaseSrc) -> Option<u64> {
if let StreamingState::Started { ref file, .. } = self.streaming_state {
file.metadata().ok().map(|m| m.len())
} else {
@ -74,7 +74,7 @@ impl SourceImpl for FileSrc {
}
}
fn start(&mut self, src: &RsBaseSrc, uri: Url) -> Result<(), ErrorMessage> {
fn start(&mut self, src: &BaseSrc, uri: Url) -> Result<(), ErrorMessage> {
if let StreamingState::Started { .. } = self.streaming_state {
return Err(error_msg!(
gst::LibraryError::Failed,
@ -122,7 +122,7 @@ impl SourceImpl for FileSrc {
Ok(())
}
fn stop(&mut self, _src: &RsBaseSrc) -> Result<(), ErrorMessage> {
fn stop(&mut self, _src: &BaseSrc) -> Result<(), ErrorMessage> {
self.streaming_state = StreamingState::Stopped;
Ok(())
@ -130,7 +130,7 @@ impl SourceImpl for FileSrc {
fn fill(
&mut self,
src: &RsBaseSrc,
src: &BaseSrc,
offset: u64,
_: u32,
buffer: &mut gst::BufferRef,
@ -190,7 +190,7 @@ impl SourceImpl for FileSrc {
Ok(())
}
fn seek(&mut self, _src: &RsBaseSrc, _: u64, _: Option<u64>) -> Result<(), ErrorMessage> {
fn seek(&mut self, _src: &BaseSrc, _: u64, _: Option<u64>) -> Result<(), ErrorMessage> {
Ok(())
}
}

View file

@ -17,6 +17,7 @@ use flavors::parser as flavors;
use gst_plugin::error::*;
use gst_plugin::adapter::*;
use gst_plugin::bytes::*;
use gst_plugin::element::*;
use gst_plugin_simple::demuxer::*;
use gst;
@ -488,7 +489,7 @@ pub struct FlvDemux {
}
impl FlvDemux {
pub fn new(_demuxer: &RsDemuxer) -> FlvDemux {
pub fn new(_demuxer: &Element) -> FlvDemux {
FlvDemux {
cat: gst::DebugCategory::new(
"rsflvdemux",
@ -501,13 +502,13 @@ impl FlvDemux {
}
}
pub fn new_boxed(demuxer: &RsDemuxer) -> Box<DemuxerImpl> {
pub fn new_boxed(demuxer: &Element) -> Box<DemuxerImpl> {
Box::new(Self::new(demuxer))
}
fn handle_script_tag(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
tag_header: &flavors::TagHeader,
) -> Result<HandleBufferResult, FlowError> {
if self.adapter.get_available() < (15 + tag_header.data_size) as usize {
@ -575,7 +576,7 @@ impl FlvDemux {
fn update_audio_stream(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
data_header: &flavors::AudioDataHeader,
) -> Result<HandleBufferResult, FlowError> {
gst_trace!(
@ -629,7 +630,7 @@ impl FlvDemux {
fn handle_audio_tag(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
tag_header: &flavors::TagHeader,
data_header: &flavors::AudioDataHeader,
) -> Result<HandleBufferResult, FlowError> {
@ -748,7 +749,7 @@ impl FlvDemux {
fn update_video_stream(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
data_header: &flavors::VideoDataHeader,
) -> Result<HandleBufferResult, FlowError> {
gst_trace!(
@ -803,7 +804,7 @@ impl FlvDemux {
fn handle_video_tag(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
tag_header: &flavors::TagHeader,
data_header: &flavors::VideoDataHeader,
) -> Result<HandleBufferResult, FlowError> {
@ -944,7 +945,7 @@ impl FlvDemux {
Ok(HandleBufferResult::BufferForStream(VIDEO_STREAM_ID, buffer))
}
fn update_state(&mut self, demuxer: &RsDemuxer) -> Result<HandleBufferResult, FlowError> {
fn update_state(&mut self, demuxer: &Element) -> Result<HandleBufferResult, FlowError> {
match self.state {
State::Stopped => unreachable!(),
State::NeedHeader => {
@ -1090,7 +1091,7 @@ impl FlvDemux {
impl DemuxerImpl for FlvDemux {
fn start(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
_upstream_size: Option<u64>,
_random_access: bool,
) -> Result<(), ErrorMessage> {
@ -1099,7 +1100,7 @@ impl DemuxerImpl for FlvDemux {
Ok(())
}
fn stop(&mut self, demuxer: &RsDemuxer) -> Result<(), ErrorMessage> {
fn stop(&mut self, demuxer: &Element) -> Result<(), ErrorMessage> {
self.state = State::Stopped;
self.adapter.clear();
self.streaming_state = None;
@ -1109,7 +1110,7 @@ impl DemuxerImpl for FlvDemux {
fn seek(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
start: gst::ClockTime,
stop: gst::ClockTime,
) -> Result<SeekResult, ErrorMessage> {
@ -1118,7 +1119,7 @@ impl DemuxerImpl for FlvDemux {
fn handle_buffer(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
buffer: Option<gst::Buffer>,
) -> Result<HandleBufferResult, FlowError> {
if let Some(buffer) = buffer {
@ -1128,16 +1129,16 @@ impl DemuxerImpl for FlvDemux {
self.update_state(demuxer)
}
fn end_of_stream(&mut self, demuxer: &RsDemuxer) -> Result<(), ErrorMessage> {
fn end_of_stream(&mut self, demuxer: &Element) -> Result<(), ErrorMessage> {
// nothing to do here, all data we have left is incomplete
Ok(())
}
fn is_seekable(&self, demuxer: &RsDemuxer) -> bool {
fn is_seekable(&self, demuxer: &Element) -> bool {
false
}
fn get_position(&self, demuxer: &RsDemuxer) -> gst::ClockTime {
fn get_position(&self, demuxer: &Element) -> gst::ClockTime {
if let Some(StreamingState { last_position, .. }) = self.streaming_state {
return last_position;
}
@ -1145,7 +1146,7 @@ impl DemuxerImpl for FlvDemux {
gst::CLOCK_TIME_NONE
}
fn get_duration(&self, demuxer: &RsDemuxer) -> gst::ClockTime {
fn get_duration(&self, demuxer: &Element) -> gst::ClockTime {
if let Some(StreamingState {
metadata: Some(Metadata { duration, .. }),
..

View file

@ -42,7 +42,7 @@ pub struct HttpSrc {
}
impl HttpSrc {
pub fn new(_src: &RsBaseSrc) -> HttpSrc {
pub fn new(_src: &BaseSrc) -> HttpSrc {
HttpSrc {
streaming_state: StreamingState::Stopped,
cat: gst::DebugCategory::new(
@ -54,13 +54,13 @@ impl HttpSrc {
}
}
pub fn new_boxed(src: &RsBaseSrc) -> Box<SourceImpl> {
pub fn new_boxed(src: &BaseSrc) -> Box<SourceImpl> {
Box::new(HttpSrc::new(src))
}
fn do_request(
&self,
src: &RsBaseSrc,
src: &BaseSrc,
uri: Url,
start: u64,
stop: Option<u64>,
@ -109,12 +109,10 @@ impl HttpSrc {
let seekable = size.is_some() && accept_byte_ranges;
let position = if let Some(
&ContentRange(ContentRangeSpec::Bytes {
range: Some((range_start, _)),
..
}),
) = response.headers().get()
let position = if let Some(&ContentRange(ContentRangeSpec::Bytes {
range: Some((range_start, _)),
..
})) = response.headers().get()
{
range_start
} else {
@ -158,34 +156,34 @@ impl SourceImpl for HttpSrc {
Box::new(validate_uri)
}
fn is_seekable(&self, _src: &RsBaseSrc) -> bool {
fn is_seekable(&self, _src: &BaseSrc) -> bool {
match self.streaming_state {
StreamingState::Started { seekable, .. } => seekable,
_ => false,
}
}
fn get_size(&self, _src: &RsBaseSrc) -> Option<u64> {
fn get_size(&self, _src: &BaseSrc) -> Option<u64> {
match self.streaming_state {
StreamingState::Started { size, .. } => size,
_ => None,
}
}
fn start(&mut self, src: &RsBaseSrc, uri: Url) -> Result<(), ErrorMessage> {
fn start(&mut self, src: &BaseSrc, uri: Url) -> Result<(), ErrorMessage> {
self.streaming_state = StreamingState::Stopped;
self.streaming_state = try!(self.do_request(src, uri, 0, None));
Ok(())
}
fn stop(&mut self, _src: &RsBaseSrc) -> Result<(), ErrorMessage> {
fn stop(&mut self, _src: &BaseSrc) -> Result<(), ErrorMessage> {
self.streaming_state = StreamingState::Stopped;
Ok(())
}
fn seek(&mut self, src: &RsBaseSrc, start: u64, stop: Option<u64>) -> Result<(), ErrorMessage> {
fn seek(&mut self, src: &BaseSrc, start: u64, stop: Option<u64>) -> Result<(), ErrorMessage> {
let (position, old_stop, uri) = match self.streaming_state {
StreamingState::Started {
position,
@ -210,7 +208,7 @@ impl SourceImpl for HttpSrc {
fn fill(
&mut self,
src: &RsBaseSrc,
src: &BaseSrc,
offset: u64,
_: u32,
buffer: &mut gst::BufferRef,

View file

@ -46,33 +46,31 @@ pub enum HandleBufferResult {
Eos(Option<StreamIndex>),
}
pub type RsDemuxer = RsElement;
pub trait DemuxerImpl: Send + 'static {
fn start(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
upstream_size: Option<u64>,
random_access: bool,
) -> Result<(), ErrorMessage>;
fn stop(&mut self, demuxer: &RsDemuxer) -> Result<(), ErrorMessage>;
fn stop(&mut self, demuxer: &Element) -> Result<(), ErrorMessage>;
fn seek(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
start: gst::ClockTime,
stop: gst::ClockTime,
) -> Result<SeekResult, ErrorMessage>;
fn handle_buffer(
&mut self,
demuxer: &RsDemuxer,
demuxer: &Element,
buffer: Option<gst::Buffer>,
) -> Result<HandleBufferResult, FlowError>;
fn end_of_stream(&mut self, demuxer: &RsDemuxer) -> Result<(), ErrorMessage>;
fn end_of_stream(&mut self, demuxer: &Element) -> Result<(), ErrorMessage>;
fn is_seekable(&self, demuxer: &RsDemuxer) -> bool;
fn get_position(&self, demuxer: &RsDemuxer) -> gst::ClockTime;
fn get_duration(&self, demuxer: &RsDemuxer) -> gst::ClockTime;
fn is_seekable(&self, demuxer: &Element) -> bool;
fn get_position(&self, demuxer: &Element) -> gst::ClockTime;
fn get_duration(&self, demuxer: &Element) -> gst::ClockTime;
}
#[derive(Debug)]
@ -99,7 +97,7 @@ pub struct DemuxerInfo {
pub classification: String,
pub author: String,
pub rank: u32,
pub create_instance: fn(&RsDemuxer) -> Box<DemuxerImpl>,
pub create_instance: fn(&Element) -> Box<DemuxerImpl>,
pub input_caps: gst::Caps,
pub output_caps: gst::Caps,
}
@ -134,7 +132,7 @@ unsafe impl Send for UniqueFlowCombiner {}
unsafe impl Sync for UniqueFlowCombiner {}
impl Demuxer {
fn new(demuxer: &RsDemuxer, sinkpad: gst::Pad, demuxer_info: &DemuxerInfo) -> Self {
fn new(element: &Element, sinkpad: gst::Pad, demuxer_info: &DemuxerInfo) -> Self {
Self {
cat: gst::DebugCategory::new(
"rsdemux",
@ -145,11 +143,11 @@ impl Demuxer {
flow_combiner: Mutex::new(Default::default()),
group_id: Mutex::new(gst::util_group_id_next()),
srcpads: Mutex::new(BTreeMap::new()),
imp: Mutex::new((demuxer_info.create_instance)(demuxer)),
imp: Mutex::new((demuxer_info.create_instance)(element)),
}
}
fn class_init(klass: &mut RsElementClass, demuxer_info: &DemuxerInfo) {
fn class_init(klass: &mut ElementClass, demuxer_info: &DemuxerInfo) {
klass.set_metadata(
&demuxer_info.long_name,
&demuxer_info.classification,
@ -174,7 +172,7 @@ impl Demuxer {
klass.add_pad_template(pad_template);
}
fn init(element: &RsElement, demuxer_info: &DemuxerInfo) -> Box<ElementImpl<RsElement>> {
fn init(element: &Element, demuxer_info: &DemuxerInfo) -> Box<ElementImpl<Element>> {
let templ = element.get_pad_template("sink").unwrap();
let sinkpad = gst::Pad::new_from_template(&templ, "sink");
sinkpad.set_activate_function(Demuxer::sink_activate);
@ -187,7 +185,7 @@ impl Demuxer {
Box::new(imp)
}
fn add_stream(&self, element: &RsElement, index: u32, caps: gst::Caps, stream_id: &str) {
fn add_stream(&self, element: &Element, index: u32, caps: gst::Caps, stream_id: &str) {
let mut srcpads = self.srcpads.lock().unwrap();
assert!(!srcpads.contains_key(&index));
@ -217,12 +215,12 @@ impl Demuxer {
srcpads.insert(index, pad);
}
fn added_all_streams(&self, element: &RsElement) {
fn added_all_streams(&self, element: &Element) {
element.no_more_pads();
*self.group_id.lock().unwrap() = gst::util_group_id_next();
}
fn stream_format_changed(&self, _element: &RsElement, index: u32, caps: gst::Caps) {
fn stream_format_changed(&self, _element: &Element, index: u32, caps: gst::Caps) {
let srcpads = self.srcpads.lock().unwrap();
if let Some(pad) = srcpads.get(&index) {
@ -230,7 +228,7 @@ impl Demuxer {
}
}
fn stream_eos(&self, _element: &RsElement, index: Option<u32>) {
fn stream_eos(&self, _element: &Element, index: Option<u32>) {
let srcpads = self.srcpads.lock().unwrap();
let event = gst::Event::new_eos().build();
@ -246,7 +244,7 @@ impl Demuxer {
fn stream_push_buffer(
&self,
_element: &RsElement,
_element: &Element,
index: u32,
buffer: gst::Buffer,
) -> gst::FlowReturn {
@ -262,7 +260,7 @@ impl Demuxer {
}
}
fn remove_all_streams(&self, element: &RsElement) {
fn remove_all_streams(&self, element: &Element) {
self.flow_combiner.lock().unwrap().clear();
let mut srcpads = self.srcpads.lock().unwrap();
for (_, pad) in srcpads.iter().by_ref() {
@ -294,7 +292,7 @@ impl Demuxer {
}
}
fn start(&self, element: &RsDemuxer, upstream_size: Option<u64>, random_access: bool) -> bool {
fn start(&self, element: &Element, upstream_size: Option<u64>, random_access: bool) -> bool {
let demuxer_impl = &mut self.imp.lock().unwrap();
gst_debug!(
@ -318,7 +316,7 @@ impl Demuxer {
}
}
fn stop(&self, element: &RsDemuxer) -> bool {
fn stop(&self, element: &Element) -> bool {
let demuxer_impl = &mut self.imp.lock().unwrap();
gst_debug!(self.cat, obj: element, "Stopping");
@ -346,7 +344,7 @@ impl Demuxer {
.as_ref()
.cloned()
.unwrap()
.downcast::<RsElement>()
.downcast::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
@ -385,7 +383,7 @@ impl Demuxer {
.as_ref()
.cloned()
.unwrap()
.downcast::<RsElement>()
.downcast::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
@ -483,7 +481,7 @@ impl Demuxer {
.as_ref()
.cloned()
.unwrap()
.downcast::<RsElement>()
.downcast::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
@ -518,7 +516,7 @@ impl Demuxer {
.as_ref()
.cloned()
.unwrap()
.downcast::<RsElement>()
.downcast::<Element>()
.unwrap();
let demuxer = element.get_impl().downcast_ref::<Demuxer>().unwrap();
@ -593,7 +591,7 @@ impl Demuxer {
fn seek(
&self,
element: &RsDemuxer,
element: &Element,
start: gst::ClockTime,
stop: gst::ClockTime,
offset: &mut u64,
@ -635,12 +633,12 @@ impl Demuxer {
}
}
impl ObjectImpl<RsElement> for Demuxer {}
impl ObjectImpl<Element> for Demuxer {}
impl ElementImpl<RsElement> for Demuxer {
impl ElementImpl<Element> for Demuxer {
fn change_state(
&self,
element: &RsElement,
element: &Element,
transition: gst::StateChange,
) -> gst::StateChangeReturn {
let mut ret = gst::StateChangeReturn::Success;
@ -681,16 +679,16 @@ struct DemuxerStatic {
demuxer_info: DemuxerInfo,
}
impl ImplTypeStatic<RsElement> for DemuxerStatic {
impl ImplTypeStatic<Element> for DemuxerStatic {
fn get_name(&self) -> &str {
self.name.as_str()
}
fn new(&self, element: &RsElement) -> Box<ElementImpl<RsElement>> {
fn new(&self, element: &Element) -> Box<ElementImpl<Element>> {
Demuxer::init(element, &self.demuxer_info)
}
fn class_init(&self, klass: &mut RsElementClass) {
fn class_init(&self, klass: &mut ElementClass) {
Demuxer::class_init(klass, &self.demuxer_info);
}
}

View file

@ -23,16 +23,16 @@ use gst_plugin::base_sink::*;
use gst_plugin::uri_handler::*;
use gst_plugin::error::*;
pub use gst_plugin::base_sink::RsBaseSink;
pub use gst_plugin::base_sink::BaseSink;
use UriValidator;
pub trait SinkImpl: Send + 'static {
fn uri_validator(&self) -> Box<UriValidator>;
fn start(&mut self, sink: &RsBaseSink, uri: Url) -> Result<(), ErrorMessage>;
fn stop(&mut self, sink: &RsBaseSink) -> Result<(), ErrorMessage>;
fn render(&mut self, sink: &RsBaseSink, buffer: &gst::BufferRef) -> Result<(), FlowError>;
fn start(&mut self, sink: &BaseSink, uri: Url) -> Result<(), ErrorMessage>;
fn stop(&mut self, sink: &BaseSink) -> Result<(), ErrorMessage>;
fn render(&mut self, sink: &BaseSink, buffer: &gst::BufferRef) -> Result<(), FlowError>;
}
struct Sink {
@ -53,7 +53,7 @@ static PROPERTIES: [Property; 1] = [
];
impl Sink {
fn new(sink: &RsBaseSink, sink_info: &SinkInfo) -> Self {
fn new(sink: &BaseSink, sink_info: &SinkInfo) -> Self {
let sink_impl = (sink_info.create_instance)(sink);
Self {
@ -68,7 +68,7 @@ impl Sink {
}
}
fn class_init(klass: &mut RsBaseSinkClass, sink_info: &SinkInfo) {
fn class_init(klass: &mut BaseSinkClass, sink_info: &SinkInfo) {
klass.set_metadata(
&sink_info.long_name,
&sink_info.classification,
@ -88,7 +88,7 @@ impl Sink {
klass.install_properties(&PROPERTIES);
}
fn init(element: &RsBaseSink, sink_info: &SinkInfo) -> Box<BaseSinkImpl<RsBaseSink>> {
fn init(element: &BaseSink, sink_info: &SinkInfo) -> Box<BaseSinkImpl<BaseSink>> {
element.set_blocksize(4096);
let imp = Self::new(element, sink_info);
@ -101,7 +101,7 @@ impl Sink {
}
fn set_uri(&self, element: &glib::Object, uri_str: Option<String>) -> Result<(), glib::Error> {
let sink = element.clone().dynamic_cast::<RsBaseSink>().unwrap();
let sink = element.clone().dynamic_cast::<BaseSink>().unwrap();
let uri_storage = &mut self.uri.lock().unwrap();
@ -135,7 +135,7 @@ impl Sink {
}
}
impl ObjectImpl<RsBaseSink> for Sink {
impl ObjectImpl<BaseSink> for Sink {
fn set_property(&self, obj: &glib::Object, id: u32, value: &glib::Value) {
let prop = &PROPERTIES[id as usize];
@ -157,10 +157,10 @@ impl ObjectImpl<RsBaseSink> for Sink {
}
}
impl ElementImpl<RsBaseSink> for Sink {}
impl ElementImpl<BaseSink> for Sink {}
impl BaseSinkImpl<RsBaseSink> for Sink {
fn start(&self, sink: &RsBaseSink) -> bool {
impl BaseSinkImpl<BaseSink> for Sink {
fn start(&self, sink: &BaseSink) -> bool {
gst_debug!(self.cat, obj: sink, "Starting");
// Don't keep the URI locked while we call start later
@ -192,7 +192,7 @@ impl BaseSinkImpl<RsBaseSink> for Sink {
}
}
fn stop(&self, sink: &RsBaseSink) -> bool {
fn stop(&self, sink: &BaseSink) -> bool {
let sink_impl = &mut self.imp.lock().unwrap();
gst_debug!(self.cat, obj: sink, "Stopping");
@ -212,7 +212,7 @@ impl BaseSinkImpl<RsBaseSink> for Sink {
}
}
fn render(&self, sink: &RsBaseSink, buffer: &gst::BufferRef) -> gst::FlowReturn {
fn render(&self, sink: &BaseSink, buffer: &gst::BufferRef) -> gst::FlowReturn {
let sink_impl = &mut self.imp.lock().unwrap();
gst_trace!(self.cat, obj: sink, "Rendering buffer {:?}", buffer,);
@ -250,7 +250,7 @@ pub struct SinkInfo {
pub classification: String,
pub author: String,
pub rank: u32,
pub create_instance: fn(&RsBaseSink) -> Box<SinkImpl>,
pub create_instance: fn(&BaseSink) -> Box<SinkImpl>,
pub protocols: Vec<String>,
}
@ -259,16 +259,16 @@ struct SinkStatic {
sink_info: SinkInfo,
}
impl ImplTypeStatic<RsBaseSink> for SinkStatic {
impl ImplTypeStatic<BaseSink> for SinkStatic {
fn get_name(&self) -> &str {
self.name.as_str()
}
fn new(&self, element: &RsBaseSink) -> Box<BaseSinkImpl<RsBaseSink>> {
fn new(&self, element: &BaseSink) -> Box<BaseSinkImpl<BaseSink>> {
Sink::init(element, &self.sink_info)
}
fn class_init(&self, klass: &mut RsBaseSinkClass) {
fn class_init(&self, klass: &mut BaseSinkClass) {
Sink::class_init(klass, &self.sink_info);
}
@ -277,8 +277,8 @@ impl ImplTypeStatic<RsBaseSink> for SinkStatic {
}
}
impl URIHandlerImplStatic<RsBaseSink> for SinkStatic {
fn get_impl<'a>(&self, imp: &'a Box<BaseSinkImpl<RsBaseSink>>) -> &'a URIHandlerImpl {
impl URIHandlerImplStatic<BaseSink> for SinkStatic {
fn get_impl<'a>(&self, imp: &'a Box<BaseSinkImpl<BaseSink>>) -> &'a URIHandlerImpl {
imp.downcast_ref::<Sink>().unwrap()
}

View file

@ -25,26 +25,26 @@ use gst_plugin::base_src::*;
use gst_plugin::uri_handler::*;
use gst_plugin::error::*;
pub use gst_plugin::base_src::RsBaseSrc;
pub use gst_plugin::base_src::BaseSrc;
use UriValidator;
pub trait SourceImpl: Send + 'static {
fn uri_validator(&self) -> Box<UriValidator>;
fn is_seekable(&self, src: &RsBaseSrc) -> bool;
fn get_size(&self, src: &RsBaseSrc) -> Option<u64>;
fn is_seekable(&self, src: &BaseSrc) -> bool;
fn get_size(&self, src: &BaseSrc) -> Option<u64>;
fn start(&mut self, src: &RsBaseSrc, uri: Url) -> Result<(), ErrorMessage>;
fn stop(&mut self, src: &RsBaseSrc) -> Result<(), ErrorMessage>;
fn start(&mut self, src: &BaseSrc, uri: Url) -> Result<(), ErrorMessage>;
fn stop(&mut self, src: &BaseSrc) -> Result<(), ErrorMessage>;
fn fill(
&mut self,
src: &RsBaseSrc,
src: &BaseSrc,
offset: u64,
length: u32,
buffer: &mut gst::BufferRef,
) -> Result<(), FlowError>;
fn seek(&mut self, src: &RsBaseSrc, start: u64, stop: Option<u64>) -> Result<(), ErrorMessage>;
fn seek(&mut self, src: &BaseSrc, start: u64, stop: Option<u64>) -> Result<(), ErrorMessage>;
}
struct Source {
@ -66,7 +66,7 @@ static PROPERTIES: [Property; 1] = [
];
impl Source {
fn new(source: &RsBaseSrc, source_info: &SourceInfo) -> Self {
fn new(source: &BaseSrc, source_info: &SourceInfo) -> Self {
let source_impl = (source_info.create_instance)(source);
Self {
@ -82,7 +82,7 @@ impl Source {
}
}
fn class_init(klass: &mut RsBaseSrcClass, source_info: &SourceInfo) {
fn class_init(klass: &mut BaseSrcClass, source_info: &SourceInfo) {
klass.set_metadata(
&source_info.long_name,
&source_info.classification,
@ -102,7 +102,7 @@ impl Source {
klass.install_properties(&PROPERTIES);
}
fn init(element: &RsBaseSrc, source_info: &SourceInfo) -> Box<BaseSrcImpl<RsBaseSrc>> {
fn init(element: &BaseSrc, source_info: &SourceInfo) -> Box<BaseSrcImpl<BaseSrc>> {
element.set_blocksize(4096);
let imp = Self::new(element, source_info);
@ -115,7 +115,7 @@ impl Source {
}
fn set_uri(&self, element: &glib::Object, uri_str: Option<String>) -> Result<(), glib::Error> {
let src = element.clone().dynamic_cast::<RsBaseSrc>().unwrap();
let src = element.clone().dynamic_cast::<BaseSrc>().unwrap();
let uri_storage = &mut self.uri.lock().unwrap();
@ -149,7 +149,7 @@ impl Source {
}
}
impl ObjectImpl<RsBaseSrc> for Source {
impl ObjectImpl<BaseSrc> for Source {
fn set_property(&self, obj: &glib::Object, id: u32, value: &glib::Value) {
let prop = &PROPERTIES[id as usize];
@ -171,10 +171,10 @@ impl ObjectImpl<RsBaseSrc> for Source {
}
}
impl ElementImpl<RsBaseSrc> for Source {}
impl ElementImpl<BaseSrc> for Source {}
impl BaseSrcImpl<RsBaseSrc> for Source {
fn start(&self, src: &RsBaseSrc) -> bool {
impl BaseSrcImpl<BaseSrc> for Source {
fn start(&self, src: &BaseSrc) -> bool {
gst_debug!(self.cat, obj: src, "Starting");
// Don't keep the URI locked while we call start later
@ -206,7 +206,7 @@ impl BaseSrcImpl<RsBaseSrc> for Source {
}
}
fn stop(&self, src: &RsBaseSrc) -> bool {
fn stop(&self, src: &BaseSrc) -> bool {
let source_impl = &mut self.imp.lock().unwrap();
gst_debug!(self.cat, obj: src, "Stopping");
@ -226,7 +226,7 @@ impl BaseSrcImpl<RsBaseSrc> for Source {
}
}
fn query(&self, src: &RsBaseSrc, query: &mut gst::QueryRef) -> bool {
fn query(&self, src: &BaseSrc, query: &mut gst::QueryRef) -> bool {
use gst::QueryView;
match query.view_mut() {
@ -238,12 +238,12 @@ impl BaseSrcImpl<RsBaseSrc> for Source {
_ => (),
}
BaseSrc::parent_query(src, query)
BaseSrcBase::parent_query(src, query)
}
fn fill(
&self,
src: &RsBaseSrc,
src: &BaseSrc,
offset: u64,
length: u32,
buffer: &mut gst::BufferRef,
@ -274,7 +274,7 @@ impl BaseSrcImpl<RsBaseSrc> for Source {
}
}
fn do_seek(&self, src: &RsBaseSrc, segment: &mut gst::Segment) -> bool {
fn do_seek(&self, src: &BaseSrc, segment: &mut gst::Segment) -> bool {
let source_impl = &mut self.imp.lock().unwrap();
let start = segment.get_start();
@ -295,12 +295,12 @@ impl BaseSrcImpl<RsBaseSrc> for Source {
}
}
fn is_seekable(&self, src: &RsBaseSrc) -> bool {
fn is_seekable(&self, src: &BaseSrc) -> bool {
let source_impl = &self.imp.lock().unwrap();
source_impl.is_seekable(src)
}
fn get_size(&self, src: &RsBaseSrc) -> Option<u64> {
fn get_size(&self, src: &BaseSrc) -> Option<u64> {
let source_impl = &self.imp.lock().unwrap();
source_impl.get_size(src)
}
@ -323,7 +323,7 @@ pub struct SourceInfo {
pub classification: String,
pub author: String,
pub rank: u32,
pub create_instance: fn(&RsBaseSrc) -> Box<SourceImpl>,
pub create_instance: fn(&BaseSrc) -> Box<SourceImpl>,
pub protocols: Vec<String>,
pub push_only: bool,
}
@ -333,16 +333,16 @@ struct SourceStatic {
source_info: SourceInfo,
}
impl ImplTypeStatic<RsBaseSrc> for SourceStatic {
impl ImplTypeStatic<BaseSrc> for SourceStatic {
fn get_name(&self) -> &str {
self.name.as_str()
}
fn new(&self, element: &RsBaseSrc) -> Box<BaseSrcImpl<RsBaseSrc>> {
fn new(&self, element: &BaseSrc) -> Box<BaseSrcImpl<BaseSrc>> {
Source::init(element, &self.source_info)
}
fn class_init(&self, klass: &mut RsBaseSrcClass) {
fn class_init(&self, klass: &mut BaseSrcClass) {
Source::class_init(klass, &self.source_info);
}
@ -351,8 +351,8 @@ impl ImplTypeStatic<RsBaseSrc> for SourceStatic {
}
}
impl URIHandlerImplStatic<RsBaseSrc> for SourceStatic {
fn get_impl<'a>(&self, imp: &'a Box<BaseSrcImpl<RsBaseSrc>>) -> &'a URIHandlerImpl {
impl URIHandlerImplStatic<BaseSrc> for SourceStatic {
fn get_impl<'a>(&self, imp: &'a Box<BaseSrcImpl<BaseSrc>>) -> &'a URIHandlerImpl {
imp.downcast_ref::<Source>().unwrap()
}

View file

@ -178,9 +178,8 @@ impl Adapter {
return Ok(gst::Buffer::new());
}
let sub = self.deque
.front()
.and_then(|front| if front.get_size() - self.skip >= size {
let sub = self.deque.front().and_then(|front| {
if front.get_size() - self.skip >= size {
gst_trace!(CAT, "Get buffer of {} bytes, subbuffer of first", size);
let new = front
.get_buffer()
@ -189,7 +188,8 @@ impl Adapter {
Some(new)
} else {
None
});
}
});
if let Some(s) = sub {
self.flush(size).unwrap();
@ -262,9 +262,13 @@ impl io::Read for Adapter {
if len == 0 {
return Err(io::Error::new(
io::ErrorKind::WouldBlock,
format!("Missing data: requesting {} but only got {}.",
buf.len(), len)));
io::ErrorKind::WouldBlock,
format!(
"Missing data: requesting {} but only got {}.",
buf.len(),
len
),
));
}
if buf.len() < len {

View file

@ -25,7 +25,7 @@ use object::*;
use element::*;
use anyimpl::*;
pub trait BaseSinkImpl<T: BaseSink>
pub trait BaseSinkImpl<T: BaseSinkBase>
: AnyImpl + ObjectImpl<T> + ElementImpl<T> + Send + Sync + 'static {
fn start(&self, _element: &T) -> bool {
true
@ -92,9 +92,9 @@ pub trait BaseSinkImpl<T: BaseSink>
}
}
any_impl!(BaseSink, BaseSinkImpl);
any_impl!(BaseSinkBase, BaseSinkImpl);
pub unsafe trait BaseSink
pub unsafe trait BaseSinkBase
: IsA<gst::Element> + IsA<gst_base::BaseSink> + ObjectType {
fn parent_query(&self, query: &mut gst::QueryRef) -> bool {
unsafe {
@ -159,7 +159,7 @@ pub unsafe trait BaseSink
}
}
pub unsafe trait BaseSinkClass<T: BaseSink>
pub unsafe trait BaseSinkClassExt<T: BaseSinkBase>
where
T::ImplType: BaseSinkImpl<T>,
{
@ -184,28 +184,28 @@ where
}
glib_wrapper! {
pub struct RsBaseSink(Object<InstanceStruct<RsBaseSink>>): [gst_base::BaseSink => gst_base_ffi::GstBaseSink,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
pub struct BaseSink(Object<InstanceStruct<BaseSink>>): [gst_base::BaseSink => gst_base_ffi::GstBaseSink,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
match fn {
get_type => || get_type::<RsBaseSink>(),
get_type => || get_type::<BaseSink>(),
}
}
unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseSink> + ObjectType> BaseSink for T {}
pub type RsBaseSinkClass = ClassStruct<RsBaseSink>;
unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseSink> + ObjectType> BaseSinkBase for T {}
pub type BaseSinkClass = ClassStruct<BaseSink>;
// FIXME: Boilerplate
unsafe impl BaseSinkClass<RsBaseSink> for RsBaseSinkClass {}
unsafe impl ElementClass<RsBaseSink> for RsBaseSinkClass {}
unsafe impl BaseSinkClassExt<BaseSink> for BaseSinkClass {}
unsafe impl ElementClassExt<BaseSink> for BaseSinkClass {}
#[macro_export]
macro_rules! box_base_sink_impl(
($name:ident) => {
box_element_impl!($name);
impl<T: BaseSink> BaseSinkImpl<T> for Box<$name<T>> {
impl<T: BaseSinkBase> BaseSinkImpl<T> for Box<$name<T>> {
fn start(&self, element: &T) -> bool {
let imp: &$name<T> = self.as_ref();
imp.start(element)
@ -276,7 +276,7 @@ macro_rules! box_base_sink_impl(
box_base_sink_impl!(BaseSinkImpl);
impl ObjectType for RsBaseSink {
impl ObjectType for BaseSink {
const NAME: &'static str = "RsBaseSink";
type GlibType = gst_base_ffi::GstBaseSink;
type GlibClassType = gst_base_ffi::GstBaseSinkClass;
@ -286,15 +286,15 @@ impl ObjectType for RsBaseSink {
unsafe { from_glib(gst_base_ffi::gst_base_sink_get_type()) }
}
fn class_init(token: &ClassInitToken, klass: &mut RsBaseSinkClass) {
ElementClass::override_vfuncs(klass, token);
BaseSinkClass::override_vfuncs(klass, token);
fn class_init(token: &ClassInitToken, klass: &mut BaseSinkClass) {
ElementClassExt::override_vfuncs(klass, token);
BaseSinkClassExt::override_vfuncs(klass, token);
}
object_type_fns!();
}
unsafe extern "C" fn base_sink_start<T: BaseSink>(
unsafe extern "C" fn base_sink_start<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
) -> glib_ffi::gboolean
where
@ -309,7 +309,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.start(&wrap) }).to_glib()
}
unsafe extern "C" fn base_sink_stop<T: BaseSink>(
unsafe extern "C" fn base_sink_stop<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
) -> glib_ffi::gboolean
where
@ -324,7 +324,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.stop(&wrap) }).to_glib()
}
unsafe extern "C" fn base_sink_render<T: BaseSink>(
unsafe extern "C" fn base_sink_render<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
buffer: *mut gst_ffi::GstBuffer,
) -> gst_ffi::GstFlowReturn
@ -343,7 +343,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_sink_prepare<T: BaseSink>(
unsafe extern "C" fn base_sink_prepare<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
buffer: *mut gst_ffi::GstBuffer,
) -> gst_ffi::GstFlowReturn
@ -362,7 +362,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_sink_render_list<T: BaseSink>(
unsafe extern "C" fn base_sink_render_list<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
list: *mut gst_ffi::GstBufferList,
) -> gst_ffi::GstFlowReturn
@ -381,7 +381,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_sink_prepare_list<T: BaseSink>(
unsafe extern "C" fn base_sink_prepare_list<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
list: *mut gst_ffi::GstBufferList,
) -> gst_ffi::GstFlowReturn
@ -400,7 +400,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_sink_query<T: BaseSink>(
unsafe extern "C" fn base_sink_query<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
query_ptr: *mut gst_ffi::GstQuery,
) -> glib_ffi::gboolean
@ -419,7 +419,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_sink_event<T: BaseSink>(
unsafe extern "C" fn base_sink_event<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
event_ptr: *mut gst_ffi::GstEvent,
) -> glib_ffi::gboolean
@ -437,7 +437,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_sink_get_caps<T: BaseSink>(
unsafe extern "C" fn base_sink_get_caps<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
filter: *mut gst_ffi::GstCaps,
) -> *mut gst_ffi::GstCaps
@ -464,7 +464,7 @@ where
.unwrap_or(ptr::null_mut())
}
unsafe extern "C" fn base_sink_set_caps<T: BaseSink>(
unsafe extern "C" fn base_sink_set_caps<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
caps: *mut gst_ffi::GstCaps,
) -> glib_ffi::gboolean
@ -486,7 +486,7 @@ where
).to_glib()
}
unsafe extern "C" fn base_sink_fixate<T: BaseSink>(
unsafe extern "C" fn base_sink_fixate<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
caps: *mut gst_ffi::GstCaps,
) -> *mut gst_ffi::GstCaps
@ -505,7 +505,7 @@ where
}).into_ptr()
}
unsafe extern "C" fn base_sink_unlock<T: BaseSink>(
unsafe extern "C" fn base_sink_unlock<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
) -> glib_ffi::gboolean
where
@ -520,7 +520,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.unlock(&wrap) }).to_glib()
}
unsafe extern "C" fn base_sink_unlock_stop<T: BaseSink>(
unsafe extern "C" fn base_sink_unlock_stop<T: BaseSinkBase>(
ptr: *mut gst_base_ffi::GstBaseSink,
) -> glib_ffi::gboolean
where

View file

@ -25,7 +25,7 @@ use object::*;
use element::*;
use anyimpl::*;
pub trait BaseSrcImpl<T: BaseSrc>
pub trait BaseSrcImpl<T: BaseSrcBase>
: AnyImpl + ObjectImpl<T> + ElementImpl<T> + Send + Sync + 'static {
fn start(&self, _element: &T) -> bool {
true
@ -99,9 +99,9 @@ pub trait BaseSrcImpl<T: BaseSrc>
}
}
any_impl!(BaseSrc, BaseSrcImpl);
any_impl!(BaseSrcBase, BaseSrcImpl);
pub unsafe trait BaseSrc
pub unsafe trait BaseSrcBase
: IsA<gst::Element> + IsA<gst_base::BaseSrc> + ObjectType {
fn parent_create(&self, offset: u64, length: u32) -> Result<gst::Buffer, gst::FlowReturn> {
unsafe {
@ -212,7 +212,7 @@ pub unsafe trait BaseSrc
}
}
pub unsafe trait BaseSrcClass<T: BaseSrc>
pub unsafe trait BaseSrcClassExt<T: BaseSrcBase>
where
T::ImplType: BaseSrcImpl<T>,
{
@ -239,28 +239,28 @@ where
}
glib_wrapper! {
pub struct RsBaseSrc(Object<InstanceStruct<RsBaseSrc>>): [gst_base::BaseSrc => gst_base_ffi::GstBaseSrc,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
pub struct BaseSrc(Object<InstanceStruct<BaseSrc>>): [gst_base::BaseSrc => gst_base_ffi::GstBaseSrc,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
match fn {
get_type => || get_type::<RsBaseSrc>(),
get_type => || get_type::<BaseSrc>(),
}
}
unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseSrc> + ObjectType> BaseSrc for T {}
pub type RsBaseSrcClass = ClassStruct<RsBaseSrc>;
unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseSrc> + ObjectType> BaseSrcBase for T {}
pub type BaseSrcClass = ClassStruct<BaseSrc>;
// FIXME: Boilerplate
unsafe impl BaseSrcClass<RsBaseSrc> for RsBaseSrcClass {}
unsafe impl ElementClass<RsBaseSrc> for RsBaseSrcClass {}
unsafe impl BaseSrcClassExt<BaseSrc> for BaseSrcClass {}
unsafe impl ElementClassExt<BaseSrc> for BaseSrcClass {}
#[macro_export]
macro_rules! box_base_src_impl(
($name:ident) => {
box_element_impl!($name);
impl<T: BaseSrc> BaseSrcImpl<T> for Box<$name<T>> {
impl<T: BaseSrcBase> BaseSrcImpl<T> for Box<$name<T>> {
fn start(&self, element: &T) -> bool {
let imp: &$name<T> = self.as_ref();
imp.start(element)
@ -351,7 +351,7 @@ macro_rules! box_base_src_impl(
);
box_base_src_impl!(BaseSrcImpl);
impl ObjectType for RsBaseSrc {
impl ObjectType for BaseSrc {
const NAME: &'static str = "RsBaseSrc";
type GlibType = gst_base_ffi::GstBaseSrc;
type GlibClassType = gst_base_ffi::GstBaseSrcClass;
@ -361,15 +361,15 @@ impl ObjectType for RsBaseSrc {
unsafe { from_glib(gst_base_ffi::gst_base_src_get_type()) }
}
fn class_init(token: &ClassInitToken, klass: &mut RsBaseSrcClass) {
ElementClass::override_vfuncs(klass, token);
BaseSrcClass::override_vfuncs(klass, token);
fn class_init(token: &ClassInitToken, klass: &mut BaseSrcClass) {
ElementClassExt::override_vfuncs(klass, token);
BaseSrcClassExt::override_vfuncs(klass, token);
}
object_type_fns!();
}
unsafe extern "C" fn base_src_start<T: BaseSrc>(
unsafe extern "C" fn base_src_start<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
) -> glib_ffi::gboolean
where
@ -384,7 +384,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.start(&wrap) }).to_glib()
}
unsafe extern "C" fn base_src_stop<T: BaseSrc>(
unsafe extern "C" fn base_src_stop<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
) -> glib_ffi::gboolean
where
@ -399,7 +399,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.stop(&wrap) }).to_glib()
}
unsafe extern "C" fn base_src_is_seekable<T: BaseSrc>(
unsafe extern "C" fn base_src_is_seekable<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
) -> glib_ffi::gboolean
where
@ -414,7 +414,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.is_seekable(&wrap) }).to_glib()
}
unsafe extern "C" fn base_src_get_size<T: BaseSrc>(
unsafe extern "C" fn base_src_get_size<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
size: *mut u64,
) -> glib_ffi::gboolean
@ -438,7 +438,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_src_fill<T: BaseSrc>(
unsafe extern "C" fn base_src_fill<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
offset: u64,
length: u32,
@ -459,7 +459,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_src_create<T: BaseSrc>(
unsafe extern "C" fn base_src_create<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
offset: u64,
length: u32,
@ -488,7 +488,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_src_do_seek<T: BaseSrc>(
unsafe extern "C" fn base_src_do_seek<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
segment: *mut gst_ffi::GstSegment,
) -> glib_ffi::gboolean
@ -506,7 +506,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_src_query<T: BaseSrc>(
unsafe extern "C" fn base_src_query<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
query_ptr: *mut gst_ffi::GstQuery,
) -> glib_ffi::gboolean
@ -525,7 +525,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_src_event<T: BaseSrc>(
unsafe extern "C" fn base_src_event<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
event_ptr: *mut gst_ffi::GstEvent,
) -> glib_ffi::gboolean
@ -543,7 +543,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_src_get_caps<T: BaseSrc>(
unsafe extern "C" fn base_src_get_caps<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
filter: *mut gst_ffi::GstCaps,
) -> *mut gst_ffi::GstCaps
@ -570,7 +570,7 @@ where
.unwrap_or(ptr::null_mut())
}
unsafe extern "C" fn base_src_negotiate<T: BaseSrc>(
unsafe extern "C" fn base_src_negotiate<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
) -> glib_ffi::gboolean
where
@ -585,7 +585,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.negotiate(&wrap) }).to_glib()
}
unsafe extern "C" fn base_src_set_caps<T: BaseSrc>(
unsafe extern "C" fn base_src_set_caps<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
caps: *mut gst_ffi::GstCaps,
) -> glib_ffi::gboolean
@ -607,7 +607,7 @@ where
).to_glib()
}
unsafe extern "C" fn base_src_fixate<T: BaseSrc>(
unsafe extern "C" fn base_src_fixate<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
caps: *mut gst_ffi::GstCaps,
) -> *mut gst_ffi::GstCaps
@ -626,7 +626,7 @@ where
}).into_ptr()
}
unsafe extern "C" fn base_src_unlock<T: BaseSrc>(
unsafe extern "C" fn base_src_unlock<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
) -> glib_ffi::gboolean
where
@ -641,7 +641,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.unlock(&wrap) }).to_glib()
}
unsafe extern "C" fn base_src_unlock_stop<T: BaseSrc>(
unsafe extern "C" fn base_src_unlock_stop<T: BaseSrcBase>(
ptr: *mut gst_base_ffi::GstBaseSrc,
) -> glib_ffi::gboolean
where

View file

@ -25,7 +25,7 @@ use object::*;
use element::*;
use anyimpl::*;
pub trait BaseTransformImpl<T: BaseTransform>
pub trait BaseTransformImpl<T: BaseTransformBase>
: AnyImpl + ObjectImpl<T> + ElementImpl<T> + Send + Sync + 'static {
fn start(&self, _element: &T) -> bool {
true
@ -104,9 +104,9 @@ pub trait BaseTransformImpl<T: BaseTransform>
}
}
any_impl!(BaseTransform, BaseTransformImpl);
any_impl!(BaseTransformBase, BaseTransformImpl);
pub unsafe trait BaseTransform
pub unsafe trait BaseTransformBase
: IsA<gst::Element> + IsA<gst_base::BaseTransform> + ObjectType {
fn parent_transform_caps(
&self,
@ -252,7 +252,7 @@ pub enum BaseTransformMode {
Both,
}
pub unsafe trait BaseTransformClass<T: BaseTransform>
pub unsafe trait BaseTransformClassExt<T: BaseTransformBase>
where
T::ImplType: BaseTransformImpl<T>,
{
@ -302,28 +302,30 @@ where
}
glib_wrapper! {
pub struct RsBaseTransform(Object<InstanceStruct<RsBaseTransform>>): [gst_base::BaseTransform => gst_base_ffi::GstBaseTransform,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
pub struct BaseTransform(Object<InstanceStruct<BaseTransform>>): [gst_base::BaseTransform => gst_base_ffi::GstBaseTransform,
gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
match fn {
get_type => || get_type::<RsBaseTransform>(),
get_type => || get_type::<BaseTransform>(),
}
}
unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseTransform> + ObjectType> BaseTransform for T {}
pub type RsBaseTransformClass = ClassStruct<RsBaseTransform>;
unsafe impl<T: IsA<gst::Element> + IsA<gst_base::BaseTransform> + ObjectType> BaseTransformBase
for T {
}
pub type BaseTransformClass = ClassStruct<BaseTransform>;
// FIXME: Boilerplate
unsafe impl BaseTransformClass<RsBaseTransform> for RsBaseTransformClass {}
unsafe impl ElementClass<RsBaseTransform> for RsBaseTransformClass {}
unsafe impl BaseTransformClassExt<BaseTransform> for BaseTransformClass {}
unsafe impl ElementClassExt<BaseTransform> for BaseTransformClass {}
#[macro_export]
macro_rules! box_base_transform_impl(
($name:ident) => {
box_element_impl!($name);
impl<T: BaseTransform> BaseTransformImpl<T> for Box<$name<T>> {
impl<T: BaseTransformBase> BaseTransformImpl<T> for Box<$name<T>> {
fn start(&self, element: &T) -> bool {
let imp: &$name<T> = self.as_ref();
imp.start(element)
@ -393,7 +395,7 @@ macro_rules! box_base_transform_impl(
);
box_base_transform_impl!(BaseTransformImpl);
impl ObjectType for RsBaseTransform {
impl ObjectType for BaseTransform {
const NAME: &'static str = "RsBaseTransform";
type GlibType = gst_base_ffi::GstBaseTransform;
type GlibClassType = gst_base_ffi::GstBaseTransformClass;
@ -403,15 +405,15 @@ impl ObjectType for RsBaseTransform {
unsafe { from_glib(gst_base_ffi::gst_base_transform_get_type()) }
}
fn class_init(token: &ClassInitToken, klass: &mut RsBaseTransformClass) {
ElementClass::override_vfuncs(klass, token);
BaseTransformClass::override_vfuncs(klass, token);
fn class_init(token: &ClassInitToken, klass: &mut BaseTransformClass) {
ElementClassExt::override_vfuncs(klass, token);
BaseTransformClassExt::override_vfuncs(klass, token);
}
object_type_fns!();
}
unsafe extern "C" fn base_transform_start<T: BaseTransform>(
unsafe extern "C" fn base_transform_start<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
) -> glib_ffi::gboolean
where
@ -426,7 +428,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.start(&wrap) }).to_glib()
}
unsafe extern "C" fn base_transform_stop<T: BaseTransform>(
unsafe extern "C" fn base_transform_stop<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
) -> glib_ffi::gboolean
where
@ -441,7 +443,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.stop(&wrap) }).to_glib()
}
unsafe extern "C" fn base_transform_transform_caps<T: BaseTransform>(
unsafe extern "C" fn base_transform_transform_caps<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
direction: gst_ffi::GstPadDirection,
caps: *mut gst_ffi::GstCaps,
@ -473,7 +475,7 @@ where
}).into_ptr()
}
unsafe extern "C" fn base_transform_fixate_caps<T: BaseTransform>(
unsafe extern "C" fn base_transform_fixate_caps<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
direction: gst_ffi::GstPadDirection,
caps: *mut gst_ffi::GstCaps,
@ -498,7 +500,7 @@ where
}).into_ptr()
}
unsafe extern "C" fn base_transform_set_caps<T: BaseTransform>(
unsafe extern "C" fn base_transform_set_caps<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
incaps: *mut gst_ffi::GstCaps,
outcaps: *mut gst_ffi::GstCaps,
@ -517,7 +519,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_accept_caps<T: BaseTransform>(
unsafe extern "C" fn base_transform_accept_caps<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
direction: gst_ffi::GstPadDirection,
caps: *mut gst_ffi::GstCaps,
@ -536,7 +538,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_query<T: BaseTransform>(
unsafe extern "C" fn base_transform_query<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
direction: gst_ffi::GstPadDirection,
query: *mut gst_ffi::GstQuery,
@ -560,7 +562,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_transform_size<T: BaseTransform>(
unsafe extern "C" fn base_transform_transform_size<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
direction: gst_ffi::GstPadDirection,
caps: *mut gst_ffi::GstCaps,
@ -594,7 +596,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_get_unit_size<T: BaseTransform>(
unsafe extern "C" fn base_transform_get_unit_size<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
caps: *mut gst_ffi::GstCaps,
size: *mut usize,
@ -619,7 +621,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_sink_event<T: BaseTransform>(
unsafe extern "C" fn base_transform_sink_event<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
event: *mut gst_ffi::GstEvent,
) -> glib_ffi::gboolean
@ -637,7 +639,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_src_event<T: BaseTransform>(
unsafe extern "C" fn base_transform_src_event<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
event: *mut gst_ffi::GstEvent,
) -> glib_ffi::gboolean
@ -655,7 +657,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_transform<T: BaseTransform>(
unsafe extern "C" fn base_transform_transform<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
inbuf: *mut gst_ffi::GstBuffer,
outbuf: *mut gst_ffi::GstBuffer,
@ -678,7 +680,7 @@ where
}).to_glib()
}
unsafe extern "C" fn base_transform_transform_ip<T: BaseTransform>(
unsafe extern "C" fn base_transform_transform_ip<T: BaseTransformBase>(
ptr: *mut gst_base_ffi::GstBaseTransform,
buf: *mut *mut gst_ffi::GstBuffer,
) -> gst_ffi::GstFlowReturn

View file

@ -23,7 +23,7 @@ use gst::prelude::*;
use object::*;
use anyimpl::*;
pub trait ElementImpl<T: Element>
pub trait ElementImpl<T: ElementBase>
: ObjectImpl<T> + AnyImpl + Send + Sync + 'static {
fn change_state(&self, element: &T, transition: gst::StateChange) -> gst::StateChangeReturn {
element.parent_change_state(transition)
@ -54,9 +54,9 @@ pub trait ElementImpl<T: Element>
}
}
any_impl!(Element, ElementImpl);
any_impl!(ElementBase, ElementImpl);
pub unsafe trait Element: IsA<gst::Element> + ObjectType {
pub unsafe trait ElementBase: IsA<gst::Element> + ObjectType {
fn parent_change_state(&self, transition: gst::StateChange) -> gst::StateChangeReturn {
unsafe {
let klass = self.get_class();
@ -104,7 +104,7 @@ pub unsafe trait Element: IsA<gst::Element> + ObjectType {
}
}
pub unsafe trait ElementClass<T: Element>
pub unsafe trait ElementClassExt<T: ElementBase>
where
T::ImplType: ElementImpl<T>,
{
@ -149,26 +149,26 @@ where
}
glib_wrapper! {
pub struct RsElement(Object<InstanceStruct<RsElement>>): [gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
pub struct Element(Object<InstanceStruct<Element>>): [gst::Element => gst_ffi::GstElement,
gst::Object => gst_ffi::GstObject];
match fn {
get_type => || get_type::<RsElement>(),
get_type => || get_type::<Element>(),
}
}
unsafe impl<T: IsA<gst::Element> + ObjectType> Element for T {}
pub type RsElementClass = ClassStruct<RsElement>;
unsafe impl<T: IsA<gst::Element> + ObjectType> ElementBase for T {}
pub type ElementClass = ClassStruct<Element>;
// FIXME: Boilerplate
unsafe impl ElementClass<RsElement> for RsElementClass {}
unsafe impl ElementClassExt<Element> for ElementClass {}
#[macro_export]
macro_rules! box_element_impl(
($name:ident) => {
box_object_impl!($name);
impl<T: Element> ElementImpl<T> for Box<$name<T>> {
impl<T: ElementBase> ElementImpl<T> for Box<$name<T>> {
fn change_state(
&self,
element: &T,
@ -208,7 +208,7 @@ macro_rules! box_element_impl(
box_element_impl!(ElementImpl);
impl ObjectType for RsElement {
impl ObjectType for Element {
const NAME: &'static str = "RsElement";
type GlibType = gst_ffi::GstElement;
type GlibClassType = gst_ffi::GstElementClass;
@ -218,14 +218,14 @@ impl ObjectType for RsElement {
unsafe { from_glib(gst_ffi::gst_element_get_type()) }
}
fn class_init(token: &ClassInitToken, klass: &mut RsElementClass) {
fn class_init(token: &ClassInitToken, klass: &mut ElementClass) {
klass.override_vfuncs(token);
}
object_type_fns!();
}
unsafe extern "C" fn element_change_state<T: Element>(
unsafe extern "C" fn element_change_state<T: ElementBase>(
ptr: *mut gst_ffi::GstElement,
transition: gst_ffi::GstStateChange,
) -> gst_ffi::GstStateChangeReturn
@ -243,7 +243,7 @@ where
}).to_glib()
}
unsafe extern "C" fn element_request_new_pad<T: Element>(
unsafe extern "C" fn element_request_new_pad<T: ElementBase>(
ptr: *mut gst_ffi::GstElement,
templ: *mut gst_ffi::GstPadTemplate,
name: *const libc::c_char,
@ -268,7 +268,7 @@ where
}).to_glib_full()
}
unsafe extern "C" fn element_release_pad<T: Element>(
unsafe extern "C" fn element_release_pad<T: ElementBase>(
ptr: *mut gst_ffi::GstElement,
pad: *mut gst_ffi::GstPad,
) where
@ -285,7 +285,7 @@ unsafe extern "C" fn element_release_pad<T: Element>(
})
}
unsafe extern "C" fn element_send_event<T: Element>(
unsafe extern "C" fn element_send_event<T: ElementBase>(
ptr: *mut gst_ffi::GstElement,
event: *mut gst_ffi::GstEvent,
) -> glib_ffi::gboolean
@ -303,7 +303,7 @@ where
}).to_glib()
}
unsafe extern "C" fn element_query<T: Element>(
unsafe extern "C" fn element_query<T: ElementBase>(
ptr: *mut gst_ffi::GstElement,
query: *mut gst_ffi::GstQuery,
) -> glib_ffi::gboolean
@ -320,7 +320,7 @@ where
panic_to_error!(&wrap, &element.panicked, false, { imp.query(&wrap, query) }).to_glib()
}
unsafe extern "C" fn element_set_context<T: Element>(
unsafe extern "C" fn element_set_context<T: ElementBase>(
ptr: *mut gst_ffi::GstElement,
context: *mut gst_ffi::GstContext,
) where

View file

@ -88,8 +88,20 @@ pub enum Property<'a> {
Option<&'a str>,
PropertyMutability,
),
Boxed(&'a str, &'a str, &'a str, fn() -> glib::Type, PropertyMutability),
Object(&'a str, &'a str, &'a str, fn() -> glib::Type, PropertyMutability),
Boxed(
&'a str,
&'a str,
&'a str,
fn() -> glib::Type,
PropertyMutability,
),
Object(
&'a str,
&'a str,
&'a str,
fn() -> glib::Type,
PropertyMutability,
),
}
impl<'a> Into<*mut gobject_ffi::GParamSpec> for &'a Property<'a> {