From 2b49c265a813b860512cb1eab9cc8eb1aeb29d62 Mon Sep 17 00:00:00 2001 From: Brent Allen Date: Wed, 9 Oct 2019 11:02:54 -0700 Subject: [PATCH] Style cleanup --- src/csharp/Examples/Recording/Program.cs | 11 +- src/csharp/Record/DataBlock.cs | 32 ++- .../AzureKinectAddAttachmentException.cs | 12 +- ...reKinectAddCustomSubtitleTrackException.cs | 12 +- ...AzureKinectAddCustomVideoTrackException.cs | 12 +- .../AzureKinectAddImuTrackException.cs | 10 +- .../Exceptions/AzureKinectAddTagException.cs | 2 +- .../AzureKinectCreateRecordingException.cs | 6 +- .../Exceptions/AzureKinectFlushException.cs | 12 +- .../AzureKinectGetCalibrationException.cs | 10 +- .../AzureKinectGetCaptureException.cs | 10 +- .../AzureKinectGetDataBlockException.cs | 10 +- .../AzureKinectGetImuSampleException.cs | 10 +- .../AzureKinectGetRawCalibrationException.cs | 10 +- .../Exceptions/AzureKinectGetTagException.cs | 12 +- ...zureKinectGetTrackCodecContextException.cs | 12 +- .../AzureKinectGetTrackNameException.cs | 12 +- .../AzureKinectOpenPlaybackException.cs | 10 +- .../Exceptions/AzureKinectRecordException.cs | 20 +- .../Exceptions/AzureKinectSeekException.cs | 12 +- .../AzureKinectSetColorConversionException.cs | 10 +- ...ureKinectTrackGetVideoSettingsException.cs | 10 +- .../AzureKinectWriteCaptureException.cs | 12 +- ...zureKinectWriteCustomTrackDataException.cs | 12 +- .../AzureKinectWriteHeaderException.cs | 12 +- .../AzureKinectWriteImuSampleException.cs | 10 +- src/csharp/Record/NativeMethods.cs | 95 +++---- src/csharp/Record/Playback.cs | 234 +++++++++--------- src/csharp/Record/PlaybackSeekOrigin.cs | 26 +- src/csharp/Record/RecordConfiguration.cs | 83 ++++++- src/csharp/Record/RecordLogger.cs | 10 +- src/csharp/Record/RecordSubtitleSettings.cs | 19 +- src/csharp/Record/RecordVideoSettings.cs | 29 ++- src/csharp/Record/{Record.cs => Recorder.cs} | 72 +++--- src/csharp/SDK/Device.cs | 47 ++-- src/csharp/SDK/GlobalSuppressions.cs | 8 - src/csharp/SDK/Native/NativeMethods.cs | 34 --- .../Tests/Record.UnitTests/LoopbackTests.cs | 6 +- 38 files changed, 584 insertions(+), 382 deletions(-) rename src/csharp/Record/{Record.cs => Recorder.cs} (92%) delete mode 100644 src/csharp/SDK/GlobalSuppressions.cs diff --git a/src/csharp/Examples/Recording/Program.cs b/src/csharp/Examples/Recording/Program.cs index e91b43cd1..f7d4898ed 100644 --- a/src/csharp/Examples/Recording/Program.cs +++ b/src/csharp/Examples/Recording/Program.cs @@ -31,22 +31,21 @@ static void Main(string[] args) DepthMode = DepthMode.NFOV_2x2Binned, SynchronizedImagesOnly = true }; - using (Device device = Device.Open()) - using (Record recording = Record.Create(path, device, configuration)) + using (Recorder recorder = Recorder.Create(path, device, configuration)) { device.StartCameras(configuration); device.StartImu(); - recording.AddImuTrack(); - recording.WriteHeader(); + recorder.AddImuTrack(); + recorder.WriteHeader(); for (frame = 0; frame < 100; frame++) { using (Capture capture = device.GetCapture()) { - recording.WriteCapture(capture); + recorder.WriteCapture(capture); Console.WriteLine($"Wrote capture ({capture.Color.DeviceTimestamp})"); try { @@ -55,7 +54,7 @@ static void Main(string[] args) // Throws TimeoutException when Imu sample is not available ImuSample sample = device.GetImuSample(TimeSpan.Zero); - recording.WriteImuSample(sample); + recorder.WriteImuSample(sample); Console.WriteLine($"Wrote imu ({sample.AccelerometerTimestamp})"); } } diff --git a/src/csharp/Record/DataBlock.cs b/src/csharp/Record/DataBlock.cs index 5fdc0a52c..a9c7e2cda 100644 --- a/src/csharp/Record/DataBlock.cs +++ b/src/csharp/Record/DataBlock.cs @@ -1,12 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Globalization; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; +using System.Buffers; using System.Runtime.InteropServices; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record { - public class DataBlock : IDisposable + /// + /// Represents a block of data from a custom recording track. + /// + public class DataBlock : IDisposable, IMemoryOwner { // The native handle for this data block. private readonly NativeMethods.k4a_playback_data_block_t handle; @@ -16,12 +23,19 @@ public class DataBlock : IDisposable private byte[] buffer = null; + /// + /// Initializes a new instance of the class. + /// + /// Native handle to the data block. internal DataBlock(NativeMethods.k4a_playback_data_block_t handle) { this.handle = handle; } - public byte[] Buffer + /// + /// Gets the memory with the custom data. + /// + public Memory Memory { get { @@ -37,7 +51,7 @@ public byte[] Buffer ulong bufferSize = NativeMethods.k4a_playback_data_block_get_buffer_size(this.handle); this.buffer = new byte[bufferSize]; - + IntPtr bufferPtr = NativeMethods.k4a_playback_data_block_get_buffer(this.handle); if (bufferPtr != IntPtr.Zero) @@ -55,6 +69,9 @@ public byte[] Buffer } } + /// + /// Gets the device timestamp associated with the data. + /// public TimeSpan DeviceTimestamp { get @@ -73,7 +90,6 @@ public TimeSpan DeviceTimestamp } } - /// public void Dispose() { diff --git a/src/csharp/Record/Exceptions/AzureKinectAddAttachmentException.cs b/src/csharp/Record/Exceptions/AzureKinectAddAttachmentException.cs index 3dd850417..aacf0d6a6 100644 --- a/src/csharp/Record/Exceptions/AzureKinectAddAttachmentException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectAddAttachmentException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when adding an attachment to a recording + /// Represents errors that occur when adding an attachment to a recording. /// [Serializable] public class AzureKinectAddAttachmentException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectAddCustomSubtitleTrackException.cs b/src/csharp/Record/Exceptions/AzureKinectAddCustomSubtitleTrackException.cs index b75e5fe46..12527430e 100644 --- a/src/csharp/Record/Exceptions/AzureKinectAddCustomSubtitleTrackException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectAddCustomSubtitleTrackException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when adding a custom subtitle track + /// Represents errors that occur when adding a custom subtitle track. /// [Serializable] public class AzureKinectAddCustomSubtitleTrackException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectAddCustomVideoTrackException.cs b/src/csharp/Record/Exceptions/AzureKinectAddCustomVideoTrackException.cs index efa5be47d..aa59301cd 100644 --- a/src/csharp/Record/Exceptions/AzureKinectAddCustomVideoTrackException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectAddCustomVideoTrackException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when adding a custom video track + /// Represents errors that occur when adding a custom video track. /// [Serializable] public class AzureKinectAddCustomVideoTrackException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectAddImuTrackException.cs b/src/csharp/Record/Exceptions/AzureKinectAddImuTrackException.cs index 161c8dde9..3fadd2128 100644 --- a/src/csharp/Record/Exceptions/AzureKinectAddImuTrackException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectAddImuTrackException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when adding an IMU track to a recording. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectAddTagException.cs b/src/csharp/Record/Exceptions/AzureKinectAddTagException.cs index 43d4f259e..070d9ca06 100644 --- a/src/csharp/Record/Exceptions/AzureKinectAddTagException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectAddTagException.cs @@ -11,7 +11,7 @@ namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { /// - /// Represents errors that occur when adding a tag to a recording + /// Represents errors that occur when adding a tag to a recording. /// [Serializable] public class AzureKinectAddTagException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectCreateRecordingException.cs b/src/csharp/Record/Exceptions/AzureKinectCreateRecordingException.cs index 58506b54c..db66af19c 100644 --- a/src/csharp/Record/Exceptions/AzureKinectCreateRecordingException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectCreateRecordingException.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; -using Microsoft.Azure.Kinect.Sensor.Record; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { @@ -84,13 +83,12 @@ protected AzureKinectCreateRecordingException(string message, ICollection if the result of the function /// is not a success. /// - /// File name of the create + /// File name of the create. /// The native function to call. /// The type of result to expect from the function call. internal static void ThrowIfNotSuccess(string fileName, Func function) where T : System.Enum { - using (LoggingTracer tracer = new LoggingTracer(LogLevel.Warning, Logger.LogProvider, RecordLogger.LogProvider)) { T result = function(); @@ -105,7 +103,7 @@ internal static void ThrowIfNotSuccess(string fileName, Func function) /// Throws an if the result of the function /// is not a success. /// - /// File name of the create + /// File name of the create. /// The tracer is that is capturing logging messages. /// The result native function to call. /// The type of result to expect from the function call. diff --git a/src/csharp/Record/Exceptions/AzureKinectFlushException.cs b/src/csharp/Record/Exceptions/AzureKinectFlushException.cs index c0021f44d..e23177971 100644 --- a/src/csharp/Record/Exceptions/AzureKinectFlushException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectFlushException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when an error occurs during flushing + /// Represents errors that occur when an error occurs during flushing. /// [Serializable] public class AzureKinectFlushException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectGetCalibrationException.cs b/src/csharp/Record/Exceptions/AzureKinectGetCalibrationException.cs index 48b45ab64..8050101ed 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetCalibrationException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetCalibrationException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when getting calibration from a recording. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectGetCaptureException.cs b/src/csharp/Record/Exceptions/AzureKinectGetCaptureException.cs index 7e4ec0b71..8960681fb 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetCaptureException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetCaptureException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when getting the next or previous capture. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectGetDataBlockException.cs b/src/csharp/Record/Exceptions/AzureKinectGetDataBlockException.cs index f3685e9c8..e06bfccab 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetDataBlockException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetDataBlockException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when getting a data block. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectGetImuSampleException.cs b/src/csharp/Record/Exceptions/AzureKinectGetImuSampleException.cs index d06addf96..089d6e49c 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetImuSampleException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetImuSampleException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when reading an IMU sample. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectGetRawCalibrationException.cs b/src/csharp/Record/Exceptions/AzureKinectGetRawCalibrationException.cs index ec7d0aca8..ba9795441 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetRawCalibrationException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetRawCalibrationException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when getting raw calibration from a recording. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectGetTagException.cs b/src/csharp/Record/Exceptions/AzureKinectGetTagException.cs index afcaae86b..1aefdbc9d 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetTagException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetTagException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when getting a tag value + /// Represents errors that occur when getting a tag value. /// [Serializable] public class AzureKinectGetTagException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectGetTrackCodecContextException.cs b/src/csharp/Record/Exceptions/AzureKinectGetTrackCodecContextException.cs index 2181246c3..e5f359115 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetTrackCodecContextException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetTrackCodecContextException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when getting a codec context from a track + /// Represents errors that occur when getting a codec context from a track. /// [Serializable] public class AzureKinectGetTrackCodecContextException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectGetTrackNameException.cs b/src/csharp/Record/Exceptions/AzureKinectGetTrackNameException.cs index 977192c51..609089873 100644 --- a/src/csharp/Record/Exceptions/AzureKinectGetTrackNameException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectGetTrackNameException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when getting a track name + /// Represents errors that occur when getting a track name. /// [Serializable] public class AzureKinectGetTrackNameException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectOpenPlaybackException.cs b/src/csharp/Record/Exceptions/AzureKinectOpenPlaybackException.cs index 1725c53de..c098844cc 100644 --- a/src/csharp/Record/Exceptions/AzureKinectOpenPlaybackException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectOpenPlaybackException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when opening a recording for playback. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectRecordException.cs b/src/csharp/Record/Exceptions/AzureKinectRecordException.cs index 5ba743eef..5f7404e81 100644 --- a/src/csharp/Record/Exceptions/AzureKinectRecordException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectRecordException.cs @@ -1,17 +1,25 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { + /// + /// Represents errors occuring during record or playback. + /// [Serializable] public abstract class AzureKinectRecordException : AzureKinectException { /// /// Initializes a new instance of the class. /// - public AzureKinectRecordException() + protected AzureKinectRecordException() { } @@ -20,7 +28,7 @@ public AzureKinectRecordException() /// with a specified error message. /// /// The message that describes the error. - public AzureKinectRecordException(string message) + protected AzureKinectRecordException(string message) : base(message) { } @@ -37,7 +45,7 @@ public AzureKinectRecordException(string message) /// The exception that is the cause of the current exception, or a null reference /// (Nothing in Visual Basic) if no inner exception is specified. /// - public AzureKinectRecordException(string message, Exception innerException) + protected AzureKinectRecordException(string message, Exception innerException) : base(message, innerException) { } @@ -98,7 +106,7 @@ internal static bool IsSuccess(T result) throw new ArgumentException("Result is not of a recognized result type.", nameof(result)); } } - + /// /// Determines if the is a success. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectSeekException.cs b/src/csharp/Record/Exceptions/AzureKinectSeekException.cs index 70700af7d..1c91f5abc 100644 --- a/src/csharp/Record/Exceptions/AzureKinectSeekException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectSeekException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when seeking + /// Represents errors that occur when seeking. /// [Serializable] public class AzureKinectSeekException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectSetColorConversionException.cs b/src/csharp/Record/Exceptions/AzureKinectSetColorConversionException.cs index 6de3cb76e..8f9c6d728 100644 --- a/src/csharp/Record/Exceptions/AzureKinectSetColorConversionException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectSetColorConversionException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when setting a color conversion on playback. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectTrackGetVideoSettingsException.cs b/src/csharp/Record/Exceptions/AzureKinectTrackGetVideoSettingsException.cs index 98b157a9e..4e3f10254 100644 --- a/src/csharp/Record/Exceptions/AzureKinectTrackGetVideoSettingsException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectTrackGetVideoSettingsException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when an error occurs getting track video settings. /// diff --git a/src/csharp/Record/Exceptions/AzureKinectWriteCaptureException.cs b/src/csharp/Record/Exceptions/AzureKinectWriteCaptureException.cs index 162da069a..a7be4bcab 100644 --- a/src/csharp/Record/Exceptions/AzureKinectWriteCaptureException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectWriteCaptureException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when writing a capture to a recording + /// Represents errors that occur when writing a capture to a recording. /// [Serializable] public class AzureKinectWriteCaptureException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectWriteCustomTrackDataException.cs b/src/csharp/Record/Exceptions/AzureKinectWriteCustomTrackDataException.cs index 4244a4c66..8fece967e 100644 --- a/src/csharp/Record/Exceptions/AzureKinectWriteCustomTrackDataException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectWriteCustomTrackDataException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when writing a custom track + /// Represents errors that occur when writing a custom track. /// [Serializable] public class AzureKinectWriteCustomTrackDataException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectWriteHeaderException.cs b/src/csharp/Record/Exceptions/AzureKinectWriteHeaderException.cs index fcaba6d9b..1d3277753 100644 --- a/src/csharp/Record/Exceptions/AzureKinectWriteHeaderException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectWriteHeaderException.cs @@ -1,13 +1,17 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// - /// Represents errors that occur when writing the header + /// Represents errors that occur when writing the header. /// [Serializable] public class AzureKinectWriteHeaderException : AzureKinectRecordException diff --git a/src/csharp/Record/Exceptions/AzureKinectWriteImuSampleException.cs b/src/csharp/Record/Exceptions/AzureKinectWriteImuSampleException.cs index 0278cae03..982843ab2 100644 --- a/src/csharp/Record/Exceptions/AzureKinectWriteImuSampleException.cs +++ b/src/csharp/Record/Exceptions/AzureKinectWriteImuSampleException.cs @@ -1,11 +1,15 @@ -using System; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions { - /// /// Represents errors that occur when writing an IMU sample. /// diff --git a/src/csharp/Record/NativeMethods.cs b/src/csharp/Record/NativeMethods.cs index c1ee0995f..d36a84cdc 100644 --- a/src/csharp/Record/NativeMethods.cs +++ b/src/csharp/Record/NativeMethods.cs @@ -5,8 +5,6 @@ // //------------------------------------------------------------------------------ using System; -using System.Globalization; -using System.Linq.Expressions; using System.Numerics; using System.Runtime.InteropServices; using System.Text; @@ -16,6 +14,7 @@ namespace Microsoft.Azure.Kinect.Sensor.Record #pragma warning disable IDE1006 // Naming Styles #pragma warning disable SA1600 // Elements should be documented #pragma warning disable SA1602 // Enumeration items should be documented +#pragma warning disable CA2101 // Specify marshaling for P/Invoke string arguments internal static class NativeMethods { private const CallingConvention k4aCallingConvention = CallingConvention.Cdecl; @@ -58,7 +57,7 @@ public static extern k4a_result_t k4a_record_set_debug_message_handler( [DllImport("k4arecord", CallingConvention = k4aCallingConvention, CharSet = CharSet.Ansi)] public static extern k4a_result_t k4a_record_create(string path, IntPtr device, k4a_device_configuration_t deviceConfiguration, out k4a_record_t handle); - + [DllImport("k4arecord", CallingConvention = k4aCallingConvention, CharSet = CharSet.Ansi)] public static extern k4a_result_t k4a_record_add_tag(k4a_record_t handle, string name, string value); @@ -102,7 +101,7 @@ public static extern k4a_result_t k4a_record_set_debug_message_handler( public static extern k4a_result_t k4a_playback_get_calibration(k4a_playback_t playback_handle, out Calibration calibration); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_result_t k4a_playback_get_record_configuration(k4a_playback_t playback_handle, out k4a_record_configuration_t configuration); + public static extern k4a_result_t k4a_playback_get_record_configuration(k4a_playback_t playback_handle, [Out] k4a_record_configuration_t configuration); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] public static extern bool k4a_playback_check_track_exists(k4a_playback_t playback_handle, string track_name); @@ -123,80 +122,87 @@ public static extern k4a_result_t k4a_record_set_debug_message_handler( public static extern k4a_buffer_result_t k4a_playback_track_get_codec_id(k4a_playback_t playback_handle, string track_name, StringBuilder codec_id, ref UIntPtr codec_id_size); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_buffer_result_t k4a_playback_track_get_codec_context(k4a_playback_t playback_handle, - string track_name, - byte[] codec_context, - ref UIntPtr codec_context_size); + public static extern k4a_buffer_result_t k4a_playback_track_get_codec_context( + k4a_playback_t playback_handle, + string track_name, + byte[] codec_context, + ref UIntPtr codec_context_size); - [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_buffer_result_t k4a_playback_get_tag(k4a_playback_t playback_handle, - string track_name, - StringBuilder value, - ref UIntPtr codec_context_size); + [DllImport("k4arecord", CallingConvention = k4aCallingConvention, CharSet = CharSet.Ansi)] + public static extern k4a_buffer_result_t k4a_playback_get_tag( + k4a_playback_t playback_handle, + string track_name, + StringBuilder value, + ref UIntPtr codec_context_size); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_result_t k4a_playback_set_color_conversion(k4a_playback_t playback_handle, - ImageFormat target_format); + public static extern k4a_result_t k4a_playback_set_color_conversion( + k4a_playback_t playback_handle, + ImageFormat target_format); - [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_buffer_result_t k4a_playback_get_attachment(k4a_playback_t playback_handle, - string file_name, - byte[] data, - ref UIntPtr data_size); + [DllImport("k4arecord", CallingConvention = k4aCallingConvention, CharSet = CharSet.Ansi)] + public static extern k4a_buffer_result_t k4a_playback_get_attachment( + k4a_playback_t playback_handle, + string file_name, + byte[] data, + ref UIntPtr data_size); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_stream_result_t k4a_playback_get_next_capture(k4a_playback_t playback_handle, - out IntPtr capture_handle); + public static extern k4a_stream_result_t k4a_playback_get_next_capture( + k4a_playback_t playback_handle, + out IntPtr capture_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_stream_result_t k4a_playback_get_previous_capture(k4a_playback_t playback_handle, - out IntPtr capture_handle); - + public static extern k4a_stream_result_t k4a_playback_get_previous_capture( + k4a_playback_t playback_handle, + out IntPtr capture_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_stream_result_t k4a_playback_get_next_imu_sample(k4a_playback_t playback_handle, - [Out] k4a_imu_sample_t imu_sample); + public static extern k4a_stream_result_t k4a_playback_get_next_imu_sample( + k4a_playback_t playback_handle, + [Out] k4a_imu_sample_t imu_sample); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_stream_result_t k4a_playback_get_previous_imu_sample(k4a_playback_t playback_handle, - [Out] k4a_imu_sample_t imu_sample); + public static extern k4a_stream_result_t k4a_playback_get_previous_imu_sample( + k4a_playback_t playback_handle, + [Out] k4a_imu_sample_t imu_sample); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_stream_result_t k4a_playback_get_next_data_block(k4a_playback_t playback_handle, - string track_name, - out k4a_playback_data_block_t data_block); + public static extern k4a_stream_result_t k4a_playback_get_next_data_block( + k4a_playback_t playback_handle, + string track_name, + out k4a_playback_data_block_t data_block); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_stream_result_t k4a_playback_get_previous_data_block(k4a_playback_t playback_handle, - string track_name, - out k4a_playback_data_block_t data_block_handle); + public static extern k4a_stream_result_t k4a_playback_get_previous_data_block( + k4a_playback_t playback_handle, + string track_name, + out k4a_playback_data_block_t data_block_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] public static extern IntPtr k4a_playback_data_block_get_buffer(k4a_playback_data_block_t data_block_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern UInt64 k4a_playback_data_block_get_device_timestamp_usec(k4a_playback_data_block_t data_block_handle); + public static extern ulong k4a_playback_data_block_get_device_timestamp_usec(k4a_playback_data_block_t data_block_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern UInt64 k4a_playback_data_block_get_buffer_size(k4a_playback_data_block_t data_block_handle); + public static extern ulong k4a_playback_data_block_get_buffer_size(k4a_playback_data_block_t data_block_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] public static extern void k4a_playback_data_block_release(IntPtr data_block_handle); - [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern k4a_result_t k4a_playback_seek_timestamp(k4a_playback_t playback_handle, UInt64 offset_usec, PlaybackSeekOrigin origin); + public static extern k4a_result_t k4a_playback_seek_timestamp(k4a_playback_t playback_handle, ulong offset_usec, PlaybackSeekOrigin origin); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern UInt64 k4a_playback_get_recording_length_usec(k4a_playback_t playback_handle); + public static extern ulong k4a_playback_get_recording_length_usec(k4a_playback_t playback_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - public static extern UInt64 k4a_playback_get_last_timestamp_usec(k4a_playback_t playback_handle); + public static extern ulong k4a_playback_get_last_timestamp_usec(k4a_playback_t playback_handle); [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] public static extern void k4a_playback_close(IntPtr playback_handle); - [StructLayout(LayoutKind.Sequential)] public struct k4a_version_t { @@ -342,20 +348,23 @@ public ImuSample ToImuSample() [StructLayout(LayoutKind.Sequential)] public class k4a_record_configuration_t { +#pragma warning disable SA1401 // Fields should be private public ImageFormat color_format; public ColorResolution color_resolution; public DepthMode depth_mode; public FPS camera_fps; public bool color_track_enabled; public bool depth_track_enabled; + public bool ir_track_enabled; public bool imu_track_enabled; public int depth_delay_off_color_usec; public WiredSyncMode wired_sync_mode; public uint subordinate_delay_off_master_usec; public uint start_timestamp_offset_usec; +#pragma warning restore SA1401 // Fields should be private } - } +#pragma warning restore CA2101 // Specify marshaling for P/Invoke string arguments #pragma warning restore SA1602 // Enumeration items should be documented #pragma warning restore SA1600 // Elements should be documented #pragma warning restore IDE1006 // Naming Styles diff --git a/src/csharp/Record/Playback.cs b/src/csharp/Record/Playback.cs index 40204c701..a7a26d077 100644 --- a/src/csharp/Record/Playback.cs +++ b/src/csharp/Record/Playback.cs @@ -1,10 +1,18 @@ -using System; -using System.Collections.Generic; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Text; using Microsoft.Azure.Kinect.Sensor.Record.Exceptions; namespace Microsoft.Azure.Kinect.Sensor.Record { + /// + /// Respresents a file being used to playback data from an Azure Kinect device. + /// public class Playback : IDisposable { // The native handle for this recording. @@ -23,51 +31,7 @@ private Playback(NativeMethods.k4a_playback_t handle) } /// - /// Opens an existing recording file for reading. - /// - /// Filesystem path of the existing recording. - /// - public static Playback Open(string path) - { - NativeMethods.k4a_playback_t handle = null; - - AzureKinectOpenPlaybackException.ThrowIfNotSuccess(() => NativeMethods.k4a_playback_open(path, out handle)); - - return new Playback(handle); - } - - /// - /// Get the raw calibration blob for the Azure Kinect device used during recording. - /// - /// The raw calibration may not exist if the device was not specified during recording. - public byte[] GetRawCalibration() - { - lock (this) - { - if (this.disposedValue) - { - throw new ObjectDisposedException(nameof(Playback)); - } - - // Determine the required calibration size - UIntPtr size = new UIntPtr(0); - if (NativeMethods.k4a_playback_get_raw_calibration(this.handle, null, ref size) != NativeMethods.k4a_buffer_result_t.K4A_BUFFER_RESULT_TOO_SMALL) - { - throw new AzureKinectGetRawCalibrationException($"Unexpected result calling {nameof(NativeMethods.k4a_playback_get_raw_calibration)}"); - } - - // Allocate a string buffer - byte[] raw = new byte[size.ToUInt32()]; - - // Get the raw calibration - AzureKinectGetRawCalibrationException.ThrowIfNotSuccess(() => NativeMethods.k4a_playback_get_raw_calibration(this.handle, raw, ref size)); - - return raw; - } - } - - /// - /// Get the camera calibration for Azure Kinect device used during recording. The output struct is used as input to all transformation functions. + /// Gets get the camera calibration for Azure Kinect device used during recording. The output struct is used as input to all transformation functions. /// /// /// The calibration may not exist if the device was not specified during recording. @@ -85,8 +49,7 @@ public Calibration? Calibration if (!this.calibration.HasValue) { - Calibration localCalibration = new Calibration(); - if (NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED == NativeMethods.k4a_playback_get_calibration(this.handle, out localCalibration)) + if (NativeMethods.k4a_playback_get_calibration(this.handle, out Calibration localCalibration) == NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED) { this.calibration = localCalibration; } @@ -98,7 +61,7 @@ public Calibration? Calibration } /// - /// Get the device configuration used during recording. + /// Gets get the device configuration used during recording. /// public RecordConfiguration RecordConfiguration { @@ -113,7 +76,9 @@ public RecordConfiguration RecordConfiguration if (this.recordConfiguration == null) { - if (NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED == NativeMethods.k4a_playback_get_record_configuration(this.handle, out NativeMethods.k4a_record_configuration_t nativeConfig)) + NativeMethods.k4a_record_configuration_t nativeConfig = new NativeMethods.k4a_record_configuration_t(); + + if (NativeMethods.k4a_playback_get_record_configuration(this.handle, nativeConfig) == NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED) { this.recordConfiguration = RecordConfiguration.FromNative(nativeConfig); } @@ -125,11 +90,66 @@ public RecordConfiguration RecordConfiguration } /// - /// Checks whether a track with the given track name exists in the playback file. + /// Gets get the number of tracks in a playback file. /// - /// The track name to be checked to see whether it exists or not. - /// - public bool CheckTrackExists(string trackName) + public int TrackCount + { + get + { + lock (this) + { + if (this.disposedValue) + { + throw new ObjectDisposedException(nameof(Playback)); + } + + return checked((int)NativeMethods.k4a_playback_get_track_count(this.handle)); + } + } + } + + /// + /// Gets the length of the recording in microseconds. + /// + /// + /// The recording length, calculated as the difference between the first and last timestamp in the file. + /// + /// The recording length may be longer than an individual track if, for example, the IMU continues to run after the last + /// color image is recorded. + /// + public TimeSpan RecordingLength + { + get + { + if (this.disposedValue) + { + throw new ObjectDisposedException(nameof(Playback)); + } + + long length = checked((long)NativeMethods.k4a_playback_get_recording_length_usec(this.handle)); + return TimeSpan.FromTicks(length * 10); + } + } + + /// + /// Opens an existing recording file for reading. + /// + /// Filesystem path of the existing recording. + /// An object representing the file for playback. + public static Playback Open(string path) + { + NativeMethods.k4a_playback_t handle = null; + + AzureKinectOpenPlaybackException.ThrowIfNotSuccess(() => NativeMethods.k4a_playback_open(path, out handle)); + + return new Playback(handle); + } + + /// + /// Get the raw calibration blob for the Azure Kinect device used during recording. + /// + /// The raw calibration may not exist if the device was not specified during recording. + public byte[] GetRawCalibration() { lock (this) { @@ -138,31 +158,43 @@ public bool CheckTrackExists(string trackName) throw new ObjectDisposedException(nameof(Playback)); } - if (trackName == null) + // Determine the required calibration size + UIntPtr size = new UIntPtr(0); + if (NativeMethods.k4a_playback_get_raw_calibration(this.handle, null, ref size) != NativeMethods.k4a_buffer_result_t.K4A_BUFFER_RESULT_TOO_SMALL) { - throw new ArgumentNullException(nameof(trackName)); + throw new AzureKinectGetRawCalibrationException($"Unexpected result calling {nameof(NativeMethods.k4a_playback_get_raw_calibration)}"); } - return NativeMethods.k4a_playback_check_track_exists(this.handle, trackName); + // Allocate a string buffer + byte[] raw = new byte[size.ToUInt32()]; + + // Get the raw calibration + AzureKinectGetRawCalibrationException.ThrowIfNotSuccess(() => NativeMethods.k4a_playback_get_raw_calibration(this.handle, raw, ref size)); + + return raw; } } /// - /// Get the number of tracks in a playback file. + /// Checks whether a track with the given track name exists in the playback file. /// - public int TrackCount + /// The track name to be checked to see whether it exists or not. + /// True if the track exists in the file. + public bool CheckTrackExists(string trackName) { - get + lock (this) { - lock (this) + if (this.disposedValue) { - if (this.disposedValue) - { - throw new ObjectDisposedException(nameof(Playback)); - } + throw new ObjectDisposedException(nameof(Playback)); + } - return checked((int)NativeMethods.k4a_playback_get_track_count(this.handle)); + if (trackName == null) + { + throw new ArgumentNullException(nameof(trackName)); } + + return NativeMethods.k4a_playback_check_track_exists(this.handle, trackName); } } @@ -257,8 +289,8 @@ public RecordVideoSettings GetTrackVideoSettings(string trackName) /// /// Gets the codec id string for a particular track. /// - /// - /// The track name to read the codec id from. + /// The track name to read the codec id from. + /// Codec ID for the track. /// /// The codec ID is a string that corresponds to the codec of the track's data. Some of the existing formats are listed /// here: https://www.matroska.org/technical/specs/codecid/index.html. It can also be custom defined by the user. @@ -419,7 +451,7 @@ public byte[] GetAttachment(string fileName) } // Allocate a buffer - byte[] buffer= new byte[checked((int)size)]; + byte[] buffer = new byte[checked((int)size)]; // Get the codec id AzureKinectGetTrackNameException.ThrowIfNotSuccess(() => NativeMethods.k4a_playback_get_attachment(this.handle, fileName, buffer, ref size)); @@ -434,14 +466,14 @@ public byte[] GetAttachment(string fileName) /// The next capture in the sequence, or null if at the end of the sequence. /// /// always returns the next capture in sequence after the most recently returned capture. - /// + /// /// The first call to after will return the capture /// in the recording closest to the seek time with an image timestamp greater than or equal to the seek time. - /// + /// /// If a call was made to that returned null, the playback /// position is at the beginning of the stream and will return the first capture in the /// recording. - /// + /// /// Capture objects returned by the playback API will always contain at least one image, but may have images missing if /// frames were dropped in the original recording. When calling , /// , or , the image should be checked for null. @@ -477,14 +509,14 @@ public Capture GetNextCapture() /// The previous capture in the sequence, or null if at the beginning of the sequence. /// /// always returns the previous capture in sequence after the most recently returned capture. - /// + /// /// The first call to after will return the capture /// in the recording closest to the seek time with all image timestamps less than the seek time. - /// + /// /// If a call was made to that returned null, the playback /// position is at the end of the stream and will return the last capture in the /// recording. - /// + /// /// Capture objects returned by the playback API will always contain at least one image, but may have images missing if /// frames were dropped in the original recording. When calling , /// , or , the image should be checked for null. @@ -520,10 +552,10 @@ public Capture GetPreviousCapture() /// The next IMU sample in the sequence, or null if at the end of the sequence. /// /// always returns the next IMU sample in sequence after the most recently returned sample. - /// + /// /// The first call to after will return the sample /// in the recording closest to the seek time with a timestamp greater than or equal to the seek time. - /// + /// /// If a call was made to that returned null, the playback /// position is at the beginning of the stream and will return the first sample in the /// recording. @@ -536,6 +568,7 @@ public ImuSample GetNextImuSample() { throw new ObjectDisposedException(nameof(Playback)); } + NativeMethods.k4a_imu_sample_t imu_sample = new NativeMethods.k4a_imu_sample_t(); switch (NativeMethods.k4a_playback_get_next_imu_sample(this.handle, imu_sample)) @@ -558,10 +591,10 @@ public ImuSample GetNextImuSample() /// The previous IMU sample in the sequence, or null if at the beginning of the sequence. /// /// always returns the previous IMU sample in sequence before the most recently returned sample. - /// + /// /// The first call to after will return the sample /// in the recording closest to the seek time with a timestamp less than the seek time. - /// + /// /// If a call was made to that returned null, the playback /// position is at the end of the stream and will return the last sample in the /// recording. @@ -599,10 +632,10 @@ public ImuSample GetPreviousImuSample() /// /// always returns the next data block in sequence after the most recently returned data block /// for a particular track. - /// + /// /// The first call to after will return the data block /// in the recording closest to the seek time with a timestamp greater than or equal to the seek time. - /// + /// /// If a call was made to that returned null for a particular track, the playback /// position is at the beginning of the stream and will return the first data block in the /// recording. @@ -643,10 +676,10 @@ public DataBlock GetNextDataBlock(string trackName) /// /// always returns the previous data block in sequence after the most recently returned data block /// for a particular track. - /// + /// /// The first call to after will return the data block /// in the recording closest to the seek time with a timestamp less than the seek time. - /// + /// /// If a call was made to that returned null for a particular track, the playback /// position is at the end of the stream and will return the last data block in the /// recording. @@ -682,22 +715,22 @@ public DataBlock GetPreviousDataBlock(string trackName) /// /// Seek to a specific timestamp within a recording. /// - /// The timestamp offset to seek to, relative to + /// The timestamp offset to seek to, relative to . /// Specifies how the given timestamp should be interpreted. Seek can be done relative to the beginning or end of the /// recording, or using an absolute device timestamp. /// /// The first device timestamp in a recording is usually non-zero. The recording file starts at the device timestamp /// defined by , which is accessible via . - /// + /// /// The first call to after will return a capture containing an image /// timestamp greater than or equal to the seek time. - /// + /// /// The first call to after will return a capture with /// all image timstamps less than the seek time. - /// + /// /// The first call to and after will return the /// first data with a timestamp greater than or equal to the seek time. - /// + /// /// The first call to and after will return the /// first data with a timestamp less than the seek time. /// @@ -714,29 +747,6 @@ public void Seek(TimeSpan offset, PlaybackSeekOrigin origin = PlaybackSeekOrigin } } - /// - /// Returns the length of the recording in microseconds. - /// - /// - /// The recording length, calculated as the difference between the first and last timestamp in the file. - /// - /// The recording length may be longer than an individual track if, for example, the IMU continues to run after the last - /// color image is recorded. - /// - public TimeSpan RecordingLength - { - get - { - if (this.disposedValue) - { - throw new ObjectDisposedException(nameof(Playback)); - } - - long length = checked((long)NativeMethods.k4a_playback_get_recording_length_usec(this.handle)); - return TimeSpan.FromTicks(length * 10); - } - } - /// public void Dispose() { diff --git a/src/csharp/Record/PlaybackSeekOrigin.cs b/src/csharp/Record/PlaybackSeekOrigin.cs index d461cf137..1f8caf5cf 100644 --- a/src/csharp/Record/PlaybackSeekOrigin.cs +++ b/src/csharp/Record/PlaybackSeekOrigin.cs @@ -1,13 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Text; - +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ namespace Microsoft.Azure.Kinect.Sensor.Record { + /// + /// The origin for relative seek operations. + /// public enum PlaybackSeekOrigin { + /// + /// The seek operation is relative to the beginning of the file. + /// Begin = 0, + + /// + /// The seek operation is relative to the end of the file. + /// End, - DeviceTime + + /// + /// The seek operation is specified in the device time. + /// + DeviceTime, } } diff --git a/src/csharp/Record/RecordConfiguration.cs b/src/csharp/Record/RecordConfiguration.cs index 995ad34f0..a58bb02c7 100644 --- a/src/csharp/Record/RecordConfiguration.cs +++ b/src/csharp/Record/RecordConfiguration.cs @@ -1,23 +1,93 @@ -using System; -using System.Collections.Generic; -using System.Text; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; namespace Microsoft.Azure.Kinect.Sensor.Record { + /// + /// Structure containing the device configuration used to record. + /// public class RecordConfiguration { + /// + /// Gets or sets the image format used to record the color camera. + /// public ImageFormat ColorFormat { get; set; } + + /// + /// Gets or sets the image resolution used to record the color camera. + /// public ColorResolution ColorResolution { get; set; } + + /// + /// Gets or sets the mode used to record the depth camera. + /// public DepthMode DepthMode { get; set; } + + /// + /// Gets or sets the frame rate used to record the color and depth camera. + /// public FPS CameraFPS { get; set; } + + /// + /// Gets or sets a value indicating whether the recording contains Color camera frames. + /// public bool ColorTrackEnabled { get; set; } + + /// + /// Gets or sets a value indicating whether the recording contains Depth camera frames. + /// public bool DepthTrackEnabled { get; set; } - public bool IMUTrackEnabled { get; set; } + + /// + /// Gets or sets a value indicating whether the recording contains IR camera frames. + /// + public bool IRTrackEnabled { get; set; } + + /// + /// Gets or sets a value indicating whether the recording contains IMU sample data. + /// + public bool ImuTrackEnabled { get; set; } + + /// + /// Gets or sets the delay between color and depth images in the recording. + /// + /// + /// A negative delay means depth images are first, and a positive delay means color images are first. + /// public TimeSpan DepthDelayOffColor { get; set; } + + /// + /// Gets or sets external synchronization mode. + /// public WiredSyncMode WiredSyncMode { get; set; } + + /// + /// Gets or sets the delay between this recording and the externally synced master camera. + /// + /// + /// This value is 0 unless is set to . + /// public TimeSpan SubordinateDelayOffMaster { get; set; } + + /// + /// Gets or sets the timestamp offset of the start of the recording. + /// + /// + /// All recorded timestamps are offset by this value such that + /// the recording starts at timestamp 0. This value can be used to synchronize timestamps between 2 recording files. + /// public TimeSpan StartTimestampOffset { get; set; } + /// + /// Gets a object from a native object. + /// + /// Native object. + /// Managed object. internal static RecordConfiguration FromNative(NativeMethods.k4a_record_configuration_t config) { return new RecordConfiguration() @@ -28,11 +98,12 @@ internal static RecordConfiguration FromNative(NativeMethods.k4a_record_configur CameraFPS = config.camera_fps, ColorTrackEnabled = config.color_track_enabled, DepthTrackEnabled = config.depth_track_enabled, - IMUTrackEnabled = config.imu_track_enabled, + IRTrackEnabled = config.ir_track_enabled, + ImuTrackEnabled = config.imu_track_enabled, DepthDelayOffColor = TimeSpan.FromTicks(config.subordinate_delay_off_master_usec * 10), WiredSyncMode = config.wired_sync_mode, SubordinateDelayOffMaster = TimeSpan.FromTicks(config.subordinate_delay_off_master_usec * 10), - StartTimestampOffset = TimeSpan.FromTicks(config.start_timestamp_offset_usec) + StartTimestampOffset = TimeSpan.FromTicks(config.start_timestamp_offset_usec), }; } } diff --git a/src/csharp/Record/RecordLogger.cs b/src/csharp/Record/RecordLogger.cs index 5cd50e26b..18eb11ac8 100644 --- a/src/csharp/Record/RecordLogger.cs +++ b/src/csharp/Record/RecordLogger.cs @@ -5,9 +5,7 @@ // //------------------------------------------------------------------------------ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record { @@ -55,13 +53,7 @@ public static event Action LogMessage /// /// Gets the interface for reading log messages. /// - public static ILoggingProvider LogProvider - { - get - { - return RecordLogger.LoggerProvider; - } - } + public static ILoggingProvider LogProvider => RecordLogger.LoggerProvider; /// /// Initializes the class to begin receiving messages from the Azure Kinect Sensor SDK. diff --git a/src/csharp/Record/RecordSubtitleSettings.cs b/src/csharp/Record/RecordSubtitleSettings.cs index f66c08f57..d7b666b37 100644 --- a/src/csharp/Record/RecordSubtitleSettings.cs +++ b/src/csharp/Record/RecordSubtitleSettings.cs @@ -1,13 +1,26 @@ -using System; -using System.Collections.Generic; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ +using System; using System.Runtime.InteropServices; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record { + /// + /// Settings for a recording subtitle track. + /// [StructLayout(LayoutKind.Sequential)] public class RecordSubtitleSettings { + /// + /// Gets or sets a value indicating whether data will be grouped together to reduce overhead. + /// + /// + /// If set, only a single timestamp will be stored per batch, and an estimated timestamp will be use by and . + /// The estimated timestamp is calculated with the assumption that blocks are evenly spaced within a batch. public bool HighFrequencyData { get; set; } } } diff --git a/src/csharp/Record/RecordVideoSettings.cs b/src/csharp/Record/RecordVideoSettings.cs index 0ebb9a02c..bcdd1cc95 100644 --- a/src/csharp/Record/RecordVideoSettings.cs +++ b/src/csharp/Record/RecordVideoSettings.cs @@ -1,15 +1,32 @@ -using System; -using System.Collections.Generic; +//------------------------------------------------------------------------------ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// +//------------------------------------------------------------------------------ using System.Runtime.InteropServices; -using System.Text; namespace Microsoft.Azure.Kinect.Sensor.Record { + /// + /// Structure containing additional metadata specific to custom video tracks. + /// [StructLayout(LayoutKind.Sequential)] public class RecordVideoSettings { - public ulong Width { get; set; } - public ulong Height { get; set; } - public ulong FrameRate { get; set; } + /// + /// Gets or sets frame width of the video. + /// + public long Width { get; set; } + + /// + /// Gets or sets frame height of the video. + /// + public long Height { get; set; } + + /// + /// Gets or sets frame rate of the video. + /// + public long FrameRate { get; set; } } } diff --git a/src/csharp/Record/Record.cs b/src/csharp/Record/Recorder.cs similarity index 92% rename from src/csharp/Record/Record.cs rename to src/csharp/Record/Recorder.cs index 8d2585354..590e68cf7 100644 --- a/src/csharp/Record/Record.cs +++ b/src/csharp/Record/Recorder.cs @@ -1,12 +1,10 @@ //------------------------------------------------------------------------------ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // //------------------------------------------------------------------------------ using System; -using System.Collections.Generic; -using System.Text; using Microsoft.Azure.Kinect.Sensor.Record.Exceptions; namespace Microsoft.Azure.Kinect.Sensor.Record @@ -14,7 +12,7 @@ namespace Microsoft.Azure.Kinect.Sensor.Record /// /// Represents a writable sensor recording. /// - public class Record : IDisposable + public class Recorder : IDisposable { // The native handle for this recording. private readonly NativeMethods.k4a_record_t handle; @@ -22,7 +20,7 @@ public class Record : IDisposable // To detect redundant calls to Dispose private bool disposedValue = false; - private Record(NativeMethods.k4a_record_t handle) + private Recorder(NativeMethods.k4a_record_t handle) { this.handle = handle; } @@ -34,7 +32,7 @@ private Record(NativeMethods.k4a_record_t handle) /// Device to get properties from. May be null for user-generated recordings. /// Parameters used to open the device. /// A new recording object. - public static Record Create(string path, Device device, DeviceConfiguration deviceConfiguration) + public static Recorder Create(string path, Device device, DeviceConfiguration deviceConfiguration) { NativeMethods.k4a_record_t handle = null; if (device != null) @@ -51,7 +49,7 @@ public static Record Create(string path, Device device, DeviceConfiguration devi AzureKinectCreateRecordingException.ThrowIfNotSuccess(path, () => NativeMethods.k4a_record_create(path, IntPtr.Zero, NativeMethods.k4a_device_configuration_t.FromDeviceConfiguration(deviceConfiguration), out handle)); } - return new Record(handle); + return new Recorder(handle); } /// @@ -65,7 +63,7 @@ public void AddTag(string name, string value) { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectAddTagException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_add_tag(this.handle, name, value)); @@ -81,7 +79,7 @@ public void AddImuTrack() { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectAddImuTrackException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_add_imu_track(this.handle)); @@ -99,7 +97,7 @@ public void AddAttachment(string attachmentName, byte[] buffer) { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectAddAttachmentException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_add_attachment(this.handle, attachmentName, buffer, (UIntPtr)buffer.Length)); @@ -110,23 +108,24 @@ public void AddAttachment(string attachmentName, byte[] buffer) /// Adds custom video tracks to the recording. /// /// The name of the custom video track to be added. - /// A UTF8 null terminated string containing the codec ID of the track. - /// Some of the existing formats are listed here: https://www.matroska.org/technical/specs/codecid/index.html. + /// A UTF8 null terminated string containing the codec ID of the track. + /// Some of the existing formats are listed here: https://www.matroska.org/technical/specs/codecid/index.html. /// The codec ID can also be custom defined by the user. Video codec ID's should start with 'V_'. /// The codec context is a codec-specific buffer that contains any required codec metadata that is only known to the codec. It is mapped to the matroska 'CodecPrivate' element. /// Additional metadata for the video track such as resolution and framerate. /// /// Built-in video tracks like the DEPTH, IR, and COLOR tracks will be created automatically when the k4a_record_create() /// API is called.This API can be used to add additional video tracks to save custom data. - /// + /// /// Track names must be ALL CAPS and may only contain A-Z, 0-9, '-' and '_'. - /// + /// /// All tracks need to be added before the recording header is written. - /// + /// /// Call k4a_record_write_custom_track_data() with the same track_name to write data to this track. - /// + /// /// - public void AddCustomVideoTrack(string trackName, + public void AddCustomVideoTrack( + string trackName, string codecId, byte[] codecContext, RecordVideoSettings trackSettings) @@ -135,7 +134,7 @@ public void AddCustomVideoTrack(string trackName, { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectAddCustomVideoTrackException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_add_custom_video_track( @@ -152,7 +151,7 @@ public void AddCustomVideoTrack(string trackName, /// Adds custom subtitle tracks to the recording. /// /// The name of the custom subtitle track to be added. - /// A UTF8 null terminated string containing the codec ID of the track. + /// A UTF8 null terminated string containing the codec ID of the track. /// Some of the existing formats are listed here: https://www.matroska.org/technical/specs/codecid/index.html. The codec ID can also be custom defined by the user. /// Subtitle codec ID's should start with 'S_'. /// The codec context is a codec-specific buffer that contains any required codec metadata that is only known to the codec.It is mapped to the matroska 'CodecPrivate' element. @@ -160,13 +159,14 @@ public void AddCustomVideoTrack(string trackName, /// /// Built-in subtitle tracks like the IMU track will be created automatically when the k4a_record_add_imu_track() API is /// called.This API can be used to add additional subtitle tracks to save custom data. - /// + /// /// Track names must be ALL CAPS and may only contain A-Z, 0-9, '-' and '_'. - /// + /// /// All tracks need to be added before the recording header is written. - /// + /// /// Call k4a_record_write_custom_track_data() with the same track_name to write data to this track. - public void AddCustomSubtitleTrack(string trackName, + public void AddCustomSubtitleTrack( + string trackName, string codecId, byte[] codecContext, RecordSubtitleSettings trackSettings) @@ -175,7 +175,7 @@ public void AddCustomSubtitleTrack(string trackName, { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectAddCustomSubtitleTrackException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_add_custom_subtitle_track( @@ -200,7 +200,7 @@ public void WriteHeader() { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectWriteHeaderException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_write_header(this.handle)); @@ -213,7 +213,7 @@ public void WriteHeader() /// Capture containing data to write. /// /// Captures must be written in increasing order of timestamp, and the file's header must already be written. - /// + /// /// k4a_record_write_capture() will write all images in the capture to the corresponding tracks in the recording file. /// If any of the images fail to write, other images will still be written before a failure is returned. /// @@ -223,7 +223,7 @@ public void WriteCapture(Capture capture) { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } if (capture == null) @@ -238,20 +238,24 @@ public void WriteCapture(Capture capture) } } + /// + /// Writes an IMU sample to the recording. + /// + /// Sample with the IMU data. public void WriteImuSample(ImuSample imuSample) { lock (this) { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } if (imuSample == null) { throw new ArgumentNullException(nameof(imuSample)); } - + NativeMethods.k4a_imu_sample_t sample = new NativeMethods.k4a_imu_sample_t() { temperature = imuSample.Temperature, @@ -276,7 +280,8 @@ public void WriteImuSample(ImuSample imuSample) /// When writing custom track data at the same time as captures or IMU data, the custom data should be within 1 second of /// the most recently written timestamp. /// - public void WriteCustomTrackData(string trackName, + public void WriteCustomTrackData( + string trackName, TimeSpan deviceTimestamp, byte[] customData) { @@ -284,7 +289,7 @@ public void WriteCustomTrackData(string trackName, { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } if (trackName == null) @@ -297,7 +302,8 @@ public void WriteCustomTrackData(string trackName, throw new ArgumentNullException(nameof(customData)); } - AzureKinectWriteCustomTrackDataException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_write_custom_track_data(this.handle, + AzureKinectWriteCustomTrackDataException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_write_custom_track_data( + this.handle, trackName, checked((ulong)deviceTimestamp.Ticks / 10), customData, @@ -316,7 +322,7 @@ public void Flush() { if (this.disposedValue) { - throw new ObjectDisposedException(nameof(Record)); + throw new ObjectDisposedException(nameof(Recorder)); } AzureKinectFlushException.ThrowIfNotSuccess(() => NativeMethods.k4a_record_flush(this.handle)); diff --git a/src/csharp/SDK/Device.cs b/src/csharp/SDK/Device.cs index 6d77c6c24..d091dc3d9 100644 --- a/src/csharp/SDK/Device.cs +++ b/src/csharp/SDK/Device.cs @@ -166,6 +166,7 @@ public HardwareVersion Version } } } + /// /// Gets the native handle. /// @@ -214,27 +215,6 @@ public static Device Open(int index = 0) return new Device(handle); } - /// - /// Gets the native handle. - /// - /// The native handle that is wrapped by this device. - /// The function is dangerous because there is no guarantee that the - /// handle will not be disposed once it is retrieved. This should only be called - /// by code that can ensure that the Capture object will not be disposed on another - /// thread. - internal NativeMethods.k4a_device_t DangerousGetHandle() - { - lock (this) - { - if (this.disposedValue) - { - throw new ObjectDisposedException(nameof(Device)); - } - - return this.handle; - } - } - /// /// Gets the calibration of the device. /// @@ -320,7 +300,9 @@ public Capture GetCapture(TimeSpan timeout) throw new ObjectDisposedException(nameof(Device)); } +#pragma warning disable CA1508 // Avoid dead conditional code using (LoggingTracer tracer = new LoggingTracer()) +#pragma warning restore CA1508 // Avoid dead conditional code { NativeMethods.k4a_wait_result_t result = NativeMethods.k4a_device_get_capture(this.handle, out NativeMethods.k4a_capture_t capture, (int)timeout.TotalMilliseconds); @@ -374,7 +356,9 @@ public ImuSample GetImuSample(TimeSpan timeout) throw new ObjectDisposedException(nameof(Device)); } +#pragma warning disable CA1508 // Avoid dead conditional code using (LoggingTracer tracer = new LoggingTracer()) +#pragma warning restore CA1508 // Avoid dead conditional code { NativeMethods.k4a_imu_sample_t sample = new NativeMethods.k4a_imu_sample_t(); NativeMethods.k4a_wait_result_t result = NativeMethods.k4a_device_get_imu_sample(this.handle, sample, (int)timeout.TotalMilliseconds); @@ -549,6 +533,27 @@ public void Dispose() GC.SuppressFinalize(this); } + /// + /// Gets the native handle. + /// + /// The native handle that is wrapped by this device. + /// The function is dangerous because there is no guarantee that the + /// handle will not be disposed once it is retrieved. This should only be called + /// by code that can ensure that the Capture object will not be disposed on another + /// thread. + internal NativeMethods.k4a_device_t DangerousGetHandle() + { + lock (this) + { + if (this.disposedValue) + { + throw new ObjectDisposedException(nameof(Device)); + } + + return this.handle; + } + } + /// /// Releases unmanaged and - optionally - managed resources. /// diff --git a/src/csharp/SDK/GlobalSuppressions.cs b/src/csharp/SDK/GlobalSuppressions.cs deleted file mode 100644 index 2f6f2f7b7..000000000 --- a/src/csharp/SDK/GlobalSuppressions.cs +++ /dev/null @@ -1,8 +0,0 @@ - -// This file is used by Code Analysis to maintain SuppressMessage -// attributes that are applied to this project. -// Project-level suppressions either have no target or are given -// a specific target and scoped to a namespace, type, member, etc. - -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Maintainability", "CA1508:Avoid dead conditional code", Justification = "", Scope = "member", Target = "~M:Microsoft.Azure.Kinect.Sensor.Device.GetCapture(System.TimeSpan)~Microsoft.Azure.Kinect.Sensor.Capture")] - diff --git a/src/csharp/SDK/Native/NativeMethods.cs b/src/csharp/SDK/Native/NativeMethods.cs index 1ce4a0bd3..d28acf6c2 100644 --- a/src/csharp/SDK/Native/NativeMethods.cs +++ b/src/csharp/SDK/Native/NativeMethods.cs @@ -372,26 +372,6 @@ public static extern k4a_result_t k4a_set_debug_message_handler( IntPtr message_cb_context, LogLevel min_level); - [DllImport("k4arecord", CallingConvention = k4aCallingConvention, CharSet = CharSet.Ansi)] - [NativeReference] - public static extern k4a_result_t k4a_record_create([MarshalAs(UnmanagedType.LPStr)] string path, k4a_device_t device, k4a_device_configuration_t deviceConfiguration, out k4a_record_t handle); - - [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - [NativeReference] - public static extern void k4a_record_close(IntPtr handle); - - [DllImport("k4arecord", CallingConvention = k4aCallingConvention, CharSet = CharSet.Ansi)] - [NativeReference] - public static extern k4a_result_t k4a_record_add_tag(k4a_record_t handle, string name, string value); - - [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - [NativeReference] - public static extern k4a_result_t k4a_record_write_header(k4a_record_t handle); - - [DllImport("k4arecord", CallingConvention = k4aCallingConvention)] - [NativeReference] - public static extern k4a_result_t k4a_record_write_capture(k4a_record_t handle, k4a_capture_t capture); - [NativeReference] [StructLayout(LayoutKind.Sequential)] public struct k4a_version_t @@ -530,20 +510,6 @@ protected override bool ReleaseHandle() } } - public class k4a_record_t : Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid - { - private k4a_record_t() - : base(true) - { - } - - protected override bool ReleaseHandle() - { - NativeMethods.k4a_record_close(this.handle); - return true; - } - } - [StructLayout(LayoutKind.Sequential)] [Native.NativeReference("k4a_imu_sample_t")] public class k4a_imu_sample_t diff --git a/src/csharp/Tests/Record.UnitTests/LoopbackTests.cs b/src/csharp/Tests/Record.UnitTests/LoopbackTests.cs index 2190ef195..623966815 100644 --- a/src/csharp/Tests/Record.UnitTests/LoopbackTests.cs +++ b/src/csharp/Tests/Record.UnitTests/LoopbackTests.cs @@ -51,7 +51,7 @@ public void LoopbackTest1() }; #pragma warning disable CA1508 // Avoid dead conditional code - using (Record record = Record.Create(this.recordingPath, null, deviceConfiguration)) + using (Recorder record = Recorder.Create(this.recordingPath, null, deviceConfiguration)) #pragma warning restore CA1508 // Avoid dead conditional code { record.AddImuTrack(); @@ -187,7 +187,7 @@ public void LoopbackTest1() using (DataBlock videoBlock = playback.GetNextDataBlock("CUSTOM_VIDEO")) { - Assert.AreEqual(customData, videoBlock.Buffer); + Assert.AreEqual(customData, videoBlock.Memory.ToArray()); Assert.AreEqual(TimeSpan.FromSeconds(timeStamp), videoBlock.DeviceTimestamp); } @@ -198,7 +198,7 @@ public void LoopbackTest1() using (DataBlock subtitleBlock = playback.GetNextDataBlock("CUSTOM_SUBTITLE")) { - Assert.AreEqual(customData, subtitleBlock.Buffer); + Assert.AreEqual(customData, subtitleBlock.Memory.ToArray()); Assert.AreEqual(TimeSpan.FromSeconds(timeStamp), subtitleBlock.DeviceTimestamp); } }