stream_open主要流程

stream_open 流程主要负责播放器运行过程中相关上下文和队列的初始化,以及码流读取线程的创建。
也就是从这个函数开始,播放器就真正开始运行起来了。
本次主要还是介绍这个过程中使用到的结构体。
比较重要的后面单独解析。
stream_open源码
static VideoState *stream_open(const char *filename,
const AVInputFormat *iformat)
{
//创建VideoState结构体,这个结构体是ffplay的核心上下文,贯穿整个播放流程
VideoState *is;
is = av_mallocz(sizeof(VideoState));
if (!is)
return NULL;
//初始化is,保存filename和iformat
is->last_video_stream = is->video_stream = -1;
is->last_audio_stream = is->audio_stream = -1;
is->last_subtitle_stream = is->subtitle_stream = -1;
is->filename = av_strdup(filename);
if (!is->filename)
goto fail;
is->iformat = iformat;
is->ytop = 0;
is->xleft = 0;
/*初始化帧缓存队列,视频初始化,大小如下
VIDEO_PICTURE_QUEUE_SIZE 3
SUBPICTURE_QUEUE_SIZE 16
SAMPLE_QUEUE_SIZE 9 */
if (frame_queue_init(&is->pictq, &is->videoq, VIDEO_PICTURE_QUEUE_SIZE, 1) < 0)
goto fail;
if (frame_queue_init(&is->subpq, &is->subtitleq, SUBPICTURE_QUEUE_SIZE, 0) < 0)

本文详细介绍了FFplay中的stream_open函数,其主要负责初始化播放器上下文、队列和线程,包括VideoState结构的创建、帧缓存、包缓存队列设置,以及关键组件的初始化过程。
最低0.47元/天 解锁文章
1265

被折叠的 条评论
为什么被折叠?



