Commit 139abe4e authored by Martin Finkel's avatar Martin Finkel

Fix more UTF8 interop calls

parent 8c24dff1
using LibVLCSharp.Shared.Structures; using LibVLCSharp.Shared.Structures;
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace LibVLCSharp.Shared.Helpers namespace LibVLCSharp.Shared.Helpers
{ {
...@@ -114,5 +117,9 @@ namespace LibVLCSharp.Shared.Helpers ...@@ -114,5 +117,9 @@ namespace LibVLCSharp.Shared.Helpers
internal static RendererDescription Build(this RendererDescriptionStructure s) => internal static RendererDescription Build(this RendererDescriptionStructure s) =>
new RendererDescription(Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.Name) as string, new RendererDescription(Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.Name) as string,
Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.LongName) as string); Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.LongName) as string);
internal static IntPtr ToUtf8(this string str) => Utf8StringMarshaler.GetInstance().MarshalManagedToNative(str);
internal static string FromUtf8(this IntPtr nativeString) => Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(nativeString) as string;
} }
} }
\ No newline at end of file
...@@ -82,7 +82,7 @@ namespace LibVLCSharp.Shared.Helpers ...@@ -82,7 +82,7 @@ namespace LibVLCSharp.Shared.Helpers
var utf8Args = default(IntPtr[]); var utf8Args = default(IntPtr[]);
try try
{ {
utf8Args = ToUtf8(options); utf8Args = options.ToUtf8();
return create(utf8Args.Length, utf8Args); return create(utf8Args.Length, utf8Args);
} }
finally finally
...@@ -332,7 +332,7 @@ namespace LibVLCSharp.Shared.Helpers ...@@ -332,7 +332,7 @@ namespace LibVLCSharp.Shared.Helpers
/// </summary> /// </summary>
/// <param name="args"></param> /// <param name="args"></param>
/// <returns>Array of pointer you need to release when you're done with Marshal.FreeHGlobal</returns> /// <returns>Array of pointer you need to release when you're done with Marshal.FreeHGlobal</returns>
internal static IntPtr[] ToUtf8(string[] args) internal static IntPtr[] ToUtf8(this string[] args)
{ {
var utf8Args = new IntPtr[args?.Length ?? 0]; var utf8Args = new IntPtr[args?.Length ?? 0];
......
...@@ -61,7 +61,7 @@ namespace LibVLCSharp.Shared ...@@ -61,7 +61,7 @@ namespace LibVLCSharp.Shared
#if NET || NETSTANDARD #if NET || NETSTANDARD
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_add_intf")] EntryPoint = "libvlc_add_intf")]
internal static extern int LibVLCAddInterface(IntPtr libVLC, [MarshalAs(UnmanagedType.LPStr)] string name); internal static extern int LibVLCAddInterface(IntPtr libVLC, IntPtr name);
#endif #endif
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_exit_handler")] EntryPoint = "libvlc_set_exit_handler")]
...@@ -69,13 +69,11 @@ namespace LibVLCSharp.Shared ...@@ -69,13 +69,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_user_agent")] EntryPoint = "libvlc_set_user_agent")]
internal static extern void LibVLCSetUserAgent(IntPtr libVLC, [MarshalAs(UnmanagedType.LPStr)] string name, internal static extern void LibVLCSetUserAgent(IntPtr libVLC, IntPtr name, IntPtr http);
[MarshalAs(UnmanagedType.LPStr)] string http);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_app_id")] EntryPoint = "libvlc_set_app_id")]
internal static extern void LibVLCSetAppId(IntPtr libVLC, [MarshalAs(UnmanagedType.LPStr)] string id, internal static extern void LibVLCSetAppId(IntPtr libVLC, IntPtr id, IntPtr version, IntPtr icon);
[MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string icon);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_log_unset")] EntryPoint = "libvlc_log_unset")]
...@@ -222,7 +220,8 @@ namespace LibVLCSharp.Shared ...@@ -222,7 +220,8 @@ namespace LibVLCSharp.Shared
/// </summary> /// </summary>
/// <param name="name">interface name, or empty string for default</param> /// <param name="name">interface name, or empty string for default</param>
/// <returns>True if successful, false otherwise</returns> /// <returns>True if successful, false otherwise</returns>
public bool AddInterface(string name) => Native.LibVLCAddInterface(NativeReference, name ?? string.Empty) == 0; public bool AddInterface(string name) => Native.LibVLCAddInterface(NativeReference,
Utf8StringMarshaler.GetInstance().MarshalManagedToNative(name)) == 0;
#endif #endif
/// <summary> /// <summary>
/// <para>Registers a callback for the LibVLC exit event. This is mostly useful if</para> /// <para>Registers a callback for the LibVLC exit event. This is mostly useful if</para>
...@@ -255,10 +254,8 @@ namespace LibVLCSharp.Shared ...@@ -255,10 +254,8 @@ namespace LibVLCSharp.Shared
/// <param name="name">human-readable application name, e.g. &quot;FooBar player 1.2.3&quot;</param> /// <param name="name">human-readable application name, e.g. &quot;FooBar player 1.2.3&quot;</param>
/// <param name="http">HTTP User Agent, e.g. &quot;FooBar/1.2.3 Python/2.6.0&quot;</param> /// <param name="http">HTTP User Agent, e.g. &quot;FooBar/1.2.3 Python/2.6.0&quot;</param>
/// <remarks>LibVLC 1.1.1 or later</remarks> /// <remarks>LibVLC 1.1.1 or later</remarks>
public void SetUserAgent(string name, string http) public void SetUserAgent(string name, string http) => Native.LibVLCSetUserAgent(NativeReference,
{ Utf8StringMarshaler.GetInstance().MarshalManagedToNative(name), Utf8StringMarshaler.GetInstance().MarshalManagedToNative(http));
Native.LibVLCSetUserAgent(NativeReference, name, http);
}
/// <summary> /// <summary>
/// <para>Sets some meta-information about the application.</para> /// <para>Sets some meta-information about the application.</para>
...@@ -268,10 +265,10 @@ namespace LibVLCSharp.Shared ...@@ -268,10 +265,10 @@ namespace LibVLCSharp.Shared
/// <param name="version">application version numbers, e.g. &quot;1.2.3&quot;</param> /// <param name="version">application version numbers, e.g. &quot;1.2.3&quot;</param>
/// <param name="icon">application icon name, e.g. &quot;foobar&quot;</param> /// <param name="icon">application icon name, e.g. &quot;foobar&quot;</param>
/// <remarks>LibVLC 2.1.0 or later.</remarks> /// <remarks>LibVLC 2.1.0 or later.</remarks>
public void SetAppId(string id, string version, string icon) public void SetAppId(string id, string version, string icon) => Native.LibVLCSetAppId(NativeReference,
{ Utf8StringMarshaler.GetInstance().MarshalManagedToNative(id),
Native.LibVLCSetAppId(NativeReference, id, version, icon); Utf8StringMarshaler.GetInstance().MarshalManagedToNative(version),
} Utf8StringMarshaler.GetInstance().MarshalManagedToNative(icon));
/// <summary>Unsets the logging callback.</summary> /// <summary>Unsets the logging callback.</summary>
/// <remarks> /// <remarks>
......
...@@ -50,11 +50,11 @@ namespace LibVLCSharp.Shared ...@@ -50,11 +50,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_add_option")] EntryPoint = "libvlc_media_add_option")]
internal static extern void LibVLCMediaAddOption(IntPtr media, [MarshalAs(UnmanagedType.LPStr)] string options); internal static extern void LibVLCMediaAddOption(IntPtr media, IntPtr option);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_add_option_flag")] EntryPoint = "libvlc_media_add_option_flag")]
internal static extern void LibVLCMediaAddOptionFlag(IntPtr media, [MarshalAs(UnmanagedType.LPStr)] string options, uint flags); internal static extern void LibVLCMediaAddOptionFlag(IntPtr media, IntPtr options, uint flags);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_mrl")] EntryPoint = "libvlc_media_get_mrl")]
...@@ -70,7 +70,7 @@ namespace LibVLCSharp.Shared ...@@ -70,7 +70,7 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_set_meta")] EntryPoint = "libvlc_media_set_meta")]
internal static extern void LibVLCMediaSetMeta(IntPtr media, MetadataType metadataType, [MarshalAs(UnmanagedType.LPStr)] string value); internal static extern void LibVLCMediaSetMeta(IntPtr media, MetadataType metadataType, IntPtr value);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_save_meta")] EntryPoint = "libvlc_media_save_meta")]
...@@ -134,7 +134,7 @@ namespace LibVLCSharp.Shared ...@@ -134,7 +134,7 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_slaves_add")] EntryPoint = "libvlc_media_slaves_add")]
internal static extern int LibVLCMediaAddSlaves(IntPtr media, MediaSlaveType slaveType, uint priority, [MarshalAs(UnmanagedType.LPStr)] string uri); internal static extern int LibVLCMediaAddSlaves(IntPtr media, MediaSlaveType slaveType, uint priority, IntPtr uri);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_slaves_clear")] EntryPoint = "libvlc_media_slaves_clear")]
...@@ -154,7 +154,7 @@ namespace LibVLCSharp.Shared ...@@ -154,7 +154,7 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_get_codec_description")] EntryPoint = "libvlc_media_get_codec_description")]
internal static extern string LibvlcMediaGetCodecDescription(TrackType type, uint codec); internal static extern IntPtr LibvlcMediaGetCodecDescription(TrackType type, uint codec);
} }
/// <summary> /// <summary>
...@@ -232,12 +232,12 @@ namespace LibVLCSharp.Shared ...@@ -232,12 +232,12 @@ namespace LibVLCSharp.Shared
public Media(LibVLC libVLC, Stream stream, params string[] options) public Media(LibVLC libVLC, Stream stream, params string[] options)
: base(() => CtorFromCallbacks(libVLC, stream), Native.LibVLCMediaRelease) : base(() => CtorFromCallbacks(libVLC, stream), Native.LibVLCMediaRelease)
{ {
if (options.Any()) foreach(var option in options)
Native.LibVLCMediaAddOption(NativeReference, options.ToString()); {
Native.LibVLCMediaAddOption(NativeReference, Utf8StringMarshaler.GetInstance().MarshalManagedToNative(option));
}
} }
static IntPtr CtorFromCallbacks(LibVLC libVLC, Stream stream) static IntPtr CtorFromCallbacks(LibVLC libVLC, Stream stream)
{ {
if (libVLC == null) throw new ArgumentNullException(nameof(libVLC)); if (libVLC == null) throw new ArgumentNullException(nameof(libVLC));
...@@ -280,11 +280,11 @@ namespace LibVLCSharp.Shared ...@@ -280,11 +280,11 @@ namespace LibVLCSharp.Shared
/// <para>such as text renderer options, have no effects on an individual media.</para> /// <para>such as text renderer options, have no effects on an individual media.</para>
/// <para>These options must be set through libvlc_new() instead.</para> /// <para>These options must be set through libvlc_new() instead.</para>
/// </remarks> /// </remarks>
public void AddOption(string options) public void AddOption(string option)
{ {
if(string.IsNullOrEmpty(options)) throw new ArgumentNullException(nameof(options)); if(string.IsNullOrEmpty(option)) throw new ArgumentNullException(nameof(option));
Native.LibVLCMediaAddOption(NativeReference, options); Native.LibVLCMediaAddOption(NativeReference, option.ToUtf8());
} }
/// <summary> /// <summary>
...@@ -299,7 +299,7 @@ namespace LibVLCSharp.Shared ...@@ -299,7 +299,7 @@ namespace LibVLCSharp.Shared
} }
/// <summary>Add an option to the media with configurable flags.</summary> /// <summary>Add an option to the media with configurable flags.</summary>
/// <param name="options">the options (as a string)</param> /// <param name="options">the option (as a string)</param>
/// <param name="flags">the flags for this option</param> /// <param name="flags">the flags for this option</param>
/// <remarks> /// <remarks>
/// <para>This option will be used to determine how the media_player will</para> /// <para>This option will be used to determine how the media_player will</para>
...@@ -311,11 +311,11 @@ namespace LibVLCSharp.Shared ...@@ -311,11 +311,11 @@ namespace LibVLCSharp.Shared
/// <para>such as text renderer options cannot be set on a single media. They</para> /// <para>such as text renderer options cannot be set on a single media. They</para>
/// <para>must be set on the whole libvlc instance instead.</para> /// <para>must be set on the whole libvlc instance instead.</para>
/// </remarks> /// </remarks>
public void AddOptionFlag(string options, uint flags) public void AddOptionFlag(string option, uint flags)
{ {
if (string.IsNullOrEmpty(options)) throw new ArgumentNullException(nameof(options)); if (string.IsNullOrEmpty(option)) throw new ArgumentNullException(nameof(option));
Native.LibVLCMediaAddOptionFlag(NativeReference, options, flags); Native.LibVLCMediaAddOptionFlag(NativeReference, option.ToUtf8(), flags);
} }
string _mrl; string _mrl;
...@@ -364,7 +364,7 @@ namespace LibVLCSharp.Shared ...@@ -364,7 +364,7 @@ namespace LibVLCSharp.Shared
{ {
if(string.IsNullOrEmpty(value)) throw new ArgumentNullException(value); if(string.IsNullOrEmpty(value)) throw new ArgumentNullException(value);
Native.LibVLCMediaSetMeta(NativeReference, metadataType, value); Native.LibVLCMediaSetMeta(NativeReference, metadataType, value.ToUtf8());
} }
/// <summary>Save the meta previously set</summary> /// <summary>Save the meta previously set</summary>
...@@ -514,7 +514,7 @@ namespace LibVLCSharp.Shared ...@@ -514,7 +514,7 @@ namespace LibVLCSharp.Shared
/// <para>LibVLC 3.0.0 and later.</para> /// <para>LibVLC 3.0.0 and later.</para>
/// </remarks> /// </remarks>
public bool AddSlave(MediaSlaveType type, uint priority, string uri) => public bool AddSlave(MediaSlaveType type, uint priority, string uri) =>
Native.LibVLCMediaAddSlaves(NativeReference, type, priority, uri) != 0; Native.LibVLCMediaAddSlaves(NativeReference, type, priority, uri.ToUtf8()) != 0;
/// <summary> /// <summary>
......
...@@ -16,7 +16,7 @@ namespace LibVLCSharp.Shared ...@@ -16,7 +16,7 @@ namespace LibVLCSharp.Shared
{ {
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_new")] EntryPoint = "libvlc_media_discoverer_new")]
internal static extern IntPtr LibVLCMediaDiscovererNew(IntPtr libvlc, [MarshalAs(UnmanagedType.LPStr)] string name); internal static extern IntPtr LibVLCMediaDiscovererNew(IntPtr libvlc, IntPtr name);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_discoverer_start")] EntryPoint = "libvlc_media_discoverer_start")]
...@@ -53,7 +53,7 @@ namespace LibVLCSharp.Shared ...@@ -53,7 +53,7 @@ namespace LibVLCSharp.Shared
/// <param name="libVLC">libvlc instance this will be attached to</param> /// <param name="libVLC">libvlc instance this will be attached to</param>
/// <param name="name">name from one of LibVLC.MediaDiscoverers</param> /// <param name="name">name from one of LibVLC.MediaDiscoverers</param>
public MediaDiscoverer(LibVLC libVLC, string name) public MediaDiscoverer(LibVLC libVLC, string name)
: base(() => Native.LibVLCMediaDiscovererNew(libVLC.NativeReference, name), Native.LibVLCMediaDiscovererRelease) : base(() => Native.LibVLCMediaDiscovererNew(libVLC.NativeReference, name.ToUtf8()), Native.LibVLCMediaDiscovererRelease)
{ {
} }
......
...@@ -259,30 +259,22 @@ namespace LibVLCSharp.Shared ...@@ -259,30 +259,22 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_audio_set_format_callbacks")] EntryPoint = "libvlc_audio_set_format_callbacks")]
internal static extern void LibVLCAudioSetFormatCallbacks(IntPtr mediaPlayer, LibVLCAudioSetupCb setup, LibVLCAudioCleanupCb cleanup); internal static extern void LibVLCAudioSetFormatCallbacks(IntPtr mediaPlayer, LibVLCAudioSetupCb setup, LibVLCAudioCleanupCb cleanup);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_set_format")] EntryPoint = "libvlc_audio_set_format")]
internal static extern void LibVLCAudioSetFormat(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string format, internal static extern void LibVLCAudioSetFormat(IntPtr mediaPlayer, IntPtr format,
uint rate, uint channels); uint rate, uint channels);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_enum")] EntryPoint = "libvlc_audio_output_device_enum")]
internal static extern IntPtr LibVLCAudioOutputDeviceEnum(IntPtr mediaPlayer); internal static extern IntPtr LibVLCAudioOutputDeviceEnum(IntPtr mediaPlayer);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_set")] EntryPoint = "libvlc_audio_output_device_set")]
internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string module, internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, IntPtr module, IntPtr deviceId);
[MarshalAs(UnmanagedType.LPStr)] string deviceId);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_set")] EntryPoint = "libvlc_audio_output_set")]
internal static extern int LibVLCAudioOutputSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string name); internal static extern int LibVLCAudioOutputSet(IntPtr mediaPlayer, IntPtr name);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
...@@ -355,11 +347,9 @@ namespace LibVLCSharp.Shared ...@@ -355,11 +347,9 @@ namespace LibVLCSharp.Shared
internal static extern void LibVLCVideoSetCallbacks(IntPtr mediaPlayer, LibVLCVideoLockCb lockCallback, internal static extern void LibVLCVideoSetCallbacks(IntPtr mediaPlayer, LibVLCVideoLockCb lockCallback,
LibVLCVideoUnlockCb unlock, LibVLCVideoDisplayCb display, IntPtr opaque); LibVLCVideoUnlockCb unlock, LibVLCVideoDisplayCb display, IntPtr opaque);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_format")] EntryPoint = "libvlc_video_set_format")]
internal static extern void LibVLCVideoSetFormat(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string chroma, internal static extern void LibVLCVideoSetFormat(IntPtr mediaPlayer, IntPtr chroma,
uint width, uint height, uint pitch); uint width, uint height, uint pitch);
...@@ -401,13 +391,11 @@ namespace LibVLCSharp.Shared ...@@ -401,13 +391,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_aspect_ratio")] EntryPoint = "libvlc_video_get_aspect_ratio")]
internal static extern string LibVLCVideoGetAspectRatio(IntPtr mediaPlayer); internal static extern IntPtr LibVLCVideoGetAspectRatio(IntPtr mediaPlayer);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_aspect_ratio")] EntryPoint = "libvlc_video_set_aspect_ratio")]
internal static extern void LibVLCVideoSetAspectRatio(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string aspect); internal static extern void LibVLCVideoSetAspectRatio(IntPtr mediaPlayer, IntPtr aspect);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
...@@ -429,12 +417,9 @@ namespace LibVLCSharp.Shared ...@@ -429,12 +417,9 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_video_set_spu")] EntryPoint = "libvlc_video_set_spu")]
internal static extern int LibVLCVideoSetSpu(IntPtr mediaPlayer, int spu); internal static extern int LibVLCVideoSetSpu(IntPtr mediaPlayer, int spu);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_subtitle_file")] EntryPoint = "libvlc_video_set_subtitle_file")]
internal static extern int LibVLCVideoSetSubtitleFile(IntPtr mediaPlayer, internal static extern int LibVLCVideoSetSubtitleFile(IntPtr mediaPlayer, IntPtr subtitle);
[MarshalAs(UnmanagedType.LPStr)] string subtitle);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
...@@ -480,14 +465,11 @@ namespace LibVLCSharp.Shared ...@@ -480,14 +465,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_crop_geometry")] EntryPoint = "libvlc_video_get_crop_geometry")]
internal static extern string LibVLCVideoGetCropGeometry(IntPtr mediaPlayer); internal static extern IntPtr LibVLCVideoGetCropGeometry(IntPtr mediaPlayer);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_crop_geometry")] EntryPoint = "libvlc_video_set_crop_geometry")]
internal static extern void LibVLCVideoSetCropGeometry(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string geometry); internal static extern void LibVLCVideoSetCropGeometry(IntPtr mediaPlayer, IntPtr geometry);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_teletext")] EntryPoint = "libvlc_video_get_teletext")]
...@@ -518,18 +500,14 @@ namespace LibVLCSharp.Shared ...@@ -518,18 +500,14 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_video_set_track")] EntryPoint = "libvlc_video_set_track")]
internal static extern int LibVLCVideoSetTrack(IntPtr mediaPlayer, int track); internal static extern int LibVLCVideoSetTrack(IntPtr mediaPlayer, int track);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_take_snapshot")] EntryPoint = "libvlc_video_take_snapshot")]
internal static extern int LibVLCVideoTakeSnapshot(IntPtr mediaPlayer, uint num, internal static extern int LibVLCVideoTakeSnapshot(IntPtr mediaPlayer, uint num,
[MarshalAs(UnmanagedType.LPStr)] string filepath, uint width, uint height); IntPtr filepath, uint width, uint height);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_deinterlace")] EntryPoint = "libvlc_video_set_deinterlace")]
internal static extern void LibVLCVideoSetDeinterlace(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string mode); internal static extern void LibVLCVideoSetDeinterlace(IntPtr mediaPlayer, IntPtr mode);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
...@@ -539,47 +517,36 @@ namespace LibVLCSharp.Shared ...@@ -539,47 +517,36 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_marquee_string")] EntryPoint = "libvlc_video_get_marquee_string")]
internal static extern string LibVLCVideoGetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option); internal static extern IntPtr LibVLCVideoGetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_marquee_int")] EntryPoint = "libvlc_video_set_marquee_int")]
internal static extern void LibVLCVideoSetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option, int marqueeValue); internal static extern void LibVLCVideoSetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option, int marqueeValue);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_marquee_string")] EntryPoint = "libvlc_video_set_marquee_string")]
internal static extern void LibVLCVideoSetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option, [MarshalAs(UnmanagedType.LPStr)] string marqueeValue); internal static extern void LibVLCVideoSetMarqueeString(IntPtr mediaPlayer, VideoMarqueeOption option, IntPtr marqueeValue);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_logo_int")] EntryPoint = "libvlc_video_get_logo_int")]
internal static extern int LibVLCVideoGetLogoInt(IntPtr mediaPlayer, VideoLogoOption option); internal static extern int LibVLCVideoGetLogoInt(IntPtr mediaPlayer, VideoLogoOption option);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_logo_int")] EntryPoint = "libvlc_video_set_logo_int")]
internal static extern void LibVLCVideoSetLogoInt(IntPtr mediaPlayer, VideoLogoOption option, int value); internal static extern void LibVLCVideoSetLogoInt(IntPtr mediaPlayer, VideoLogoOption option, int value);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_logo_string")] EntryPoint = "libvlc_video_set_logo_string")]
internal static extern void LibVLCVideoSetLogoString(IntPtr mediaPlayer, VideoLogoOption option, internal static extern void LibVLCVideoSetLogoString(IntPtr mediaPlayer, VideoLogoOption option, IntPtr logoOptionValue);
[MarshalAs(UnmanagedType.LPStr)] string logoOptionValue);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_adjust_int")] EntryPoint = "libvlc_video_get_adjust_int")]
internal static extern int LibVLCVideoGetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option); internal static extern int LibVLCVideoGetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_adjust_int")] EntryPoint = "libvlc_video_set_adjust_int")]
internal static extern void LibVLCVideoSetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option, int value); internal static extern void LibVLCVideoSetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option, int value);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_adjust_float")] EntryPoint = "libvlc_video_get_adjust_float")]
internal static extern float LibVLCVideoGetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option); internal static extern float LibVLCVideoGetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option);
...@@ -589,12 +556,11 @@ namespace LibVLCSharp.Shared ...@@ -589,12 +556,11 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_video_set_adjust_float")] EntryPoint = "libvlc_video_set_adjust_float")]
internal static extern void LibVLCVideoSetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option, float value); internal static extern void LibVLCVideoSetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option, float value);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_add_slave")] EntryPoint = "libvlc_media_player_add_slave")]
internal static extern int LibVLCMediaPlayerAddSlave(IntPtr mediaPlayer, MediaSlaveType mediaSlaveType, internal static extern int LibVLCMediaPlayerAddSlave(IntPtr mediaPlayer, MediaSlaveType mediaSlaveType,
[MarshalAs(UnmanagedType.LPStr)] string uri, bool selectWhenloaded); IntPtr uri, bool selectWhenloaded);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, [DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_new_viewpoint")] EntryPoint = "libvlc_video_new_viewpoint")]
...@@ -1064,11 +1030,8 @@ namespace LibVLCSharp.Shared ...@@ -1064,11 +1030,8 @@ namespace LibVLCSharp.Shared
/// <param name="format">a four-characters string identifying the sample format (e.g. "S16N" or "FL32")</param> /// <param name="format">a four-characters string identifying the sample format (e.g. "S16N" or "FL32")</param>
/// <param name="rate">sample rate (expressed in Hz)</param> /// <param name="rate">sample rate (expressed in Hz)</param>
/// <param name="channels">channels count</param> /// <param name="channels">channels count</param>
public void SetAudioFormat(string format, uint rate, uint channels) public void SetAudioFormat(string format, uint rate, uint channels) => Native.LibVLCAudioSetFormat(NativeReference, format.ToUtf8(), rate, channels);
{
Native.LibVLCAudioSetFormat(NativeReference, format, rate, channels);
}
/// <summary> /// <summary>
/// Selects an audio output module. /// Selects an audio output module.
/// Note: /// Note:
...@@ -1076,7 +1039,7 @@ namespace LibVLCSharp.Shared ...@@ -1076,7 +1039,7 @@ namespace LibVLCSharp.Shared
/// </summary> /// </summary>