]> git.sesse.net Git - vlc/blob - bindings/cil/src/instance.cs
Cleanup instance and media class
[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         protected override void Destroy ()
40         {
41             LibVLC.Release (handle, null);
42         }
43     };
44
45     /**
46      * @brief VLC: VLC media player instance
47      * @ingroup API
48      *
49      * The VLC class provides represent a run-time instance of a media player.
50      * An instance can spawn multiple independent medias, however
51      * configuration settings, message logging, etc are common to all medias
52      * from the same instance.
53      */
54     public class VLC : BaseObject
55     {
56         internal InstanceHandle Handle
57         {
58             get
59             {
60                 return handle as InstanceHandle;
61             }
62         }
63
64         /**
65          * Loads the native LibVLC and creates a LibVLC instance.
66          *
67          * @param args VLC command line parameters for the LibVLC Instance.
68          */
69         public VLC (string[] args)
70         {
71             U8String[] argv = new U8String[args.Length];
72             for (int i = 0; i < args.Length; i++)
73                 argv[i] = new U8String (args[i]);
74
75             handle = LibVLC.Create (argv.Length, argv, ex);
76             Raise ();
77         }
78
79         /**
80          * Starts a VLC interface plugin.
81          *
82          * @param name name of the interface plugin (e.g. "http", "qt4", ...)
83          */
84         public void AddInterface (string name)
85         {
86             U8String uname = new U8String (name);
87
88             LibVLC.AddIntf (Handle, uname, ex);
89             Raise ();
90         }
91
92         /**
93          * Waits until VLC instance exits. This can happen if a fatal error
94          * occurs (e.g. cannot parse the arguments), if the user has quit
95          * through an interface, or if the special vlc://quit item was played.
96          */
97         public void Run ()
98         {
99             LibVLC.Wait (Handle);
100         }
101
102         /**
103          * The human-readable LibVLC version number.
104          */
105         public static string Version
106         {
107             get
108             {
109                 return U8String.FromNative (LibVLC.GetVersion ());
110             }
111         }
112
113         /**
114          * The human-readable LibVLC C compiler infos.
115          */
116         public static string Compiler
117         {
118             get
119             {
120                 return U8String.FromNative (LibVLC.GetCompiler ());
121             }
122         }
123
124         /**
125          * The unique commit identifier from the LibVLC source control system,
126          * or "exported" if unknown.
127          */
128         public static string ChangeSet
129         {
130             get
131             {
132                 return U8String.FromNative (LibVLC.GetChangeset ());
133             }
134         }
135
136         /**
137          * The unmanaged VLC-internal instance object.
138          * Do not use this unless you really know what you are doing.
139          */
140         public SafeHandle Object
141         {
142             get
143             {
144                 return LibVLC.GetVLCInstance (Handle);
145             }
146         }
147     };
148 };