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

Fix more UTF8 interop calls

parent 8c24dff1
using LibVLCSharp.Shared.Structures;
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace LibVLCSharp.Shared.Helpers
{
......@@ -114,5 +117,9 @@ namespace LibVLCSharp.Shared.Helpers
internal static RendererDescription Build(this RendererDescriptionStructure s) =>
new RendererDescription(Utf8StringMarshaler.GetInstance().MarshalNativeToManaged(s.Name) 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
var utf8Args = default(IntPtr[]);
try
{
utf8Args = ToUtf8(options);
utf8Args = options.ToUtf8();
return create(utf8Args.Length, utf8Args);
}
finally
......@@ -332,7 +332,7 @@ namespace LibVLCSharp.Shared.Helpers
/// </summary>
/// <param name="args"></param>
/// <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];
......
......@@ -61,7 +61,7 @@ namespace LibVLCSharp.Shared
#if NET || NETSTANDARD
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_exit_handler")]
......@@ -69,13 +69,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_user_agent")]
internal static extern void LibVLCSetUserAgent(IntPtr libVLC, [MarshalAs(UnmanagedType.LPStr)] string name,
[MarshalAs(UnmanagedType.LPStr)] string http);
internal static extern void LibVLCSetUserAgent(IntPtr libVLC, IntPtr name, IntPtr http);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_set_app_id")]
internal static extern void LibVLCSetAppId(IntPtr libVLC, [MarshalAs(UnmanagedType.LPStr)] string id,
[MarshalAs(UnmanagedType.LPStr)] string version, [MarshalAs(UnmanagedType.LPStr)] string icon);
internal static extern void LibVLCSetAppId(IntPtr libVLC, IntPtr id, IntPtr version, IntPtr icon);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_log_unset")]
......@@ -222,7 +220,8 @@ namespace LibVLCSharp.Shared
/// </summary>
/// <param name="name">interface name, or empty string for default</param>
/// <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
/// <summary>
/// <para>Registers a callback for the LibVLC exit event. This is mostly useful if</para>
......@@ -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="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>
public void SetUserAgent(string name, string http)
{
Native.LibVLCSetUserAgent(NativeReference, name, http);
}
public void SetUserAgent(string name, string http) => Native.LibVLCSetUserAgent(NativeReference,
Utf8StringMarshaler.GetInstance().MarshalManagedToNative(name), Utf8StringMarshaler.GetInstance().MarshalManagedToNative(http));
/// <summary>
/// <para>Sets some meta-information about the application.</para>
......@@ -268,10 +265,10 @@ namespace LibVLCSharp.Shared
/// <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>
/// <remarks>LibVLC 2.1.0 or later.</remarks>
public void SetAppId(string id, string version, string icon)
{
Native.LibVLCSetAppId(NativeReference, id, version, icon);
}
public void SetAppId(string id, string version, string icon) => Native.LibVLCSetAppId(NativeReference,
Utf8StringMarshaler.GetInstance().MarshalManagedToNative(id),
Utf8StringMarshaler.GetInstance().MarshalManagedToNative(version),
Utf8StringMarshaler.GetInstance().MarshalManagedToNative(icon));
/// <summary>Unsets the logging callback.</summary>
/// <remarks>
......
......@@ -50,11 +50,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
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,
EntryPoint = "libvlc_media_get_mrl")]
......@@ -70,7 +70,7 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
EntryPoint = "libvlc_media_save_meta")]
......@@ -134,7 +134,7 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
EntryPoint = "libvlc_media_slaves_clear")]
......@@ -154,7 +154,7 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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>
......@@ -232,12 +232,12 @@ namespace LibVLCSharp.Shared
public Media(LibVLC libVLC, Stream stream, params string[] options)
: base(() => CtorFromCallbacks(libVLC, stream), Native.LibVLCMediaRelease)
{
if (options.Any())
Native.LibVLCMediaAddOption(NativeReference, options.ToString());
foreach(var option in options)
{
Native.LibVLCMediaAddOption(NativeReference, Utf8StringMarshaler.GetInstance().MarshalManagedToNative(option));
}
}
static IntPtr CtorFromCallbacks(LibVLC libVLC, Stream stream)
{
if (libVLC == null) throw new ArgumentNullException(nameof(libVLC));
......@@ -280,11 +280,11 @@ namespace LibVLCSharp.Shared
/// <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>
/// </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>
......@@ -299,7 +299,7 @@ namespace LibVLCSharp.Shared
}
/// <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>
/// <remarks>
/// <para>This option will be used to determine how the media_player will</para>
......@@ -311,11 +311,11 @@ namespace LibVLCSharp.Shared
/// <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>
/// </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;
......@@ -364,7 +364,7 @@ namespace LibVLCSharp.Shared
{
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>
......@@ -514,7 +514,7 @@ namespace LibVLCSharp.Shared
/// <para>LibVLC 3.0.0 and later.</para>
/// </remarks>
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>
......
......@@ -16,7 +16,7 @@ namespace LibVLCSharp.Shared
{
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
EntryPoint = "libvlc_media_discoverer_start")]
......@@ -53,7 +53,7 @@ namespace LibVLCSharp.Shared
/// <param name="libVLC">libvlc instance this will be attached to</param>
/// <param name="name">name from one of LibVLC.MediaDiscoverers</param>
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
EntryPoint = "libvlc_audio_set_format_callbacks")]
internal static extern void LibVLCAudioSetFormatCallbacks(IntPtr mediaPlayer, LibVLCAudioSetupCb setup, LibVLCAudioCleanupCb cleanup);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_enum")]
internal static extern IntPtr LibVLCAudioOutputDeviceEnum(IntPtr mediaPlayer);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_audio_output_device_set")]
internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, [MarshalAs(UnmanagedType.LPStr)] string module,
[MarshalAs(UnmanagedType.LPStr)] string deviceId);
// TODO: UTF8
internal static extern void LibVLCAudioOutputDeviceSet(IntPtr mediaPlayer, IntPtr module, IntPtr deviceId);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
......@@ -355,11 +347,9 @@ namespace LibVLCSharp.Shared
internal static extern void LibVLCVideoSetCallbacks(IntPtr mediaPlayer, LibVLCVideoLockCb lockCallback,
LibVLCVideoUnlockCb unlock, LibVLCVideoDisplayCb display, IntPtr opaque);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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);
......@@ -401,13 +391,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_aspect_ratio")]
internal static extern string LibVLCVideoGetAspectRatio(IntPtr mediaPlayer);
//TODO: UTF8
internal static extern IntPtr LibVLCVideoGetAspectRatio(IntPtr mediaPlayer);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
......@@ -429,12 +417,9 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_video_set_spu")]
internal static extern int LibVLCVideoSetSpu(IntPtr mediaPlayer, int spu);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_subtitle_file")]
internal static extern int LibVLCVideoSetSubtitleFile(IntPtr mediaPlayer,
[MarshalAs(UnmanagedType.LPStr)] string subtitle);
internal static extern int LibVLCVideoSetSubtitleFile(IntPtr mediaPlayer, IntPtr subtitle);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
......@@ -480,14 +465,11 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_crop_geometry")]
internal static extern string LibVLCVideoGetCropGeometry(IntPtr mediaPlayer);
//TODO: UTF8
internal static extern IntPtr LibVLCVideoGetCropGeometry(IntPtr mediaPlayer);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
EntryPoint = "libvlc_video_get_teletext")]
......@@ -518,18 +500,14 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_video_set_track")]
internal static extern int LibVLCVideoSetTrack(IntPtr mediaPlayer, int track);
// TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_take_snapshot")]
internal static extern int LibVLCVideoTakeSnapshot(IntPtr mediaPlayer, uint num,
[MarshalAs(UnmanagedType.LPStr)] string filepath, uint width, uint height);
// TODO: UTF8
IntPtr filepath, uint width, uint height);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
......@@ -539,47 +517,36 @@ namespace LibVLCSharp.Shared
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
EntryPoint = "libvlc_video_set_marquee_int")]
internal static extern void LibVLCVideoSetMarqueeInt(IntPtr mediaPlayer, VideoMarqueeOption option, int marqueeValue);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
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,
EntryPoint = "libvlc_video_get_logo_int")]
internal static extern int LibVLCVideoGetLogoInt(IntPtr mediaPlayer, VideoLogoOption option);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_logo_int")]
internal static extern void LibVLCVideoSetLogoInt(IntPtr mediaPlayer, VideoLogoOption option, int value);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_logo_string")]
internal static extern void LibVLCVideoSetLogoString(IntPtr mediaPlayer, VideoLogoOption option,
[MarshalAs(UnmanagedType.LPStr)] string logoOptionValue);
internal static extern void LibVLCVideoSetLogoString(IntPtr mediaPlayer, VideoLogoOption option, IntPtr logoOptionValue);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_adjust_int")]
internal static extern int LibVLCVideoGetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_set_adjust_int")]
internal static extern void LibVLCVideoSetAdjustInt(IntPtr mediaPlayer, VideoAdjustOption option, int value);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_video_get_adjust_float")]
internal static extern float LibVLCVideoGetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option);
......@@ -589,12 +556,11 @@ namespace LibVLCSharp.Shared
EntryPoint = "libvlc_video_set_adjust_float")]
internal static extern void LibVLCVideoSetAdjustFloat(IntPtr mediaPlayer, VideoAdjustOption option, float value);
//TODO: UTF8
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_media_player_add_slave")]
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,
EntryPoint = "libvlc_video_new_viewpoint")]
......@@ -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="rate">sample rate (expressed in Hz)</param>
/// <param name="channels">channels count</param>
public void SetAudioFormat(string format, uint rate, uint channels)
{
Native.LibVLCAudioSetFormat(NativeReference, format, rate, channels);
}
public void SetAudioFormat(string format, uint rate, uint channels) => Native.LibVLCAudioSetFormat(NativeReference, format.ToUtf8(), rate, channels);
/// <summary>
/// Selects an audio output module.
/// Note:
......@@ -1076,7 +1039,7 @@ namespace LibVLCSharp.Shared
/// </summary>
/// <param name="name">name of audio output, use psz_name of</param>
/// <returns>0 if function succeeded, -1 on error</returns>
public int SetAudioOutput(string name) => Native.LibVLCAudioOutputSet(NativeReference, name);
public int SetAudioOutput(string name) => Native.LibVLCAudioOutputSet(NativeReference, name.ToUtf8());
// TODO
/// <summary>
......@@ -1090,11 +1053,8 @@ namespace LibVLCSharp.Shared
}
}
public void OutputDeviceSet(string deviceId, string module = null)
{
Native.LibVLCAudioOutputDeviceSet(NativeReference, module, deviceId);
}
public void OutputDeviceSet(string deviceId, string module = null) => Native.LibVLCAudioOutputDeviceSet(NativeReference, module.ToUtf8(), deviceId.ToUtf8());
/// <summary>
/// Toggle mute status.
/// Warning
......@@ -1103,11 +1063,8 @@ namespace LibVLCSharp.Shared
/// Thus, there is a small race condition where toggling will not work.
/// See also the limitations of libvlc_audio_set_mute().
/// </summary>
public void ToggleMute()
{
Native.LibVLCAudioToggleMute(NativeReference);
}
public void ToggleMute() => Native.LibVLCAudioToggleMute(NativeReference);
/// <summary>
/// Get current mute status.
/// Set mute status.
......@@ -1232,7 +1189,7 @@ namespace LibVLCSharp.Shared
/// <param name="pitch">line pitch (in bytes)</param>
public void SetVideoFormat(string chroma, uint width, uint height, uint pitch)
{
Native.LibVLCVideoSetFormat(NativeReference, chroma, width, height, pitch);
Native.LibVLCVideoSetFormat(NativeReference, chroma.ToUtf8(), width, height, pitch);
}
/// <summary>
......@@ -1328,8 +1285,8 @@ namespace LibVLCSharp.Shared
/// </summary>
public string AspectRatio
{
get => Native.LibVLCVideoGetAspectRatio(NativeReference);
set => Native.LibVLCVideoSetAspectRatio(NativeReference, value);
get => Native.LibVLCVideoGetAspectRatio(NativeReference).FromUtf8();
set => Native.LibVLCVideoSetAspectRatio(NativeReference, value.ToUtf8());
}
public int Spu => Native.LibVLCVideoGetSpu(NativeReference);
......@@ -1360,7 +1317,7 @@ namespace LibVLCSharp.Shared
/// </summary>
/// <param name="subtitle">new video subtitle file</param>
/// <returns></returns>
public bool SetSubtitleFile(string subtitle) => Native.LibVLCVideoSetSubtitleFile(NativeReference, subtitle) != 0;
public bool SetSubtitleFile(string subtitle) => Native.LibVLCVideoSetSubtitleFile(NativeReference, subtitle.ToUtf8()) != 0;
/// <summary>
/// Get the current subtitle delay.
......@@ -1403,8 +1360,8 @@ namespace LibVLCSharp.Shared
/// </summary>
public string CropGeometry
{
get => Native.LibVLCVideoGetCropGeometry(NativeReference);
set => Native.LibVLCVideoSetCropGeometry(NativeReference, value);
get => Native.LibVLCVideoGetCropGeometry(NativeReference).FromUtf8();
set => Native.LibVLCVideoSetCropGeometry(NativeReference, value.ToUtf8());
}
/// <summary>
......@@ -1454,13 +1411,13 @@ namespace LibVLCSharp.Shared
/// <param name="height">the snapshot's height</param>
/// <returns>true on success</returns>
public bool TakeSnapshot(uint num, string filePath, uint width, uint height) =>
Native.LibVLCVideoTakeSnapshot(NativeReference, num, filePath, width, height) == 0;
Native.LibVLCVideoTakeSnapshot(NativeReference, num, filePath.ToUtf8(), width, height) == 0;
/// <summary>
/// Enable or disable deinterlace filter
/// </summary>
/// <param name="mode">type of deinterlace filter, empty string to disable</param>
public void SetDeinterlace(string mode) => Native.LibVLCVideoSetDeinterlace(NativeReference, mode);
public void SetDeinterlace(string mode) => Native.LibVLCVideoSetDeinterlace(NativeReference, mode.ToUtf8());
/// <summary>
/// Get an integer marquee option value
......@@ -1474,7 +1431,7 @@ namespace LibVLCSharp.Shared
/// </summary>
/// <param name="option">marq option to get</param>
/// <returns></returns>
public string MarqueeString(VideoMarqueeOption option) => Native.LibVLCVideoGetMarqueeString(NativeReference, option);
public string MarqueeString(VideoMarqueeOption option) => Native.LibVLCVideoGetMarqueeString(NativeReference, option).FromUtf8();
/// <summary>
/// Enable, disable or set an integer marquee option
......@@ -1492,7 +1449,7 @@ namespace LibVLCSharp.Shared
/// <param name="option">marq option to set</param>
/// <param name="value">marq option value</param>
public void SetMarqueeString(VideoMarqueeOption option, string value) =>
Native.LibVLCVideoSetMarqueeString(NativeReference, option, value);
Native.LibVLCVideoSetMarqueeString(NativeReference, option, value.ToUtf8());
/// <summary>
/// Get integer logo option.
......@@ -1515,7 +1472,7 @@ namespace LibVLCSharp.Shared
/// </summary>
/// <param name="option">logo option to set, values of libvlc_video_logo_option_t</param>
/// <param name="value">logo option value</param>
public void SetLogoString(VideoLogoOption option, string value) => Native.LibVLCVideoSetLogoString(NativeReference, option, value);
public void SetLogoString(VideoLogoOption option, string value) => Native.LibVLCVideoSetLogoString(NativeReference, option, value.ToUtf8());
/// <summary>
/// Get integer adjust option.
......@@ -1560,7 +1517,7 @@ namespace LibVLCSharp.Shared
/// <param name="select">True if this slave should be selected when it's loaded</param>
/// <returns></returns>
public bool AddSlave(MediaSlaveType type, string uri, bool select) =>
Native.LibVLCMediaPlayerAddSlave(NativeReference, type, uri, select) == 0;
Native.LibVLCMediaPlayerAddSlave(NativeReference, type, uri.ToUtf8(), select) == 0;
/// <summary>
/// Current 360 viewpoint of this mediaplayer.
......
......@@ -16,7 +16,7 @@ namespace LibVLCSharp.Shared
{
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_renderer_discoverer_new")]
internal static extern IntPtr LibVLCRendererDiscovererNew(IntPtr libvlc, string name);
internal static extern IntPtr LibVLCRendererDiscovererNew(IntPtr libvlc, IntPtr name);
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl,
EntryPoint = "libvlc_renderer_discoverer_release")]
......@@ -41,7 +41,7 @@ namespace LibVLCSharp.Shared
/// <param name="libVLC">libvlc instance this will be connected to</param>
/// <param name="name">The service discovery protocol name depending on platform. Use LibVLC.RendererList to find the one for your platform</param>
public RendererDiscoverer(LibVLC libVLC, string name)
: base(() => Native.LibVLCRendererDiscovererNew(libVLC.NativeReference, name), Native.LibVLCRendererDiscovererRelease)
: base(() => Native.LibVLCRendererDiscovererNew(libVLC.NativeReference, name.ToUtf8()), Native.LibVLCRendererDiscovererRelease)
{
}
......
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