2016-05-15 15:54:09 +00:00
|
|
|
// Copyright (C) 2016 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
// 2016 Luis de Bethencourt <luisbg@osg.samsung.com>
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
// Boston, MA 02110-1301, USA.
|
|
|
|
|
2016-08-22 20:03:45 +00:00
|
|
|
#![crate_type="cdylib"]
|
2016-05-13 13:35:48 +00:00
|
|
|
|
2016-05-13 15:02:19 +00:00
|
|
|
extern crate libc;
|
2016-05-14 09:34:50 +00:00
|
|
|
extern crate url;
|
2016-11-14 18:57:54 +00:00
|
|
|
extern crate reqwest;
|
2016-09-17 12:31:10 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate bitflags;
|
2016-11-24 14:29:43 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate nom;
|
|
|
|
extern crate flavors;
|
2016-05-13 15:02:19 +00:00
|
|
|
|
2016-05-14 11:44:49 +00:00
|
|
|
#[macro_use]
|
|
|
|
pub mod utils;
|
2016-08-27 08:16:17 +00:00
|
|
|
#[macro_use]
|
|
|
|
pub mod error;
|
2016-09-12 13:00:28 +00:00
|
|
|
pub mod buffer;
|
2016-09-17 12:31:35 +00:00
|
|
|
pub mod adapter;
|
2016-05-14 11:44:49 +00:00
|
|
|
pub mod rssource;
|
2016-05-14 13:31:39 +00:00
|
|
|
pub mod rssink;
|
2016-05-13 13:35:48 +00:00
|
|
|
pub mod rsfilesrc;
|
2016-05-14 14:04:53 +00:00
|
|
|
pub mod rshttpsrc;
|
2016-05-13 15:07:26 +00:00
|
|
|
pub mod rsfilesink;
|
2016-11-24 14:29:43 +00:00
|
|
|
pub mod rsdemuxer;
|
|
|
|
pub mod flvdemux;
|
2016-05-14 12:44:40 +00:00
|
|
|
|
|
|
|
use utils::*;
|
|
|
|
use rsfilesrc::FileSrc;
|
2016-05-14 14:04:53 +00:00
|
|
|
use rshttpsrc::HttpSrc;
|
2016-05-14 13:31:39 +00:00
|
|
|
use rsfilesink::FileSink;
|
2016-11-24 14:29:43 +00:00
|
|
|
use flvdemux::FlvDemux;
|
2016-05-14 12:44:40 +00:00
|
|
|
|
|
|
|
use std::os::raw::c_void;
|
2016-05-15 13:15:58 +00:00
|
|
|
use libc::c_char;
|
2016-05-14 12:44:40 +00:00
|
|
|
use std::ffi::CString;
|
|
|
|
|
2016-08-22 20:03:06 +00:00
|
|
|
unsafe fn source_register(plugin: *const c_void,
|
|
|
|
name: &str,
|
|
|
|
long_name: &str,
|
|
|
|
description: &str,
|
|
|
|
classification: &str,
|
|
|
|
author: &str,
|
|
|
|
rank: i32,
|
|
|
|
create_instance: *const c_void,
|
|
|
|
protocols: &str,
|
|
|
|
push_only: bool) {
|
2016-08-27 08:22:55 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
fn gst_rs_source_register(plugin: *const c_void,
|
|
|
|
name: *const c_char,
|
|
|
|
long_name: *const c_char,
|
|
|
|
description: *const c_char,
|
|
|
|
classification: *const c_char,
|
|
|
|
author: *const c_char,
|
|
|
|
rank: i32,
|
|
|
|
create_instance: *const c_void,
|
|
|
|
protocols: *const c_char,
|
|
|
|
push_only: GBoolean)
|
|
|
|
-> GBoolean;
|
|
|
|
}
|
|
|
|
|
2016-08-22 20:03:06 +00:00
|
|
|
let cname = CString::new(name).unwrap();
|
|
|
|
let clong_name = CString::new(long_name).unwrap();
|
|
|
|
let cdescription = CString::new(description).unwrap();
|
|
|
|
let cclassification = CString::new(classification).unwrap();
|
|
|
|
let cauthor = CString::new(author).unwrap();
|
|
|
|
let cprotocols = CString::new(protocols).unwrap();
|
|
|
|
|
|
|
|
gst_rs_source_register(plugin,
|
|
|
|
cname.as_ptr(),
|
|
|
|
clong_name.as_ptr(),
|
|
|
|
cdescription.as_ptr(),
|
|
|
|
cclassification.as_ptr(),
|
|
|
|
cauthor.as_ptr(),
|
|
|
|
rank,
|
|
|
|
create_instance,
|
|
|
|
cprotocols.as_ptr(),
|
|
|
|
GBoolean::from_bool(push_only));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-14 12:44:40 +00:00
|
|
|
#[no_mangle]
|
2016-08-22 20:03:06 +00:00
|
|
|
pub unsafe extern "C" fn sources_register(plugin: *const c_void) -> GBoolean {
|
|
|
|
source_register(plugin,
|
|
|
|
"rsfilesrc",
|
|
|
|
"File Source",
|
|
|
|
"Reads local files",
|
|
|
|
"Source/File",
|
|
|
|
"Sebastian Dröge <sebastian@centricular.com>",
|
|
|
|
256 + 100,
|
|
|
|
FileSrc::new_boxed as *const c_void,
|
|
|
|
"file",
|
|
|
|
false);
|
|
|
|
|
|
|
|
source_register(plugin,
|
|
|
|
"rshttpsrc",
|
|
|
|
"HTTP Source",
|
|
|
|
"Read HTTP/HTTPS files",
|
|
|
|
"Source/Network/HTTP",
|
|
|
|
"Sebastian Dröge <sebastian@centricular.com>",
|
|
|
|
256 + 100,
|
|
|
|
HttpSrc::new_boxed as *const c_void,
|
|
|
|
"http:https",
|
|
|
|
true);
|
|
|
|
|
|
|
|
GBoolean::True
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn sink_register(plugin: *const c_void,
|
|
|
|
name: &str,
|
|
|
|
long_name: &str,
|
|
|
|
description: &str,
|
|
|
|
classification: &str,
|
|
|
|
author: &str,
|
|
|
|
rank: i32,
|
|
|
|
create_instance: *const c_void,
|
|
|
|
protocols: &str) {
|
2016-08-27 08:22:55 +00:00
|
|
|
extern "C" {
|
|
|
|
fn gst_rs_sink_register(plugin: *const c_void,
|
|
|
|
name: *const c_char,
|
|
|
|
long_name: *const c_char,
|
|
|
|
description: *const c_char,
|
|
|
|
classification: *const c_char,
|
|
|
|
author: *const c_char,
|
|
|
|
rank: i32,
|
|
|
|
create_instance: *const c_void,
|
|
|
|
protocols: *const c_char)
|
|
|
|
-> GBoolean;
|
|
|
|
}
|
|
|
|
|
2016-08-22 20:03:06 +00:00
|
|
|
let cname = CString::new(name).unwrap();
|
|
|
|
let clong_name = CString::new(long_name).unwrap();
|
|
|
|
let cdescription = CString::new(description).unwrap();
|
|
|
|
let cclassification = CString::new(classification).unwrap();
|
|
|
|
let cauthor = CString::new(author).unwrap();
|
|
|
|
let cprotocols = CString::new(protocols).unwrap();
|
|
|
|
|
|
|
|
gst_rs_sink_register(plugin,
|
|
|
|
cname.as_ptr(),
|
|
|
|
clong_name.as_ptr(),
|
|
|
|
cdescription.as_ptr(),
|
|
|
|
cclassification.as_ptr(),
|
|
|
|
cauthor.as_ptr(),
|
|
|
|
rank,
|
|
|
|
create_instance,
|
|
|
|
cprotocols.as_ptr());
|
2016-05-14 12:44:40 +00:00
|
|
|
}
|
2016-05-14 13:31:39 +00:00
|
|
|
|
|
|
|
#[no_mangle]
|
2016-08-22 20:03:06 +00:00
|
|
|
pub unsafe extern "C" fn sinks_register(plugin: *const c_void) -> GBoolean {
|
|
|
|
sink_register(plugin,
|
|
|
|
"rsfilesink",
|
|
|
|
"File Sink",
|
|
|
|
"Writes to local files",
|
|
|
|
"Sink/File",
|
|
|
|
"Luis de Bethencourt <luisbg@osg.samsung.com>",
|
|
|
|
256 + 100,
|
|
|
|
FileSink::new_boxed as *const c_void,
|
|
|
|
"file");
|
|
|
|
|
|
|
|
GBoolean::True
|
2016-05-14 13:31:39 +00:00
|
|
|
}
|
2016-11-24 14:29:43 +00:00
|
|
|
|
|
|
|
unsafe fn demuxer_register(plugin: *const c_void,
|
|
|
|
name: &str,
|
|
|
|
long_name: &str,
|
|
|
|
description: &str,
|
|
|
|
classification: &str,
|
|
|
|
author: &str,
|
|
|
|
rank: i32,
|
|
|
|
create_instance: *const c_void,
|
|
|
|
input_format: &str,
|
|
|
|
output_formats: &str) {
|
|
|
|
extern "C" {
|
|
|
|
fn gst_rs_demuxer_register(plugin: *const c_void,
|
|
|
|
name: *const c_char,
|
|
|
|
long_name: *const c_char,
|
|
|
|
description: *const c_char,
|
|
|
|
classification: *const c_char,
|
|
|
|
author: *const c_char,
|
|
|
|
rank: i32,
|
|
|
|
create_instance: *const c_void,
|
|
|
|
input_format: *const c_char,
|
|
|
|
output_formats: *const c_char)
|
|
|
|
-> GBoolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
let cname = CString::new(name).unwrap();
|
|
|
|
let clong_name = CString::new(long_name).unwrap();
|
|
|
|
let cdescription = CString::new(description).unwrap();
|
|
|
|
let cclassification = CString::new(classification).unwrap();
|
|
|
|
let cauthor = CString::new(author).unwrap();
|
|
|
|
let cinput_format = CString::new(input_format).unwrap();
|
|
|
|
let coutput_formats = CString::new(output_formats).unwrap();
|
|
|
|
|
|
|
|
gst_rs_demuxer_register(plugin,
|
|
|
|
cname.as_ptr(),
|
|
|
|
clong_name.as_ptr(),
|
|
|
|
cdescription.as_ptr(),
|
|
|
|
cclassification.as_ptr(),
|
|
|
|
cauthor.as_ptr(),
|
|
|
|
rank,
|
|
|
|
create_instance,
|
|
|
|
cinput_format.as_ptr(),
|
|
|
|
coutput_formats.as_ptr());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub unsafe extern "C" fn demuxers_register(plugin: *const c_void) -> GBoolean {
|
|
|
|
demuxer_register(plugin,
|
|
|
|
"rsflvdemux",
|
|
|
|
"FLV Demuxer",
|
|
|
|
"Demuxes FLV Streams",
|
|
|
|
"Codec/Demuxer",
|
|
|
|
"Sebastian Dröge <sebastian@centricular.com>",
|
|
|
|
256 + 100,
|
|
|
|
FlvDemux::new_boxed as *const c_void,
|
|
|
|
"video/x-flv",
|
|
|
|
"ANY");
|
|
|
|
|
|
|
|
GBoolean::True
|
|
|
|
}
|