Exemplo n.º 1
0
 public void Start(RecordingParameters control)
 {
     options        = control;
     encodingThread = new Thread(EncodeUpdate);
     encodingThread.IsBackground = true;
     encodingThread.Start();
     running = true;
 }
Exemplo n.º 2
0
 public void Start(RecordingParameters control)
 {
     this.RecordingParemeters = control;
     frametime = Stopwatch.Frequency / control.FrameRate;
     //timer.Start();
     maxframes           = control.FrameRate;
     thread              = new Thread(Update);
     thread.IsBackground = true;
     thread.Start();
 }
Exemplo n.º 3
0
 public RecordingParameters(RecordingParameters copyFrom)
 {
     this.PosX              = copyFrom.PosX;
     this.PosY              = copyFrom.PosY;
     this.SizeX             = copyFrom.SizeX;
     this.SizeY             = copyFrom.SizeY;
     this.ResX              = copyFrom.ResX;
     this.ResY              = copyFrom.ResY;
     this.FrameRate         = copyFrom.FrameRate;
     this.running           = copyFrom.running;
     this.RecordingMs       = copyFrom.RecordingMs;
     this.audioBalance      = copyFrom.audioBalance;
     this.leftVolume        = copyFrom.leftVolume;
     this.rightVolume       = copyFrom.rightVolume;
     this.pixelFormat       = copyFrom.pixelFormat;
     this.interpolationMode = copyFrom.interpolationMode;
     this.smoothingMode     = copyFrom.smoothingMode;
     this.compressionRate   = copyFrom.compressionRate;
 }
Exemplo n.º 4
0
        private void Update()
        {
            timer.Start();
            nextFrame       = timer.ElapsedTicks;
            nextFrameSecond = timer.ElapsedTicks;
            var lastFrametime = timer.ElapsedMilliseconds;
            var Tasks         = new List <Task <FrameWork> >();

            while (true)
            {
                Thread.Sleep(0);
                if (Tasks.Count > 0)
                {
                    var first = Tasks.First();
                    if (first.IsCompleted)
                    {
                        var work = first.Result;
                        RaiseDataAvailable(work);
                        RecordingParemeters.RecordingMs = work.framems;
                        //workstack.Push(work);
                        Tasks.RemoveAt(0);
                    }
                    continue;
                }
                if (!RecordingParemeters.running)
                {
                    break;
                }
                bool needframe = false;
                bool keyFrame  = false;

                if (frames < maxframes)
                {
                    if (nextFrame > timer.ElapsedTicks)
                    {
                        continue;
                    }
                    frames++;
                    nextFrame += frametime;
                    needframe  = RecordingParemeters.running;
                }
                if (frames > maxframes || nextFrameSecond <= timer.ElapsedTicks)
                {
                    needframe          = RecordingParemeters.running;
                    keyFrame           = true;
                    currentFrameParams = new RecordingParameters(RecordingParemeters);                    //only change on keyframe.
                    compression        = RecordingParemeters.compressionRate;
                    frames             = 0;
                    nextFrame          = timer.ElapsedTicks + frametime;
                    nextFrameSecond   += frequency;
                }
                if (!needframe)
                {
                    continue;
                }
                FrameWork p;
                if (workstack.Count > 0)
                {
                    lock (workstack)
                    {
                        p = workstack.Pop();
                    }
                }
                else
                {
                    p = new FrameWork();
                }
                p.Prepare(currentFrameParams, keyFrame, compression);
                p.GetScreenshot();
                var task = Task.Run(p.DoWork);
                Tasks.Add(task);
            }
            timer.Stop();
            RaiseStoppedRecording();
        }