[vlc-devel] Re: How to embed VLC in my C application
Herman Schultz
herman.schultz at gmail.com
Wed Jun 13 07:35:31 CEST 2007
On 6/12/07, Tony Anecito <adanecito at yahoo.com> wrote:
>
> Hi Sherman,
>
> Yes I can do that. There is a set of java classes (JVLC.class, input.class,
> vlm.class, video.class, playlist.class) that I use. The main thing as was
> mentioned by Remi was not to try to reuse the same instance. What I do is
> the JVLC.class makes a call the the libvlc.dll through a wrapper class
> jvlc.dll to create an instance. when creating an instance the libvlc.dllcan be passed a window handle to an existing window which is created for a
> canvas class. In return a instance handle (integer) is passed back to the
> jvlc.class for use in makeing calls by video, input, playlist audio, vlm
> classes.
>
> You can look at the class source to see how they in turn make calls to the
> dll(s) which will help. But the main thing is to never ever try to reuse the
> same instance for another video when you want two videos running at the same
> time. Also I discovered for java at least there are times when the window
> tied to a canvas class get destroyed by the java runtime engine (jre) such
> as repainting when moving a window to the top of the zorder. When that
> happens you need to destroy the instance of vlc tied to the java
> canvas otherwise you get segment faults. The same thing also happens where
> the window gets destroyed when a window get turned into an icon.
> This required destroying of a window may even effect a C application
> because I discovered there was a windows call used by the jre to restack the
> windows during a zorder call which may also happen in C but the instance was
> destroyed by the jre. If I overode the method to destroy the window handle
> vlc crashed.
>
> There might be other things I ran into but the very interesting thing I
> discovered is you need to specify when doing an install the path to the vlc
> dlls because if you do not do that vlc may not find them in the default
> directory structure it hopes to find. There is an option to do this which I
> have to use since the java deployment method (java web start) I use puts the
> jars containing the main method and the dlls are in a jar that can end up in
> any folder in the cache folder structure but may not end up in the same
> folder together. So I had to write code to get the dlls out of the jar and
> put them into a folder where I can pass to the vlc instance the folder
> location.
>
> I have been able to get the reading of video files on the disk to work but
> the streaming is intermittantly working on different PC's running Windows
> XP. I am hoping it is a dll issue or a config issue where the options need
> to be just so in order for me to use the dlls. The vlc.exe sets certain
> options by default and sometimes it is really important to understand them.
>
> A lot of effort but I believe I am the only one who has gotten this far
> with the java bindings. I still need to work with the registration for event
> notification which is very new but resolves things like notification of a
> video finishing without the dreaded polling in a separate thread.
>
> I know this may not be the answer you are looking for but maybe it gives
> you a starting point at least.
>
> Regards,
> Tony Anecito
> Founder,
> MyUniPortal
> http://www.myuniportal.com
>
Thanks.
I am trying to call libvlc_new() using this code:
libvlc_exception_t exception;
libvlc_exception_init( &exception );
libvlc_instance_t *p_i1 = libvlc_new( i_argc , ppsz_argv2, &exception );
if (p_i1 == NULL) {
printf ("Instance creation failed" ); // I don't see this gets print,
so I assume it works.
} else {
}
This is my argument to libvlc_new:
char *ppsz_argv2[] = { "./vlc" ,
"-I"
"dummy",
"test.flv",
"--sout",
"#transcode{vcodec=mp4v,vb=400}:rtp{dst= 135.23.52.1,port-video=3342,
,sdp=file:///usr/local/movies/test2.sdp}" }
I don't see the file 'test2.sdp' get generated but the old way works.
The above argument works for my 'old' way, i.e. this:
int i_ret = VLC_Create();
i_ret = VLC_Init( 0, i_argc, ppsz_argv2 );
i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
Thank you for any help.
*Herman Schultz <herman.schultz at gmail.com>* wrote:
>
> Can you please share how you run vlc using the vlc libraries? I can't see
> to get that to work.
>
> On 6/12/07, Tony Anecito < adanecito at yahoo.com> wrote:
> >
> > Actually I am trying to get multiple child windows running videos using
> > the vlc libraries right now. I am using the latest builds and the jvlc
> > bindings. I am trying to work through understanding how to get the right
> > options setup like for streaming (I left and email for the vlc team today)
> > but otherwise it appears to work fine but I need to get streaming working so
> > I and my testers can get back to testing vlc.
> >
> > Regards,
> > -Tony Anecito
> > Founder,
> > MyUniportal
> > http://www.myuniportal.com
> >
> >
> > *Rémi Denis-Courmont <rem at videolan.org >* wrote:
> >
> > Hello,
> >
> > Le mardi 12 juin 2007, Herman Schultz a écrit :
> > > I am trying to embed&invoke VLC in my c application.
> > >
> > > I invoke VLC like this:
> > > // i_argc is an int
> > > // ppsz_argv2 is char* ppsz_argv2[]
> > >
> > > int i_ret = VLC_Create();
> > > i_ret = VLC_Init( 0, i_argc, ppsz_argv2 );
> > > i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
> > >
> > > It works the first time when I do this.
> > > But when I do that the same i_argc, ppsz_arg2[] the second time, I
> > > get an segmentation inside VLC_Init().
> > >
> > > Can you please tell me why is there? Or if that is the right way to
> > > embed/invoke VLC in my own application.
> >
> > There are two reasons why they crashes:
> > The bad reason is that VLC 0.8.6 is not quite multi-instance-safe yet;
> > we are trying to solve this in upcoming version 0.9.0 but we would need
> > people to test this seriously.
> >
> > The good reason is that the "VLC" API (as used in src/vlc.c) uses main
> > VLC object number "0". Given object numbers are shared across a
> > process, there cannot be two VLC instance using object number 0. In
> > other word, without some changes, the "VLC" API cannot be used to spawn
> > more than one instance at a time.
> >
> > *However*, as Pierre pointed out, the newer LibVLC media control API
> > should work fine.
> >
> > --
> > Rémi Denis-Courmont
> > http://www.remlab.net/
> >
> >
> > ------------------------------
> > Luggage? GPS? Comic books?
> > Check out fitting gifts for grads
> > <http://us.rd.yahoo.com/evt=48249/*http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz>at
> > Yahoo! Search.
> >
>
>
> ------------------------------
> Yahoo! oneSearch: Finally, mobile search that gives answers<http://us.rd.yahoo.com/evt=48252/*http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC>,
> not web links.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070613/ed3384b2/attachment.html>
More information about the vlc-devel
mailing list