Page 1 of 1

libvlc_video_set_callbacks inside c++ class

Posted: 25 Aug 2010 17:01
by phingage
Hi, i'm trying to use new libvlc_video_set_callbacks function inside a c++ project but unsuccessfull!

I have create this simple class to test new function, but in runtime i get a segementation foult, can you tell me where i'm wrong?


Thanks!

vlcTestClass.h

Code: Select all

#include <vector> #include <cstdio> #include <cstdlib> #include <ctime> typedef unsigned char uchar; struct ctx { uint16_t* pixel; //SDL_mutex *mutex; }; class vlcTestClass { public: vlcTestClass(); virtual ~vlcTestClass(); static void display(void *data, void *id); static void unlock(void *data, void *id, void *const *p_pixels); static void *lock(void *data, void **p_pixels); void test(); libvlc_instance_t *libvlc; libvlc_media_t *m; libvlc_media_player_t *mp; struct ctx ctx; }; #endif /* VLCTESTCLASS_H_ */
vlcTestClass.cpp

Code: Select all

#include "vlcTestClass.h" #define WIDTH 1024 #define HEIGHT 768 #define VIDEOWIDTH 720 #define VIDEOHEIGHT 576 vlcTestClass::vlcTestClass() { // TODO Auto-generated constructor stub std::cout << "!"; char const *vlc_argv[] = { "-vvv", "--no-audio", /* skip any audio track */ "--no-xlib", /* tell VLC to not use Xlib */ }; int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); libvlc = libvlc_new(vlc_argc, vlc_argv); m = libvlc_media_new_path(libvlc, "/home/armanini/Videos/stazione1.avi"); mp = libvlc_media_player_new_from_media(m); libvlc_media_release(m); libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx); libvlc_video_set_format(mp, "RV16", VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2); libvlc_media_player_play(mp); std::cout << "!"; } void vlcTestClass::display(void *data, void *id){ (void) data; assert(id == NULL); } void vlcTestClass::unlock(void *data, void *id, void *const *p_pixels){ struct ctx *ctx = (struct ctx*)data; /* VLC just rendered the video, but we can also render stuff */ uint16_t *pixels = (uint16_t*)*p_pixels; assert(id == NULL); } void *vlcTestClass::lock(void *data, void **p_pixels){ struct ctx *ctx = (struct ctx*)data; *p_pixels = ctx->pixel; return NULL; } void vlcTestClass::test() { std::cout << "test"; } vlcTestClass::~vlcTestClass() { // TODO Auto-generated destructor stub }

Re: libvlc_video_set_callbacks inside c++ class

Posted: 27 Aug 2010 04:55
by Rémi Denis-Courmont
I think it should be quite obvious from common sense, the sample code and the documentation, but you need to provide the pixel planes to VLC through the lock function, not the other way around.

Re: libvlc_video_set_callbacks inside c++ class

Posted: 30 Aug 2010 10:26
by phingage
Thanks a lot for replay, but i'm very noob and i can't appreciate at all your tips, please can you give me a short example?

thanks again and regards!
I think it should be quite obvious from common sense, the sample code and the documentation, but you need to provide the pixel planes to VLC through the lock function, not the other way around.

Re: libvlc_video_set_callbacks inside c++ class

Posted: 06 Sep 2010 17:10
by phingage
Hi, I have correct all my problem and now all works perfectly!

thanks!

Re: libvlc_video_set_callbacks inside c++ class

Posted: 27 Oct 2010 14:18
by mika
Hi,

How did you solve it?

Regards

Re: libvlc_video_set_callbacks inside c++ class

Posted: 05 Jan 2011 08:46
by dragonview
Hi,
I'm trying to use new libvlc_video_set_callbacks function inside a c++ project,
I set callbacks, but it doesn't callback data, can you tell me where i'm wrong?

thanks!

Re: libvlc_video_set_callbacks inside c++ class

Posted: 05 Jan 2011 17:22
by Jean-Baptiste Kempf
You need to be more verbose, for help...

Re: libvlc_video_set_callbacks inside c++ class

Posted: 05 Jan 2011 17:51
by Rémi Denis-Courmont
The most typical error is that you did not call libvlc_video_set_format(_callbacks)

Re: libvlc_video_set_callbacks inside c++ class

Posted: 08 Jan 2011 01:36
by dragonview
Hi,

I have create the vlcTestClass class to test libvlc_video_set_callbacks function, but in runtime not callback functions(display,lock,ulock).

Thanks!

Re: libvlc_video_set_callbacks inside c++ class

Posted: 09 Feb 2012 16:00
by FherCuba
Hi:
I am using libvlc in a c++ proyect. I trying to get a frame by frame video using libvlc_video_set_callbacks function.I use some examples posted in this site. I call libvlc_video_set_format(_callbacks) too but in runtime, after execute lock function, the program send an access violation inside libswscale_plugin.dll.

Thanks!

Code: Select all

static void *lock(void *opaque, void **plane) { struct PixelData *data = (struct PixelData*)opaque; *plane = data->pixel; return NULL; }

Re: libvlc_video_set_callbacks inside c++ class

Posted: 09 Feb 2012 16:04
by FherCuba
Hi, I have correct all my problem and now all works perfectly!

thanks!
Hi:
Could you explain how you did it?
Thanks