示例#1
0
        private static void ConvertCTexImage(
            NativeEnvironment e,
            ITexImage src,
            CTexImage *dst)
        {
            var mipmaps = src.Mipmaps;

            dst->mipmap_count   = mipmaps.Count;
            dst->mipmaps_length = mipmaps.Count;

            if (mipmaps.Count == 0)
            {
                dst->mipmaps = null;
                return;
            }

            var cmipmaps = e.AllocateStructArray <CTexMipmap>(mipmaps.Count);

            dst->mipmaps = cmipmaps;

            for (var i = 0; i < mipmaps.Count; i++)
            {
                ConvertCTexMipmap(e, mipmaps[i], &cmipmaps[i]);
            }
        }
示例#2
0
        public static CPackage *ConvertToCPackage(
            this NativeEnvironment e,
            Core.Package.Package package)
        {
            var pkg = e.AllocateStruct <CPackage>();

            pkg->magic       = e.ToCString(package.Magic);
            pkg->header_size = package.HeaderSize;
            pkg->entry_count = package.Entries.Count;

            if (package.Entries.Count == 0)
            {
                pkg->entries = null;
                return(pkg);
            }

            var entryArray = e.AllocateStructArray <CPackageEntry>(package.Entries.Count);

            for (var i = 0; i < package.Entries.Count; i++)
            {
                ConvertCPackageEntry(e, package.Entries[i], &entryArray[i]);
            }

            pkg->entries = entryArray;

            return(pkg);
        }
示例#3
0
        public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
        {
            var info = new FFMpegInstallInfo();

            // Windows builds: http://ffmpeg.zeranoe.com/builds/
            // Linux builds: http://johnvansickle.com/ffmpeg/
            // OS X builds: http://ffmpegmac.net/
            // OS X x64: http://www.evermeet.cx/ffmpeg/

            switch (environment.OperatingSystem)
            {
            case OperatingSystem.Osx:
            case OperatingSystem.Bsd:
                break;

            case OperatingSystem.Linux:

                info.ArchiveType = "7z";
                info.Version     = "20160215";
                break;
            }

            info.DownloadUrls = GetDownloadUrls(environment);

            return(info);
        }
示例#4
0
        private NativeEnvironment GetEnvironmentInfo()
        {
            var info = new NativeEnvironment
            {
                OperatingSystem = Startup.Common.OperatingSystem.Linux
            };

            var uname = GetUnixName();

            var sysName = uname.sysname ?? string.Empty;

            info.OperatingSystem = Startup.Common.OperatingSystem.Osx;

            var archX86 = new Regex("(i|I)[3-6]86");

            if (archX86.IsMatch(uname.machine))
            {
                info.SystemArchitecture = Architecture.X86;
            }
            else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
            {
                info.SystemArchitecture = Architecture.X86_X64;
            }
            else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
            {
                info.SystemArchitecture = Architecture.Arm;
            }

            info.OperatingSystemVersionString = string.IsNullOrWhiteSpace(sysName) ?
                                                System.Environment.OSVersion.VersionString :
                                                sysName;

            return(info);
        }
示例#5
0
        public static FFMpegDownloadInfo GetInfo(NativeEnvironment environment)
        {
            var info = new FFMpegDownloadInfo();

            // Windows builds: http://ffmpeg.zeranoe.com/builds/
            // Linux builds: http://johnvansickle.com/ffmpeg/
            // OS X builds: http://ffmpegmac.net/
            // OS X x64: http://www.evermeet.cx/ffmpeg/

            switch (environment.OperatingSystem)
            {
            case OperatingSystem.Bsd:
                break;

            case OperatingSystem.Linux:

                info.ArchiveType = "7z";
                info.Version     = "20150717";
                break;

            case OperatingSystem.Osx:

                info.ArchiveType = "7z";

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    info.Version = "20150827";
                    break;

                case Architecture.X86:
                    info.Version = "20150110";
                    break;
                }
                break;

            case OperatingSystem.Windows:

                info.FFMpegFilename  = "ffmpeg.exe";
                info.FFProbeFilename = "ffprobe.exe";
                info.Version         = "20150717";
                info.ArchiveType     = "7z";

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    break;

                case Architecture.X86:
                    break;
                }
                break;
            }

            info.DownloadUrls = GetDownloadUrls(environment);

            return(info);
        }
示例#6
0
 public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment)
 {
     _logger = logger;
     _appPaths = appPaths;
     _httpClient = httpClient;
     _zipClient = zipClient;
     _fileSystem = fileSystem;
     _environment = environment;
 }
示例#7
0
 public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment)
 {
     _logger      = logger;
     _appPaths    = appPaths;
     _httpClient  = httpClient;
     _zipClient   = zipClient;
     _fileSystem  = fileSystem;
     _environment = environment;
 }
示例#8
0
        public WCTexImage(CTexImage *self, NativeEnvironment environment)
        {
            Self = self;

            _mipmaps = new WCList <CTexMipmap, ITexMipmap>(
                &Self->mipmap_count,
                &Self->mipmaps,
                environment,
                (x, e) => new WCTexMipmap(x, e));
        }
示例#9
0
 public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, FFMpegInstallInfo ffmpegInstallInfo)
 {
     _logger            = logger;
     _appPaths          = appPaths;
     _httpClient        = httpClient;
     _zipClient         = zipClient;
     _fileSystem        = fileSystem;
     _environment       = environment;
     _ffmpegInstallInfo = ffmpegInstallInfo;
 }
示例#10
0
 public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, FFMpegInstallInfo ffmpegInstallInfo)
 {
     _logger = logger;
     _appPaths = appPaths;
     _httpClient = httpClient;
     _zipClient = zipClient;
     _fileSystem = fileSystem;
     _environment = environment;
     _ffmpegInstallInfo = ffmpegInstallInfo;
 }
示例#11
0
        public WCTexImageContainer(CTexImageContainer *self, NativeEnvironment environment)
        {
            Self = self;

            _magic  = new WCString(&self->magic, environment);
            _images = new WCList <CTexImage, ITexImage>(
                &Self->image_count,
                &Self->images,
                environment,
                (x, e) => new WCTexImage(x, e));
        }
示例#12
0
        public static FFMpegDownloadInfo GetInfo(NativeEnvironment environment)
        {
            var info = new FFMpegDownloadInfo();

            // Windows builds: http://ffmpeg.zeranoe.com/builds/
            // Linux builds: http://johnvansickle.com/ffmpeg/
            // OS X builds: http://ffmpegmac.net/
            // OS X x64: http://www.evermeet.cx/ffmpeg/

            switch (environment.OperatingSystem)
            {
                case OperatingSystem.Bsd:
                    break;
                case OperatingSystem.Linux:

                    info.ArchiveType = "7z";
                    info.Version = "20150917";
                    break;
                case OperatingSystem.Osx:

                    info.ArchiveType = "7z";

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            info.Version = "20160124";
                            break;
                        case Architecture.X86:
                            info.Version = "20150110";
                            break;
                    }
                    break;

                case OperatingSystem.Windows:

                    info.FFMpegFilename = "ffmpeg.exe";
                    info.FFProbeFilename = "ffprobe.exe";
                    info.Version = "20151111";
                    info.ArchiveType = "7z";

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            break;
                        case Architecture.X86:
                            break;
                    }
                    break;
            }

            info.DownloadUrls = GetDownloadUrls(environment);

            return info;
        }
示例#13
0
 private static void ConvertCPackageEntry(
     NativeEnvironment e,
     PackageEntry src,
     CPackageEntry *dst)
 {
     dst->offset    = src.Offset;
     dst->length    = src.Length;
     dst->bytes     = src.Bytes == null ? null : e.Pin(src.Bytes);
     dst->type      = src.Type;
     dst->full_path = e.ToCString(src.FullPath);
 }
示例#14
0
        public WCTexFrameInfoContainer(CTexFrameInfoContainer *self, NativeEnvironment environment)
        {
            Self = self;

            _magic = new WCString(&self->magic, environment);

            _frames = new WCList <CTexFrameInfo, ITexFrameInfo>(
                &Self->frame_count,
                &Self->frames,
                environment,
                (x, _) => new WCTexFrameInfo(x));
        }
示例#15
0
        public static void Initialize()
        {
            lock (_lock)
            {
                if (_initialized)
                {
                    return;
                }

                NativeEnvironment.Initialize();
                _initialized = true;
            }
        }
示例#16
0
 private static void ConvertCTexMipmap(
     NativeEnvironment e,
     ITexMipmap src,
     CTexMipmap *dst)
 {
     dst->bytes       = e.Pin(src.Bytes);
     dst->bytes_count = src.Bytes.Length;
     dst->width       = src.Width;
     dst->height      = src.Height;
     dst->decompressed_bytes_count = src.DecompressedBytesCount;
     dst->is_lz4_compressed        = src.IsLZ4Compressed;
     dst->format = src.Format;
 }
示例#17
0
        private static string[] GetDownloadUrls(NativeEnvironment environment)
        {
            switch (environment.SystemArchitecture)
            {
            case Architecture.X64:
                return(new[]
                {
                    "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z"
                });
            }

            // No version available
            return(new string[] { });
        }
示例#18
0
 private static void ConvertCTexFrameInfo(
     NativeEnvironment e,
     ITexFrameInfo src,
     CTexFrameInfo *dst)
 {
     dst->image_id  = src.ImageId;
     dst->frametime = src.Frametime;
     dst->x         = src.X;
     dst->y         = src.Y;
     dst->width     = src.Width;
     dst->unk0      = src.Unk0;
     dst->unk1      = src.Unk1;
     dst->height    = src.Height;
 }
示例#19
0
        private static string[] GetDownloadUrls(NativeEnvironment environment)
        {
            switch (environment.OperatingSystem)
            {
            case OperatingSystem.Osx:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.5.3.7z"
                    });
                }
                break;

            case OperatingSystem.Linux:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z"
                    });

                case Architecture.Arm:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-arm.7z"
                    });
                }
                break;
            }

            // No version available
            return(new string[] { });
        }
示例#20
0
文件: CTex.cs 项目: woydmw/repkg
        public WCTex(CTex *self, NativeEnvironment environment)
        {
            Self         = self;
            _environment = environment;

            _wcTexHeader         = new WCTexHeader(&self->header);
            _wcTexImageContainer = new WCTexImageContainer(&self->images_container, _environment);

            _magic1 = new WCString(&self->magic1, environment);
            _magic2 = new WCString(&self->magic2, environment);

            if (Self->frameinfo_container != null)
            {
                _wcTexFrameInfoContainer = new WCTexFrameInfoContainer(Self->frameinfo_container, environment);
            }
        }
示例#21
0
        public static FFMpegInstallInfo GetInfo(NativeEnvironment environment)
        {
            var info = new FFMpegInstallInfo();

            info.ArchiveType = "7z";

            switch (environment.SystemArchitecture)
            {
            case Architecture.X64:
                info.Version = "20160124";
                break;

            case Architecture.X86:
                info.Version = "20150110";
                break;
            }

            info.DownloadUrls = GetDownloadUrls(environment);

            return(info);
        }
示例#22
0
 public static void SetEnv(string name, string value)
 {
     NativeEnvironment.SetEnv(name, value);
 }
示例#23
0
        private static string[] GetDownloadUrls(NativeEnvironment environment)
        {
            switch (environment.OperatingSystem)
            {
            case OperatingSystem.Windows:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20141111-git-48efe9e-win64-static.7z",
                        "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141111-git-48efe9e-win64-static.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20141111-git-48efe9e-win32-static.7z",
                        "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141111-git-48efe9e-win32-static.7z"
                    });
                }
                break;

            case OperatingSystem.Osx:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.4.1.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.4.2.7z"
                    });
                }
                break;

            case OperatingSystem.Linux:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz",
                        "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.64bit.2014-07-16.tar.gz"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.latest.tar.gz",
                        "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.32bit.2014-07-16.tar.gz"
                    });
                }
                break;
            }

            // No version available
            return(new string[] { });
        }
示例#24
0
        private static string[] GetDownloadUrls(NativeEnvironment environment)
        {
            switch (environment.OperatingSystem)
            {
                case OperatingSystem.Windows:

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            return new[]
                            {
                                "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20141111-git-48efe9e-win64-static.7z",
                                "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141111-git-48efe9e-win64-static.7z"
                            };
                        case Architecture.X86:
                            return new[]
                            {
                                "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20141111-git-48efe9e-win32-static.7z",
                                "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/windows/ffmpeg-20141111-git-48efe9e-win32-static.7z"
                            };
                    }
                    break;

                case OperatingSystem.Osx:

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.4.1.7z"
                            };
                        case Architecture.X86:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.4.2.7z"
                            };
                    }
                    break;

                case OperatingSystem.Linux:

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            return new[]
                            {
                                "http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz",
                                "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.64bit.2014-07-16.tar.gz"
                            };
                        case Architecture.X86:
                            return new[]
                            {
                                "http://ffmpeg.gusari.org/static/32bit/ffmpeg.static.32bit.latest.tar.gz",
                                "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/linux/ffmpeg.static.32bit.2014-07-16.tar.gz"
                            };
                    }
                    break;
            }

            // No version available 
            return new string[] { };
        }
示例#25
0
        public async Task <FFMpegInfo> GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress <double> progress)
        {
            var customffMpegPath  = options.GetOption("-ffmpeg");
            var customffProbePath = options.GetOption("-ffprobe");

            if (!string.IsNullOrWhiteSpace(customffMpegPath) && !string.IsNullOrWhiteSpace(customffProbePath))
            {
                return(new FFMpegInfo
                {
                    ProbePath = customffProbePath,
                    EncoderPath = customffMpegPath,
                    Version = "custom"
                });
            }

            var downloadInfo = FFMpegDownloadInfo.GetInfo(environment);

            var version = downloadInfo.Version;

            if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
            {
                return(new FFMpegInfo
                {
                    ProbePath = downloadInfo.FFProbeFilename,
                    EncoderPath = downloadInfo.FFMpegFilename,
                    Version = version
                });
            }

            var rootEncoderPath        = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
            var versionedDirectoryPath = Path.Combine(rootEncoderPath, version);

            var info = new FFMpegInfo
            {
                ProbePath   = Path.Combine(versionedDirectoryPath, downloadInfo.FFProbeFilename),
                EncoderPath = Path.Combine(versionedDirectoryPath, downloadInfo.FFMpegFilename),
                Version     = version
            };

            Directory.CreateDirectory(versionedDirectoryPath);

            var excludeFromDeletions = new List <string> {
                versionedDirectoryPath
            };

            if (!File.Exists(info.ProbePath) || !File.Exists(info.EncoderPath))
            {
                // ffmpeg not present. See if there's an older version we can start with
                var existingVersion = GetExistingVersion(info, rootEncoderPath);

                // No older version. Need to download and block until complete
                if (existingVersion == null)
                {
                    await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false);
                }
                else
                {
                    // Older version found.
                    // Start with that. Download new version in the background.
                    var newPath = versionedDirectoryPath;
                    Task.Run(() => DownloadFFMpegInBackground(downloadInfo, newPath));

                    info = existingVersion;
                    versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath);

                    excludeFromDeletions.Add(versionedDirectoryPath);
                }
            }

            await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false);

            DeleteOlderFolders(Path.GetDirectoryName(versionedDirectoryPath), excludeFromDeletions);

            return(info);
        }
示例#26
0
        private static string[] GetDownloadUrls(NativeEnvironment environment)
        {
            switch (environment.OperatingSystem)
            {
                case OperatingSystem.Windows:

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20151111-win64.7z",
                                "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20151109-git-480bad7-win64-static.7z"
                            };
                        case Architecture.X86:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20151111-win32.7z",
                                "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20151109-git-480bad7-win32-static.7z"
                            };
                    }
                    break;

                case OperatingSystem.Osx:

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z"
                            };
                        case Architecture.X86:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.5.3.7z"
                            };
                    }
                    break;

                case OperatingSystem.Linux:

                    switch (environment.SystemArchitecture)
                    {
                        case Architecture.X86_X64:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.8.0-64bit-static.7z"
                            };
                        case Architecture.X86:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.8.0-32bit-static.7z"
                            };
                        case Architecture.Arm:
                            return new[]
                            {
                                "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-arm.7z"
                            };
                    }
                    break;
            }

            // No version available 
            return new string[] { };
        }
示例#27
0
        public async Task <FFMpegInfo> GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress <double> progress)
        {
            var customffMpegPath  = options.GetOption("-ffmpeg");
            var customffProbePath = options.GetOption("-ffprobe");

            if (!string.IsNullOrWhiteSpace(customffMpegPath) && !string.IsNullOrWhiteSpace(customffProbePath))
            {
                return(new FFMpegInfo
                {
                    ProbePath = customffProbePath,
                    EncoderPath = customffMpegPath,
                    Version = "external"
                });
            }

            var downloadInfo = _ffmpegInstallInfo;

            var version = downloadInfo.Version;

            if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
            {
                return(new FFMpegInfo
                {
                    ProbePath = downloadInfo.FFProbeFilename,
                    EncoderPath = downloadInfo.FFMpegFilename,
                    Version = version
                });
            }

            if (string.Equals(version, "0", StringComparison.OrdinalIgnoreCase))
            {
                return(new FFMpegInfo());
            }

            var rootEncoderPath        = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
            var versionedDirectoryPath = Path.Combine(rootEncoderPath, version);

            var info = new FFMpegInfo
            {
                ProbePath   = Path.Combine(versionedDirectoryPath, downloadInfo.FFProbeFilename),
                EncoderPath = Path.Combine(versionedDirectoryPath, downloadInfo.FFMpegFilename),
                Version     = version
            };

            _fileSystem.CreateDirectory(versionedDirectoryPath);

            var excludeFromDeletions = new List <string> {
                versionedDirectoryPath
            };

            if (!_fileSystem.FileExists(info.ProbePath) || !_fileSystem.FileExists(info.EncoderPath))
            {
                // ffmpeg not present. See if there's an older version we can start with
                var existingVersion = GetExistingVersion(info, rootEncoderPath);

                // No older version. Need to download and block until complete
                if (existingVersion == null)
                {
                    var success = await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false);

                    if (!success)
                    {
                        return(new FFMpegInfo());
                    }
                }
                else
                {
                    info = existingVersion;
                    versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath);
                    excludeFromDeletions.Add(versionedDirectoryPath);
                }
            }

            if (_environment.OperatingSystem == OperatingSystem.Windows)
            {
                await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false);
            }

            DeleteOlderFolders(Path.GetDirectoryName(versionedDirectoryPath), excludeFromDeletions);

            // Allow just one of these to be overridden, if desired.
            if (!string.IsNullOrWhiteSpace(customffMpegPath))
            {
                info.EncoderPath = customffMpegPath;
            }
            if (!string.IsNullOrWhiteSpace(customffProbePath))
            {
                info.EncoderPath = customffProbePath;
            }

            return(info);
        }
示例#28
0
 public WCTexMipmap(CTexMipmap *self, NativeEnvironment environment)
 {
     Self         = self;
     _environment = environment;
 }
示例#29
0
        public static CTex *ConvertToCTex(
            this NativeEnvironment e,
            ITex tex)
        {
            // tex
            var ctex = e.AllocateStruct <CTex>();

            ctex->magic1 = e.ToCString(tex.Magic1);
            ctex->magic2 = e.ToCString(tex.Magic2);

            // header
            var header = tex.Header;

            ctex->header.format         = header.Format;
            ctex->header.flags          = header.Flags;
            ctex->header.texture_width  = header.TextureWidth;
            ctex->header.texture_height = header.TextureHeight;
            ctex->header.image_width    = header.ImageWidth;
            ctex->header.image_height   = header.ImageHeight;
            ctex->header.unk_int0       = header.UnkInt0;

            // images container
            var imgContainer = tex.ImagesContainer;
            var images       = imgContainer.Images;

            ctex->images_container.magic             = e.ToCString(imgContainer.Magic);
            ctex->images_container.image_format      = imgContainer.ImageFormat;
            ctex->images_container.image_count       = images.Count;
            ctex->images_container.images_length     = images.Count;
            ctex->images_container.container_version = imgContainer.ImageContainerVersion;

            if (images.Count == 0)
            {
                ctex->images_container.images = null;
            }
            else
            {
                var cimages = e.AllocateStructArray <CTexImage>(images.Count);
                ctex->images_container.images = cimages;

                for (var i = 0; i < images.Count; i++)
                {
                    ConvertCTexImage(e, images[i], &cimages[i]);
                }
            }

            // frame info container
            var frameContainer = tex.FrameInfoContainer;

            if (frameContainer == null)
            {
                ctex->frameinfo_container = null;
                return(ctex);
            }

            var frames = frameContainer.Frames;

            ctex->frameinfo_container                = e.AllocateStruct <CTexFrameInfoContainer>();
            ctex->frameinfo_container->magic         = e.ToCString(frameContainer.Magic);
            ctex->frameinfo_container->frame_count   = frames.Count;
            ctex->frameinfo_container->frames_length = frames.Count;
            ctex->frameinfo_container->gif_width     = frameContainer.GifWidth;
            ctex->frameinfo_container->gif_height    = frameContainer.GifHeight;

            if (frames.Count == 0)
            {
                ctex->frameinfo_container->frames = null;
                return(ctex);
            }

            var cframes = e.AllocateStructArray <CTexFrameInfo>(frames.Count);

            ctex->frameinfo_container->frames = cframes;

            for (var i = 0; i < frames.Count; i++)
            {
                ConvertCTexFrameInfo(e, frames[i], &cframes[i]);
            }

            return(ctex);
        }
示例#30
0
        private static string[] GetDownloadUrls(NativeEnvironment environment)
        {
            switch (environment.OperatingSystem)
            {
            case OperatingSystem.Windows:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "http://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20150717-git-8250943-win64-static.7z",
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20150901-git-b54e03c-win64-static.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20150717-git-8250943-win32-static.7z",
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/windows/ffmpeg-20150901-git-b54e03c-win32-static.7z"
                    });
                }
                break;

            case OperatingSystem.Osx:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.7.2.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.5.3.7z"
                    });
                }
                break;

            case OperatingSystem.Linux:

                switch (environment.SystemArchitecture)
                {
                case Architecture.X86_X64:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.7.1-64bit-static.7z"
                    });

                case Architecture.X86:
                    return(new[]
                    {
                        "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-2.7.1-32bit-static.7z"
                    });
                }
                break;
            }

            // No version available
            return(new string[] { });
        }
示例#31
0
        public async Task<FFMpegInfo> GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress<double> progress)
        {
            var customffMpegPath = options.GetOption("-ffmpeg");
            var customffProbePath = options.GetOption("-ffprobe");

            if (!string.IsNullOrWhiteSpace(customffMpegPath) && !string.IsNullOrWhiteSpace(customffProbePath))
            {
                return new FFMpegInfo
                {
                    ProbePath = customffProbePath,
                    EncoderPath = customffMpegPath,
                    Version = "custom"
                };
            }

            var downloadInfo = FFMpegDownloadInfo.GetInfo(environment);

            var version = downloadInfo.Version;

            if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
            {
                return new FFMpegInfo
                {
                    ProbePath = downloadInfo.FFProbeFilename,
                    EncoderPath = downloadInfo.FFMpegFilename,
                    Version = version
                };
            }

            var rootEncoderPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
            var versionedDirectoryPath = Path.Combine(rootEncoderPath, version);

            var info = new FFMpegInfo
            {
                ProbePath = Path.Combine(versionedDirectoryPath, downloadInfo.FFProbeFilename),
                EncoderPath = Path.Combine(versionedDirectoryPath, downloadInfo.FFMpegFilename),
                Version = version
            };

			_fileSystem.CreateDirectory(versionedDirectoryPath);

            var excludeFromDeletions = new List<string> { versionedDirectoryPath };

			if (!_fileSystem.FileExists(info.ProbePath) || !_fileSystem.FileExists(info.EncoderPath))
            {
                // ffmpeg not present. See if there's an older version we can start with
                var existingVersion = GetExistingVersion(info, rootEncoderPath);

                // No older version. Need to download and block until complete
                if (existingVersion == null)
                {
                    await DownloadFFMpeg(downloadInfo, versionedDirectoryPath, progress).ConfigureAwait(false);
                }
                else
                {
                    // Older version found. 
                    // Start with that. Download new version in the background.
                    var newPath = versionedDirectoryPath;
                    Task.Run(() => DownloadFFMpegInBackground(downloadInfo, newPath));

                    info = existingVersion;
                    versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath);

                    excludeFromDeletions.Add(versionedDirectoryPath);
                }
            }

            await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false);

            DeleteOlderFolders(Path.GetDirectoryName(versionedDirectoryPath), excludeFromDeletions);

            // Allow just one of these to be overridden, if desired.
            if (!string.IsNullOrWhiteSpace(customffMpegPath))
            {
                info.EncoderPath = customffMpegPath;
            }
            if (!string.IsNullOrWhiteSpace(customffProbePath))
            {
                info.EncoderPath = customffProbePath;
            }

            return info;
        }