Exemple #1
0
    public static OperatingSystemArchitecture GetCPUArchitecture(ManagementScope scope, int major)
    {
        OperatingSystemArchitecture systemArchitecture = OperatingSystemArchitecture.x86;

        if (major == 5)
        {
            ObjectQuery query = new ObjectQuery("Select Architecture From WIN32_Processor");
            using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = new ManagementObjectSearcher(scope, query).Get().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    systemArchitecture = (OperatingSystemArchitecture)(short)(ushort)enumerator.Current["Architecture"];
                }
            }
        }
        else if (major == 6)
        {
            ObjectQuery query = new ObjectQuery("Select OSArchitecture From WIN32_OperatingSystem");
            using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = new ManagementObjectSearcher(scope, query).Get().GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    systemArchitecture = !enumerator.Current["OSArchitecture"].ToString().Contains("32") ? OperatingSystemArchitecture.x64 : OperatingSystemArchitecture.x86;
                }
            }
        }
        return(systemArchitecture);
    }
Exemple #2
0
        internal async Task DownloadLatestAndroidVersionWithProgressAndRetriesTest(OperatingSystemArchitecture arch)
        {
            var operatingSystemArchProvider = Substitute.For <IOperatingSystemArchitectureProvider>();

            operatingSystemArchProvider.GetArchitecture().Returns(x => arch);

            var ffmpegExecutablesPath = FFmpeg.ExecutablesPath;

            try
            {
                FFbinariesVersionInfo currentVersion = JsonConvert.DeserializeObject <FFbinariesVersionInfo>(File.ReadAllText(Resources.FFbinariesInfo));
                FFmpeg.SetExecutablesPath("assemblies");
                if (Directory.Exists("assemblies"))
                {
                    Directory.Delete("assemblies", true);
                }
                AndroidFFmpegDownloader  downloader = new AndroidFFmpegDownloader(operatingSystemArchProvider);
                IProgress <ProgressInfo> progress   = new Progress <ProgressInfo>();
                await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3);

                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffmpeg", arch, FFmpeg.ExecutablesPath)));
                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffprobe", arch, FFmpeg.ExecutablesPath)));
            }
            finally
            {
                FFmpeg.SetExecutablesPath(ffmpegExecutablesPath);
            }
        }
Exemple #3
0
        protected async Task GetLatestVersionForArchitecture(string path, OperatingSystemArchitecture arch, IProgress <ProgressInfo> progress = null, int retries = 0)
        {
            if (!CheckIfFilesExist(path))
            {
                return;
            }

            string link        = GenerateLink(arch);
            var    fullPackZip = await DownloadFile(link, progress, retries);

            Extract(fullPackZip, path ?? ".");
        }
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = FrameworkDescription != null?FrameworkDescription.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (RunningEnvironment != null ? RunningEnvironment.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (EntryAssemblyName != null ? EntryAssemblyName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (EntryAssemblyVersion != null ? EntryAssemblyVersion.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (LocalTimeString != null ? LocalTimeString.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (OperatingSystemPlatform != null ? OperatingSystemPlatform.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (OperatingSystemArchitecture != null ? OperatingSystemArchitecture.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (OperatingSystemVersion != null ? OperatingSystemVersion.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ProcessArchitecture != null ? ProcessArchitecture.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ProcessorCount != null ? ProcessorCount.GetHashCode() : 0);
                return(hashCode);
            }
        }
        internal async Task DownloadLatestAndroidVersionTest(OperatingSystemArchitecture arch)
        {
            var operatingSystemArchProvider = Substitute.For <IOperatingSystemArchitectureProvider>();

            operatingSystemArchProvider.GetArchitecture().Returns(x => arch);

            var ffmpegExecutablesPath = FFmpeg.ExecutablesPath;

            try
            {
                FFbinariesVersionInfo currentVersion = JsonConvert.DeserializeObject <FFbinariesVersionInfo>(File.ReadAllText(Resources.FFbinariesInfo));
                FFmpeg.SetExecutablesPath(_storageFixture.GetTempDirectory());
                AndroidFFmpegDownloader downloader = new AndroidFFmpegDownloader(operatingSystemArchProvider);
                await downloader.GetLatestVersion(FFmpeg.ExecutablesPath);

                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffmpeg", arch, FFmpeg.ExecutablesPath)));
                Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffprobe", arch, FFmpeg.ExecutablesPath)));
            }
            finally
            {
                FFmpeg.SetExecutablesPath(ffmpegExecutablesPath);
            }
        }
Exemple #6
0
        private string GenerateLink(OperatingSystemArchitecture arch)
        {
            if (arch == OperatingSystemArchitecture.Arm64)
            {
                return("https://xabe.net/ffmpeg/versions/ffmpeg-android-arm64.zip");
            }

            if (arch == OperatingSystemArchitecture.Arm)
            {
                return("https://xabe.net/ffmpeg/versions/ffmpeg-android-arm.zip");
            }

            if (arch == OperatingSystemArchitecture.X86)
            {
                return("https://xabe.net/ffmpeg/versions/ffmpeg-android-x86.zip");
            }

            if (arch == OperatingSystemArchitecture.X64)
            {
                return("https://xabe.net/ffmpeg/versions/ffmpeg-android-x86_64.zip");
            }

            return(string.Empty);
        }
Exemple #7
0
        public override async Task GetLatestVersion(string path, IProgress <ProgressInfo> progress = null, int retries = 0)
        {
            OperatingSystemArchitecture arch = _operatingSystemArchitectureProvider.GetArchitecture();

            await GetLatestVersionForArchitecture(path, arch, progress, retries);
        }
Exemple #8
0
 internal string ComputeFileDestinationPath(string filename, OperatingSystemArchitecture arch, string destinationPath)
 {
     return(Path.Combine(destinationPath ?? ".", filename));
 }