Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent-A committed Oct 9, 2019
1 parent 09a6cf3 commit 2b49c26
Show file tree
Hide file tree
Showing 38 changed files with 584 additions and 382 deletions.
11 changes: 5 additions & 6 deletions src/csharp/Examples/Recording/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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})");
}
}
Expand Down
32 changes: 24 additions & 8 deletions src/csharp/Record/DataBlock.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using System;
using System.Collections.Generic;
using System.Globalization;
//------------------------------------------------------------------------------
// <copyright file="DataBlock.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Buffers;
using System.Runtime.InteropServices;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record
{
public class DataBlock : IDisposable
/// <summary>
/// Represents a block of data from a custom recording track.
/// </summary>
public class DataBlock : IDisposable, IMemoryOwner<byte>
{
// The native handle for this data block.
private readonly NativeMethods.k4a_playback_data_block_t handle;
Expand All @@ -16,12 +23,19 @@ public class DataBlock : IDisposable

private byte[] buffer = null;

/// <summary>
/// Initializes a new instance of the <see cref="DataBlock"/> class.
/// </summary>
/// <param name="handle">Native handle to the data block.</param>
internal DataBlock(NativeMethods.k4a_playback_data_block_t handle)
{
this.handle = handle;
}

public byte[] Buffer
/// <summary>
/// Gets the memory with the custom data.
/// </summary>
public Memory<byte> Memory
{
get
{
Expand All @@ -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)
Expand All @@ -55,6 +69,9 @@ public byte[] Buffer
}
}

/// <summary>
/// Gets the device timestamp associated with the data.
/// </summary>
public TimeSpan DeviceTimestamp
{
get
Expand All @@ -73,7 +90,6 @@ public TimeSpan DeviceTimestamp
}
}


/// <inheritdoc/>
public void Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectAddAttachmentException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when adding an attachment to a recording
/// Represents errors that occur when adding an attachment to a recording.
/// </summary>
[Serializable]
public class AzureKinectAddAttachmentException : AzureKinectRecordException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectAddCustomSubtitleTrackException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when adding a custom subtitle track
/// Represents errors that occur when adding a custom subtitle track.
/// </summary>
[Serializable]
public class AzureKinectAddCustomSubtitleTrackException : AzureKinectRecordException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectAddCustomVideoTrackException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when adding a custom video track
/// Represents errors that occur when adding a custom video track.
/// </summary>
[Serializable]
public class AzureKinectAddCustomVideoTrackException : AzureKinectRecordException
Expand Down
10 changes: 7 additions & 3 deletions src/csharp/Record/Exceptions/AzureKinectAddImuTrackException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectAddImuTrackException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when adding an IMU track to a recording.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/csharp/Record/Exceptions/AzureKinectAddTagException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{
/// <summary>
/// Represents errors that occur when adding a tag to a recording
/// Represents errors that occur when adding a tag to a recording.
/// </summary>
[Serializable]
public class AzureKinectAddTagException : AzureKinectRecordException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -84,13 +83,12 @@ protected AzureKinectCreateRecordingException(string message, ICollection<LogMes
/// Throws an <see cref="AzureKinectCreateRecordingException"/> if the result of the function
/// is not a success.
/// </summary>
/// <param name="fileName">File name of the create</param>
/// <param name="fileName">File name of the create.</param>
/// <param name="function">The native function to call.</param>
/// <typeparam name="T">The type of result to expect from the function call.</typeparam>
internal static void ThrowIfNotSuccess<T>(string fileName, Func<T> function)
where T : System.Enum
{

using (LoggingTracer tracer = new LoggingTracer(LogLevel.Warning, Logger.LogProvider, RecordLogger.LogProvider))
{
T result = function();
Expand All @@ -105,7 +103,7 @@ internal static void ThrowIfNotSuccess<T>(string fileName, Func<T> function)
/// Throws an <see cref="AzureKinectCreateRecordingException"/> if the result of the function
/// is not a success.
/// </summary>
/// <param name="fileName">File name of the create</param>
/// <param name="fileName">File name of the create.</param>
/// <param name="tracer">The tracer is that is capturing logging messages.</param>
/// <param name="result">The result native function to call.</param>
/// <typeparam name="T">The type of result to expect from the function call.</typeparam>
Expand Down
12 changes: 8 additions & 4 deletions src/csharp/Record/Exceptions/AzureKinectFlushException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectFlushException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when an error occurs during flushing
/// Represents errors that occur when an error occurs during flushing.
/// </summary>
[Serializable]
public class AzureKinectFlushException : AzureKinectRecordException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetCalibrationException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when getting calibration from a recording.
/// </summary>
Expand Down
10 changes: 7 additions & 3 deletions src/csharp/Record/Exceptions/AzureKinectGetCaptureException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetCaptureException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when getting the next or previous capture.
/// </summary>
Expand Down
10 changes: 7 additions & 3 deletions src/csharp/Record/Exceptions/AzureKinectGetDataBlockException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetDataBlockException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when getting a data block.
/// </summary>
Expand Down
10 changes: 7 additions & 3 deletions src/csharp/Record/Exceptions/AzureKinectGetImuSampleException.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetImuSampleException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when reading an IMU sample.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetRawCalibrationException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when getting raw calibration from a recording.
/// </summary>
Expand Down
12 changes: 8 additions & 4 deletions src/csharp/Record/Exceptions/AzureKinectGetTagException.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetTagException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when getting a tag value
/// Represents errors that occur when getting a tag value.
/// </summary>
[Serializable]
public class AzureKinectGetTagException : AzureKinectRecordException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System;
//------------------------------------------------------------------------------
// <copyright file="AzureKinectGetTrackCodecContextException.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;

namespace Microsoft.Azure.Kinect.Sensor.Record.Exceptions
{

/// <summary>
/// Represents errors that occur when getting a codec context from a track
/// Represents errors that occur when getting a codec context from a track.
/// </summary>
[Serializable]
public class AzureKinectGetTrackCodecContextException : AzureKinectRecordException
Expand Down
Loading

0 comments on commit 2b49c26

Please sign in to comment.