Bug 3979 - [CoreMedia] Missing ability to get Channel Layout from CMAudioFormat object
Summary: [CoreMedia] Missing ability to get Channel Layout from CMAudioFormat object
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Miguel de Icaza [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2012-03-19 16:01 UTC by Eric Beisecker
Modified: 2012-03-19 18:18 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Eric Beisecker 2012-03-19 16:01:30 UTC
Reference.
https://developer.apple.com/library/mac/#documentation/CoreMedia/Reference/CMFormatDescription/Reference/reference.html

In order to save audio with compression settings we need the ability to get the ChannelLayoutData from a CMAudioFormat object.

Whats Missing:
    Ability to get NSData object of the CurrentChannelLayoutData. (currentChannelLayoutData = NSData.FromBytes(currentChannelLayout, currentChannelLayout.Size);
    AVAudioSettings.AVChannelLayout


Sample Code:

AudioChannelLayout currentChannelLayout = currentFormatDescription.AudioChannelLayout; 
NSData currentChannelLayoutData = null;
				
// AVChannelLayoutKey must be specified, but if we don't know any better give an empty data and let AVAssetWriter decide.
if(currentChannelLayout != null)
   currentChannelLayoutData = NSData.FromBytes(currentChannelLayout, currentChannelLayout); // Cannot current get a IntPtr to the Channel Layout 
else
   currentChannelLayoutData = new NSData();

NSDictionary audioCompressionSettings = NSDictionary.FromObjectsAndKeys (
new Object[]
{ 
	  NSNumber.FromInt32 ((int)AudioFormatType.MPEG4AAC), 
	  NSNumber.FromDouble (currentASBD.SampleRate), 
	  NSNumber.FromInt32 (64000),
	  NSNumber.FromInt32 (currentASBD.ChannelsPerFrame),
          currentChannelayoutData // Where ChannelLayoutData is required
},
new Object[]
{ 
	AVAudioSettings.AVFormatIDKey,
	AVAudioSettings.AVSampleRateKey,
	AVAudioSettings.AVEncoderBitRateKey,
	AVAudioSettings.AVNumberOfChannelsKey,
        AVAudioSettings.AVChannelLayout // Missing
});
Comment 1 Miguel de Icaza [MSFT] 2012-03-19 18:18:59 UTC
I just added a method:

AudioChannelLayout.AsData ()

That will return the data in NSData form.