libvlc_media_player_set_drawable failing (Java)

This forum is about all development around libVLC.
sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

libvlc_media_player_set_drawable failing (Java)

Postby sherington » 31 Mar 2009 18:19

Hi,

I've been doing a lot of work to embed a vlc media player inside a Java application on Ubuntu 8.04. I already have something working with the latest available JVLC bindings.

However, I want to write my own Java binding rather than use JVLC - my own binding is a cut-down and simplified version that contains only the functions that I need and does not use any deprecated libvlc functions as JVLC does. I'm also trying to make a really robust binding that hides all libvlc implementation quirks from the calling Java application.

In particular, the existing JVLC uses libvlc_video_set_parent() which is deprecated in favour of libvlc_media_player_set_drawable(). My application works with libvlc_video_set_parent(), although I do see a seemingly harmless warning reported to the log (libvlc: no active input). The point is, it does work.

So, without using JVLC and using my own new Java binding, my sequence of (pseudo) code is this:

Code: Select all

createAndShowFrame(); // This creates a Canvas that will subsequently be used in set_drawable() libvlc_new(); libvlc_media_new(); libvlc_media_player_from_media(); libvlc_media_release(); libvlc_media_player_set_drawable(); libvlc_media_player_play();
I've looked at some examples of media players that use vlc and they do seem to follow this same sequence.

My problem is with libvlc_media_player_set_drawable() - if I invoke this before calling play(), then I get a hard VM failure somewhere in the libvlc native library:

Code: Select all

# Java VM: Java HotSpot(TM) Server VM (11.3-b02 mixed mode linux-x86) # Problematic frame: # C [libvlc.so+0x10e7a] libvlc_media_player_set_drawable+0x2a
I then tried waiting after calling play() for video output to appear before calling set_drawable() - but this does not reliably work, the video still displays in a new window, unless I stop() and play() again at which point the video does indeed appear in my Canvas.

Can anyone offer any hints or ideas on my approach - is my usage of libvlc_media_player_set_drawable correct? Have I missed something?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: libvlc_media_player_set_drawable failing (Java)

Postby sherington » 31 Mar 2009 19:09

Forget it, I've managed to get it to work.

In case anyone else is interested...

The deprecated method libvlc_video_set_parent takes a long parameter for the native id of the component to render the video to.

libvlc_media_player_set_drawable takes an int parameter for the native id of the component to render the video to.

This parameter value is obtained by a JNA call to Native.getComponentId(canvas). This returns a long value which is ok for video_set_parent, but not for media_player_set_drawable.

To make libvlc_media_player_set_drawable() work, this long value for the component id needs to be converted to an int. Obviously if the value is large then it may be truncated to fit inside an int and it won't work.

I think ideally libvlc_media_player_set_drawable() would need to be changed to accept a long rather than an int for the drawable id?? Or will the component id always fit inside an int?

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

Re: libvlc_media_player_set_drawable failing (Java)

Postby Rémi Denis-Courmont » 31 Mar 2009 20:26

This is a known bug that is fixed in the 1.0 libvlc API.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 18 guests