Skip to content

Commit 9386a3f

Browse files
committed
Allow to play more than 1 segment
1 parent d8ddab4 commit 9386a3f

File tree

7 files changed

+363
-93
lines changed

7 files changed

+363
-93
lines changed

OpenpilotSdk/Hardware/OpenpilotDevice.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ public async Task<Bitmap> GetThumbnailAsync(DriveSegment driveSegment)
380380
await ConnectAsync();
381381

382382
Bitmap thumbnail = null;
383-
var drive = new DirectoryInfo(Path.GetDirectoryName(driveSegment.FrontVideo.File.FullName)).Name;
383+
var videoFile = driveSegment.FrontVideoQuick ?? driveSegment.FrontVideo;
384+
var drive = new DirectoryInfo(Path.GetDirectoryName(videoFile.File.FullName)).Name;
384385
var cachedThumbnail = Path.Combine(TempDirectory, drive + ".jpg");
385386

386387

@@ -389,7 +390,6 @@ public async Task<Bitmap> GetThumbnailAsync(DriveSegment driveSegment)
389390
bool quickVideo = driveSegment.FrontVideoQuick != null;
390391
var offset = 0;
391392

392-
var videoFile = driveSegment.FrontVideoQuick ?? driveSegment.FrontVideo;
393393
var imageBuffer = quickVideo ? new byte[10000] : new byte[200000];
394394

395395
await using (var sftpFileStream = SftpClient.OpenRead(videoFile.File.FullName))
@@ -407,7 +407,7 @@ public async Task<Bitmap> GetThumbnailAsync(DriveSegment driveSegment)
407407
try
408408
{
409409
await FFMpegArguments
410-
.FromPipeInput(new StreamPipeSource(msInput), options => options.WithFramerate(20).ForceFormat(quickVideo ? "mpegts" : "rawvideo"))
410+
.FromPipeInput(new StreamPipeSource(msInput), options => options.WithFramerate(20))
411411
.OutputToPipe(new StreamPipeSink(msOutput), options =>
412412
options.WithVideoCodec(VideoCodec.Png)
413413
.WithFrameOutputCount(1)
@@ -591,9 +591,7 @@ public async Task<IEnumerable<Firmware>> GetFirmwareVersions(IProgress<int> prog
591591

592592
var firmwares = new List<Firmware>();
593593

594-
var drives = GetDrives();
595-
596-
foreach (var drive in drives)
594+
await foreach (var drive in GetDrivesAsync())
597595
{
598596
foreach (var driveSegment in drive.Segments.OrderBy(segment => segment.Index))
599597
{
@@ -668,7 +666,7 @@ public async Task<GpxFile> GenerateGpxFileAsync(Drive drive, IProgress<int> prog
668666

669667
public async IAsyncEnumerable<Drive> GetDrivesAsync([EnumeratorCancellation]CancellationToken cancellationToken = default(CancellationToken))
670668
{
671-
await ConnectAsync();
669+
await ConnectAsync(cancellationToken);
672670

673671
IOrderedEnumerable<IGrouping<DateTime, SftpFile>> directoryListing;
674672

@@ -680,7 +678,7 @@ public async Task<GpxFile> GenerateGpxFileAsync(Drive drive, IProgress<int> prog
680678
{
681679
return DateTime.ParseExact(dir.Name.AsSpan().Slice(0, 20), "yyyy-MM-dd--HH-mm-ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime();
682680
})
683-
.OrderBy(dir =>
681+
.OrderByDescending(dir =>
684682
{
685683
var date = dir.Key;
686684
return date;

OpenpilotSdk/OpenpilotSdk.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<PackageReference Include="NetTopologySuite" Version="2.4.0" />
4242
<PackageReference Include="NetTopologySuite.IO.GPX" Version="1.1.1" />
4343
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
44-
<PackageReference Include="Serilog" Version="2.10.0" />
44+
<PackageReference Include="Serilog" Version="2.11.0" />
4545
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
4646
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
4747
<PackageReference Include="SharpZipLib" Version="1.3.3" />

OpenpilotToolkit/Controls/Media/VideoPlayer.Designer.cs

Lines changed: 145 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)