Commit 046aaadd authored by Martin Finkel's avatar Martin Finkel

[Docs] RendererDiscoverer

(cherry picked from commit daa0ae489d0ba7353a5e48dae4d698e9ebab3f9e)
parent fc479775
using LibVLCSharp.Shared.Helpers;
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace LibVLCSharp.Shared
{
/// <summary>
/// The renderer discoverer can be used to find and use a Chromecast or other distant renderers.
/// </summary>
public class RendererDiscoverer : Internal
{
RendererDiscovererEventManager _eventManager;
......@@ -37,6 +39,11 @@ namespace LibVLCSharp.Shared
internal static extern IntPtr LibVLCRendererDiscovererEventManager(IntPtr rendererDiscoverer);
}
/// <summary>
/// Renderer discoverer constructor
/// </summary>
/// <param name="libVLC">libvlc instance this will be connected to</param>
/// <param name="name">The service discovery protocol depending on platform (inferred)</param>
public RendererDiscoverer(LibVLC libVLC, string name = Constants.ServiceDiscoveryProtocol)
: base(() => Native.LibVLCRendererDiscovererNew(libVLC.NativeReference, name), Native.LibVLCRendererDiscovererRelease)
{
......@@ -55,22 +62,39 @@ namespace LibVLCSharp.Shared
}
}
/// <summary>
/// Start the renderer discovery
/// </summary>
/// <returns>true if start successful</returns>
public bool Start() => Native.LibVLCRendererDiscovererStart(NativeReference) == 0;
/// <summary>
/// Stop the renderer discovery
/// </summary>
public void Stop() => Native.LibVLCRendererDiscovererStop(NativeReference);
/// <summary>
/// Raised when a renderer item has been found
/// </summary>
public event EventHandler<RendererDiscovererItemAddedEventArgs> ItemAdded
{
add => EventManager.AttachEvent(EventType.RendererDiscovererItemAdded, value);
remove => EventManager.DetachEvent(EventType.RendererDiscovererItemAdded, value);
}
/// <summary>
/// Raised when a renderer item has disappeared
/// </summary>
public event EventHandler<RendererDiscovererItemDeletedEventArgs> ItemDeleted
{
add => EventManager.AttachEvent(EventType.RendererDiscovererItemDeleted, value);
remove => EventManager.DetachEvent(EventType.RendererDiscovererItemDeleted, value);
}
/// <summary>
/// Dispose of this renderer discoverer instance
/// </summary>
/// <param name="disposing">true if called from a method</param>
protected override void Dispose(bool disposing)
{
if (IsDisposed || NativeReference == IntPtr.Zero)
......@@ -85,6 +109,9 @@ namespace LibVLCSharp.Shared
}
}
/// <summary>
/// A renderer item represents a device that libvlc can use to render media.
/// </summary>
public class RendererItem : Internal
{
const int VideoRenderer = 0x0002;
......@@ -119,22 +146,41 @@ namespace LibVLCSharp.Shared
internal static extern int LibVLCRendererItemFlags(IntPtr rendererItem);
}
public RendererItem(IntPtr reference) :
internal RendererItem(IntPtr reference) :
base(() => reference, Native.LibVLCRendererItemRelease)
{
Native.LibVLCRendererItemHold(reference);
}
/// <summary>
/// Name of the renderer item
/// </summary>
public string Name => _utf8Marshaler.MarshalNativeToManaged(Native.LibVLCRendererItemName(NativeReference)) as string;
/// <summary>
/// Type of the renderer item
/// </summary>
public string Type => _utf8Marshaler.MarshalNativeToManaged(Native.LibVLCRendererItemType(NativeReference)) as string;
/// <summary>
/// IconUri of the renderer item
/// </summary>
public string IconUri => _utf8Marshaler.MarshalNativeToManaged(Native.LibVLCRendererItemIconUri(NativeReference)) as string;
/// <summary>
/// true if the renderer item can render video
/// </summary>
public bool CanRenderVideo => (Native.LibVLCRendererItemFlags(NativeReference) & VideoRenderer) != 0;
/// <summary>
/// true if the renderer item can render audio
/// </summary>
public bool CanRenderAudio => (Native.LibVLCRendererItemFlags(NativeReference) & AudioRenderer) != 0;
/// <summary>
/// Dispose of this renderer item instance
/// </summary>
/// <param name="disposing">true if called from a method</param>
protected override void Dispose(bool disposing)
{
if (IsDisposed || NativeReference == IntPtr.Zero)
......
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