Copyright information:
This article is from the Internet and is reposted here for streaming media fans to learn and use. Please respect the author's Labor achievements. Unauthorized commercial use of the original author's articles is an infringement. The consequences shall be borne by the user and I shall not assume any legal liability.
Analysis of Network Data Stream receiving and processing: the main thread loop thread in charge of processing the network packets and demultiplexing in the input. C (src/input) File
Network Data Stream Receiving and Processing Analysis
1. Main thread loop in the input. C (src/input) File
Thread in charge of processing the network packets and demultiplexing
Runthread (input_thread_t * p_input)
{
Initthread (p_input );
.............................................................
Input_selectes (p_input, p_input-> stream. p_newly_selected_es );
.............................................................
/* Read and demultiplex some data .*/
I _count = p_input-> pf_demux (p_input );
}
2. In the following functions:
- Separates access, Demux, and name strings;
- Use the module_need function to find the acess pointer Module Based on the isolated access string;
- Find the Demux pointer module by using the module_need function based on the separated Demux string;
Static int initthread (input_thread_t * p_input)
{
Msg_dbg (p_input, "Access '% s', Demux' % s', name '% S '",
P_input-> psz_access, p_input-> psz_demux, p_input-> psz_name );
/* Find and open appropriate access module */
P_input-> p_access = module_need (p_input, "access ",
P_input-> psz_access, vlc_true );
.............................................................
While (! Input_fillbuffer (p_input ))
.............................................................
/* Find and open appropriate Demux module */
P_input-> p_demux =
Module_need (p_input, "Demux ",
(P_input-> psz_demux & * p_input-> psz_demux )?
P_input-> psz_demux: "$ Demux ",
(P_input-> psz_demux & * p_input-> psz_demux )?
Vlc_true: vlc_false );
.............................................................
}
3. In the PS. C (module/Demux/MPEG) File
A. Activate the activate function through macro assignment of message ing;
B. Use the activate function to assign p_input-> pf_demux = Demux;
C. Use the module_need (p_input, "MPEG-System", null, 0) function to activate p_input-> p_demux_data-> MPEG. pf_read_ps (p_input, & p_data) function (pf_read_ps );
D. Activate it in the initthread function;
Static int activate (vlc_object_t * p_this)
{
/* Set the Demux function */
P_input-> pf_demux = Demux;
P_input-> p_private = (void *) & p_demux-> MPEG;
P_demux-> p_module = module_need (p_input, "MPEG-System", null, 0 );
}
4. In the system. C (module/Demux/MPEG) File
Value assignment decoding module mpeg_demux_t member functions;
Static int activate (vlc_object_t * p_this)
{
Static mpeg_demux_t mpeg_demux =
{Null, readps, parseps, demuxps, readts, demuxts };
Mpeg_demux.cur_scr_time =-1;
Memcpy (p_this-> p_private, & mpeg_demux, sizeof (mpeg_demux ));
Return vlc_success;
}
And declare the function static ssize_t readps (input_thread_t * p_input, data_packet_t ** pp_data );
5. In the PS. C (module/Demux/MPEG) File
Demux (input_thread_t * p_input)
{
I _result = p_input-> p_demux_data-> MPEG. pf_read_ps (p_input, & p_data );
P_input-> p_demux_data-> MPEG. pf_demux_ps (p_input, p_data );
}
Read and separate data;
6. In the system. C (module/Demux/MPEG) File
The following figure shows the data trend.
Readps-> peek-> input_peek (src/input/input_ext-plugins.c)-> input_fillbuffert through
I _ret = p_input-> pf_read (p_input,
(Byte_t *) p_buf + sizeof (data_buffer_t) + I _remains,
P_input-> I _bufsize );
If the pf_read function Member of the input_thread_t structure is the rtpchoose function of UDP. C (modules/access ),
Enable access (UDP module) through module_need;
Activate the network read data module rtpchoose (modules/access/udp. c)-> Read-> net_read (src/MISC/net. C );
7. In the input_programs.c (src/input) File
Run the decoder to decode the es stream
Int input_selectes (input_thread_t * p_input, es_descriptor_t * p_es)
{
P_es-> p_dec = input_rundecoder (p_input, p_es );
}
Input_selectes (src/input/input_programs.c)-> input_rundecoder (src/input/input_dec.c)-> decoderthread-> decoderdecode-> vout_displaypicture