Core Audio input: Added Codec info reporting
parent
cb70b066d7
commit
0ec1ae4c47
|
@ -21,6 +21,7 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <AudioToolbox/AudioFile.h>
|
||||
#include <AudioToolbox/AudioFormat.h>
|
||||
#include <AudioToolbox/ExtendedAudioFile.h>
|
||||
|
||||
#import "Plugin.h"
|
||||
|
@ -43,6 +44,8 @@
|
|||
int channels;
|
||||
float frequency;
|
||||
long totalFrames;
|
||||
|
||||
NSString* codec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -133,12 +133,13 @@ static SInt64 getSizeProc(void* clientData) {
|
|||
{
|
||||
OSStatus err;
|
||||
UInt32 size;
|
||||
UInt32 asbdSize;
|
||||
AudioStreamBasicDescription asbd;
|
||||
AudioFileID afi;
|
||||
|
||||
// Get input file information
|
||||
size = sizeof(asbd);
|
||||
err = ExtAudioFileGetProperty(_in, kExtAudioFileProperty_FileDataFormat, &size, &asbd);
|
||||
asbdSize = sizeof(asbd);
|
||||
err = ExtAudioFileGetProperty(_in, kExtAudioFileProperty_FileDataFormat, &asbdSize, &asbd);
|
||||
if(err != noErr) {
|
||||
err = ExtAudioFileDispose(_in);
|
||||
return NO;
|
||||
|
@ -183,6 +184,23 @@ static SInt64 getSizeProc(void* clientData) {
|
|||
|
||||
bitrate = (_bitrate + 500) / 1000;
|
||||
|
||||
CFStringRef formatName;
|
||||
size = sizeof(formatName);
|
||||
err = AudioFormatGetProperty(kAudioFormatProperty_FormatName, asbdSize, &asbd, &size, &formatName);
|
||||
if(err != noErr) {
|
||||
err = ExtAudioFileDispose(_in);
|
||||
return NO;
|
||||
}
|
||||
|
||||
codec = (__bridge NSString *)formatName;
|
||||
|
||||
CFRelease(formatName);
|
||||
|
||||
NSRange range = [codec rangeOfString:@","];
|
||||
if (range.location != NSNotFound) {
|
||||
codec = [codec substringToIndex:range.location];
|
||||
}
|
||||
|
||||
// Set our properties
|
||||
bitsPerSample = formatBitsPerSample;
|
||||
channels = asbd.mChannelsPerFrame;
|
||||
|
@ -307,6 +325,7 @@ static SInt64 getSizeProc(void* clientData) {
|
|||
[NSNumber numberWithFloat:frequency],@"sampleRate",
|
||||
[NSNumber numberWithLong:totalFrames],@"totalFrames",
|
||||
[NSNumber numberWithBool:YES], @"seekable",
|
||||
codec, @"codec",
|
||||
floatingPoint ? @"host" : @"big", @"endian",
|
||||
nil];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue