Is it possible to use libvlc.dll directly instead of ActiveX

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
aagis
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Oct 2006 16:57

Is it possible to use libvlc.dll directly instead of ActiveX

Postby aagis » 05 Oct 2006 17:04

Hello everyone,
I've been dealing with some nasty issues while trying to incorporate the VLC ActiveX in an application and was wondering wether it is possible to use a dll (libvlc.dll) directly to simplify the design and hopefully avoid these issues. Does anybody know if something like that is possible?

Thank you,
Agis Andreou.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Postby Jean-Baptiste Kempf » 05 Oct 2006 18:23

Yes, it should be possible and will be better in next versions (0.9.0).
Be careful, if you link against libvlc.dll, your soft needs to be GPL.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

aagis
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Oct 2006 16:57

Postby aagis » 19 Oct 2006 16:27

Thank you for your reply, is there any documentation of that API?

Thanks agains,
Agis Andreou.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Postby Jean-Baptiste Kempf » 19 Oct 2006 17:20

Hmm... Yes. look in the developper section on the website.
Look into the source code .h :D
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

BorPas
Blank Cone
Blank Cone
Posts: 15
Joined: 25 Aug 2006 12:38

Postby BorPas » 24 Oct 2006 08:22

can somebody write a simple example of creating and placing on form vlc video window using libvlc.dll for msvc6 or delphi(vcl or winapi) ? i want to get rid of activex one day :-)

Odysee
Blank Cone
Blank Cone
Posts: 15
Joined: 25 Oct 2006 17:18
Location: Germany

Postby Odysee » 25 Oct 2006 17:35

I'm trying this too!
I have taken a look in the activex source. But it is not working yet :(
Witch steps must be done, to show a video in my own window ?

Here is my code. What is missing ???

Code: Select all

... // create vlc instance m_iVlcInstance = VLC_Create(); // init vlc char *ppsz_argv[2] = { "C:\\Programme\\VideoLAN\\VLC", "--no-one-instance" }; VLC_Init(m_iVlcInstance, 2, ppsz_argv); ... /* set internal video width and height */ vlc_value_t val; val.i_int = rcClient.right - rcClient.left; int iResult = VariableSet(m_iVlcInstance, "conf::width", val); val.i_int = rcClient.bottom-rcClient.top; iResult = VLC_VariableSet(m_iVlcInstance, "conf::height", val); /* set internal video parent window */ /* horrible cast there */ val.i_int = reinterpret_cast<int>(m_hWnd); // -> thisis my window handle!!! iResult = VLC_VariableSet(m_iVlcInstance, "drawable", val); // add video stream iResult = VLC_AddTarget(m_iVlcInstance, "D:\\videostream.mpeg", NULL, 0, PLAYLIST_APPEND , PLAYLIST_END); // play iResult = VLC_Play(m_iVlcInstance);
ciao Odysee

Odysee
Blank Cone
Blank Cone
Posts: 15
Joined: 25 Oct 2006 17:18
Location: Germany

Postby Odysee » 25 Oct 2006 18:22

I have found the problem!

When i copy the exe into the vlc directory it works!

But how must i initialize libvlc, when the program is not in the vlc directory ???

Working code in the vlc directory:
char *ppsz_argv[2] = { "vlc", "--no-one-instance" };

-> Problem sloved :D
char *ppsz_argv[2] = { "C:\\Programme\\VideoLAN\\VLC\\vlc", "--no-one-instance"};

aagis
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Oct 2006 16:57

thanks!

Postby aagis » 26 Oct 2006 20:09

Thanks!! the code worked fine in my delphi application. Just some issues I came accross for general reference:
-- note to use the cdecl calling convention when importing the functions (it took me some time to figure that out)
-- set vlc_value_t to int64 as (correct me if I'm wrong) there are no union structures in delphi. thus a function as the following is needed
type
vlc_value_t=int64;

function vlc_int(i:integer):vlc_value_t;
type PInt=^integer;
begin
Result := 0;
PInt(@Result)^ := i;
end;

function vlc_int(const val:vlc_value_t):integer;
type PInt=^integer;
begin
Result := PInt(@val)^;
end;

Thanks again,
Agis

aagis
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Oct 2006 16:57

Postby aagis » 27 Oct 2006 16:57

Here is the delphi code

libvlc wrapper

Code: Select all

unit vlc; interface type vlc_bool_t=integer; vlc_int64_t=int64; //typedef struct vlc_list_t vlc_list_t; //typedef struct vlc_object_t vlc_object_t; const VLC_VAR_VOID =$0010; VLC_VAR_BOOL =$0020; VLC_VAR_INTEGER =$0030; VLC_VAR_HOTKEY =$0031; VLC_VAR_STRING =$0040; VLC_VAR_MODULE =$0041; VLC_VAR_FILE =$0042; VLC_VAR_DIRECTORY=$0043; VLC_VAR_VARIABLE =$0044; VLC_VAR_FLOAT =$0050; VLC_VAR_TIME =$0060; VLC_VAR_ADDRESS =$0070; VLC_VAR_MUTEX =$0080; VLC_VAR_LIST =$0090; type vlc_value_t=packed record a, b, c, d, e, f, g, h:char; end; //typedef union //{ // int i_int; // vlc_bool_t b_bool; // float f_float; // char * psz_string; // void * p_address; // vlc_object_t * p_object; // vlc_list_t * p_list; // vlc_int64_t i_time; // // struct { char *psz_name; int i_object_id; } var; // // /* Make sure the structure is at least 64bits */ // struct { char a, b, c, d, e, f, g, h; } padding; //} ; function vlc_int(const val:vlc_value_t):integer;overload; function vlc_int(val:integer):vlc_value_t;overload; function vlc_bool(const val:vlc_value_t):vlc_bool_t;overload; function vlc_bool(val:vlc_bool_t):vlc_value_t;overload; function vlc_pchar(const val:vlc_value_t):Pchar;overload; function vlc_pchar(val:Pchar):vlc_value_t;overload; function vlc_time(const val:vlc_value_t):vlc_int64_t;overload; function vlc_time(val:vlc_int64_t):vlc_value_t;overload; //struct vlc_list_t //{ // int i_count; // vlc_value_t * p_values; // int * pi_types; //}; //***************************************************************************** // * Error values // *****************************************************************************/ const VLC_SUCCESS =-0;// /* No error */ VLC_ENOMEM =-1;// /* Not enough memory */ VLC_ETHREAD =-2;// /* Thread error */ VLC_ETIMEOUT =-3;// /* Timeout */ VLC_ENOMOD =-10;// /* Module not found */ VLC_ENOOBJ =-20;// /* Object not found */ VLC_EBADOBJ =-21;// /* Bad object type */ VLC_ENOVAR =-30;// /* Variable not found */ VLC_EBADVAR =-31;// /* Bad variable value */ VLC_EEXIT =-255;// /* Program exited */ VLC_EEXITSUCCESS =-999;// /* Program exited successfully */ VLC_EGENERIC =-666;// /* Generic error */ //***************************************************************************** // * Booleans //*****************************************************************************/ VLC_FALSE =0; VLC_TRUE =1; ///***************************************************************************** // * Playlist // *****************************************************************************/ ///* Used by VLC_AddTarget() */ PLAYLIST_INSERT =$0001; PLAYLIST_REPLACE =$0002; PLAYLIST_APPEND =$0004; PLAYLIST_GO =$0008; PLAYLIST_CHECK_INSERT =$0010; PLAYLIST_PREPARSE =$0020; PLAYLIST_INSERTANDGO =$0009; PLAYLIST_END =-666; function VLC_Version ( ):PChar;cdecl; function VLC_CompileTime ():PChar;cdecl; function VLC_CompileBy ( ):Pchar;cdecl; function VLC_CompileHost ():Pchar;cdecl; function VLC_CompileDomain ():Pchar;cdecl; function VLC_Compiler ( ):Pchar;cdecl; function VLC_Changeset ( ):Pchar;cdecl; function VLC_Error ( i_err:integer ):PChar;cdecl; function VLC_Create( ):integer;cdecl; function VLC_Init( i_obj,i_argc:integer;ppsz_argv:PPChar ):integer;cdecl; function VLC_AddIntf( i_obj:integer;psz_module:Pchar;b_block,b_play:vlc_bool_t ):integer;cdecl; function VLC_Die( i_obj:integer ):integer;cdecl; function VLC_CleanUp(i_obj:integer ):integer;cdecl; function VLC_Destroy(i_obj:integer ):integer;cdecl; function VLC_VariableSet( i_obj:integer; psz_var:PChar;value:vlc_value_t ):integer;cdecl; function VLC_VariableGet( i_obj:integer; psz_var:PChar;var value:vlc_value_t ):integer;cdecl; function VLC_VariableType( i_obj:integer; psz_var:PChar;var pi_type:integer ):integer;cdecl; function VLC_AddTarget(i_object:integer;psz_target:Pchar;ppsz_options:PPChar; i_options,i_mode,i_pos:integer ):integer;cdecl; function VLC_Play( i_obj:integer ):integer;cdecl; function VLC_Pause( i_obj:integer ):integer;cdecl; function VLC_Stop( i_obj:integer ):integer;cdecl; function VLC_IsPlaying( i_obj:integer ):vlc_bool_t;cdecl; function VLC_PositionGet( i_obj:integer ):single;cdecl; function VLC_PositionSet( i_obj:integer;pos:single ):single;cdecl; function VLC_TimeGet( i_obj:integer ):integer;cdecl; function VLC_TimeSet( i_obj,i_seconds:integer;b_relative:vlc_bool_t ):integer;cdecl; function VLC_LengthGet( i_obj:integer ):integer;cdecl; function VLC_SpeedFaster( i_obj:integer ):Single;cdecl; function VLC_SpeedSlower( i_obj:integer ):Single;cdecl; function VLC_PlaylistIndex( i_obj:integer ):integer;cdecl; function VLC_PlaylistNumberOfItems( i_obj:integer ):integer;cdecl; function VLC_PlaylistNext( i_obj:integer ):integer;cdecl; function VLC_PlaylistPrev( i_obj:integer ):integer;cdecl; function VLC_PlaylistClear( i_obj:integer ):integer;cdecl; function VLC_VolumeSet( i_obj,volume:integer):integer;cdecl; function VLC_VolumeGet( i_obj:integer):integer;cdecl; function VLC_VolumeMute( i_obj:integer):integer;cdecl; function VLC_FullScreen( i_obj:integer):integer;cdecl; implementation const VLC_DLL='libvlc.dll'; function vlc_int(val:integer):vlc_value_t; type P=^integer; begin FillChar(Result,sizeof(vlc_value_t),0); P(@Result)^ := val; end; function vlc_int(const val:vlc_value_t):integer; type P=^integer; begin Result := P(@val)^; end; function vlc_bool(val:vlc_bool_t):vlc_value_t; type P=^vlc_bool_t; begin FillChar(Result,sizeof(vlc_value_t),0); P(@Result)^ := val; end; function vlc_bool(const val:vlc_value_t):vlc_bool_t; type P=^vlc_bool_t; begin Result := P(@val)^; end; function vlc_pchar(val:Pchar):vlc_value_t; type P=^Pchar; begin FillChar(Result,sizeof(vlc_value_t),0); P(@Result)^ := val; end; function vlc_pchar(const val:vlc_value_t):PChar; type P=^Pchar; begin Result := P(@val)^; end; function vlc_time(val:vlc_int64_t):vlc_value_t; type P=^vlc_int64_t; begin FillChar(Result,sizeof(vlc_value_t),0); P(@Result)^ := val; end; function vlc_time(const val:vlc_value_t):vlc_int64_t; type P=^vlc_int64_t; begin Result := P(@val)^; end; function VLC_Version ( ):PChar;external VLC_DLL; function VLC_CompileTime ():PChar;external VLC_DLL; function VLC_CompileBy ( ):Pchar;external VLC_DLL; function VLC_CompileHost ():Pchar;external VLC_DLL; function VLC_CompileDomain ():Pchar;external VLC_DLL; function VLC_Compiler ( ):Pchar;external VLC_DLL; function VLC_Changeset ( ):Pchar;external VLC_DLL; function VLC_Error ( i_err:integer ):PChar;external VLC_DLL; function VLC_Create( ):integer;external VLC_DLL; function VLC_Init( i_obj,i_argc:integer;ppsz_argv:PPChar ):integer;external VLC_DLL; function VLC_AddIntf( i_obj:integer;psz_module:Pchar;b_block,b_play:vlc_bool_t ):integer;external VLC_DLL; function VLC_Die( i_obj:integer ):integer;external VLC_DLL; function VLC_CleanUp(i_obj:integer ):integer;external VLC_DLL; function VLC_Destroy(i_obj:integer ):integer;external VLC_DLL; function VLC_VariableSet( i_obj:integer; psz_var:PChar;value:vlc_value_t ):integer;external VLC_DLL; function VLC_VariableGet( i_obj:integer; psz_var:PChar;var value:vlc_value_t ):integer;external VLC_DLL; function VLC_VariableType( i_obj:integer; psz_var:PChar;var pi_type:integer ):integer;external VLC_DLL; function VLC_AddTarget(i_object:integer;psz_target:Pchar;ppsz_options:PPChar; i_options,i_mode,i_pos:integer ):integer;external VLC_DLL; function VLC_Play( i_obj:integer ):integer;external VLC_DLL; function VLC_Pause( i_obj:integer ):integer;external VLC_DLL; function VLC_Stop( i_obj:integer ):integer;external VLC_DLL; function VLC_IsPlaying( i_obj:integer ):vlc_bool_t;external VLC_DLL; function VLC_PositionGet( i_obj:integer ):single;external VLC_DLL; function VLC_PositionSet( i_obj:integer;pos:single ):single;external VLC_DLL; function VLC_TimeGet( i_obj:integer ):integer;external VLC_DLL; function VLC_TimeSet( i_obj,i_seconds:integer;b_relative:vlc_bool_t ):integer;external VLC_DLL; function VLC_LengthGet( i_obj:integer ):integer;external VLC_DLL; function VLC_SpeedFaster( i_obj:integer ):Single;external VLC_DLL; function VLC_SpeedSlower( i_obj:integer ):Single;external VLC_DLL; function VLC_PlaylistIndex( i_obj:integer ):integer;external VLC_DLL; function VLC_PlaylistNumberOfItems( i_obj:integer ):integer;external VLC_DLL; function VLC_PlaylistNext( i_obj:integer ):integer;external VLC_DLL; function VLC_PlaylistPrev( i_obj:integer ):integer;external VLC_DLL; function VLC_PlaylistClear( i_obj:integer ):integer;external VLC_DLL; function VLC_VolumeSet( i_obj,volume:integer):integer;external VLC_DLL; function VLC_VolumeGet( i_obj:integer):integer;external VLC_DLL; function VLC_VolumeMute( i_obj:integer):integer;external VLC_DLL; function VLC_FullScreen( i_obj:integer):integer;external VLC_DLL; end.
And the in object code (interchangable with the activeX)

Code: Select all

unit vlcwrap; interface uses vlc,SysUtils,Classes,Windows,Forms,extctrls,Variants; const VlcPlayListInsert = PLAYLIST_INSERT; VlcPlayListInsertAndGo = PLAYLIST_INSERT+PLAYLIST_GO; type TVLCPlugin=class private Panel:TPanel; handle:THandle; i_object:integer; function getVolume: integer; procedure setVolume(const Value: integer); function getVisible: boolean; procedure setVisible(const Value: boolean); function getLength: integer; function getTime: integer; procedure setTime(const Value: integer); function getPlaying: boolean; public constructor Create(Panel:TPanel); destructor Destroy;override; property Volume:integer read getVolume write setVolume; property Visible:boolean read getVisible write setVisible; property Time:integer read getTime write setTime; property Length:integer read getLength; property Playing:boolean read getPlaying; procedure play; procedure pause; procedure stop; procedure shuttle(seconds:integer); procedure playFaster; procedure playSlower; procedure playListClear; function AddTarget(psz_target:string;options:Variant; i_mode,i_pos:integer ):integer;cdecl; end; implementation { TVLCPlugin } function TVLCPlugin.AddTarget(psz_target: string; options: Variant; i_mode,i_pos: integer): integer; begin assert(options=null,'Options not supported'); VLC_AddTarget(i_object,Pchar(psz_target),nil,0,i_mode,-666); end; constructor TVLCPlugin.Create(Panel: TPanel); label ERROR; var psz_option:PChar; i_result:integer; val:vlc_value_t; msg:string; begin inherited Create; Self.Panel := Panel; Handle:=Panel.Handle; i_object := VLC_Create(); psz_option := 'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe'; i_result := VLC_Init(i_object,1,@psz_option); if i_result<0 then goto ERROR; i_result :=VLC_VariableSet(i_object,'conf::width',vlc_int(Panel.Width)); if i_result<0 then goto ERROR; i_result :=VLC_VariableSet(i_object,'conf::height',vlc_int(Panel.Height)); if i_result<0 then goto ERROR; i_result :=VLC_VariableSet(i_object,'drawable',vlc_int(Panel.Handle)); if i_result<0 then goto ERROR; i_result := VLC_VariableGet(i_object,'drawable',val); if i_result<0 then goto ERROR; exit; ERROR: msg := 'Error '+IntToStr(i_result) + ' :'; msg := msg + VLC_ERROR(i_result); MessageBox(handle,Pchar(msg),'error',MB_ICONWARNING); exit; end; destructor TVLCPlugin.destroy; begin VLC_CleanUp(i_object); VLC_Destroy(i_object); inherited; end; function TVLCPlugin.getLength: integer; begin Result := VLC_LengthGet(i_object); end; function TVLCPlugin.getPlaying: boolean; begin Result := VLC_IsPlaying(i_object)<>VLC_FALSE; end; function TVLCPlugin.getTime: integer; begin Result := VLC_TimeGet(i_object); end; function TVLCPlugin.getVisible: boolean; begin Result := Panel.Visible; end; function TVLCPlugin.getVolume: integer; begin Result := VLC_VolumeGet(i_object); end; procedure TVLCPlugin.pause; begin VLC_pause(i_object); end; procedure TVLCPlugin.play; begin VLC_Play(i_object); end; procedure TVLCPlugin.playFaster; begin VLC_SpeedFaster(i_object); end; procedure TVLCPlugin.playListClear; begin VLC_PlayListClear(i_object); end; procedure TVLCPlugin.playSlower; begin VLC_SpeedSlower(i_object); end; procedure TVLCPlugin.setTime(const Value: integer); begin VLC_TimeSet(i_object,Value,VLC_FALSE); end; procedure TVLCPlugin.setVisible(const Value: boolean); begin Panel.Visible := Value; end; procedure TVLCPlugin.setVolume(const Value: integer); begin VLC_volumeSet(i_object,Value); end; procedure TVLCPlugin.shuttle(seconds: integer); begin VLC_TimeSet(i_object,seconds,VLC_TRUE); end; procedure TVLCPlugin.stop; begin VLC_Stop(i_object); end;
Hope this helps

BorPas
Blank Cone
Blank Cone
Posts: 15
Joined: 25 Aug 2006 12:38

Postby BorPas » 27 Oct 2006 18:38

many thanks aagis, it is greate!

Fritivi
New Cone
New Cone
Posts: 5
Joined: 24 May 2006 10:01

Postby Fritivi » 07 Nov 2006 17:55

Another implementation and example can also be found here :
http://tothpaul.free.fr/zip/VLD.zip

I use Paul Toth's version and it has the advantage of having a clearer to use type (TValue) to send and retrieve data with vlc functions. It also finds vlclib using the Registry, i think you should include the same code in your unit aagis.

For those who want to test things with direct access to vlclib the example included in vld.zip will let you know what happens and what vlc functions send back, i found it very usefull.

VLD has been available for two months now and a link is present in the Wiki page about Delphi and the Active X, reading the wiki would have saved you a lot of time ;)
http://fritivi.free.fr ... merci VLC ! :D

darianmiller
New Cone
New Cone
Posts: 9
Joined: 16 Oct 2006 21:04

Postby darianmiller » 08 Nov 2006 00:03

VLC_AddTarget() Anyone passing in options using Delphi with success? I haven't seen any samples on this and I'm running out of ideas.

Thanks,

Darian

BorPas
Blank Cone
Blank Cone
Posts: 15
Joined: 25 Aug 2006 12:38

Postby BorPas » 08 Nov 2006 12:46

I just do all needed VLC_setVariable before addTarget///

keypad
Blank Cone
Blank Cone
Posts: 17
Joined: 27 Sep 2006 17:50

Postby keypad » 08 Nov 2006 14:35

Hello !

I try VLD with Delphi and it works great !
However, i can enable goom effect by doing this

Code: Select all

val.AsPChar:= 'goom'; call('VLC_VariableSet',VLC_VariableSet(vlc,'conf::audio-visual',val));
but how can i disable it when i want to ?

thanks

keypad
Blank Cone
Blank Cone
Posts: 17
Joined: 27 Sep 2006 17:50

Postby keypad » 10 Nov 2006 09:27

Hello !

I just want to inform you that i find the answer...
To disable the goom effect, just do this !

Code: Select all

val.AsPChar:= '0'; call('VLC_VariableSet',VLC_VariableSet(vlc,'conf::audio-visual',val));
it works perfectly ! :wink:

BorPas
Blank Cone
Blank Cone
Posts: 15
Joined: 25 Aug 2006 12:38

Postby BorPas » 11 Nov 2006 14:59

by the way, did anyone succeed in changing parameters of vout and aout in realtime : you know, to make something like this using libvlc.dll ?

Code: Select all

vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE); if( p_vout == NULL ) { switch( event.GetId() ) { case Hue_Event: config_PutInt( p_intf , "hue" , event.GetPosition() ); break; ............... }
any the same with p_aout ...


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 44 guests