Skip to content

Commit

Permalink
Merge pull request #184 from davidkline-ms/master
Browse files Browse the repository at this point in the history
merging per approval

fix for issue 181 and updating the connection
  • Loading branch information
David Kline authored Oct 3, 2016
2 parents 7f707bc + 9b418ee commit e815f6a
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private void ConnectToDevice_Click(object sender, RoutedEventArgs e)
// remainder of this session.
if (allowUntrusted)
{
await portal.GetRootDeviceCertificate(true);
this.certificate = await portal.GetRootDeviceCertificate(true);
}
await portal.Connect(manualCertificate: this.certificate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@ public void UpdateConnection(bool requiresHttps)
/// <summary>
/// The Mock will never update the connection.
/// </summary>
/// <param name="ipConfig">IP info</param>
/// <param name="requiresHttps">https required</param>
public void UpdateConnection(IpConfiguration ipConfig, bool requiresHttps)
/// <param name="ipConfig">Object that describes the current network configuration.</param>
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
public void UpdateConnection(
IpConfiguration ipConfig,
bool requiresHttps,
bool preservePort)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,21 @@ public async Task Connect(
DeviceConnectionStatus.Connecting,
DeviceConnectionPhase.UpdatingDeviceAddress,
connectionPhaseDescription);
this.deviceConnection.UpdateConnection(await this.GetIpConfig(), requiresHttps);

bool preservePort = true;
// HoloLens and Mobile are the only devices that support USB.
// They require the port to be changed when the connection is updated
// to WiFi.
if ((this.Platform == DevicePortalPlatforms.HoloLens) ||
(this.Platform == DevicePortalPlatforms.Mobile))
{
preservePort = false;
}

this.deviceConnection.UpdateConnection(
await this.GetIpConfig(),
requiresHttps,
preservePort);
}

this.SendConnectionStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public partial class DevicePortal
/// <summary>
/// API for getting a high resolution live Holographic Mixed Reality Capture stream.
/// </summary>
public static readonly string MrcLiveStreamHighwResApi = "api/holographic/stream/live_high.mp4";
public static readonly string MrcLiveStreamHighResApi = "api/holographic/stream/live_high.mp4";

/// <summary>
/// API for getting a low resolution live Holographic Mixed Reality Capture stream.
Expand All @@ -81,8 +81,8 @@ public partial class DevicePortal
/// 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>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <returns>Task tracking completion of the REST call.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public async Task DeleteMrcFile(string fileName)
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -95,11 +95,95 @@ await this.Delete(
string.Format("filename={0}", Utilities.Hex64Encode(fileName)));
}

/// <summary>
/// Retrieve the Uri for the high resolution Mixed Reality Capture live stream.
/// </summary>
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public Uri GetHighResolutionMrcLiveStreamUri(
bool includeHolograms = true,
bool includeColorCamera = true,
bool includeMicrophone = true,
bool includeAudio = true)
{
string payload = string.Format(
"holo={0}&pv={1}&mic={2}&loopback={3}",
includeHolograms,
includeColorCamera,
includeMicrophone,
includeAudio).ToLower();

return Utilities.BuildEndpoint(
this.deviceConnection.Connection,
MrcLiveStreamHighResApi,
payload);
}

/// <summary>
/// Retrieve the Uri for the low resolution Mixed Reality Capture live stream.
/// </summary>
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public Uri GetLowResolutionMrcLiveStreamUri(
bool includeHolograms = true,
bool includeColorCamera = true,
bool includeMicrophone = true,
bool includeAudio = true)
{
string payload = string.Format(
"holo={0}&pv={1}&mic={2}&loopback={3}",
includeHolograms,
includeColorCamera,
includeMicrophone,
includeAudio).ToLower();

return Utilities.BuildEndpoint(
this.deviceConnection.Connection,
MrcLiveStreamLowResApi,
payload);
}

/// <summary>
/// Retrieve the Uri for the medium resolution Mixed Reality Capture live stream.
/// </summary>
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public Uri GetMediumResolutionMrcLiveStreamUri(
bool includeHolograms = true,
bool includeColorCamera = true,
bool includeMicrophone = true,
bool includeAudio = true)
{
string payload = string.Format(
"holo={0}&pv={1}&mic={2}&loopback={3}",
includeHolograms,
includeColorCamera,
includeMicrophone,
includeAudio).ToLower();

return Utilities.BuildEndpoint(
this.deviceConnection.Connection,
MrcLiveStreamMediumResApi,
payload);
}

/// <summary>
/// Gets the capture file data
/// </summary>
/// <param name="fileName">Name of the file to retrieve</param>
/// <param name="isThumbnailRequest">Whether or not we just want a thumbnail</param>
/// <param name="fileName">Name of the file to retrieve.</param>
/// <param name="isThumbnailRequest">Specifies whether or not we are requesting a thumbnail image.</param>
/// <returns>Byte array containing the file data.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public async Task<byte[]> GetMrcFileData(
Expand Down Expand Up @@ -154,6 +238,36 @@ public async Task<MrcFileList> GetMrcFileList()
return mrcFileList;
}

/// <summary>
/// Retrieve the Uri for the Mixed Reality Capture live stream using the default resolution.
/// </summary>
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
/// <returns>Uri used to retreive the Mixed Reality Capture stream.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public Uri GetMrcLiveStreamUri(
bool includeHolograms = true,
bool includeColorCamera = true,
bool includeMicrophone = true,
bool includeAudio = true)
{
string payload = string.Format(
"holo={0}&pv={1}&mic={2}&loopback={3}",
includeHolograms,
includeColorCamera,
includeMicrophone,
includeAudio).ToLower();

return Utilities.BuildEndpoint(
this.deviceConnection.Connection,
MrcLiveStreamApi,
payload);
}

// TODO: GetMrcSettings()

/// <summary>
/// Gets the status of the reality capture
/// </summary>
Expand Down Expand Up @@ -181,15 +295,17 @@ public async Task<byte[]> GetMrcThumbnailData(string fileName)
return await this.GetMrcFileData(fileName, true);
}

// TODO: SetMrcSettings()

/// <summary>
/// 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>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
/// <param name="includeMicrophone">Specifies whether or not to include microphone data</param>
/// <param name="includeAudio">Specifies whether or not to include audio data</param>
/// <returns>Task tracking completion of the REST call.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public async Task StartMrcRecording(
bool includeHolograms = true,
bool includeColorCamera = true,
Expand All @@ -216,8 +332,8 @@ await this.Post(
/// <summary>
/// Stops the Mixed Reality Capture recording
/// </summary>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <returns>Task tracking completion of the REST call.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public async Task StopMrcRecording()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -231,10 +347,10 @@ public async Task StopMrcRecording()
/// <summary>
/// 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>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <param name="includeHolograms">Specifies whether or not to include holograms</param>
/// <param name="includeColorCamera">Specifies whether or not to include the color camera</param>
/// <returns>Task tracking completion of the REST call.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
public async Task TakeMrcPhoto(
bool includeHolograms = true,
bool includeColorCamera = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ public interface IDevicePortalConnection
/// </summary>
/// <param name="ipConfig">Object that describes the current network configuration.</param>
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
void UpdateConnection(
IpConfiguration ipConfig,
bool requiresHttps);
bool requiresHttps,
bool preservePort);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public Uri WebSocketConnection
// Convert the scheme from http[s] to ws[s].
string scheme = this.Connection.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase) ? "wss" : "ws";

return new Uri(
string.Format("{0}://{1}",
scheme,
this.Connection.Authority));
return new Uri(string.Format("{0}://{1}", scheme, this.Connection.Authority));
}
}

Expand Down Expand Up @@ -106,11 +103,13 @@ public void UpdateConnection(bool requiresHttps)
/// <summary>
/// Updates the device's connection Uri.
/// </summary>
/// <param name="ipConfig">The device's IP configuration data.</param>
/// <param name="requiresHttps">Indicates whether or not to always require a secure connection.</param>
/// <param name="ipConfig">Object that describes the current network configuration.</param>
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
public void UpdateConnection(
IpConfiguration ipConfig,
bool requiresHttps = false)
bool requiresHttps,
bool preservePort)
{
Uri newConnection = null;

Expand All @@ -121,11 +120,20 @@ public void UpdateConnection(
// We take the first, non-169.x.x.x address we find that is not 0.0.0.0.
if ((addressInfo.Address != "0.0.0.0") && !addressInfo.Address.StartsWith("169."))
{
string address = addressInfo.Address;
if (preservePort)
{
address = string.Format(
"{0}:{1}",
address,
this.Connection.Port);
}

newConnection = new Uri(
string.Format(
"{0}://{1}",
requiresHttps ? "https" : "http",
this.Connection.Authority));
address));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
},
"frameworks": {
"uap10.0": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ public void UpdateConnection(bool requiresHttps)
/// <summary>
/// Updates the device's connection Uri.
/// </summary>
/// <param name="ipConfig">The device's IP configuration data.</param>
/// <param name="requiresHttps">Indicates whether or not to always require a secure connection.</param>
/// <param name="ipConfig">Object that describes the current network configuration.</param>
/// <param name="requiresHttps">True if an https connection is required, false otherwise.</param>
/// <param name="preservePort">True if the previous connection's port is to continue to be used, false otherwise.</param>
public void UpdateConnection(
IpConfiguration ipConfig,
bool requiresHttps = false)
bool requiresHttps,
bool preservePort)
{
Uri newConnection = null;

Expand All @@ -151,11 +153,19 @@ public void UpdateConnection(
// We take the first, non-169.x.x.x address we find that is not 0.0.0.0.
if ((addressInfo.Address != "0.0.0.0") && !addressInfo.Address.StartsWith("169."))
{
string address = addressInfo.Address;
if (preservePort)
{
address = string.Format("{0}:{1}",
address,
this.Connection.Port);
}

newConnection = new Uri(
string.Format(
"{0}://{1}",
requiresHttps ? "https" : "http",
this.Connection.Authority));
address));
break;
}
}
Expand Down

0 comments on commit e815f6a

Please sign in to comment.