Commit 87464208 authored by Martin Finkel's avatar Martin Finkel

Add net40 target support

parent 354da4c5
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.1'"> <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.1'">
<DefineConstants>$(DefineConstants);NETSTANDARD1_1</DefineConstants> <DefineConstants>$(DefineConstants);NETSTANDARD1_1</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))"> <PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
<DefineConstants>$(DefineConstants);XAML;DESKTOP</DefineConstants> <DefineConstants>$(DefineConstants);NET40</DefineConstants>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.16299'"> <PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.16299'">
<DefineConstants>$(DefineConstants);NETFX_CORE;XAML;WINDOWS_UWP;WINDOWS</DefineConstants> <DefineConstants>$(DefineConstants);NETFX_CORE;XAML;WINDOWS_UWP;WINDOWS</DefineConstants>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<Summary>.NET bindings for LibVLC</Summary> <Summary>.NET bindings for LibVLC</Summary>
<Description>.NET bindings for LibVLC</Description> <Description>.NET bindings for LibVLC</Description>
<PackageTags>libvlc native xamarin .net video audio media mediaplayer</PackageTags> <PackageTags>libvlc native xamarin .net video audio media mediaplayer</PackageTags>
<TargetFrameworks>netstandard2.0;netstandard1.1;MonoAndroid81;Xamarin.iOS10;Xamarin.Mac20</TargetFrameworks> <TargetFrameworks>netstandard2.0;netstandard1.1;MonoAndroid81;Xamarin.iOS10;Xamarin.Mac20;net40</TargetFrameworks>
<RootNamespace>LibVLCSharp</RootNamespace> <RootNamespace>LibVLCSharp</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
<DefineConstants>$(DefineConstants);UNITY_ANDROID</DefineConstants> <DefineConstants>$(DefineConstants);UNITY_ANDROID</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" /> <PackageReference Condition="'$(TargetFramework)' != 'net40'"
Include="System.Runtime.InteropServices.RuntimeInformation"
Version="4.3.0" />
<Compile Include="Shared\**\*.cs" /> <Compile Include="Shared\**\*.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))"> <ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid'))">
......
...@@ -573,7 +573,7 @@ namespace LibVLCSharp.Shared ...@@ -573,7 +573,7 @@ namespace LibVLCSharp.Shared
{ {
var arrayResultPtr = IntPtr.Zero; var arrayResultPtr = IntPtr.Zero;
var count = Native.LibVLCMediaDiscovererListGet(NativeReference, category, ref arrayResultPtr); var count = Native.LibVLCMediaDiscovererListGet(NativeReference, category, ref arrayResultPtr);
#if NETSTANDARD1_1 #if NETSTANDARD1_1 || NET40
if (count == 0) return new MediaDiscoverer.Description[0]; if (count == 0) return new MediaDiscoverer.Description[0];
#else #else
if (count == 0) return Array.Empty<MediaDiscoverer.Description>(); if (count == 0) return Array.Empty<MediaDiscoverer.Description>();
...@@ -646,7 +646,7 @@ namespace LibVLCSharp.Shared ...@@ -646,7 +646,7 @@ namespace LibVLCSharp.Shared
updateProgress(dlg, position, text); updateProgress(dlg, position, text);
} }
}; };
_dialogCbsPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DialogCallbacks))); _dialogCbsPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DialogCallbacks)));
Marshal.StructureToPtr(dialogCbs, _dialogCbsPtr, true); Marshal.StructureToPtr(dialogCbs, _dialogCbsPtr, true);
Native.LibVLCDialogSetCallbacks(NativeReference, _dialogCbsPtr, IntPtr.Zero); Native.LibVLCDialogSetCallbacks(NativeReference, _dialogCbsPtr, IntPtr.Zero);
...@@ -722,7 +722,11 @@ namespace LibVLCSharp.Shared ...@@ -722,7 +722,11 @@ namespace LibVLCSharp.Shared
GetLogContext(ctx, out var module, out var file, out var line); GetLogContext(ctx, out var module, out var file, out var line);
// Do the notification on another thread, so that VLC is not interrupted by the logging // Do the notification on another thread, so that VLC is not interrupted by the logging
#if NET40
Task.Factory.StartNew(() => _log?.Invoke(NativeReference, new LogEventArgs(level, formattedDecodedMessage, module, file, line)));
#else
Task.Run(() => _log?.Invoke(NativeReference, new LogEventArgs(level, formattedDecodedMessage, module, file, line))); Task.Run(() => _log?.Invoke(NativeReference, new LogEventArgs(level, formattedDecodedMessage, module, file, line)));
#endif
} }
/// <summary> /// <summary>
......
...@@ -13,7 +13,7 @@ namespace LibVLCSharp.Shared ...@@ -13,7 +13,7 @@ namespace LibVLCSharp.Shared
var nativeRef = getRef(); var nativeRef = getRef();
if (nativeRef == IntPtr.Zero) if (nativeRef == IntPtr.Zero)
{ {
#if NETSTANDARD1_1 #if NETSTANDARD1_1 || NET40
return new TU[0]; return new TU[0];
#else #else
return Array.Empty<TU>(); return Array.Empty<TU>();
...@@ -56,7 +56,7 @@ namespace LibVLCSharp.Shared ...@@ -56,7 +56,7 @@ namespace LibVLCSharp.Shared
public static T PtrToStructure<T>(IntPtr ptr) public static T PtrToStructure<T>(IntPtr ptr)
{ {
#if NETSTANDARD1_1 #if NETSTANDARD1_1 || NET40
return (T)Marshal.PtrToStructure(ptr, typeof(T)); return (T)Marshal.PtrToStructure(ptr, typeof(T));
#else #else
return Marshal.PtrToStructure<T>(ptr); return Marshal.PtrToStructure<T>(ptr);
......
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