-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeviceDiscoveryExtension] Added bindings for DeviceDiscoveryExtensio…
…n. (#20272) --------- Co-authored-by: Israel Soto <issoto@microsoft.com>
- Loading branch information
1 parent
d1f387c
commit 2348736
Showing
17 changed files
with
396 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Custom methods for DDDevice | ||
// | ||
// Authors: | ||
// Israel Soto (issoto@microsoft.com) | ||
// Rolf Bjarne Kvinge (rolf@xamarin.com) | ||
// | ||
// Copyright 2022, 2024 Microsoft Corporation. | ||
// | ||
|
||
#nullable enable | ||
|
||
using ObjCRuntime; | ||
using Foundation; | ||
using Network; | ||
using System; | ||
|
||
using nw_endpoint_t = System.IntPtr; | ||
|
||
namespace DeviceDiscoveryExtension { | ||
public partial class DDDevice { | ||
public NWEndpoint? NetworkEndpoint { | ||
get => _NetworkEndpoint != nw_endpoint_t.Zero ? new NWEndpoint (_NetworkEndpoint, false) : null; | ||
set => _NetworkEndpoint = value.GetHandle (); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// Enums.cs | ||
// | ||
// Authors: | ||
// Israel Soto (issoto@microsoft.com) | ||
// Rolf Bjarne Kvinge (rolf@xamarin.com) | ||
// | ||
// Copyright 2022, 2024 Microsoft Corporation. | ||
// | ||
|
||
using System; | ||
|
||
using ObjCRuntime; | ||
using Foundation; | ||
|
||
namespace DeviceDiscoveryExtension { | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[Native] | ||
public enum DDDeviceProtocol : long { | ||
Invalid = 0, | ||
Dial = 1, | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[Native] | ||
public enum DDDeviceCategory : long { | ||
HiFiSpeaker = 0, | ||
HiFiSpeakerMultiple = 1, | ||
TvWithMediaBox = 2, | ||
Tv = 3, | ||
LaptopComputer = 4, | ||
DesktopComputer = 5, | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[Native] | ||
public enum DDDeviceState : long { | ||
Invalid = 0, | ||
Activating = 10, | ||
Activated = 20, | ||
Authorized = 25, | ||
Invalidating = 30, | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[Native] | ||
public enum DDDeviceMediaPlaybackState : long { | ||
NoContent = 0, | ||
Paused = 1, | ||
Playing = 2, | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[ErrorDomain ("DDErrorDomain")] | ||
[Native] | ||
public enum DDErrorCode : long { | ||
Success = 0, | ||
Unknown = 350000, | ||
BadParameter = 350001, | ||
Unsupported = 350002, | ||
Timeout = 350003, | ||
Internal = 350004, | ||
MissingEntitlement = 350005, | ||
Permission = 350006, | ||
// Next, // don't bind 'Next', it's not static and we'd have to break compat if it were ever to change | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[Native] | ||
public enum DDEventType : long { | ||
Unknown = 0, | ||
DeviceFound = 40, | ||
DeviceLost = 41, | ||
DeviceChanged = 42, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// | ||
// DeviceDiscoveryExtension C# bindings | ||
// | ||
// Authors: | ||
// Israel Soto (issoto@microsoft.com) | ||
// Rolf Bjarne Kvinge (rolf@xamarin.com) | ||
// | ||
// Copyright 2022, 2024 Microsoft Corporation. | ||
// | ||
|
||
using System; | ||
using ObjCRuntime; | ||
using Foundation; | ||
using UniformTypeIdentifiers; | ||
|
||
using nw_endpoint_t = System.IntPtr; | ||
|
||
#if !NET | ||
using NativeHandle = System.IntPtr; | ||
#endif | ||
|
||
namespace DeviceDiscoveryExtension { | ||
|
||
[Static] | ||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
interface DDDeviceProtocolStrings { | ||
[Field ("DDDeviceProtocolStringInvalid")] | ||
NSString Invalid { get; } | ||
|
||
[Field ("DDDeviceProtocolStringDIAL")] | ||
NSString Dial { get; } | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[BaseType (typeof (NSObject))] | ||
[DisableDefaultCtor] | ||
interface DDDevice { | ||
[Export ("initWithDisplayName:category:protocolType:identifier:")] | ||
[DesignatedInitializer] | ||
NativeHandle Constructor (string displayName, DDDeviceCategory category, UTType protocolType, string identifier); | ||
|
||
[NullAllowed, Export ("bluetoothIdentifier", ArgumentSemantic.Strong)] | ||
NSUuid BluetoothIdentifier { get; set; } | ||
|
||
[Export ("category", ArgumentSemantic.Assign)] | ||
DDDeviceCategory Category { get; set; } | ||
|
||
[Export ("displayName")] | ||
string DisplayName { get; set; } | ||
|
||
[Export ("identifier")] | ||
string Identifier { get; set; } | ||
|
||
[Internal] | ||
[Export ("networkEndpoint", ArgumentSemantic.Strong)] | ||
nw_endpoint_t _NetworkEndpoint { get; set; } | ||
|
||
[Export ("protocol", ArgumentSemantic.Assign)] | ||
DDDeviceProtocol Protocol { get; set; } | ||
|
||
[Export ("protocolType", ArgumentSemantic.Strong)] | ||
UTType ProtocolType { get; set; } | ||
|
||
[Export ("state", ArgumentSemantic.Assign)] | ||
DDDeviceState State { get; set; } | ||
|
||
[NullAllowed, Export ("txtRecordData", ArgumentSemantic.Copy)] | ||
NSData TxtRecordData { get; set; } | ||
|
||
[Export ("url", ArgumentSemantic.Copy)] | ||
NSUrl Url { get; set; } | ||
|
||
[Export ("mediaPlaybackState", ArgumentSemantic.Assign)] | ||
DDDeviceMediaPlaybackState MediaPlaybackState { get; set; } | ||
|
||
[NullAllowed, Export ("mediaContentTitle")] | ||
string MediaContentTitle { get; set; } | ||
|
||
[NullAllowed, Export ("mediaContentSubtitle")] | ||
string MediaContentSubtitle { get; set; } | ||
|
||
[iOS (17, 0)] | ||
[Export ("supportsGrouping")] | ||
bool SupportsGrouping { get; set; } | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[BaseType (typeof (NSObject))] | ||
[DisableDefaultCtor] | ||
interface DDDeviceEvent { | ||
[Export ("initWithEventType:device:")] | ||
NativeHandle Constructor (DDEventType type, DDDevice device); | ||
|
||
[Export ("device", ArgumentSemantic.Strong)] | ||
DDDevice Device { get; } | ||
|
||
[Export ("eventType", ArgumentSemantic.Assign)] | ||
DDEventType EventType { get; } | ||
} | ||
|
||
[NoMac, iOS (16, 0), NoMacCatalyst, NoWatch, NoTV] | ||
[BaseType (typeof (NSObject))] | ||
interface DDDiscoverySession { | ||
[Export ("reportEvent:")] | ||
void ReportEvent (DDDeviceEvent inEvent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong.