[FFmpeg-devel] [PATCH 3/3] lavd/alsa_audio_enc: implementation of query_codec

Nicolas George george at nsup.org
Sat Nov 2 11:54:09 CET 2013


Le primidi 11 brumaire, an CCXXII, Lukasz Marek a écrit :
> Implementation of query_codec callback that allow to
> check if specific codec is supported by device.
> 
> Signed-off-by: Lukasz Marek <lukasz.m.luki at gmail.com>
> ---
>  libavdevice/alsa-audio-enc.c |   25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c
> index 0f4e4a2..d3447a3 100644
> --- a/libavdevice/alsa-audio-enc.c
> +++ b/libavdevice/alsa-audio-enc.c
> @@ -115,6 +115,30 @@ audio_get_output_timestamp(AVFormatContext *s1, int stream,
>      *dts = s1->streams[0]->cur_dts - delay;
>  }
>  
> +static int audio_query_codec(enum AVCodecID id, int std_compliance)
> +{
> +    return id == AV_CODEC_ID_PCM_F64LE ||
> +           id == AV_CODEC_ID_PCM_F64BE ||
> +           id == AV_CODEC_ID_PCM_F32LE ||
> +           id == AV_CODEC_ID_PCM_F32BE ||
> +           id == AV_CODEC_ID_PCM_S32LE ||
> +           id == AV_CODEC_ID_PCM_S32BE ||
> +           id == AV_CODEC_ID_PCM_U32LE ||
> +           id == AV_CODEC_ID_PCM_U32BE ||
> +           id == AV_CODEC_ID_PCM_S24LE ||
> +           id == AV_CODEC_ID_PCM_S24BE ||
> +           id == AV_CODEC_ID_PCM_U24LE ||
> +           id == AV_CODEC_ID_PCM_U24BE ||
> +           id == AV_CODEC_ID_PCM_S16LE ||
> +           id == AV_CODEC_ID_PCM_S16BE ||
> +           id == AV_CODEC_ID_PCM_U16LE ||
> +           id == AV_CODEC_ID_PCM_U16BE ||
> +           id == AV_CODEC_ID_PCM_S8    ||
> +           id == AV_CODEC_ID_PCM_U8    ||
> +           id == AV_CODEC_ID_PCM_MULAW ||
> +           id == AV_CODEC_ID_PCM_ALAW ? 1: 0;
> +}
> +

This list looks like a copy of the one in the codec_id_to_pcm_format()
function. Rather than duplicating it, checking that codec_id_to_pcm_format()
returns something useful or SND_PCM_FORMAT_UNKNOWN would probably be
simpler.

>  AVOutputFormat ff_alsa_muxer = {
>      .name           = "alsa",
>      .long_name      = NULL_IF_CONFIG_SMALL("ALSA audio output"),
> @@ -125,5 +149,6 @@ AVOutputFormat ff_alsa_muxer = {
>      .write_packet   = audio_write_packet,
>      .write_trailer  = ff_alsa_close,
>      .get_output_timestamp = audio_get_output_timestamp,
> +    .query_codec    = audio_query_codec,
>      .flags          = AVFMT_NOFILE,
>  };

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131102/792c60ef/attachment.asc>


More information about the ffmpeg-devel mailing list