// License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2017 Intel Corporation. All Rights Reserved. namespace Intel.RealSense { using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; public class RecordDevice : Device { internal RecordDevice(IntPtr ptr) : base(ptr) { } internal static IntPtr Create(Device dev, string file) { object error; return NativeMethods.rs2_create_record_device(dev.Handle, file, out error); } /// /// Initializes a new instance of the class. /// /// The to record /// The desired path to which the recorder should save the data public RecordDevice(Device dev, string file) : base(Create(dev, file), NativeMethods.rs2_delete_device) { } /// /// Create a from existing /// /// a device that supports /// a new /// Thrown when does not support public static RecordDevice FromDevice(Device dev) { object error; if (NativeMethods.rs2_is_device_extendable_to(dev.Handle, Extension.Record, out error) == 0) { throw new ArgumentException($"Device does not support {nameof(Extension.Record)}"); } return Device.Create(dev.Handle); } /// /// Pause the recording device without stopping the actual device from streaming. /// Pausing will cause the device to stop writing new data to the file, in particular, frames and changes to extensions /// public void Pause() { object error; NativeMethods.rs2_record_device_pause(Handle, out error); } /// /// Unpause the recording device. Resume will cause the device to continue writing new data to the file, in particular, frames and changes to extensions /// public void Resume() { object error; NativeMethods.rs2_record_device_resume(Handle, out error); } /// /// Gets the name of the file to which the recorder is writing /// public string FileName { get { object error; var p = NativeMethods.rs2_record_device_filename(Handle, out error); return Marshal.PtrToStringAnsi(p); } } } }