[vlc-devel] Re: Making a IRC-like Chat client plugin module
Gildas Bazin
gbazin at altern.org
Thu Apr 15 21:37:28 CEST 2004
On Tuesday 13 April 2004 18:26, Sooyoung wrote:
> Hi,
> I've been asking many questions recently. Thanks for those who've
> answered them, and those who've been patient with my emails.
>
> I've written an IRC-like chat client, and now I'd like to incorporate it
> into VLC so that a user can play AV stream while he/she chats with
> people who are watching the same stream.
>
That's a neat idea :)
> So, I added a new dialog window inside wxwindows interface plugin and
> when I launch VLC, an additional chat window pops up.
>
> Now, I need to associate this window with the chat client code I've
> written.
>
> I created a directory called "Chat" in modules/misc, copied my chat code
> in there, and modified Modules.am, and such.. I also ran bootstrap and
> configure, and it seems like my chat module is added to VLC source tree
> fine.
>
> So, here's the part that I'm stuck with.
> I understand that I need to have open(), close(), and run() functions in
> my chat code. I get that open() and close() are for initialization and
> destroy of the plugin, but how about run()?
>
The only required (common) part for all the different plugins are the open
and close functions that are set via "set_callbacks( open, close );" in the
module declaration part.
Actually close is not even required and you could very well pass NULL there
if you don't need it.
> How does run() get called and by whom?
run() is not part of the required (common) callbacks functions for a module.
Only a couple of different module types do implement a run function (eg.
the interface modules) but other types of modules specify other callbacks
(eg. video decoders have a picture_t *pf_decode_block() callback).
All this to say that what you'd better do is define a new module type for
your chat module. Something like VLC_OBJECT_CHAT in include/vlc_objects.h
(you'll also need to modify vlc_object_create() in src/misc/objects.c).
Then you'll need to define the new structure associated with this object
type (for a model, have a look at "struct intf_thread_t" in
include/vlc_interface.h).
In this new structure (chat_t), you'll be able to define a callback pointer
(pf_read) that will be filled by your chat module when its open() is called
(called from module_Need()). You can also add a pf_connect() callback if
you feel it is useful, etc...
So now, basically what you need to do from your wxWindows code is to
load/initialize your chat module with vlc_object_create() then
module_Need(). After that you'll be able to call your callbacks and finally
call module_Unneed() when you're done.
> In my chat code, I loop over
> read() to constantly keep checking if there's any data available on the
> socket. Can I put this code inside run(), and assume that my chat plugin
> will run as a separate thread?
>
If you want your chat plugin to run in a separate thread then you'll need to
create this thread and start it from the open() function of your plugin.
--
Gildas
--
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>
More information about the vlc-devel
mailing list