Skip to content

Commit 44141b1

Browse files
committed
Setting the encoder from C
1 parent 4b08981 commit 44141b1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/lib_ccx/general_loop.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#include "dvd_subtitle_decoder.h"
1919
#include "ccx_demuxer_mxf.h"
2020

21+
#ifndef DISABLE_RUST
22+
extern void ccxr_dtvcc_set_encoder(void *dtvcc_rust, void *encoder);
23+
#endif
24+
2125
int end_of_file = 0; // End of file?
2226

2327
// Program stream specific data grabber
@@ -897,6 +901,9 @@ int process_non_multiprogram_general_loop(struct lib_ccx_ctx *ctx,
897901
*enc_ctx = update_encoder_list_cinfo(ctx, cinfo);
898902
*dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
899903
(*dec_ctx)->dtvcc->encoder = (void *)(*enc_ctx);
904+
#ifndef DISABLE_RUST
905+
ccxr_dtvcc_set_encoder((*dec_ctx)->dtvcc_rust, *enc_ctx);
906+
#endif
900907

901908
if ((*dec_ctx)->timing->min_pts == 0x01FFFFFFFFLL) // if we didn't set the min_pts of the program
902909
{
@@ -1094,6 +1101,9 @@ int general_loop(struct lib_ccx_ctx *ctx)
10941101
enc_ctx = update_encoder_list_cinfo(ctx, cinfo);
10951102
dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
10961103
dec_ctx->dtvcc->encoder = (void *)enc_ctx; // WARN: otherwise cea-708 will not work
1104+
#ifndef DISABLE_RUST
1105+
ccxr_dtvcc_set_encoder(dec_ctx->dtvcc_rust, (void *)enc_ctx);
1106+
#endif
10971107

10981108
if (dec_ctx->timing->min_pts == 0x01FFFFFFFFLL) // if we didn't set the min_pts of the program
10991109
{
@@ -1269,6 +1279,9 @@ int rcwt_loop(struct lib_ccx_ctx *ctx)
12691279

12701280
dec_ctx = update_decoder_list(ctx);
12711281
dec_ctx->dtvcc->encoder = (void *)enc_ctx; // WARN: otherwise cea-708 will not work
1282+
#ifndef DISABLE_RUST
1283+
ccxr_dtvcc_set_encoder(dec_ctx->dtvcc_rust, (void *)enc_ctx);
1284+
#endif
12721285
if (parsebuf[6] == 0 && parsebuf[7] == 2)
12731286
{
12741287
dec_ctx->codec = CCX_CODEC_TELETEXT;

src/rust/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ extern "C" fn ccxr_dtvcc_free(dtvcc_rust: *mut Dtvcc) {
7070
unsafe { dtvcc_rust.drop_in_place() };
7171
}
7272

73+
#[no_mangle]
74+
extern "C" fn ccxr_dtvcc_set_encoder(dtvcc_rust: *mut Dtvcc, encoder: *mut encoder_ctx) {
75+
unsafe { dtvcc_rust.as_mut() }.unwrap().encoder = Some(unsafe { encoder.as_mut() }.unwrap());
76+
}
77+
7378
/// Process cc_data
7479
///
7580
/// # Safety

0 commit comments

Comments
 (0)