[FFmpeg-devel] [PATCH] avcodec/avformat: Added codec_name to AVCodecContext and AVCodecParameters

Hendrik Leppkes h.leppkes at gmail.com
Wed Jul 3 11:02:16 EEST 2024


On Wed, Jul 3, 2024 at 9:48 AM Bernardo Pilarz via ffmpeg-devel
<ffmpeg-devel at ffmpeg.org> wrote:
>
> Added the codec_name field, in which the unprocessed, not-interpreted codec
> name is stored.
> This is useful when codecs that are not handled by the libav
> (i.e. AV_CODEC_ID_NONE) are encountered, since the application might still
> want to handle them.
> Having this field allows the application to determine the codec type.
>
> As of this commit, the codec_name field is only filled when opening an RTSP
> stream, during the parsing of the SDP.
>
> Signed-off-by: bpilarz <bernardo.pilarz at aitek.it>
> ---
>   libavcodec/avcodec.h   | 10 ++++++++++
>   libavcodec/codec_par.c | 19 +++++++++++++++++++
>   libavcodec/codec_par.h | 10 ++++++++++
>   libavcodec/options.c   |  1 +
>   libavformat/rtsp.c     |  5 +++++
>   5 files changed, 45 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 2da63c87ea..464b4078fc 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -451,6 +451,16 @@ typedef struct AVCodecContext {
>       int log_level_offset;
>
>       enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
> +    /**
> +     * Generic codec name of the encoded data.
> +     *
> +     * Null-terminated string, can be NULL.
> +     * Contents may vary depending on the source of the data stream.
> +     * This is typically the string that's interpreted to determine
> 'codec_id'.
> +     * Must be allocated with av_malloc() or av_strdup() and will be
> freed by
> +     * avcodec_free_context().
> +     */
> +    char *codec_name;
>       const struct AVCodec  *codec;
>       enum AVCodecID     codec_id; /* see AV_CODEC_ID_xxx */
>

Adding a new field here is an ABI break, it would need to go at the
end of the struct.

In general, I feel like this might be better served to go into
metadata though, especially as very few containers have a string codec
identifier to begin with.

- Hendrik


More information about the ffmpeg-devel mailing list