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

CMSampleAttachmentKey should be public #4688

Closed
lobrien opened this issue Aug 23, 2018 · 2 comments
Closed

CMSampleAttachmentKey should be public #4688

lobrien opened this issue Aug 23, 2018 · 2 comments
Assignees
Labels
enhancement The issue or pull request is an enhancement iOS Issues affecting Xamarin.iOS
Milestone

Comments

@lobrien
Copy link

lobrien commented Aug 23, 2018

Apple samples use kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix, which AFAICT is not publicly available in Xamarin.iOS

Steps to Reproduce

  1. Download Apple sample Tracking the User’s Face in Real Time
  2. Unzip and open ViewController.swift
  3. Navigate to captureOutput and line 462:
 let cameraIntrinsicData = CMGetAttachment(sampleBuffer, key: kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix, attachmentModeOut: nil)
  1. Create a Xamarin.iOS workbook and enter what I believe to be the equivalent code in C#:
		var cameraIntrinsicData = CMAttachmentBearer.GetAttachment(CMSampleAttachmentKey.CameraIntrinsicMatrixKey, sampleBuffer ); // typeof(sampleBuffer) is `CVSampleBuffer`
		

Expected Behavior

The code compiles.

Actual Behavior

The compiler says "CMSampleAttachmentKey is inaccessible due to its protection level."

Workaround

Use the hardcoded value "CameraIntrinsicMatrix"

Environment

=== Visual Studio Community 2017 for Mac (Preview) ===

Version 7.6 Preview (7.6 build 1773)
Installation UUID: 6b94f136-026d-4a5a-bf6d-af2c0d8dc019
Runtime:
Mono 5.12.0.273 (2018-02/f59eac4c0f1) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e)

Package version: 512000273

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.1
2.0.5
2.0.3
2.0.0
SDK: /usr/local/share/dotnet/sdk/2.1.301/Sdks
SDK Versions:
2.1.301
2.1.4
2.0.3
2.0.0
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.4.0.1 (Visual Studio Community)
Android SDK: /Users/larryobrien/Library/Android/sdk
Supported Android versions:
4.1 (API level 16)
5.0 (API level 21)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 27.0.3

Java SDK: /usr
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Apple Developer Tools ===

Xcode 10.0 (14313.2)
Build 10L213o

=== Xamarin.Mac ===

Version: 4.99.3.344 (Visual Studio Community)
Hash: 0b72651
Branch:
Build date: 2018-08-09 10:37:58-0400

=== Xamarin.iOS ===

Version: 11.99.3.224 (Visual Studio Community)
Hash: 0b72651
Branch: HEAD
Build date: 2018-08-09 10:37:57-0400

=== Build Information ===

Release ID: 706001773
Git revision: e5958ff9015312c81fc3b1b6b6413585575ca869
Build date: 2018-06-19 12:19:27+00
Build branch: release-7.6
Xamarin extensions: 6910f36b43e7d559ff40ae268e73ae26c30a2a6b

=== Operating System ===

Mac OS X 10.13.6
Darwin 17.7.0 Darwin Kernel Version 17.7.0
Thu Jun 21 22:53:14 PDT 2018
root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

AddinMaker 1.4.2
Larry's F# Templates 2.0.8
MicroFramework 1.0.3
Internet of Things (IoT) development (Preview) 7.5.3

@mandel-macaque
Copy link
Member

@lobrien what about the following:

var att = new CMSampleBufferAttachmentSettings (sampleBuffer.GetAttachments (CMAttachmentMode.ShouldNotPropagate));
var matrix = att.CameraIntrinsicMatrix;

I'm not sure about the mode, but you can create the CMSampleBufferAttachmentSettings from the NSDictionary and then used them. (could we have a performance hit?)

@mandel-macaque mandel-macaque added iOS Issues affecting Xamarin.iOS need-info Waiting for more information before the bug can be investigated labels Aug 24, 2018
@VincentDondain
Copy link
Contributor

I think what @mandel-macaque should work but that's a convoluted way to achieve what you want here. Also there's kinda no point having CMAttachmentBearer's GetAttachment public if it takes a string key but we don't make the keys you can give it public.

It doesn't cost us to open up (remove [Internal]) CMSampleAttachmentKey. It's internal because there's the strong dictionary but it's used in different way for different APIs. We probably did not know at the time that CMAttachmentBearer's GetAttachment wanted CMSampleAttachmentKey. The documentation isn't very precise on that matter: https://developer.apple.com/documentation/coremedia/1470707-cmgetattachment?language=objc

Note: we could make a smart enum out of CMSampleAttachmentKey and a new GetAttachment overload to make it easier to use. The problem is that it might take keys other than CMSampleAttachmentKey. Don't know about that.

@VincentDondain VincentDondain added enhancement The issue or pull request is an enhancement and removed need-info Waiting for more information before the bug can be investigated labels Aug 24, 2018
@VincentDondain VincentDondain added this to the Future milestone Aug 24, 2018
@mandel-macaque mandel-macaque self-assigned this Sep 19, 2018
mandel-macaque added a commit to mandel-macaque/xamarin-macios that referenced this issue Sep 19, 2018
…#4688

We have an issue when the user wants to use the CMAttachmentSample,
ideally, the user will want to do:

var cameraIntrinsicData = CMAttachmentBearer.GetAttachment(CMSampleAttachmentKey.CameraIntrinsicMatrixKey, sampleBuffer );

Instead of the current workaround:

var att = new CMSampleBufferAttachmentSettings (sampleBuffer.GetAttachments (CMAttachmentMode.ShouldNotPropagate));
var matrix = att.CameraIntrinsicMatrix;

With this push, we can allow the user use the first example provided in
this commit.

Fixes xamarin#4688
mandel-macaque added a commit to mandel-macaque/xamarin-macios that referenced this issue Sep 21, 2018
…#4688

We have an issue when the user wants to use the CMAttachmentSample,
ideally, the user will want to do:

var cameraIntrinsicData = CMAttachmentBearer.GetAttachment(CMSampleAttachmentKey.CameraIntrinsicMatrixKey, sampleBuffer );

Instead of the current workaround:

var att = new CMSampleBufferAttachmentSettings (sampleBuffer.GetAttachments (CMAttachmentMode.ShouldNotPropagate));
var matrix = att.CameraIntrinsicMatrix;

With this push, we can allow the user use the first example provided in
this commit.

Fixes xamarin#4688
mandel-macaque added a commit to mandel-macaque/xamarin-macios that referenced this issue Sep 21, 2018
…#4688

We have an issue when the user wants to use the CMAttachmentSample,
ideally, the user will want to do:

var cameraIntrinsicData = CMAttachmentBearer.GetAttachment(CMSampleAttachmentKey.CameraIntrinsicMatrixKey, sampleBuffer );

Instead of the current workaround:

var att = new CMSampleBufferAttachmentSettings (sampleBuffer.GetAttachments (CMAttachmentMode.ShouldNotPropagate));
var matrix = att.CameraIntrinsicMatrix;

With this push, we can allow the user use the first example provided in
this commit.

Fixes xamarin#4688
mandel-macaque added a commit that referenced this issue Sep 25, 2018
…4841)

* [CoreMedia] Expose the CMSampleAttachmentKey interface. Fixes #4688

We have an issue when the user wants to use the CMAttachmentSample,
ideally, the user will want to do:

var cameraIntrinsicData = CMAttachmentBearer.GetAttachment(CMSampleAttachmentKey.CameraIntrinsicMatrixKey, sampleBuffer );

Instead of the current workaround:

var att = new CMSampleBufferAttachmentSettings (sampleBuffer.GetAttachments (CMAttachmentMode.ShouldNotPropagate));
var matrix = att.CameraIntrinsicMatrix;

With this push, we can allow the user use the first example provided in
this commit.

Fixes #4688
@ghost ghost locked as resolved and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement The issue or pull request is an enhancement iOS Issues affecting Xamarin.iOS
Projects
None yet
Development

No branches or pull requests

3 participants