Skip to content

Commit

Permalink
Revert "roll back to working solution file"
Browse files Browse the repository at this point in the history
This reverts commit 94d33b9.
  • Loading branch information
MerlinCooper committed Jun 7, 2020
1 parent 4ed64b0 commit 7432ae1
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 27 deletions.
2 changes: 2 additions & 0 deletions ClassDiagram3.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />
3 changes: 2 additions & 1 deletion Phases/AnalyseRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ void AnalyseRaceSituations(IEnumerable<DataSample> samples)
fastestLaps = new RecordFastestLaps(overlayData);
replayControl = new ReplayControl(samples.First().SessionData, incidents, removalEdits, TrackCameras);
sessionDataCapture = new SessionDataCapture(overlayData);

//CAPTURING LEADERBOARD, CAMERAS will be done at FF16x. TO BE DETERMINED WHETHER STANDARD INTERVALS HAVE TO BE REDUCED BY FACTOR OF 16?!
captureLeaderBoardEveryHalfSecond = new SampleFilter(TimeSpan.FromSeconds(0.5),
new CaptureLeaderBoard(overlayData, commentaryMessages, removalEdits).Process);
captureCamDriverEveryQuaterSecond = new SampleFilter(TimeSpan.FromSeconds(0.25),
Expand All @@ -153,7 +155,6 @@ void AnalyseRaceSituations(IEnumerable<DataSample> samples)
.TakeUntil(3.Seconds()).AfterReplayPaused();

samples = samples.AtSpeed(iReplaySpeedForAnalysis);
Settings.AppliedTimingFactor = 1.0 / iReplaySpeedForAnalysis;

overlayData.CapturedVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

Expand Down
12 changes: 9 additions & 3 deletions Phases/CaptureOpeningScenes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ namespace iRacingReplayOverlay.Phases
{
public partial class IRacingReplay
{
static private VideoCapture raceVideo = new VideoCapture();

void _CaptureOpeningScenes(Action onComplete)
{
if (bRecordUsingPauseResume)
{

}
var data = iRacing.GetDataFeed().First();
var session = data.SessionData.SessionInfo.Sessions.Qualifying();
if (session == null || session.ResultsPositions == null)
Expand Down Expand Up @@ -57,13 +63,13 @@ void _CaptureOpeningScenes(Action onComplete)
var aCar = data.SessionData.DriverInfo.CompetingDrivers[1].CarNumberRaw;
iRacing.Replay.CameraOnDriver((short)aCar, (short)scenicCameras);

var videoCapture = new VideoCapture();
//var videoCapture = new VideoCapture();

videoCapture.Activate(workingFolder);
raceVideo.Activate(workingFolder);

Thread.Sleep(shortTestOnly ? 5000 : 20000);

var fileNames = videoCapture.Deactivate();
var fileNames = raceVideo.Deactivate(bRecordUsingPauseResume);
if( fileNames.Count == 0)
return;

Expand Down
34 changes: 23 additions & 11 deletions Phases/CaptureRace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public partial class IRacingReplay
string workingFolder;
string introVideo;


void _WithWorkingFolder(string workingFolder)
{
this.workingFolder = workingFolder;
Expand All @@ -63,30 +64,41 @@ internal void _CaptureRaceTest(Action<string> onComplete, IEnumerable<DataSample
//Retrieve list of raceEvents selected depending on the duration of the highlight video
var totalRaceEvents = RaceEventExtension.GetInterestingRaceEvents(overlayData.RaceEvents.ToList());

//set iRacing Replay to Race start and ensure that iRacing is playing out replay at normal speed
ApplyFirstLapCameraDirection(samples, replayControl);

/*//set iRacing Replay to Race start and ensure that iRacing is playing out replay at normal speed
iRacing.Replay.MoveToFrame(raceStartFrameNumber); //move in iRacing replay to start of Race
iRacing.Replay.SetSpeed((int)replaySpeeds.normal); //set replay speed to normal
iRacing.Replay.SetSpeed((int)replaySpeeds.normal); //set replay speed to normal*/

//Record the selected race events into a highlight video
var highligtVideoCapture = new VideoCapture(); //create instance to control by sending hot-keys to recording software (tested with OBS)
highligtVideoCapture.Activate(workingFolder); //Start video capturing FileName will be given by recording software.
//var highligtVideoCapture = new VideoCapture(); //create instance to control by sending hot-keys to recording software (tested with OBS)
raceVideo.Activate(workingFolder); //Active video-capturing and send start command to recording software.

//cycle through all raceEvents selected for the highlight video and record them (REMARK: Camera switching not implemented yet)
foreach (var raceEvent in totalRaceEvents)
{
TraceInfo.WriteLine("ADV_RECORDING: Type: {0} | Durations-Span: {1} | ".F(raceEvent.GetType(), raceEvent.ToString()));
//pause recording software before jumping to new position in iRacing Replay
highligtVideoCapture.Pause();
TraceInfo.WriteLine("ADV_RECORDING: Type: {0} | Durations-Span: {1} | ".F(raceEvent.GetType(), raceEvent.Duration));

//jump to selected RaceEvent in iRacing Replay
int framePositionInRace = raceStartFrameNumber + (int)Math.Round(raceEvent.StartTime * 60.0);
iRacing.Replay.MoveToFrame(raceStartFrameNumber + (int)Math.Round(raceEvent.StartTime * 60.0));


highligtVideoCapture.Resume(); //resume recording
//TODO: SET CAMERA TO DRIVER

Thread.Sleep((int)(1000*raceEvent.Duration)); //pause thread until scene is fully recorded.

iRacing.Replay.SetSpeed((int)replaySpeeds.normal); //start iRacing Replay at selected position

raceVideo.Resume(); //resume recording
TraceDebug.WriteLine("Recording Race-Event. Frame-Position: {0} | Duration: {1} ms".F(framePositionInRace, 1000 * raceEvent.Duration));
//TODO: START THREAD TO SWITCH / CONTROL CAMERA WHILE RECORDING SCENE
Thread.Sleep((int)(1000 * raceEvent.Duration)); //pause thread until scene is fully recorded.
//TODO: TERMINATE THREAD CAMERA CONTROL
raceVideo.Pause(); //pause recording software before jumping to new position in iRacing Replay
}

TraceDebug.WriteLine("Video Capture of Race-Events completed");
raceVideo.Stop();

} else { //Code to be removed after being able to implment working solution where analysis phase and replay-capture phase are distinct processes.
//use local variables for original code instead of global variables introduced to support full analysis in analysis-phase

Expand Down
47 changes: 38 additions & 9 deletions Phases/Direction/VideoCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,37 @@ namespace iRacingReplayOverlay.Phases.Direction
{
enum videoStatus { stopped, running, paused };

public class VideoCapture
public class VideoCapture
{
string workingFolder;
DateTime started;
Timer timer;
List<CapturedVideoFile> captureFileNames = new List<CapturedVideoFile>();
videoStatus curVideoStatus = videoStatus.stopped;

~VideoCapture()
{
if(curVideoStatus != videoStatus.stopped)
SendKeyStroke_StartStopp();
}

public void Activate(string workingFolder)
public void Activate(string workingFolder, bool bStartRecording = true)
{
this.workingFolder = workingFolder;
this.started = DateTime.Now;

timer = new Timer(500);
timer.Elapsed += CaptureNewFileNames; ;
timer.Elapsed += CaptureNewFileNames;
timer.AutoReset = false;
timer.Enabled = true;
curVideoStatus = videoStatus.running;

SendKeyStroke_StartStopp(); //Send hot-key to start recording

if (bStartRecording && (curVideoStatus == videoStatus.stopped))
{
SendKeyStroke_StartStopp(); //Send hot-key to start recording
curVideoStatus = videoStatus.running;
}else if( curVideoStatus == videoStatus.paused){
Resume();
}
}

private void CaptureNewFileNames(object sender, ElapsedEventArgs e)
Expand Down Expand Up @@ -80,18 +91,26 @@ private void CaptureNewFileNames(object sender, ElapsedEventArgs e)
}
}

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

}

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

System.Threading.Thread.Sleep(2000);

Expand Down Expand Up @@ -122,6 +141,16 @@ public void Resume()
}
}

public void Stop()
{
if(curVideoStatus == videoStatus.running || curVideoStatus == videoStatus.paused)
{
SendKeyStroke_StartStopp();
curVideoStatus = videoStatus.stopped;
}
}


private static void SendKeyStroke_StartStopp()
{
TraceInfo.WriteLine("Sending key event to start/stopp recording ALT+F9");
Expand Down
1 change: 1 addition & 0 deletions iRacingReplayDirector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<ItemGroup>
<None Include="App.config" />
<None Include="ClassDiagram2.cd" />
<None Include="ClassDiagram3.cd" />
<None Include="DeploymentSite\.gitignore" />
<None Include="DeploymentSite\main.jsx" />
<None Include="DeploymentSite\package.json" />
Expand Down
1 change: 1 addition & 0 deletions iRacingReplayDirector.nugetreferenceswitcher
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iRacingSDK iRacingSDK.Net/iRacingSDK.csproj packages/iRacingSDK.1.0.0.42/lib/net40-client/iRacingSDK.dll
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="iRacingSDK, Version=1.0.0.40, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -72,6 +71,10 @@
<Project>{0E523573-2972-4DC0-AECB-C4CF746854BB}</Project>
<Name>iRacingReplayOverlay.net</Name>
</ProjectReference>
<ProjectReference Include="..\iRacingSDK.Net\iRacingSDK.csproj">
<Project>{5422AE20-F220-4BE1-9E61-5296981ABB5C}</Project>
<Name>iRacingSDK</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<ProjectReference Include="..\iRacingSDK.Net\iRacingSDK.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iRacingSDK ../iRacingSDK.Net/iRacingSDK.csproj ../packages/iRacingSDK.1.0.0.42/lib/net40-client/iRacingSDK.dll
2 changes: 1 addition & 1 deletion iRacingReplayOverlay.net.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="iRacingSDK" version="1.0.0.40" targetFramework="net451" />
<package id="iRacingSDK" version="1.0.0.42" targetFramework="net451" />
<package id="Moq" version="4.2.1409.1722" targetFramework="net451" />
<package id="NUnit" version="2.6.3" targetFramework="net40" />
<package id="NUnit.Runners" version="2.6.3" targetFramework="net451" />
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="AWSSDK.Core" version="3.1.4.0" targetFramework="net40-client" requireReinstallation="true" />
<package id="ILMerge" version="2.14.1208" targetFramework="net451" />
<package id="iRacingDirector.Plugin" version="1.0.0.5" targetFramework="net40-client" />
<package id="iRacingSDK" version="1.0.0.40" targetFramework="net45" />
<package id="iRacingSDK" version="1.0.0.42" targetFramework="net45" />
<package id="MediaFoundation.Net" version="2.0.0.32" targetFramework="net40-client" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
<package id="Octokit" version="0.17.0" targetFramework="net45" />
Expand Down

0 comments on commit 7432ae1

Please sign in to comment.