[vlc-devel] libvcl: screen:// does not work

Jens Kallup kallup.jens at web.de
Mon Sep 9 16:10:14 CEST 2019


Hello ListMember's,

I habe problem with screen:// cast - the Message "look into logs"
is displayed, but I can't find any other informations on console.
And I can't find any /var/log that is relevant to libvlc.

Here is a code snippet of the relevant code:

#include <stdio.h>
#include <assert.h>
#include <math.h>

#undef HAVE_STRINGS_H

#include "fe-gtk.h"
#include "video.h"

struct ctx ctx;

#define VIDEOWIDTH  160
#define VIDEOHEIGHT 100

bool videoinit = false;

libvlc_instance_t     * inst  = NULL;
libvlc_media_t        * m     = NULL;
libvlc_media_player_t * mp    = NULL;
libvlc_media_list_t   * media = NULL;

GtkWidget    * video, *vpane;
GMainContext * context;
GThread      * thread ;
SDL_Surface  * screen,* empty;
SDL_Rect       rect;


void OnQuit(void) {
     if (videoinit) {
         libvlc_media_player_stop   (mp);
         libvlc_media_player_release(mp);
         libvlc_release(inst);
     }
}

static gboolean
update_process(gpointer user_data)
{
     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);

     return G_SOURCE_REMOVE;
}

static gpointer
thread_func(gpointer user_data)
{
     GSource * source;

     rect.w = 0;
     rect.h = 0;

     source = g_idle_source_new();

     g_source_set_callback(source, update_process, NULL, NULL);
     g_source_attach(source, context);
     g_source_unref(source);

     return NULL;
}

static void *lock(void *data, void **p_pixels)
{
     struct ctx *ctx = data;

     SDL_LockMutex(ctx->mutex);
     SDL_LockSurface(ctx->surf);
     *p_pixels = ctx->surf->pixels;
     return NULL; /* picture identifier, not needed here */
}

static void unlock(void *data, void *id, void *const *p_pixels)
{
     struct ctx *ctx = data;

     /* VLC just rendered the video, but we can also render stuff */
     uint16_t *pixels = *p_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);

     assert(id == NULL); /* picture identifier, not needed here */
}

static void display(void *data, void *id)
{
     /* VLC wants to display the video */
     (void) data;
     assert(id == NULL);
}

void init_video(GtkWidget * box)
{
     int n = 0;

     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1) {
         g_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(VIDEOWIDTH, VIDEOHEIGHT, 0, options);

     if (!screen) {
         printf("cannot set video mode\n");
         return EXIT_FAILURE;
     }

     video =
     gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(video),GTK_SHADOW_ETCHED_OUT);
     gtk_container_add(GTK_CONTAINER(box),video);

     inst = libvlc_new(0, NULL);
     mp   = libvlc_media_player_new(inst);
     m    = libvlc_media_new_location(inst,"screen://"); if (m) {
            libvlc_media_player_set_media(mp,m);
     }      else {
            printf("eerrrrrr\n"); // dont show, so m is init.? !!!
     }

     libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx);
     libvlc_video_set_format   (mp, "RV16", VIDEOWIDTH, VIDEOHEIGHT,
VIDEOWIDTH*2);

     libvlc_media_player_set_xwindow (mp, GDK_WINDOW_XID(video->window));

     gtk_widget_realize(video);
     gtk_widget_show(video);

     libvlc_media_player_play(mp);

     context = g_main_context_default();
     thread  = g_thread_new(NULL, thread_func, GINT_TO_POINTER(n));
}


(hexchat:8463): Gdk-WARNING **:
/build/gtk+2.0-KsZSEA/gtk+2.0-2.24.23/gdk/x11/gdkdrawable-x11.c:952
drawable is not a pixmap or window
[000056201b955090] main input error: Ihre Eingabe konnte nicht geöffnet
werden
[000056201b955090] main input error: VLC kann die Medienadresse
'screen://' nicht öffnen. Für Details bitte im Fehlerprotokoll nachsehen.


Thanks for helping
Jens


More information about the vlc-devel mailing list