3 * @brief Bindings to LibVLC for the .NET Common Intermediate Language
6 * @defgroup API Managed interface to LibVLC
7 * This is the primary class library for .NET applications
8 * to embed and control LibVLC.
10 * @defgroup Internals LibVLC internals
11 * This covers internal marshalling functions to use the native LibVLC.
12 * Only VLC developpers should need to read this section.
15 /**********************************************************************
16 * Copyright (C) 2007-2009 RĂ©mi Denis-Courmont. *
17 * This program is free software; you can redistribute and/or modify *
18 * it under the terms of the GNU General Public License as published *
19 * by the Free Software Foundation; version 2 of the license, or (at *
20 * your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
25 * See the GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, you can get it from: *
29 * http://www.gnu.org/copyleft/gpl.html *
30 **********************************************************************/
33 using System.Runtime.InteropServices;
35 namespace VideoLAN.LibVLC
38 * @brief InstanceHandle: unmanaged LibVLC instance pointer
41 internal sealed class InstanceHandle : NonNullHandle
43 [DllImport ("libvlc.dll", EntryPoint="libvlc_get_version")]
44 public static extern IntPtr GetVersion ();
46 [DllImport ("libvlc.dll", EntryPoint="libvlc_get_compiler")]
47 public static extern IntPtr GetCompiler ();
49 [DllImport ("libvlc.dll", EntryPoint="libvlc_get_changeset")]
50 public static extern IntPtr GetChangeSet ();
52 [DllImport ("libvlc.dll", EntryPoint="libvlc_new")]
54 InstanceHandle Create (int argc, U8String[] argv,
57 /*[DllImport ("libvlc.dll", EntryPoint="libvlc_retain")]
58 public static extern void Hold (InstanceHandle h,
59 NativeException ex);*/
61 [DllImport ("libvlc.dll", EntryPoint="libvlc_release")]
62 private static extern void Release (IntPtr h,
65 [DllImport ("libvlc.dll", EntryPoint="libvlc_add_intf")]
66 public static extern void AddInterface (InstanceHandle h,
70 [DllImport ("libvlc.dll", EntryPoint="libvlc_wait")]
71 public static extern void Run (InstanceHandle h);
73 [DllImport ("libvlc.dll", EntryPoint="libvlc_get_vlc_instance")]
74 public static extern NonNullHandle GetVLC (InstanceHandle h);
76 protected override void Destroy ()
78 Release (handle, null);
83 * @brief VLC: VLC media player instance
86 * The VLC class provides represent a run-time instance of a media player.
87 * An instance can spawn multiple independent medias, however
88 * configuration settings, message logging, etc are common to all medias
89 * from the same instance.
91 public class VLC : BaseObject
93 internal InstanceHandle Handle
97 return handle as InstanceHandle;
102 * Loads the native LibVLC and creates a LibVLC instance.
104 * @param args VLC command line parameters for the LibVLC Instance.
106 public VLC (string[] args)
108 U8String[] argv = new U8String[args.Length];
109 for (int i = 0; i < args.Length; i++)
110 argv[i] = new U8String (args[i]);
112 handle = InstanceHandle.Create (argv.Length, argv, ex);
117 * Starts a VLC interface plugin.
119 * @param name name of the interface plugin (e.g. "http", "qt4", ...)
121 public void AddInterface (string name)
123 U8String uname = new U8String (name);
125 InstanceHandle.AddInterface (Handle, uname, ex);
130 * Waits until VLC instance exits. This can happen if a fatal error
131 * occurs (e.g. cannot parse the arguments), if the user has quit
132 * through an interface, or if the special vlc://quit item was played.
136 InstanceHandle.Run (Handle);
140 * The human-readable LibVLC version number.
142 public static string Version
146 return U8String.FromNative (InstanceHandle.GetVersion ());
151 * The human-readable LibVLC C compiler infos.
153 public static string Compiler
157 return U8String.FromNative (InstanceHandle.GetCompiler ());
162 * The unique commit identifier from the LibVLC source control system,
163 * or "exported" if unknown.
165 public static string ChangeSet
169 return U8String.FromNative (InstanceHandle.GetChangeSet ());
174 * The unmanaged VLC-internal instance object.
175 * Do not use this unless you really know what you are doing.
177 public SafeHandle Object
181 return InstanceHandle.GetVLC (Handle);