Ejemplo n.º 1
0
        /// <summary>
        /// Show a configuration dialog (modal) for JMDWriter
        /// </summary>
        /// <param name="threads">number of threads</param>
        /// <param name="compLevel">compression level</param>
        /// <param name="tMin">minimum possible number of threads</param>
        /// <param name="tMax">maximum possible number of threads</param>
        /// <param name="cMin">minimum compression level, assumed to be "no compression"</param>
        /// <param name="cMax">maximum compression level</param>
        /// <param name="hwnd">hwnd of parent</param>
        /// <returns>false if user canceled; true if user consented</returns>
        public static bool DoCompressionDlg(ref int threads, ref int compLevel, int tMin, int tMax, int cMin, int cMax, IWin32Window hwnd)
        {
            var j = new JmdForm
            {
                threadsBar     = { Minimum = tMin, Maximum = tMax },
                compressionBar = { Minimum = cMin, Maximum = cMax }
            };

            j.threadsBar.Value     = threads;
            j.compressionBar.Value = compLevel;
            j.ThreadsBar_Scroll(null, null);
            j.CompressionBar_Scroll(null, null);
            j.threadLeft.Text       = $"{tMin}";
            j.threadRight.Text      = $"{tMax}";
            j.compressionLeft.Text  = $"{cMin}";
            j.compressionRight.Text = $"{cMax}";

            DialogResult d = j.ShowDialog(hwnd);

            threads   = j.threadsBar.Value;
            compLevel = j.compressionBar.Value;

            j.Dispose();
            return(d.IsOk());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// obtain a set of recording compression parameters
        /// </summary>
        /// <param name="hwnd">hwnd to attach to if the user is shown config dialog</param>
        /// <returns>codec token, dispose of it when you're done with it</returns>
        public IDisposable AcquireVideoCodecToken(System.Windows.Forms.IWin32Window hwnd)
        {
            CodecToken ret = new CodecToken();

            // load from config and sanitize
            int t = Math.Min(Math.Max(Global.Config.JmdThreads, 1), 6);

            int c = Math.Min(Math.Max(Global.Config.JmdCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION);

            if (!JmdForm.DoCompressionDlg(ref t, ref c, 1, 6, Deflater.NO_COMPRESSION, Deflater.BEST_COMPRESSION, hwnd))
            {
                return(null);
            }

            Global.Config.JmdThreads     = ret.NumThreads = t;
            Global.Config.JmdCompression = ret.CompressionLevel = c;

            return(ret);
        }
Ejemplo n.º 3
0
        public IDisposable AcquireVideoCodecToken(Config config)
        {
            var ret = new CodecToken();

            // load from config and sanitize
            int t = Math.Min(Math.Max(config.JmdThreads, 1), 6);

            int c = Math.Min(Math.Max(config.JmdCompression, NO_COMPRESSION), BEST_COMPRESSION);

            if (!JmdForm.DoCompressionDlg(ref t, ref c, 1, 6, NO_COMPRESSION, BEST_COMPRESSION, _dialogParent.AsWinFormsHandle()))
            {
                return(null);
            }

            config.JmdThreads     = ret.NumThreads = t;
            config.JmdCompression = ret.CompressionLevel = c;

            return(ret);
        }