zoukankan      html  css  js  c++  java
  • VLC播放器架构剖析

    VLC采用多线程并行解码架构,线程之间通过单独的一个线程控制所有线程的状态,解码器采用filter模式.组织方式为模块架构


    模块简述:
    libvlc                  
    是VLC的核心部分。它是一个提供接口的库,比如给VLC提供功能接口:流的接入,音频视频的输出,插件管理,线程系统。

    interface           包含与用户交互的按键和设备弹出。
    Playlist               管理播放列表的交互,如停止,播放,下一个,或者随机播放。
    Video_output    初始化video显示器,从解码器得到所有的图片和子图片。随意将他们转换为其他的格式并且播放(如YUV到RGB)
    Stream_output  类似Audio_output
    Misc                    是被其他部分使用的杂项,如线程系统,消息队列,CPU探测,对象查询系统,或者特定平台代码。
     

    运行时架构:步骤

    1.main负责初始化所有结构体,全局资源,派生出:
    --->   2.playlist,初始化和管理播放器的播放列表。
    --->   3.一个中间线程,
    --->   4.SigThread控制播放器的播放暂停等,管理最终的程序退出,在接到信号(待定)后执行libvlc_Quit()销毁所有与libvlc相关的线程和资源.。播放完毕后,音视频的输出线程先退出(可能由他们自己管理自己,完成后自动退出 )
          接着渲染(或者驱动)线程退出。2个视频解码渲染,1个音频解码渲染。
            ( 7-Vout,    9-video_output,   10-xcb.c/Thread()
                                                        11-xdg.c/Thread()
                8-Aout,    12-audio_output/alsa.c/ALSAThread()循环调用ALSAFill(p_aout))
    --->  5.RunInterface: setups necessary data and give control to the interface
         执行Run(),控制所有线程开始,其他线程得到消息之后并行运行。 Run()函数中ReadCommand( p_intf, p_buffer, &i_size );解析外部命令。这里是一个命令模式
     
     
    线程2 派生出
           线程6.input/Run(),该线程阻塞在while( !LoopInput( p_playlist ) ) vlc_cond_wait( &p_sys->signal, &p_sys->lock ); 上。并且通过 LoopRequest( p_playlist );循环解析播放列表,播放所有的资源。
    线程6派生出:
          线程7.input/DecoderThread(),这个线程被VoutCreate函数创建,使用Ffmpeg作为解码库
          线程8.input/DecoderThread(),这个线程被audio_output/alsa.c/Open()函数创建
    线程7是Video的解码线程,它派生出:
          线程9.video_output/RunThread(),这个线程作为视频解码器使用,这是它的调用栈的回溯表:
              FT_Get_Glyph () from /usr/lib/i386-linux-gnu/libfreetype.so.6
              RenderText () at freetype.c:1212
              SpuRenderText () at video_output/vout_subpictures.c:1093
              SpuRenderRegion () at video_output/vout_subpictures.c:1361
              spu_RenderSubpictures () at video_output/vout_subpictures.c:507
              vout_RenderPicture () at video_output/vout_pictures.c:383
               RunThread () at video_output/video_output.c:1148
     
           线程9派生出两个渲染器线程线程分别为:
                  ---> 线程10.video_output/xcb/Thread()
                  ---> 线程11.modules/misc/inhibit/xdg.c/Thread()
    线程8.是音频解码线程,通过aout_outputNew创建,它派生出线程12.audio_output/alsa.c/ALSAThreade()作为音频的渲染。
     
  • 相关阅读:
    Solution: Win 10 和 Ubuntu 16.04 LTS双系统, Win 10 不能从grub启动
    在Ubuntu上如何往fcitx里添加输入法
    LaTeX 笔记---Q&A
    Hong Kong Regional Online Preliminary 2016 C. Classrooms
    Codeforces 711E ZS and The Birthday Paradox
    poj 2342 anniversary party
    poj 1088 滑雪
    poj 2479 maximum sum
    poj 2481 cows
    poj 2352 stars
  • 原文地址:https://www.cnblogs.com/shakin/p/3901338.html
Copyright © 2011-2022 走看看