Welcome to mirror list, hosted at ThFree Co, Russian Federation.

lib.rs « src - gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9292d23b9e149f02e8fcad9ecaf445d864d152d (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//  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.

#![crate_type="cdylib"]

extern crate libc;
extern crate url;
extern crate hyper;

#[macro_use]
pub mod utils;
#[macro_use]
pub mod error;
pub mod buffer;
pub mod rssource;
pub mod rssink;
pub mod rsfilesrc;
pub mod rshttpsrc;
pub mod rsfilesink;

use utils::*;
use rsfilesrc::FileSrc;
use rshttpsrc::HttpSrc;
use rsfilesink::FileSink;

use std::os::raw::c_void;
use libc::c_char;
use std::ffi::CString;

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) {

    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;
    }

    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));

}

#[no_mangle]
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) {
    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;
    }

    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());
}

#[no_mangle]
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
}