Skip to content

Commit

Permalink
Windows 10 Version 1709 - February 2019 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnewthing committed Feb 7, 2019
1 parent da59ad2 commit f5636b9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
26 changes: 22 additions & 4 deletions Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ namespace SDKTemplate
return ref new DeviceSelectorInfo("UPnP", DeviceClass::All, "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"", DeviceInformationKind::AssociationEndpoint);
}

void AddVideoCastingIfSupported(Vector<DeviceSelectorInfo^>^ selectors)
{
try
{
selectors->Append(DeviceSelectorChoices::VideoCasting);
}
catch (Exception^ ex)
{
if (ex->HResult == HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED))
{
// Video casting not supported by the system.
}
else
{
throw;
}
}
}

IVectorView<DeviceSelectorInfo^>^ DeviceSelectorChoices::DevicePickerSelectors::get()
{
Expand All @@ -138,7 +156,7 @@ namespace SDKTemplate
selectors->Append(BluetoothLEUnpairedOnly);
selectors->Append(WiFiDirect);
selectors->Append(PointOfServicePrinter);
selectors->Append(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors->Append(DialAllApps);

return selectors->GetView();
Expand All @@ -161,7 +179,7 @@ namespace SDKTemplate
selectors->Append(BluetoothLE);
selectors->Append(WiFiDirect);
selectors->Append(PointOfServicePrinter);
selectors->Append(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors->Append(DialAllApps);
selectors->Append(Wsd);
selectors->Append(Upnp);
Expand All @@ -176,7 +194,7 @@ namespace SDKTemplate
selectors->Append(BluetoothLEPairedOnly);
selectors->Append(WiFiDirectPairedOnly);
selectors->Append(PointOfServicePrinter);
selectors->Append(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors->Append(DialAllApps);
selectors->Append(Wsd);
selectors->Append(Upnp);
Expand All @@ -191,7 +209,7 @@ namespace SDKTemplate
selectors->Append(BluetoothLE);
selectors->Append(WiFiDirect);
selectors->Append(PointOfServicePrinter);
selectors->Append(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors->Append(Wsd);
selectors->Append(Upnp);

Expand Down
20 changes: 16 additions & 4 deletions Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,18 @@ public static DeviceSelectorInfo Upnp
}
}

public static void AddVideoCastingIfSupported(List<DeviceSelectorInfo> selectors)
{
try
{
selectors.Add(VideoCasting);
}
catch (Exception ex) when (ex.HResult == unchecked((int)0x80070032)) // HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
{
// Video casting is not supported by the system.
}
}

public static List<DeviceSelectorInfo> DevicePickerSelectors
{
get
Expand All @@ -207,7 +219,7 @@ public static List<DeviceSelectorInfo> DevicePickerSelectors
selectors.Add(BluetoothLEUnpairedOnly);
selectors.Add(WiFiDirect);
selectors.Add(PointOfServicePrinter);
selectors.Add(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors.Add(DialAllApps);

return selectors;
Expand Down Expand Up @@ -238,7 +250,7 @@ public static List<DeviceSelectorInfo> DeviceWatcherSelectors
selectors.Add(BluetoothLE);
selectors.Add(WiFiDirect);
selectors.Add(PointOfServicePrinter);
selectors.Add(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors.Add(DialAllApps);
selectors.Add(Wsd);
selectors.Add(Upnp);
Expand All @@ -257,7 +269,7 @@ public static List<DeviceSelectorInfo> BackgroundDeviceWatcherSelectors
selectors.Add(BluetoothLEPairedOnly);
selectors.Add(WiFiDirectPairedOnly);
selectors.Add(PointOfServicePrinter);
selectors.Add(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors.Add(DialAllApps);
selectors.Add(Wsd);
selectors.Add(Upnp);
Expand All @@ -279,7 +291,7 @@ public static List<DeviceSelectorInfo> PairingSelectors
selectors.Add(BluetoothLE);
selectors.Add(WiFiDirect);
selectors.Add(PointOfServicePrinter);
selectors.Add(VideoCasting);
AddVideoCastingIfSupported(selectors);
selectors.Add(Wsd);
selectors.Add(Upnp);

Expand Down
20 changes: 15 additions & 5 deletions Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@
var wiFiDirect = { displayName: "Wi-Fi Direct", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector(Windows.Devices.WiFiDirect.WiFiDirectDeviceSelectorType.associationEndpoint) };
var wiFiDirectPairedOnly = { displayName: "Wi-Fi Direct (paired)", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector() };
var pointOfServicePrinter = { displayName: "Point of Service Printer", selector: Windows.Devices.PointOfService.PosPrinter.getDeviceSelector() };
var videoCasting = { displayName: "Video Casting", selector: Windows.Media.Casting.CastingDevice.getDeviceSelector(Windows.Media.Casting.CastingPlaybackTypes.video) };

try {
var videoCasting = { displayName: "Video Casting", selector: Windows.Media.Casting.CastingDevice.getDeviceSelector(Windows.Media.Casting.CastingPlaybackTypes.video) };
} catch (e) {
if (e.number === 0x80070032 | 0) { // HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)
// Video casting not supported by the system.
} else {
throw e;
}
}

var dialAllApps = { displayName: "DIAL (All Apps)", selector: Windows.Media.DialProtocol.DialDevice.getDeviceSelector("") };

// WSD and UPnP are unique in that there are currently no general WSD or UPnP APIs to USE the devices once you've discovered them.
Expand All @@ -53,7 +63,7 @@
devicePickerArray.push(bluetoothLEUnpairedOnly);
devicePickerArray.push(wiFiDirect);
devicePickerArray.push(pointOfServicePrinter);
devicePickerArray.push(videoCasting);
videoCasting && devicePickerArray.push(videoCasting);
devicePickerArray.push(dialAllApps);
var devicePickerSelectors = new WinJS.Binding.List(devicePickerArray);

Expand All @@ -68,7 +78,7 @@
deviceWatcherArray.push(bluetoothLE);
deviceWatcherArray.push(wiFiDirect);
deviceWatcherArray.push(pointOfServicePrinter);
deviceWatcherArray.push(videoCasting);
videoCasting && deviceWatcherArray.push(videoCasting);
deviceWatcherArray.push(dialAllApps);
deviceWatcherArray.push(wsd);
deviceWatcherArray.push(upnp);
Expand All @@ -79,7 +89,7 @@
backgroundDeviceWatcherArray.push(bluetoothLEPairedOnly);
backgroundDeviceWatcherArray.push(wiFiDirectPairedOnly);
backgroundDeviceWatcherArray.push(pointOfServicePrinter);
backgroundDeviceWatcherArray.push(videoCasting);
videoCasting && backgroundDeviceWatcherArray.push(videoCasting);
backgroundDeviceWatcherArray.push(dialAllApps);
backgroundDeviceWatcherArray.push(wsd);
backgroundDeviceWatcherArray.push(upnp);
Expand All @@ -90,7 +100,7 @@
pairingArray.push(bluetoothLE);
pairingArray.push(wiFiDirect);
pairingArray.push(pointOfServicePrinter);
pairingArray.push(videoCasting);
videoCasting && pairingArray.push(videoCasting);
pairingArray.push(wsd);
pairingArray.push(upnp);
var pairingSelectors = new WinJS.Binding.List(pairingArray);
Expand Down

0 comments on commit f5636b9

Please sign in to comment.