From 1a8febfb6c43619b1df322aee610c2aeafe7c72c Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Wed, 30 Nov 2016 21:53:17 -0500 Subject: [PATCH 1/2] [avfoundation] Fix incorrect selector for AVPlayerItemVideoOutput .ctor. Fixes #48382 Commit ba37aa44 workaround around a signature clash incorrectly and turned the selector to static ones (and incorrectly set the handle) Also fix a typo in the [Advice] attribute of the old API https://bugzilla.xamarin.com/show_bug.cgi?id=48382 --- src/AVFoundation/AVPlayerItemVideoOutput.cs | 10 ++--- src/avfoundation.cs | 4 +- .../AVFoundation/PlayerItemVideoOutputTest.cs | 44 +++++++++++++++++++ tests/monotouch-test/monotouch-test.csproj | 1 + 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 tests/monotouch-test/AVFoundation/PlayerItemVideoOutputTest.cs diff --git a/src/AVFoundation/AVPlayerItemVideoOutput.cs b/src/AVFoundation/AVPlayerItemVideoOutput.cs index 4e196a14fe1d..a5c554c29c2c 100644 --- a/src/AVFoundation/AVPlayerItemVideoOutput.cs +++ b/src/AVFoundation/AVPlayerItemVideoOutput.cs @@ -13,16 +13,16 @@ public partial class AVPlayerItemVideoOutput { enum InitMode { PixelAttributes, OutputSettings - } + } - AVPlayerItemVideoOutput (NSDictionary data, AVPlayerItemVideoOutput.InitMode mode) : this (IntPtr.Zero) + AVPlayerItemVideoOutput (NSDictionary data, AVPlayerItemVideoOutput.InitMode mode) : this () { switch (mode) { case InitMode.PixelAttributes: - Handle = _FromPixelBufferAttributes (data); + InitializeHandle (_FromPixelBufferAttributes (data), "initWithPixelBufferAttributes:"); break; case InitMode.OutputSettings: - Handle = _FromOutputSettings (data); + InitializeHandle (_FromOutputSettings (data), "initWithOutputSettings:"); break; default: throw new ArgumentException (nameof (mode)); @@ -30,7 +30,7 @@ enum InitMode { } [DesignatedInitializer] - [Advice ("Please use the constructor that uses one of the available StrongDictionaries. This constructor expects Pixelbugger attributes.")] + [Advice ("Please use the constructor that uses one of the available StrongDictionaries. This constructor expects PixelBuffer attributes.")] protected AVPlayerItemVideoOutput (NSDictionary pixelBufferAttributes) : this (pixelBufferAttributes, InitMode.PixelAttributes) {} } } diff --git a/src/avfoundation.cs b/src/avfoundation.cs index 5224876e2980..aadf11371f8e 100644 --- a/src/avfoundation.cs +++ b/src/avfoundation.cs @@ -9945,11 +9945,11 @@ interface AVPlayerItemVideoOutput { [Export ("delegateQueue"), NullAllowed] DispatchQueue DelegateQueue { get; } - [Internal, Static] + [Internal] [Export ("initWithPixelBufferAttributes:")] IntPtr _FromPixelBufferAttributes ([NullAllowed] NSDictionary pixelBufferAttributes); - [Internal, Static] + [Internal] [Export ("initWithOutputSettings:")] IntPtr _FromOutputSettings ([NullAllowed] NSDictionary outputSettings); diff --git a/tests/monotouch-test/AVFoundation/PlayerItemVideoOutputTest.cs b/tests/monotouch-test/AVFoundation/PlayerItemVideoOutputTest.cs new file mode 100644 index 000000000000..bd0c00fd25a9 --- /dev/null +++ b/tests/monotouch-test/AVFoundation/PlayerItemVideoOutputTest.cs @@ -0,0 +1,44 @@ +// +// Unit tests for AVPlayerItemVideoOutput +// +// Authors: +// Sebastien Pouliot +// +// Copyright 2016 Xamarin Inc. All rights reserved. +// + +#if !__WATCHOS__ + +using System; +#if XAMCORE_2_0 +using AVFoundation; +using CoreVideo; +using Foundation; +using UIKit; +#else +using MonoTouch.AVFoundation; +using MonoTouch.CoreVideo; +using MonoTouch.Foundation; +using MonoTouch.UIKit; +#endif +using NUnit.Framework; + +namespace MonoTouchFixtures.AVFoundation { + + [TestFixture] + [Preserve (AllMembers = true)] + public class PlayerItemVideoOutputTest { + + [Test] + public void Ctor_CVPixelBufferAttributes () + { + var attributes = new CVPixelBufferAttributes () { + PixelFormatType = CVPixelFormatType.CV32BGRA + }; + using (var output = new AVPlayerItemVideoOutput (attributes)) + Assert.That (output.Handle, Is.Not.EqualTo (IntPtr.Zero), "valid"); + } + } +} + +#endif // !__WATCHOS__ diff --git a/tests/monotouch-test/monotouch-test.csproj b/tests/monotouch-test/monotouch-test.csproj index 27e700c367e2..ea16af810f85 100644 --- a/tests/monotouch-test/monotouch-test.csproj +++ b/tests/monotouch-test/monotouch-test.csproj @@ -644,6 +644,7 @@ + From ddeef2fe5d3a2c4ab48ebf6d3cdfa05a6aa7e7ba Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 1 Dec 2016 15:10:24 -0500 Subject: [PATCH 2/2] Call base(NSObjectFlag.Empty) to avoid running before the real --- src/AVFoundation/AVPlayerItemVideoOutput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AVFoundation/AVPlayerItemVideoOutput.cs b/src/AVFoundation/AVPlayerItemVideoOutput.cs index a5c554c29c2c..49e1ecef022c 100644 --- a/src/AVFoundation/AVPlayerItemVideoOutput.cs +++ b/src/AVFoundation/AVPlayerItemVideoOutput.cs @@ -15,7 +15,7 @@ enum InitMode { OutputSettings } - AVPlayerItemVideoOutput (NSDictionary data, AVPlayerItemVideoOutput.InitMode mode) : this () + AVPlayerItemVideoOutput (NSDictionary data, AVPlayerItemVideoOutput.InitMode mode) : base (NSObjectFlag.Empty) { switch (mode) { case InitMode.PixelAttributes: