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);  
               }
            }
        }
     }
   }
}




评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值