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_ */
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
}