Need vlc to display video in window I provide

This forum is about all development around libVLC.
Ultraseamus
Blank Cone
Blank Cone
Posts: 18
Joined: 06 May 2009 18:47

Need vlc to display video in window I provide

Postby Ultraseamus » 30 Sep 2009 21:48

I am currently running vlc version 1.0.2 through C++ in embedded windows xp, and I need to have vlc draw to a window that I have created. I used to just have VLC display in its own window, but had to change that for issues discussed here: viewtopic.php?f=32&t=65508. So, to do this I am creating my own window and sending VLC the handle via "libvlc_media_player_set_hwnd". Problem is that no matter what I do VLC seems to insist on creating its own window titled "VLC (hardware YUV overlay DirectX output)". This seems somewhat similar to an issue posted a few years ago: https://forum.videolan.org/viewtopic.php?f=15&t=29573 which was never resolved, or http://mailman.videolan.org/pipermail/v ... 62272.html. It is possible that I am missing a parameter that tells VLC to wait for the window handle before creating its own. My other theory comes from the documentation for the function I am using, where it says "If LibVLC was built without Win32/Win64 API output support, then this has no effects." I Was previously using dlls with my project from vlc 0.8.6, and just recently downloaded the new 1.0.2 dlls off of the VLC website (http://www.videolan.org/vlc/download-windows.html)to get access to this new functionality.

So, my question is: are there special parameters that need to be set to tell VLC not to create its own window or, is it possible that the LibVLC I downloaded was built without Win32/Win64 API output support? Or, is there some other reason why my window would be completely ignored? I feel like these may be trivial questions, but I am new to this kind of work and have had no luck in working through this problem. Any advice at all would be greatly appreciated. I have not had much luck with these forums before, so I am trying to give as much information as I can. Even if someone replied telling me why my question is stupid, it would be helpful. :) Thanks.

Have tried other functions like set drawable, or set parent. They all have the same lack of effect. My window comes up, but it remains blank. And VLC continues to open up its own window where it renders the video.

Mountazar
New Cone
New Cone
Posts: 6
Joined: 25 Sep 2009 18:26

Re: Need vlc to display video in window I provide

Postby Mountazar » 01 Oct 2009 13:45

Hi Ultraseamus,
please try the following:

1. Launch VLC application; under Tools/Preferences/Interface (Show settings = Simple), ensure "Embed video in interface" is checked. And under the same subject ensure that you are not using inside your program a VLC launching parameter called:
--no-embed-video (this will override the VLC application setting)

2. Try resetting VLC settings to its defaults (since you have done an upgrade it may be inheriting or modifying some previous settings). This is done by clicking on the "Reset Settings" button at the bottom of the Preferences dialog.

3. If still not resolved, you may try setting up a clean VLC installation from scratch (on a PC where you didn't have VLC before). Retest there.

4. If not yet solved, please send me the following data so that I try to reproduce the problem:
a. The VLC launching parameters you are using in your application
b. The VLC config file: %appdata%\vlc\vlcrc (e.g. C:\Documents and Settings\Administrator\Application Data\vlc\vlcrc)

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

Re: Need vlc to display video in window I provide

Postby Rémi Denis-Courmont » 01 Oct 2009 16:33

It seems you are calling set_hwnd after VLC created its window. This cannot work.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Ultraseamus
Blank Cone
Blank Cone
Posts: 18
Joined: 06 May 2009 18:47

Re: Need vlc to display video in window I provide

Postby Ultraseamus » 01 Oct 2009 20:34

First of all, thank you both very much for the responses.
It seems you are calling set_hwnd after VLC created its window. This cannot work.
As far as I can tell I set the handle as soon as possible:

Code: Select all

m_media_player = libvlc_media_player_new_from_media_dll (m_media, &ex); catchException (&ex); libvlc_media_player_set_hwnd_dll(m_media_player, handleVLC, &ex); catchException (&ex);
Hi Ultraseamus,
please try the following:

1. Launch VLC application; under Tools/Preferences/Interface (Show settings = Simple), ensure "Embed video in interface" is checked. And under the same subject ensure that you are not using inside your program a VLC launching parameter called:
--no-embed-video (this will override the VLC application setting)

2. Try resetting VLC settings to its defaults (since you have done an upgrade it may be inheriting or modifying some previous settings). This is done by clicking on the "Reset Settings" button at the bottom of the Preferences dialog.

3. If still not resolved, you may try setting up a clean VLC installation from scratch (on a PC where you didn't have VLC before). Retest there.

4. If not yet solved, please send me the following data so that I try to reproduce the problem:
a. The VLC launching parameters you are using in your application
b. The VLC config file: %appdata%\vlc\vlcrc (e.g. C:\Documents and Settings\Administrator\Application Data\vlc\vlcrc)
I am not actually using the GUI for these settings, I am doing it through C++ in visual studio:

Code: Select all

char const *vlc_argv[] = { "-vvvvv", "--plugin-path", "plugins", "--ignore-config", "--reset-config", "--noaudio", "--rtsp-caching", "500", }; int vlc_argc = sizeof (vlc_argv) / sizeof (*vlc_argv); libvlc_exception_init_dll (&ex); m_libvlc = libvlc_new_dll (vlc_argc, vlc_argv, &ex); catchException (&ex);
While these settings have changed many times, they all still have the same end result. If it would help resolve the problem I can have my settings save to a config file (via the "--save-config" parameter) and send the file whatever way is easiest for you.


The following is the block of code that I think is directly relevant to this issue. It has been through many changes trying to get this to work, and then trying to find other solutions.

Code: Select all

static bool class_reg = false; DWORD ret; HWND hWindow = NULL; // Check if we have already registered the window class... if(class_reg == false) { WNDCLASS tmp_wc; tmp_wc.style = 0; tmp_wc.lpfnWndProc = WndProc; tmp_wc.cbClsExtra = 0; tmp_wc.cbWndExtra = 8; tmp_wc.hInstance = 0; tmp_wc.hIcon = LoadIcon (NULL, MAKEINTRESOURCE(IDI_ICON)); tmp_wc.hCursor = LoadCursor (NULL, IDC_ARROW); tmp_wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); tmp_wc.lpszMenuName = NULL; tmp_wc.lpszClassName = "VLCWindow"; ret = RegisterClass (&tmp_wc); class_reg = true; } handleVLC = CreateWindowEx( (WS_EX_TOPMOST | WS_EX_NOACTIVATE), "VLCWindow", "", (WS_VISIBLE | WS_POPUP | WS_EX_TRANSPARENT), 502, 152, 900, 900, R->getRenderWindow(), //parent, NULL, 0, NULL); char const *vlc_argv[] = { "-vvvvv", "--plugin-path", "plugins", "--ignore-config", "--reset-config", "--noaudio", "--rtsp-caching", "500", }; int vlc_argc = sizeof (vlc_argv) / sizeof (*vlc_argv); libvlc_exception_init_dll (&ex); m_libvlc = libvlc_new_dll (vlc_argc, vlc_argv, &ex); catchException (&ex); char ipString[50]; strcpy (ipString, "rtsp://"); strcat (ipString, R->m_config.Server[R->m_config.ServerIndex].Camera.cameraStr); strcat (ipString, "/mpeg4?multicast"); m_media = libvlc_media_new_dll (m_libvlc, ipString, &ex); catchException (&ex); m_media_player = libvlc_media_player_new_from_media_dll (m_media, &ex); catchException (&ex); libvlc_media_player_set_hwnd_dll(m_media_player, handleVLC, &ex); catchException (&ex); libvlc_media_player_play_dll (m_media_player, &ex); catchException (&ex);

Mountazar
New Cone
New Cone
Posts: 6
Joined: 25 Sep 2009 18:26

Re: Need vlc to display video in window I provide

Postby Mountazar » 02 Oct 2009 15:01

Hi Ultraseamus,
I used your code (with your vlc launching parameters i.e. not to use VLC config) and didn't get the problem you are talking about ! I used VLC 1.0.2
When you create the Window that has to host VLC, you are setting a parent "R->getRenderWindow()".
During my test, if I set a valid handle to a valid window (already created and visible), it works fine.
Try NULL (the parent will be the desktop) and it should work (I tested it and it works fine).


However if I specify an invalid window handle for this parameter such as "HWND(0x7200012)" (a random value of a non-existent window), in this case VLC will open in its own window labelled "hardware YUV overlay DirectX output".
This is because the CreateWindowEx fails and returns "handleVLC = 0" and thus VLC switches to its own window.

However I didn't get your exact described behaviour; you say that the Window is created and at the same time VLC opens another one for its own.
In my test I either get VLC playing in the successfully created window. Or the window fails to be created and in this case VLC opens its own window.
I can send you the sample app of the test done.

I suggest to test NULL as the parent, or to ensure "R->getRenderWindow()" is already created and shown on screen

Ultraseamus
Blank Cone
Blank Cone
Posts: 18
Joined: 06 May 2009 18:47

Re: Need vlc to display video in window I provide

Postby Ultraseamus » 02 Oct 2009 19:01

Hmm. I have tried setting the parent to NULL, always does the same thing for me, with both my window and vlc's showing up at the same time. There must be some other variable that I am not aware of. This solution would have been ideal, but once I got the impression that it would never work I moved onto the back up plan of taking complete control over the vlc window. So, I am routing its message proc through my own first, and I can pretty much alter any settings I want after it has been created. Not the ideal solution, but it works. Thanks for your help, if I get the chance to go back to that code to try and figure it out I will let you know what was wrong in the end. :)


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 8 guests