]> git.sesse.net Git - vlc/blob - bindings/cil/src/instance.cs
Fix documentation
[vlc] / bindings / cil / src / instance.cs
1 /**
2  * @file instance.cs
3  * @brief Bindings to LibVLC for the .NET Common Intermediate Language
4  * @ingroup API
5  *
6  * @defgroup API Managed interface to LibVLC
7  * This is the primary class library for .NET applications
8  * to embed and control LibVLC.
9  */
10
11 /**********************************************************************
12  *  Copyright (C) 2007-2009 RĂ©mi Denis-Courmont.                      *
13  *  This program is free software; you can redistribute and/or modify *
14  *  it under the terms of the GNU General Public License as published *
15  *  by the Free Software Foundation; version 2 of the license, or (at *
16  *  your option) any later version.                                   *
17  *                                                                    *
18  *  This program is distributed in the hope that it will be useful,   *
19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
21  *  See the GNU General Public License for more details.              *
22  *                                                                    *
23  *  You should have received a copy of the GNU General Public License *
24  *  along with this program; if not, you can get it from:             *
25  *  http://www.gnu.org/copyleft/gpl.html                              *
26  **********************************************************************/
27
28 using System;
29 using System.Runtime.InteropServices;
30
31 namespace VideoLAN.LibVLC
32 {
33     /**
34      * @brief InstanceHandle: unmanaged LibVLC instance pointer
35      * @ingroup Internals
36      */
37     internal sealed class InstanceHandle : NonNullHandle
38     {
39         /**
40          * NonNullHandle.Destroy
41          */
42         protected override void Destroy ()
43         {
44             LibVLC.Release (handle, null);
45         }
46     };
47
48     /**
49      * @brief VLC: VLC media player instance
50      * @ingroup API
51      *
52      * The VLC class provides represent a run-time instance of a media player.
53      * An instance can spawn multiple independent medias, however
54      * configuration settings, message logging, etc are common to all medias
55      * from the same instance.
56      */
57     public class VLC : BaseObject
58     {
59         internal InstanceHandle Handle
60         {
61             get
62             {
63                 return handle as InstanceHandle;
64             }
65         }
66
67         /**
68          * Loads the native LibVLC and creates a LibVLC instance.
69          *
70          * @param args VLC command line parameters for the LibVLC Instance.
71          */
72         public VLC (string[] args)
73         {
74             U8String[] argv = new U8String[args.Length];
75             for (int i = 0; i < args.Length; i++)
76                 argv[i] = new U8String (args[i]);
77
78             handle = LibVLC.Create (argv.Length, argv, ex);
79             Raise ();
80         }
81
82         /**
83          * Starts a VLC interface plugin.
84          *
85          * @param name name of the interface plugin (e.g. "http", "qt4", ...)
86          */
87         public void AddInterface (string name)
88         {
89             U8String uname = new U8String (name);
90
91             LibVLC.AddIntf (Handle, uname, ex);
92             Raise ();
93         }
94
95         /**
96          * Waits until VLC instance exits. This can happen if a fatal error
97          * occurs (e.g. cannot parse the arguments), if the user has quit
98          * through an interface, or if the special vlc://quit item was played.
99          */
100         public void Run ()
101         {
102             LibVLC.Wait (Handle);
103         }
104
105         /**
106          * The human-readable LibVLC version number.
107          */
108         public static string Version
109         {
110             get
111             {
112                 return U8String.FromNative (LibVLC.GetVersion ());
113             }
114         }
115
116         /**
117          * The human-readable LibVLC C compiler infos.
118          */
119         public static string Compiler
120         {
121             get
122             {
123                 return U8String.FromNative (LibVLC.GetCompiler ());
124             }
125         }
126
127         /**
128          * The unique commit identifier from the LibVLC source control system,
129          * or "exported" if unknown.
130          */
131         public static string ChangeSet
132         {
133             get
134             {
135                 return U8String.FromNative (LibVLC.GetChangeset ());
136             }
137         }
138
139         /**
140          * The unmanaged VLC-internal instance object.
141          * Do not use this unless you really know what you are doing.
142          */
143         public SafeHandle Object
144         {
145             get
146             {
147                 return LibVLC.GetVLCInstance (Handle);
148             }
149         }
150     };
151 };