VLC Learning Program (5) - VLC Program Macro and Thread Analysis

xiaoxiao2021-03-06  38

The first part variable and macro definition 1. Message mapping macro VLC_Module_Begin (); ........................vlc_module_end (); 2. Structure contains function struct input_thread_t {vlc_common_members

/ * Thread Properties * / VLC_BOOL_T B_EOF; VLC_BOOL_T B_OUT_PACE_CONTROL;

/ * Access module * / module_t * p_access; ssize_t (* pf_read) (input_thread_t *, byte_t *, size_t); int (* pf_set_program) (input_thread_t *, pgrm_descriptor_t *); int (* pf_set_area) (input_thread_t *, input_area_t *) ; Void (* pf_seek) (INPUT_THREAD_T *, OFF_T);} 3. Macro and newline Magical #define VLC_COMMON_MEMBERS // ** / name VLC_COMMON_MEMBERS / * these members are common for all vlc objects / * / // ** @ {* / / int i_object_id; / int i_object_type; / char * psz_object_type; / Char * psz_object_name; / / ** JUST A Reminder SO That People Don't Cast Garbage * / / / / INT BE_SURE_TO_ADD_VLC_COMMON_MEMBERS_TO_STRUCT; // ** @} * /

#DEfine VLC_Object (x) / ((VLC_Object_t *) (x)) 0 * (x) -> be_su_to_add_vlc_common_members_to_struct

Struct VLC_Object_t {VLC_COMMON_MEMBERS}; // Defines a structure to use the macro defined public member 4. Custom Export function #ifndef __PLUGIN __ # define VLC_EXPORT (type, name, args) type name args # else # define VLC_EXPORT (type, name, args) struct _u_n_u_s_e_d_ extern module_symbols_t * p_symbols; # endif5. Define the callback function

TYPEDEF INT (* VLC_CALLBACK_T) (VLC_Object_t *, / * variable's object * / char const *, / * variable name * / vlc_value_t, / * Old value * / vlc_value_t, / * new value * /

void *); / * Callback data * /

6. Function as a definition of parameters INT FUN (INT N, INT, INT, INT), CHAR * PSTR) {INT J = 10; PF (n, j);}

7. The statement of the callback function must be declared as global, or static

INT VLC_CALLBACK_T (int, int) {. . . . . . . . . . . } 8. Using Fun (0, VLC_CALLBACK_T, "TEST");

9. Function expression #define input_buffersinit (a) __INPUT_BUFFERSINIT (VLC_Object (a)) void * __INPUT_BUFFERSINIT (VLC_Object_t *);

#define module_need (A, B, C, D) __Module_Need (VLC_Object (a), B, C, D) VLC_EXPORT (MODULE_T *, __MODULE_NEED, (VLC_Object_t *, const char *, const char *, vlc_bool_t));

10. Define function / * Dynamic Array Handling: Realloc Array, Move Data, Insert_ELEM (P_ar, i_oldsize, i_pos, elem) / do / {/ if (i_oldsize) / {/ (p_ar) = Realloc (p_ar, ((i_oldsize) 1) * SizeOf (* (p_ar))); /} / else / {/ (p_ar) = malloc ((i_oldsize) 1) * SizeOf (* (p_ar)); /} / IF (i_oldsize) - (i_pos)) / {/ Memmove 1, / (p_ar) (i_pos), / (i_oldsize) - (i_pos)) * sizeof (* (p_ar)); /} / (p_ar) [i_pos] = elem; / (i_oldsize) ; /} / while (0)

Application is: INSERT_ELEM (p_new-> p_libvlc-> pp_objects, p_new-> p_libvlc-> i_Objects, p_new-> p_libvlc-> i_objects, p_new); 11. Changing the way of passing the address value stream_t * input_StreamNew (input_thread_t * p_input) {stream_t * s = vlc_object_create (p_input, sizeof (stream_t)); input_stream_sys_t * p_sys; if (s) {s-> p_sys = malloc (sizeof (input_stream_sys_t) ); P_sys = (input_stream_sys_t *) S-> p_sys; p_sys-> p_input = p_input;} returnits S; // Note: S-> p_sys change}

The second part of the program framework implementation 1. Playlist file src / playlist / playlist.c threads playlist_t * __playlist_Create (vlc_object_t * p_parent) function to create a thread, the thread function static void RunThread (playlist_t * p_playlist) threads ideas Analysis: RunThread execution cycles in which, if there is no task If the appropriate delay is applied, if you receive the condition of p_playlist-> i_status! = Playlist_stopped, call the PlayItem (p_playlist) function, create the input thread from the newly created in the PlayItem (P_PlayList).

A variety of commands from the GUI interface are received via Void Playlist_Command (PLAYLIST_T * P_PLAYLIST, INT i_ARG), and then sets the status of p_playlist-> i_status, which changes the execution of the playlist file main loop thread by this state.

2. Enter the file SRC / INPUT / INPUT.C input thread input_thread_t * __ input_CreateThread (vlc_object_t * p_parent, input_item_t * p_item) function to create a thread, the thread function int RunThread (input_thread_t * p_input) thread thinking analysis is static: members from input_thread_t structure Analysis is to receive the file stream or the network stream. If it is a file stream, call the File Module's read function (PF_READ) and open function (-). If it is Network Module open function and read function (PF_READ). Receive data and call DEMUX or DECODE ETC processing in the RUNTHREAD thread function. Once a new input is generated, the input thread will be ended first in the playlist thread, and then create a new input thread from the newly created.

3. Video output file src / video_output / video_output.c threads vout_thread_t * __vout_Create (vlc_object_t * p_parent, unsigned int i_width, unsigned int i_height, vlc_fourcc_t i_chroma, unsigned int i_aspect) function to create a thread, the thread function static void RunThread (vout_thread_t * P_VOUT) Thread Idea: Perform a loop in Runthread, the task is to display the video. 4. The thread created in the GUI thread static void run in modules / gui / wxwindows / wxwindows.cpp, the thread function is static void init (intf_thread_t * p_intf)

Thread Idea: Perform a loop in Init (intf_thread_t * p_intf), create a new GUI instance. Instance- "CREATEDIALOGSPROVIDER -" DialogsProvider is the running dialog. The step of receiving the network file onOpennet (WxCommandEvent & Event) Opens the network file. Open the OpenDialog dialog box, click OK to call the OpenDialog :: Onok (WxCommandEvent & WXUSED (Event)) function, call the PlayList_Command function to change the status of the playlist thread.

Active threads Analysis: wxwindow.cpp the message map set_callbacks (OpenDialogs, Close); the set module_t-> pf_activate = OpenDialogs function, __module_Need in the module.c (vlc_object_t * p_this, const char * psz_capability, const char * psz_name, the VLC_BOOL_T B_STRICT function is used in the PF_ACTIVATE to activate the GUI dialog; in the static void runthread (Vout_thread_t * p_vout) thread in Video_Output.c, the PF_ACTIVATE activation GUI dialog is also used;

5. All start message map macro module essence vlc_module_begin (); set_callbacks (NetOpen, NULL); vlc_module_end (); then setting member function module structure is: #define set_callbacks (activate, deactivate) / p_submodule-> pf_activate = activate; / p_submodule -> Pf_deactivate = deActivate

转载请注明原文地址:https://www.9cbs.com/read-63467.html

New Post(0)