FFMPEG(二)关键数据结构

来源:互联网 发布:it之家官网 编辑:程序博客网 时间:2024/05/24 03:21

总体上,整个播放流程的数据结构由三类组成,分别如下:

1)解协议

核心的数据结构是AVIOContext、URLProtocol和URLContext。对于每种输入源都会定义一个Context,其中包含这些核心数据结构。URLProtocol定义的是从协议流中获取媒体封装流的操作接口,而URLContext用于记录输入源的url、类型等信息和一个AVIOInterruptCB回调函数。URLContext的priv_data一般就是AVIOContext类型,它与AVIOInterruptCB配合完成解协议的过程变量,保证流程的衔接。比如FTP协议多媒体源定义了FTPContext就内置了FTP认证的信息和FTP控制连接和数据连接两个URLContext变量。
2)解封装
核心数据结构是AVFormatContext,其关键的关键的成员如下:
typedef struct AVFormatContext {
    struct AVInputFormat *iformat;
    struct AVOutputFormat *oformat;
    AVIOContext *pb;
    unsigned int nb_streams;
    AVStream **streams;
    char filename[1024];
    AVProgram **programs;
    AVChapter **chapters;
    AVDictionary *metadata;
    enum AVDurationEstimationMethod duration_estimation_method;
    AVFormatInternal *internal;
    AVCodec *video_codec;
    AVCodec *audio_codec;
    AVCodec *subtitle_codec;
} AVFormatContext;
3)解编码
每个AVStream存储一个视频/音频流的相关数据;每个AVStream对应一个AVCodecContext,存储该视频/音频流使用解码方式的相关数据;每个AVCodecContext中对应一个AVCodec,包含该视频/音频对应的解码器。每种解码器都对应一个AVCodec结构。AVStream内置一个AVPacket成员,AVCodecContext内置一个AVFrame,通过这两个变量推动着媒体播放数据的输出。
原创粉丝点击