44#include "ccx_common_common.h"
55#include "utility.h"
66
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+
779LLONG ts_start_of_xds = -1 ; // Time at which we switched to XDS mode, =-1 hasn't happened yet
880
981static const char * XDSclasses [] =
@@ -80,6 +152,9 @@ static const char *XDSProgramTypes[] =
80152
81153struct ccx_decoders_xds_context * ccx_decoders_xds_init_library (struct ccx_common_timing_ctx * timing , int xds_write_to_file )
82154{
155+ #ifndef DISABLE_RUST
156+ return ccxr_ccx_decoders_xds_init_library (* timing , xds_write_to_file );
157+ #else
83158 int i ;
84159 struct ccx_decoders_xds_context * ctx = NULL ;
85160
@@ -121,10 +196,14 @@ struct ccx_decoders_xds_context *ccx_decoders_xds_init_library(struct ccx_common
121196 ctx -> xds_write_to_file = xds_write_to_file ;
122197
123198 return ctx ;
199+ #endif
124200}
125201
126202int write_xds_string (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , char * p , size_t len )
127203{
204+ #ifndef DISABLE_RUST
205+ return ccxr_write_xds_string (sub , ctx , p , len );
206+ #else
128207 struct eia608_screen * data = NULL ;
129208 data = (struct eia608_screen * )realloc (sub -> data , (sub -> nb_data + 1 ) * sizeof (* data ));
130209 if (!data )
@@ -151,10 +230,18 @@ int write_xds_string(struct cc_subtitle *sub, struct ccx_decoders_xds_context *c
151230 }
152231
153232 return 0 ;
233+ #endif
154234}
155235
156236void xdsprint (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , const char * fmt , ...)
157237{
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+
158245 if (!ctx -> xds_write_to_file )
159246 return ;
160247 /* 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
192279 p = np ;
193280 }
194281 }
282+ #endif
195283}
196284
197285void xds_debug_test (struct ccx_decoders_xds_context * ctx , struct cc_subtitle * sub )
198286{
287+ #ifndef DISABLE_RUST
288+ ccxr_xds_debug_test (ctx , sub );
289+ #else
199290 process_xds_bytes (ctx , 0x05 , 0x02 );
200291 process_xds_bytes (ctx , 0x20 , 0x20 );
201292 do_end_of_xds (sub , ctx , 0x2a );
293+ #endif
202294}
203295
204296void xds_cea608_test (struct ccx_decoders_xds_context * ctx , struct cc_subtitle * sub )
205297{
298+ #ifndef DISABLE_RUST
299+ ccxr_xds_cea608_test (ctx , sub );
300+ #else
206301 /* This test is the sample data that comes in CEA-608. It sets the program name
207302 to be "Star Trek". The checksum is 0x1d and the validation must succeed. */
208303 process_xds_bytes (ctx , 0x01 , 0x03 );
@@ -214,28 +309,40 @@ void xds_cea608_test(struct ccx_decoders_xds_context *ctx, struct cc_subtitle *s
214309 process_xds_bytes (ctx , 0x02 , 0x03 );
215310 process_xds_bytes (ctx , 0x6b , 0x00 );
216311 do_end_of_xds (sub , ctx , 0x1d );
312+ #endif
217313}
218314
219315int how_many_used (struct ccx_decoders_xds_context * ctx )
220316{
317+ #ifndef DISABLE_RUST
318+ ccxr_how_many_used (ctx );
319+ #else
221320 int c = 0 ;
222321 for (int i = 0 ; i < NUM_XDS_BUFFERS ; i ++ )
223322 if (ctx -> xds_buffers [i ].in_use )
224323 c ++ ;
225324 return c ;
325+ #endif
226326}
227327
228328void clear_xds_buffer (struct ccx_decoders_xds_context * ctx , int num )
229329{
330+ #ifndef DISABLE_RUST
331+ ccxr_clear_xds_buffer (ctx , num );
332+ #else
230333 ctx -> xds_buffers [num ].in_use = 0 ;
231334 ctx -> xds_buffers [num ].xds_class = -1 ;
232335 ctx -> xds_buffers [num ].xds_type = -1 ;
233336 ctx -> xds_buffers [num ].used_bytes = 0 ;
234337 memset (ctx -> xds_buffers [num ].bytes , 0 , NUM_BYTES_PER_PACKET );
338+ #endif
235339}
236340
237341void process_xds_bytes (struct ccx_decoders_xds_context * ctx , const unsigned char hi , int lo )
238342{
343+ #ifndef DISABLE_RUST
344+ ccxr_process_xds_bytes (ctx , hi , lo );
345+ #else
239346 int is_new ;
240347 if (!ctx )
241348 return ;
@@ -305,12 +412,17 @@ void process_xds_bytes(struct ccx_decoders_xds_context *ctx, const unsigned char
305412 ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].bytes [ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].used_bytes ++ ] = lo ;
306413 ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].bytes [ctx -> xds_buffers [ctx -> cur_xds_buffer_idx ].used_bytes ] = 0 ;
307414 }
415+ #endif
308416}
417+
309418/**
310419 * ctx XDS context can be NULL, if user don't want to write xds in transcript
311420 */
312421void xds_do_copy_generation_management_system (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned c1 , unsigned c2 )
313422{
423+ #ifndef DISABLE_RUST
424+ ccxr_xds_do_copy_generation_management_system (sub , ctx , c1 , c2 );
425+ #else
314426 static unsigned last_c1 = -1 , last_c2 = -1 ;
315427 static char copy_permited [256 ];
316428 static char aps [256 ];
@@ -364,10 +476,14 @@ void xds_do_copy_generation_management_system(struct cc_subtitle *sub, struct cc
364476 ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , copy_permited );
365477 ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , aps );
366478 ccx_common_logging .debug_ftn (CCX_DMT_DECODER_XDS , "\rXDS: %s\n" , rcd );
479+ #endif
367480}
368481
369482void xds_do_content_advisory (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned c1 , unsigned c2 )
370483{
484+ #ifndef DISABLE_RUST
485+ ccxr_xds_do_content_advisory (sub , ctx , c1 , c2 );
486+ #else
371487 static unsigned last_c1 = -1 , last_c2 = -1 ;
372488 static char age [256 ];
373489 static char content [256 ];
@@ -477,10 +593,14 @@ void xds_do_content_advisory(struct cc_subtitle *sub, struct ccx_decoders_xds_co
477593
478594 if (changed && !supported )
479595 ccx_common_logging .log_ftn ("XDS: Unsupported ContentAdvisory encoding, please submit sample.\n" );
596+ #endif
480597}
481598
482599int xds_do_current_and_future (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
483600{
601+ #ifndef DISABLE_RUST
602+ ccxr_xds_do_current_and_future (sub , ctx );
603+ #else
484604 int was_proc = 0 ;
485605
486606 char * str = malloc (1024 );
@@ -727,10 +847,14 @@ int xds_do_current_and_future(struct cc_subtitle *sub, struct ccx_decoders_xds_c
727847
728848 free (str );
729849 return was_proc ;
850+ #endif
730851}
731852
732853int xds_do_channel (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
733854{
855+ #ifndef DISABLE_RUST
856+ ccxr_xds_do_channel (sub , ctx );
857+ #else
734858 int was_proc = 0 ;
735859 if (!ctx )
736860 return CCX_EINVAL ;
@@ -790,10 +914,14 @@ int xds_do_channel(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx
790914 break ;
791915 }
792916 return was_proc ;
917+ #endif
793918}
794919
795920int xds_do_private_data (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx )
796921{
922+ #ifndef DISABLE_RUST
923+ ccxr_xds_do_private_data (sub , ctx );
924+ #else
797925 char * str ;
798926 int i ;
799927
@@ -810,10 +938,14 @@ int xds_do_private_data(struct cc_subtitle *sub, struct ccx_decoders_xds_context
810938 xdsprint (sub , ctx , str );
811939 free (str );
812940 return 1 ;
941+ #endif
813942}
814943
815944int xds_do_misc (struct ccx_decoders_xds_context * ctx )
816945{
946+ #ifndef DISABLE_RUST
947+ ccxr_xds_do_misc (ctx );
948+ #else
817949 int was_proc = 0 ;
818950 if (!ctx )
819951 return CCX_EINVAL ;
@@ -853,10 +985,15 @@ int xds_do_misc(struct ccx_decoders_xds_context *ctx)
853985 break ;
854986 }
855987 return was_proc ;
988+ #endif
856989}
857990
858991void do_end_of_xds (struct cc_subtitle * sub , struct ccx_decoders_xds_context * ctx , unsigned char expected_checksum )
859992{
993+ #ifndef DISABLE_RUST
994+ ccxr_do_end_of_xds (sub , ctx , expected_checksum );
995+ #else
996+
860997 int cs = 0 ;
861998 int i ;
862999
@@ -935,4 +1072,5 @@ void do_end_of_xds(struct cc_subtitle *sub, struct ccx_decoders_xds_context *ctx
9351072 dump (CCX_DMT_DECODER_XDS , ctx -> cur_xds_payload , ctx -> cur_xds_payload_length , 0 , 0 );
9361073 }
9371074 clear_xds_buffer (ctx , ctx -> cur_xds_buffer_idx );
1075+ #endif
9381076}
0 commit comments