C# Wrapper for libvlc 0.9.0 - Testers Required

This forum is about all development around libVLC.
twilight tinker
New Cone
New Cone
Posts: 5
Joined: 25 May 2008 15:45
Location: San Francisco, CA

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby twilight tinker » 26 Aug 2008 18:36

Hi,

I appreciate your taking the time to discuss this issue...

I was not aware of System.Threading.Thread.BeginThreadAffinity--and I will try it.

However, did you know that if you take any of the several C# wrapper previosly done for libvlc and call DLLImport in "separate threads" you do NOT keep seperate instances of the library? TRY IT....
Look at the handles from each instance--they should all be the number 1... When you create the first instance the handle is number 1. And any ther instances created on threads should ALSO be number 1, but they 1, 257, 288, etc. indicating that you have shared resources which means that one instance can crap out another player--which is what happens in testing.

Marx
Blank Cone
Blank Cone
Posts: 21
Joined: 08 Jun 2008 12:17

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Marx » 27 Aug 2008 08:47

However, did you know that if you take any of the several C# wrapper previosly done for libvlc and call DLLImport in "separate threads" you do NOT keep seperate instances of the library?


That's why we use System.Threading.Thread.BeginThreadAffinity. .NET threads are not real physical threads and thus share resources. Its the same as starting multiple instances of an application.

santiagokci
New Cone
New Cone
Posts: 1
Joined: 28 Aug 2008 01:18

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby santiagokci » 28 Aug 2008 01:24

Hi Max, at first, really great work with the wrapper. Sorry if I will ask a newbbie question (and for my bad english too) but I really want to know if there is any way to know if the current playing video alredy finish with your wrapper (some like an event?).

Thanks a lot for your time and for your work.
Santiago.

Demo55
New Cone
New Cone
Posts: 2
Joined: 21 Aug 2008 17:46

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Demo55 » 28 Aug 2008 12:45

Hi guys,

I want to use that wrapper in Windows Form Application. So How coul I set e.g. a PictureBox as "videooutput" for the video I want to play with that wrapper ?

Thx in advance,

Demo

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 » 28 Aug 2008 14:26

pass the .Handle member of the control you want to play in to video_set_parent.

Demo55
New Cone
New Cone
Posts: 2
Joined: 21 Aug 2008 17:46

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Demo55 » 28 Aug 2008 16:09

pass the .Handle member of the control you want to play in to video_set_parent.
Thx for your post. It's works.

maxwelllin
New Cone
New Cone
Posts: 1
Joined: 29 Aug 2008 18:05

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby maxwelllin » 29 Aug 2008 18:10

If I am interested, how to get the last version of wrapper

bratao
New Cone
New Cone
Posts: 7
Joined: 02 Sep 2008 22:38

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby bratao » 02 Sep 2008 22:41

I would love the lasest version too.

I´m doing a c++ wrapper for libvlc and will basing on your wrapper. So the lastest would save some work !

IanT
New Cone
New Cone
Posts: 1
Joined: 04 Sep 2008 12:24

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby IanT » 04 Sep 2008 20:28

I've just started using this for a project, very handy. Are there some updates coming soon?

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 05:47

I´m doing a c++ wrapper for libvlc and will basing on your wrapper. So the lastest would save some work !
I'm doing the same thing as you,but this is my work...And now my biggest problem is,when using the API of VLC,it requires some structures(such as "libvlc_instance_t"),and in these structures there're other structures,in other structures there're other structures...All these structures are declared in header files of VLC or cygwin.If I copy all the declaration of the structures to the header files of my project,that costs a lot of time;if I include all the header files of VLC and cygwin which related to,that make compiling errors(such as "inttypes.h","_types.h",can't pass compiling..).How to solve this problem?I don't know why <C# Wrapper for libvlc 0.9.0> doesn't need to either include .h files or declare structures...
Thank you.

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)?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 31 guests