About libvlc...

*nix specific usage questions
Kimishima
New Cone
New Cone
Posts: 3
Joined: 06 Aug 2008 10:04

About libvlc...

Postby Kimishima » 06 Aug 2008 10:15

Hello there,

I'm trying to use libvlc to play video in a program i'm writing in C++. I use version 0.8.6h. I tried to have this sample working : http://wiki.videolan.org/LibVLC_SampleCode_SDL

But it doesn't compile, for the reason that it doesn't find the type libvlc_media_t (and some other things). This sample looks obsolete, as I didn't find any occurrence of libvlc_meedia_t type in the source of vlc.
So I would like to know, if anyone is used with the latest libvlc, what changes I should do to this sample to have it compile ? The current document is still incomplete so it's a bit hard to understand how it works.

Here's gcc log :
gcc vlctest.c `sdl-config --cflags --libs` -I/usr/include -lvlc
vlctest.c: In function 'main':
vlctest.c:69: error: 'libvlc_media_t' undeclared (first use in this function)
vlctest.c:69: error: (Each undeclared identifier is reported only once
vlctest.c:69: error: for each function it appears in.)
vlctest.c:69: error: 'm' undeclared (first use in this function)
vlctest.c:70: error: 'libvlc_media_player_t' undeclared (first use in this function)
vlctest.c:70: error: 'mp' undeclared (first use in this function)
vlctest.c:75: error: 'VLC_TREE' undeclared (first use in this function)
vlctest.c:75: error: expected '}' before string constant
vlctest.c:137: warning: passing argument 2 of 'libvlc_new' from incompatible pointer type
Please note that I added #include <vlc/libvlc.h> who was already missing.

Thanks

Kimishima
New Cone
New Cone
Posts: 3
Joined: 06 Aug 2008 10:04

Re: About libvlc...

Postby Kimishima » 07 Aug 2008 14:24

I find out that it comes from the fact that I don't have the file control/libvlc_internal.h, where is defined libvlc_media_t. I use Debian and got libvlc0-dev and vlc-nox from aptitude. This include isn't provided in these packages. I downloaded the whole tar (corresponding to version 0.8.6h) in order to have the sources, and this file doesn't appear to be there neither...

Does anyone know why ? And how could I got this fixed in the proper way ?

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: About libvlc...

Postby Jean-Baptiste Kempf » 08 Aug 2008 03:03

Are you sure this code is not for 0.9.0 ?
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.

Kimishima
New Cone
New Cone
Posts: 3
Joined: 06 Aug 2008 10:04

Re: About libvlc...

Postby Kimishima » 08 Aug 2008 11:07

Yes you're right, it looks to be... I got the 0.9.0 sources and this files is in it.

Can I find a 0.9.0 version, packaged for Debian ? There's almost nothing on my Linux target (it's kinda embedded), I can't build the whole source. I'd need only libvlc-dev and vlc-nox. Apt-get doesn't find any package for version 0.9.0... I'd need the binaries of vlc, built in the same way that in the package vlc-nox.

coder_gate
Blank Cone
Blank Cone
Posts: 24
Joined: 12 Mar 2010 07:34

Re: About libvlc...

Postby coder_gate » 26 Apr 2010 11:03

Are you sure this code is not for 0.9.0 ?


when i use VLC 0.9.0 lib,it error
i:\ProgramFiles\QtCreator4_62\qt\lib/libqtmaind.a(qtmain_win.o): In function `WinMain@16':
C:\qt-greenhouse\Trolltech\Code_less_create_more\Trolltech\Code_less_create_more\Troll\4.6\qt\src\winmain/qtmain_win.cpp:131: undefined reference to `qMain(int, char**)'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\QTMedia.exe] Error 1
mingw32-make: *** [debug] Error 2

Image


Code: Select all

/* libSDL and libVLC sample code * Copyright © 2008 Sam Hocevar <sam@zoy.org> * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */ #include <stdio.h> #include <stdint.h> #include <math.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_mutex.h> #include <vlc/vlc.h> #define WIDTH 640 #define HEIGHT 480 #define VIDEOWIDTH 320 #define VIDEOHEIGHT 240 struct ctx { SDL_Surface *surf; SDL_mutex *mutex; }; static void myCatch (libvlc_exception_t *ex) { if(libvlc_exception_raised(ex)) { fprintf(stderr, "exception: %s\n", libvlc_exception_get_message(ex)); exit(1); } libvlc_exception_clear(ex); } #ifdef VLC09X static void * lock(struct ctx *ctx) { SDL_LockMutex(ctx->mutex); SDL_LockSurface(ctx->surf); return ctx->surf->pixels; } #else static void lock(struct ctx *ctx, void **pp_ret) { SDL_LockMutex(ctx->mutex); SDL_LockSurface(ctx->surf); *pp_ret = ctx->surf->pixels; } #endif static void unlock(struct ctx *ctx) { /* VLC just rendered the video, but we can also render stuff */ uint16_t *pixels = (uint16_t *)ctx->surf->pixels; int x, y; for(y = 10; y < 40; y++) for(x = 10; x < 40; x++) if(x < 13 || y < 13 || x > 36 || y > 36) pixels[y * VIDEOWIDTH + x] = 0xffff; else pixels[y * VIDEOWIDTH + x] = 0x0; SDL_UnlockSurface(ctx->surf); SDL_UnlockMutex(ctx->mutex); } int main(int argc, char *argv[]) { char clock[64], cunlock[64], cdata[64]; char width[32], height[32], pitch[32]; libvlc_exception_t ex; libvlc_instance_t *libvlc; libvlc_media_t *m; libvlc_media_player_t *mp; char const *vlc_argv[] = { "-q", //"-vvvvv", "--plugin-path", VLC_TREE, "/modules", "--ignore-config", /* Don't use VLC's config files */ "--noaudio", "--vout", "vmem", "--vmem-width", width, "--vmem-height", height, "--vmem-pitch", pitch, "--vmem-chroma", "RV16", "--vmem-lock", clock, "--vmem-unlock", cunlock, "--vmem-data", cdata, }; int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); SDL_Surface *screen, *empty; SDL_Event event; SDL_Rect rect; int done = 0, action = 0, pause = 0, n = 0; struct ctx ctx; /* * Initialise libSDL */ if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1) { printf("cannot initialize SDL\n"); return EXIT_FAILURE; } empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT, 32, 0, 0, 0, 0); ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT, 16, 0x001f, 0x07e0, 0xf800, 0); ctx.mutex = SDL_CreateMutex(); int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF; screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options); if(!screen) { printf("cannot set video mode\n"); return EXIT_FAILURE; } /* * Initialise libVLC */ sprintf(clock, "%lld", (long long int)(intptr_t)lock); sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock); sprintf(cdata, "%lld", (long long int)(intptr_t)&ctx); sprintf(width, "%i", VIDEOWIDTH); sprintf(height, "%i", VIDEOHEIGHT); sprintf(pitch, "%i", VIDEOWIDTH * 2); if(argc < 2) { printf("too few arguments (MRL needed)\n"); return EXIT_FAILURE; } libvlc_exception_init(&ex); libvlc = libvlc_new(vlc_argc, vlc_argv, &ex); myCatch(&ex); m = libvlc_media_new(libvlc, argv[1], &ex); myCatch(&ex); mp = libvlc_media_player_new_from_media(m, &ex); myCatch(&ex); libvlc_media_release(m); libvlc_media_player_play(mp, &ex); myCatch(&ex); /* * Main loop */ rect.w = 0; rect.h = 0; while(!done) { action = 0; /* Keys: enter (fullscreen), space (pause), escape (quit) */ while( SDL_PollEvent( &event ) ) { switch(event.type) { case SDL_QUIT: done = 1; break; case SDL_KEYDOWN: action = event.key.keysym.sym; break; } } switch(action) { case SDLK_ESCAPE: done = 1; break; case SDLK_RETURN: options ^= SDL_FULLSCREEN; screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options); break; case ' ': pause = !pause; break; } rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2); rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2); if(!pause) n++; /* Blitting the surface does not prevent it from being locked and * written to by another thread, so we use this additional mutex. */ SDL_LockMutex(ctx.mutex); SDL_BlitSurface(ctx.surf, NULL, screen, &rect); SDL_UnlockMutex(ctx.mutex); SDL_Flip(screen); SDL_Delay(10); SDL_BlitSurface(empty, NULL, screen, &rect); } /* * Stop stream and clean up libVLC */ libvlc_media_player_stop(mp, &ex); myCatch(&ex); libvlc_media_player_release(mp); libvlc_release(libvlc); /* * Close window and clean up libSDL */ SDL_DestroyMutex(ctx.mutex); SDL_FreeSurface(ctx.surf); SDL_FreeSurface(empty); SDL_Quit(); return 0; }
main.cpp: In function 'int SDL_main(int, char**)':
main.cpp:85: error: 'VLC_TREE' was not declared in this scope

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: About libvlc...

Postby Jean-Baptiste Kempf » 26 Apr 2010 13:18

Use VLC 1.1.0
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.


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 24 guests