Transferring data between two plugins

This forum is about all development around libVLC.
koyaya
Blank Cone
Blank Cone
Posts: 14
Joined: 25 May 2011 11:52

Transferring data between two plugins

Postby koyaya » 10 Jul 2011 23:42

Hello

i write a control plugin and a video filter plugin that is supposed to control the video filter params (much like the rc plugin)
My question is how do i transfer data between the two

what i did was
[*]var_Create( p_intf, "rctm-bool",VLC_VAR_BOOL); in the Open function of the control plugin
[*]var_GetBool( p_intf, "rctm-bool"); / var_SetBool( p_intf, "rctm-bool", newval ); in the body of the control plugin according to the received command
[*]do i need to call explicitly var_TriggerCallback( p_intf, "rctm-bool" ); after i update the value??

then in the video filter plugin i do
[*] var_AddCallback( p_filter, "rctm-bool", SetParamsCallback, p_sys );

needless to say it doesnt work, i am missing something but dont know what..
i am getting an error of "Failed to add a callback to the non-existeng variable"

thanks for the help, referring me to a specific var in a code that is used in a similar way will be enough to help me find the way
or if there is some tutorial about using vars and callbacks - thats will be great, because i couldnt figure out what is the Inherit with vars

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Transferring data between two plugins

Postby Rémi Denis-Courmont » 11 Jul 2011 09:15

Variables are tied to objects. You need to use the same object on all sides.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

koyaya
Blank Cone
Blank Cone
Posts: 14
Joined: 25 May 2011 11:52

Re: Transferring data between two plugins

Postby koyaya » 11 Jul 2011 16:55

and how do i create an object? or transfer a reference to it once i create it?

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Transferring data between two plugins

Postby Rémi Denis-Courmont » 11 Jul 2011 17:08

1/ vlc_object_create() 2/ no generic solution
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

koyaya
Blank Cone
Blank Cone
Posts: 14
Joined: 25 May 2011 11:52

Re: Transferring data between two plugins

Postby koyaya » 11 Jul 2011 18:01

i still dont understand...

i see other plugins creating vars using var_CreateGetBoolCommand (for example)
they never call the vlc_object_create (i guess its created outside of the plugin and passed as a parameter)

is there some developers tutorial explaining how to do it?
what was missing in what i did?

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Transferring data between two plugins

Postby Rémi Denis-Courmont » 11 Jul 2011 18:44

Plugins usually use their own object, passed through the activation callback. They rarely need to create an object directly.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

vladymary
New Cone
New Cone
Posts: 2
Joined: 17 Nov 2021 23:23

Re: Transferring data between two plugins

Postby vladymary » 17 Nov 2021 23:36

Hi,
I have a similar use case where I want to share information between two modules. More precisely it is about a chained demuxer that must set variables, which are then intercepted by the parent demuxer. The VLC Hacker Guide/Variables clearly says: "VLC media player has a powerful "object variable" infrastructure, that can be used to pass information between modules." According to the answers in this thread, I have to bind my variable to an object. Fine! But how I then pass this object across modules? This is not mentioned in the Hacker Guide.

Thanks in advance!

vladymary
New Cone
New Cone
Posts: 2
Joined: 17 Nov 2021 23:23

Re: Transferring data between two plugins

Postby vladymary » 18 Nov 2021 10:15

While studying the code of some existing VLC modules, I've finally found a working solution. For all, who will be in the same situation:
As mentioned by Rémi Denis-Courmont, variables must be tied to objects. In order to make your variable "global" (visible across modules), you must tied it to a global object. Apparently the most global object is libvlc. For my use case I have created a new variable and bound it to the global object like that

Code: Select all

var_Create(p_demux->obj.libvlc, "my-boolean-var", VLC_VAR_BOOL);
Then I registered the callback

Code: Select all

var_AddCallback(p_demux->obj.libvlc, "my-boolean-var", varUpdateCb, NULL);
And whenever I'm changing this variable in my chained demuxer with

Code: Select all

var_SetBool( p_demux->obj.libvlc, "my-boolean-var", true );
, my callback is being called.

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: Transferring data between two plugins

Postby unidan » 12 Dec 2021 21:41

Hi, if you want inter-module communication, you don’t need vlc variables. VLC variables are used for user configuration and CLI.

If the modules are living in a single plugin, just use a static storage protected by some lock, and custom protocol between the two module implementation. Said otherwise, interpret “module” as “capability” instead of “object”, the real “module” being your underlying implementation.

If your modules are splitted into different plugins, you’ll need to share a common protocol between them, and a new capability can do the trick, to allow you to get back to the previous case (a static storage for your custom capability, that the two plugins will somehow use).

If you need user configuration, the «interface » plugin can register the variables to configure from them, and then use the other method to dynamically update the other modules.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 12 guests