Commit 22ab5689 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

Remove Rs prefix from everything

We have proper namespaces in Rust
parent 656dc990
......@@ -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);
}
}
......
......@@ -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;
......
......@@ -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(())
}
}
......@@ -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, .. }),
..
......
......@@ -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,
......
......@@ -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>()