ijkplayer 一款国人开发的Android 和 iOS 双平台视频播放器,代码风格简洁统一,值得深入学习。简单记录下学习笔记,方便自己以后查询。
https://github.com/Bilibili/ijkplayer.git
ijkplayer基于ffplay实现,简单的描述下解码和显示流程:
(a)创建解码和显示模块
ffpipeline_create_from_ffplay
IJKFF_Pipeline* pipeline = ffpipeline_alloc(&g_pipeline_class, sizeof(IJKFF_Pipeline_Opaque));
IJKFF_Pipeline_Opaque *opaque = pipeline->opaque;
opaque->ffp = ffp;
pipeline->func_destroy = func_destroy;
pipeline->func_open_video_decoder = func_open_video_decoder;
pipeline->func_open_video_output = func_open_video_output;
(b)解码流程
func_open_video_decoder
|-- ffpipenode_create_video_decoder_from_android_mediacodec
| func_run_sync
| SDL_JNI_SetupThreadEnv attach thread to JniEnv
| enqueue_thread_func 创建线程,从队列获取数据,解码
| feed_input_buffer
| ffp_packet_queue_get_or_buffering
| SDL_AMediaCodec_dequeueInputBuffer
| SDL_AMediaCodec_getInputBuffer
| copy_size = FFMIN(input_buffer_size, d->pkt_temp.size);
| memcpy(input_buffer_ptr, d->pkt_temp.data, copy_size);
| SDL_AMediaCodec_queueInputBuffer
| drain_output_buffer
| drain_output_buffer_l
| SDL_AMediaCodec_dequeueOutputBuffer
| amc_queue_picture_buffer
|
| ffp_video_thread
| ffplay_video_thread
| get_video_frame
| queue_picture
| SDL_VoutFFmpeg_ConvertFrame
| overlay_fill
(c)显示流程
func_open_video_output
|--ffpipenode_create_video_output_from_android_mediacodec
| func_run_sync
| ffp_video_refresh_thread
| video_refresh
| frame_queue_peek(&is->pictq);
| video_display2
| video_image_display2
| SDL_VoutDisplayYUVOverlay
| vout->display_overlay(vout, overlay);
| voud_display_overlay_l
| //释放MediaCodec
| case: SDL_VoutOverlayAMediaCodec_releaseFrame
| //nativewindows显示解码视频数据
| case: SDL_Android_NativeWindow_display_l
| AndroidHalFourccDescriptor *voutDesc = native_window_get_desc(curr_format);
| voutDesc->render(&out_buffer, overlay);
| android_render_on_rgb8888
| android_render_rgb_on_rgb
| nativewindows显示
| frame_queue_next
版权声明:本文为博主原创文章,未经博主允许不得转载。