this is my test source code for libvlc..
On OSX i still can't get it to display video on a PB window.

On Windows it runs about 10 minutes and crashes unexpectedly.

On Linux it runs a lot better.. Not tested how long..

My experience so far working with external libs with PB on windows:
Using library calls within procedures most of all crashes PB (IMA),
- CallFunction or CallFunctionFast crash
- Import or ImportC some cases work
- Using a created PB User library also crash
Any help is welcome..
Code: Select all
; v windows
; v linux
; x macosx
; - opengl won't open, sometimes ascii caca output is selected:
; "no opengl provider module matching "default" could be loaded"
; struct
Structure mediacontrol_Instance
*p_instance;
*p_media_player;
EndStructure
Structure libvlc_exception
raised.l
code.l
message.s
EndStructure
Structure libvlc_log_message_t
sizeof_msg.l
i_severity.i
*psz_type.s
*psz_name.s
*psz_header.s
*psz_message.s
EndStructure
; global vars
Global Dim vlc_args.s(10)
; OS Specific..
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
Structure _GdkScreen Extends GdkScreen ; PB def seems to be incomplete
*font_options;
resolution.d
EndStructure
Structure GdkScreenX11
parent_instance._GdkScreen;
*display;
*xdisplay;
*xscreen;
EndStructure
Structure GdkDrawableImplX11
parent_instance.GdkDrawable
*wrapper;
*colormap;
xid.l
*screen
picture.l ;Picture
*cairo_surface;
EndStructure
Structure _GdkWindowObject ; PB def is empty!
parent_instance.GdkDrawable;
*impl.GdkDrawable
*parent;
user_data.l
EndStructure
Procedure XDisplayFromWindowID(*Window.GtkWidget)
*gdkwindowobj._GdkWindowObject = *Window\window
*impl.GdkDrawableImplX11 = *gdkwindowobj\impl
*screen.GdkScreenX11 = *impl\screen
ProcedureReturn *impl\xid ;*screen\xdisplay
EndProcedure
CompilerEndSelect
; procedures
Procedure Debug_Exception(cmd.s,ex.l,result.l=-1)
If ex
*exception.libvlc_exception=ex
If *exception\raised
Debug "Debug_Exception"
Debug cmd+" = "+Str(result)
Debug "libvlc_exception\raised="+Str(*exception\raised)
Debug "libvlc_exception\code="+Str(*exception\code)
Debug "libvlc_exception\message="+*exception\message
Debug " "
EndIf
EndIf
EndProcedure
Procedure.l getosdrawable()
drawable.l = 0
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
drawable=XDisplayFromWindowID(WindowID(0))
CompilerCase #PB_OS_Windows
drawable=WindowID(0)
CompilerCase #PB_OS_MacOS
drawable=GetWindowPort_(WindowID(0))
CompilerEndSelect
ProcedureReturn drawable
EndProcedure
Procedure.s getoslib()
lib$ = ""
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
lib$ = "/usr/lib/libvlc.so"
CompilerCase #PB_OS_Windows
lib$ = "C:\Program Files\VideoLAN\VLC\libvlc.dll"
CompilerCase #PB_OS_MacOS
lib$ = "/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib"
CompilerEndSelect
ProcedureReturn lib$
EndProcedure
Procedure.l setosarguments()
vlc_args(0) = "-I"
vlc_args(1) = "dummy"
vlc_args(2) = "--ignore-config"
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
vlc_args(3) = "--plugin-path=/usr/lib/vlc/codecs/"
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
vlc_args(3) = "--plugin-path=C:\\Program Files\\VideoLAN\\VLC\\plugins\\"
CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
vlc_args(3) = "--plugin-path=/Applications/VLC.app/Contents/MacOS/modules/"
CompilerEndIf
vlc_args(4) = "--mms-caching"
vlc_args(5) = "3200"
vlc_args(6) = "--http-caching"
vlc_args(7) = "3200"
EndProcedure
; local vars
lib$ = getoslib()
*mediacontrol.mediacontrol_Instance = 0
*inst = 0
ex.l = 0
wevent.l = 0
width.l = 0
height.l = 0
owidth.l = 0
oheight.l = 0
*log = 0
logcount.l = 0
count.l = 0
*it = 0
pos.f = 0
; Choose any media file..
location.s = "mms://media.omroep.nl/bobo01/1/media/tv/bnn/vangodlos/bb.20051001.asf"
; main
SetCurrentDirectory(GetPathPart(lib$))
If OpenLibrary(0, lib$)
If OpenWindow(0, 0, 0, 320,200, "", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)
SmartWindowRefresh(0, 1): SetWindowColor(0, RGB(0,0,0))
draw = getosdrawable()
setosarguments()
CallFunction(0, "libvlc_exception_init", @ex):
Debug_Exception("libvlc_exception_init", @ex)
*inst = CallFunction(0, "libvlc_new", 8,@vlc_args(),@ex)
Debug_Exception("libvlc_new", @ex)
*log = CallFunction(0, "libvlc_log_open", *inst, @ex)
Debug_Exception("libvlc_log_open", @ex)
CallFunction(0, "libvlc_set_log_verbosity", *log, 10000, @ex)
Debug_Exception("libvlc_set_log_verbosity", @ex)
If *inst And *log
CallFunction(0, "libvlc_video_set_parent", *inst, draw, @ex)
Debug_Exception("libvlc_video_set_parent", @ex)
*mediacontrol.mediacontrol_Instance = CallFunction(0, "mediacontrol_new_from_instance", *inst, @ex)
Debug_Exception("mediacontrol_new_from_instance", @ex)
CallFunction(0, "mediacontrol_set_mrl", *mediacontrol, location.s, @ex )
Debug_Exception("mediacontrol_set_mrl", @ex)
CallFunction(0, "mediacontrol_start", *mediacontrol, @pos.f, @ex )
Debug_Exception("mediacontrol_start", @ex)
If *mediacontrol.mediacontrol_Instance
Repeat
wevent = WindowEvent(): Delay(10)
logcount.l = CallFunction(0, "libvlc_log_count", *log, @ex.l)
Debug_Exception("libvlc_log_count", @ex)
If logcount
count.l=0
*it = CallFunction(0, "libvlc_log_get_iterator", *log, @ex)
Debug_Exception("libvlc_log_get_iterator", @ex)
If *it
msg.libvlc_log_message_t
While CallFunction(0, "libvlc_log_iterator_has_next", *it, @ex)
Debug_Exception("libvlc_log_iterator_has_next", @ex)
CallFunction(0, "libvlc_log_iterator_next", *it, @msg, @ex)
Debug_Exception("libvlc_log_iterator_next", @ex)
Debug "LOG_"+Str(count)
Debug "Type: "+msg\psz_type
Debug "Name: "+msg\psz_name
Debug "Header: "+msg\psz_header
Debug "Message: "+msg\psz_message
Debug " "
count+1
Wend
CallFunction(0, "libvlc_log_iterator_free", *it, @ex)
Debug_Exception("libvlc_log_iterator_free", @ex)
CallFunction(0, "libvlc_log_clear", *log, @ex)
Debug_Exception("libvlc_log_clear", @ex)
EndIf
EndIf
Until wevent = #PB_Event_CloseWindow
EndIf
CallFunction(0, "libvlc_release", *inst)
CallFunction(0, "libvlc_log_close", *log)
EndIf
CloseWindow(0)
EndIf
CloseLibrary(0)
EndIf
End