Skip to content

Commit

Permalink
showing language at channel in DVB transcript
Browse files Browse the repository at this point in the history
  • Loading branch information
anshul1912 committed Jul 30, 2014
1 parent a32c8a3 commit 783e889
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/cc_decoders_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct cc_subtitle
LLONG end_time;
/* flags */
int flags;
/* index of language table */
int lang_index;
/** flag to tell that decoder has given output */
int got_output;
};
Expand Down
10 changes: 9 additions & 1 deletion src/cc_encoders_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,15 @@ int write_cc_bitmap_as_transcript(struct cc_subtitle *sub, struct encoder_ctx *c
fdprintf(context->out->fh, "%s%c%03d|", buf2,ccx_options.millis_separator,end_time_dec);
}
}
fdprintf(context->out->fh,"DVB|%s\n",token);
if (ccx_options.transcript_settings.showCC)
{
fdprintf(context->out->fh,"%s|",language[sub->lang_index]);
}
if (ccx_options.transcript_settings.showMode)
{
fdprintf(context->out->fh,"DVB|");
}
fdprintf(context->out->fh,"%s\n",token);
token = strtok(NULL,"\r\n");

}
Expand Down
8 changes: 8 additions & 0 deletions src/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,11 @@ enum
DTVCC_PACKET_DATA = 2,
DTVCC_PACKET_START = 3,
};

const char *language[4] =
{
"und",
"eng",
"fin",
NULL
};
2 changes: 1 addition & 1 deletion src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,5 @@ enum subtype
CC_608,
CC_TEXT,
};

extern const char *language[4];
#endif
15 changes: 8 additions & 7 deletions src/dvb_subtitle_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ const uint8_t crop_tab[256 + 2 * MAX_NEG_CROP] = { times256(0x00), 0x00, 0x01,

#define cm (crop_tab + MAX_NEG_CROP)

const char *dvb_language[] = { "und", "eng", "fin", NULL };

static __inline unsigned int bytestream_get_byte(const uint8_t **b)
{
Expand Down Expand Up @@ -270,7 +269,7 @@ typedef struct DVBSubContext
{
int composition_id;
int ancillary_id;

int lang_index;
int version;
int time_out;
DVBSubRegion *region_list;
Expand Down Expand Up @@ -420,14 +419,15 @@ static void delete_regions(DVBSubContext *ctx)
* @return DVB context kept as void* for abstraction
*
*/
void* dvbsub_init_decoder(int composition_id, int ancillary_id)
void* dvbsub_init_decoder(struct dvb_config* cfg)
{
int i, r, g, b, a = 0;
DVBSubContext *ctx = (DVBSubContext*) malloc(sizeof(DVBSubContext));
memset(ctx, 0, sizeof(DVBSubContext));

ctx->composition_id = composition_id;
ctx->ancillary_id = ancillary_id;
ctx->composition_id = cfg->composition_id[0];
ctx->ancillary_id = cfg->ancillary_id[0];
ctx->lang_index = cfg->lang_index[0];

ctx->version = -1;

Expand Down Expand Up @@ -1427,6 +1427,7 @@ static int write_dvb_sub(void *dvb_ctx, struct cc_subtitle *sub)
int offset_x=0, offset_y=0;

sub->type = CC_BITMAP;
sub->lang_index = ctx->lang_index;
if (display_def)
{
offset_x = display_def->x;
Expand Down Expand Up @@ -1646,9 +1647,9 @@ int parse_dvb_description(struct dvb_config* cfg, unsigned char*data,
for (i = 0; i < cfg->n_language; i++, data += i * 8)
{
/* setting language to undefined if not found in language lkup table */
for (j = 0, cfg->lang_index[i] = 0; dvb_language[j] != NULL; j++)
for (j = 0, cfg->lang_index[i] = 0; language[j] != NULL; j++)
{
if (!strncmp((const char*) (data), dvb_language[j], 3))
if (!strncmp((const char*) (data), language[j], 3))
cfg->lang_index[i] = j;
}
cfg->sub_type[i] = data[3];
Expand Down
9 changes: 2 additions & 7 deletions src/dvb_subtitle_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ struct dvb_config
};

/**
* @param composition_id composition-page_id found in Subtitle descriptors
* associated with subtitle stream in the PMT
* it could be -1 if not found in PMT.
* @param ancillary_id ancillary-page_id found in Subtitle descriptors
* associated with subtitle stream in the PMT.
* it could be -1 if not found in PMT.
* @param cfg Structure containg configuration
*
* @return DVB context kept as void* for abstraction
*
*/
void* dvbsub_init_decoder(int composition_id, int ancillary_id);
void* dvbsub_init_decoder(struct dvb_config* cfg);

int dvbsub_close_decoder(void *dvb_ctx);

Expand Down
2 changes: 1 addition & 1 deletion src/ts_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int parse_PMT (unsigned char *buf,int len, int pos)
ret = parse_dvb_description(&cnf,es_info,desc_len);
if(ret < 0)
break;
cxx_dvb_context = dvbsub_init_decoder(cnf.composition_id[0],cnf.ancillary_id[0]);
cxx_dvb_context = dvbsub_init_decoder(&cnf);
if (cxx_dvb_context == NULL)
break;
ccx_options.ts_cappid = newcappid = elementary_PID;
Expand Down

0 comments on commit 783e889

Please sign in to comment.