Commit 571452ca authored by Martin Finkel's avatar Martin Finkel

Cleanup: namespace, useless code, comments, warning

parent e6e1ceaa
using System; using System;
using LibVLCSharp.Shared;
using Org.Videolan.Libvlc; using Org.Videolan.Libvlc;
namespace LibVLCSharp.Platforms.Android namespace LibVLCSharp.Platforms.Android
......
...@@ -11,12 +11,12 @@ namespace LibVLCSharp.Platforms.iOS ...@@ -11,12 +11,12 @@ namespace LibVLCSharp.Platforms.iOS
public VideoView(string[] cliOptions = default(string[])) public VideoView(string[] cliOptions = default(string[]))
{ {
Instance = new Instance(cliOptions); Instance = new Instance(cliOptions);
MediaPlayer = new MediaPlayer(Instance); MediaPlayer = new Shared.MediaPlayer(Instance);
Attach(); Attach();
} }
public MediaPlayer MediaPlayer { get; } public Shared.MediaPlayer MediaPlayer { get; }
public Instance Instance { get; } public Instance Instance { get; }
void Attach() => MediaPlayer.NsObject = Handle; void Attach() => MediaPlayer.NsObject = Handle;
......
...@@ -3,9 +3,8 @@ using System.Runtime.InteropServices; ...@@ -3,9 +3,8 @@ using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
public class Dialog : IDisposable public class Dialog : IDisposable
{ {
......
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
public class Equalizer : Internal public class Equalizer : Internal
{ {
...@@ -72,7 +71,7 @@ namespace LibVLCSharp ...@@ -72,7 +71,7 @@ namespace LibVLCSharp
/// version LibVLC 2.2.0 or later /// version LibVLC 2.2.0 or later
/// </summary> /// </summary>
[LibVLC(2, 2)] [LibVLC(2, 2)]
public Equalizer() : base(Native.LibVLCAudioEqualizerNew, Native.LibVLCAudioEqualizerRelease ) public Equalizer() : base(Native.LibVLCAudioEqualizerNew, Native.LibVLCAudioEqualizerRelease)
{ {
} }
......
...@@ -2,11 +2,9 @@ using System; ...@@ -2,11 +2,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using LibVLCSharp.Shared.Structures; using LibVLCSharp.Shared.Structures;
using VideoLAN.LibVLCSharp.Structures;
namespace LibVLCSharp.Shared namespace LibVLCSharp.Shared
{ {
......
using System; using System;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
public abstract class Internal : IDisposable public abstract class Internal : IDisposable
{ {
/// <summary>
/// The pointer to the native code representation of this object
/// </summary>
public IntPtr NativeReference { get; private set; } public IntPtr NativeReference { get; private set; }
/// <summary>
/// Release native resources by calling this C function
/// </summary>
protected readonly Action<IntPtr> Release; protected readonly Action<IntPtr> Release;
protected Internal(Func<IntPtr> create, Action<IntPtr> release) protected Internal(Func<IntPtr> create, Action<IntPtr> release)
...@@ -20,6 +25,8 @@ namespace LibVLCSharp ...@@ -20,6 +25,8 @@ namespace LibVLCSharp
public virtual void Dispose() public virtual void Dispose()
{ {
if (NativeReference == IntPtr.Zero) return;
Release(NativeReference); Release(NativeReference);
NativeReference = IntPtr.Zero; NativeReference = IntPtr.Zero;
} }
......
...@@ -2,11 +2,10 @@ ...@@ -2,11 +2,10 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp.Shared;
//using Cauldron.Interception; //using Cauldron.Interception;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property, [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property,
AllowMultiple = true, AllowMultiple = true,
......
using System; using System;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
/// <summary>LibVLCEvent types</summary> /// <summary>LibVLCEvent types</summary>
public enum EventType public enum EventType
......
...@@ -253,12 +253,12 @@ namespace LibVLCSharp.Shared ...@@ -253,12 +253,12 @@ namespace LibVLCSharp.Shared
FromLocation, FromLocation,
/// <summary> /// <summary>
/// Create a media as an empty node with a given name. /// Create a media as an empty node with a given name.
/// </summary /// </summary>
AsNode AsNode
} }
/// <summary> /// <summary>
/// <summary>Parse flags used by libvlc_media_parse_with_options() /// Parse flags used by libvlc_media_parse_with_options()
/// </summary> /// </summary>
/// <remarks>libvlc_media_parse_with_options</remarks> /// <remarks>libvlc_media_parse_with_options</remarks>
[Flags] [Flags]
......
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
/// <summary> /// <summary>
/// libvlc v3 check /// libvlc v3 check
......
using System;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp
{
public class MediaLibrary : Internal
{
struct Native
{
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_library_new")]
internal static extern IntPtr LibVLCMediaLibraryNew(IntPtr instance);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_library_release")]
internal static extern void LibVLCMediaLibraryRelease(IntPtr mediaLibrary);
[SuppressUnmanagedCodeSecurity]
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_library_load")]
internal static extern int LibVLCMediaLibraryLoad(IntPtr mediaLibrary);
}
public MediaLibrary(Instance instance)
: base(() => Native.LibVLCMediaLibraryNew(instance.NativeReference), Native.LibVLCMediaLibraryRelease)
{
}
/// <summary>
/// Load media library.
/// </summary>
/// <returns>true on success</returns>
public bool Load() => Native.LibVLCMediaLibraryLoad(NativeReference) == 0;
}
}
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
public class MediaList : Internal public class MediaList : Internal
{ {
...@@ -113,15 +112,6 @@ namespace LibVLCSharp ...@@ -113,15 +112,6 @@ namespace LibVLCSharp
{ {
} }
/// <summary>
/// Get media library subitems.
/// </summary>
/// <param name="mediaList"></param>
public MediaList(MediaLibrary mediaList)
: base(() => Native.LibVLCMediaLibraryMediaList(mediaList.NativeReference), Native.LibVLCMediaListRelease)
{
}
/// <summary> /// <summary>
/// Create an empty media list. /// Create an empty media list.
/// </summary> /// </summary>
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp.Shared; using LibVLCSharp.Shared.Structures;
using VideoLAN.LibVLCSharp.Structures;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
public class MediaPlayer : Internal public class MediaPlayer : Internal
{ {
...@@ -693,12 +692,17 @@ namespace LibVLCSharp ...@@ -693,12 +692,17 @@ namespace LibVLCSharp
public bool IsPlaying => Native.LibVLCMediaPlayerIsPlaying(NativeReference) != 0; public bool IsPlaying => Native.LibVLCMediaPlayerIsPlaying(NativeReference) != 0;
/// <summary> /// <summary>
/// Start playback /// Start playback with Media that is set
/// If playback was already started, this method has no effect /// If playback was already started, this method has no effect
/// </summary> /// </summary>
/// <returns></returns> /// <returns>true if successful</returns>
public bool Play() => Native.LibVLCMediaPlayerPlay(NativeReference) == 0; public bool Play() => Native.LibVLCMediaPlayerPlay(NativeReference) == 0;
/// <summary>
/// Set media and start playback
/// </summary>
/// <param name="media"></param>
/// <returns>true if successful</returns>
public bool Play(Media media) public bool Play(Media media)
{ {
Media = media; Media = media;
...@@ -711,10 +715,7 @@ namespace LibVLCSharp ...@@ -711,10 +715,7 @@ namespace LibVLCSharp
/// </summary> /// </summary>
/// <param name="pause">play/resume if true, pause if false</param> /// <param name="pause">play/resume if true, pause if false</param>
[LibVLC(1, 1)] [LibVLC(1, 1)]
public void SetPause(bool pause) public void SetPause(bool pause) => Native.LibVLCMediaPlayerSetPause(NativeReference, pause);
{
Native.LibVLCMediaPlayerSetPause(NativeReference, pause);
}
/// <summary> /// <summary>
/// Toggle pause (no effect if there is no media) /// Toggle pause (no effect if there is no media)
......
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp namespace LibVLCSharp.Shared
{ {
public class RendererDiscoverer : Internal public class RendererDiscoverer : Internal
{ {
......
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security; using System.Security;
using LibVLCSharp;
using LibVLCSharp.Shared;
namespace VideoLAN.LibVLCSharp.Structures namespace LibVLCSharp.Shared.Structures
{ {
/// <summary> /// <summary>
/// <para>Description for audio output. It contains</para> /// <para>Description for audio output. It contains</para>
......
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace VideoLAN.LibVLCSharp.Structures namespace LibVLCSharp.Shared.Structures
{ {
// TODO: cleanup // TODO: cleanup
public unsafe partial class ModuleDescription : IDisposable public unsafe partial class ModuleDescription : IDisposable
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace VideoLAN.LibVLCSharp.Structures namespace LibVLCSharp.Shared.Structures
{ {
/// <summary> /// <summary>
/// <para>Description for video, audio tracks and subtitles. It contains</para> /// <para>Description for video, audio tracks and subtitles. It contains</para>
...@@ -25,5 +25,14 @@ namespace VideoLAN.LibVLCSharp.Structures ...@@ -25,5 +25,14 @@ namespace VideoLAN.LibVLCSharp.Structures
Name == description.Name && Name == description.Name &&
EqualityComparer<IntPtr>.Default.Equals(Next, description.Next); EqualityComparer<IntPtr>.Default.Equals(Next, description.Next);
} }
public override int GetHashCode()
{
var hashCode = -485159682;
hashCode = hashCode * -1521134295 + Id.GetHashCode();
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
hashCode = hashCode * -1521134295 + EqualityComparer<IntPtr>.Default.GetHashCode(Next);
return hashCode;
}
} }
} }
\ No newline at end of file
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