<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Erwan10</id>
	<title>VideoLAN Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Erwan10"/>
	<link rel="alternate" type="text/html" href="https://wiki.videolan.org/Special:Contributions/Erwan10/"/>
	<updated>2026-11-04T15:53:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=12807</id>
		<title>LibVLC SampleCode SDL</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=12807"/>
		<updated>2008-11-28T22:38:39Z</updated>

		<summary type="html">&lt;p&gt;Erwan10: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This sample code will render a video into an SDL surface.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039;: this requires the &amp;quot;vmem&amp;quot; video output which was checked in on March 21st, 2008. Update Nov 28th, 2008 to work with vlc-1.0.0(git).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* libSDL and libVLC sample code&lt;br /&gt;
 * Copyright © 2008 Sam Hocevar &amp;lt;sam@zoy.org&amp;gt;&lt;br /&gt;
 * license: [http://en.wikipedia.org/wiki/WTFPL WTFPL] */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;SDL.h&amp;gt;&lt;br /&gt;
#include &amp;lt;SDL_mutex.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define WIDTH 640&lt;br /&gt;
#define HEIGHT 480&lt;br /&gt;
&lt;br /&gt;
#define VIDEOWIDTH 320&lt;br /&gt;
#define VIDEOHEIGHT 240&lt;br /&gt;
&lt;br /&gt;
struct ctx&lt;br /&gt;
{&lt;br /&gt;
    SDL_Surface *surf;&lt;br /&gt;
    SDL_mutex *mutex;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
static void catch (libvlc_exception_t *ex)&lt;br /&gt;
{&lt;br /&gt;
    if(libvlc_exception_raised(ex))&lt;br /&gt;
    {&lt;br /&gt;
        fprintf(stderr, &amp;quot;exception: %s\n&amp;quot;, libvlc_exception_get_message(ex));&lt;br /&gt;
        exit(1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    libvlc_exception_clear(ex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#ifdef VLC09X&lt;br /&gt;
static void * lock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    return ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#else&lt;br /&gt;
static void lock(struct ctx *ctx, void **pp_ret)&lt;br /&gt;
{&lt;br /&gt;
    SDL_LockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
    SDL_LockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    *pp_ret = ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void unlock(struct ctx *ctx)&lt;br /&gt;
{&lt;br /&gt;
    /* VLC just rendered the video, but we can also render stuff */&lt;br /&gt;
    uint16_t *pixels = (uint16_t *)ctx-&amp;gt;surf-&amp;gt;pixels;&lt;br /&gt;
    int x, y;&lt;br /&gt;
&lt;br /&gt;
    for(y = 10; y &amp;lt; 40; y++)&lt;br /&gt;
        for(x = 10; x &amp;lt; 40; x++)&lt;br /&gt;
            if(x &amp;lt; 13 || y &amp;lt; 13 || x &amp;gt; 36 || y &amp;gt; 36)&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0xffff;&lt;br /&gt;
            else&lt;br /&gt;
                pixels[y * VIDEOWIDTH + x] = 0x0;&lt;br /&gt;
&lt;br /&gt;
    SDL_UnlockSurface(ctx-&amp;gt;surf);&lt;br /&gt;
    SDL_UnlockMutex(ctx-&amp;gt;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    char clock[64], cunlock[64], cdata[64];&lt;br /&gt;
    char width[32], height[32], pitch[32];&lt;br /&gt;
    libvlc_exception_t ex;&lt;br /&gt;
    libvlc_instance_t *libvlc;&lt;br /&gt;
    libvlc_media_t *m;&lt;br /&gt;
    libvlc_media_player_t *mp;&lt;br /&gt;
    char const *vlc_argv[] =&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;-q&amp;quot;,&lt;br /&gt;
        //&amp;quot;-vvvvv&amp;quot;,&lt;br /&gt;
        &amp;quot;--plugin-path&amp;quot;, VLC_TREE &amp;quot;/modules&amp;quot;,&lt;br /&gt;
        &amp;quot;--ignore-config&amp;quot;, /* Don&#039;t use VLC&#039;s config files */&lt;br /&gt;
        &amp;quot;--noaudio&amp;quot;,&lt;br /&gt;
        &amp;quot;--vout&amp;quot;, &amp;quot;vmem&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-width&amp;quot;, width,&lt;br /&gt;
        &amp;quot;--vmem-height&amp;quot;, height,&lt;br /&gt;
        &amp;quot;--vmem-pitch&amp;quot;, pitch,&lt;br /&gt;
        &amp;quot;--vmem-chroma&amp;quot;, &amp;quot;RV16&amp;quot;,&lt;br /&gt;
        &amp;quot;--vmem-lock&amp;quot;, clock,&lt;br /&gt;
        &amp;quot;--vmem-unlock&amp;quot;, cunlock,&lt;br /&gt;
        &amp;quot;--vmem-data&amp;quot;, cdata,&lt;br /&gt;
    };&lt;br /&gt;
    int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);&lt;br /&gt;
&lt;br /&gt;
    SDL_Surface *screen, *empty;&lt;br /&gt;
    SDL_Event event;&lt;br /&gt;
    SDL_Rect rect;&lt;br /&gt;
    int done = 0, action = 0, pause = 0, n = 0;&lt;br /&gt;
&lt;br /&gt;
    struct ctx ctx;&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libSDL&lt;br /&gt;
     */&lt;br /&gt;
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot initialize SDL\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    empty = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                 32, 0, 0, 0, 0);&lt;br /&gt;
    ctx.surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VIDEOWIDTH, VIDEOHEIGHT,&lt;br /&gt;
                                    16, 0x001f, 0x07e0, 0xf800, 0);&lt;br /&gt;
&lt;br /&gt;
    ctx.mutex = SDL_CreateMutex();&lt;br /&gt;
&lt;br /&gt;
    int options = SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF;&lt;br /&gt;
&lt;br /&gt;
    screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
    if(!screen)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;cannot set video mode\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Initialise libVLC&lt;br /&gt;
     */&lt;br /&gt;
    sprintf(clock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)lock);&lt;br /&gt;
    sprintf(cunlock, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)unlock);&lt;br /&gt;
    sprintf(cdata, &amp;quot;%lld&amp;quot;, (long long int)(intptr_t)&amp;amp;ctx);&lt;br /&gt;
    sprintf(width, &amp;quot;%i&amp;quot;, VIDEOWIDTH);&lt;br /&gt;
    sprintf(height, &amp;quot;%i&amp;quot;, VIDEOHEIGHT);&lt;br /&gt;
    sprintf(pitch, &amp;quot;%i&amp;quot;, VIDEOWIDTH * 2);&lt;br /&gt;
&lt;br /&gt;
    if(argc &amp;lt; 2)&lt;br /&gt;
    {&lt;br /&gt;
        printf(&amp;quot;too few arguments (MRL needed)\n&amp;quot;);&lt;br /&gt;
        return EXIT_FAILURE;&lt;br /&gt;
    }&lt;br /&gt;
    libvlc_exception_init(&amp;amp;ex);&lt;br /&gt;
    libvlc = libvlc_new(vlc_argc, vlc_argv, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    m = libvlc_media_new(libvlc, argv[1], &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    mp = libvlc_media_player_new_from_media(m, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
    libvlc_media_release(m);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_play(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     *  Main loop&lt;br /&gt;
     */&lt;br /&gt;
    rect.w = 0;&lt;br /&gt;
    rect.h = 0;&lt;br /&gt;
&lt;br /&gt;
    while(!done)&lt;br /&gt;
    { &lt;br /&gt;
        action = 0;&lt;br /&gt;
&lt;br /&gt;
        /* Keys: enter (fullscreen), space (pause), escape (quit) */&lt;br /&gt;
        while( SDL_PollEvent( &amp;amp;event ) ) &lt;br /&gt;
        { &lt;br /&gt;
            switch(event.type)&lt;br /&gt;
            {&lt;br /&gt;
            case SDL_QUIT:&lt;br /&gt;
                done = 1;&lt;br /&gt;
                break;&lt;br /&gt;
            case SDL_KEYDOWN:&lt;br /&gt;
                action = event.key.keysym.sym;&lt;br /&gt;
                break;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        switch(action)&lt;br /&gt;
        {&lt;br /&gt;
        case SDLK_ESCAPE:&lt;br /&gt;
            done = 1;&lt;br /&gt;
            break;&lt;br /&gt;
        case SDLK_RETURN:&lt;br /&gt;
            options ^= SDL_FULLSCREEN;&lt;br /&gt;
            screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);&lt;br /&gt;
            break;&lt;br /&gt;
        case &#039; &#039;:&lt;br /&gt;
            pause = !pause;&lt;br /&gt;
            break;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        rect.x = (int)((1. + .5 * sin(0.03 * n)) * (WIDTH - VIDEOWIDTH) / 2);&lt;br /&gt;
        rect.y = (int)((1. + .5 * cos(0.03 * n)) * (HEIGHT - VIDEOHEIGHT) / 2);&lt;br /&gt;
&lt;br /&gt;
        if(!pause)&lt;br /&gt;
            n++;&lt;br /&gt;
&lt;br /&gt;
        /* Blitting the surface does not prevent it from being locked and&lt;br /&gt;
         * written to by another thread, so we use this additional mutex. */&lt;br /&gt;
        SDL_LockMutex(ctx.mutex);&lt;br /&gt;
        SDL_BlitSurface(ctx.surf, NULL, screen, &amp;amp;rect);&lt;br /&gt;
        SDL_UnlockMutex(ctx.mutex);&lt;br /&gt;
&lt;br /&gt;
        SDL_Flip(screen);&lt;br /&gt;
        SDL_Delay(10);&lt;br /&gt;
&lt;br /&gt;
        SDL_BlitSurface(empty, NULL, screen, &amp;amp;rect);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Stop stream and clean up libVLC&lt;br /&gt;
     */&lt;br /&gt;
    libvlc_media_player_stop(mp, &amp;amp;ex);&lt;br /&gt;
    catch(&amp;amp;ex);&lt;br /&gt;
&lt;br /&gt;
    libvlc_media_player_release(mp);&lt;br /&gt;
    libvlc_release(libvlc);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Close window and clean up libSDL&lt;br /&gt;
     */&lt;br /&gt;
    SDL_DestroyMutex(ctx.mutex);&lt;br /&gt;
    SDL_FreeSurface(ctx.surf);&lt;br /&gt;
    SDL_FreeSurface(empty);&lt;br /&gt;
&lt;br /&gt;
    SDL_Quit();&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Erwan10</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=12806</id>
		<title>LibVLC SampleCode SDL</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=LibVLC_SampleCode_SDL&amp;diff=12806"/>
		<updated>2008-11-28T22:36:02Z</updated>

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