This commit is contained in:
Luke Pulverenti 2014-01-22 12:05:36 -05:00
commit 529a397b69

View file

@ -1,6 +1,8 @@
using System; using System;
#if __MonoCS__ #if __MonoCS__
using System.Runtime.InteropServices; using Mono.Unix.Native;
using System.Text.RegularExpressions;
using System.IO;
#endif #endif
namespace MediaBrowser.ServerApplication.FFMpeg namespace MediaBrowser.ServerApplication.FFMpeg
@ -41,7 +43,9 @@ namespace MediaBrowser.ServerApplication.FFMpeg
#if __MonoCS__ #if __MonoCS__
case PlatformID.Unix: case PlatformID.Unix:
if (IsRunningOnMac()) if (PlatformDetection.IsMac)
{
if (PlatformDetection.IsX86_64)
{ {
switch (arg) switch (arg)
{ {
@ -56,13 +60,15 @@ namespace MediaBrowser.ServerApplication.FFMpeg
} }
break; break;
} }
else }
if (PlatformDetection.IsLinux)
{
if (PlatformDetection.IsX86)
{ {
// Linux
switch (arg) switch (arg)
{ {
case "Version": case "Version":
return "20140104"; return "linux_x86_20140118";
case "FFMpegFilename": case "FFMpegFilename":
return "ffmpeg"; return "ffmpeg";
case "FFProbeFilename": case "FFProbeFilename":
@ -72,6 +78,25 @@ namespace MediaBrowser.ServerApplication.FFMpeg
} }
break; break;
} }
else if (PlatformDetection.IsX86_64)
{
// Linux on x86 or x86_64
switch (arg)
{
case "Version":
return "linux_x86_64_20140118";
case "FFMpegFilename":
return "ffmpeg";
case "FFProbeFilename":
return "ffprobe";
case "ArchiveType":
return "gz";
}
break;
}
}
// Unsupported Unix platform
return "";
#endif #endif
} }
return ""; return "";
@ -92,52 +117,81 @@ namespace MediaBrowser.ServerApplication.FFMpeg
#if __MonoCS__ #if __MonoCS__
case PlatformID.Unix: case PlatformID.Unix:
if (IsRunningOnMac()) if (PlatformDetection.IsMac && PlatformDetection.IsX86_64)
{ {
// Mac OS X Intel 64bit
return new[] return new[]
{ {
"https://copy.com/IB0W4efS6t9A/ffall-2.1.1.tar.gz?download=1" "https://copy.com/IB0W4efS6t9A/ffall-2.1.1.tar.gz?download=1"
}; };
} }
else
if (PlatformDetection.IsLinux)
{
if (PlatformDetection.IsX86)
{ {
// Linux
return new[] return new[]
{ {
"http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.2014-01-04.tar.gz", "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.2014-01-18.tar.gz",
"https://www.dropbox.com/s/b7nkg71sil812hp/ffmpeg.static.32bit.2014-01-04.tar.gz?dl=1" "https://www.dropbox.com/s/b7nkg71sil812hp/ffmpeg.static.32bit.2014-01-04.tar.gz?dl=1"
}; };
} }
#endif
if (PlatformDetection.IsX86_64)
{
return new[]
{
"http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.2014-01-18.tar.gz"
};
} }
}
//No Unix version available
return new string[] {}; return new string[] {};
#endif
}
return new string[] {};
}
} }
#if __MonoCS__ #if __MonoCS__
// From mono/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs public static class PlatformDetection
[DllImport ("libc")]
static extern int uname (IntPtr buf);
static bool IsRunningOnMac()
{ {
IntPtr buf = IntPtr.Zero; public readonly static bool IsWindows;
try { public readonly static bool IsMac;
buf = Marshal.AllocHGlobal (8192); public readonly static bool IsLinux;
// This is a hacktastic way of getting sysname from uname () public readonly static bool IsX86;
if (uname (buf) == 0) { public readonly static bool IsX86_64;
string os = Marshal.PtrToStringAnsi (buf); public readonly static bool IsArm;
if (os == "Darwin")
return true; static PlatformDetection ()
{
IsWindows = Path.DirectorySeparatorChar == '\\';
//Don't call uname on windows
if (!IsWindows)
{
Utsname uname;
var callResult = Syscall.uname(out uname);
if (callResult == 0)
{
IsMac = uname.sysname == "Darwin";
IsLinux = !IsMac && uname.sysname == "Linux";
Regex archX86 = new Regex("(i|I)[3-6]86");
IsX86 = archX86.IsMatch(uname.machine);
IsX86_64 = !IsX86 && uname.machine == "x86_64";
IsArm = !IsX86 && !IsX86 && uname.machine.StartsWith("arm");
}
}
else
{
if (System.Environment.Is64BitOperatingSystem)
IsX86_64 = true;
else
IsX86 = true;
} }
} catch {
} finally {
if (buf != IntPtr.Zero)
Marshal.FreeHGlobal (buf);
} }
return false;
} }
#endif #endif
}
} }