Skip to content

Commit

Permalink
[AVFoundation] Fix a few issues with the AVAssetImageGenerator bindin…
Browse files Browse the repository at this point in the history
…gs. Partial fix for dotnet#18452.

* The 'copyCGImageAtTime:actualTime:error:' selector is deprecated, so replicate that.
* Bind the 'generateCGImageAsynchronouslyForTime:completionHandler:' selector.

Fixes parts 1 and 2 of dotnet#18452.
  • Loading branch information
rolfbjarne committed Jun 16, 2023
1 parent 959bb55 commit 769276e
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 14 deletions.
8 changes: 8 additions & 0 deletions src/avfoundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ interface MTAudioProcessingTap {}
delegate void AVAssetImageGeneratorCompletionHandler (CMTime requestedTime, IntPtr imageRef, CMTime actualTime, AVAssetImageGeneratorResult result, NSError error);
delegate void AVAssetImageGeneratorCompletionHandler2 (CMTime requestedTime, CGImage imageRef, CMTime actualTime, AVAssetImageGeneratorResult result, NSError error);
#endif
delegate void AVAssetImageGenerateAsynchronouslyForTimeCompletionHandler (CGImage imageRef, CMTime actualTime, NSError error);
delegate void AVCompletion (bool finished);
delegate void AVRequestAccessStatus (bool accessGranted);
delegate AVAudioBuffer AVAudioConverterInputHandler (uint inNumberOfPackets, out AVAudioConverterInputStatus outStatus);
Expand Down Expand Up @@ -4231,6 +4232,10 @@ interface AVAssetImageGenerator {
[Export ("initWithAsset:")]
NativeHandle Constructor (AVAsset asset);

[Deprecated (PlatformName.MacOSX, 13, 0, message: "Use the 'GenerateCGImagesAsynchronously' method instead.")]
[Deprecated (PlatformName.TvOS, 16, 0, message: "Use the 'GenerateCGImagesAsynchronously' method instead.")]
[Deprecated (PlatformName.iOS, 16, 0, message: "Use the 'GenerateCGImagesAsynchronously' method instead.")]
[Deprecated (PlatformName.MacCatalyst, 16, 0, message: "Use the 'GenerateCGImagesAsynchronously' method instead.")]
[Export ("copyCGImageAtTime:actualTime:error:")]
[return: NullAllowed]
[return: Release ()]
Expand All @@ -4245,6 +4250,9 @@ interface AVAssetImageGenerator {
void GenerateCGImagesAsynchronously (NSValue [] cmTimesRequestedTimes, AVAssetImageGeneratorCompletionHandler2 handler);
#endif

[Export ("generateCGImageAsynchronouslyForTime:completionHandler:")]
void GenerateCGImageAsynchronously (CMTime requestedTime, AVAssetImageGenerateAsynchronouslyForTimeCompletionHandler handler);

[Export ("cancelAllCGImageGeneration")]
void CancelAllCGImageGeneration ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -74,7 +73,6 @@
!missing-selector! +NSValue::valueWithCMVideoDimensions: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -69,7 +68,6 @@
!missing-selector! +AVVideoComposition::videoCompositionWithPropertiesOfAsset:completionHandler: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -73,7 +72,6 @@
!missing-selector! +AVVideoComposition::videoCompositionWithPropertiesOfAsset:completionHandler: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -68,7 +67,6 @@
!missing-selector! +AVVideoComposition::videoCompositionWithPropertiesOfAsset:completionHandler: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/iOS-AVFoundation.todo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -69,7 +68,6 @@
!missing-selector! +AVVideoComposition::videoCompositionWithPropertiesOfAsset:completionHandler: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/macOS-AVFoundation.todo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -73,7 +72,6 @@
!missing-selector! +AVVideoComposition::videoCompositionWithPropertiesOfAsset:completionHandler: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/tvOS-AVFoundation.todo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
!deprecated-attribute-missing! AVAsset::tracksWithMediaType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::trackWithTrackID: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAsset::unusedTrackID missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetImageGenerator::copyCGImageAtTime:actualTime:error: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::associatedTracksOfType: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::metadataForFormat: missing a [Deprecated] attribute
!deprecated-attribute-missing! AVAssetTrack::samplePresentationTimeForTrackTime: missing a [Deprecated] attribute
Expand Down Expand Up @@ -68,7 +67,6 @@
!missing-selector! +AVVideoComposition::videoCompositionWithPropertiesOfAsset:completionHandler: not bound
!missing-selector! AVAssetExportSession::audioTrackGroupHandling not bound
!missing-selector! AVAssetExportSession::setAudioTrackGroupHandling: not bound
!missing-selector! AVAssetImageGenerator::generateCGImageAsynchronouslyForTime:completionHandler: not bound
!missing-selector! AVAssetPlaybackAssistant::loadPlaybackConfigurationOptionsWithCompletionHandler: not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::isEntireLengthAvailableOnDemand not bound
!missing-selector! AVAssetResourceLoadingContentInformationRequest::setEntireLengthAvailableOnDemand: not bound
Expand Down

0 comments on commit 769276e

Please sign in to comment.