Commit 8f30c533 authored by Martin Finkel's avatar Martin Finkel

Add Media class

parent 088f2cad
using System;
using System.IO;
using NUnit.Framework;
using VideoLAN.LibVLC;
namespace Bindings.Tests
{
[TestFixture]
public class MediaTests
{
[Test]
public void CreateMedia()
{
var instance = new Instance();
var media = new Media(instance, Path.GetTempFileName(), Media.FromType.FromPath);
Assert.AreNotEqual(IntPtr.Zero, media.NativeReference);
}
[Test]
public void CreateMediaFail()
{
Assert.Throws<ArgumentNullException>(() => new Media(null, Path.GetTempFileName(), Media.FromType.FromPath));
Assert.Throws<ArgumentNullException>(() => new Media(new Instance(), string.Empty, Media.FromType.FromPath));
}
[Test]
public void ReleaseMedia()
{
var media = new Media(new Instance(), Path.GetTempFileName(), Media.FromType.FromPath);
media.Dispose();
Assert.AreEqual(IntPtr.Zero, media.NativeReference);
}
[Test]
public void CreateMediaFromStream()
{
var media = new Media(new Instance(), new FileStream(Path.GetTempFileName(), FileMode.OpenOrCreate));
Assert.AreNotEqual(IntPtr.Zero, media.NativeReference);
}
[Test]
public void AddOption()
{
var media = new Media(new Instance(), new FileStream(Path.GetTempFileName(), FileMode.OpenOrCreate));
media.AddOption("-sout-all");
}
}
}
......@@ -142,6 +142,14 @@ namespace VideoLAN.LibVLC
EntryPoint = "libvlc_media_discoverer_list_release")]
internal static extern void LibVLCMediaDiscovererListRelease(IntPtr ppServices, ulong count);
/// <summary>Retrieve libvlc version.</summary>
/// <returns>a string containing the libvlc version</returns>
/// <remarks>Example: &quot;1.1.0-git The Luggage&quot;</remarks>
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_get_version")]
internal static extern IntPtr LibVLCVersion();
/// <summary>
/// Compute the size required by vsprintf to print the parameters.
/// </summary>
......@@ -217,7 +225,7 @@ namespace VideoLAN.LibVLC
/// <para>cross-platform compatibility with regards to libvlc_new() arguments.</para>
/// <para>We recommend that you do not use them, other than when debugging.</para>
/// </remarks>
public Instance(int argc, string[] args)
public Instance(int argc = 0, string[] args = null)
{
unsafe
{
......@@ -241,8 +249,18 @@ namespace VideoLAN.LibVLC
__ownsNativeInstance = true;
NativeToManagedMap[NativeReference] = this;
var version = Marshal.PtrToStringAnsi(Internal.LibVLCVersion());
if (string.IsNullOrEmpty(version)) return;
if (decimal.TryParse(version.Substring(0, 3), out var versionNumber))
{
LibVLCVersion = versionNumber;
}
}
public readonly decimal LibVLCVersion;
/// <para>Decrement the reference count of a libvlc instance, and destroy it</para>
/// <para>if it reaches zero.</para>
public void Dispose()
......
......@@ -309,20 +309,7 @@ namespace VideoLAN.LibVLC
EntryPoint = "libvlc_audio_output_set_device_type")]
internal static extern void LibvlcAudioOutputSetDeviceType(global::System.IntPtr p_mp, int device_type);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint = "libvlc_media_parse")]
internal static extern void LibvlcMediaParse(global::System.IntPtr p_md);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint = "libvlc_media_parse_async")]
internal static extern void LibvlcMediaParseAsync(global::System.IntPtr p_md);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint = "libvlc_media_is_parsed")]
internal static extern int LibvlcMediaIsParsed(global::System.IntPtr p_md);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
......@@ -588,59 +575,7 @@ namespace VideoLAN.LibVLC
__Internal.LibvlcAudioOutputSetDeviceType(__arg0, device_type);
}
/// <summary>Parse a media.</summary>
/// <param name="p_md">media descriptor object</param>
/// <remarks>
/// <para>This fetches (local) art, meta data and tracks information.</para>
/// <para>The method is synchronous.</para>
/// <para>This function could block indefinitely.</para>
/// <para>Use libvlc_media_parse_with_options() instead</para>
/// <para>libvlc_media_parse_with_options</para>
/// <para>libvlc_media_get_meta</para>
/// <para>libvlc_media_get_tracks_info</para>
/// </remarks>
public static void LibvlcMediaParse(global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
__Internal.LibvlcMediaParse(__arg0);
}
/// <summary>Parse a media.</summary>
/// <param name="p_md">media descriptor object</param>
/// <remarks>
/// <para>This fetches (local) art, meta data and tracks information.</para>
/// <para>The method is the asynchronous of libvlc_media_parse().</para>
/// <para>To track when this is over you can listen to libvlc_MediaParsedChanged</para>
/// <para>event. However if the media was already parsed you will not receive this</para>
/// <para>event.</para>
/// <para>You can't be sure to receive the libvlc_MediaParsedChanged</para>
/// <para>event (you can wait indefinitely for this event).</para>
/// <para>Use libvlc_media_parse_with_options() instead</para>
/// <para>libvlc_media_parse</para>
/// <para>libvlc_MediaParsedChanged</para>
/// <para>libvlc_media_get_meta</para>
/// <para>libvlc_media_get_tracks_info</para>
/// </remarks>
public static void LibvlcMediaParseAsync(global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
__Internal.LibvlcMediaParseAsync(__arg0);
}
/// <summary>Return true is the media descriptor object is parsed</summary>
/// <param name="p_md">media descriptor object</param>
/// <returns>true if media object has been parsed otherwise it returns false</returns>
/// <remarks>
/// <para>This can return true in case of failure.</para>
/// <para>Use libvlc_media_get_parsed_status() instead</para>
/// <para>libvlc_MediaParsedChanged</para>
/// </remarks>
public static int LibvlcMediaIsParsed(global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __ret = __Internal.LibvlcMediaIsParsed(__arg0);
return __ret;
}
/// <summary>Get media descriptor's elementary streams description</summary>
/// <param name="p_md">media descriptor object</param>
......@@ -658,7 +593,7 @@ namespace VideoLAN.LibVLC
public static int LibvlcMediaGetTracksInfo(global::VideoLAN.LibVLC.Media p_md,
global::VideoLAN.LibVLC.MediaTrackInfo tracks)
{
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __arg1 = ReferenceEquals(tracks, null) ? global::System.IntPtr.Zero : tracks.__Instance;
var __ret = __Internal.LibvlcMediaGetTracksInfo(__arg0, __arg1);
return __ret;
......
......@@ -80,6 +80,12 @@ namespace VideoLAN.LibVLC
return;
__Instance = new global::System.IntPtr(native);
}
public EventManager(IntPtr ptr)
{
if (ptr == IntPtr.Zero) return;
__Instance = ptr;
}
}
public unsafe partial class Log
......@@ -291,11 +297,6 @@ namespace VideoLAN.LibVLC
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_get_version")]
internal static extern global::System.IntPtr LibvlcGetVersion();
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
......@@ -405,14 +406,6 @@ namespace VideoLAN.LibVLC
/// <summary>Retrieve libvlc version.</summary>
/// <returns>a string containing the libvlc version</returns>
/// <remarks>Example: &quot;1.1.0-git The Luggage&quot;</remarks>
public static string LibvlcGetVersion()
{
var __ret = __Internal.LibvlcGetVersion();
return Marshal.PtrToStringAnsi(__ret);
}
/// <summary>Retrieve libvlc compiler version.</summary>
/// <returns>a string containing the libvlc compiler version</returns>
......
......@@ -270,7 +270,7 @@ namespace VideoLAN.LibVLC
public partial struct __Internal
{
[FieldOffset(0)]
internal global::VideoLAN.LibVLC.MetadataType meta_type;
internal global::VideoLAN.LibVLC.Media.MetadataType meta_type;
}
}
......@@ -586,10 +586,10 @@ namespace VideoLAN.LibVLC
private Event.__Internal __instance;
internal Event.__Internal __Instance { get { return __instance; } }
internal static global::VideoLAN.LibVLC.Event __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{
return new global::VideoLAN.LibVLC.Event(native.ToPointer(), skipVTables);
}
//internal static global::VideoLAN.LibVLC.Event __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
//{
// //return new global::VideoLAN.LibVLC.Event(native.ToPointer(), skipVTables);
//}
internal static global::VideoLAN.LibVLC.Event __CreateInstance(global::VideoLAN.LibVLC.Event.__Internal native, bool skipVTables = false)
{
......@@ -602,21 +602,21 @@ namespace VideoLAN.LibVLC
__instance = native;
}
private Event(void* native, bool skipVTables = false) : this()
{
__instance = *(global::VideoLAN.LibVLC.Event.__Internal*) native;
}
public Event(global::VideoLAN.LibVLC.Event _0)
: this()
{
var ____arg0 = _0.__Instance;
var __arg0 = new global::System.IntPtr(&____arg0);
fixed (__Internal* __instancePtr = &__instance)
{
__Internal.cctor(new global::System.IntPtr(__instancePtr), __arg0);
}
}
//private Event(void* native, bool skipVTables = false) : this()
//{
// __instance = *(global::VideoLAN.LibVLC.Event.__Internal*) native;
//}
//public Event(global::VideoLAN.LibVLC.Event _0)
// : this()
//{
// var ____arg0 = _0.__Instance;
// var __arg0 = new global::System.IntPtr(&____arg0);
// fixed (__Internal* __instancePtr = &__instance)
// {
// __Internal.cctor(new global::System.IntPtr(__instancePtr), __arg0);
// }
//}
public int Type
{
......
This diff is collapsed.
......@@ -137,7 +137,7 @@ namespace VideoLAN.LibVLC
public static void LibvlcMediaListSetMedia(global::VideoLAN.LibVLC.MediaList p_ml, global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
__Internal.LibvlcMediaListSetMedia(__arg0, __arg1);
}
......@@ -148,17 +148,17 @@ namespace VideoLAN.LibVLC
/// </summary>
/// <param name="p_ml">a media list instance</param>
/// <returns>media instance</returns>
public static global::VideoLAN.LibVLC.Media LibvlcMediaListMedia(global::VideoLAN.LibVLC.MediaList p_ml)
{
var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
var __ret = __Internal.LibvlcMediaListMedia(__arg0);
global::VideoLAN.LibVLC.Media __result0;
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::VideoLAN.LibVLC.Media.NativeToManagedMap.ContainsKey(__ret))
__result0 = (global::VideoLAN.LibVLC.Media) global::VideoLAN.LibVLC.Media.NativeToManagedMap[__ret];
else __result0 = global::VideoLAN.LibVLC.Media.__CreateInstance(__ret);
return __result0;
}
//public static global::VideoLAN.LibVLC.Media LibvlcMediaListMedia(global::VideoLAN.LibVLC.MediaList p_ml)
//{
//var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
//var __ret = __Internal.LibvlcMediaListMedia(__arg0);
//global::VideoLAN.LibVLC.Media __result0;
//if (__ret == IntPtr.Zero) __result0 = null;
//else if (global::VideoLAN.LibVLC.Media.NativeToManagedMap.ContainsKey(__ret))
// __result0 = (global::VideoLAN.LibVLC.Media) global::VideoLAN.LibVLC.Media.NativeToManagedMap[__ret];
//else __result0 = global::VideoLAN.LibVLC.Media.__CreateInstance(__ret);
//return __result0;
//}
/// <summary>
/// <para>Add media instance to media list</para>
......@@ -170,7 +170,7 @@ namespace VideoLAN.LibVLC
public static int LibvlcMediaListAddMedia(global::VideoLAN.LibVLC.MediaList p_ml, global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __ret = __Internal.LibvlcMediaListAddMedia(__arg0, __arg1);
return __ret;
}
......@@ -186,7 +186,7 @@ namespace VideoLAN.LibVLC
public static int LibvlcMediaListInsertMedia(global::VideoLAN.LibVLC.MediaList p_ml, global::VideoLAN.LibVLC.Media p_md, int i_pos)
{
var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __ret = __Internal.LibvlcMediaListInsertMedia(__arg0, __arg1, i_pos);
return __ret;
}
......@@ -229,17 +229,17 @@ namespace VideoLAN.LibVLC
/// <para>In case of success, libvlc_media_retain() is called to increase the refcount</para>
/// <para>on the media.</para>
/// </returns>
public static global::VideoLAN.LibVLC.Media LibvlcMediaListItemAtIndex(global::VideoLAN.LibVLC.MediaList p_ml, int i_pos)
{
var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
var __ret = __Internal.LibvlcMediaListItemAtIndex(__arg0, i_pos);
global::VideoLAN.LibVLC.Media __result0;
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::VideoLAN.LibVLC.Media.NativeToManagedMap.ContainsKey(__ret))
__result0 = (global::VideoLAN.LibVLC.Media) global::VideoLAN.LibVLC.Media.NativeToManagedMap[__ret];
else __result0 = global::VideoLAN.LibVLC.Media.__CreateInstance(__ret);
return __result0;
}
//public static global::VideoLAN.LibVLC.Media LibvlcMediaListItemAtIndex(global::VideoLAN.LibVLC.MediaList p_ml, int i_pos)
//{
// var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
// var __ret = __Internal.LibvlcMediaListItemAtIndex(__arg0, i_pos);
// global::VideoLAN.LibVLC.Media __result0;
// //if (__ret == IntPtr.Zero) __result0 = null;
// //else if (global::VideoLAN.LibVLC.Media.NativeToManagedMap.ContainsKey(__ret))
// // __result0 = (global::VideoLAN.LibVLC.Media) global::VideoLAN.LibVLC.Media.NativeToManagedMap[__ret];
// //else __result0 = global::VideoLAN.LibVLC.Media.__CreateInstance(__ret);
// //return __result0;
//}
/// <summary>
/// <para>Find index position of List media instance in media list.</para>
......@@ -252,7 +252,7 @@ namespace VideoLAN.LibVLC
public static int LibvlcMediaListIndexOfItem(global::VideoLAN.LibVLC.MediaList p_ml, global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_ml, null) ? global::System.IntPtr.Zero : p_ml.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __ret = __Internal.LibvlcMediaListIndexOfItem(__arg0, __arg1);
return __ret;
}
......
......@@ -310,7 +310,7 @@ namespace VideoLAN.LibVLC
public static int LibvlcMediaListPlayerPlayItem(global::VideoLAN.LibVLC.LibvlcMediaListPlayerT p_mlp, global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_mlp, null) ? global::System.IntPtr.Zero : p_mlp.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __ret = __Internal.LibvlcMediaListPlayerPlayItem(__arg0, __arg1);
return __ret;
}
......
......@@ -1906,7 +1906,7 @@ namespace VideoLAN.LibVLC
/// <returns>a new media player object, or NULL on error.</returns>
public static global::VideoLAN.LibVLC.MediaPlayer LibvlcMediaPlayerNewFromMedia(global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg0 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
var __ret = __Internal.LibvlcMediaPlayerNewFromMedia(__arg0);
global::VideoLAN.LibVLC.MediaPlayer __result0;
if (__ret == IntPtr.Zero) __result0 = null;
......@@ -1953,7 +1953,7 @@ namespace VideoLAN.LibVLC
public static void LibvlcMediaPlayerSetMedia(global::VideoLAN.LibVLC.MediaPlayer p_mi, global::VideoLAN.LibVLC.Media p_md)
{
var __arg0 = ReferenceEquals(p_mi, null) ? global::System.IntPtr.Zero : p_mi.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.__Instance;
var __arg1 = ReferenceEquals(p_md, null) ? global::System.IntPtr.Zero : p_md.NativeReference;
__Internal.LibvlcMediaPlayerSetMedia(__arg0, __arg1);
}
......@@ -1963,17 +1963,17 @@ namespace VideoLAN.LibVLC
/// <para>the media associated with p_mi, or NULL if no</para>
/// <para>media is associated</para>
/// </returns>
public static global::VideoLAN.LibVLC.Media LibvlcMediaPlayerGetMedia(global::VideoLAN.LibVLC.MediaPlayer p_mi)
{
var __arg0 = ReferenceEquals(p_mi, null) ? global::System.IntPtr.Zero : p_mi.__Instance;
var __ret = __Internal.LibvlcMediaPlayerGetMedia(__arg0);
global::VideoLAN.LibVLC.Media __result0;
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::VideoLAN.LibVLC.Media.NativeToManagedMap.ContainsKey(__ret))
__result0 = (global::VideoLAN.LibVLC.Media) global::VideoLAN.LibVLC.Media.NativeToManagedMap[__ret];
else __result0 = global::VideoLAN.LibVLC.Media.__CreateInstance(__ret);
return __result0;
}
//public static global::VideoLAN.LibVLC.Media LibvlcMediaPlayerGetMedia(global::VideoLAN.LibVLC.MediaPlayer p_mi)
//{
// var __arg0 = ReferenceEquals(p_mi, null) ? global::System.IntPtr.Zero : p_mi.__Instance;
// var __ret = __Internal.LibvlcMediaPlayerGetMedia(__arg0);
// global::VideoLAN.LibVLC.Media __result0;
// if (__ret == IntPtr.Zero) __result0 = null;
// else if (global::VideoLAN.LibVLC.Media.NativeToManagedMap.ContainsKey(__ret))
// __result0 = (global::VideoLAN.LibVLC.Media) global::VideoLAN.LibVLC.Media.NativeToManagedMap[__ret];
// else __result0 = global::VideoLAN.LibVLC.Media.__CreateInstance(__ret);
// return __result0;
//}
/// <summary>Get the Event Manager from which the media player send event.</summary>
/// <param name="p_mi">the Media Player</param>
......
......@@ -8,14 +8,12 @@ namespace Sample
static void Main(string[] args)
{
var instance = new Instance(0, null);
//var audiolist = instance.AudioFilterList;
var au = instance.AudioFilters;
//var media = libvlc_media.(instance,
//"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4");
var media = libvlc_media.LibvlcMediaNewLocation(instance,
"http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4");
var mediaPlayer = libvlc_media_player.LibvlcMediaPlayerNewFromMedia(media);
libvlc_media_player.LibvlcMediaPlayerPlay(mediaPlayer);
//var mediaPlayer = libvlc_media_player.LibvlcMediaPlayerNewFromMedia(media);
//libvlc_media_player.LibvlcMediaPlayerPlay(mediaPlayer);
Console.ReadKey();
}
......
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
namespace VideoLAN.LibVLC
{
public class Media : IDisposable
{
readonly ConcurrentDictionary<IntPtr, StreamData> DicStreams = new ConcurrentDictionary<IntPtr, StreamData>();
int _streamIndex;
internal struct Internal
{
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_new_location")]
internal static extern IntPtr LibVLCMediaNewLocation(IntPtr instance, [MarshalAs(UnmanagedType.LPStr)] string mrl);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_new_path")]
internal static extern IntPtr LibVLCMediaNewPath(IntPtr instance, [MarshalAs(UnmanagedType.LPStr)] string path);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_new_as_node")]
internal static extern IntPtr LibVLCMediaNewAsNode(IntPtr instance, [MarshalAs(UnmanagedType.LPStr)] string name);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_new_fd")]
internal static extern IntPtr LibVLCMediaNewFd(IntPtr instance, int fd);
/// <summary>
/// <para>Decrement the reference count of a media descriptor object. If the</para>
/// <para>reference count is 0, then libvlc_media_release() will release the</para>
/// <para>media descriptor object. It will send out an libvlc_MediaFreed event</para>
/// <para>to all listeners. If the media descriptor object has been released it</para>
/// <para>should not be used again.</para>
/// </summary>
/// <param name="media">the media descriptor</param>
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_release")]
internal static extern void LibVLCMediaRelease(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_list_media")]
internal static extern IntPtr LibVLCMediaListMedia(IntPtr mediaList);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_new_callbacks")]
internal static extern IntPtr LibVLCMediaNewCallbacks(IntPtr instance, OpenMedia openCb, ReadMedia readCb, SeekMedia seekCb, CloseMedia closeCb, IntPtr opaque);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_add_option")]
internal static extern void LibVLCMediaAddOption(IntPtr media, [MarshalAs(UnmanagedType.LPStr)] string options);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_add_option_flag")]
internal static extern void LibVLCMediaAddOptionFlag(IntPtr media, [MarshalAs(UnmanagedType.LPStr)] string options, uint flags);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_mrl")]
internal static extern IntPtr LibVLCMediaGetMrl(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_duplicate")]
internal static extern IntPtr LibVLCMediaDuplicate(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_meta")]
internal static extern IntPtr LibVLCMediaGetMeta(IntPtr media, MetadataType metadataType);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_set_meta")]
internal static extern void LibVLCMediaSetMeta(IntPtr media, MetadataType metadataType, [MarshalAs(UnmanagedType.LPStr)] string value);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_save_meta")]
internal static extern int LibVLCMediaSaveMeta(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_state")]
internal static extern VLCState LibVLCMediaGetState(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_event_manager")]
internal static extern IntPtr LibVLCMediaEventManager(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_stats")]
internal static extern int LibVLCMediaGetStats(IntPtr media, out MediaStats statistics);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_duration")]
internal static extern long LibVLCMediaGetDuration(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_parse")]
internal static extern void LibVLCMediaParse(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_parse_async")]
internal static extern void LibVLCMediaParseAsync(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_is_parsed")]
internal static extern int LibVLCMediaIsParsed(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_parse_with_options")]
internal static extern int LibVLCMediaParseWithOptions(IntPtr media, MediaParseOptions mediaParseOptions, int timeout);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_parsed_status")]
internal static extern MediaParsedStatus LibVLCMediaGetParsedStatus(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_parse_stop")]
internal static extern void LibVLCMediaParseStop(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_set_user_data")]
internal static extern void LibVLCMediaSetUserData(IntPtr media, IntPtr userData);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_user_data")]
internal static extern IntPtr LibVLCMediaGetUserData(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_tracks_get")]
internal static extern uint LibVLCMediaTracksGet(IntPtr media, ref IntPtr tracksPtr);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_tracks_release")]
internal static extern void LibVLCMediaTracksRelease(IntPtr tracks, uint count);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_subitems")]
internal static extern IntPtr LibVLCMediaSubitems(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_type")]
internal static extern MediaType LibVLCMediaGetType(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_slaves_add")]
internal static extern int LibVLCMediaAddSlaves(IntPtr media, MediaSlaveType slaveType, uint priority, [MarshalAs(UnmanagedType.LPStr)] string uri);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_slaves_clear")]
internal static extern void LibVLCMediaClearSlaves(IntPtr media);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_slaves_get")]
internal static extern uint LibVLCMediaGetSlaves(IntPtr media, ref IntPtr slaves);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_slaves_release")]
internal static extern void LibVLCMediaReleaseSlaves(IntPtr slaves, uint count);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_retain")]
internal static extern void LibVLCMediaRetain(IntPtr media);
}
#region enums
/// <summary>Meta data types</summary>
public enum MetadataType
{
Title = 0,
Artist = 1,
Genre = 2,
Copyright = 3,
Album = 4,
TrackNumber = 5,
Description = 6,
Rating = 7,
Date = 8,
Setting = 9,
URL = 10,
Language = 11,
NowPlaying = 12,
Publisher = 13,
EncodedBy = 14,
ArtworkURL = 15,
TrackID = 16,
TrackTotal = 17,
Director = 18,
Season = 19,
Episode = 20,
ShowName = 21,
Actors = 22,
AlbumArtist = 23,
DiscNumber = 24,
DiscTotal = 25
}
public enum FromType
{
/// <summary>
/// Create a media for a certain file path.
/// </summary>
FromPath,
/// <summary>
/// Create a media with a certain given media resource location,
/// for instance a valid URL.
/// note To refer to a local file with this function,