Skip to content

Commit

Permalink
Add support for audio timestamp offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
kierank committed Sep 30, 2014
1 parent ef7331d commit dbe912c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions filters/audio/audio.c
Expand Up @@ -77,6 +77,8 @@ static void *start_filter( void *ptr )
&raw_frame->audio_frame.audio_data[((output_stream->sdi_audio_pair-1)<<1)+output_stream->mono_channel], 0, 0,
split_raw_frame->audio_frame.num_samples, num_channels, split_raw_frame->audio_frame.sample_fmt );

split_raw_frame->pts += (int64_t)output_stream->audio_offset * OBE_CLOCK/100;

add_to_encode_queue( h, split_raw_frame, h->encoders[i]->output_stream_id );
}

Expand Down
1 change: 1 addition & 0 deletions obe.h
Expand Up @@ -420,6 +420,7 @@ typedef struct
int sdi_audio_pair;
uint64_t channel_layout;
int mono_channel;
int audio_offset; /* in milliseconds */

/* Metadata */
obe_audio_metadata_t audio_metadata;
Expand Down
32 changes: 17 additions & 15 deletions obecli.c
Expand Up @@ -95,7 +95,7 @@ static const char * stream_opts[] = { "action", "format",
"width", "max-refs",

/* Audio options */
"sdi-audio-pair", "channel-map", "mono-channel",
"sdi-audio-pair", "channel-map", "mono-channel", "audio-offset",
/* AAC options */
"aac-profile", "aac-encap",
/* MP2 options */
Expand Down Expand Up @@ -620,18 +620,19 @@ static int set_stream( char *command, obecli_command_t *child )
char *sdi_audio_pair = obe_get_option( stream_opts[22], opts );
char *channel_map = obe_get_option( stream_opts[23], opts );
char *mono_channel = obe_get_option( stream_opts[24], opts );
char *audio_offset = obe_get_option( stream_opts[24], opts );

/* AAC options */
char *aac_profile = obe_get_option( stream_opts[25], opts );
char *aac_encap = obe_get_option( stream_opts[26], opts );
char *aac_profile = obe_get_option( stream_opts[26], opts );
char *aac_encap = obe_get_option( stream_opts[27], opts );

/* MP2 options */
char *mp2_mode = obe_get_option( stream_opts[27], opts );
char *mp2_mode = obe_get_option( stream_opts[28], opts );

/* NB: remap these and the ttx values below if more encoding options are added - TODO: split them up */
char *pid = obe_get_option( stream_opts[28], opts );
char *lang = obe_get_option( stream_opts[29], opts );
char *audio_type = obe_get_option( stream_opts[30], opts );
char *pid = obe_get_option( stream_opts[29], opts );
char *lang = obe_get_option( stream_opts[30], opts );
char *audio_type = obe_get_option( stream_opts[31], opts );

if( input_stream->stream_type == STREAM_TYPE_VIDEO )
{
Expand Down Expand Up @@ -807,15 +808,16 @@ static int set_stream( char *command, obecli_command_t *child )
memcpy( cli.output_streams[output_stream_id].ts_opts.lang_code, lang, 3 );
cli.output_streams[output_stream_id].ts_opts.lang_code[3] = 0;
}
cli.output_streams[output_stream_id].audio_offset = obe_otoi( audio_offset, cli.output_streams[output_stream_id].audio_offset );
}
else if( output_stream->stream_format == MISC_TELETEXT ||
output_stream->stream_format == VBI_RAW )
{
/* NB: remap these if more encoding options are added - TODO: split them up */
char *ttx_lang = obe_get_option( stream_opts[32], opts );
char *ttx_type = obe_get_option( stream_opts[33], opts );
char *ttx_mag = obe_get_option( stream_opts[34], opts );
char *ttx_page = obe_get_option( stream_opts[35], opts );
char *ttx_lang = obe_get_option( stream_opts[33], opts );
char *ttx_type = obe_get_option( stream_opts[34], opts );
char *ttx_mag = obe_get_option( stream_opts[35], opts );
char *ttx_page = obe_get_option( stream_opts[36], opts );

FAIL_IF_ERROR( ttx_type && ( check_enum_value( ttx_type, teletext_types ) < 0 ),
"Invalid Teletext type\n" );
Expand Down Expand Up @@ -844,10 +846,10 @@ static int set_stream( char *command, obecli_command_t *child )
if( output_stream->stream_format == VBI_RAW )
{
obe_dvb_vbi_opts_t *vbi_opts = &cli.output_streams[output_stream_id].dvb_vbi_opts;
char *vbi_ttx = obe_get_option( stream_opts[36], opts );
char *vbi_inv_ttx = obe_get_option( stream_opts[37], opts );
char *vbi_vps = obe_get_option( stream_opts[38], opts );
char *vbi_wss = obe_get_option( stream_opts[39], opts );
char *vbi_ttx = obe_get_option( stream_opts[37], opts );
char *vbi_inv_ttx = obe_get_option( stream_opts[38], opts );
char *vbi_vps = obe_get_option( stream_opts[39], opts );
char *vbi_wss = obe_get_option( stream_opts[40], opts );

vbi_opts->ttx = obe_otob( vbi_ttx, vbi_opts->ttx );
vbi_opts->inverted_ttx = obe_otob( vbi_inv_ttx, vbi_opts->inverted_ttx );
Expand Down

0 comments on commit dbe912c

Please sign in to comment.