Commit 042cee11 authored by Martin Finkel's avatar Martin Finkel

Add MediaDiscoverer

parent 75238d2d
...@@ -91,9 +91,9 @@ namespace Bindings.Tests ...@@ -91,9 +91,9 @@ namespace Bindings.Tests
public void Categories() public void Categories()
{ {
var instance = new Instance(); var instance = new Instance();
var md1 = instance.MediaDiscoverers(MediaDiscovererCategory.Devices); var md1 = instance.MediaDiscoverers(MediaDiscoverer.Category.Devices);
var md2 = instance.MediaDiscoverers(MediaDiscovererCategory.Lan); var md2 = instance.MediaDiscoverers(MediaDiscoverer.Category.Lan);
var md3 = instance.MediaDiscoverers(MediaDiscovererCategory.Localdirs); var md3 = instance.MediaDiscoverers(MediaDiscoverer.Category.Localdirs);
} }
[Test] [Test]
...@@ -134,7 +134,6 @@ namespace Bindings.Tests ...@@ -134,7 +134,6 @@ namespace Bindings.Tests
[Test] [Test]
public void SetLogFile() public void SetLogFile()
{ {
// logging works but test keeps file handle opened so unable to read
var instance = new Instance(); var instance = new Instance();
var path = Path.GetTempFileName(); var path = Path.GetTempFileName();
instance.SetLogFile(path); instance.SetLogFile(path);
......
using System.Linq;
using NUnit.Framework;
using VideoLAN.LibVLC.Manual;
namespace Bindings.Tests
{
[TestFixture]
public class MediaDiscovererTests
{
[Test]
public void CreateStartAndStopDiscoverer()
{
var instance = new Instance();
var mds = instance.MediaDiscoverers(MediaDiscoverer.Category.Lan);
var md = new MediaDiscoverer(instance, mds.First().Name);
Assert.True(md.Start());
Assert.True(md.IsRunning);
md.Stop();
Assert.False(md.IsRunning);
}
}
}
\ No newline at end of file
...@@ -135,7 +135,7 @@ namespace VideoLAN.LibVLC.Manual ...@@ -135,7 +135,7 @@ namespace VideoLAN.LibVLC.Manual
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_list_get")] EntryPoint = "libvlc_media_discoverer_list_get")]
internal static extern ulong LibVLCMediaDiscovererListGet(IntPtr instance, MediaDiscovererCategory category, ref IntPtr pppServices); internal static extern ulong LibVLCMediaDiscovererListGet(IntPtr instance, MediaDiscoverer.Category category, ref IntPtr pppServices);
[SuppressUnmanagedCodeSecurity] [SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
...@@ -566,21 +566,20 @@ namespace VideoLAN.LibVLC.Manual ...@@ -566,21 +566,20 @@ namespace VideoLAN.LibVLC.Manual
/// <param name="category">category of services to fetch</param> /// <param name="category">category of services to fetch</param>
/// <returns>the number of media discoverer services (0 on error)</returns> /// <returns>the number of media discoverer services (0 on error)</returns>
/// <remarks>LibVLC 3.0.0 and later.</remarks> /// <remarks>LibVLC 3.0.0 and later.</remarks>
public MediaDiscovererDescription[] MediaDiscoverers(MediaDiscovererCategory category) public MediaDiscoverer.Description[] MediaDiscoverers(MediaDiscoverer.Category category)
{ {
var arrayResultPtr = IntPtr.Zero; var arrayResultPtr = IntPtr.Zero;
var count = Native.LibVLCMediaDiscovererListGet(NativeReference, category, ref arrayResultPtr); var count = Native.LibVLCMediaDiscovererListGet(NativeReference, category, ref arrayResultPtr);
if (count == 0) return Array.Empty<MediaDiscovererDescription>(); if (count == 0) return Array.Empty<MediaDiscoverer.Description>();
var mediaDiscovererDescription = new MediaDiscovererDescription[(int)count]; var mediaDiscovererDescription = new MediaDiscoverer.Description[(int)count];
for (var i = 0; i < (int)count; i++) for (var i = 0; i < (int)count; i++)
{ {
var ptr = Marshal.ReadIntPtr(arrayResultPtr, i * IntPtr.Size); var ptr = Marshal.ReadIntPtr(arrayResultPtr, i * IntPtr.Size);
var managedStruct = (MediaDiscovererDescription.__Internal) Marshal.PtrToStructure(ptr, typeof(MediaDiscovererDescription.__Internal)); var managedStruct = (MediaDiscoverer.Description)Marshal.PtrToStructure(ptr, typeof(MediaDiscoverer.Description));
var mdd = MediaDiscovererDescription.__CreateInstance(managedStruct); mediaDiscovererDescription[i] = managedStruct;
mediaDiscovererDescription[i] = mdd;
} }
Native.LibVLCMediaDiscovererListRelease(arrayResultPtr, count); Native.LibVLCMediaDiscovererListRelease(arrayResultPtr, count);
......
...@@ -8,301 +8,268 @@ using System; ...@@ -8,301 +8,268 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Text; using System.Text;
using VideoLAN.LibVLC.Manual;
namespace VideoLAN.LibVLC namespace VideoLAN.LibVLC
{ {
/// <summary>Category of a media discoverer</summary>
/// <remarks>libvlc_media_discoverer_list_get()</remarks>
public enum MediaDiscovererCategory // /// <summary>
{ // /// <para>LibVLC media discovery finds available media via various means.</para>
/// <summary>devices, like portable music player</summary> // /// <para>This corresponds to the service discovery functionality in VLC media player.</para>
Devices = 0, // /// <para>Different plugins find potential medias locally (e.g. user media directory),</para>
/// <summary>LAN/WAN services, like Upnp, SMB, or SAP</summary> // /// <para>from peripherals (e.g. video capture device), on the local network</para>
Lan = 1, // /// <para>(e.g. SAP) or on the Internet (e.g. Internet radios).</para>
/// <summary>Podcasts</summary> // /// <para>@{</para>
Podcasts = 2, // /// <para></para>
/// <summary>Local directories, like Video, Music or Pictures directories</summary> // /// <para>LibVLC media discovery external API</para>
Localdirs = 3 // /// </summary>
} // public unsafe partial class MediaDiscoverer
// {
/// <summary>
/// <para>LibVLC media discovery finds available media via various means.</para>
/// <para>This corresponds to the service discovery functionality in VLC media player.</para> // [StructLayout(LayoutKind.Explicit, Size = 0)]
/// <para>Different plugins find potential medias locally (e.g. user media directory),</para> // public partial struct __Internal
/// <para>from peripherals (e.g. video capture device), on the local network</para> // {
/// <para>(e.g. SAP) or on the Internet (e.g. Internet radios).</para> // }
/// <para>@{</para>
/// <para></para> // public global::System.IntPtr __Instance { get; protected set; }
/// <para>LibVLC media discovery external API</para>
/// </summary> // protected int __PointerAdjustment;
public unsafe partial class MediaDiscoverer // internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscoverer> NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscoverer>();
{ // protected void*[] __OriginalVTables;
// protected bool __ownsNativeInstance;
[StructLayout(LayoutKind.Explicit, Size = 0)]
public partial struct __Internal // internal static global::VideoLAN.LibVLC.MediaDiscoverer __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
{ // {
} // return new global::VideoLAN.LibVLC.MediaDiscoverer(native.ToPointer(), skipVTables);
// }
public global::System.IntPtr __Instance { get; protected set; }
// internal static global::VideoLAN.LibVLC.MediaDiscoverer __CreateInstance(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal native, bool skipVTables = false)
protected int __PointerAdjustment; // {
internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscoverer> NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscoverer>(); // return new global::VideoLAN.LibVLC.MediaDiscoverer(native, skipVTables);
protected void*[] __OriginalVTables; // }
protected bool __ownsNativeInstance; // private static void* __CopyValue(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal native)
// {
internal static global::VideoLAN.LibVLC.MediaDiscoverer __CreateInstance(global::System.IntPtr native, bool skipVTables = false) // var ret = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal));
{ // *(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal*) ret = native;
return new global::VideoLAN.LibVLC.MediaDiscoverer(native.ToPointer(), skipVTables); // return ret.ToPointer();
} // }
internal static global::VideoLAN.LibVLC.MediaDiscoverer __CreateInstance(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal native, bool skipVTables = false) // private MediaDiscoverer(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal native, bool skipVTables = false)
{ // : this(__CopyValue(native), skipVTables)
return new global::VideoLAN.LibVLC.MediaDiscoverer(native, skipVTables); // {
} // __ownsNativeInstance = true;
// NativeToManagedMap[__Instance] = this;
private static void* __CopyValue(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal native) // }
{
var ret = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal)); // protected MediaDiscoverer(void* native, bool skipVTables = false)
*(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal*) ret = native; // {
return ret.ToPointer(); // if (native == null)
} // return;
// __Instance = new global::System.IntPtr(native);
private MediaDiscoverer(global::VideoLAN.LibVLC.MediaDiscoverer.__Internal native, bool skipVTables = false) // }
: this(__CopyValue(native), skipVTables) // }
{
__ownsNativeInstance = true; // /// <summary>Media discoverer description</summary>
NativeToManagedMap[__Instance] = this; // /// <remarks>libvlc_media_discoverer_list_get()</remarks>
} //public unsafe class MediaDiscovererDescription //: IDisposable
//{
protected MediaDiscoverer(void* native, bool skipVTables = false) // [StructLayout(LayoutKind.Sequential)]
{ // public struct __Internal
if (native == null) // {
return; // internal IntPtr psz_name;
__Instance = new global::System.IntPtr(native);
} // internal IntPtr psz_longname;
}
// internal int i_cat;
/// <summary>Media discoverer description</summary> // }
/// <remarks>libvlc_media_discoverer_list_get()</remarks>
public unsafe class MediaDiscovererDescription //: IDisposable // public IntPtr NativeReference { get; protected set; }
{
[StructLayout(LayoutKind.Sequential)] // protected int __PointerAdjustment;
public struct __Internal // internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscovererDescription> NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscovererDescription>();
{ // protected void*[] __OriginalVTables;
internal IntPtr psz_name;
// protected bool __ownsNativeInstance;
internal IntPtr psz_longname;
// internal static global::VideoLAN.LibVLC.MediaDiscovererDescription __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
internal int i_cat; // {
} // return new global::VideoLAN.LibVLC.MediaDiscovererDescription(native.ToPointer(), skipVTables);
// }
public IntPtr NativeReference { get; protected set; }
// internal static global::VideoLAN.LibVLC.MediaDiscovererDescription __CreateInstance(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal native, bool skipVTables = false)
protected int __PointerAdjustment; // {
internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscovererDescription> NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary<IntPtr, global::VideoLAN.LibVLC.MediaDiscovererDescription>(); // return new global::VideoLAN.LibVLC.MediaDiscovererDescription(native, skipVTables);
protected void*[] __OriginalVTables; // }
protected bool __ownsNativeInstance; // private static void* __CopyValue(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal native)
// {
internal static global::VideoLAN.LibVLC.MediaDiscovererDescription __CreateInstance(global::System.IntPtr native, bool skipVTables = false) // var ret = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal));
{ // *(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal*)ret = native;
return new global::VideoLAN.LibVLC.MediaDiscovererDescription(native.ToPointer(), skipVTables); // return ret.ToPointer();
} // }
internal static global::VideoLAN.LibVLC.MediaDiscovererDescription __CreateInstance(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal native, bool skipVTables = false) // private MediaDiscovererDescription(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal native, bool skipVTables = false)
{ // : this(__CopyValue(native), skipVTables)
return new global::VideoLAN.LibVLC.MediaDiscovererDescription(native, skipVTables); // {
} // __ownsNativeInstance = true;
// NativeToManagedMap[NativeReference] = this;
private static void* __CopyValue(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal native) // }
{
var ret = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal)); // protected MediaDiscovererDescription(void* native, bool skipVTables = false)
*(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal*) ret = native; // {
return ret.ToPointer(); // if (native == null)
} // return;
// NativeReference = new global::System.IntPtr(native);
private MediaDiscovererDescription(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal native, bool skipVTables = false) // }
: this(__CopyValue(native), skipVTables)
{ // public MediaDiscovererDescription()
__ownsNativeInstance = true; // {
NativeToManagedMap[NativeReference] = this; // NativeReference = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal));
} // __ownsNativeInstance = true;
// NativeToManagedMap[NativeReference] = this;
protected MediaDiscovererDescription(void* native, bool skipVTables = false) // }
{
if (native == null) // public MediaDiscovererDescription(global::VideoLAN.LibVLC.MediaDiscovererDescription _0)
return; // {
NativeReference = new global::System.IntPtr(native); // NativeReference = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal));
} // __ownsNativeInstance = true;
// NativeToManagedMap[NativeReference] = this;
public MediaDiscovererDescription() // *((global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal*)NativeReference) = *((global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal*)_0.NativeReference);
{ // }
NativeReference = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal));
__ownsNativeInstance = true; // public void Dispose()
NativeToManagedMap[NativeReference] = this; // {
} // Dispose(disposing: true);
// }
public MediaDiscovererDescription(global::VideoLAN.LibVLC.MediaDiscovererDescription _0)
{ // public virtual void Dispose(bool disposing)
NativeReference = Marshal.AllocHGlobal(sizeof(global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal)); // {
__ownsNativeInstance = true; // if (NativeReference == IntPtr.Zero)
NativeToManagedMap[NativeReference] = this; // return;
*((global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal*)NativeReference) = *((global::VideoLAN.LibVLC.MediaDiscovererDescription.__Internal*) _0.NativeReference); // global::VideoLAN.LibVLC.MediaDiscovererDescription __dummy;
} // NativeToManagedMap.TryRemove(NativeReference, out __dummy);
// if (__ownsNativeInstance)
public void Dispose() // Marshal.FreeHGlobal(NativeReference);
{ // NativeReference = IntPtr.Zero;
Dispose(disposing: true); // }
}
// public string Name => (string)Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(((__Internal*)NativeReference)->psz_name);
public virtual void Dispose(bool disposing) // public string Longname => (string)Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(((__Internal*)NativeReference)->psz_longname);
{ // public MediaDiscoverer.Category Category => (MediaDiscoverer.Category)((__Internal*)NativeReference)->i_cat;
if (NativeReference == IntPtr.Zero) //}
return;
global::VideoLAN.LibVLC.MediaDiscovererDescription __dummy; // public unsafe partial class libvlc_media_discoverer
NativeToManagedMap.TryRemove(NativeReference, out __dummy); // {
if (__ownsNativeInstance) // public partial struct __Internal
Marshal.FreeHGlobal(NativeReference); // {
NativeReference = IntPtr.Zero;
} // [SuppressUnmanagedCodeSecurity]
// [DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
public string Name => (string)Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(((__Internal*)NativeReference)->psz_name); // EntryPoint="libvlc_media_discoverer_media_list")]
public string Longname => (string)Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(((__Internal*)NativeReference)->psz_longname); // internal static extern global::System.IntPtr LibvlcMediaDiscovererMediaList(global::System.IntPtr p_mdis);
public MediaDiscovererCategory Category => (MediaDiscovererCategory)((__Internal*)NativeReference)->i_cat;
} //
public unsafe partial class libvlc_media_discoverer // }
{
public partial struct __Internal // /// <summary>Create a media discoverer object by name.</summary>
{ // /// <param name="p_inst">libvlc instance</param>
[SuppressUnmanagedCodeSecurity] // /// <param name="psz_name">
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, // /// <para>service name; use libvlc_media_discoverer_list_get() to get</para>
EntryPoint="libvlc_media_discoverer_new")] // /// <para>a list of the discoverer names available in this libVLC instance</para>
internal static extern global::System.IntPtr LibvlcMediaDiscovererNew(global::System.IntPtr p_inst, [MarshalAs(UnmanagedType.LPStr)] string psz_name); // /// </param>
// /// <returns>media discover object or NULL in case of error</returns>
[SuppressUnmanagedCodeSecurity] // /// <remarks>
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, // /// <para>After this object is created, you should attach to media_list events in</para>
EntryPoint="libvlc_media_discoverer_start")] // /// <para>order to be notified of new items discovered.</para>
internal static extern int LibvlcMediaDiscovererStart(global::System.IntPtr p_mdis); // /// <para>You need to call libvlc_media_discoverer_start() in order to start the</para>
// /// <para>discovery.</para>
[SuppressUnmanagedCodeSecurity] // /// <para>libvlc_media_discoverer_media_list</para>
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, // /// <para>libvlc_media_discoverer_event_manager</para>
EntryPoint="libvlc_media_discoverer_stop")] // /// <para>libvlc_media_discoverer_start</para>
internal static extern void LibvlcMediaDiscovererStop(global::System.IntPtr p_mdis); // /// <para>LibVLC 3.0.0 or later</para>
// /// </remarks>
[SuppressUnmanagedCodeSecurity] // public static global::VideoLAN.LibVLC.MediaDiscoverer LibvlcMediaDiscovererNew(global::VideoLAN.LibVLC.Manual.Instance p_inst, string psz_name)
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, // {
EntryPoint="libvlc_media_discoverer_release")] // var __arg0 = ReferenceEquals(p_inst, null) ? global::System.IntPtr.Zero : p_inst.NativeReference;
internal static extern void LibvlcMediaDiscovererRelease(global::System.IntPtr p_mdis); // var __ret = __Internal.LibvlcMediaDiscovererNew(__arg0, psz_name);
// global::VideoLAN.LibVLC.MediaDiscoverer __result0;
[SuppressUnmanagedCodeSecurity] // if (__ret == IntPtr.Zero) __result0 = null;
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl, // else if (global::VideoLAN.LibVLC.MediaDiscoverer.NativeToManagedMap.ContainsKey(__ret))
EntryPoint="libvlc_media_discoverer_media_list")] // __result0 = (global::VideoLAN.LibVLC.MediaDiscoverer) global::VideoLAN.LibVLC.MediaDiscoverer.NativeToManagedMap[__ret];
internal static extern global::System.IntPtr LibvlcMediaDiscovererMediaList(global::System.IntPtr p_mdis); // else __result0 = global::VideoLAN.LibVLC.MediaDiscoverer.__CreateInstance(__ret);
// return __result0;
[SuppressUnmanagedCodeSecurity] // }
[DllImport("libvlc", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
EntryPoint="libvlc_media_discoverer_is_running")] // /// <summary>Start media discovery.</summary>
internal static extern int LibvlcMediaDiscovererIsRunning(global::System.IntPtr p_mdis); // /// <param name="p_mdis">media discover object</param>
// /// <returns>-1 in case of error, 0 otherwise</returns>
} // /// <remarks>
// /// <para>To stop it, call libvlc_media_discoverer_stop() or</para>
/// <summary>Create a media discoverer object by name.</summary> // /// <para>libvlc_media_discoverer_list_release() directly.</para>
/// <param name="p_inst">libvlc instance</param> // /// <para>libvlc_media_discoverer_stop</para>
/// <param name="psz_name"> // /// <para>LibVLC 3.0.0 or later</para>
/// <para>service name; use libvlc_media_discoverer_list_get() to get</para> // /// </remarks>
/// <para>a list of the discoverer names available in this libVLC instance</para> // public static int LibvlcMediaDiscovererStart(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
/// </param> // {
/// <returns>media discover object or NULL in case of error</returns> // var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
/// <remarks> // var __ret = __Internal.LibvlcMediaDiscovererStart(__arg0);
/// <para>After this object is created, you should attach to media_list events in</para> // return __ret;
/// <para>order to be notified of new items discovered.</para> // }
/// <para>You need to call libvlc_media_discoverer_start() in order to start the</para>
/// <para>discovery.</para> // /// <summary>Stop media discovery.</summary>
/// <para>libvlc_media_discoverer_media_list</para> // /// <param name="p_mdis">media discover object</param>
/// <para>libvlc_media_discoverer_event_manager</para> // /// <remarks>
/// <para>libvlc_media_discoverer_start</para> // /// <para>libvlc_media_discoverer_start</para>
/// <para>LibVLC 3.0.0 or later</para> // /// <para>LibVLC 3.0.0 or later</para>
/// </remarks> // /// </remarks>
public static global::VideoLAN.LibVLC.MediaDiscoverer LibvlcMediaDiscovererNew(global::VideoLAN.LibVLC.Manual.Instance p_inst, string psz_name) // public static void LibvlcMediaDiscovererStop(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
{ // {
var __arg0 = ReferenceEquals(p_inst, null) ? global::System.IntPtr.Zero : p_inst.NativeReference; // var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
var __ret = __Internal.LibvlcMediaDiscovererNew(__arg0, psz_name); // __Internal.LibvlcMediaDiscovererStop(__arg0);
global::VideoLAN.LibVLC.MediaDiscoverer __result0; // }
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::VideoLAN.LibVLC.MediaDiscoverer.NativeToManagedMap.ContainsKey(__ret)) // /// <summary>
__result0 = (global::VideoLAN.LibVLC.MediaDiscoverer) global::VideoLAN.LibVLC.MediaDiscoverer.NativeToManagedMap[__ret]; // /// <para>Release media discover object. If the reference count reaches 0, then</para>
else __result0 = global::VideoLAN.LibVLC.MediaDiscoverer.__CreateInstance(__ret); // /// <para>the object will be released.</para>
return __result0; // /// </summary>
} // /// <param name="p_mdis">media service discover object</param>
// public static void LibvlcMediaDiscovererRelease(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
/// <summary>Start media discovery.</summary> // {
/// <param name="p_mdis">media discover object</param> // var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
/// <returns>-1 in case of error, 0 otherwise</returns> // __Internal.LibvlcMediaDiscovererRelease(__arg0);
/// <remarks> // }
/// <para>To stop it, call libvlc_media_discoverer_stop() or</para>
/// <para>libvlc_media_discoverer_list_release() directly.</para> // /// <summary>Get media service discover media list.</summary>
/// <para>libvlc_media_discoverer_stop</para> // /// <param name="p_mdis">media service discover object</param>
/// <para>LibVLC 3.0.0 or later</para> // /// <returns>list of media items</returns>
/// </remarks> // public static global::VideoLAN.LibVLC.MediaList LibvlcMediaDiscovererMediaList(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
public static int LibvlcMediaDiscovererStart(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis) // {
{ // var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance; // var __ret = __Internal.LibvlcMediaDiscovererMediaList(__arg0);
var __ret = __Internal.LibvlcMediaDiscovererStart(__arg0); // global::VideoLAN.LibVLC.MediaList __result0;
return __ret; // if (__ret == IntPtr.Zero) __result0 = null;
} // else if (global::VideoLAN.LibVLC.MediaList.NativeToManagedMap.ContainsKey(__ret))
// __result0 = (global::VideoLAN.LibVLC.MediaList) global::VideoLAN.LibVLC.MediaList.NativeToManagedMap[__ret];
/// <summary>Stop media discovery.</summary> // else __result0 = global::VideoLAN.LibVLC.MediaList.__CreateInstance(__ret);
/// <param name="p_mdis">media discover object</param> // return __result0;libvlc_media_discoverer_event_manager
/// <remarks> // }
/// <para>libvlc_media_discoverer_start</para>
/// <para>LibVLC 3.0.0 or later</para> // /// <summary>Query if media service discover object is running.</summary>
/// </remarks> // /// <param name="p_mdis">media service discover object</param>
public static void LibvlcMediaDiscovererStop(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis) // /// <returns>true if running, false if not</returns>
{ // public static int LibvlcMediaDiscovererIsRunning(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance; // {
__Internal.LibvlcMediaDiscovererStop(__arg0); // var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
} // var __ret = __Internal.LibvlcMediaDiscovererIsRunning(__arg0);
// return __ret;
/// <summary> // }
/// <para>Release media discover object. If the reference count reaches 0, then</para>
/// <para>the object will be released.</para>
/// </summary> //}
/// <param name="p_mdis">media service discover object</param>
public static void LibvlcMediaDiscovererRelease(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
{
var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
__Internal.LibvlcMediaDiscovererRelease(__arg0);
}
/// <summary>Get media service discover media list.</summary>
/// <param name="p_mdis">media service discover object</param>
/// <returns>list of media items</returns>
public static global::VideoLAN.LibVLC.MediaList LibvlcMediaDiscovererMediaList(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
{
var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
var __ret = __Internal.LibvlcMediaDiscovererMediaList(__arg0);
global::VideoLAN.LibVLC.MediaList __result0;
if (__ret == IntPtr.Zero) __result0 = null;
else if (global::VideoLAN.LibVLC.MediaList.NativeToManagedMap.ContainsKey(__ret))
__result0 = (global::VideoLAN.LibVLC.MediaList) global::VideoLAN.LibVLC.MediaList.NativeToManagedMap[__ret];
else __result0 = global::VideoLAN.LibVLC.MediaList.__CreateInstance(__ret);
return __result0;
}
/// <summary>Query if media service discover object is running.</summary>
/// <param name="p_mdis">media service discover object</param>
/// <returns>true if running, false if not</returns>
public static int LibvlcMediaDiscovererIsRunning(global::VideoLAN.LibVLC.MediaDiscoverer p_mdis)
{
var __arg0 = ReferenceEquals(p_mdis, null) ? global::System.IntPtr.Zero : p_mdis.__Instance;
var __ret = __Internal.LibvlcMediaDiscovererIsRunning(__arg0);
return __ret;
}
}
} }
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace VideoLAN.LibVLC.Manual
{
/// <summary>
/// libvlc v3 check
/// </summary>
public class MediaDiscoverer : Internal
{
MediaDiscovererEventManager _eventManager;
MediaList _mediaList;
struct Native
{
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_new")]
internal static extern IntPtr LibVLCMediaDiscovererNew(IntPtr instance, [MarshalAs(UnmanagedType.LPStr)] string name);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_start")]
internal static extern int LibVLCMediaDiscovererStart(IntPtr mediaDiscoverer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_stop")]
internal static extern void LibVLCMediaDiscovererStop(IntPtr mediaDiscoverer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_release")]
internal static extern void LibVLCMediaDiscovererRelease(IntPtr mediaDiscoverer);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,