Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib_ccx/ccx_common_option.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void init_options (struct ccx_s_options *options)
options->output_filename = NULL;
options->debug_mask=CCX_DMT_GENERIC_NOTICES; // dbg_print will use this mask to print or ignore different types
options->debug_mask_on_debug=CCX_DMT_VERBOSE; // If we're using temp_debug to enable/disable debug "live", this is the mask when temp_debug=1
options->force_flush = 0; //Default value

/* Networking */
options->udpaddr = NULL;
options->udpport=0; // Non-zero => Listen for UDP packets on this port, no files.
Expand Down
5 changes: 3 additions & 2 deletions src/lib_ccx/ccx_common_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ struct encoder_cfg
char *output_filename;
enum ccx_output_format write_format; // 0=Raw, 1=srt, 2=SMI
int keep_output_closed;

int force_flush; //Flushing only when passed as a parameter

enum ccx_encoding_type encoding;
enum ccx_output_date_format date_format;
char millis_separator;
Expand Down Expand Up @@ -79,7 +80,7 @@ struct ccx_s_options // Options from user parameters
int notypesetting;
struct ccx_boundary_time extraction_start, extraction_end; // Segment we actually process
int print_file_reports;

int force_flush ; // Flushing only when passed as a parameter. //0 - Don't flush, 1- Flush

ccx_decoder_608_settings settings_608; // Contains the settings for the 608 decoder.
ccx_decoder_dtvcc_settings settings_dtvcc; //Same for 708 decoder
Expand Down
8 changes: 7 additions & 1 deletion src/lib_ccx/ccx_encoders_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifdef WIN32
int fsync(int fd)
{
printf("Flushing");
FlushFileBuffers(fd);
}
#endif
Expand Down Expand Up @@ -1066,6 +1067,7 @@ static int init_output_ctx(struct encoder_ctx *ctx, struct encoder_cfg *cfg)
return -1;
ctx->nb_out = nb_lang;
ctx->keep_output_closed = cfg->keep_output_closed;
ctx->force_flush = cfg->force_flush;

if(cfg->cc_to_stdout == CCX_FALSE && cfg->send_to_srv == CCX_FALSE)
{
Expand Down Expand Up @@ -1254,6 +1256,7 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt)
ctx->gui_mode_reports = opt->gui_mode_reports;
ctx->extract = opt->extract;
ctx->keep_output_closed = opt->keep_output_closed;
ctx->force_flush = opt->force_flush;

ctx->subline = (unsigned char *) malloc (SUBLINESIZE);
if(!ctx->subline)
Expand Down Expand Up @@ -1498,7 +1501,10 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
}
if (!sub->nb_data)
freep(&sub->data);
if (wrote_something)

//Flush only if -forceflush has been parsed and wrote_something returns non-zero value(by default both 0).

if (wrote_something && context->force_flush)
fsync(context->out->fh); // Don't buffer
return wrote_something;
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib_ccx/ccx_encoders_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct encoder_ctx
int dtvcc_extract; //1 or 0 depending if we have to handle dtvcc
ccx_dtvcc_writer_ctx dtvcc_writers[CCX_DTVCC_MAX_SERVICES];



/* Timing related variables*/
/* start time of previous sub */
LLONG prev_start;
Expand All @@ -96,6 +98,8 @@ struct encoder_ctx

int program_number;
struct list_head list;

int force_flush; //Flush only if the parameter is passed
};

#define INITIAL_ENC_BUFFER_CAPACITY 2048
Expand Down
5 changes: 4 additions & 1 deletion src/lib_ccx/lib_ccx.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct lib_ccx_ctx* init_libraries(struct ccx_s_options *opt)
memset(report_608, 0, sizeof(struct ccx_decoder_608_report));

ccx_decoder_dtvcc_report *report_dtvcc = (ccx_decoder_dtvcc_report *)
malloc(sizeof(ccx_decoder_dtvcc_report));
malloc(sizeof(ccx_decoder_dtvcc_report));
if (!report_dtvcc)
ccx_common_logging.fatal_ftn(EXIT_NOT_ENOUGH_MEMORY, "report_dtvcc");
memset(report_dtvcc, 0, sizeof(ccx_decoder_dtvcc_report));
Expand Down Expand Up @@ -145,6 +145,7 @@ struct lib_ccx_ctx* init_libraries(struct ccx_s_options *opt)
ctx->pesheaderbuf = (unsigned char *) malloc (188); // Never larger anyway

ctx->cc_to_stdout = opt->cc_to_stdout;
ctx->force_flush = opt->force_flush;

ctx->hauppauge_mode = opt->hauppauge_mode;
ctx->live_stream = opt->live_stream;
Expand Down Expand Up @@ -325,6 +326,8 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
if (enc_ctx->program_number == pn)
return enc_ctx;
}
//Flushing
enc_ctx->force_flush = (ctx->force_flush == 1) ? 1: 0;

extension = get_file_extension(ccx_options.enc_cfg.write_format);
if(!extension)
Expand Down
1 change: 1 addition & 0 deletions src/lib_ccx/lib_ccx.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ struct lib_ccx_ctx
struct ccx_s_mp4Cfg mp4_cfg;
int out_interval;
int segment_counter;
int force_flush;
LLONG system_start_time;
};

Expand Down
7 changes: 7 additions & 0 deletions src/lib_ccx/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ void usage (void)
mprint (" -koc: keep-output-close. If used then CCExtractor will close\n");
mprint (" the output file after writing each subtitle frame and\n");
mprint (" attempt to create it again when needed.");
mprint (" -ff --forceflush: Flush\n");
mprint ("\n");

mprint ("Options that affect the built-in closed caption decoder:\n");
Expand Down Expand Up @@ -1707,6 +1708,11 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
i++;
continue;
}
if (strcmp(argv[i], "-ff") == 0 || strcmp(argv[i], "-forceflush") == 0)
{
opt->force_flush = 1;
continue;
}

fatal (EXIT_INCOMPATIBLE_PARAMETERS, "Error: Parameter %s not understood.\n", argv[i]);
// Unrecognized switches are silently ignored
Expand Down Expand Up @@ -1818,6 +1824,7 @@ int parse_parameters (struct ccx_s_options *opt, int argc, char *argv[])
opt->enc_cfg.no_font_color = opt->nofontcolor;
opt->enc_cfg.no_type_setting = opt->notypesetting;
opt->enc_cfg.subs_delay = opt->subs_delay;
opt->enc_cfg.force_flush = opt->force_flush;
if(opt->output_filename && opt->multiprogram == CCX_FALSE)
opt->enc_cfg.output_filename = strdup(opt->output_filename);
else
Expand Down