public List<CapturedVideoFile> Deactivate(bool bRecordUsingPauseResume=false)
        {
            if (timer != null)
            {
                var t = timer;
                timer = null;
                t.Stop();
                t.Dispose();
                
            }

            if (bRecordUsingPauseResume && curVideoStatus != videoStatus.paused)
            {
                Pause();
                curVideoStatus = videoStatus.paused;
            } else
            {
                SendKeyStroke_StartStopp();
                curVideoStatus = videoStatus.stopped;
            }

            System.Threading.Thread.Sleep(2000);

            CaptureNewFileNames(null, null);

            TraceInfo.WriteLineIf(captureFileNames.Count == 0, "Unable to find video files in folder '{0}' - check your Video Working folder", workingFolder);

            return captureFileNames;
        }
        IEnumerable <DataSample> WaitForInitialConnection()
        {
            bool wasConnected = iRacingMemory.Accessor != null;

            TraceInfo.WriteLineIf(!wasConnected, "Waiting to connect to iRacing application");

            while (!iRacingMemory.IsConnected())
            {
                yield return(DataSample.YetToConnected);

                Thread.Sleep(10);
            }

            TraceInfo.WriteLineIf(!wasConnected, "Connected to iRacing application");
        }
        void Process(Transcoder transcoder, bool highlights, Action <long, long> monitorProgress, Func <bool> isAborted)
        {
            try
            {
                TraceInfo.WriteLineIf(highlights, "Transcoding highlights to {0}", transcoder.DestinationFile);
                TraceInfo.WriteLineIf(!highlights, "Transcoding full replay to {0}", transcoder.DestinationFile);

                transcoder.ProcessVideo((readers, saveToSink) =>
                {
                    var writeToSink = monitorProgress == null ? saveToSink : MonitorProgress(saveToSink);

                    var fadeSegments     = AVOperations.FadeIn(AVOperations.FadeOut(writeToSink));
                    var edits            = highlights ? ApplyEdits(writeToSink) : writeToSink;
                    var mainBodyOverlays = AVOperations.Overlay(applyRaceDataOverlay, edits);
                    var introOverlay     = AVOperations.Overlay(applyIntroOverlay, fadeSegments);

                    var sourceReaderExtra = readers.FirstOrDefault(r => ((CapturedVideoFile)r.State).isIntroVideo);
                    if (sourceReaderExtra != null)
                    {
                        var introSourceReader = sourceReaderExtra.SourceReader;
                        var mainReaders       = AVOperations.Combine(readers.Skip(1).Select(r => r.SourceReader).ToArray(), Settings.Default.VideoSplitGap);

                        totalDuration += introSourceReader.Duration + mainReaders.Duration;

                        AVOperations.StartConcat(introSourceReader, introOverlay,
                                                 AVOperations.Concat(mainReaders, mainBodyOverlays, isAborted), isAborted);
                    }
                    else
                    {
                        var mainReaders = AVOperations.Combine(readers.Select(r => r.SourceReader).ToArray(), Settings.Default.VideoSplitGap);

                        totalDuration += mainReaders.Duration;

                        AVOperations.Concat(mainReaders, mainBodyOverlays, isAborted)(0, 0);
                    }
                });

                TraceInfo.WriteLineIf(highlights, "Done Transcoding highlights to {0}", transcoder.DestinationFile);
                TraceInfo.WriteLineIf(!highlights, "Done Transcoding full replay to {0}", transcoder.DestinationFile);
            }
            catch (Exception e)
            {
                TraceError.WriteLine(e.Message);
                TraceError.WriteLine(e.StackTrace);
                throw e;
            }
        }
Beispiel #4
0
        public ReplayControl(SessionData sessionData, Incidents incidents, RemovalEdits removalEdits, TrackCameras trackCameras)
        {
            var cameras = trackCameras.Where(tc => tc.TrackName == sessionData.WeekendInfo.TrackDisplayName).ToArray();

            TraceInfo.WriteLineIf(cameras.Count() <= 0, "Track Cameras not defined for {0}", sessionData.WeekendInfo.TrackDisplayName);
            Debug.Assert(cameras.Count() > 0, "Track Cameras not defined for {0}".F(sessionData.WeekendInfo.TrackDisplayName));

            foreach (var tc in cameras)
            {
                tc.CameraNumber = (short)sessionData.CameraInfo.Groups.First(g => g.GroupName.ToLower() == tc.CameraName.ToLower()).GroupNum;
            }

            var camera = cameras.First(tc => tc.IsRaceStart);

            //var cameraControl = new CameraControl(cameras);
            cameraControl = new CameraControl(cameras);
            cameraControl.CameraOnPositon(1, camera.CameraNumber);

            var battleMarker  = removalEdits.For(InterestState.Battle);
            var restartMarker = removalEdits.For(InterestState.Restart);

            var ruleLastSectors       = new RuleLastLapPeriod(cameraControl, removalEdits);
            var ruleUnlimitedIncident = new RuleIncident(cameraControl, removalEdits, incidents, 999);
            var ruleLimitedIncident   = new RuleIncident(cameraControl, removalEdits, incidents, Settings.Default.IgnoreIncidentsBelowPosition);
            var ruleFirstSectors      = new RuleFirstLapPeriod(cameraControl, removalEdits);
            var rulePaceLaps          = new RulePaceLaps(cameraControl, restartMarker, battleMarker);
            var ruleBattle            = new RuleBattle(cameraControl, battleMarker, Settings.Default.CameraStickyPeriod, Settings.Default.BattleStickyPeriod, Settings.Default.BattleGap, Settings.Default.BattleFactor2);

            ruleRandom = new RuleRandomDriver(cameraControl, sessionData, Settings.Default.CameraStickyPeriod);

            var ruleForFirstSectors = Settings.Default.IgnoreIncidentsDuringRaceStart ? ruleFirstSectors : ruleFirstSectors.WithVeto(ruleUnlimitedIncident);

            directionRules = new IDirectionRule[] {
                ruleLastSectors,
                ruleForFirstSectors,
                rulePaceLaps.WithVeto(ruleUnlimitedIncident.WithVeto(ruleLastSectors)),
                ruleBattle.WithVeto(ruleLimitedIncident.WithVeto(ruleLastSectors)),
                ruleUnlimitedIncident.WithVeto(ruleLastSectors),
                ruleRandom.WithVeto(ruleLastSectors)
            };

            currentRule = directionRules[0];
        }
Beispiel #5
0
        public List <CapturedVideoFile> Deactivate()
        {
            if (timer != null)
            {
                var t = timer;
                timer = null;
                t.Stop();
                t.Dispose();
            }

            SendKeyStroke();

            System.Threading.Thread.Sleep(2000);

            CaptureNewFileNames(null, null);

            TraceInfo.WriteLineIf(captureFileNames.Count == 0, "Unable to find video files in folder '{0}' - check your Video Working folder", workingFolder);

            return(captureFileNames);
        }
        public bool IsActive(DataSample data)
        {
            if (restarting)
            {
                if (data.Telemetry.SessionTimeSpan < restartEndTime)
                {
                    return(true);
                }

                restartMarker.Stop();

                restarting = false;
                return(false);
            }

            if (wasUnderPaceCar)
            {
                if (data.Telemetry.UnderPaceCar)
                {
                    return(true);
                }

                restartEndTime = data.Telemetry.SessionTimeSpan + RestartStickyTime;
                restarting     = true;

                TraceInfo.WriteLine("{0} Race restarting", data.Telemetry.SessionTimeSpan);
                wasUnderPaceCar = false;
                restartMarker.Start();
                return(true);
            }

            wasUnderPaceCar = data.Telemetry.UnderPaceCar;
            if (wasUnderPaceCar)
            {
                TraceInfo.WriteLineIf(wasUnderPaceCar, "{0} Double Yellows. Pace Car", data.Telemetry.SessionTimeSpan);
                battleMarker.Stop();
                cameraControl.CameraOnPositon(1, cameraControl.RaceStartCameraNumber);
            }

            return(wasUnderPaceCar);
        }