Added support for M2TS

This commit is contained in:
cfsmp3 2015-02-10 17:27:17 +01:00
parent c989c941df
commit c3d00d80f5
8 changed files with 53 additions and 1 deletions

View File

@ -1,3 +1,7 @@
0.76
-----------------
- Added basic M2TS support
0.75 (2015-01-15)
-----------------
- Fixed issue with teletext to other then srt.

View File

@ -91,6 +91,7 @@ void init_options (struct ccx_s_options *options)
options->noautotimeref=0; // Do NOT set time automatically?
options->input_source=CCX_DS_FILE; // Files, stdin or network
options->auto_stream = CCX_SM_AUTODETECT;
options->m2ts = 0;
// Prepare time structures
init_boundary_time (&options->extraction_start);

View File

@ -86,6 +86,7 @@ struct ccx_s_options // Options from user parameters
char **inputfile; // List of files to process
int num_input_files; // How many?
enum ccx_stream_mode_enum auto_stream;
int m2ts; // Regular TS or M2TS
LLONG subs_delay; // ms to delay (or advance) subs
int cc_to_stdout; // If this is set to 1, the stdout will be flushed when data was written to the screen during a process_608 call.
// Output structures

View File

@ -50,6 +50,7 @@ struct lib_ccx_ctx* init_libraries(struct ccx_s_options *opt)
ctx->stream_mode = CCX_SM_ELEMENTARY_OR_NOT_FOUND;
ctx->auto_stream = opt->auto_stream;
ctx->m2ts = opt->m2ts;
ctx->screens_to_process = -1;
ctx->current_file = -1;
ctx->infd = -1;//Set to -1 to indicate no file is open.

View File

@ -135,6 +135,7 @@ struct lib_ccx_ctx
struct lib_cc_decode *dec_ctx;
enum ccx_stream_mode_enum stream_mode;
enum ccx_stream_mode_enum auto_stream;
int m2ts;
int rawmode; // Broadcast or DVD

View File

@ -272,8 +272,16 @@ void set_input_format (struct ccx_s_options *opt, const char *format)
format++;
if (strcmp (format,"es")==0) // Does this actually do anything?
opt->auto_stream = CCX_SM_ELEMENTARY_OR_NOT_FOUND;
else if (strcmp (format,"ts")==0)
else if (strcmp(format, "ts") == 0)
{
opt->auto_stream = CCX_SM_TRANSPORT;
opt->m2ts = 0;
}
else if (strcmp(format, "m2ts") == 0)
{
opt->auto_stream = CCX_SM_TRANSPORT;
opt->m2ts = 1;
}
else if (strcmp (format,"ps")==0 || strcmp (format,"nots")==0)
opt->auto_stream = CCX_SM_PROGRAM;
else if (strcmp (format,"asf")==0 || strcmp (format,"dvr-ms")==0)

View File

@ -73,6 +73,23 @@ void detect_stream_type (struct lib_ccx_ctx *ctx)
// Eight sync bytes, that's good enough
ctx->startbytes_pos=i;
ctx->stream_mode=CCX_SM_TRANSPORT;
ctx->m2ts = 0;
break;
}
}
// Check for M2TS
for (unsigned i = 0; i<192; i++)
{
if (ctx->startbytes[i+4] == 0x47 && ctx->startbytes[i + 4 + 192] == 0x47 &&
ctx->startbytes[i + 192 * 2+4] == 0x47 && ctx->startbytes[i + 192 * 3+4] == 0x47 &&
ctx->startbytes[i + 192 * 4+4] == 0x47 && ctx->startbytes[i + 192 * 5+4] == 0x47 &&
ctx->startbytes[i + 192 * 6+4] == 0x47 && ctx->startbytes[i + 192 * 7+4] == 0x47
)
{
// Eight sync bytes, that's good enough
ctx->startbytes_pos = i;
ctx->stream_mode = CCX_SM_TRANSPORT;
ctx->m2ts = 1;
break;
}
}

View File

@ -57,6 +57,25 @@ void init_ts(struct lib_ccx_ctx *ctx)
// Return 1 for sucessfully read ts packet
int ts_readpacket(struct lib_ccx_ctx* ctx)
{
if (ctx->m2ts)
{
/* M2TS just adds 4 bytes to each packet (so size goes from 188 to 192)
The 4 bytes are not important to us, so just skip
// TP_extra_header {
Copy_permission_indicator 2 unimsbf
Arrival_time_stamp 30 unimsbf
} */
char tp_extra_header[4];
buffered_read(ctx, tp_extra_header, 4);
ctx->past += result;
if (result != 4)
{
if (result>0)
mprint("Premature end of file!\n");
end_of_file = 1;
return 0;
}
}
buffered_read(ctx, tspacket, 188);
ctx->past+=result;
if (result!=188)