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

Cleanup instance and media class

parent e876396a
......@@ -7,6 +7,7 @@ SOURCES_dll = \
ustring.cs \
exception.cs \
marshal.cs \
instance.cs \
media.cs \
player.cs \
libvlc.cs
......
/**
* @file instance.cs
* @brief Bindings to LibVLC for the .NET Common Intermediate Language
* @ingroup API
*
* @defgroup API Managed interface to LibVLC
* This is the primary class library for .NET applications
* to embed and control LibVLC.
*/
/**********************************************************************
* Copyright (C) 2007-2009 Rémi Denis-Courmont. *
* This program is free software; you can redistribute and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation; version 2 of the license, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, you can get it from: *
* http://www.gnu.org/copyleft/gpl.html *
**********************************************************************/
using System;
using System.Runtime.InteropServices;
namespace VideoLAN.LibVLC
{
/**
* @brief InstanceHandle: unmanaged LibVLC instance pointer
* @ingroup Internals
*/
internal sealed class InstanceHandle : NonNullHandle
{
protected override void Destroy ()
{
LibVLC.Release (handle, null);
}
};
/**
* @brief VLC: VLC media player instance
* @ingroup API
*
* The VLC class provides represent a run-time instance of a media player.
* An instance can spawn multiple independent medias, however
* configuration settings, message logging, etc are common to all medias
* from the same instance.
*/
public class VLC : BaseObject
{
internal InstanceHandle Handle
{
get
{
return handle as InstanceHandle;
}
}
/**
* Loads the native LibVLC and creates a LibVLC instance.
*
* @param args VLC command line parameters for the LibVLC Instance.
*/
public VLC (string[] args)
{
U8String[] argv = new U8String[args.Length];
for (int i = 0; i < args.Length; i++)
argv[i] = new U8String (args[i]);
handle = LibVLC.Create (argv.Length, argv, ex);
Raise ();
}
/**
* Starts a VLC interface plugin.
*
* @param name name of the interface plugin (e.g. "http", "qt4", ...)
*/
public void AddInterface (string name)
{
U8String uname = new U8String (name);
LibVLC.AddIntf (Handle, uname, ex);
Raise ();
}
/**
* Waits until VLC instance exits. This can happen if a fatal error
* occurs (e.g. cannot parse the arguments), if the user has quit
* through an interface, or if the special vlc://quit item was played.
*/
public void Run ()
{
LibVLC.Wait (Handle);
}
/**
* The human-readable LibVLC version number.
*/
public static string Version
{
get
{
return U8String.FromNative (LibVLC.GetVersion ());
}
}
/**
* The human-readable LibVLC C compiler infos.
*/
public static string Compiler
{
get
{
return U8String.FromNative (LibVLC.GetCompiler ());
}
}
/**
* The unique commit identifier from the LibVLC source control system,
* or "exported" if unknown.
*/
public static string ChangeSet
{
get
{
return U8String.FromNative (LibVLC.GetChangeset ());
}
}
/**
* The unmanaged VLC-internal instance object.
* Do not use this unless you really know what you are doing.
*/
public SafeHandle Object
{
get
{
return LibVLC.GetVLCInstance (Handle);
}
}
};
};
/**
* @file libvlc.cs
* @brief Bindings to LibVLC for the .NET Common Intermediate Language
* @ingroup API
*
* @defgroup API Managed interface to LibVLC
* This is the primary class library for .NET applications
* to embed and control LibVLC.
* @brief Unmanaged LibVLC APIs
* @ingroup Internals
*
* @defgroup Internals LibVLC internals
* This covers internal marshalling functions to use the native LibVLC.
......@@ -35,11 +31,12 @@ using System.Runtime.InteropServices;
namespace VideoLAN.LibVLC
{
/**
* @brief InstanceHandle: unmanaged LibVLC instance pointer
* @brief Native: unmanaged LibVLC APIs
* @ingroup Internals
*/
internal sealed class InstanceHandle : NonNullHandle
internal static class LibVLC
{
/* core.c */
[DllImport ("libvlc.dll", EntryPoint="libvlc_get_version")]
public static extern IntPtr GetVersion ();
......@@ -47,139 +44,99 @@ namespace VideoLAN.LibVLC
public static extern IntPtr GetCompiler ();
[DllImport ("libvlc.dll", EntryPoint="libvlc_get_changeset")]
public static extern IntPtr GetChangeSet ();
public static extern IntPtr GetChangeset ();
[DllImport ("libvlc.dll", EntryPoint="libvlc_new")]
public static extern
InstanceHandle Create (int argc, U8String[] argv,
NativeException ex);
InstanceHandle Create (int argc, U8String[] argv, NativeException ex);
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_retain")]
public static extern void Hold (InstanceHandle h,
NativeException ex);*/
public static extern
void Retain (InstanceHandle h, NativeException ex);*/
[DllImport ("libvlc.dll", EntryPoint="libvlc_release")]
private static extern void Release (IntPtr h,
NativeException ex);
public static extern
void Release (IntPtr h, NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_add_intf")]
public static extern void AddInterface (InstanceHandle h,
U8String name,
NativeException ex);
public static extern
void AddIntf (InstanceHandle h, U8String name, NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_wait")]
public static extern void Run (InstanceHandle h);
public static extern
void Wait (InstanceHandle h);
[DllImport ("libvlc.dll", EntryPoint="libvlc_get_vlc_instance")]
public static extern NonNullHandle GetVLC (InstanceHandle h);
public static extern
SafeHandle GetVLCInstance (InstanceHandle h);
protected override void Destroy ()
{
Release (handle, null);
}
};
/* media.c */
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_new")]
public static extern
MediaHandle MediaCreate (InstanceHandle inst, U8String mrl,
NativeException ex);
/**
* @brief VLC: VLC media player instance
* @ingroup API
*
* The VLC class provides represent a run-time instance of a media player.
* An instance can spawn multiple independent medias, however
* configuration settings, message logging, etc are common to all medias
* from the same instance.
*/
public class VLC : BaseObject
{
internal InstanceHandle Handle
{
get
{
return handle as InstanceHandle;
}
}
/**
* Loads the native LibVLC and creates a LibVLC instance.
*
* @param args VLC command line parameters for the LibVLC Instance.
*/
public VLC (string[] args)
{
U8String[] argv = new U8String[args.Length];
for (int i = 0; i < args.Length; i++)
argv[i] = new U8String (args[i]);
handle = InstanceHandle.Create (argv.Length, argv, ex);
Raise ();
}
/**
* Starts a VLC interface plugin.
*
* @param name name of the interface plugin (e.g. "http", "qt4", ...)
*/
public void AddInterface (string name)
{
U8String uname = new U8String (name);
InstanceHandle.AddInterface (Handle, uname, ex);
Raise ();
}
/**
* Waits until VLC instance exits. This can happen if a fatal error
* occurs (e.g. cannot parse the arguments), if the user has quit
* through an interface, or if the special vlc://quit item was played.
*/
public void Run ()
{
InstanceHandle.Run (Handle);
}
/**
* The human-readable LibVLC version number.
*/
public static string Version
{
get
{
return U8String.FromNative (InstanceHandle.GetVersion ());
}
}
/**
* The human-readable LibVLC C compiler infos.
*/
public static string Compiler
{
get
{
return U8String.FromNative (InstanceHandle.GetCompiler ());
}
}
/**
* The unique commit identifier from the LibVLC source control system,
* or "exported" if unknown.
*/
public static string ChangeSet
{
get
{
return U8String.FromNative (InstanceHandle.GetChangeSet ());
}
}
/**
* The unmanaged VLC-internal instance object.
* Do not use this unless you really know what you are doing.
*/
public SafeHandle Object
{
get
{
return InstanceHandle.GetVLC (Handle);
}
}
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_new_as_node")]
public static extern
MediaHandle MediaCreateAsNode (InstanceHandle inst, U8String name,
NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_add_option")]
public static extern
void MediaAddOption (MediaHandle media, U8String options,
NativeException ex);
[DllImport ("libvlc.dll",
EntryPoint="libvlc_media_add_option_untrusted")]
public static extern
void MediaAddUntrustedOption (MediaHandle media, U8String options,
NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_release")]
public static extern
void MediaRelease (IntPtr ptr);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_mrl")]
public static extern
void MediaGetMRL (MediaHandle media);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_duplicate")]
public static extern
MediaHandle MediaDuplicate (MediaHandle media);
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_read_meta")]
public static extern
MediaHandle MediaDuplicate (MediaHandle media, int type,
NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_state")]
public static extern
int MediaGetState (MediaHandle media, NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_subitems")]
public static extern
MediaListHandle MediaSubItems (MediaHandle media, NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_state")]
public static extern
EventManagerHandle MediaGetEventManager (MediaHandle media,
NativeException ex);*/
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_duration")]
public static extern
long MediaGetDuration (MediaHandle media, NativeException ex);
[DllImport ("libvlc.dll", EntryPoint="libvlc_media_is_preparsed")]
public static extern
int MediaIsPreparsed (MediaHandle media, NativeException ex);
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_set_user_data")]
public static extern
void MediaIsPreparsed (MediaHandle media, IntPtr data,
NativeException ex);*/
/*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_user_data")]
public static extern
IntPtr MediaIsPreparsed (MediaHandle media, NativeException ex);*/
};
};
......@@ -33,30 +33,9 @@ namespace VideoLAN.LibVLC
*/
internal sealed class MediaHandle : NonNullHandle
{
[DllImport ("libvlc.dll",
EntryPoint="libvlc_media_new")]
public static extern
MediaHandle Create (InstanceHandle inst, U8String mrl,
NativeException ex);
[DllImport ("libvlc.dll",
EntryPoint="libvlc_media_release")]
private static extern void Release (IntPtr ptr);
[DllImport ("libvlc.dll",
EntryPoint="libvlc_media_add_option")]
public static extern void AddOption (MediaHandle ptr, U8String options,
NativeException ex);
[DllImport ("libvlc.dll",
EntryPoint="libvlc_media_add_option_untrusted")]
public static extern void AddUntrustedOption (MediaHandle ptr,
U8String options,
NativeException ex);
protected override void Destroy ()
{
Release (handle);
LibVLC.MediaRelease (handle);
}
};
......@@ -84,7 +63,7 @@ namespace VideoLAN.LibVLC
{
U8String umrl = new U8String (mrl);
handle = MediaHandle.Create (instance.Handle, umrl, ex);
handle = LibVLC.MediaCreate (instance.Handle, umrl, ex);
Raise ();
}
......@@ -93,9 +72,9 @@ namespace VideoLAN.LibVLC
U8String uopts = new U8String (options);
if (trusted)
MediaHandle.AddOption (Handle, uopts, ex);
LibVLC.MediaAddOption (Handle, uopts, ex);
else
MediaHandle.AddUntrustedOption (Handle, uopts, ex);
LibVLC.MediaAddUntrustedOption (Handle, uopts, ex);
Raise ();
}
};
......
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