Commit 66af5fd9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Some more doc

parent a1251a8d
...@@ -31,15 +31,27 @@ namespace VideoLAN.LibVLC ...@@ -31,15 +31,27 @@ namespace VideoLAN.LibVLC
*/ */
public class VLCException : Exception public class VLCException : Exception
{ {
/**
* Creates a managed VLC exception.
*/
public VLCException () public VLCException ()
{ {
} }
/**
* Creates a managed VLC exception.
* @param message exception error message
*/
public VLCException (string message) public VLCException (string message)
: base (message) : base (message)
{ {
} }
/**
* Creates a managed VLC exception wrapping another exception.
* @param message exception error message
* @param inner inner wrapped exception
*/
public VLCException (string message, Exception inner) public VLCException (string message, Exception inner)
: base (message, inner) : base (message, inner)
{ {
...@@ -72,6 +84,10 @@ namespace VideoLAN.LibVLC ...@@ -72,6 +84,10 @@ namespace VideoLAN.LibVLC
Init (this); Init (this);
} }
/**
* Throws a managed exception if LibVLC has returned a native
* unmanaged exception. Clears the native exception.
*/
public void Raise () public void Raise ()
{ {
try try
...@@ -86,6 +102,7 @@ namespace VideoLAN.LibVLC ...@@ -86,6 +102,7 @@ namespace VideoLAN.LibVLC
} }
} }
/** IDisposable implementation. */
public void Dispose () public void Dispose ()
{ {
Clear (this); Clear (this);
......
/* /**
* libvlc.cs - libvlc-control CIL bindings * @file libvlc.cs
* @brief libvlc-control CIL bindings
* *
* $Id$ * $Id$
*/ */
...@@ -27,8 +28,25 @@ using System.Runtime.InteropServices; ...@@ -27,8 +28,25 @@ using System.Runtime.InteropServices;
namespace VideoLAN.LibVLC namespace VideoLAN.LibVLC
{ {
/**
* The VLC class is used to create LibVLC Instance objects.
* The VLC class has only one static method and cannot be instanciated.
*
* @code
* string[] argv = new string[]{ "-vvv", "-I", "dummy" };
*
* Instance vlc = VLC.CreateInstance (argv);
* @endcode
*/
public sealed class VLC public sealed class VLC
{ {
/**
* Loads native LibVLC and creates a LibVLC instance.
*
* @param args VLC command line parameters for the LibVLC Instance.
*
* @return a new LibVLC Instance
*/
public static Instance CreateInstance (string[] args) public static Instance CreateInstance (string[] args)
{ {
U8String[] argv = new U8String[args.Length]; U8String[] argv = new U8String[args.Length];
...@@ -44,7 +62,9 @@ namespace VideoLAN.LibVLC ...@@ -44,7 +62,9 @@ namespace VideoLAN.LibVLC
} }
}; };
/** Safe handle for unmanaged LibVLC instance pointer */ /**
* Safe handle for unmanaged LibVLC instance pointer.
*/
public sealed class InstanceHandle : NonNullHandle public sealed class InstanceHandle : NonNullHandle
{ {
private InstanceHandle () private InstanceHandle ()
...@@ -52,12 +72,15 @@ namespace VideoLAN.LibVLC ...@@ -52,12 +72,15 @@ namespace VideoLAN.LibVLC
} }
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_new")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_new")]
public static extern internal static extern
InstanceHandle Create (int argc, U8String[] argv, NativeException ex); InstanceHandle Create (int argc, U8String[] argv, NativeException ex);
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_release")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_release")]
static extern void Destroy (IntPtr ptr, NativeException ex); static extern void Destroy (IntPtr ptr, NativeException ex);
/**
* System.Runtime.InteropServices.SafeHandle::ReleaseHandle.
*/
protected override bool ReleaseHandle () protected override bool ReleaseHandle ()
{ {
Destroy (handle, null); Destroy (handle, null);
...@@ -66,7 +89,8 @@ namespace VideoLAN.LibVLC ...@@ -66,7 +89,8 @@ namespace VideoLAN.LibVLC
}; };
/** /**
* Managed class for LibVLC instance (including playlist) * LibVLC Instance provides basic media player features from VLC,
* such as play/pause/stop and flat playlist management.
*/ */
public class Instance : BaseObject<InstanceHandle> public class Instance : BaseObject<InstanceHandle>
{ {
...@@ -77,6 +101,11 @@ namespace VideoLAN.LibVLC ...@@ -77,6 +101,11 @@ namespace VideoLAN.LibVLC
items = new Dictionary<int, PlaylistItem> (); items = new Dictionary<int, PlaylistItem> ();
} }
/**
* Creates a MediaDescriptor.
* @param mrl Media Resource Locator (file path or URL)
* @return create MediaDescriptor object.
*/
public MediaDescriptor CreateDescriptor (string mrl) public MediaDescriptor CreateDescriptor (string mrl)
{ {
U8String umrl = new U8String (mrl); U8String umrl = new U8String (mrl);
...@@ -89,7 +118,7 @@ namespace VideoLAN.LibVLC ...@@ -89,7 +118,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_loop")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_loop")]
static extern void PlaylistLoop (InstanceHandle self, bool b, static extern void PlaylistLoop (InstanceHandle self, bool b,
NativeException ex); NativeException ex);
/** Sets the playlist loop flag */ /** Sets the playlist loop flag. */
public bool Loop public bool Loop
{ {
set set
...@@ -102,7 +131,7 @@ namespace VideoLAN.LibVLC ...@@ -102,7 +131,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_play")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_play")]
static extern void PlaylistPlay (InstanceHandle self, int id, int optc, static extern void PlaylistPlay (InstanceHandle self, int id, int optc,
U8String[] optv, NativeException ex); U8String[] optv, NativeException ex);
/** Plays the next playlist item */ /** Plays the next playlist item (if not already playing). */
public void Play () public void Play ()
{ {
PlaylistPlay (self, -1, 0, new U8String[0], ex); PlaylistPlay (self, -1, 0, new U8String[0], ex);
...@@ -112,7 +141,7 @@ namespace VideoLAN.LibVLC ...@@ -112,7 +141,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_pause")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_pause")]
static extern void PlaylistPause (InstanceHandle self, static extern void PlaylistPause (InstanceHandle self,
NativeException ex); NativeException ex);
/** Toggles pause */ /** Toggles pause (starts playing if stopped, pauses if playing). */
public void TogglePause () public void TogglePause ()
{ {
PlaylistPause (self, ex); PlaylistPause (self, ex);
...@@ -123,7 +152,7 @@ namespace VideoLAN.LibVLC ...@@ -123,7 +152,7 @@ namespace VideoLAN.LibVLC
EntryPoint="libvlc_playlist_isplaying")] EntryPoint="libvlc_playlist_isplaying")]
static extern int PlaylistIsPlaying (InstanceHandle self, static extern int PlaylistIsPlaying (InstanceHandle self,
NativeException ex); NativeException ex);
/** Whether the playlist is running, or in pause/stop */ /** Whether the playlist is running, or paused/stopped. */
public bool IsPlaying public bool IsPlaying
{ {
get get
...@@ -137,7 +166,7 @@ namespace VideoLAN.LibVLC ...@@ -137,7 +166,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_stop")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_stop")]
static extern void PlaylistStop (InstanceHandle self, static extern void PlaylistStop (InstanceHandle self,
NativeException ex); NativeException ex);
/** Stops playing */ /** Stops playing. */
public void Stop () public void Stop ()
{ {
PlaylistStop (self, ex); PlaylistStop (self, ex);
...@@ -147,7 +176,7 @@ namespace VideoLAN.LibVLC ...@@ -147,7 +176,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_next")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_next")]
static extern void PlaylistNext (InstanceHandle self, static extern void PlaylistNext (InstanceHandle self,
NativeException ex); NativeException ex);
/** Goes to next playlist item (and start playing it) */ /** Switches to next playlist item, and starts playing it. */
public void Next () public void Next ()
{ {
PlaylistNext (self, ex); PlaylistNext (self, ex);
...@@ -157,7 +186,7 @@ namespace VideoLAN.LibVLC ...@@ -157,7 +186,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_prev")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_prev")]
static extern void PlaylistPrev (InstanceHandle self, static extern void PlaylistPrev (InstanceHandle self,
NativeException ex); NativeException ex);
/** Goes to previous playlist item (and start playing it) */ /** Switches to previous playlist item, and starts playing it. */
public void Prev () public void Prev ()
{ {
PlaylistPrev (self, ex); PlaylistPrev (self, ex);
...@@ -167,7 +196,7 @@ namespace VideoLAN.LibVLC ...@@ -167,7 +196,7 @@ namespace VideoLAN.LibVLC
[DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_clear")] [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_clear")]
static extern void PlaylistClear (InstanceHandle self, static extern void PlaylistClear (InstanceHandle self,
NativeException ex); NativeException ex);
/** Clears the whole playlist */ /** Clears the whole playlist. */
public void Clear () public void Clear ()
{ {
PlaylistClear (self, ex); PlaylistClear (self, ex);
...@@ -183,7 +212,13 @@ namespace VideoLAN.LibVLC ...@@ -183,7 +212,13 @@ namespace VideoLAN.LibVLC
static extern int PlaylistAdd (InstanceHandle self, U8String uri, static extern int PlaylistAdd (InstanceHandle self, U8String uri,
U8String name, int optc, U8String name, int optc,
U8String[] optv, NativeException e); U8String[] optv, NativeException e);
/** Appends an item to the playlist with options */ /**
* Appends an item to the playlist, with options.
* @param mrl Media Resource Locator (file name or URL)
* @param name playlist item user-visible name
* @param opts item options (see LibVLC documentation for details)
* @return created playlist item.
*/
public PlaylistItem Add (string mrl, string name, string[] opts) public PlaylistItem Add (string mrl, string name, string[] opts)
{ {
U8String umrl = new U8String (mrl); U8String umrl = new U8String (mrl);
...@@ -199,14 +234,31 @@ namespace VideoLAN.LibVLC ...@@ -199,14 +234,31 @@ namespace VideoLAN.LibVLC
items.Add (id, item); items.Add (id, item);
return item; return item;
} }
/**
* Appends an item with options.
* @param mrl Media Resource Locator (file name or URL)
* @param opts item options (see LibVLC documentation for details)
* @return created playlist item.
*/
public PlaylistItem Add (string mrl, string[] opts) public PlaylistItem Add (string mrl, string[] opts)
{ {
return Add (mrl, null, opts); return Add (mrl, null, opts);
} }
/**
* Appends an item to the playlist.
* @param mrl Media Resource Locator (file name or URL)
* @param name playlist item user-visible name
* @return created playlist item.
*/
public PlaylistItem Add (string mrl, string name) public PlaylistItem Add (string mrl, string name)
{ {
return Add (mrl, name, new string[0]); return Add (mrl, name, new string[0]);
} }
/**
* Appends an item to the playlist.
* @param mrl Media Resource Locator (file name or URL)
* @return created playlist item.
*/
public PlaylistItem Add (string mrl) public PlaylistItem Add (string mrl)
{ {
return Add (mrl, null, new string[0]); return Add (mrl, null, new string[0]);
...@@ -216,6 +268,10 @@ namespace VideoLAN.LibVLC ...@@ -216,6 +268,10 @@ namespace VideoLAN.LibVLC
EntryPoint="libvlc_playlist_delete_item")] EntryPoint="libvlc_playlist_delete_item")]
static extern int PlaylistDelete (InstanceHandle self, int id, static extern int PlaylistDelete (InstanceHandle self, int id,
NativeException e); NativeException e);
/**
* Removes an item from the playlist.
* @param item playlist item (as obtained from Add())
*/
public void Delete (PlaylistItem item) public void Delete (PlaylistItem item)
{ {
int id = item.Id; int id = item.Id;
...@@ -227,6 +283,9 @@ namespace VideoLAN.LibVLC ...@@ -227,6 +283,9 @@ namespace VideoLAN.LibVLC
} }
}; };
/**
* A playlist item.
*/
public class PlaylistItem public class PlaylistItem
{ {
int id; int id;
...@@ -278,6 +337,9 @@ namespace VideoLAN.LibVLC ...@@ -278,6 +337,9 @@ namespace VideoLAN.LibVLC
} }
}; };
/**
* Media descriptor. Not implemented yet.
*/
public class MediaDescriptor : BaseObject<DescriptorHandle> public class MediaDescriptor : BaseObject<DescriptorHandle>
{ {
internal MediaDescriptor (DescriptorHandle self) : base (self) internal MediaDescriptor (DescriptorHandle self) : base (self)
......
/* /**
* libvlc.cs - libvlc-control CIL bindings * @file marshal.cs
* @brief LibVLC marshalling utilities
* *
* $Id$ * $Id$
*/ */
...@@ -28,7 +29,8 @@ namespace VideoLAN.LibVLC ...@@ -28,7 +29,8 @@ namespace VideoLAN.LibVLC
{ {
/** /**
* Abstract safe handle class for non-NULL pointers * Abstract safe handle class for non-NULL pointers
* (Microsoft.* namespace has a similar class, but lets stick to System.*) * (Microsoft.* namespace has a similar class,
* but lets stick to System.*).
*/ */
public abstract class NonNullHandle : SafeHandle public abstract class NonNullHandle : SafeHandle
{ {
...@@ -46,6 +48,9 @@ namespace VideoLAN.LibVLC ...@@ -46,6 +48,9 @@ namespace VideoLAN.LibVLC
} }
}; };
/**
* Generic class for managed wrapper around a native safe handle.
*/
public class BaseObject<HandleT> : IDisposable where HandleT : SafeHandle public class BaseObject<HandleT> : IDisposable where HandleT : SafeHandle
{ {
protected NativeException ex; protected NativeException ex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment