Skip to content

[AVFoundation] Add missing categories from Xcode 9 and add new API from Xcode 9.1 - #2919

Merged
mandel-macaque merged 4 commits into
dotnet:xcode9.1from
mandel-macaque:avfoundation-xcode9.1
Oct 30, 2017
Merged

[AVFoundation] Add missing categories from Xcode 9 and add new API from Xcode 9.1#2919
mandel-macaque merged 4 commits into
dotnet:xcode9.1from
mandel-macaque:avfoundation-xcode9.1

Conversation

@mandel-macaque

Copy link
Copy Markdown
Contributor

No description provided.

@monojenkins

Copy link
Copy Markdown
Contributor

Build failure

Comment thread src/avfoundation.cs Outdated
[Export ("preferredPeakBitRate")]
double PreferredPeakBitRate { get; set; }

[iOS (11, 0)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since only iOS headers were updated you need to add [NoMac] (XM intro tests are failing) [NoTV] and [NoWatch] attributes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, Sorry for thatI forgot theNoMac and NoTV, watch is already ignored since is in the top of the class.

Comment thread src/avfoundation.cs Outdated

[TV (11, 0), NoWatch, Mac (10, 13), iOS (11, 0)]
[Field ("AVSampleBufferAudioRendererWasFlushedAutomaticallyNotification")]
NSString AudioRendererWasFlushedAutomaticallyNotification { get; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the naming makes it sound like a [Notification] attribute is missing (and intro complains about this)

Comment thread src/avfoundation.cs
[Field ("AVCaptureDeviceTypeBuiltInDualCamera")]
BuiltInDualCamera,

[iOS (11, 1)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing NoMac, NoTV and NoWatch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those decorators are already present in line 9422 on top of the enum, we have NoTV, NoMac, NoWatch.

Comment thread src/AVFoundation/Enums.cs
VideoDeviceInUseByAnotherClient = 3,
VideoDeviceNotAvailableWithMultipleForegroundApps = 4
VideoDeviceNotAvailableWithMultipleForegroundApps = 4,
[iOS (11, 1)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoMac, NoTV and NoWatch missing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already has a [NoTV, NoWatch] in the top of the enum and it is inside a #if !MONOMAC which means that is not necessary, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah technically it is not needed but I think it was the plan that at some point we would get rid of those conditionals if possible so having that metadata there won't hurt I guess, unless @spouliot says otherwise :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd get rid of #if !MONOMAC, not of availability attributes on the parent (so lack of [NoTV, NoWatch] still valid).

We could just add a [NoMac] to public enum AVCaptureSessionInterruptionReason but that would be just noise in this case, better do it for things we add.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, we'll soon have xtro results so it will be easier to spot them :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, leaving as it is to reduce noise in the diff. We can do this later for new types or in a pr just to get rid of the #if !MONOMAC

Comment thread src/avfoundation.cs Outdated
[Export ("automaticallyConfiguresCaptureDeviceForWideColor")]
bool AutomaticallyConfiguresCaptureDeviceForWideColor { get; set; }

[iOS (11, 1)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the #if are not clear in the diff but this cannot be added in Mac, TV or Watch since the headers were not updated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is within a #if !MONOMAC in line 8156 to line 8184 that includes the only iOS methods. The class has a NoWatch NoTV already, therefore AFAIK, it is not added in Mac, TV or Watch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that because the class has [NoWatch] and [NoTV] we shouldn't add those but I would still add the [NoMac] even though there's a #if !MONOMAC. Remember we're trying to move away from them, it adds clarity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even a [NoMac] should be added on the type, so we would not see it in the diff :|
hopefully xtro will make this easier to review (really soon now)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding NoMac and moving out side the #if !MONOMAC.

Comment thread src/avfoundation.cs Outdated

[Mac (10, 13), iOS (11, 0), TV (11, 0)]
[Export ("sourceTrackIDForFrameTiming")]
int SourceTrackIDForFrameTiming { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id - not ID since it's not an acronym

Comment thread src/avfoundation.cs Outdated

[iOS (11, 0)]
[Export ("metadata", ArgumentSemantic.Copy)]
NSDictionary<NSString, NSObject> Metadata { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an NSDictionary so we can use a strong dictionary later

Comment thread src/avfoundation.cs Outdated

[iOS (11,0)]
[Export ("supportedPhotoPixelFormatTypesForFileType:")]
NSNumber[] SupportedPhotoPixelFormatTypesForFileType (string fileType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> Get SupportedPhotoPixelFormatTypes

Comment thread src/avfoundation.cs Outdated

[iOS (11,0)]
[Export ("supportedPhotoCodecTypesForFileType:")]
string[] SupportedPhotoCodecTypesForFileType (string fileType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> GetSupportedPhotoCodecTypes

Comment thread src/avfoundation.cs Outdated

[iOS (11,0)]
[Export ("supportedRawPhotoPixelFormatTypesForFileType:")]
NSNumber[] SupportedRawPhotoPixelFormatTypesForFileType (string fileType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> Get SupportedRawPhotoPixelFormatTypes

Comment thread src/avfoundation.cs
[NullAllowed, Export ("error")]
NSError Error { get; }

[NullAllowed, Export ("audioOutputDeviceUniqueID")]

@dalexsoto dalexsoto Oct 25, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with the API so to be honest I am not sure of what the unique id is for, maybe we should keep the full property name AudioOutputDeviceUniqueId

@VincentDondain VincentDondain Oct 25, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should keep the full property name AudioOutputDeviceUniqueId

Yes we should, the class is AVSampleBufferAudioRenderer not AudioOutputDevice so it makes sense to keep the full name, see swift version too: https://developer.apple.com/documentation/avfoundation/avsamplebufferaudiorenderer/2866182-audiooutputdeviceuniqueid

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/avfoundation.cs
[iOS (11,0)]
[Static]
[Export ("photoSettingsWithRawPixelFormatType:rawFileType:processedFormat:processedFileType:")]
AVCapturePhotoSettings FromRawPixelFormatType (uint rawPixelFormatType, [NullAllowed] string rawFileType, [NullAllowed] NSDictionary<NSString, NSObject> processedFormat, [NullAllowed] string processedFileType);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can make a strong dictionary in the future of NSDictionary<NSString, NSObject> processedFormat if so please just do NSDictionary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Over here I followed the pattern from the other static creators. If you look you will find:

[Static]
[Export ("photoSettingsWithRawPixelFormatType:processedFormat:")]
AVCapturePhotoSettings FromRawPixelFormatType (uint rawPixelFormatType,
[NullAllowed] NSDictionary<NSString, NSObject> processedFormat);

And this new method is an overload with an extra string parameter as a second parameter:

AVCapturePhotoSettings FromRawPixelFormatType (uint rawPixelFormatType, [NullAllowed] string rawFileType, [NullAllowed] NSDictionary<NSString, NSObject> processedFormat, [NullAllowed] string processedFileType);

I don't know if we want to have one (that is already a public API) with the template dir and a new one with a simple NSDictionary, makes the API look funny.

@spouliot comments?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's be consistent then

I think we need a something like NSDictionary GetWeakDictionary (); added to NSDictionary<T,V> (and maybe a GetStrongDictionary<T,V> () to NSDictionary too ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would end up with multiple managed objects per native handle.

We should really look into fixing our runtime to make that a supported scenario.

Comment thread src/avfoundation.cs Outdated

[iOS (11, 0)]
[Export ("availableEmbeddedThumbnailPhotoCodecTypes")]
string[] AvailableEmbeddedThumbnailPhotoCodecTypes { get; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like it returns a bunch of NSString constants (likely a smart enum) if that is the case please use NSString[] instead of string or better yet, if you have the info return a smart enum ;)

Comment thread src/avfoundation.cs Outdated

[iOS (11, 0)]
[Export ("availablePhotoFileTypes")]
string[] AvailablePhotoFileTypes { get; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like it returns a bunch of NSString constants (likely a smart enum) if that is the case please use NSString[] instead of string or better yet, if you have the info return a smart enum ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that since AFAIK it should be a AVVideoCodecType.

Comment thread src/avfoundation.cs Outdated

[iOS (11, 0)]
[Export ("availableRawPhotoFileTypes")]
string[] AvailableRawPhotoFileTypes { get; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like it returns a bunch of NSString constants (likely a smart enum) if that is the case please use NSString[] instead of string or better yet, if you have the info return a smart enum ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will do that with a simple wrap.

Comment thread src/avfoundation.cs Outdated
NSString AudioRendererWasFlushedAutomaticallyNotification { get; }

[TV (11, 0), NoWatch, Mac (10, 13), iOS (11, 0)]
[Field ("AVSampleBufferAudioRendererFlushTimeKey")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part of the Flushed Automatically Notification payload?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is part of the AVSampleBufferAudioRendererWasFlushedAutomaticallyNotification, as per the headers:

The renderer may flush enqueued media data when the user routes playback to a new destination. The renderer may also flush enqueued media data when the playback rat
e of the attached AVSampleBufferRenderSynchronizer is changed (e.g. 1.0 -> 2.0 or 1.0 -> 0.0 -> 2.0), however no flush will occur for normal pauses (non-zero -> 0.0) and resumes (0.
0 -> same non-zero rate as before).

            When an automatic flush occurs, the attached render synchronizer's timebase will remain running at its current rate.  It is typically best to respond to this notification by enqueueing media data with timestamps starting at the timebase's current time.  To the listener, this will sound similar to muting the audio for a short period of time.  If it is more desirable to ensure that all audio is played than to keep the timeline moving, you may also stop the synchronizer, set the synchronizer's current time to the value of AVSampleBufferAudioRendererFlushTimeKey, start reenqueueing sample buffers with timestamps starting at that time, and restart the synchronizer.  To the listener, this will sound similar to pausing the audio for a short period of time.

            This notification is delivered on an arbitrary thread.  If sample buffers are being enqueued with the renderer concurrently with the receipt of this notification, it is possible that one or more sample buffers will remain enqueued in the renderer.  This is generally undesirable, because the sample buffers that remain will likely have timestamps far ahead of the timebase's current time and so won't be rendered for some time.  The best practice is to invoke the -flush method, in a manner that is serialized with enqueueing sample buffers, after receiving this notification and before resuming the enqueueing of sample buffers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you need to add it to the Notification attribute as described here https://developer.xamarin.com/guides/cross-platform/macios/binding/binding-types-reference/#NotificationAttribute

look for this

If your notification contains parameters, you should specify a helper EventArgs interface, like this:

@monojenkins

Copy link
Copy Markdown
Contributor

Build failure

@monojenkins

Copy link
Copy Markdown
Contributor

Build success

Comment thread src/avfoundation.cs
[NullAllowed, Export ("error")]
NSError Error { get; }

[NullAllowed, Export ("audioOutputDeviceUniqueID")]

@VincentDondain VincentDondain Oct 25, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should keep the full property name AudioOutputDeviceUniqueId

Yes we should, the class is AVSampleBufferAudioRenderer not AudioOutputDevice so it makes sense to keep the full name, see swift version too: https://developer.apple.com/documentation/avfoundation/avsamplebufferaudiorenderer/2866182-audiooutputdeviceuniqueid

Comment thread src/avfoundation.cs Outdated
[Export ("automaticallyConfiguresCaptureDeviceForWideColor")]
bool AutomaticallyConfiguresCaptureDeviceForWideColor { get; set; }

[iOS (11, 1)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that because the class has [NoWatch] and [NoTV] we shouldn't add those but I would still add the [NoMac] even though there's a #if !MONOMAC. Remember we're trying to move away from them, it adds clarity.

Comment thread src/avfoundation.cs

// From @interface AVCapturePhotoBracketedCapture (AVCapturePhoto)

#if !MONOMAC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we go [NoMac] here? Are AVCaptureBracketedStillImageSettings and AVCaptureLensStabilizationStatus just not available?

SequenceCount could definitely avoid the #if !MONOMAC

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AVCaptureBracketedStillImageSettings and AVCaptureLensStabilizationStatus is not present in the mac AFAIK. Moving the other ones out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is misleading AVCaptureLensStabilizationStatus seems to be present since you did not put it in the #if !MONOMAC and it built just fine (:

@spouliot @mandel-macaque should we take this approach instead? https://github.com/xamarin/xamarin-macios/blob/master/src/scenekit.cs#L76-L97

It's also a comment for the future, I'd like to know the approach we prefer, moving forward.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I meant just one of them. tested the others :)

Comment thread src/avfoundation.cs
NSObject AddPeriodicTimeObserver (CMTime interval, [NullAllowed] DispatchQueue queue, Action<CMTime> handler);

[Export ("addBoundaryTimeObserverForTimes:queue:usingBlock:")]
NSObject AddBoundaryTimeObserver (NSValue[] times, [NullAllowed] DispatchQueue queue, Action handler);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a comment here and the one above (and remove its [Async])

Comment thread src/avfoundation.cs
[iOS (11,0)]
[Static]
[Export ("photoSettingsWithRawPixelFormatType:rawFileType:processedFormat:processedFileType:")]
AVCapturePhotoSettings FromRawPixelFormatType (uint rawPixelFormatType, [NullAllowed] string rawFileType, [NullAllowed] NSDictionary<NSString, NSObject> processedFormat, [NullAllowed] string processedFileType);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's be consistent then

I think we need a something like NSDictionary GetWeakDictionary (); added to NSDictionary<T,V> (and maybe a GetStrongDictionary<T,V> () to NSDictionary too ?

…added event args for the flush notification. A helper property was added to go from NSValue to CMTime.
@monojenkins

Copy link
Copy Markdown
Contributor

Build success

@VincentDondain VincentDondain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/xamarin/xamarin-macios/pull/2919/files#r147492859 is still unanswered, I think we could avoid #if !MONOMAC completely but that's not really a blocker for the merge (:

@mandel-macaque

Copy link
Copy Markdown
Contributor Author

Merging after talking with Vincent as his comment is not a blocked and we do not want to be waiting for this regarding xcode 9.1

@mandel-macaque
mandel-macaque merged commit a26d527 into dotnet:xcode9.1 Oct 30, 2017
@mandel-macaque
mandel-macaque deleted the avfoundation-xcode9.1 branch October 30, 2017 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants