Ejemplo n.º 1
0
        public void ConstantRateFactor_Verify()
        {
            var settingWrong1 = new ConstantRateFactor(-1);
            var settingWrong2 = new ConstantRateFactor(60);
            var setting       = new ConstantRateFactor(18);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-crf 18");
        }
Ejemplo n.º 2
0
        public void CodecAudio_Verify()
        {
            var settingWrong1 = new CodecAudio(string.Empty);
            var settingWrong2 = new CodecAudio("  ");
            var setting       = new CodecAudio(AudioCodecType.LibFdk_Aac);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-c:a libfdk_aac");
        }
Ejemplo n.º 3
0
        public void Map_Verify()
        {
            var settingWrong1 = new Map(string.Empty);
            var settingWrong2 = new Map("  ");
            var setting       = new Map("output1");

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-map [output1]");
        }
Ejemplo n.º 4
0
        public void Channels_Verify()
        {
            var settingWrong1 = new ChannelOutput(0);
            var settingWrong2 = new ChannelOutput(-1);
            var setting       = new ChannelOutput(1);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-ac 1");
        }
Ejemplo n.º 5
0
            public void WellKnownAll()
            {
                var text = SettingSerializer.ConvertToString(CommandKeyBindings);
                var list = SettingSerializer.ConvertToCommandKeyBindings(text);

                Assert.Equal(CommandKeyBindings.Count, list.Count);
                for (int i = 0; i < list.Count; i++)
                {
                    ExpectEqual(CommandKeyBindings[i], list[i]);
                }
            }
Ejemplo n.º 6
0
        public void StartAt_Verify()
        {
            var settingWrong1 = new StartAt(0);
            var settingWrong2 = new StartAt(-1);
            var setting       = new StartAt(120);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-ss 00:02:00.0");
        }
Ejemplo n.º 7
0
        public void MovFlags_Verify()
        {
            var settingWrong1 = new MovFlags(string.Empty);
            var settingWrong2 = new MovFlags("  ");
            var setting       = new MovFlags(MovFlags.EnableFastStart);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-movflags +faststart");
        }
Ejemplo n.º 8
0
        public void ProfileVideo_Verify()
        {
            var settingWrong1 = new ProfileVideo(string.Empty);
            var settingWrong2 = new ProfileVideo("  ");
            var setting       = new ProfileVideo("baseline");

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-profile:v baseline");
        }
Ejemplo n.º 9
0
        public void PixelFormat_Verify()
        {
            var settingWrong1 = new PixelFormat(string.Empty);
            var settingWrong2 = new PixelFormat("  ");
            var setting       = new PixelFormat("yuv420p");

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-pix_fmt yuv420p");
        }
Ejemplo n.º 10
0
        public void FormatOutput_Verify()
        {
            var settingWrong1 = new FormatOutput(string.Empty);
            var settingWrong2 = new FormatOutput("  ");
            var setting       = new FormatOutput("mp4");

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-f mp4");
        }
Ejemplo n.º 11
0
        public void CodecVideo_Verify()
        {
            var settingWrong1 = new CodecVideo(string.Empty);
            var settingWrong2 = new CodecVideo("  ");
            var setting       = new CodecVideo(VideoCodecType.Libx264);

            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); });
            Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); });
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting));
            Assert.Equal(SettingSerializer.Serialize(setting), "-c:v libx264");
        }
Ejemplo n.º 12
0
        public void AvoidNegativeTimestamps_Verify()
        {
            var setting1 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.Auto);
            var setting2 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.Disabled);
            var setting3 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.MakeNonNegative);
            var setting4 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.MakeZero);

            Assert.Equal("-avoid_negative_ts auto", SettingSerializer.Serialize(setting1));
            Assert.Equal("-avoid_negative_ts disabled", SettingSerializer.Serialize(setting2));
            Assert.Equal("-avoid_negative_ts make_non_negative", SettingSerializer.Serialize(setting3));
            Assert.Equal("-avoid_negative_ts make_zero", SettingSerializer.Serialize(setting4));
        }
Ejemplo n.º 13
0
        public void FrameDropThreshold_Verify()
        {
            var setting1 = new FrameDropThreshold()
            {
                Threshold = 0
            };
            var setting2 = new FrameDropThreshold(0);

            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting1));
            Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting2));
            Assert.Equal(SettingSerializer.Serialize(setting1), "-frame_drop_threshold 0");
            Assert.Equal(SettingSerializer.Serialize(setting2), "-frame_drop_threshold 0");
        }
Ejemplo n.º 14
0
        private void WriteOutputSettings(CommandOutput output)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            output.Settings.SettingsList.ForEach(setting =>
            {
                BuilderBase.Append(" ");
                BuilderBase.Append(SettingSerializer.Serialize(setting));
            });
        }
Ejemplo n.º 15
0
        private void WriteResource(CommandInput resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            WriteResourcePreSettings(resource);

            var inputResource = new Input(resource.Resource);

            BuilderBase.Append(" ");
            BuilderBase.Append(SettingSerializer.Serialize(inputResource));

            WriteResourcePostSettings(resource);
        }
Ejemplo n.º 16
0
        private void WriteResourcePostSettings(CommandInput resource)
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            resource.Settings.SettingsList.ForEach(setting =>
            {
                if (!setting.IsPostSetting())
                {
                    return;
                }

                BuilderBase.Append(" ");
                BuilderBase.Append(SettingSerializer.Serialize(setting));
            });
        }
Ejemplo n.º 17
0
        //-------------------------------------------------------------
        // 概要:初期化
        //-------------------------------------------------------------
        public void Init(PlayerView playerView, PecaPlayerControl pecaPlayer, StatusBarControl statusBar)
        {
            // コマンド作成
            CreateCommand(playerView, pecaPlayer, statusBar);

            // ショートカット設定の読み込み
            try
            {
                settings = SettingSerializer.LoadSettings <ShortcutSettings>("ShortcutSettings.xml");
            }
            catch
            {
                Logger.Instance.Error("ショートカット設定ファイルの読み込みに失敗したため、デフォルト設定を読み込みます。");
                LoadDefaultSettings();
            }

            // 設定ファイルが壊れている場合
            if ((settings.EventMap == null) || (settings.GestureMap == null) || (settings.KeyMap == null))
            {
                Logger.Instance.Error("ショートカット設定ファイルが壊れているため、デフォルト設定を読み込みます。");
                LoadDefaultSettings();
            }
        }
Ejemplo n.º 18
0
        public void AspectRatio_Verify()
        {
            var setting = new AspectRatio(Ratio.Create(1, 1));

            Assert.Equal("-aspect 1:1", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 19
0
        public void AutoConvert_Verify()
        {
            var setting = new AutoConvert();

            Assert.Equal("-auto_convert 1", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 20
0
        public void TrimShortest_Verify()
        {
            var setting = new TrimShortest();

            Assert.Equal("-shortest", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 21
0
        public void QualityScaleAudio_Verify()
        {
            var setting = new QualityScaleAudio(1);

            Assert.Equal("-q:a 1", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 22
0
        public void RemoveAudio_Verify()
        {
            var setting = new RemoveAudio();

            Assert.Equal("-an", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 23
0
            private static void Expect(string input, string[] expected)
            {
                var list = SettingSerializer.ConvertToList(input);

                Assert.Equal(expected, list);
            }
Ejemplo n.º 24
0
        public void Input_Verify()
        {
            var setting = new Input(Resource.From("c:\\apple.mp4"));

            Assert.Equal("-i \"c:/apple.mp4\"", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 25
0
        public void OverwriteOutput_Verify()
        {
            var setting = new OverwriteOutput();

            Assert.Equal("-y", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 26
0
        public void Size_Verify()
        {
            var setting = new Size(852, 480);

            Assert.Equal("-s 852x480", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 27
0
        public void CopyTimestamps_Verify()
        {
            var setting = new CopyTimestamps();

            Assert.Equal("-copyts", SettingSerializer.Serialize(setting));
        }
Ejemplo n.º 28
0
        private async void UpdateProgram()
        {
            var programInfo = new ProgramInfoSerializer();

            _mainWindowVeiwModel.CheckProgramTimer.Stop();
            _mainWindowVeiwModel.IsEnabledTable = false;
            var net = new Net();

            var setHelp = new SettingHelper();
            SettingSerializer         selectProgram = null;
            LauncherSettingSerializer launcherSet   = null;

            try
            {
                launcherSet = setHelp.Read <LauncherSettingSerializer>(CommonConstant.KeySettings, CommonConstant.FileSettingsLauncher);

                selectProgram = launcherSet.InfoInstallPrograms?.FirstOrDefault(p => p.Dep == _mainWindowVeiwModel.SelectedRow.Dep);
                if (selectProgram == null)
                {
                    MessageBox.Show(Constant.NotFoundInstallProgram);
                    _mainWindowVeiwModel.IsEnabledTable = true;
                    return;
                }
            }
            catch (Exception ex)
            {
                if (ex is DirectoryNotFoundException || ex is FileNotFoundException)
                {
                    MessageBox.Show(CommonConstant.NotFoundFileSettings);
                }
                else
                {
                    MessageBox.Show(CommonConstant.ErrorReadOrWriteSettings);
                }
                Application.Current.Shutdown();
                return;
            }

            programInfo.dep = _mainWindowVeiwModel.SelectedRow.Dep;



            var request = await net.RequestAsync(
                Constant.UrlGetProgram,
                Net.Post,
                programInfo,
                _mainWindowVeiwModel.Auth,
                null,
                (s, e) =>
            {
                _mainWindowVeiwModel.ProgressValue = e.BytesReceived * 100 / e.TotalBytesToReceive;
            });

            if (request.detail != null)
            {
                _mainWindowVeiwModel.CheckProgramTimer.Start();
                MessageBox.Show(ErrorParser.Parse(request.detail));
                _mainWindowVeiwModel.IsEnabledTable = true;
                return;
            }

            var cryptBytesProgram = Convert.FromBase64String(request.data);


            if (Hash.Sha256Bytes(cryptBytesProgram) == request.hash)
            {
                var crypt = new Crypt(Encoding.UTF8.GetBytes(CommonConstant.Key));
                crypt.RemoveAndSetIv(ref cryptBytesProgram);

                var bytesLauncher = crypt.Decode(cryptBytesProgram);


                try
                {
                    setHelp.RemoveProgram(selectProgram.Path, true);
                    setHelp.RemoveDumps <SettingSerializer, IRemoveData>(selectProgram);
                }
                catch (DirectoryNotFoundException)
                {
                    MessageBox.Show(Constant.NotFoundFileOrDirectoryWithProgram);
                }
                catch (FileNotFoundException)
                {
                    MessageBox.Show(Constant.NotFoundFileOrDirectoryWithProgram);
                }


                var zip = new ArchiveHelper();

                var bytesProgramSetting = zip.Extract(bytesLauncher, request.hash);

                var getProgramSetting = setHelp.Read <SettingSerializer>(bytesProgramSetting, CommonConstant.KeySettings);

                getProgramSetting.Path = request.hash;


                var instalProgs = launcherSet.InfoInstallPrograms.ToList();
                for (int i = 0; i < instalProgs.Count; i++)
                {
                    if (instalProgs[i].Dep == getProgramSetting.Dep)
                    {
                        instalProgs[i] = getProgramSetting;
                        break;
                    }
                }


                setHelp.Write(launcherSet, CommonConstant.KeySettings, CommonConstant.FileSettingsLauncher);

                _mainWindowVeiwModel.SelectedRow.SetStateAfterUpdate();
                _mainWindowVeiwModel.SelectedRow.Status  = StatusHelper.InstallAndUpdated;
                _mainWindowVeiwModel.SelectedRow.Version = getProgramSetting.Version;
                _mainWindowVeiwModel.ProgressValue       = 0;
            }
            else
            {
                MessageBox.Show(Constant.NoHashEqual);
            }
            _mainWindowVeiwModel.IsEnabledTable = true;
            _mainWindowVeiwModel.CheckProgramTimer.Start();
        }
Ejemplo n.º 29
0
 public void WriteSerializerSpecifier(ISetting setting)
 {
     BuilderBase.Append(" ");
     BuilderBase.Append(SettingSerializer.Serialize(setting));
 }
Ejemplo n.º 30
0
        /// <summary>
        /// 保存ボタン押下
        /// </summary>
        private void saveButton_Click(object sender, System.EventArgs e)
        {
            // プレイヤー設定
            PlayerSettings.DisconnectRealyOnClose = disconnectRealyOnCloseCheckBox.Checked;
            PlayerSettings.ReturnPositionOnStart  = returnPositionOnStartCheckBox.Checked;
            PlayerSettings.ReturnSizeOnStart      = returnSizeOnStartCheckBox.Checked;
            PlayerSettings.WindowSnapEnable       = windowSnapEnableCheckBox.Checked;
            PlayerSettings.AspectRateFix          = aspectRateFixCheckBox.Checked;
            PlayerSettings.FrameInvisible         = frameInvisibleCheckBox.Checked;
            PlayerSettings.TopMost                   = topMostCheckBox.Checked;
            PlayerSettings.WriteFieldVisible         = writeFieldVisibleCheckBox.Checked;
            PlayerSettings.SaveReturnPositionOnClose = saveReturnPositionCheckBox.Checked;
            PlayerSettings.SaveReturnSizeOnClose     = saveReturnSizeCheckBox.Checked;
            PlayerSettings.ExitedViewerClose         = exitedViewerCloseCheckBox.Checked;

            // チェックボックスの設定(ステータスバー)
            PlayerSettings.DisplayFps            = displayFpsCheckBox.Checked;
            PlayerSettings.DisplayBitrate        = displayBitrateCheckBox.Checked;
            PlayerSettings.DisplayListenerNumber = listenerNumberCheckBox.Checked;

            // 初期音量
            int initVolume = 0;

            if (int.TryParse(initVolumeTextBox.Text, out initVolume))
            {
                PlayerSettings.InitVolume = initVolume;
            }

            // 音量変化
            int volumeChangeNone = 10;

            if (int.TryParse(volumeChangeNoneTextBox.Text, out volumeChangeNone))
            {
                PlayerSettings.VolumeChangeNone = volumeChangeNone;
            }
            int volumeChangeCtrl = 5;

            if (int.TryParse(volumeChangeCtrlTextBox.Text, out volumeChangeCtrl))
            {
                PlayerSettings.VolumeChangeCtrl = volumeChangeCtrl;
            }
            int volumeChangeShift = 1;

            if (int.TryParse(volumeChangeShiftTextBox.Text, out volumeChangeShift))
            {
                PlayerSettings.VolumeChangeShift = volumeChangeShift;
            }

            // 動画再生開始時のコマンド
            if (movieStartComboBox.SelectedIndex != -1)
            {
                PlayerSettings.MovieStartCommand = movieStartCommandList[movieStartComboBox.SelectedIndex];
            }

            // スクリーンショット
            PlayerSettings.ScreenshotFolder    = screenshotFolderTextBox.Text;
            PlayerSettings.ScreenshotExtension = screenshotExtensionComboBox.SelectedItem.ToString();
            PlayerSettings.ScreenshotFormat    = screenshotFormatTextBox.Text;

            // スレッド
            PlayerSettings.AutoReadThread = autoReadThreadCheckBox.Checked;

            // FLV
            PlayerSettings.Gpu  = flvGpuCheckBox.Checked;
            PlayerSettings.Rtmp = useRtmpCheckBox.Checked;
            double bufferTime = 1.0;

            if (double.TryParse(bufferTimeTextBox.Text, out bufferTime))
            {
                PlayerSettings.BufferTime = bufferTime;
            }
            double bufferTimeMax = 1.0;

            if (double.TryParse(bufferTimeMaxTextBox.Text, out bufferTimeMax))
            {
                PlayerSettings.BufferTimeMax = bufferTimeMax;
            }

            // 設定を保存
            PlayerSettings.Save();
            Close();

            // ショートカット設定
            shortcut.Settings.KeyMap     = new Dictionary <KeyInput, Commands>();
            shortcut.Settings.GestureMap = new Dictionary <string, Commands>();
            foreach (ListViewItem item in shortcutListView.Items)
            {
                object tag1 = item.Tag;                                 // Commands
                object tag2 = item.SubItems[1].Tag;                     // KeyInput

                // コマンド取得失敗
                if (tag1 == null)
                {
                    continue;
                }

                Commands command = (Commands)item.Tag;

                // ショートカット設定
                if (tag2 != null)
                {
                    KeyInput keyInput = (KeyInput)item.SubItems[1].Tag;
                    shortcut.Settings.KeyMap.Add(keyInput, command);
                }

                // マウスジェスチャ設定
                string gesture = item.SubItems[2].Text;
                if (gesture != "-")
                {
                    shortcut.Settings.GestureMap.Add(gesture, command);
                }
            }
            SettingSerializer.SaveSettings <ShortcutSettings>("ShortcutSettings.xml", shortcut.Settings);
        }