ios html audio支持aac,iOS检测 AAC编码支持情况

要检测iOS是否支持AAC HE的编码情况,从VideoCore摘了一段代码,稍作修改。

stackoverflow上找了个int整数转化为字符的宏,很经典

#include

#if TARGET_RT_BIG_ENDIAN

# define FourCC2Str(fourcc) (const char[]){*((char*)&fourcc), *(((char*)&fourcc)+1), *(((char*)&fourcc)+2), *(((char*)&fourcc)+3),0}

#else

# define FourCC2Str(fourcc) (const char[]){*(((char*)&fourcc)+3), *(((char*)&fourcc)+2), *(((char*)&fourcc)+1), *(((char*)&fourcc)+0),0}

#endif

Boolean IsAACHardwareEncoderAvailable(void)

{

Boolean isAvailable = false;

OSStatus error;

// get an array of AudioClassDescriptions for all installed encoders for the given format

// the specifier is the format that we are interested in - this is 'aac ' in our case

UInt32 encoderSpecifier = kAudioFormatMPEG4AAC;

// UInt32 encoderSpecifier = kAudioFormatMPEG4AAC_HE;

// UInt32 encoderSpecifier = kAudioFormatMPEG4AAC_HE_V2;

UInt32 size;

error = AudioFormatGetPropertyInfo(kAudioFormatProperty_Encoders, sizeof(encoderSpecifier),

&encoderSpecifier, &size);

if (error) { printf("AudioFormatGetPropertyInfo kAudioFormatProperty_Encoders error %d %4.4s\n", (int)error, (char*)&error); return false; }

UInt32 numEncoders = size / sizeof(AudioClassDescription);

AudioClassDescription encoderDescriptions[numEncoders];

error = AudioFormatGetProperty(kAudioFormatProperty_Encoders, sizeof(encoderSpecifier),

&encoderSpecifier, &size, encoderDescriptions);

if (error) { printf("AudioFormatGetProperty kAudioFormatProperty_Encoders error %d %4.4s\n",

(int)error, (char*)&error); return false; }

for (UInt32 i=0; i < numEncoders; ++i) {

if (encoderDescriptions[i].mSubType == kAudioFormatMPEG4AAC &&

encoderDescriptions[i].mManufacturer == kAppleHardwareAudioCodecManufacturer) isAvailable = true;

printf("\n\n list %s %s %s \n", FourCC2Str(encoderDescriptions[i].mType), FourCC2Str(encoderDescriptions[i].mSubType), FourCC2Str(encoderDescriptions[i].mManufacturer));

}

return isAvailable;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值