libvlc_video_set_callbacks inside c++ class

This forum is about all development around libVLC.
phingage
New Cone
New Cone
Posts: 4
Joined: 25 Aug 2010 16:55

libvlc_video_set_callbacks inside c++ class

Postby phingage » 25 Aug 2010 17:01

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 }

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

Re: libvlc_video_set_callbacks inside c++ class

Postby Rémi Denis-Courmont » 27 Aug 2010 04:55

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.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

phingage
New Cone
New Cone
Posts: 4
Joined: 25 Aug 2010 16:55

Re: libvlc_video_set_callbacks inside c++ class

Postby phingage » 30 Aug 2010 10:26

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.

phingage
New Cone
New Cone
Posts: 4
Joined: 25 Aug 2010 16:55

Re: libvlc_video_set_callbacks inside c++ class

Postby phingage » 06 Sep 2010 17:10

Hi, I have correct all my problem and now all works perfectly!

thanks!

mika
New Cone
New Cone
Posts: 8
Joined: 26 Oct 2010 15:48

Re: libvlc_video_set_callbacks inside c++ class

Postby mika » 27 Oct 2010 14:18

Hi,

How did you solve it?

Regards

dragonview
New Cone
New Cone
Posts: 2
Joined: 05 Jan 2011 07:54

Re: libvlc_video_set_callbacks inside c++ class

Postby dragonview » 05 Jan 2011 08:46

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!

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: libvlc_video_set_callbacks inside c++ class

Postby Jean-Baptiste Kempf » 05 Jan 2011 17:22

You need to be more verbose, for help...
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

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

Re: libvlc_video_set_callbacks inside c++ class

Postby Rémi Denis-Courmont » 05 Jan 2011 17:51

The most typical error is that you did not call libvlc_video_set_format(_callbacks)
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

dragonview
New Cone
New Cone
Posts: 2
Joined: 05 Jan 2011 07:54

Re: libvlc_video_set_callbacks inside c++ class

Postby dragonview » 08 Jan 2011 01:36

Hi,

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

Thanks!

FherCuba
New Cone
New Cone
Posts: 3
Joined: 09 Feb 2012 15:30

Re: libvlc_video_set_callbacks inside c++ class

Postby FherCuba » 09 Feb 2012 16:00

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; }
Last edited by FherCuba on 09 Feb 2012 17:18, edited 1 time in total.

FherCuba
New Cone
New Cone
Posts: 3
Joined: 09 Feb 2012 15:30

Re: libvlc_video_set_callbacks inside c++ class

Postby FherCuba » 09 Feb 2012 16:04

Hi, I have correct all my problem and now all works perfectly!

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


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests