mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-25 04:11:38 +00:00
Found wrapper for write. Check file_handle and start processing.
This commit is contained in:
parent
0327e676dd
commit
4d5f80a01d
@ -250,7 +250,6 @@ int api_start(struct ccx_s_options api_options){
|
||||
fatal(CCX_COMMON_EXIT_BUG_BUG, "Cannot be reached!");
|
||||
break;
|
||||
}
|
||||
|
||||
list_for_each_entry(dec_ctx, &ctx->dec_ctx_head, list, struct lib_cc_decode)
|
||||
{
|
||||
mprint("\n");
|
||||
@ -476,6 +475,13 @@ int api_param_count(struct ccx_s_options* api_options){
|
||||
return api_options->python_param_count;
|
||||
}
|
||||
|
||||
|
||||
int __real_write(int file_handle, char* buffer, int nbyte);
|
||||
int __wrap_write(int file_handle, char* buffer, int nbyte)
|
||||
{
|
||||
printf("file_handle = %d\n",file_handle);
|
||||
return __real_write(file_handle,buffer,nbyte);
|
||||
}
|
||||
int main(int argc, char* argv[]){
|
||||
int i;
|
||||
struct ccx_s_options* api_options = api_init_options();
|
||||
|
@ -22,8 +22,14 @@ CURLcode res;
|
||||
#define LEPT_MSG_SEVERITY L_SEVERITY_NONE
|
||||
#endif
|
||||
|
||||
struct cc_to_python_subs{
|
||||
char** subs;
|
||||
int number_of_lines;
|
||||
};
|
||||
|
||||
struct ccx_s_options ccx_options;
|
||||
struct lib_ccx_ctx *signal_ctx;
|
||||
struct cc_to_python_subs python_subs;
|
||||
//volatile int terminate_asap = 0;
|
||||
|
||||
struct ccx_s_options* api_init_options();
|
||||
@ -38,4 +44,6 @@ void sigterm_handler(int sig);
|
||||
void sigint_handler(int sig);
|
||||
void print_end_msg();
|
||||
int main(int argc, char *argv[]);
|
||||
int __real_write(int file_handle, char* buffer, int nbyte);
|
||||
int __wrap_write(int file_handle, char* buffer, int nbyte);
|
||||
#endif //CCEXTRACTOR_H
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "utility.h"
|
||||
#include "ccx_encoders_helpers.h"
|
||||
#include "ocr.h"
|
||||
#include "ccextractor.h"
|
||||
|
||||
/* The timing here is not PTS based, but output based, i.e. user delay must be accounted for
|
||||
if there is any */
|
||||
@ -195,7 +196,8 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *conte
|
||||
context->srt_counter++;
|
||||
sprintf(timeline, "%u%s", context->srt_counter, context->encoded_crlf);
|
||||
used = encode_line(context, context->buffer,(unsigned char *) timeline);
|
||||
write(context->out->fh, context->buffer, used);
|
||||
__wrap_write(context->out->fh, context->buffer, used);
|
||||
|
||||
sprintf (timeline, "%02u:%02u:%02u,%03u --> %02u:%02u:%02u,%03u%s",
|
||||
h1, m1, s1, ms1, h2, m2, s2, ms2, context->encoded_crlf);
|
||||
used = encode_line(context, context->buffer,(unsigned char *) timeline);
|
||||
@ -203,7 +205,7 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *conte
|
||||
dbg_print(CCX_DMT_DECODER_608, "\n- - - SRT caption ( %d) - - -\n", context->srt_counter);
|
||||
dbg_print(CCX_DMT_DECODER_608, "%s",timeline);
|
||||
|
||||
write (context->out->fh, context->buffer, used);
|
||||
__wrap_write(context->out->fh, context->buffer, used);
|
||||
for (int i=0;i<15;i++)
|
||||
{
|
||||
if (data->row_used[i])
|
||||
@ -263,7 +265,7 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *conte
|
||||
do_dash=0;
|
||||
|
||||
if (do_dash)
|
||||
write(context->out->fh, "- ", 2);
|
||||
__wrap_write(context->out->fh, "- ", 2);
|
||||
prev_line_start=first;
|
||||
prev_line_end=last;
|
||||
prev_line_center1=center1;
|
||||
@ -276,8 +278,8 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *conte
|
||||
dbg_print(CCX_DMT_DECODER_608, "\r");
|
||||
dbg_print(CCX_DMT_DECODER_608, "%s\n",context->subline);
|
||||
}
|
||||
write(context->out->fh, context->subline, length);
|
||||
write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
|
||||
__wrap_write(context->out->fh, context->subline, length);
|
||||
__wrap_write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
|
||||
wrote_something=1;
|
||||
// fprintf (wb->fh,context->encoded_crlf);
|
||||
}
|
||||
@ -285,6 +287,7 @@ int write_cc_buffer_as_srt(struct eia608_screen *data, struct encoder_ctx *conte
|
||||
dbg_print(CCX_DMT_DECODER_608, "- - - - - - - - - - - -\r\n");
|
||||
|
||||
// fprintf (wb->fh, context->encoded_crlf);
|
||||
write (context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
|
||||
__wrap_write(context->out->fh, context->encoded_crlf, context->encoded_crlf_length);
|
||||
//printf("$ = %s\n",context->encoded_crlf);
|
||||
return wrote_something;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user