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

Cleanup: namespace, useless code, comments, warning

parent e6e1ceaa
using System;
using LibVLCSharp.Shared;
using Org.Videolan.Libvlc;
namespace LibVLCSharp.Platforms.Android
......
......@@ -11,12 +11,12 @@ namespace LibVLCSharp.Platforms.iOS
public VideoView(string[] cliOptions = default(string[]))
{
Instance = new Instance(cliOptions);
MediaPlayer = new MediaPlayer(Instance);
MediaPlayer = new Shared.MediaPlayer(Instance);
Attach();
}
public MediaPlayer MediaPlayer { get; }
public Shared.MediaPlayer MediaPlayer { get; }
public Instance Instance { get; }
void Attach() => MediaPlayer.NsObject = Handle;
......
......@@ -3,9 +3,8 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
using System.Threading.Tasks;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
public class Dialog : IDisposable
{
......
using System;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
public class Equalizer : Internal
{
......@@ -72,7 +71,7 @@ namespace LibVLCSharp
/// version LibVLC 2.2.0 or later
/// </summary>
[LibVLC(2, 2)]
public Equalizer() : base(Native.LibVLCAudioEqualizerNew, Native.LibVLCAudioEqualizerRelease )
public Equalizer() : base(Native.LibVLCAudioEqualizerNew, Native.LibVLCAudioEqualizerRelease)
{
}
......
......@@ -2,11 +2,9 @@ using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using LibVLCSharp.Shared.Structures;
using VideoLAN.LibVLCSharp.Structures;
namespace LibVLCSharp.Shared
{
......
using System;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
public abstract class Internal : IDisposable
{
/// <summary>
/// The pointer to the native code representation of this object
/// </summary>
public IntPtr NativeReference { get; private set; }
/// <summary>
/// Release native resources by calling this C function
/// </summary>
protected readonly Action<IntPtr> Release;
protected Internal(Func<IntPtr> create, Action<IntPtr> release)
......@@ -20,6 +25,8 @@ namespace LibVLCSharp
public virtual void Dispose()
{
if (NativeReference == IntPtr.Zero) return;
Release(NativeReference);
NativeReference = IntPtr.Zero;
}
......
......@@ -2,11 +2,10 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
//using Cauldron.Interception;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property,
AllowMultiple = true,
......
using System;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
/// <summary>LibVLCEvent types</summary>
public enum EventType
......
......@@ -253,12 +253,12 @@ namespace LibVLCSharp.Shared
FromLocation,
/// <summary>
/// Create a media as an empty node with a given name.
/// </summary
/// </summary>
AsNode
}
/// <summary>
/// <summary>Parse flags used by libvlc_media_parse_with_options()
/// Parse flags used by libvlc_media_parse_with_options()
/// </summary>
/// <remarks>libvlc_media_parse_with_options</remarks>
[Flags]
......
using System;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
/// <summary>
/// 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.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
public class MediaList : Internal
{
......@@ -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>
/// Create an empty media list.
/// </summary>
......
......@@ -2,10 +2,9 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
using VideoLAN.LibVLCSharp.Structures;
using LibVLCSharp.Shared.Structures;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
public class MediaPlayer : Internal
{
......@@ -693,12 +692,17 @@ namespace LibVLCSharp
public bool IsPlaying => Native.LibVLCMediaPlayerIsPlaying(NativeReference) != 0;
/// <summary>
/// Start playback
/// Start playback with Media that is set
/// If playback was already started, this method has no effect
/// </summary>
/// <returns></returns>
/// <returns>true if successful</returns>
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)
{
Media = media;
......@@ -711,10 +715,7 @@ namespace LibVLCSharp
/// </summary>
/// <param name="pause">play/resume if true, pause if false</param>
[LibVLC(1, 1)]
public void SetPause(bool pause)
{
Native.LibVLCMediaPlayerSetPause(NativeReference, pause);
}
public void SetPause(bool pause) => Native.LibVLCMediaPlayerSetPause(NativeReference, pause);
/// <summary>
/// Toggle pause (no effect if there is no media)
......
using System;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp.Shared;
namespace LibVLCSharp
namespace LibVLCSharp.Shared
{
public class RendererDiscoverer : Internal
{
......
using System;
using System.Runtime.InteropServices;
using System.Security;
using LibVLCSharp;
using LibVLCSharp.Shared;
namespace VideoLAN.LibVLCSharp.Structures
namespace LibVLCSharp.Shared.Structures
{
/// <summary>
/// <para>Description for audio output. It contains</para>
......
using System;
using System.Runtime.InteropServices;
namespace VideoLAN.LibVLCSharp.Structures
namespace LibVLCSharp.Shared.Structures
{
// TODO: cleanup
public unsafe partial class ModuleDescription : IDisposable
......
using System;
using System.Collections.Generic;
namespace VideoLAN.LibVLCSharp.Structures
namespace LibVLCSharp.Shared.Structures
{
/// <summary>
/// <para>Description for video, audio tracks and subtitles. It contains</para>
......@@ -25,5 +25,14 @@ namespace VideoLAN.LibVLCSharp.Structures
Name == description.Name &&
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