]> git.sesse.net Git - vlc/blob - bindings/cil/src/media.cs
Cleanup instance and media class
[vlc] / bindings / cil / src / media.cs
1 /**
2  * @file media.cs
3  * @brief Media descriptor class
4  * @ingroup API
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2007-2009 RĂ©mi Denis-Courmont.                      *
9  *  This program is free software; you can redistribute and/or modify *
10  *  it under the terms of the GNU General Public License as published *
11  *  by the Free Software Foundation; version 2 of the license, or (at *
12  *  your option) any later version.                                   *
13  *                                                                    *
14  *  This program is distributed in the hope that it will be useful,   *
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
17  *  See the GNU General Public License for more details.              *
18  *                                                                    *
19  *  You should have received a copy of the GNU General Public License *
20  *  along with this program; if not, you can get it from:             *
21  *  http://www.gnu.org/copyleft/gpl.html                              *
22  **********************************************************************/
23
24 using System;
25 //using System.Collections.Generic;
26 using System.Runtime.InteropServices;
27
28 namespace VideoLAN.LibVLC
29 {
30     /**
31      * @brief MediaHandle: unmanaged LibVLC media pointer
32      * @ingroup Internals
33      */
34     internal sealed class MediaHandle : NonNullHandle
35     {
36         protected override void Destroy ()
37         {
38             LibVLC.MediaRelease (handle);
39         }
40     };
41
42     /**
43      * @brief Media: a source media
44      * Use this class to extract meta-informations from a media.
45      */
46     public class Media : BaseObject
47     {
48         internal MediaHandle Handle
49         {
50             get
51             {
52                 return handle as MediaHandle;
53             }
54         }
55
56         /**
57          * Creates a Media object.
58          *
59          * @param instance VLC instance
60          * @param mrl Media Resource Locator (file path or URL)
61          */
62         public Media (VLC instance, string mrl)
63         {
64             U8String umrl = new U8String (mrl);
65
66             handle = LibVLC.MediaCreate (instance.Handle, umrl, ex);
67             Raise ();
68         }
69
70         public void AddOptions (string options, bool trusted)
71         {
72             U8String uopts = new U8String (options);
73
74             if (trusted)
75                 LibVLC.MediaAddOption (Handle, uopts, ex);
76             else
77                 LibVLC.MediaAddUntrustedOption (Handle, uopts, ex);
78             Raise ();
79         }
80     };
81 };