Recent

Author Topic: [solved] lclvlc - HasX define?  (Read 11576 times)

cpicanco

  • Hero Member
  • *****
  • Posts: 618
  • Behavioral Scientist and Programmer
    • Portfolio
[solved] lclvlc - HasX define?
« on: October 14, 2016, 10:06:53 pm »
What is the HasX define standing for?

I can't compile the lazvlc package without it.

Best,
Rafael
« Last Edit: November 01, 2016, 04:22:15 am by cpicanco »
Be mindful and excellent with each other.
https://github.com/cpicanco/

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: lclvlc - HasX define?
« Reply #1 on: October 15, 2016, 02:00:44 am »
hello,

Quote
HasX -> X can be used for accessing functions not implented in gtk/gdk
         (this does not mean that gdkx functions can be used)
 HasGdk2X -> gdk2x can be used (gdk2x is defined for fpc 2.1+)
 UseX -> Use the X version of gtk instead of a native version

what is your O.S ? unix system ? 
have you X11 installed on it ? if yes what is your desktop environment ? KDE, GTK, GTK+, QT , other ?

Friendly, J.P
« Last Edit: October 15, 2016, 02:04:20 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11922
Re: lclvlc - HasX define?
« Reply #2 on: October 16, 2016, 12:33:34 pm »
I was unsuccessfully looking for an overview of all the important defines as well, this is really a mess!

Anyway, if you remove the {$IFDEF HasX} then the package compiles:

Code: Pascal  [Select][+][-]
  1. unit lclvlc;
  2. ...
  3. implementation
  4. //{$ifdef HasX}
  5. {$ifdef lclgtk2}
  6.   {$I vlcgtk2.inc}
  7. {$endif}
  8.  
  9. {$ifdef lclqt}
  10.   {$I vlcqt.inc}
  11. {$endif}
  12. //{$endif}
  13. ,,,

The demo, however, is not running, not even on Windows, maybe some dll-not-found thing, I did not investigate. I would appreciate if someone could investigate further and give instructions on how to use the component.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: lclvlc - HasX define?
« Reply #3 on: October 16, 2016, 01:56:13 pm »
See my comment in issue:
 http://bugs.freepascal.org/view.php?id=30742
I have assigned it to Mattias.

Does this component have any relation to:
 http://prog.olsztyn.pl/paslibvlc/
which I coincidentally downloaded and installed recently?
I have not studied their code.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: lclvlc - HasX define?
« Reply #4 on: October 16, 2016, 04:14:39 pm »
hello,
The demo, however, is not running, not even on Windows,.
the demo of lazvlc runs on windows 7 with my computer  :
Lazarus 1.6.0  32 bits   Windows 7 64 bits. VLC 2.2.1  32 bits. I have copied the folder c:\program files (x86)\VideoLAN in the folder c:\program files

 Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11922
Re: lclvlc - HasX define?
« Reply #5 on: October 16, 2016, 04:43:33 pm »
I have copied the folder c:\program files (x86)\VideoLAN in the folder c:\program files
I don't understand: You copy the program folder of the 32-bit VLC installation into the 64-bit programs folder? Although I don't believe that this is of any use I did this and still get "Could not create instance of libvlc".

My setup: Laz trunk/fpc 3.0 (32-bit) on Win 10 64 bit. VLC is V2.2.4 32 bit. The project tested is the testlcl that comes with Lazarus (in folder "(lazarus)\components\vlc\test")

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: lclvlc - HasX define?
« Reply #6 on: October 16, 2016, 05:12:27 pm »
I don't understand: You copy the program folder of the 32-bit VLC installation into the 64-bit programs folder?

if i don't copy the folder i have the message    :-X :
Quote
[Window Title]
testlcl

[Content]
Could not load library "C:\Program files\Videolan\VLC\libvlccore.dll":
Press OK to ignore and risk data corruption.
Press Cancel to kill the program.
[OK] [Cancel]

Have you tried to run your program as admin ?
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11922
Re: lclvlc - HasX define?
« Reply #7 on: October 16, 2016, 05:49:47 pm »
Have you tried to run your program as admin ?
Same: "Could not create instance of libvlc"

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: lclvlc - HasX define?
« Reply #8 on: October 17, 2016, 04:10:28 am »
hello,
wp, if you want to debug lazvlc for your problem :

1 - get the files vlc.pp and libvlc.pp from the folder  lazarus_1_6_xxx\fpc\3xxxx\source\packages\libvlc\src and put them in the folder azarus_1_6_xxxx\components\vlc
2 - open the package lazvlc and add the two files to the files of the package.
3 - compile the package
4 - Open the vlc demo project
5 - Open the file vlc.pp

===========================================

The problem of VLC path is in the file  libvlc.pp  here :
Code: Pascal  [Select][+][-]
  1. {$ifdef unix}
  2.   libname = 'libvlc.so.5';
  3. {$else}
  4. {$ifdef windows}
  5.   DefaultlibPath = 'C:\Program files\Videolan\VLC\';
  6.   corelibname    = 'libvlccore.dll';
  7.   libname        = 'libvlc.dll';
  8. {$endif}
  9. {$endif}
not good with windows 64 bits  Lazarus 32 bits VLC 32 bits.
And your error message is here in the file vlc.pp  :
Code: Pascal  [Select][+][-]
  1. function TVLCLibrary.GetInstance: plibvlc_instance_t;
  2.  
  3. var
  4.   args: Array of AnsiString;
  5.   cargs : array of PAnsiChar;
  6.   argc,
  7.   I : integer;
  8.  
  9. begin
  10.   If (FInstance=Nil) then
  11.     begin
  12.     LibraryArgs.add('--no-video-title-show');
  13.     SetLength(cArgs,LibraryArgs.Count+2);
  14.     SetLength(Args,LibraryArgs.Count+1);
  15.     cargs[0] := PChar(FLibraryPath);
  16.     For I:=0 to LibraryArgs.Count-1 do
  17.       begin
  18.       Args[i]:=LibraryArgs[i];
  19.       CArgs[i+1]:=PChar(Args[i]);
  20.       end;
  21.     argc:=Length(CArgs);
  22.     cargs[argc-1] := NIL;
  23.     FInstance := libvlc_new(argc-1, PPcchar(cargs));
  24.     if (FInstance=Nil) then
  25.       Raise EVLC.Create('Could not create instance of libvlc');
  26.     end;
  27.   Result:=FInstance;
  28. end;

put a breakpoint at the line Finstance := ...  et check the cargs. May be  the problem is before this in the load of the library.


Friendly, J.P

Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11922
Re: lclvlc - HasX define?
« Reply #9 on: October 17, 2016, 11:52:47 am »
That's a good catch! Inspired by https://wiki.videolan.org/Using_libvlc_with_Delphi/#Get_VLC_installation_path I added this code to libvlc.pas which seeks the VLC installation folder in the registry (I'm not 100% sure about it because my RegEdit shows the VideoLAN\VLC to be in HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\VideoLAN\VLC (Microsoft's usage of 32-bit programs in the 64-bit OS is terribly complicated...):
Code: Pascal  [Select][+][-]
  1. {$IFDEF WINDOWS}
  2. function GetVLCLibPath: String;
  3. var
  4.   Handle: HKEY;
  5.   RegType: Integer;
  6.   DataSize: Cardinal;
  7.   Key: PWideChar;
  8.   res: WideString;
  9. begin
  10.   Result := '';
  11.   Key := 'Software\VideoLAN\VLC';
  12.   if RegOpenKeyExW(HKEY_LOCAL_MACHINE, Key, 0, KEY_READ, Handle) = ERROR_SUCCESS then
  13.   begin
  14.     if RegQueryValueExW(Handle, 'InstallDir', nil, @RegType, nil, @DataSize) = ERROR_SUCCESS then
  15.     begin
  16.       SetLength(res, DataSize div 2);
  17.       RegQueryValueExW(Handle, 'InstallDir', nil, @RegType, PByte(@res[1]), @DataSize);
  18.       res[DataSize div 2] := '\';
  19.     end
  20.     else
  21.       raise Exception.Create('Error on reading registry');
  22.     RegCloseKey(Handle);
  23.     Result := UTF8Encode(res);
  24.   end;
  25. end;
Then I removed the global constant DefaultLibPath and redeclared it locally within "LoadLibVLC()" to take the result of above function. And now the demo runs (it takes a long time, though, until the video starts).

I think I'll write a bug report on this.

What I don't understand is why the "Could not create instance of vlc" error happens if the two dlls, libvlc.dll and libvlccore.dll, are copied to the exe folder of the application. The way I understand the LoadLibVLC() procedure is that it first seeks for these dlls in the current directory, then in the DefaultLibPath.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: lclvlc - HasX define?
« Reply #10 on: October 17, 2016, 12:39:23 pm »
hello,
for this :
And now the demo runs (it takes a long time, though, until the video starts).
you can have a look here
and what i have tried :
Quote from: jurassic pork
same problem for me with PasLibVlcPlayer :
if i run the program in the IDE with Option Debugger/General  Type and Path to Gnu Debugger (gdb) , the program run slowly.
if i run the program in the IDE with Option Debugger/General  Type and Path to none the video plays  instantaneously.

Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11922
Re: lclvlc - HasX define?
« Reply #11 on: October 17, 2016, 12:58:07 pm »
Yes, same here: if I run the demo outside the IDE the video starts reasonably fast.

What is your opion on the registry procedure above? Will it find the VLC installation folder for all combinations of VLC and OS bitness? It works for 32-bit VLC on 64-Bit Win, and it will probably work for 32-bit vlc on 32-bit Win. But will it work for 64-bit VLC on 64-bit Win? Is anybody using this combination? I don't want to change my VLC installation just for this test... ( I never understood why Microsoft had to introduce the chaos of that WOW6432 etc...)

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: lclvlc - HasX define?
« Reply #12 on: October 17, 2016, 02:59:18 pm »
may be something like this :  :-[
Quote
1 - Test if your app is 32 bits or 64 bits
2 - if your app is 32 bits you must use libvlc.dll 32 bits
3 - if your app is 64 bits you must use libvlc.dll 64 bits
4 - test if your O.S is 32 or 64 bits
5 - if your O.S is 32 bits and your app is 32 bits search for vlc 32 bits in the registry (without WOW6432Node)
5 - if your O.S is 64 bits and your app is 64 bits search for vlc 64 bits in the registry
6 - if your O.S is 64 bits and your app is 32 bits search for vlc 32 bits in the registry (WOW6432Node)
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wp

  • Hero Member
  • *****
  • Posts: 11922
Re: lclvlc - HasX define?
« Reply #13 on: October 17, 2016, 03:10:56 pm »
I am having case #6: 64-bit OS and 32-bit app. Looking in the registry I find VideoLan/VLC in the WOW6432 node, but my code in reply #9 is working fine although it does not use WOW6432. If I add WOW6432Node it is working correctly as well. Not using WOW6432, therefore, is probably the more general case since it may probably work also for 32-bit OS/32-bit App and 64-bit OS / 64-bit App.

Thaddy

  • Hero Member
  • *****
  • Posts: 14377
  • Sensorship about opinions does not belong here.
Re: lclvlc - HasX define?
« Reply #14 on: October 17, 2016, 03:12:48 pm »
may be something like this :  :-[
And test if your system is linux AND uses X.
E.g. the raspberry Pi doesn't need ff'ing X for vlc (vlc compiled from its trunk sourcecode) to work....(gtk+ or KDE or whatever...)
There is a bug report that excludes X for such reason in Mantis and it is indeed fixed in trunk.

People seem to think X == Linux. That is not the case. XX == X, just a windowing system that is often used on Linux.... Or BSD...
Hence the define: HasX simply means: can we use X?
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018