Ejemplo n.º 1
0
 public void AddJob(FrameWork work)
 {
     AddWork(work);
     //var job = new AddWorkHandler(AddWork);
     //if(running)
     //workDispatcher.BeginInvoke(DispatcherPriority.Normal, job, work);
 }
Ejemplo n.º 2
0
 private void InternalGetWork(FrameWork obj)
 {
     lock (workstack)
     {
         workstack.Push(obj);
     }
 }
Ejemplo n.º 3
0
 private void AddWork(FrameWork work)
 {
     if (running)
     {
         lock (workList)
         {
             workList.Add(work);
         }
     }
 }
Ejemplo n.º 4
0
        private void RaiseDataAvailable(FrameWork framedata)
        {
            var args = new VideoEventArgs(framedata);

            Data_Available?.Invoke(this, args);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
 public void ReturnWork(FrameWork obj)
 {
     InternalGetWork(obj);
 }
Ejemplo n.º 7
0
 public VideoEventArgs(FrameWork frame)
 {
     payload = frame;
 }