When developing VLC, I want to use one module to access the data of another module. For example, I want to obtain some data from the network module and process the data from other modules, at this time, the two modules need to share some variables.
Check the source code of VLC and find that VLC has variables. h and variables. c used to process variables. It provides methods to create VLC variables, set VLC variables, change and destroy VLC variables.
When we want to generate a VLC variable, we use the var_create () function;
For example, if a variable is created in the UDP module,
Vlc_value_t valtemp;
Var_create (p_access, "var_test", vlc_var_string );
Valtemp. psz_string = "hello ";
Var_set (p_access, "var_test", valtemp );
In this way, a vlc_var_string variable named "var_test" is created and its value is set to "hello ".
After the creation, the exam asked: how do we access it in other modules?
For example, access this variable in marq. C as follows:
Vlc_value_t val_test;
Vlc_list_t * p_list;
Module_t * p_module;
Access_t * p_access;
Int I;
Val_test.psz_string = "";
P_list = vlc_list_find (p_filter-> p_vlc, vlc_object_access, find_anywhere );
For (I = 0; I <p_list-> I _count; I ++)
{
P_access = (access_t *) p_list-> p_values [I]. p_object;
// P_module = (module_t *) p_list-> p_values [I]. p_object;
If (var_get (p_access, "var_test", & val_test) = vlc_success)
{
Msg_dbg (p_filter, "=======:::: val_test =: % s", val_test.psz_string );
Break;
}
// P_intf = NULL;
}
Vlc_list_release (p_list );
In this way, we can get the value of "var_test" in the marq. c module.