From dbe912c8646b7aa6f646c63db6e9812bf7ecd98c Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Tue, 30 Sep 2014 13:16:43 +0100 Subject: [PATCH] Add support for audio timestamp offsets --- filters/audio/audio.c | 2 ++ obe.h | 1 + obecli.c | 32 +++++++++++++++++--------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/filters/audio/audio.c b/filters/audio/audio.c index b24d934a..4aa19c17 100644 --- a/filters/audio/audio.c +++ b/filters/audio/audio.c @@ -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 ); } diff --git a/obe.h b/obe.h index 792e0708..022c066e 100644 --- a/obe.h +++ b/obe.h @@ -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; diff --git a/obecli.c b/obecli.c index 0752a77e..8cb2f766 100644 --- a/obecli.c +++ b/obecli.c @@ -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 */ @@ -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 ) { @@ -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" ); @@ -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 );