C# Wrapper for libvlc 0.9.0 - Testers Required

This forum is about all development around libVLC.
jshort86
New Cone
New Cone
Posts: 4
Joined: 04 Nov 2008 17:05

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby jshort86 » 07 Nov 2008 12:33

Hi

I was wondering if this .NET wrapper is available for download, as I am trying to find a .NET wrapper which will allow me to stream video from my VB.NET application through the libvlc class?

Any feedback would be greatly appreciated?

Best Regards
Jack


jshort86
New Cone
New Cone
Posts: 4
Joined: 04 Nov 2008 17:05

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby jshort86 » 07 Nov 2008 16:11

Hi

Thanks thats great I have the file now.

I was wondering if I could get some help in setting this up from my VB.NET application.

Am I able to use imports or do I need to use DLLIMPORT to set this up.

And can someone confirm that this library will allow me to stream video over UDP, from my VB.NET application?

Thanks
Jack

Zeussy
New Cone
New Cone
Posts: 1
Joined: 08 Nov 2008 11:58

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Zeussy » 08 Nov 2008 13:25

thanks for the great wrapper, been very useful so far. Building a touch screen interface for my media box.

We watch a lot of anime in this house :) So being able to list and set the subtitle track is important. Currently I am just using the arguments for libvlc_core to specify my preference, but that does not help if the subtitle track has been named something obscure like "Styled Subs". Setting the sub track ID is not preferable just in case there are other language subs and English is not the first in the list. Is there a way to get the subtitles listed. I cannot see any way in the libvlc documentation, or in the wrapper. Perhaps I overlooked something?

Thanks in advance.

benshole
New Cone
New Cone
Posts: 6
Joined: 29 Sep 2008 18:06

Changing Media

Postby benshole » 13 Nov 2008 19:13

Hey Guys,

Using the C# wrapper in an application and i need to rapidly change from one piece of media to another.

I *assumed* this could be done by re-initiating a libvlc_media object with a new file path. Then assign the libvlc_media_player the changed media object.

When i do this i get an exception about the libvlc_core handle being invalid on the media object the 2nd time it is called.
I havn't disposed of the core object or modified it in any way. So its a little perplexing!

Also hopefully just a small one that i have missed in the thread somewhere.
In the wrapper the get_time and get_length calls were missing. If anyone needs these calls i have built a modified dll containing them.

Thanks a lot!

Ben

sun_yiqin
New Cone
New Cone
Posts: 4
Joined: 11 Nov 2008 03:08

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby sun_yiqin » 14 Nov 2008 08:35

Thanks for the wrapper, It is really nice. Sorry for my poor English...
Now I am trying to play a kind of TS stream from a TV usb device. The stream contain 3 channels at the same time.
I can switch by using the VLC player, just need to change the Playback-->Programm on the navigater.

How can I do the same thing by using the wrapper? I want to separate the 3 channels.
Any one can help me? Thanks very much!

BexX
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2008 00:26

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby BexX » 17 Nov 2008 14:48

You are setting up the frequency and the other stuff, by adding mrl-options to your mediadiscriptor, right? Then you just have to add ":programs=[SID]" as option to your mediadiscriptor objekt.

sun_yiqin
New Cone
New Cone
Posts: 4
Joined: 11 Nov 2008 03:08

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby sun_yiqin » 20 Nov 2008 03:10

You are setting up the frequency and the other stuff, by adding mrl-options to your mediadiscriptor, right? Then you just have to add ":programs=[SID]" as option to your mediadiscriptor objekt.
You mean "libvlc_media.add_option(options, ref ex);"? I tried setting the options as you said, but it doesn't work. What does the "SID" mean? Is it the program ID of the TS stream? But the program ID is always changing.

drainey
New Cone
New Cone
Posts: 6
Joined: 06 May 2008 06:17

VB.net samples

Postby drainey » 20 Nov 2008 08:15

I am after a VB.net sample using the wrapper. Does anyone have such a beast? A working example of would be greatly appreciated. Even if it in C# i will port to VB and post for others to use.

BexX
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2008 00:26

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby BexX » 22 Nov 2008 14:04

Hi guys:
Sorry if is not the correct forum, but I'm very interesting in use and help with the .NET interface for VLC, so my question is where can I get a fresh copy of the source or where can a check out the last version (svn repo?).
I would suggest using this wrapper instead:
viewtopic.php?f=14&t=52021&start=15
1) I'm a c#/mono programmer so I wonder if someone test this libvlc wrapper in c# on linux?
both wrappers work, with some few modifications. i am going to post my changes to the meedios wrapper in the corresponding thread.
2) the current wrapper is not a wrapper arround a ActiveX control right?
no
3) the native function wrappers are also in C# not VS.NET C++ right?
and finally...
no
4) what is the current status of the vlc streaming capabilities of LibVlc and/or the .NET wrapper?
does work, by adding stream output options to the mrl.
You are setting up the frequency and the other stuff, by adding mrl-options to your mediadiscriptor, right? Then you just have to add ":programs=[SID]" as option to your mediadiscriptor objekt.
You mean "libvlc_media.add_option(options, ref ex);"? I tried setting the options as you said, but it doesn't work. What does the "SID" mean? Is it the program ID of the TS stream? But the program ID is always changing.
SID is the service identifier that should be in any DVB stream. Imho it describes the Video and Audio PIDs belonging to a channel.
Here is some Code i wrote for the meedios Wrapper mentioned above:

Code: Select all

// Main.cs created with MonoDevelop // User: bexx at 1:15 AM 11/20/2008 // // To change standard headers go to Edit->Preferences->Coding->Standard Headers // using System; using VideoLan; using System.Threading; namespace DVBsharp { public interface VlcDvbChannel { String[] mrlOptions { get; } } public class SChannel : VlcDvbChannel { private readonly String name; private readonly int frequency; private readonly int symbolrate; private readonly int sid; private readonly bool horizontal; public SChannel(String name, int frequency, int symbolrate, int sid, bool horizontal) { this.name = name; this.frequency = frequency; this.symbolrate = symbolrate; this.sid = sid; this.horizontal = horizontal; } public String Name { get { return name; } } public int Frequency { get { return frequency; } } public int Symbolrate { get { return symbolrate; } } public int Sid { get { return sid; } } public bool isHorizontal { get { return horizontal; } } public String[] mrlOptions { get { return new String[] {":dvb-frequency="+frequency, ":dvb-srate="+symbolrate, ":dvb-voltage="+(horizontal?"18":"13"), ":program="+sid}; } // program does work for streaming, but does not for playing } } class MainClass { public static void Main(string[] args) { // init libvlc VideoLanClient vlc = new VideoLanClient(new String[]{}); // mrl VlcMedia media = vlc.NewMedia("dvb://"); SChannel chan1 = new SChannel("Das Erste", 11836000, 27500000, 28106, true); foreach (string option in chan1.mrlOptions) media.AddOption(option); //player VlcMediaPlayer player = vlc.NewMediaPlayer(IntPtr.Zero, media); player.StateChanged += new EventHandler<StateChangedEventArgs>(StateChanged); // Thread.Sleep(10000); player.Play(); Thread.Sleep(10000); player.Video.FullScreen = true; Thread.Sleep(30000); player.Stop(); } private static void StateChanged(object sender, StateChangedEventArgs e) { Console.WriteLine("State: " + e.NewState); } } }
This is working on ubuntu with an new VideoLanClient Constructor, and should work on windows, when you adjust the "mrlOptions" property to your needs.

benshole
New Cone
New Cone
Posts: 6
Joined: 29 Sep 2008 18:06

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby benshole » 24 Nov 2008 13:00

I think i found a solution to the problem i was having changing media. I thought i would just throw it up here incase anyone else was having a similar issue.

The problem i was having was that when calling video_set_parent the libvlc_core object was losing its handle.
I sorted it by creating a new instance of lib_vlc core and all other object whenever changing media. I initially didnt think about doing this as i thought it would mean waiting for VLC to load in the background again. However this doesn't seem to be the case.

However there is still an issue when closing the forms application as it appears VLC doesn't die gracefully. I get a debug request whenever i close the program.
I'm not sure if this is due to libvlc or the c# wrapper. But its certainly annoying thats for sure!

Beardless2
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 02 Feb 2007 09:53

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Beardless2 » 23 Dec 2008 15:36

"However there is still an issue when closing the forms application as it appears VLC doesn't die gracefully. I get a debug request whenever i close the program.
I'm not sure if this is due to libvlc or the c# wrapper. But its certainly annoying thats for sure!"

I think its libvlc. I have used a Delphi wrapper and the ActiveX plugins and i have problems with destroying vlc. Stopping the video before destroying does seem to help a bit but i am still getting it to hang.

e.beckers
New Cone
New Cone
Posts: 5
Joined: 23 Dec 2008 15:10

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby e.beckers » 23 Dec 2008 15:48

Hi

I think there is a memory leak in the "C#" wrapper.
I've made a small simple application which plays 1 video over and over again.
The more times you play the video, the more memory gets consumed until you reach a point where the system is out of memory.
On my pc it leaks +/- 512Kbyte for each time the file gets played.
Note that the memory leak does not happen when playing the file in VLC.exe itself

For those interested, the demo app (with source) can be downloaded from:
http://www.sendspace.com/file/ngmgej

to test simply:
- donwload & unrar it to a folder
- run it (VlcMemoryLeak\VlcMemoryLeak\bin\Debug\VlcMemoryLeak.exe)
- click on the open file button and select a movie
- when its playing the movie, take a note of the memory usage in the task manager
- wait until movie is played >10 times
- look at the memory usage in the task manager again...

T0T4L
New Cone
New Cone
Posts: 6
Joined: 04 May 2007 20:44

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby T0T4L » 17 Jan 2009 19:00

Hello guys,

I need to know if it's possible to set a Buffertime (ora http caching) and how using this wrapper.

Thanks in advance!

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby elund » 27 Jan 2009 15:20

Sorry, I've been busy on project work. I'll be releasing the source of the Media player interface and wrapper soon.
Hi Marx!

Nice work! Did you ever release the source of the Media Player interface?

I want to test your C# Wrapper, because I have some problems with the other 2 wrappers discussed in this forum.
A GUI would be very nice for a flying start :)

Thanks in advance, Elund

astlin
New Cone
New Cone
Posts: 3
Joined: 27 Jan 2009 12:25

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby astlin » 27 Jan 2009 20:04

exception while running Marx_libvlc_wrapper_test.exe: System.BadImageFormatException:
HRESULT: 0x8007000B
в Marx_libvlc_wrapper.Marx_libvlc_exception.libvlc_exception_init(libvlc_exception_struct& ex)
в Marx_libvlc_wrapper.Marx_libvlc_exception.init(libvlc_exception_struct& ex) в C:\Users\DNA User\Documents\Visual Studio 2008\Projects\Ma
rx_libvlc_wrapper\Marx_libvlc_wrapper\Marx_libvlc_exception.cs:line 50
в Marx_libvlc_wrapper.Marx_libvlc_exception..ctor(libvlc_exception_struct& ex) в C:\Users\DNA User\Documents\Visual Studio 2008\Projects\M
arx_libvlc_wrapper\Marx_libvlc_wrapper\Marx_libvlc_exception.cs:line 41
в Marx_libvlc_wrapper_test.Program.Main(String[] args) в C:\Users\DNA User\Documents\Visual Studio 2008\Projects\Marx_libvlc_wrapper\Marx_
libvlc_wrapper_test\Program.cs:line 49

using vlc 0.9.4, any ideas?

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby elund » 28 Jan 2009 11:51

Hi!

Can someone sketch how to create and use a Marx_libvlc_media_list object?

Thanks in advance, Elund

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby elund » 29 Jan 2009 10:56

Can someone sketch how to create and use a Marx_libvlc_media_list object?
Is there missing an implementation of libvlc_media_list_player in the Marx C# Wrapper?

Best regards, Elund

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby elund » 02 Feb 2009 15:59

Is there missing an implementation of libvlc_media_list_player in the Marx C# Wrapper?
I have now implemented Marx_libvlc_media_list_player:

Code: Select all

using System; using System.Runtime.InteropServices; using System.IO; namespace Marx_libvlc_wrapper { #region Handle for libvlc_media_list_player public class Marx_libvlc_media_list_player_handle : SafeHandle { public Marx_libvlc_media_list_player_handle() : base(IntPtr.Zero, true) { } public override bool IsInvalid { get { return handle == IntPtr.Zero; } } protected override bool ReleaseHandle() { if (!IsInvalid) { libvlc_media_list_player_release(this); handle = IntPtr.Zero; } return true; } protected override void Dispose(bool disposing) { ReleaseHandle(); base.Dispose(disposing); } [DllImport("libvlc")] private static extern void libvlc_media_list_player_release(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle); } #endregion public class Marx_libvlc_media_list_player { private Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle; #region Constructor public Marx_libvlc_media_list_player(Marx_libvlc_core_handle libvlc_core_handle, ref libvlc_exception_struct ex) { libvlc_media_list_player_handle = libvlc_media_list_player_new(libvlc_core_handle, ref ex); } #endregion #region Properties public Marx_libvlc_media_list_player_handle Handle { get { return libvlc_media_list_player_handle; } } #endregion #region Methods public void set_media_player(Marx_libvlc_media_player_handle libvlc_media_player_handle, ref libvlc_exception_struct ex) { libvlc_media_list_player_set_media_player(libvlc_media_list_player_handle, libvlc_media_player_handle, ref ex); } public void set_media_list(Marx_libvlc_media_list_handle libvlc_media_list_handle, ref libvlc_exception_struct ex) { libvlc_media_list_player_set_media_list(libvlc_media_list_player_handle, libvlc_media_list_handle, ref ex); } public void play(ref libvlc_exception_struct ex) { libvlc_media_list_player_play(libvlc_media_list_player_handle, ref ex); } public void pause(ref libvlc_exception_struct ex) { libvlc_media_list_player_pause(libvlc_media_list_player_handle, ref ex); } public int is_playing(ref libvlc_exception_struct ex) { return libvlc_media_list_player_is_playing(libvlc_media_list_player_handle, ref ex); } //TODO: libvlc_state public void play_item_at_index(int index, ref libvlc_exception_struct ex) { libvlc_media_list_player_play_item_at_index(libvlc_media_list_player_handle, index, ref ex); } public void play_item(Marx_libvlc_media_handle libvlc_media_handle, ref libvlc_exception_struct ex) { libvlc_media_list_player_play_item(libvlc_media_list_player_handle, libvlc_media_handle, ref ex); } public void stop(ref libvlc_exception_struct ex) { libvlc_media_list_player_stop(libvlc_media_list_player_handle, ref ex); } public void next(ref libvlc_exception_struct ex) { libvlc_media_list_player_next(libvlc_media_list_player_handle, ref ex); } #endregion #region DLL Imports [DllImport("libvlc")] private static extern Marx_libvlc_media_list_player_handle libvlc_media_list_player_new(Marx_libvlc_core_handle libvlc_core_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern void libvlc_media_list_player_release(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle); [DllImport("libvlc")] private static extern void libvlc_media_list_player_set_media_player(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, Marx_libvlc_media_player_handle libvlc_media_player_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern void libvlc_media_list_player_set_media_list(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, Marx_libvlc_media_list_handle libvlc_media_list_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern void libvlc_media_list_player_play(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern void libvlc_media_list_player_pause(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern int libvlc_media_list_player_is_playing(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, ref libvlc_exception_struct ex); //TODO: libvlc_state [DllImport("libvlc")] private static extern void libvlc_media_list_player_play_item_at_index(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, int index, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern int libvlc_media_list_player_play_item(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, Marx_libvlc_media_handle libvlc_media_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern void libvlc_media_list_player_stop(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, ref libvlc_exception_struct ex); [DllImport("libvlc")] private static extern void libvlc_media_list_player_next(Marx_libvlc_media_list_player_handle libvlc_media_list_player_handle, ref libvlc_exception_struct ex); #endregion } }
I can add media's to a media_list: libvlc_media_list.add_media(libvlc_media.Handle, ref ex);
I can play items at a certain index: libvlc_media_list_player.play_item_at_index(2, ref ex);

But when I call libvlc_media_list_player.play(ref ex); I had expected that it plays all the items in the list.

Is this a wrong understanding of libvlc? Or what do I miss?

Best regards, Elund

tamiro44
Cone that earned his stripes
Cone that earned his stripes
Posts: 131
Joined: 15 Feb 2009 15:21

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby tamiro44 » 15 Feb 2009 16:25

Hi Marx,
Is there any API for setting text on top of the video?
It should be important for various usages and i saw vlc allow this
at the original GUI.

Thanks,
Tamiro.

Jeremiah
Blank Cone
Blank Cone
Posts: 53
Joined: 16 Oct 2008 09:31

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby Jeremiah » 05 Mar 2009 11:18

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);
does anyone konw how to do like this about changing the libvlc_new() function of the parameter args?

Code: Select all

[DllImport("libvlc")] private static extern CoreHandle libvlc_new(int argc, string[] args, ref ExceptionStruct ex);
i got puzzled......

blich
New Cone
New Cone
Posts: 2
Joined: 12 Mar 2009 00:53

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby blich » 12 Mar 2009 01:05

Can somebody post a link to the latest version of this? I tried one a link earlier in the thread, but I get the following message when I try to run it. Any ideas?

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at WinControls.VlcWrapper.Marx_libvlc_exception.libvlc_exception_init(libvlc_exception_struct& ex)
at WinControls.VlcWrapper.Marx_libvlc_exception.init(libvlc_exception_struct& ex) in C:\Users\brianlic\Desktop\oi\TestVlc\VlcWrapper\Marx_libvlc_exception.cs:line 50
at WinControls.VlcWrapper.Marx_libvlc_exception..ctor(libvlc_exception_struct& ex) in C:\Users\brianlic\Desktop\oi\TestVlc\VlcWrapper\Marx_libvlc_exception.cs:line 41
at WinControls.VlcWrapper.VlcWrapperUserControl.OnLoad(EventArgs e) in C:\Users\brianlic\Desktop\oi\TestVlc\VlcWrapper\VlcWrapperUserControl.cs:line 131
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

tamiro44
Cone that earned his stripes
Cone that earned his stripes
Posts: 131
Joined: 15 Feb 2009 15:21

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby tamiro44 » 12 Mar 2009 09:07

I think that at the bottom of page two but i'll glad to newer version

Marx libvlc Wrapper for 0.9.0 version 0.0.2 (Alpha Release)
http://www.2shared.com/file/3586524/6c4 ... apper.html

mohamnag
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Mar 2009 16:04

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby mohamnag » 12 Mar 2009 16:31

Hi there,
greate job, I used this lib to play an stream from network but I was unable to find out how to save that stream to a file. It would be much better if I was able to pass the config strings that VLC itself builds to this lib. I mean if I can pass it something like ":sout=#duplicate{dst=display,dst=std{access=file,dst=D:\ghfghg.ps}}" to say the lib to save my stream.
Is there any way?

blich
New Cone
New Cone
Posts: 2
Joined: 12 Mar 2009 00:53

Re: C# Wrapper for libvlc 0.9.0 - Testers Required

Postby blich » 12 Mar 2009 22:17

Weird. I still get the same exception. Is this supported on x64? (Sorry, VLC dev noob).


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 34 guests