4
4
#include "ccx_common_common.h"
5
5
#include "utility.h"
6
6
7
+ #ifndef DISABLE_RUST
8
+
9
+ extern struct ccx_decoders_xds_context * ccxr_ccx_decoders_xds_init_library (
10
+ struct ccx_common_timing_ctx timing ,
11
+ int xds_write_to_file );
12
+
13
+ extern int ccxr_write_xds_string (
14
+ struct cc_subtitle * sub ,
15
+ struct ccx_decoders_xds_context * ctx ,
16
+ const char * p ,
17
+ size_t len );
18
+
19
+ extern void ccxr_xdsprint (
20
+ struct cc_subtitle * sub ,
21
+ struct ccx_decoders_xds_context * ctx ,
22
+ const char * _fmt ,
23
+ va_list args );
24
+
25
+ extern void ccxr_clear_xds_buffer (
26
+ struct ccx_decoders_xds_context * ctx ,
27
+ int64_t num );
28
+
29
+ extern int64_t ccxr_how_many_used (
30
+ const struct ccx_decoders_xds_context * ctx );
31
+
32
+ extern void ccxr_process_xds_bytes (
33
+ struct ccx_decoders_xds_context * ctx ,
34
+ uint8_t hi ,
35
+ int64_t lo );
36
+
37
+ extern void ccxr_xds_do_copy_generation_management_system (
38
+ struct cc_subtitle * sub ,
39
+ struct ccx_decoders_xds_context * ctx ,
40
+ uint8_t c1 ,
41
+ uint8_t c2 );
42
+
43
+ extern void ccxr_xds_do_content_advisory (
44
+ struct cc_subtitle * sub ,
45
+ struct ccx_decoders_xds_context * ctx ,
46
+ uint8_t c1 ,
47
+ uint8_t c2 );
48
+
49
+ extern int64_t ccxr_xds_do_private_data (
50
+ struct cc_subtitle * sub ,
51
+ struct ccx_decoders_xds_context * ctx );
52
+
53
+ extern int64_t ccxr_xds_do_misc (
54
+ const struct ccx_decoders_xds_context * ctx );
55
+
56
+ extern int64_t ccxr_xds_do_current_and_future (
57
+ struct cc_subtitle * sub ,
58
+ struct ccx_decoders_xds_context * ctx );
59
+
60
+ extern void ccxr_do_end_of_xds (
61
+ struct cc_subtitle * sub ,
62
+ struct ccx_decoders_xds_context * ctx ,
63
+ int64_t expected_checksum );
64
+
65
+ extern int64_t ccxr_xds_do_channel (
66
+ struct cc_subtitle * sub ,
67
+ struct ccx_decoders_xds_context * ctx );
68
+
69
+ extern void ccxr_xds_debug_test (
70
+ struct ccx_decoders_xds_context * ctx ,
71
+ struct cc_subtitle * sub );
72
+
73
+ extern void ccxr_xds_cea608_test (
74
+ struct ccx_decoders_xds_context * ctx ,
75
+ struct cc_subtitle * sub );
76
+
77
+ #endif
78
+
7
79
LLONG ts_start_of_xds = -1 ; // Time at which we switched to XDS mode, =-1 hasn't happened yet
8
80
9
81
static const char * XDSclasses [] =
@@ -80,6 +152,9 @@ static const char *XDSProgramTypes[] =
80
152
81
153
struct ccx_decoders_xds_context * ccx_decoders_xds_init_library (struct ccx_common_timing_ctx * timing , int xds_write_to_file )
82
154
{
155
+ #ifndef DISABLE_RUST
156
+ return ccxr_ccx_decoders_xds_init_library (* timing , xds_write_to_file );
157
+ #else
83
158
int i ;
84
159
struct ccx_decoders_xds_context * ctx = NULL ;
85
160
@@ -121,10 +196,14 @@ struct ccx_decoders_xds_context *ccx_decoders_xds_init_library(struct ccx_common
121
196
ctx -> xds_write_to_file = xds_write_to_file ;
122
197
123
198
return ctx ;
199
+ #endif
124
200
}
125
201
126
202
int write_xds_string (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , char * p , size_t len )
127
203
{
204
+ #ifndef DISABLE_RUST
205
+ return ccxr_write_xds_string (sub , ctx , p , len );
206
+ #else
128
207
struct eia608_screen * data = NULL ;
129
208
data = (struct eia608_screen * )realloc (sub -> data , (sub -> nb_data + 1 ) * sizeof (* data ));
130
209
if (!data )
@@ -151,10 +230,18 @@ int write_xds_string(struct cc_subtitle *sub, struct ccx_decoders_xds_context *c
151
230
}
152
231
153
232
return 0 ;
233
+ #endif
154
234
}
155
235
156
236
void xdsprint (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , const char * fmt , ...)
157
237
{
238
+ #ifndef DISABLE_RUST
239
+ va_list ap ;
240
+ va_start (ap , fmt );
241
+ ccxr_xdsprint (sub , ctx , fmt , ap );
242
+ va_end (ap );
243
+ #else
244
+
158
245
if (!ctx -> xds_write_to_file )
159
246
return ;
160
247
/* Guess we need no more than 100 bytes. */
@@ -192,17 +279,25 @@ void xdsprint(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx, con
192
279
p = np ;
193
280
}
194
281
}
282
+ #endif
195
283
}
196
284
197
285
void xds_debug_test (struct ccx_decoders_xds_context * ctx , struct cc_subtitle * sub )
198
286
{
287
+ #ifndef DISABLE_RUST
288
+ ccxr_xds_debug_test (ctx , sub );
289
+ #else
199
290
process_xds_bytes (ctx , 0x05 , 0x02 );
200
291
process_xds_bytes (ctx , 0x20 , 0x20 );
201
292
do_end_of_xds (sub , ctx , 0x2a );
293
+ #endif
202
294
}
203
295
204
296
void xds_cea608_test (struct ccx_decoders_xds_context * ctx , struct cc_subtitle * sub )
205
297
{
298
+ #ifndef DISABLE_RUST
299
+ ccxr_xds_cea608_test (ctx , sub );
300
+ #else
206
301
/* This test is the sample data that comes in CEA-608. It sets the program name
207
302
to be "Star Trek". The checksum is 0x1d and the validation must succeed. */
208
303
process_xds_bytes (ctx , 0x01 , 0x03 );
@@ -214,28 +309,40 @@ void xds_cea608_test(struct ccx_decoders_xds_context *ctx, struct cc_subtitle *s
214
309
process_xds_bytes (ctx , 0x02 , 0x03 );
215
310
process_xds_bytes (ctx , 0x6b , 0x00 );
216
311
do_end_of_xds (sub , ctx , 0x1d );
312
+ #endif
217
313
}
218
314
219
315
int how_many_used (struct ccx_decoders_xds_context * ctx )
220
316
{
317
+ #ifndef DISABLE_RUST
318
+ ccxr_how_many_used (ctx );
319
+ #else
221
320
int c = 0 ;
222
321
for (int i = 0 ; i < NUM_XDS_BUFFERS ; i ++ )
223
322
if (ctx -> xds_buffers [i ].in_use )
224
323
c ++ ;
225
324
return c ;
325
+ #endif
226
326
}
227
327
228
328
void clear_xds_buffer (struct ccx_decoders_xds_context * ctx , int num )
229
329
{
330
+ #ifndef DISABLE_RUST
331
+ ccxr_clear_xds_buffer (ctx , num );
332
+ #else
230
333
ctx -> xds_buffers [num ].in_use = 0 ;
231
334
ctx -> xds_buffers [num ].xds_class = -1 ;
232
335
ctx -> xds_buffers [num ].xds_type = -1 ;
233
336
ctx -> xds_buffers [num ].used_bytes = 0 ;
234
337
memset (ctx -> xds_buffers [num ].bytes , 0 , NUM_BYTES_PER_PACKET );
338
+ #endif
235
339
}
236
340
237
341
void process_xds_bytes (struct ccx_decoders_xds_context * ctx , const unsigned char hi , int lo )
238
342
{
343
+ #ifndef DISABLE_RUST
344
+ ccxr_process_xds_bytes (ctx , hi , lo );
345
+ #else
239
346
int is_new ;
240
347
if (!ctx )
241
348
return ;
@@ -305,12 +412,17 @@ void process_xds_bytes(struct ccx_decoders_xds_context *ctx, const unsigned char
305
412
ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].bytes [ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].used_bytes ++ ] = lo ;
306
413
ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].bytes [ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].used_bytes ] = 0 ;
307
414
}
415
+ #endif
308
416
}
417
+
309
418
/**
310
419
* ctx XDS context can be NULL, if user don't want to write xds in transcript
311
420
*/
312
421
void xds_do_copy_generation_management_system (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned c1 , unsigned c2 )
313
422
{
423
+ #ifndef DISABLE_RUST
424
+ ccxr_xds_do_copy_generation_management_system (sub , ctx , c1 , c2 );
425
+ #else
314
426
static unsigned last_c1 = -1 , last_c2 = -1 ;
315
427
static char copy_permited [256 ];
316
428
static char aps [256 ];
@@ -364,10 +476,14 @@ void xds_do_copy_generation_management_system(struct cc_subtitle *sub, struct cc
364
476
ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , copy_permited );
365
477
ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , aps );
366
478
ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , rcd );
479
+ #endif
367
480
}
368
481
369
482
void xds_do_content_advisory (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned c1 , unsigned c2 )
370
483
{
484
+ #ifndef DISABLE_RUST
485
+ ccxr_xds_do_content_advisory (sub , ctx , c1 , c2 );
486
+ #else
371
487
static unsigned last_c1 = -1 , last_c2 = -1 ;
372
488
static char age [256 ];
373
489
static char content [256 ];
@@ -477,10 +593,14 @@ void xds_do_content_advisory(struct cc_subtitle *sub, struct ccx_decoders_xds_co
477
593
478
594
if (changed && !supported )
479
595
ccx_common_logging .log_ftn ("XDS: Unsupported ContentAdvisory encoding, please submit sample.\n" );
596
+ #endif
480
597
}
481
598
482
599
int xds_do_current_and_future (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
483
600
{
601
+ #ifndef DISABLE_RUST
602
+ ccxr_xds_do_current_and_future (sub , ctx );
603
+ #else
484
604
int was_proc = 0 ;
485
605
486
606
char * str = malloc (1024 );
@@ -727,10 +847,14 @@ int xds_do_current_and_future(struct cc_subtitle *sub, struct ccx_decoders_xds_c
727
847
728
848
free (str );
729
849
return was_proc ;
850
+ #endif
730
851
}
731
852
732
853
int xds_do_channel (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
733
854
{
855
+ #ifndef DISABLE_RUST
856
+ ccxr_xds_do_channel (sub , ctx );
857
+ #else
734
858
int was_proc = 0 ;
735
859
if (!ctx )
736
860
return CCX_EINVAL ;
@@ -790,10 +914,14 @@ int xds_do_channel(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx
790
914
break ;
791
915
}
792
916
return was_proc ;
917
+ #endif
793
918
}
794
919
795
920
int xds_do_private_data (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
796
921
{
922
+ #ifndef DISABLE_RUST
923
+ ccxr_xds_do_private_data (sub , ctx );
924
+ #else
797
925
char * str ;
798
926
int i ;
799
927
@@ -810,10 +938,14 @@ int xds_do_private_data(struct cc_subtitle *sub, struct ccx_decoders_xds_context
810
938
xdsprint (sub , ctx , str );
811
939
free (str );
812
940
return 1 ;
941
+ #endif
813
942
}
814
943
815
944
int xds_do_misc (struct ccx_decoders_xds_context * ctx )
816
945
{
946
+ #ifndef DISABLE_RUST
947
+ ccxr_xds_do_misc (ctx );
948
+ #else
817
949
int was_proc = 0 ;
818
950
if (!ctx )
819
951
return CCX_EINVAL ;
@@ -853,10 +985,15 @@ int xds_do_misc(struct ccx_decoders_xds_context *ctx)
853
985
break ;
854
986
}
855
987
return was_proc ;
988
+ #endif
856
989
}
857
990
858
991
void do_end_of_xds (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned char expected_checksum )
859
992
{
993
+ #ifndef DISABLE_RUST
994
+ ccxr_do_end_of_xds (sub , ctx , expected_checksum );
995
+ #else
996
+
860
997
int cs = 0 ;
861
998
int i ;
862
999
@@ -935,4 +1072,5 @@ void do_end_of_xds(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx
935
1072
dump (CCX_DMT_DECODER_XDS , ctx -> cur_xds_payload , ctx -> cur_xds_payload_length , 0 , 0 );
936
1073
}
937
1074
clear_xds_buffer (ctx , ctx -> cur_xds_buffer_idx );
1075
+ #endif
938
1076
}
0 commit comments