Skip to content

Commit e815f6a

Browse files
author
David Kline
authored
Merge pull request #184 from davidkline-ms/master
merging per approval fix for issue 181 and updating the connection
2 parents 7f707bc + 9b418ee commit e815f6a

File tree

8 files changed

+186
-32
lines changed

8 files changed

+186
-32
lines changed

Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private void ConnectToDevice_Click(object sender, RoutedEventArgs e)
113113
// remainder of this session.
114114
if (allowUntrusted)
115115
{
116-
await portal.GetRootDeviceCertificate(true);
116+
this.certificate = await portal.GetRootDeviceCertificate(true);
117117
}
118118
await portal.Connect(manualCertificate: this.certificate);
119119
}

WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockDevicePortalConnection.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ public void UpdateConnection(bool requiresHttps)
8787
/// <summary>
8888
/// The Mock will never update the connection.
8989
/// </summary>
90-
/// <param name="ipConfig">IP info</param>
91-
/// <param name="requiresHttps">https required</param>
92-
public void UpdateConnection(IpConfiguration ipConfig, bool requiresHttps)
90+
/// <param name="ipConfig">Object that describes the current network configuration.</param>
91+
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
92+
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
93+
public void UpdateConnection(
94+
IpConfiguration ipConfig,
95+
bool requiresHttps,
96+
bool preservePort)
9397
{
9498
throw new NotImplementedException();
9599
}

WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/DevicePortal.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,21 @@ public async Task Connect(
256256
DeviceConnectionStatus.Connecting,
257257
DeviceConnectionPhase.UpdatingDeviceAddress,
258258
connectionPhaseDescription);
259-
this.deviceConnection.UpdateConnection(await this.GetIpConfig(), requiresHttps);
259+
260+
bool preservePort = true;
261+
// HoloLens and Mobile are the only devices that support USB.
262+
// They require the port to be changed when the connection is updated
263+
// to WiFi.
264+
if ((this.Platform == DevicePortalPlatforms.HoloLens) ||
265+
(this.Platform == DevicePortalPlatforms.Mobile))
266+
{
267+
preservePort = false;
268+
}
269+
270+
this.deviceConnection.UpdateConnection(
271+
await this.GetIpConfig(),
272+
requiresHttps,
273+
preservePort);
260274
}
261275

262276
this.SendConnectionStatus(

WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs

Lines changed: 129 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public partial class DevicePortal
6060
/// <summary>
6161
/// API for getting a high resolution live Holographic Mixed Reality Capture stream.
6262
/// </summary>
63-
public static readonly string MrcLiveStreamHighwResApi = "api/holographic/stream/live_high.mp4";
63+
public static readonly string MrcLiveStreamHighResApi = "api/holographic/stream/live_high.mp4";
6464

6565
/// <summary>
6666
/// API for getting a low resolution live Holographic Mixed Reality Capture stream.
@@ -81,8 +81,8 @@ public partial class DevicePortal
8181
/// Removes a Mixed Reality Capture file from the device's local storage.
8282
/// </summary>
8383
/// <param name="fileName">The name of the file to be deleted.</param>
84-
/// <remarks>This method is only supported on HoloLens devices.</remarks>
8584
/// <returns>Task tracking completion of the REST call.</returns>
85+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
8686
public async Task DeleteMrcFile(string fileName)
8787
{
8888
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
@@ -95,11 +95,95 @@ await this.Delete(
9595
string.Format("filename={0}", Utilities.Hex64Encode(fileName)));
9696
}
9797

98+
/// <summary>
99+
/// Retrieve the Uri for the high resolution Mixed Reality Capture live stream.
100+
/// </summary>
101+
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
102+
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
103+
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
104+
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
105+
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
106+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
107+
public Uri GetHighResolutionMrcLiveStreamUri(
108+
bool includeHolograms = true,
109+
bool includeColorCamera = true,
110+
bool includeMicrophone = true,
111+
bool includeAudio = true)
112+
{
113+
string payload = string.Format(
114+
"holo={0}&pv={1}&mic={2}&loopback={3}",
115+
includeHolograms,
116+
includeColorCamera,
117+
includeMicrophone,
118+
includeAudio).ToLower();
119+
120+
return Utilities.BuildEndpoint(
121+
this.deviceConnection.Connection,
122+
MrcLiveStreamHighResApi,
123+
payload);
124+
}
125+
126+
/// <summary>
127+
/// Retrieve the Uri for the low resolution Mixed Reality Capture live stream.
128+
/// </summary>
129+
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
130+
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
131+
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
132+
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
133+
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
134+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
135+
public Uri GetLowResolutionMrcLiveStreamUri(
136+
bool includeHolograms = true,
137+
bool includeColorCamera = true,
138+
bool includeMicrophone = true,
139+
bool includeAudio = true)
140+
{
141+
string payload = string.Format(
142+
"holo={0}&pv={1}&mic={2}&loopback={3}",
143+
includeHolograms,
144+
includeColorCamera,
145+
includeMicrophone,
146+
includeAudio).ToLower();
147+
148+
return Utilities.BuildEndpoint(
149+
this.deviceConnection.Connection,
150+
MrcLiveStreamLowResApi,
151+
payload);
152+
}
153+
154+
/// <summary>
155+
/// Retrieve the Uri for the medium resolution Mixed Reality Capture live stream.
156+
/// </summary>
157+
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
158+
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
159+
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
160+
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
161+
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
162+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
163+
public Uri GetMediumResolutionMrcLiveStreamUri(
164+
bool includeHolograms = true,
165+
bool includeColorCamera = true,
166+
bool includeMicrophone = true,
167+
bool includeAudio = true)
168+
{
169+
string payload = string.Format(
170+
"holo={0}&pv={1}&mic={2}&loopback={3}",
171+
includeHolograms,
172+
includeColorCamera,
173+
includeMicrophone,
174+
includeAudio).ToLower();
175+
176+
return Utilities.BuildEndpoint(
177+
this.deviceConnection.Connection,
178+
MrcLiveStreamMediumResApi,
179+
payload);
180+
}
181+
98182
/// <summary>
99183
/// Gets the capture file data
100184
/// </summary>
101-
/// <param name="fileName">Name of the file to retrieve</param>
102-
/// <param name="isThumbnailRequest">Whether or not we just want a thumbnail</param>
185+
/// <param name="fileName">Name of the file to retrieve.</param>
186+
/// <param name="isThumbnailRequest">Specifies whether or not we are requesting a thumbnail image.</param>
103187
/// <returns>Byte array containing the file data.</returns>
104188
/// <remarks>This method is only supported on HoloLens devices.</remarks>
105189
public async Task<byte[]> GetMrcFileData(
@@ -154,6 +238,36 @@ public async Task<MrcFileList> GetMrcFileList()
154238
return mrcFileList;
155239
}
156240

241+
/// <summary>
242+
/// Retrieve the Uri for the Mixed Reality Capture live stream using the default resolution.
243+
/// </summary>
244+
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
245+
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
246+
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
247+
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
248+
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
249+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
250+
public Uri GetMrcLiveStreamUri(
251+
bool includeHolograms = true,
252+
bool includeColorCamera = true,
253+
bool includeMicrophone = true,
254+
bool includeAudio = true)
255+
{
256+
string payload = string.Format(
257+
"holo={0}&pv={1}&mic={2}&loopback={3}",
258+
includeHolograms,
259+
includeColorCamera,
260+
includeMicrophone,
261+
includeAudio).ToLower();
262+
263+
return Utilities.BuildEndpoint(
264+
this.deviceConnection.Connection,
265+
MrcLiveStreamApi,
266+
payload);
267+
}
268+
269+
// TODO: GetMrcSettings()
270+
157271
/// <summary>
158272
/// Gets the status of the reality capture
159273
/// </summary>
@@ -181,15 +295,17 @@ public async Task<byte[]> GetMrcThumbnailData(string fileName)
181295
return await this.GetMrcFileData(fileName, true);
182296
}
183297

298+
// TODO: SetMrcSettings()
299+
184300
/// <summary>
185301
/// Starts a Mixed Reality Capture recording.
186302
/// </summary>
187-
/// <param name="includeHolograms">Whether to include holograms</param>
188-
/// <param name="includeColorCamera">Whether to include the color camera</param>
189-
/// <param name="includeMicrophone">Whether to include microphone data</param>
190-
/// <param name="includeAudio">Whether to include audio data</param>
191-
/// <remarks>This method is only supported on HoloLens devices.</remarks>
303+
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
304+
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
305+
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
306+
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
192307
/// <returns>Task tracking completion of the REST call.</returns>
308+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
193309
public async Task StartMrcRecording(
194310
bool includeHolograms = true,
195311
bool includeColorCamera = true,
@@ -216,8 +332,8 @@ await this.Post(
216332
/// <summary>
217333
/// Stops the Mixed Reality Capture recording
218334
/// </summary>
219-
/// <remarks>This method is only supported on HoloLens devices.</remarks>
220335
/// <returns>Task tracking completion of the REST call.</returns>
336+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
221337
public async Task StopMrcRecording()
222338
{
223339
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
@@ -231,10 +347,10 @@ public async Task StopMrcRecording()
231347
/// <summary>
232348
/// Take a Mixed Reality Capture photo
233349
/// </summary>
234-
/// <param name="includeHolograms">Whether to include holograms</param>
235-
/// <param name="includeColorCamera">Whether to include the color camera</param>
236-
/// <remarks>This method is only supported on HoloLens devices.</remarks>
350+
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
351+
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
237352
/// <returns>Task tracking completion of the REST call.</returns>
353+
/// <remarks>This method is only supported on HoloLens devices.</remarks>
238354
public async Task TakeMrcPhoto(
239355
bool includeHolograms = true,
240356
bool includeColorCamera = true)

WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Interfaces/IDevicePortalConnection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ public interface IDevicePortalConnection
5555
/// </summary>
5656
/// <param name="ipConfig">Object that describes the current network configuration.</param>
5757
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
58+
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
5859
void UpdateConnection(
5960
IpConfiguration ipConfig,
60-
bool requiresHttps);
61+
bool requiresHttps,
62+
bool preservePort);
6163
}
6264
}

WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DefaultDevicePortalConnection.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ public Uri WebSocketConnection
5656
// Convert the scheme from http[s] to ws[s].
5757
string scheme = this.Connection.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase) ? "wss" : "ws";
5858

59-
return new Uri(
60-
string.Format("{0}://{1}",
61-
scheme,
62-
this.Connection.Authority));
59+
return new Uri(string.Format("{0}://{1}", scheme, this.Connection.Authority));
6360
}
6461
}
6562

@@ -106,11 +103,13 @@ public void UpdateConnection(bool requiresHttps)
106103
/// <summary>
107104
/// Updates the device's connection Uri.
108105
/// </summary>
109-
/// <param name="ipConfig">The device's IP configuration data.</param>
110-
/// <param name="requiresHttps">Indicates whether or not to always require a secure connection.</param>
106+
/// <param name="ipConfig">Object that describes the current network configuration.</param>
107+
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
108+
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
111109
public void UpdateConnection(
112110
IpConfiguration ipConfig,
113-
bool requiresHttps = false)
111+
bool requiresHttps,
112+
bool preservePort)
114113
{
115114
Uri newConnection = null;
116115

@@ -121,11 +120,20 @@ public void UpdateConnection(
121120
// We take the first, non-169.x.x.x address we find that is not 0.0.0.0.
122121
if ((addressInfo.Address != "0.0.0.0") && !addressInfo.Address.StartsWith("169."))
123122
{
123+
string address = addressInfo.Address;
124+
if (preservePort)
125+
{
126+
address = string.Format(
127+
"{0}:{1}",
128+
address,
129+
this.Connection.Port);
130+
}
131+
124132
newConnection = new Uri(
125133
string.Format(
126134
"{0}://{1}",
127135
requiresHttps ? "https" : "http",
128-
this.Connection.Authority));
136+
address));
129137
break;
130138
}
131139
}

WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
3+
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
44
},
55
"frameworks": {
66
"uap10.0": {}

WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/DefaultDevicePortalConnection.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,13 @@ public void UpdateConnection(bool requiresHttps)
136136
/// <summary>
137137
/// Updates the device's connection Uri.
138138
/// </summary>
139-
/// <param name="ipConfig">The device's IP configuration data.</param>
140-
/// <param name="requiresHttps">Indicates whether or not to always require a secure connection.</param>
139+
/// <param name="ipConfig">Object that describes the current network configuration.</param>
140+
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
141+
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
141142
public void UpdateConnection(
142143
IpConfiguration ipConfig,
143-
bool requiresHttps = false)
144+
bool requiresHttps,
145+
bool preservePort)
144146
{
145147
Uri newConnection = null;
146148

@@ -151,11 +153,19 @@ public void UpdateConnection(
151153
// We take the first, non-169.x.x.x address we find that is not 0.0.0.0.
152154
if ((addressInfo.Address != "0.0.0.0") && !addressInfo.Address.StartsWith("169."))
153155
{
156+
string address = addressInfo.Address;
157+
if (preservePort)
158+
{
159+
address = string.Format("{0}:{1}",
160+
address,
161+
this.Connection.Port);
162+
}
163+
154164
newConnection = new Uri(
155165
string.Format(
156166
"{0}://{1}",
157167
requiresHttps ? "https" : "http",
158-
this.Connection.Authority));
168+
address));
159169
break;
160170
}
161171
}

0 commit comments

Comments
 (0)