Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AVKit and AVRouting] Updates for Xcode14 Beta3 #15811

Merged
merged 13 commits into from
Sep 8, 2022
Merged
21 changes: 21 additions & 0 deletions src/AVRouting/AVCustomDeviceRoute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#if IOS
//
// AVCustomDeviceRoute.cs: AVCustomDeviceRoute Complementing methods
//
// Author:
// Manuel de la Pena <[email protected]>
//
using System;
using Network;

#nullable enable

namespace AVRouting {
partial class AVCustomDeviceRoute {

public NWEndpoint NetworkEndpoint => new NWEndpoint (_NetworkEndpoint, owns: false);

}
}
#endif

2 changes: 1 addition & 1 deletion src/avfoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12300,7 +12300,7 @@ interface AVPlayerItem : NSCopying {
[Export ("externalMetadata", ArgumentSemantic.Copy)]
AVMetadataItem[] ExternalMetadata { get; set; }

[NoiOS][NoMac][NoWatch]
[iOS (16,0)][NoMacCatalyst][NoMac][NoWatch]
[TV (9,0)]
[Export ("interstitialTimeRanges", ArgumentSemantic.Copy)]
AVInterstitialTimeRange[] InterstitialTimeRanges { get; set; }
Expand Down
107 changes: 104 additions & 3 deletions src/avkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
using UIMenuElement = Foundation.NSObject;
#endif // !MONOMAC

#if TVOS || WATCH
using AVCustomRoutingController = Foundation.NSObject;
using AVCustomRoutingEvent = Foundation.NSObject;
using AVCustomRoutingActionItem = Foundation.NSObject;
#else
using AVRouting;
#endif

#if !NET
using NativeHandle = System.IntPtr;
#endif
Expand Down Expand Up @@ -310,6 +318,22 @@ interface AVPlayerViewController {
[TV (15,0), NoWatch, NoMac, NoiOS, NoMacCatalyst]
[Export ("transportBarIncludesTitleView")]
bool TransportBarIncludesTitleView { get; set; }

[NoWatch, NoTV, MacCatalyst (16,0), NoMac, iOS (16,0)]
[Export ("allowsVideoFrameAnalysis")]
bool AllowsVideoFrameAnalysis { get; set; }

[iOS (16,0), MacCatalyst (16,0), NoMac, NoWatch, TV (16,0)]
[Export ("speeds", ArgumentSemantic.Copy)]
AVPlaybackSpeed[] Speeds { get; set; }

[iOS (16,0), MacCatalyst (16,0), NoMac, NoWatch, TV (16,0)]
[NullAllowed, Export ("selectedSpeed")]
AVPlaybackSpeed SelectedSpeed { get; }

[iOS (16,0), MacCatalyst (16,0), NoMac, NoWatch, TV (16,0)]
[Export ("selectSpeed:")]
void SelectSpeed (AVPlaybackSpeed speed);
}

[NoMac]
Expand Down Expand Up @@ -345,7 +369,7 @@ interface AVPlayerViewControllerDelegate
[Export ("playerViewController:restoreUserInterfaceForPictureInPictureStopWithCompletionHandler:")]
void RestoreUserInterfaceForPictureInPicture (AVPlayerViewController playerViewController, Action<bool> completionHandler);

[NoiOS][NoMac]
[iOS (16,0)][NoMac][NoMacCatalyst][NoWatch]
[TV (9,0)]
[Export ("playerViewController:didPresentInterstitialTimeRange:")]
void DidPresentInterstitialTimeRange (AVPlayerViewController playerViewController, AVInterstitialTimeRange interstitial);
Expand All @@ -365,7 +389,7 @@ interface AVPlayerViewControllerDelegate
[Export ("playerViewControllerDidEndDismissalTransition:")]
void DidEndDismissalTransition (AVPlayerViewController playerViewController);

[NoiOS][NoMac]
[iOS (16,0)][NoMac][NoWatch][NoMacCatalyst]
[TV (9,0)]
[Export ("playerViewController:willPresentInterstitialTimeRange:")]
void WillPresentInterstitialTimeRange (AVPlayerViewController playerViewController, AVInterstitialTimeRange interstitial);
Expand Down Expand Up @@ -546,6 +570,34 @@ interface AVPlayerView {
[Mac (12,0)]
[NullAllowed, Export ("delegate", ArgumentSemantic.Weak)]
NSObject WeakDelegate { get; set; }

[Mac (13,0), NoWatch, NoiOS, NoMacCatalyst, NoTV]
[Export ("speeds", ArgumentSemantic.Copy)]
AVPlaybackSpeed[] Speeds { get; set; }

[Mac (13,0), NoWatch, NoiOS, NoMacCatalyst, NoTV]
[NullAllowed, Export ("selectedSpeed")]
AVPlaybackSpeed SelectedSpeed { get; }

[Mac (13,0), NoWatch, NoiOS, NoMacCatalyst, NoTV]
[Export ("selectSpeed:")]
void SelectSpeed (AVPlaybackSpeed speed);

[NoWatch, NoTV, NoMacCatalyst, NoiOS, Mac (13, 0)]
[Export ("allowsVideoFrameAnalysis")]
bool AllowsVideoFrameAnalysis { get; set; }

[Mac (13,0), NoWatch, NoiOS, NoMacCatalyst, NoTV]
[Export ("allowsMagnification")]
bool AllowsMagnification { get; set; }

[Mac (13,0), NoWatch, NoiOS, NoMacCatalyst, NoTV]
[Export ("magnification")]
nfloat Magnification { get; set; }

[Mac (13,0), NoWatch, NoiOS, NoMacCatalyst, NoTV]
[Export ("setMagnification:centeredAtPoint:")]
void SetMagnification (nfloat magnification, CGPoint centeredAtPoint);
}

interface IAVPlayerViewPictureInPictureDelegate {}
Expand Down Expand Up @@ -621,7 +673,7 @@ interface AVCaptureViewDelegate {
void StartRecording (AVCaptureView captureView, AVCaptureFileOutput fileOutput);
}

[NoiOS][NoMac]
[iOS (16,0)][NoMac][NoMacCatalyst][NoWatch]
[TV (9,0)]
[BaseType (typeof (NSObject))]
interface AVInterstitialTimeRange : NSCopying, NSSecureCoding {
Expand Down Expand Up @@ -761,6 +813,10 @@ interface AVRoutePickerView {
[NoiOS, NoTV, NoWatch]
[NullAllowed, Export ("player", ArgumentSemantic.Assign)]
AVPlayer Player { get; set; }

[NoTV, NoMac, iOS (16,0), MacCatalyst (16,0), NoWatch]
[NullAllowed, Export ("customRoutingController", ArgumentSemantic.Assign)]
AVCustomRoutingController CustomRoutingController { get; set; }
}

[NoiOS, NoMac, NoWatch, NoMacCatalyst]
Expand Down Expand Up @@ -956,4 +1012,49 @@ public enum AVPlayerViewTrimResult : long {
CancelButton,
}

[TV (16,0), NoWatch, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface AVPlaybackSpeed
{
[Static]
[Export ("systemDefaultSpeeds")]
AVPlaybackSpeed[] SystemDefaultSpeeds { get; }

[Export ("initWithRate:localizedName:")]
NativeHandle Constructor (float rate, string localizedName);

[Export ("rate")]
float Rate { get; }

[Export ("localizedName")]
string LocalizedName { get; }

[Export ("localizedNumericName")]
string LocalizedNumericName { get; }
}

delegate void AVCustomRoutingControllerDelegateCompletionHandler (bool success);

interface IAVCustomRoutingControllerDelegate {}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
#if NET
[Protocol, Model]
#else
[Protocol, Model (AutoGeneratedName = true)]
#endif
[BaseType (typeof (NSObject))]
interface AVCustomRoutingControllerDelegate
{
[Abstract]
[Export ("customRoutingController:handleEvent:completionHandler:")]
void HandleEvent (AVCustomRoutingController controller, AVCustomRoutingEvent @event, AVCustomRoutingControllerDelegateCompletionHandler completionHandler);

[Export ("customRoutingController:eventDidTimeOut:")]
void EventDidTimeOut (AVCustomRoutingController controller, AVCustomRoutingEvent @event);

[Export ("customRoutingController:didSelectItem:")]
void DidSelectItem (AVCustomRoutingController controller, AVCustomRoutingActionItem customActionItem);
}
}
97 changes: 97 additions & 0 deletions src/avrouting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// AVRouting bindings
//
// Authors:
// TJ Lambert <[email protected]>
//
// Copyright 2022 Microsoft Corp. All rights reserved.
//

using System;
using ObjCRuntime;
using Foundation;
using UniformTypeIdentifiers;
using AVKit;

#if !NET
using NativeHandle = System.IntPtr;
using OS_nw_endpoint = System.IntPtr;
#else
using OS_nw_endpoint = ObjCRuntime.NativeHandle;
#endif

namespace AVRouting {

[Mac (13,0), iOS (16,0), MacCatalyst (16,0), NoTV, NoWatch]
[Native]
public enum AVCustomRoutingEventReason : long
{
Activate = 0,
Deactivate,
Reactivate,
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
interface AVCustomDeviceRoute
{
[Internal]
[Export ("networkEndpoint")]
OS_nw_endpoint _NetworkEndpoint { get; }

[NullAllowed, Export ("bluetoothIdentifier")]
NSUuid BluetoothIdentifier { get; }
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
interface AVCustomRoutingActionItem
{
[Export ("type", ArgumentSemantic.Copy)]
UTType Type { get; set; }

[NullAllowed, Export ("overrideTitle")]
string OverrideTitle { get; set; }
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
interface AVCustomRoutingController
{
[Wrap ("WeakDelegate")]
IAVCustomRoutingControllerDelegate Delegate { get; set; }

[NullAllowed, Export ("delegate", ArgumentSemantic.Weak)]
NSObject WeakDelegate { get; set; }

[Export ("authorizedRoutes")]
AVCustomDeviceRoute[] AuthorizedRoutes { get; }

[Export ("customActionItems", ArgumentSemantic.Strong)]
AVCustomRoutingActionItem[] CustomActionItems { get; set; }

[Export ("invalidateAuthorizationForRoute:")]
void InvalidateAuthorization (AVCustomDeviceRoute route);

[Export ("setActive:forRoute:")]
void SetActive (bool active, AVCustomDeviceRoute route);

[Export ("isRouteActive:")]
bool IsRouteActive (AVCustomDeviceRoute route);

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[Notification, Field ("AVCustomRoutingControllerAuthorizedRoutesDidChangeNotification")]
NSString AuthorizedRoutesDidChangeNotification { get; }
}

[NoWatch, NoTV, NoMac, iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
interface AVCustomRoutingEvent
{
[Export ("reason")]
AVCustomRoutingEventReason Reason { get; }

[Export ("route")]
AVCustomDeviceRoute Route { get; }
}
}
8 changes: 8 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ AVKIT_API_SOURCES = \
AVKIT_SOURCES = \
AVKit/AVPlayerViewController.cs \

# AVRouting

AVROUTING_SOURCES = \
AVRouting/AVCustomDeviceRoute.cs \

# BackgroundTasks

BACKGROUNDTASKS_API_SOURCES = \
Expand Down Expand Up @@ -1999,6 +2004,7 @@ MACOS_FRAMEWORKS = \
AudioUnit \
AutomaticAssessmentConfiguration \
AVKit \
AVRouting \
BusinessChat \
BackgroundAssets \
CallKit \
Expand Down Expand Up @@ -2095,6 +2101,7 @@ MACOS_FRAMEWORKS = \
IOS_FRAMEWORKS = \
$(COMMON_FRAMEWORKS) \
AVKit \
AVRouting \
Accounts \
AdServices \
AdSupport \
Expand Down Expand Up @@ -2294,6 +2301,7 @@ MACCATALYST_FRAMEWORKS = \
AppClip \
AppKit \
AVKit \
AVRouting \
Accounts \
AdServices \
AdSupport \
Expand Down
38 changes: 38 additions & 0 deletions tests/monotouch-test/AVRouting/AVCustomDeviceRouteTest
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Unit tests for AVCustomDeviceRoute
//
// Authors:
// TJ Lambert <[email protected]>
//
// Copyright 2022 Microsoft Corp. All rights reserved.
//
#if IOS || __MACCATALYST__

using System;
using Foundation;
using ObjCRuntime;
using AVRouting;
using NUnit.Framework;
using Xamarin.Utils;

namespace MonoTouchFixtures.AVRouting {

[TestFixture]
[Preserve (AllMembers = true)]
public class AVCustomDeviceRouteTest {

[SetUp]
public void Setup ()
{
TestRuntime.AssertXcodeVersion (14, 0);
}

[Test]
public void GetNetworkEndpointTest ()
{
Assert.IsNotNull (AVRouting.NetworkEndpoint, "NetworkEndpoint should not be null.");
}
}
}

#endif // IOS || __MACCATALYST__
19 changes: 0 additions & 19 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-AVKit.todo

This file was deleted.

Loading