C# Wrapper for libvlc 0.9.0 - Testers Required

This forum is about all development around libVLC.
Koalar
Blank Cone
Blank Cone
Posts: 14
Joined: 12 Sep 2008 03:32

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Koalar » 12 Sep 2008 14:28

My problem has been solved.I wrote the structures by myself,for example:
typedef struct libvlc_instance_t
{
BYTE bytData[3000000];
} libvlc_instance_t;
It is big enough to receive data,so the problem has been solved... :shock:
Thank you Marx,your code helps me a lot,thank you very much!

cybercockroach
Blank Cone
Blank Cone
Posts: 19
Joined: 11 Jul 2008 03:35

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby cybercockroach » 15 Sep 2008 03:51

Hi Marx
Is it possible to get the series of images(may be Bitmap) before render to Target window by using the C# wrapper?or Is there another way to do something like that under Windows Form?

Thanks

luesak
New Cone
New Cone
Posts: 1
Joined: 24 Sep 2008 09:15

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby luesak » 24 Sep 2008 09:23

Good job done here.

One thing I found that was a problem for me working with non-english/unicode/UTF-8 filenames is that VLC wouldn't play the file.
To solve this problem... we need to modify the type of the filename string as shown below.

[DllImport("libvlc")]
private static extern VLCMediaHandle libvlc_media_new(VLCCoreHandle vlcCoreHandle, [MarshalAs(UnmanagedType.LPArray)] byte[] mri, ref VLCExceptionDetails ex);


Because the original C++ function definition was: char*, it is not completely accurate to send Uris into libvlc.dll as string. A String type in C# is Unicode (UTF-16) while libvlc.dll uses UTF-8! So no non-english Uris!!!

The code above solves this problem. To set a new media do this.

UTF8Encoding utf8 = new UTF8Encoding();
vlcMediaHandle = libvlc_media_new(vlcCoreHandle, utf8.GetBytes(link), ref ex);

ekennedy
Blank Cone
Blank Cone
Posts: 38
Joined: 18 Sep 2008 22:05
VLC version: 1.0
Operating System: Windows
Location: Texas

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby ekennedy » 24 Sep 2008 18:56

Where is the latest version of the wrapper???

corvusvideo
Blank Cone
Blank Cone
Posts: 29
Joined: 03 Mar 2008 16:14

Has anyone gotten "video_take_snapshot" to work?

Postby corvusvideo » 30 Sep 2008 14:27

I am trying to use the "video_take_snapshot" method. It thinly wraps "libvlc_video_take_snapshot". No exception is raised, and a file is created, but the file is always 0 bytes in size and (obviously) does not contain an image.

All the parameters seem correct based on the API docs. I have tried bot explicitly setting the size and allowing the native size to be used (0,0 for width,height) but still nothing.

I have tried pausing first, and a number of other variations but still no luck. BTW I tried this with 0.9.2, 0.9.3, and the current nightly 0.9.4 and still luck.

Anyone know what I might be doing wrong? Has anyone ever gotten this to work?

mmackinze
New Cone
New Cone
Posts: 2
Joined: 03 Oct 2008 20:13

Re: Has anyone gotten "video_take_snapshot" to work?

Postby mmackinze » 03 Oct 2008 20:53

I was having the same problem, but i solved it copying every single dll that comes with the 0.9.2 win32 release, to the "bin/Debug" and "bin/Release".
It seems that it is not enough with just the libvlc.dll, libvlccore.dll and the plugins.

I hope it helps!
I am trying to use the "video_take_snapshot" method. It thinly wraps "libvlc_video_take_snapshot". No exception is raised, and a file is created, but the file is always 0 bytes in size and (obviously) does not contain an image.

All the parameters seem correct based on the API docs. I have tried bot explicitly setting the size and allowing the native size to be used (0,0 for width,height) but still nothing.

I have tried pausing first, and a number of other variations but still no luck. BTW I tried this with 0.9.2, 0.9.3, and the current nightly 0.9.4 and still luck.

Anyone know what I might be doing wrong? Has anyone ever gotten this to work?

mmackinze
New Cone
New Cone
Posts: 2
Joined: 03 Oct 2008 20:13

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby mmackinze » 03 Oct 2008 21:24

I had the same problem, and it seemed a little strange to me that first you have to play the video, and then you can set where the vlc should draw it.
Reading the documentation of vlc I've found that the libvlc_video_set_parent and its companion libvlc_video_get_parent, are deprecated and should not be used.
You must use the libvlc_media_player_set_drawable and libvlc_media_player_get_drawable methods instead.

In the wrapper they are located in the Marx_libvlc_media_player Class.
The two problems mentioned happen to be related.

Firstly, libvlc_media_player.video_set_parent(libvlc_core.Handle, hDT, ex) in my multithreaded version needs to be placed after the play() command, or else I get a deadlock and the interface freezes. I've also had to wrap it in a try/Catch block to handle the exception.

The exception appears to be coming from libvlc, but does not effect binding VLC's output to the window. So, I think there may be a some code that references a null pointer within libvlc, after it has attached the output to a window.
Also I see that getting of state is not yet implemented. Is there any other way to get state?
When I get a chance, I'll get the wrapper finished. I have only two portions to do now, libvlc_vlm and libvlc_event. I need to review how the events are managed and the best way to connect to them. In fact, for a basic media player, you can avoid using libvlc_event and lib_vlm. In terms of state info, there are a few commands that will give you some info, anything that I found to be lacking I just created flags for in the interface and kept track of the state that way.

Here is a copy of the latest build, I haven't had a chance to work on this the last few weeks, but I'll get back to it soon:

Marx libvlc Wrapper for 0.9.0 version 0.0.2 (Alpha Release)

http://www.2shared.com/file/3586524/6c4 ... apper.html

corvusvideo
Blank Cone
Blank Cone
Posts: 29
Joined: 03 Mar 2008 16:14

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby corvusvideo » 06 Oct 2008 13:48

Thanks mmackinze ! That did it. I really appreciate the help!
I was having the same problem, but i solved it copying every single dll that comes with the 0.9.2 win32 release, to the "bin/Debug" and "bin/Release".
It seems that it is not enough with just the libvlc.dll, libvlccore.dll and the plugins.

tpoll
New Cone
New Cone
Posts: 2
Joined: 06 Oct 2008 16:18

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby tpoll » 06 Oct 2008 16:42

Hi,

I'm having a problem stepping past libvlc_new when debugging in Visual Studio 2005. I'm using the Marx_libvlc_wrapper sample application and am only encountering this issue on one of two PCs. The build environment is the same for both PCs. I can successfully run Marx_libclv_wrapper_test.exe in a command window on the PC where I'm seeing a hang at libvlc_new. It's just when I run it in the debugger that it hangs.

Adding "-vvv" to the libvlc_new arg list results in output that ends with these lines:

[00000365] main preparser debug: waiting or thread initialization
[00000365] main preparser debug: thread started

Has anyone encountered a similar problem, or have any ideas what might be causing this hang?

Tim

burlo
New Cone
New Cone
Posts: 4
Joined: 05 Oct 2008 17:51

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby burlo » 09 Oct 2008 11:40

Very interesting.
I'll try to get some time to play with this.

mnn
New Cone
New Cone
Posts: 6
Joined: 12 Oct 2008 15:22

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby mnn » 12 Oct 2008 15:28

Interesting. I've tested it and it worked, however I'm concerned that there hasn't been any progres since approx. August so I assume that this is dead, but I hope that it isn't.

nicopam
New Cone
New Cone
Posts: 3
Joined: 18 Oct 2008 10:46

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby nicopam » 18 Oct 2008 13:46

Hi,
First of all thanks for your job, I found it very useful and well done.

I've done some tests however, and i have a big problem.

I have wrapped your library in a UserControl, with the following code:

Code: Select all

public void AddAndPlay(string fileName, string options) { if (working) return; this.locca(true); try { IntPtr hDT = this.Handle; bool forceGC = false; if (libvlc_media_player != null) { libvlc_media_player.Handle.Dispose(); libvlc_media_player = null; forceGC = true; } if (libvlc_media != null) { libvlc_media.Handle.Dispose(); libvlc_media = null; forceGC = true; } if (libvlc_core != null) { libvlc_core.Handle.Dispose(); libvlc_core = null; forceGC = true; } ArrayList opz = (ArrayList)StandardArgs.Clone(); if (!String.IsNullOrEmpty(options)) { foreach (string s in options.Split('\n')) { opz.Add(s); } } string[] aopz = (string[])opz.ToArray(typeof(string)); libvlc_core = new Marx_libvlc_core(aopz, ref ex); this.HandleRespose("new Marx_libvlc_core"); libvlc_media = new Marx_libvlc_media(libvlc_core.Handle, fileName, ref ex); this.HandleRespose("new Marx_libvlc_media"); libvlc_media_player = new Marx_libvlc_media_player(libvlc_media.Handle, ref ex); this.HandleRespose("new Marx_libvlc_media_player"); if (libvlc_media != null) { //Dispose of media Handle and force garbage collection libvlc_media.Handle.Dispose(); libvlc_media = null; forceGC = true; } if (forceGC) { GC.Collect(); GC.WaitForPendingFinalizers(); } #if DEPRECATED libvlc_media_player.play(ref ex); this.HandleRespose("libvlc_media_player.play"); libvlc_media_player.video_set_parent(libvlc_core.Handle, hDT, ref ex); // questa torna sempre un errore, per ora exClass.clear(ref ex); #else libvlc_media_player.set_drawable(hDT, ref ex); libvlc_media_player.play(ref ex); this.HandleRespose("libvlc_media_player.set_drawable"); #endif } catch (Exception excp) { this.HandleResposeNET("AddAndPlay", excp); } finally { this.locca(false); } }
I have also uploaded a complete example here http://www.2shared.com/file/4115030/356 ... inary.html, or here http://www.2shared.com/file/4115061/3f1 ... stVlc.html with all the binaries (BIG FILE! 13M), which is a (little) complete program that shows 4 vlc windows at the same time, from file and from streaming.
When I drop a multimedia file in every single control (download the example) everything works well, but if I drop a new file over a playing one, at times all freezes. The lock is in Marx_libvlc_media_player.stop, it never go out from there, I have also tried to modifiy the wrapper with this code:

Code: Select all

public void stop(ref libvlc_exception_struct ex) { Thread.BeginThreadAffinity(); Thread.BeginCriticalRegion(); libvlc_media_player_stop(libvlc_media_player_handle, ref ex); Thread.EndCriticalRegion(); Thread.EndThreadAffinity(); }
but it is the same.

Moreover, if one or more of the shown windows are from RTSP streaming, the program :
- stops with access violation, or
- throws unhandled exception in ntdll or
- throws unhandled exception in avcodec-51

Is this a problem of libvlc and this is not the proper thread?
How can I trap so low level errors?
How can I know that libvlc_media_player_stop has ended his work?

Really thanks for everything you will answare, I really need help.

topolittle
New Cone
New Cone
Posts: 4
Joined: 19 Oct 2008 15:34

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby topolittle » 19 Oct 2008 16:20

Marx,
Thanks for your great job.

I use the wrapper to display 2 players in panels controls playing rtsp stream or xvid content.
I got several problems with the stop function (libvlc_media_player_stop) and the release handle function (libvlc_media_player_release and libvlc_release).
When I stop the player, I got some intermittent errors:
- access violation or unhandled exception in libvlc_media_player_release or libvlc_release, or froze in these functions.
- the code hang in libvlc_media_player_stop and never return.
Since I have to change the playing content frequently, I need this to work.

I try several things, including debugging vlc with windbg, And I found that vlc in sometime unable to release it's mutex in libvlc_release (core.c). It is extremly difficult do debug since the vlc symbols is not compatible with windbg.

I found a workaround by modifyng the wrapper, but it is not the good way to correct the problem and it not work at 100%.
Instead of calling one of critical function in libvlc directly (libvlc_media_player_stop, libvlc_media_player_release, libvlc_release), I call it on a new thread, with and appropriate timeout and try/catch, like this for the stop function (in VB):

Code: Select all

Private _StopDone As Threading.ManualResetEvent Private ex_g As libvlc_exception_struct Public Sub [stop](ByRef ex As libvlc_exception_struct) Dim t As New Threading.Thread(AddressOf _StopThread) _StopDone = New Threading.ManualResetEvent(False) ex_g = ex t.Start() If Not _StopDone.WaitOne(3000, False) Then System.Diagnostics.Debug.WriteLine("Media_Player_Stop: TIMEOUT") End Sub Private Sub _StopThread() Dim ex As libvlc_exception_struct = ex_g libvlc_media_player_stop(libvlc_media_player_handle, ex) _StopDone.Set() End Sub
And for the release handle function:

Code: Select all

Private _ReleaseDone As Threading.ManualResetEvent Protected Overrides Function ReleaseHandle() As Boolean If (Not IsInvalid) Then _ReleaseDone = New Threading.ManualResetEvent(False) Dim t As New Threading.Thread(AddressOf _ReleaseThread) t.Start() If Not _ReleaseDone.WaitOne(3000, False) Then System.Diagnostics.Debug.WriteLine(Now & " Marx_libvlc_media_player_handle TIMEOUT") handle = IntPtr.Zero End If Return True End Function Private Sub _ReleaseThread() Try libvlc_media_player_release(Me) Catch System.Diagnostics.Debug.WriteLine(Now & " Marx_libvlc_media_player_handle FAIL") End Try _ReleaseDone.Set() End Sub
Is someone have similars problems ? Is someone have found a better workaround ? Is someone have a fix for libvlc/vlccore ?

davidhoyt
Blank Cone
Blank Cone
Posts: 68
Joined: 02 May 2008 03:26

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby davidhoyt » 20 Oct 2008 18:08


mihies
New Cone
New Cone
Posts: 3
Joined: 08 Mar 2008 13:44

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby mihies » 21 Oct 2008 20:53

Hi guys,

Did anybody think about providing video -> DirectX texture (either managed DirectX or XNA would be fantastic)?

surf_uk
New Cone
New Cone
Posts: 5
Joined: 23 Oct 2008 18:13

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby surf_uk » 23 Oct 2008 18:18

First thanks Marx for a great wrapper.

I'm not sure wich version I have of the wrapper and are unable to register any events, have these been implememted? if so where are the new versions?
I've spent the last few days building a C# wrapper to the new API. Anything that has been depreciated has been removed. So far, I've implemented most of the API and I'm able to play media files and attach the process to a
The following are yet to be implemented. If I get some time this weekend, I should get the bulk of it done.

libvlc_event
All I want to do is get a ibvlc_MediaPlayerEndReached

Thanks

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby publicENEMY » 24 Oct 2008 06:01

is this library compatible with the latest vlc(0.9.4)? is it actively developed? approximately, when can we expect an update?

thanks.

surf_uk
New Cone
New Cone
Posts: 5
Joined: 23 Oct 2008 18:13

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby surf_uk » 24 Oct 2008 11:30

All I want to do is get a ibvlc_MediaPlayerEndReached
I made a rubbish work-around:

Code: Select all

//declare timer timer = new Timer(); timer.Interval = 500; timer.Tick += new EventHandler(TimerOnTick); timer.Enabled = true; //do something when ended void TimerOnTick(object obj, EventArgs ea) { Console.WriteLine("Media position : " + Math.Ceiling(libvlc_media_player.get_position(ref ex)*100) + "%"); if (Math.Ceiling(libvlc_media_player.get_position(ref ex) * 100) > 99) { //do something useful } }
Are there any fully functional alternatives, such as (although I haven't tested them):

C#
http://meedios.svn.sourceforge.net/view ... Auxiliary/

Java:
http://mailman.videolan.org/pipermail/v ... 46719.html
Last edited by surf_uk on 24 Nov 2008 10:38, edited 1 time in total.

Flow
Blank Cone
Blank Cone
Posts: 14
Joined: 23 Nov 2006 20:31

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Flow » 24 Oct 2008 22:14

Hello,

I've worked on libvlc with C++
I would like to know how to use the wrapper to use libvlc with C#

Thank you.
Flo.

win32nipuh
New Cone
New Cone
Posts: 2
Joined: 26 Oct 2008 13:27

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby win32nipuh » 27 Oct 2008 09:58

How can I play FLV files (local and remote) using wrapper?

Regards

arogan
New Cone
New Cone
Posts: 3
Joined: 17 Dec 2007 03:16

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby arogan » 28 Oct 2008 20:38

All I want to do is get a ibvlc_MediaPlayerEndReached
I made a rubbish work-around:

Code: Select all

//declare timer timer = new Timer(); timer.Interval = 500; timer.Tick += new EventHandler(TimerOnTick); timer.Enabled = true; //do something when ended void TimerOnTick(object obj, EventArgs ea) { Console.WriteLine("Media position : " + Math.Ceiling(libvlc_media_player.get_position(ref ex)*100) + "%"); if (Math.Ceiling(libvlc_media_player.get_position(ref ex) * 100) > 99) { //do something useful } }
Are there any fully functional alternatives, such as (although I haven't tested them):

C#
http://meedios.svn.sourceforge.net/view ... Auxiliary/

Java:
http://mailman.videolan.org/pipermail/v ... 46719.html

I tried the meedios one and it worked fine. I'm having trouble finding some missing functionality. Specifically, I'm looking for the setVariable functions of old so I can send the hotkey presses to vlc (I used it for dvd navigation and other things).

basically I'm looking for something equivalent to:
enmErr = VLC_VariableSet(m_iVlcHandle, "key-pressed", valKey);

[DllImport("libvlc")]
static extern VlcError __var_Set(IntPtr p_vlc, String name, vlc_value_t value);

static extern Error VLC_VariableSet(int iVLC, string Name, vlc_value_t value);


Getting the meedios stuff running was quite easy:
Grab the gnu tarball for videolan.interop:
http://meedios.svn.sourceforge.net/view ... n.Interop/
add the project to your solution, add a project reference, add using VideoLan for the namespace.

Code: Select all

private VideoLan.VideoLanClient vlc; private VideoLan.VlcMediaPlayer video; //init stuff: vlc = new VideoLan.VideoLanClient(@"C:\Program Files\VideoLAN\VLC"); owner = yourcontrol; // (I used a picturebox) video = vlc.NewMediaPlayer(owner.Handle); //play a file: VideoLan.VlcMedia desc = vlc.NewMedia(aFile); video.Load(desc); desc.Dispose(); //cleanup when you are done playing the video: video.Dispose(); vlc.Dispose();

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Kairos » 28 Oct 2008 23:11

I tried the meedios one and it worked fine. I'm having trouble finding some missing functionality. Specifically, I'm looking for the setVariable functions of old so I can send the hotkey presses to vlc (I used it for dvd navigation and other things).

basically I'm looking for something equivalent to:
enmErr = VLC_VariableSet(m_iVlcHandle, "key-pressed", valKey);

[DllImport("libvlc")]
static extern VlcError __var_Set(IntPtr p_vlc, String name, vlc_value_t value);

static extern Error VLC_VariableSet(int iVLC, string Name, vlc_value_t value);
arogan, I'm glad you like the MeediOS wrapper. I wrote it to fit my needs, that's why I never got around to support the MediaList or vlm stuff. Unfortunately, the functionality your looking for no longer exists in libvlc. If you look at my source code you will see the '__var_Set' stuff is all there inside the VlcObject class under the folder obsolete. If you try to call any of those functions you will get an error saying 'the entry point could not be found'. I too miss those function because now there is no way to do on the fly adjustments of the basic filter settings like brightness, contrast, hue, gamma, and saturation.

arogan
New Cone
New Cone
Posts: 3
Joined: 17 Dec 2007 03:16

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby arogan » 28 Oct 2008 23:26

I tried the meedios one and it worked fine. I'm having trouble finding some missing functionality. Specifically, I'm looking for the setVariable functions of old so I can send the hotkey presses to vlc (I used it for dvd navigation and other things).

basically I'm looking for something equivalent to:
enmErr = VLC_VariableSet(m_iVlcHandle, "key-pressed", valKey);

[DllImport("libvlc")]
static extern VlcError __var_Set(IntPtr p_vlc, String name, vlc_value_t value);

static extern Error VLC_VariableSet(int iVLC, string Name, vlc_value_t value);
arogan, I'm glad you like the MeediOS wrapper. I wrote it to fit my needs, that's why I never got around to support the MediaList or vlm stuff. Unfortunately, the functionality your looking for no longer exists in libvlc. If you look at my source code you will see the '__var_Set' stuff is all there inside the VlcObject class under the folder obsolete. If you try to call any of those functions you will get an error saying 'the entry point could not be found'. I too miss those function because now there is no way to do on the fly adjustments of the basic filter settings like brightness, contrast, hue, gamma, and saturation.
LOL, I had just found your little \obsolete folder and hooked it all in getting all excited and boom got the 'the entry point could not be found'. Doh! Oh well. Thanks Karios for all the hard work. It was an incredibly clean and easy to follow/use wrapper. I will miss __var_set. I was using it to do all sorts of things like toggle audio tracks, cycle deinterlacing modes, aspect ratios, dvd menu navigation (arrow keys, enter), cycle subtitles, etc. Some things I see you can sort of duplicate through libvlc_audio and libvlc_video but not every thing. I don't see a way to set deinterlacing mode on the fly. Anyways, if anybody has any ideas how to duplicate some of the functionality I listed in this post 0.9.0 world please share.

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby publicENEMY » 29 Oct 2008 05:27

Kairos

Thank you for sharing your interop with us. Maybe you can start a new thread so that anyone can focus on developing or enhancing your interop. By the way, did you get to render vlc in wpf(i mean, full wpf features support)?

Thanks. Im gonna download it and test it.

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby publicENEMY » 29 Oct 2008 06:07

Kairos

I tried VideoLanPlayer.UI. Is there any particular reason that you choose panel as the video container? just curious.

thanks.

overall, i would say great effort.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 27 guests