1
- use std:: { ptr, thread, time:: Duration , ffi:: { CString , CStr } } ;
2
- use std:: any:: Any ;
1
+ extern crate libc;
3
2
use std:: cmp:: PartialEq ;
4
3
use std:: io:: Write ;
4
+ use std:: { ffi:: { CStr , CString } , time:: Duration } ;
5
5
6
- extern crate libc;
7
- use std:: os:: raw:: { c_char, c_int, c_void} ;
8
- use std:: sync:: { Mutex , Once } ;
9
- use std:: thread:: sleep;
10
- use crate :: util:: log:: { debug, info, DebugMessageFlag } ;
11
6
use crate :: share:: ccxr_sub_entry_message:: CcxSubEntryMessage ;
12
- use nanomsg :: { Endpoint , Protocol , Socket } ;
7
+ use crate :: util :: log :: { debug , DebugMessageFlag } ;
13
8
use lazy_static:: lazy_static;
9
+ use nanomsg:: { Endpoint , Protocol , Socket } ;
14
10
use prost:: Message ;
11
+ use std:: os:: raw:: { c_char, c_int} ;
12
+ use std:: sync:: Mutex ;
13
+ use std:: thread:: sleep;
15
14
16
15
// use crate::bindings::{cc_subtitle, ccx_output_format};
17
16
@@ -119,7 +118,7 @@ impl Eia608Screen {
119
118
pub fn free_xds_str ( & mut self ) {
120
119
if !self . xds_str . is_null ( ) {
121
120
unsafe {
122
- CString :: from_raw ( self . xds_str ) ;
121
+ let _ = CString :: from_raw ( self . xds_str ) ;
123
122
}
124
123
self . xds_str = std:: ptr:: null_mut ( ) ;
125
124
self . xds_len = 0 ;
@@ -134,41 +133,41 @@ impl Drop for Eia608Screen {
134
133
}
135
134
136
135
137
- pub type subdatatype = :: std:: os:: raw:: c_uint ;
136
+ pub type SubDataType = std:: os:: raw:: c_uint ;
138
137
pub type LLONG = i64 ;
139
- pub const subtype_CC_BITMAP : subtype = 0 ;
140
- pub const subtype_CC_608 : subtype = 1 ;
141
- pub const subtype_CC_TEXT : subtype = 2 ;
142
- pub const subtype_CC_RAW : subtype = 3 ;
143
- pub type subtype = :: std:: os:: raw:: c_uint ;
138
+ pub const SUBTYPE_CC_BITMAP : Subtype = 0 ;
139
+ pub const SUBTYPE_CC_608 : Subtype = 1 ;
140
+ pub const SUBTYPE_CC_TEXT : Subtype = 2 ;
141
+ pub const SUBTYPE_CC_RAW : Subtype = 3 ;
142
+ pub type Subtype = std:: os:: raw:: c_uint ;
144
143
145
- pub type ccx_encoding_type = :: std:: os:: raw:: c_uint ;
144
+ pub type CcxEncodingType = std:: os:: raw:: c_uint ;
146
145
147
146
pub struct CcSubtitle {
148
147
#[ doc = " A generic data which contain data according to decoder\n @warn decoder cant output multiple types of data" ]
149
- pub data : * mut :: std:: os:: raw:: c_void ,
150
- pub datatype : subdatatype ,
148
+ pub data : * mut std:: os:: raw:: c_void ,
149
+ pub datatype : SubDataType ,
151
150
#[ doc = " number of data" ]
152
- pub nb_data : :: std:: os:: raw:: c_uint ,
151
+ pub nb_data : std:: os:: raw:: c_uint ,
153
152
#[ doc = " type of subtitle" ]
154
- pub type_ : subtype ,
153
+ pub type_ : Subtype ,
155
154
#[ doc = " Encoding type of Text, must be ignored in case of subtype as bitmap or cc_screen" ]
156
- pub enc_type : ccx_encoding_type ,
155
+ pub enc_type : CcxEncodingType ,
157
156
pub start_time : LLONG ,
158
157
pub end_time : LLONG ,
159
- pub flags : :: std :: os :: raw :: c_int ,
160
- pub lang_index : :: std :: os :: raw :: c_int ,
158
+ pub flags : c_int ,
159
+ pub lang_index : c_int ,
161
160
#[ doc = " flag to tell that decoder has given output" ]
162
- pub got_output : :: std :: os :: raw :: c_int ,
163
- pub mode : [ :: std :: os :: raw :: c_char ; 5usize ] ,
164
- pub info : [ :: std :: os :: raw :: c_char ; 4usize ] ,
161
+ pub got_output : c_int ,
162
+ pub mode : [ c_char ; 5usize ] ,
163
+ pub info : [ c_char ; 4usize ] ,
165
164
#[ doc = " Used for DVB end time in ms" ]
166
- pub time_out : :: std :: os :: raw :: c_int ,
165
+ pub time_out : c_int ,
167
166
pub next : * mut CcSubtitle ,
168
167
pub prev : * mut CcSubtitle ,
169
168
}
170
169
171
-
170
+ # [ repr ( C ) ]
172
171
#[ derive( Debug ) ]
173
172
pub enum CcxShareStatus {
174
173
Ok = 0 ,
@@ -256,7 +255,6 @@ pub fn ccxr_sub_entry_msg_print(msg: &CcxSubEntryMessage) {
256
255
}
257
256
258
257
259
-
260
258
pub fn ccxr_sub_entries_cleanup ( entries : & mut CcxSubEntries ) {
261
259
entries. messages . clear ( ) ;
262
260
}
@@ -272,16 +270,16 @@ pub fn ccxr_share_start(stream_name: &str) -> CcxShareStatus {
272
270
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] ccx_share_start: starting service\n " ) ;
273
271
let mut ctx = CCX_SHARE_CTX . lock ( ) . unwrap ( ) ;
274
272
ctx. nn_sock = Some ( Socket :: new ( Protocol :: Pub ) . unwrap ( ) ) ;
275
- if ( ctx. nn_sock . is_none ( ) ) {
273
+ if ctx. nn_sock . is_none ( ) {
276
274
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] ccx_share_start: can't nn_socket()\n " ) ;
277
275
return CcxShareStatus :: Fail ;
278
276
}
279
- /// TODO translating this line
280
- /// if (!ccx_options.sharing_url)
281
- /// {
282
- /// ccx_options.sharing_url = "tcp://*:3269";
283
- /// }
284
- /// dbg_print(CCX_DMT_SHARE, "[share] ccx_share_start: url=%s\n", ccx_options.sharing_url);
277
+ // TODO translating this line
278
+ // if (!ccx_options.sharing_url)
279
+ // {
280
+ // ccx_options.sharing_url = "tcp://*:3269";
281
+ // }
282
+ // dbg_print(CCX_DMT_SHARE, "[share] ccx_share_start: url=%s\n", ccx_options.sharing_url);
285
283
let sharing_url = "tcp://*:3269" ; // Default URL if none is provided
286
284
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] ccx_share_start: url={}" , sharing_url) ;
287
285
let binder = match ctx. nn_sock . as_mut ( ) . unwrap ( ) . bind ( sharing_url) {
@@ -371,7 +369,8 @@ pub fn _ccxr_share_send(msg: &CcxSubEntryMessage) -> CcxShareStatus {
371
369
let len = ccxr_sub_entry_message_get_packed_size ( msg) ;
372
370
let mut buf = Vec :: with_capacity ( len) ;
373
371
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] _ccx_share_send: packing" ) ;
374
- ccxr_sub_entry_message_pack ( msg, & mut buf) ;
372
+ #[ allow( unused) ]
373
+ let _ = ccxr_sub_entry_message_pack ( msg, & mut buf) ;
375
374
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] _ccx_share_send: sending" ) ;
376
375
let mut ctx = CCX_SHARE_CTX . lock ( ) . unwrap ( ) ;
377
376
if let Some ( sock) = ctx. nn_sock . as_mut ( ) {
@@ -409,8 +408,7 @@ pub fn ccxr_share_stream_done(stream_name: &str) -> CcxShareStatus {
409
408
end_time : 0 ,
410
409
lines : Vec :: new ( ) ,
411
410
} ;
412
-
413
-
411
+ #[ allow( unused) ]
414
412
let mut ctx = CCX_SHARE_CTX . lock ( ) . unwrap ( ) ;
415
413
416
414
if _ccxr_share_send ( & msg) != CcxShareStatus :: Ok {
@@ -428,7 +426,7 @@ pub fn ccxr_share_sub_to_entries(sub: &CcSubtitle, entries: &mut CcxSubEntries)
428
426
429
427
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] _ccx_share_sub_to_entries" ) ;
430
428
431
- if sub. type_ == subtype_CC_608 {
429
+ if sub. type_ == SUBTYPE_CC_608 {
432
430
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] CC_608" ) ;
433
431
434
432
let data_ptr = sub. data as * const Eia608Screen ;
@@ -489,13 +487,13 @@ pub fn ccxr_share_sub_to_entries(sub: &CcSubtitle, entries: &mut CcxSubEntries)
489
487
}
490
488
} else {
491
489
match sub. type_ {
492
- subtype_CC_BITMAP => {
490
+ SUBTYPE_CC_BITMAP => {
493
491
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] CC_BITMAP. Skipping" ) ;
494
492
}
495
- subtype_CC_RAW => {
493
+ SUBTYPE_CC_RAW => {
496
494
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] CC_RAW. Skipping" ) ;
497
495
}
498
- subtype_CC_TEXT => {
496
+ SUBTYPE_CC_TEXT => {
499
497
debug ! ( msg_type = DebugMessageFlag :: SHARE ; "[share] CC_TEXT. Skipping" ) ;
500
498
}
501
499
_ => {
0 commit comments