Loading Samples/SampleWdpClient/MainWindow.xaml.cs +15 −4 Original line number Diff line number Diff line Loading @@ -376,7 +376,18 @@ namespace SampleWdpClient try { await portal.Reboot(); // await this.portal.StartHolographicSimulationRecording("portaltest"); // System.Threading.Thread.Sleep(10000); bool isRecording = await this.portal.GetHolographicSimulationRecordingStatus(); byte[] data = await this.portal.StopHolographicSimulationRecording(); using (System.IO.FileStream fs = new System.IO.FileStream("portaltest.xef", System.IO.FileMode.Create, System.IO.FileAccess.Write)) { using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(fs)) { writer.Write(data); } } // await this.portal.Reboot(); } catch(Exception ex) { Loading Loading @@ -421,7 +432,7 @@ namespace SampleWdpClient try { await portal.Shutdown(); await this.portal.Shutdown(); } catch(Exception ex) { Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs +21 −13 Original line number Diff line number Diff line Loading @@ -18,20 +18,25 @@ namespace Microsoft.Tools.WindowsDevicePortal public partial class DevicePortal { /// <summary> /// API for getting or deleting a Mixed Reality Capture file /// API for getting or deleting a Mixed Reality Capture file. /// </summary> public static readonly string MrcFileApi = "api/holographic/mrc/file"; /// <summary> /// API for getting the list of Holographic Mixed Reality Capture files /// API for getting the list of Holographic Mixed Reality Capture files. /// </summary> public static readonly string MrcFileListApi = "api/holographic/mrc/files"; /// <summary> /// API for taking a Mixed Reality Capture photo /// API for taking a Mixed Reality Capture photo. /// </summary> public static readonly string MrcPhotoApi = "api/holographic/mrc/photo"; /// <summary> /// API for getting or setting the default Mixed Reality Capture settings. /// </summary> public static readonly string MrcSettingsApi = "api/holographic/mrc/settings"; /// <summary> /// API for starting a Holographic Mixed Reality Capture recording. /// </summary> Loading Loading @@ -76,7 +81,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Removes a Mixed Reality Capture file from the device's local storage. /// </summary> /// <param name="fileName">The name of the file to be deleted.</param> /// <returns>Task tracking the deletion request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task DeleteMrcFile(string fileName) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading @@ -94,7 +99,8 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> /// <param name="fileName">Name of the file to retrieve</param> /// <param name="isThumbnailRequest">Whether or not we just want a thumbnail</param> /// <returns>The raw capture data</returns> /// <returns>Byte array containing the file data.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<byte[]> GetMrcFileData( string fileName, bool isThumbnailRequest = false) Loading Loading @@ -123,6 +129,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets the list of capture files /// </summary> /// <returns>List of the capture files</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<MrcFileList> GetMrcFileList() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading Loading @@ -150,6 +157,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets the status of the reality capture /// </summary> /// <returns>Status of the capture</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<MrcStatus> GetMrcStatus() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading @@ -164,7 +172,8 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets thumbnail data for the capture /// </summary> /// <param name="fileName">Name of the capture file</param> /// <returns>Thumbnail data</returns> /// <returns>Byte array containing the thumbnail image data</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<byte[]> GetMrcThumbnailData(string fileName) { // GetMrcFileData checks for the appropriate platform. We do not need to duplicate the check here. Loading @@ -172,13 +181,13 @@ namespace Microsoft.Tools.WindowsDevicePortal } /// <summary> /// Starts a reality capture recording /// Starts a Mixed Reality Capture recording. /// </summary> /// <param name="includeHolograms">Whether to include holograms</param> /// <param name="includeColorCamera">Whether to include the color camera</param> /// <param name="includeMicrophone">Whether to include microphone data</param> /// <param name="includeAudio">Whether to include audio data</param> /// <returns>Task tracking the start recording request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task StartMrcRecording( bool includeHolograms = true, bool includeColorCamera = true, Loading @@ -203,9 +212,9 @@ namespace Microsoft.Tools.WindowsDevicePortal } /// <summary> /// Stops the capture recording /// Stops the Mixed Reality Capture recording /// </summary> /// <returns>Task tracking the stop request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task StopMrcRecording() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading @@ -217,11 +226,11 @@ namespace Microsoft.Tools.WindowsDevicePortal } /// <summary> /// Take a capture photo /// Take a Mixed Reality Capture photo /// </summary> /// <param name="includeHolograms">Whether to include holograms</param> /// <param name="includeColorCamera">Whether to include the color camera</param> /// <returns>Task tracking the photo request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task TakeMrcPhoto( bool includeHolograms = true, bool includeColorCamera = true) Loading @@ -237,7 +246,6 @@ namespace Microsoft.Tools.WindowsDevicePortal } #region Data contract /// <summary> /// Object representation of the capture file list /// </summary> Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationRecording.cs +121 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,10 @@ // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Threading.Tasks; namespace Microsoft.Tools.WindowsDevicePortal Loading @@ -28,8 +32,125 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> public static readonly string StopHolographicSimulationRecordingApi = "api/holographic/simulation/recording/stop"; /// <summary> /// Gets the holographic simulation recording status. /// </summary> /// <returns>True if recording, false otherwise.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<bool> GetHolographicSimulationRecordingStatus() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } HolographicSimulationRecordingStatus status = await this.Get<HolographicSimulationRecordingStatus>(HolographicSimulationRecordingStatusApi); return status.IsRecording; } /// <summary> /// Starts a Holographic Simulation recording session. /// </summary> /// <param name="name">The name of the recording.</param> /// <param name="recordHead">Should head data be recorded? The default value is true.</param> /// <param name="recordHands">Should hand data be recorded? The default value is true.</param> /// <param name="recordSpatialMapping">Should Spatial Mapping data be recorded? The default value is true.</param> /// <param name="recordEnvironment">Should environment data be recorded? The default value is true.</param> /// <param name="singleSpatialMappingFrame">Should the spatial mapping data be limited to a single frame? The default value is false.</param> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task StartHolographicSimulationRecording( string name, bool recordHead = true, bool recordHands = true, bool recordSpatialMapping = true, bool recordEnvironment = true) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "head={0}&hands={1}&spatialMapping={2}&environment={3}&name={4}", recordHead ? 1 : 0, recordHands ? 1 : 0, recordSpatialMapping ? 1 : 0, recordEnvironment ? 1: 0, name); await this.Post(StartHolographicSimulationRecordingApi, payload); } /// <summary> /// Stops a Holographic Simulation recording session. /// </summary> /// <returns>Byte array containing the recorded data.</returns> /// <exception cref="InvalidOperationException">No recording was in progress.</exception> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<byte[]> StopHolographicSimulationRecording() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } Uri uri = Utilities.BuildEndpoint( this.deviceConnection.Connection, StopHolographicSimulationRecordingApi); byte[] dataBytes = null; using (Stream dataStream = await this.Get(uri)) { if ((dataStream != null) && (dataStream.Length != 0)) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationStopRecordingError)); HolographicSimulationStopRecordingError error = null; try { // Try to get / interpret an error response. error = (HolographicSimulationStopRecordingError)serializer.ReadObject(dataStream); } catch { } if (error != null) { // We received an error response. throw new InvalidOperationException(error.Reason); } // Getting here indicates that we have file data to return. dataBytes = new byte[dataStream.Length]; dataStream.Read(dataBytes, 0, dataBytes.Length); } } return dataBytes; } #region Data contract public class HolographicSimulationStopRecordingError { [DataMember(Name = "Reason")] public string Reason { get; set; } } /// <summary> /// Object representation of Holographic Simulation recording status. /// </summary> [DataContract] public class HolographicSimulationRecordingStatus { /// <summary> /// Gets or sets the recording status. /// </summary> [DataMember(Name = "recording")] public bool IsRecording { get; set; } } #endregion // Data contract } } Loading
Samples/SampleWdpClient/MainWindow.xaml.cs +15 −4 Original line number Diff line number Diff line Loading @@ -376,7 +376,18 @@ namespace SampleWdpClient try { await portal.Reboot(); // await this.portal.StartHolographicSimulationRecording("portaltest"); // System.Threading.Thread.Sleep(10000); bool isRecording = await this.portal.GetHolographicSimulationRecordingStatus(); byte[] data = await this.portal.StopHolographicSimulationRecording(); using (System.IO.FileStream fs = new System.IO.FileStream("portaltest.xef", System.IO.FileMode.Create, System.IO.FileAccess.Write)) { using (System.IO.BinaryWriter writer = new System.IO.BinaryWriter(fs)) { writer.Write(data); } } // await this.portal.Reboot(); } catch(Exception ex) { Loading Loading @@ -421,7 +432,7 @@ namespace SampleWdpClient try { await portal.Shutdown(); await this.portal.Shutdown(); } catch(Exception ex) { Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs +21 −13 Original line number Diff line number Diff line Loading @@ -18,20 +18,25 @@ namespace Microsoft.Tools.WindowsDevicePortal public partial class DevicePortal { /// <summary> /// API for getting or deleting a Mixed Reality Capture file /// API for getting or deleting a Mixed Reality Capture file. /// </summary> public static readonly string MrcFileApi = "api/holographic/mrc/file"; /// <summary> /// API for getting the list of Holographic Mixed Reality Capture files /// API for getting the list of Holographic Mixed Reality Capture files. /// </summary> public static readonly string MrcFileListApi = "api/holographic/mrc/files"; /// <summary> /// API for taking a Mixed Reality Capture photo /// API for taking a Mixed Reality Capture photo. /// </summary> public static readonly string MrcPhotoApi = "api/holographic/mrc/photo"; /// <summary> /// API for getting or setting the default Mixed Reality Capture settings. /// </summary> public static readonly string MrcSettingsApi = "api/holographic/mrc/settings"; /// <summary> /// API for starting a Holographic Mixed Reality Capture recording. /// </summary> Loading Loading @@ -76,7 +81,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Removes a Mixed Reality Capture file from the device's local storage. /// </summary> /// <param name="fileName">The name of the file to be deleted.</param> /// <returns>Task tracking the deletion request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task DeleteMrcFile(string fileName) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading @@ -94,7 +99,8 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> /// <param name="fileName">Name of the file to retrieve</param> /// <param name="isThumbnailRequest">Whether or not we just want a thumbnail</param> /// <returns>The raw capture data</returns> /// <returns>Byte array containing the file data.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<byte[]> GetMrcFileData( string fileName, bool isThumbnailRequest = false) Loading Loading @@ -123,6 +129,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets the list of capture files /// </summary> /// <returns>List of the capture files</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<MrcFileList> GetMrcFileList() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading Loading @@ -150,6 +157,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets the status of the reality capture /// </summary> /// <returns>Status of the capture</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<MrcStatus> GetMrcStatus() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading @@ -164,7 +172,8 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets thumbnail data for the capture /// </summary> /// <param name="fileName">Name of the capture file</param> /// <returns>Thumbnail data</returns> /// <returns>Byte array containing the thumbnail image data</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<byte[]> GetMrcThumbnailData(string fileName) { // GetMrcFileData checks for the appropriate platform. We do not need to duplicate the check here. Loading @@ -172,13 +181,13 @@ namespace Microsoft.Tools.WindowsDevicePortal } /// <summary> /// Starts a reality capture recording /// Starts a Mixed Reality Capture recording. /// </summary> /// <param name="includeHolograms">Whether to include holograms</param> /// <param name="includeColorCamera">Whether to include the color camera</param> /// <param name="includeMicrophone">Whether to include microphone data</param> /// <param name="includeAudio">Whether to include audio data</param> /// <returns>Task tracking the start recording request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task StartMrcRecording( bool includeHolograms = true, bool includeColorCamera = true, Loading @@ -203,9 +212,9 @@ namespace Microsoft.Tools.WindowsDevicePortal } /// <summary> /// Stops the capture recording /// Stops the Mixed Reality Capture recording /// </summary> /// <returns>Task tracking the stop request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task StopMrcRecording() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) Loading @@ -217,11 +226,11 @@ namespace Microsoft.Tools.WindowsDevicePortal } /// <summary> /// Take a capture photo /// Take a Mixed Reality Capture photo /// </summary> /// <param name="includeHolograms">Whether to include holograms</param> /// <param name="includeColorCamera">Whether to include the color camera</param> /// <returns>Task tracking the photo request</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task TakeMrcPhoto( bool includeHolograms = true, bool includeColorCamera = true) Loading @@ -237,7 +246,6 @@ namespace Microsoft.Tools.WindowsDevicePortal } #region Data contract /// <summary> /// Object representation of the capture file list /// </summary> Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationRecording.cs +121 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,10 @@ // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Threading.Tasks; namespace Microsoft.Tools.WindowsDevicePortal Loading @@ -28,8 +32,125 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </summary> public static readonly string StopHolographicSimulationRecordingApi = "api/holographic/simulation/recording/stop"; /// <summary> /// Gets the holographic simulation recording status. /// </summary> /// <returns>True if recording, false otherwise.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<bool> GetHolographicSimulationRecordingStatus() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } HolographicSimulationRecordingStatus status = await this.Get<HolographicSimulationRecordingStatus>(HolographicSimulationRecordingStatusApi); return status.IsRecording; } /// <summary> /// Starts a Holographic Simulation recording session. /// </summary> /// <param name="name">The name of the recording.</param> /// <param name="recordHead">Should head data be recorded? The default value is true.</param> /// <param name="recordHands">Should hand data be recorded? The default value is true.</param> /// <param name="recordSpatialMapping">Should Spatial Mapping data be recorded? The default value is true.</param> /// <param name="recordEnvironment">Should environment data be recorded? The default value is true.</param> /// <param name="singleSpatialMappingFrame">Should the spatial mapping data be limited to a single frame? The default value is false.</param> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task StartHolographicSimulationRecording( string name, bool recordHead = true, bool recordHands = true, bool recordSpatialMapping = true, bool recordEnvironment = true) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "head={0}&hands={1}&spatialMapping={2}&environment={3}&name={4}", recordHead ? 1 : 0, recordHands ? 1 : 0, recordSpatialMapping ? 1 : 0, recordEnvironment ? 1: 0, name); await this.Post(StartHolographicSimulationRecordingApi, payload); } /// <summary> /// Stops a Holographic Simulation recording session. /// </summary> /// <returns>Byte array containing the recorded data.</returns> /// <exception cref="InvalidOperationException">No recording was in progress.</exception> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<byte[]> StopHolographicSimulationRecording() { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } Uri uri = Utilities.BuildEndpoint( this.deviceConnection.Connection, StopHolographicSimulationRecordingApi); byte[] dataBytes = null; using (Stream dataStream = await this.Get(uri)) { if ((dataStream != null) && (dataStream.Length != 0)) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationStopRecordingError)); HolographicSimulationStopRecordingError error = null; try { // Try to get / interpret an error response. error = (HolographicSimulationStopRecordingError)serializer.ReadObject(dataStream); } catch { } if (error != null) { // We received an error response. throw new InvalidOperationException(error.Reason); } // Getting here indicates that we have file data to return. dataBytes = new byte[dataStream.Length]; dataStream.Read(dataBytes, 0, dataBytes.Length); } } return dataBytes; } #region Data contract public class HolographicSimulationStopRecordingError { [DataMember(Name = "Reason")] public string Reason { get; set; } } /// <summary> /// Object representation of Holographic Simulation recording status. /// </summary> [DataContract] public class HolographicSimulationRecordingStatus { /// <summary> /// Gets or sets the recording status. /// </summary> [DataMember(Name = "recording")] public bool IsRecording { get; set; } } #endregion // Data contract } }