[FFmpeg-devel] [PATCH] dump: show audio service type

Clément Bœsch u at pkh.me
Sun Mar 8 11:59:57 CET 2015


On Sun, Mar 08, 2015 at 11:56:34AM +0100, Thomas Volkert wrote:
> ---
>  libavformat/dump.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/libavformat/dump.c b/libavformat/dump.c
> index 56b37ff..9801042 100644
> --- a/libavformat/dump.c
> +++ b/libavformat/dump.c
> @@ -291,6 +291,31 @@ static void dump_stereo3d(void *ctx, AVPacketSideData *sd)
>          av_log(ctx, AV_LOG_INFO, " (inverted)");
>  }
>  
> +static void dump_audio_service_type(void *ctx, AVPacketSideData *sd)
> +{
> +    enum AVAudioServiceType *ast;
> +
> +    if (sd->size < sizeof(*ast)) {
> +        av_log(ctx, AV_LOG_INFO, "invalid data");
> +        return;
> +    }
> +
> +    ast = (enum AVAudioServiceType *)sd->data;
> +
> +    switch (*ast) {
> +    case AV_AUDIO_SERVICE_TYPE_MAIN:              av_log(ctx, AV_LOG_INFO, "Main Audio Service"); break;
> +    case AV_AUDIO_SERVICE_TYPE_EFFECTS:           av_log(ctx, AV_LOG_INFO, "Effects");            break;
> +    case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: av_log(ctx, AV_LOG_INFO, "Visually Impaired");  break;
> +    case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED:  av_log(ctx, AV_LOG_INFO, "Hearing Impaired");   break;
> +    case AV_AUDIO_SERVICE_TYPE_DIALOGUE:          av_log(ctx, AV_LOG_INFO, "Dialogue");           break;
> +    case AV_AUDIO_SERVICE_TYPE_COMMENTARY:        av_log(ctx, AV_LOG_INFO, "Commentary");         break;
> +    case AV_AUDIO_SERVICE_TYPE_EMERGENCY:         av_log(ctx, AV_LOG_INFO, "Emergency");          break;
> +    case AV_AUDIO_SERVICE_TYPE_VOICE_OVER:        av_log(ctx, AV_LOG_INFO, "Voice Over");         break;
> +    case AV_AUDIO_SERVICE_TYPE_KARAOKE:           av_log(ctx, AV_LOG_INFO, "Karaoke");            break;
> +    default:                                      av_log(ctx, AV_LOG_INFO, "unknown");            break;
> +    }
> +}
> +
>  static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
>  {
>      int i;
> @@ -328,6 +353,10 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent)
>              av_log(ctx, AV_LOG_INFO, "stereo3d: ");
>              dump_stereo3d(ctx, &sd);
>              break;
> +        case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
> +            av_log(ctx, AV_LOG_INFO, "audio svc type  : ");
> +            dump_audio_service_type(ctx, &sd);
> +            break;
>          default:
>              av_log(ctx, AV_LOG_WARNING,
>                     "unknown side data type %d (%d bytes)", sd.type, sd.size);

Factorize it with ashowinfo instead of copying the code.

You can add a public helper returning the string.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150308/e9d45d6b/attachment.asc>


More information about the ffmpeg-devel mailing list