Skip to content

Commit

Permalink
Added HE-AACv2 detection (and playing) on iOS 4 for devices that supp…
Browse files Browse the repository at this point in the history
…ort it. Made use of the UIDevice Hardware extensions by vauto (http://github.com/vauto/uidevice-extension)
  • Loading branch information
iDev Software authored and Grant Pannell committed Aug 24, 2010
1 parent 601eb18 commit e42c47d
Show file tree
Hide file tree
Showing 4 changed files with 788 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Classes/AudioStreamer.m
Expand Up @@ -15,6 +15,10 @@
#import "AudioStreamer.h"
#ifdef TARGET_OS_IPHONE
#import <CFNetwork/CFNetwork.h>
#import "UIDevice+Hardware.h"
#ifndef kCFCoreFoundationVersionNumber_iPhoneOS_4_0
#define kCFCoreFoundationVersionNumber_iPhoneOS_4_0 550.32
#endif
#endif

#define BitRateEstimationMaxPackets 5000
Expand Down Expand Up @@ -1944,7 +1948,18 @@ - (void)handlePropertyChangeForFileStream:(AudioFileStreamID)inAudioFileStream
{
AudioStreamBasicDescription pasbd = formatList[i].mASBD;

if (pasbd.mFormatID == kAudioFormatMPEG4AAC_HE)
if(pasbd.mFormatID == kAudioFormatMPEG4AAC_HE_V2 &&
[[UIDevice currentDevice] platformHasCapability:(UIDeviceSupportsARMV7)] &&
kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iPhoneOS_4_0)
{
// We found HE-AAC v2 (SBR+PS), but before trying to play it
// we need to make sure that both the hardware and software are
// capable of doing so...
#if !TARGET_IPHONE_SIMULATOR
asbd = pasbd;
#endif
break;
} else if (pasbd.mFormatID == kAudioFormatMPEG4AAC_HE)
{
//
// We've found HE-AAC, remember this to tell the audio queue
Expand Down
136 changes: 136 additions & 0 deletions Classes/UIDevice+Hardware.h
@@ -0,0 +1,136 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 3.0 Edition
BSD License, Use at your own risk
*/

#import <UIKit/UIKit.h>

#define IFPGA_NAMESTRING @"iFPGA"

#define IPHONE_1G_NAMESTRING @"iPhone 1G"
#define IPHONE_3G_NAMESTRING @"iPhone 3G"
#define IPHONE_3GS_NAMESTRING @"iPhone 3GS"
#define IPHONE_4G_NAMESTRING @"iPhone 4"
#define IPHONE_FUTURE_NAMESTRING @"Future iPhone"
#define IPHONE_UNKNOWN_NAMESTRING @"Unknown iPhone"

#define IPOD_1G_NAMESTRING @"iPod touch 1G"
#define IPOD_2G_NAMESTRING @"iPod touch 2G"
#define IPOD_2GPLUS_NAMESTRING @"iPod touch 2G Plus"
#define IPOD_3G_NAMESTRING @"iPod touch 3G"
#define IPOD_4G_NAMESTRING @"iPod touch 4G"
#define IPOD_FUTURE_NAMESTRING @"Future iPod"
#define IPOD_UNKNOWN_NAMESTRING @"Unknown iPod"

#define IPAD_1G_NAMESTRING @"iPad 1G"
#define IPAD3G_1G_NAMESTRING @"iPad3G 1G"
#define IPAD_FUTURE_NAMESTRING @"Future iPad"
#define IPAD_UNKNOWN_NAMESTRING @"Unknown iPad"

#define IPOD_FAMILY_UNKNOWN_DEVICE @"Unknown device in the iPhone/iPod family"

#define IPHONE_SIMULATOR_NAMESTRING @"iPhone Simulator"
#define IPHONE_SIMULATOR_IPHONE_NAMESTRING @"iPhone Simulator"
#define IPHONE_SIMULATOR_IPAD_NAMESTRING @"iPad Simulator"

typedef enum {
UIDeviceUnknown,
UIDeviceiPhoneSimulator,
UIDeviceiPhoneSimulatoriPhone,
UIDeviceiPhoneSimulatoriPad,
UIDevice1GiPhone,
UIDevice3GiPhone,
UIDevice3GSiPhone,
UIDevice4GiPhone,
UIDevice1GiPod,
UIDevice2GiPod,
UIDevice2GPlusiPod,
UIDevice3GiPod,
UIDevice4GiPod,
UIDevice1GiPad,
UIDevice1GiPad3G,
UIDeviceUnknowniPhone,
UIDeviceUnknowniPod,
UIDeviceUnknowniPad,
UIDeviceIFPGA,
// These constants are for devices we know to be new and probably supersets of their predecessors...
UIDeviceFutureiPhone,
UIDeviceFutureiPod,
UIDeviceFutureiPad
} UIDevicePlatform;

typedef enum {
UIDeviceFirmware2,
UIDeviceFirmware3,
UIDeviceFirmware4,
} UIDeviceFirmware;

// TODO: need to represent this some other way. We're capped at 32 bits for C enums on a 32-bit platform.
// See http://stackoverflow.com/questions/366017/what-is-the-size-of-an-enum-in-c
typedef enum {
UIDeviceUnknownCapabilities = 0ULL,

UIDeviceSupportsTelephony = 1 << 0,
UIDeviceSupportsSMS = 1 << 1,
UIDeviceSupportsStillCamera = 1 << 2,
UIDeviceSupportsAutofocusCamera = 1 << 3,
UIDeviceSupportsVideoCamera = 1 << 4,
UIDeviceSupportsWifi = 1 << 5,
UIDeviceSupportsAccelerometer = 1 << 6,
UIDeviceSupportsLocationServices = 1 << 7,
UIDeviceSupportsGPS = 1 << 8,
UIDeviceSupportsMagnetometer = 1 << 9,
UIDeviceSupportsBuiltInMicrophone = 1 << 10,
UIDeviceSupportsExternalMicrophone = 1 << 11,
UIDeviceSupportsOPENGLES1_1 = 1 << 12,
UIDeviceSupportsOPENGLES2 = 1 << 13,
UIDeviceSupportsBuiltInSpeaker = 1 << 14,
UIDeviceSupportsVibration = 1 << 15,
UIDeviceSupportsBuiltInProximitySensor = 1 << 16,
UIDeviceSupportsAccessibility = 1 << 17,
UIDeviceSupportsVoiceOver = 1 << 18,
UIDeviceSupportsVoiceControl = 1 << 19,
UIDeviceSupportsBrightnessSensor = 1 << 20,
UIDeviceSupportsPeerToPeer = 1 << 21,
UIDeviceSupportsARMV7 = 1 << 22,
UIDeviceSupportsEncodeAAC = 1 << 23,
UIDeviceSupportsBluetooth = 1 << 24,
UIDeviceSupportsNike = 1 << 25,
UIDeviceSupportsPiezoClicker = 1 << 26,
UIDeviceSupportsVolumeButtons = 1 << 27,
UIDeviceSupportsEnhancedMultitouch = 1 << 28, // http://www.boygeniusreport.com/2010/01/13/apples-tablet-is-an-iphone-on-steroids/
UIDeviceSupportsCameraFlash = 1 << 29,
UIDeviceSupportsDisplayPort = 1 << 30,
UIDeviceSupportsFrontFacingCamera = 1 << 31,
// UIDeviceSupportsGyroscope = 1 << 32
} UIDeviceCapabilities;

/*
NOT Covered:
launch-applications-while-animating, load-thumbnails-while-scrolling,
delay-sleep-for-headset-click, Unified iPod, standalone contacts,
fcc-logos-via-software, gas-gauge-battery & hiccough-interval
*/

@interface UIDevice (Hardware)
- (NSString *) platform;
- (NSUInteger) platformType;
+ (UIDeviceCapabilities) platformCapabilities: (UIDevicePlatform) platform;
- (UIDeviceCapabilities) platformCapabilities;
- (NSString *) platformString;
- (NSString *) platformCode;

- (NSArray *) capabilityArray;
- (BOOL) platformHasCapability:(UIDeviceCapabilities)capability;

- (NSUInteger) cpuFrequency;
- (NSUInteger) busFrequency;
- (NSUInteger) totalMemory;
- (NSUInteger) userMemory;

- (NSNumber *) totalDiskSpace;
- (NSNumber *) freeDiskSpace;

- (NSString *) macaddress;
@end

0 comments on commit e42c47d

Please sign in to comment.