Exemple #1
0
        public static bool AudioEncodingNeeded(EncoderProfile aProfile)
        {
            switch (aProfile.Type)
            {
            case ProfileType.AC3:
            case ProfileType.FLAC:
                return(true);

            default:
                return(false);
            }
        }
        /// <summary>
        /// Removes a profile from the list
        /// </summary>
        /// <param name="inProfile"></param>
        /// <returns></returns>
        public bool RemoveProfile(EncoderProfile inProfile)
        {
            if (ProfileList == null)
            {
                return(false);
            }

            ProfileList.Remove(inProfile);
            TriggerUpdate();

            return(true);
        }
Exemple #3
0
        public static bool AudioProcessingNeeded(EncoderProfile aProfile)
        {
            int sampleRate = -1, channelOrder = -1;

            switch (aProfile.Type)
            {
            case ProfileType.AC3:
                sampleRate   = ((AC3Profile)aProfile).SampleRate;
                channelOrder = ((AC3Profile)aProfile).OutputChannels;
                break;

            case ProfileType.FLAC:
                break;

            default:
                return(false);
            }
            return(sampleRate > -1 || channelOrder > -1);
        }
Exemple #4
0
        void UpdaterDoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bw = (BackgroundWorker)sender;

            string status          = Processing.GetResourceString("update_downloading_status");
            string progressFmt     = Processing.GetResourceString("update_downloading_progress");
            string unzippingStatus = Processing.GetResourceString("update_unzipping");
            string reloadStatus    = Processing.GetResourceString("update_reload_versions");
            string finishedStatus  = Processing.GetResourceString("update_finished");
            string importProfiles  = Processing.GetResourceString("update_import_profiles");

            string tempPath = AppSettings.TempPath;

            foreach (ToolVersions item in _tempToolCollection)
            {
                string showName = item.ToolName;
                bw.ReportProgress(-1, string.Format(status, showName, item.ServerVersion));

                string outFPath = Path.GetDirectoryName(item.FileName);
                if (!string.IsNullOrEmpty(outFPath) && !Directory.Exists(outFPath))
                {
                    Directory.CreateDirectory(outFPath, DirSecurity.CreateDirSecurity(SecurityClass.Everybody));
                }
                tempPath = outFPath;

                WebClient downloader = new WebClient {
                    UseDefaultCredentials = true
                };
                downloader.DownloadFileAsync(new Uri(item.DownloadUri), item.FileName);

                ToolVersions lItem = item;

                downloader.DownloadProgressChanged += (s, ev) =>
                {
                    string progress = string.Format(progressFmt, showName, lItem.ServerVersion, ev.ProgressPercentage);
                    bw.ReportProgress(ev.ProgressPercentage, progress);
                };

                while (downloader.IsBusy)
                {
                    Thread.Sleep(200);
                }

                switch (lItem.DownloadType)
                {
                case AppType.Updater:
                    if (!string.IsNullOrEmpty(AppSettings.UpdaterPath) && !Directory.Exists(AppSettings.UpdaterPath))
                    {
                        Directory.CreateDirectory(AppSettings.UpdaterPath, DirSecurity.CreateDirSecurity(SecurityClass.Everybody));
                    }
                    bw.ReportProgress(-1, unzippingStatus);
                    try
                    {
                        using (SevenZipExtractor eFile = new SevenZipExtractor(lItem.FileName))
                        {
                            eFile.PreserveDirectoryStructure = true;
                            eFile.FileExtractionStarted     += (o, args) =>
                            {
                                if (args.FileInfo.IsDirectory)
                                {
                                    string outPath = Path.Combine(AppSettings.UpdaterPath, args.FileInfo.FileName);
                                    Directory.CreateDirectory(outPath, DirSecurity.CreateDirSecurity(SecurityClass.Everybody));
                                }
                            };
                            eFile.ExtractArchive(AppSettings.UpdaterPath);
                        }
                        File.Delete(item.FileName);
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorFormat("Error reading \"{0:s}\" -> {1:s}", item.FileName, ex.Message);
                    }
                    break;

                case AppType.Profiles:
                    try
                    {
                        bw.ReportProgress(-1, importProfiles);
                        List <EncoderProfile> importedProfiles = ProfilesHandler.ImportProfiles(lItem.FileName);
                        ProfilesHandler       profiles         = new ProfilesHandler();
                        foreach (EncoderProfile profile in profiles.ProfileList)
                        {
                            try
                            {
                                EncoderProfile selProfile =
                                    importedProfiles.Single(
                                        encoderProfile =>
                                        encoderProfile.Name == profile.Name && encoderProfile.Type == profile.Type);
                                importedProfiles.Remove(selProfile);
                            }
                            catch (Exception importException)
                            {
                                Log.Error(importException);
                            }
                        }
                        foreach (EncoderProfile encoderProfile in importedProfiles)
                        {
                            profiles.AddProfile(encoderProfile);
                        }

                        profiles.Destroy();
                        AppSettings.LastProfilesVer = lItem.ServerVersion;
                    }
                    catch (Exception exProfiles)
                    {
                        Log.Error(exProfiles);
                    }

                    break;

                default:
                {
                    _mainAppUpdate = true;
                    PackageInfo package = new PackageInfo
                    {
                        PackageName             = item.ToolName,
                        PackageLocation         = item.FileName,
                        Version                 = item.ServerVersion,
                        Destination             = item.Destination,
                        WriteVersion            = item.DownloadType == AppType.AviSynthPlugins,
                        ClearDirectory          = item.DownloadType == AppType.MainApp,
                        RecursiveClearDirectory = item.DownloadType == AppType.AviSynthPlugins
                    };
                    _packages.Add(package);
                }
                break;
                }
                bw.ReportProgress(-20, item);
            }

            if (_packages.Count > 0)
            {
                if (tempPath != null)
                {
                    MainAppUpdateFile = Path.Combine(tempPath, "update.xml");
                }
                Updater.SaveUpdateList(MainAppUpdateFile, _packages);
            }
            else
            {
                bw.ReportProgress(-1, reloadStatus);
                Processing.GetAppVersions();
            }

            bw.ReportProgress(0, finishedStatus);
        }
Exemple #5
0
 public override EncoderOptions Create()
 {
     return(new EncoderOptions
     {
         Format = Format,
         EncoderName = Name,
         EncoderArguments = $"{CurrentQualitySettings} " +
                            $"-preset {EncoderPreset.ToString().ToLowerInvariant()}" +
                            (EncoderTune == Tune.Auto ? "" : $" -tune {EncoderTune.ToString().ToLowerInvariant()}") +
                            (EncoderProfile == Profile.Auto ? "" : $" -profile:v {EncoderProfile.ToString().ToLowerInvariant()}")
     });
 }