Skip to content

Commit

Permalink
Revert "Basic multiplatform (#218)" (#226)
Browse files Browse the repository at this point in the history
This reverts commit d2fc566.
  • Loading branch information
Ruslan-B authored Oct 12, 2022
1 parent d2fc566 commit 14c0520
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 32 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,5 @@ UpgradeLog*.XML

*.stackdump

# JetBrains Rider
.idea/
*.sln.iml

# Local
/FFmpeg.AutoGen.Example/frame.*.jpg
2 changes: 1 addition & 1 deletion FFmpeg.AutoGen/FFmpeg.AutoGen.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0;net472;net45</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net472;net45</TargetFrameworks>
<GeneratePackageOnBuild Condition=" $(Configuration) == 'Release' ">true</GeneratePackageOnBuild>
<Description>FFmpeg auto generated unsafe bindings for C#/.NET and Mono.</Description>
</PropertyGroup>
Expand Down
13 changes: 0 additions & 13 deletions FFmpeg.AutoGen/FFmpeg.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using FFmpeg.AutoGen.Native;

namespace FFmpeg.AutoGen
Expand Down Expand Up @@ -39,23 +38,11 @@ static ffmpeg()
{
GetOrLoadLibrary = libraryName => LoadLibrary(libraryName, true);

#if NET
//BSD has #define EAGAIN 35 in errno.h, other OS have EAGAIN 11. Apple is based on BSD
bool bsdStyleErrno =
OperatingSystem.IsFreeBSD()
|| OperatingSystem.IsMacCatalyst()
|| OperatingSystem.IsMacOS()
|| OperatingSystem.IsIOS()
|| OperatingSystem.IsTvOS()
|| OperatingSystem.IsWatchOS();
EAGAIN = bsdStyleErrno ? 35 : 11;
#else
EAGAIN = LibraryLoader.GetPlatformId() switch
{
PlatformID.MacOSX => 35,
_ => 11
};
#endif
}

/// <summary>
Expand Down
16 changes: 2 additions & 14 deletions FFmpeg.AutoGen/Native/LibraryLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FFmpeg.AutoGen.Native
{
public delegate PlatformID? GetPlatformId();
public delegate PlatformID GetPlatformId();

public delegate string GetNativeLibraryName(string libraryName, int version);

Expand All @@ -16,23 +16,11 @@ static LibraryLoader()
{
#if NET45 || NET40
return Environment.OSVersion.Platform;
#elif NET
if (OperatingSystem.IsWindows())
return PlatformID.Win32NT;
if (OperatingSystem.IsMacCatalyst()
|| OperatingSystem.IsMacOS()
|| OperatingSystem.IsIOS()
|| OperatingSystem.IsTvOS()
|| OperatingSystem.IsWatchOS())
return PlatformID.MacOSX; // all share similar .dylib calling style. But only static libs on iOS store apps!
if (OperatingSystem.IsAndroid() || OperatingSystem.IsFreeBSD() || OperatingSystem.IsLinux())
return PlatformID.Unix;
return null;
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return PlatformID.Win32NT;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return PlatformID.Unix;
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) return PlatformID.MacOSX;
return null;
throw new PlatformNotSupportedException();
#endif
};

Expand Down

0 comments on commit 14c0520

Please sign in to comment.