VLC source Analysis (ii) playback process

Source: Internet
Author: User

VLC executes a series of processes when the file is clicked or the file to be played is entered.

First of all need to understand the video and streaming media processing and playback process, by the link in the description, video and streaming media processing, the first to solve the Protocol (HTTP,RTMP,RTSP, etc.), then the solution encapsulation (Mp4,mkv,avi, etc.), to obtain audio stream and video stream, respectively Decoded, It is then synchronized according to the timestamp. When you click Play with VLC, this is a series of processes.

When you click Play to support the RTSP protocol camera, VLC will open the thread to parse the input file or URL (src/playlist/preparser.c) and do some preparation based on the video source properties, including:

->inputsourceinit ()

->INPUT_SPLITMRL () Decomposition URL

->demux_new () creates a separator, and if it is a MP4 file, the Libmp4 library is dynamically loaded, and so on

->demux_control () calls the Control function of Libmp4, and so on

......

->initprograms () creates a decoder (decoder) based on a file or URL property, and the creation process loads the corresponding module

Then you get the data from the network or locally, and the stack is as follows. As can be seen from the stack, when the receiving thread receives the network data, if the data has packet format (such as mp4,mkv,ts, etc.), then the first is to unpack, the data after the packet block (can be understood as a struct, the structure can be used to save the compressed image data), Into the data FIFO, the decoding thread takes the block out of the data FIFO to decode it, and finally the other render modules are displayed. The difference is that the camera does not encapsulate the video format, but transmits the encoded bare data.

Similarly, the stack for playing a local MP4 file is as follows. There is no procedure to understand the protocol when playing a local file, but the libmp4 is used to split the package.

The data in the data FIFO has not been decoded, and two decoding threads (audio and video) constantly decode the data from their respective queues, and the video decoding thread stacks as follows. The decoding thread first extracts the data from the above data FIFO, decodes it using a decoder that has been created based on the data source format, and then places the decoded data in the image FIFO.

Finally, the stack of the render thread, which constantly extracts data from the image FIFO to the form.

The overall diagram of the program is as follows. When the RTSP session is established, the program creates a video decoder and audio decoder based on the SDP information obtained by the RTSP sessions. After the RTP data arrives, the Demux is placed into two FIFO respectively, and then two decoding threads take out video and audio data decoding from their FIFO respectively. The decoded audio data is played directly, and the decoded video data is placed in the picture_fifo_t, which is displayed by the rendering thread.

Report:

Configuration of the Windows version of VLC Project download: https://github.com/jiayayao/vlc_2.1.0-vs_2010, after downloading the use of vs2010 can be directly compiled to run, debugging learning is very convenient.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.