From c914bbc4dbddd288c93986afa14ff06e56abb9cd Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 9 Sep 2016 17:31:57 +0200 Subject: [PATCH] [ReplayKit] Fix RPBroadcastConfiguration.VideoCompressionProperties to have the right type and provide a strongly typed version as well. (#806) The video compression property is defined as this in the headers: NSDictionary *> so I'm not sure how it ended up being bound as NSDictionary (maybe something from an earlier beta?). I'm also adding a strongly typed version of the dictionary, since the header documentation says "AVVideoCompressionPropertiesKey in for available properties.". The manual binding is required because the generator doesn't like generic weak dictionaries (it generates invalid code). --- src/ReplayKit/RPBroadcastConfiguration.cs | 55 +++++++++++++++++++++++ src/frameworks.sources | 3 ++ src/replaykit.cs | 4 +- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/ReplayKit/RPBroadcastConfiguration.cs diff --git a/src/ReplayKit/RPBroadcastConfiguration.cs b/src/ReplayKit/RPBroadcastConfiguration.cs new file mode 100644 index 0000000000..e0571b8e01 --- /dev/null +++ b/src/ReplayKit/RPBroadcastConfiguration.cs @@ -0,0 +1,55 @@ +// +// RPBroadcastConfiguration.cs: +// +// Authors: Rolf Bjarne Kvinge +// +// Copyright 2016 Xamarin Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Drawing; +using System.Diagnostics; +using System.ComponentModel; +using System.Threading.Tasks; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; + +using XamCore.Foundation; +using XamCore.AVFoundation; + +namespace XamCore.ReplayKit { + public partial class RPBroadcastConfiguration { + public AVVideoCodecSettings VideoCompressionProperties { + get { + var weak = WeakVideoCompressionProperties; + return weak == null ? null : new AVVideoCodecSettings (new NSMutableDictionary (weak)); + } + set { +#if XAMCORE_2_0 + WeakVideoCompressionProperties = value == null ? null : new NSDictionary (value.Dictionary.Handle); +#else + WeakVideoCompressionProperties = value == null ? null : new NSDictionary (value.Dictionary.Handle); +#endif + } + } + } +} diff --git a/src/frameworks.sources b/src/frameworks.sources index abef6ef05f..59c6b878fc 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1097,6 +1097,9 @@ QUICKLOOKUI_SOURCES = \ REPLAYKIT_API_SOURCES = \ ReplayKit/RPEnums.cs \ +REPLAYKIT_SOURCES = \ + ReplayKit/RPBroadcastConfiguration.cs \ + # SafariServices SAFARISERVICES_API_SOURCES = \ diff --git a/src/replaykit.cs b/src/replaykit.cs index 794d10e034..e0774208c0 100644 --- a/src/replaykit.cs +++ b/src/replaykit.cs @@ -8,6 +8,7 @@ // using System; +using XamCore.AVFoundation; using XamCore.CoreMedia; using XamCore.ObjCRuntime; using XamCore.Foundation; @@ -203,9 +204,8 @@ namespace XamCore.ReplayKit { [Export ("clipDuration")] double ClipDuration { get; set; } - // TODO review, once API documentation is available, if we can provide an easier to use strongdictionary [NullAllowed, Export ("videoCompressionProperties", ArgumentSemantic.Strong)] - NSDictionary VideoCompressionProperties { get; set; } + NSDictionary WeakVideoCompressionProperties { get; set; } } delegate void LoadBroadcastingHandler (string bundleID, string displayName, UIImage appIcon);