Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Basic multiplatform" #226

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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