ijkplayer阅读笔记02-创建音视频读取,解码,播放线程

Posted llguanli

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ijkplayer阅读笔记02-创建音视频读取,解码,播放线程相关的知识,希望对你有一定的参考价值。

本节主要介绍音视频读取和解码线程的创建及启动,代码流程例如以下:

IjkMediaPlayer_prepareAsync{
   ijkmp_prepare_async_l{
     ijkmp_change_state_l(mp, MP_STATE_ASYNC_PREPARING);
     msg_queue_start(&mp->ffplayer->msg_queue);
     SDL_CreateThreadEx(&mp->_msg_thread, mp->msg_loop, mp, "ff_msg_loop");
     ffp_prepare_async_l(mp->ffplayer, mp->data_source);
     stream_open{
        frame_queue_init(&is->pictq, &is->videoq, ffp->pictq_size, 1)
        frame_queue_init(&is->sampq, &is->audioq, SAMPLE_QUEUE_SIZE, 1)
        packet_queue_init(&is->videoq);
        packet_queue_init(&is->audioq);
        SDL_CreateThreadEx(&is->_video_refresh_tid, video_refresh_thread, ffp, "ff_vout") //视频显示线程创建
        SDL_CreateThreadEx(&is->_read_tid, read_thread, ffp, "ff_read"){ //读取线程创建
            read_thread { //读取线程
               stream_component_open(ffp, st_index[AVMEDIA_TYPE_AUDIO]);{ //音频读取和解码
                  SDL_CreateThreadEx(&is->_audio_tid, audio_thread, ffp, "ff_audio_dec");
               }
               stream_component_open(ffp, st_index[AVMEDIA_TYPE_VIDEO]);{ //视频读取和解码
                  ffp->node_vdec = ffpipeline_open_video_decoder(ffp->pipeline, ffp);
                  SDL_CreateThreadEx(&is->_video_tid, video_thread, ffp, "ff_video_dec");
               }
               for (;;) {
                  if (is->seek_req) {
                       avformat_seek_file();
                  } 
                  ret = av_read_frame(ic, pkt);
                  packet_queue_put(&is->audioq, pkt); or packet_queue_put(&is->videoq, pkt);  
               }
            }
        }
     }
   }
}




以上是关于ijkplayer阅读笔记02-创建音视频读取,解码,播放线程的主要内容,如果未能解决你的问题,请参考以下文章

iOS ijkplayer 硬解H265(hevc)4k视频问题解决

ijkplayer系列13:video_refresh_thread

iOS ijkplayer 硬解H265(hevc)4k视频问题解决

android studio引入ijkplayer二次开发

直播技术学习笔记

转:analyze ijkplayer code