Parece que no es posible.
Mi objetivo es enviar la salida a los auriculares bluetooth y registrar la entrada de ella también. Por lo que puedo ver, mis mejores opciones son: "PlayAndRecord + AllowBluetoothInput" propiedad (iPhone 4, Nokia BH-214 auricular)
Lo importante es que de acuerdo a la documentación de Apple, que siempre tiene que volver a anulación su categoría de audio cuando cambia la ruta de audio!
ESTA ES MI método detector cambio de ruta, que las impresiones: RouteChangeReasons, outputRoute, audioRout:
void RouteChangeListener(void *inClientData,
AudioSessionPropertyID inID,
UInt32 inDataSize,
const void *inData) {
if (inID == kAudioSessionProperty_AudioRouteChange) {
NSLog(@"]-----------------[ Audio Route Change ]--------------------[");
// ************************************************************************************************
// Check route change reason **********************************************************************
// ************************************************************************************************
CFDictionaryRef routeDict = (CFDictionaryRef)inData;
NSNumber* reasonValue = (NSNumber*)CFDictionaryGetValue(routeDict, CFSTR(kAudioSession_AudioRouteChangeKey_Reason));
int reason = [reasonValue intValue];
if (reason == kAudioSessionRouteChangeReason_OldDeviceUnavailable) {
NSLog(@"] Logic: audio route change reason: OldDeviceUnavailable");
}else if (reason == kAudioSessionRouteChangeReason_NewDeviceAvailable) {
NSLog(@"] Logic: audio route change reason: NewDeviceAvailable");
}else if (reason == kAudioSessionRouteChangeReason_Unknown) {
NSLog(@"] Logic: audio route change reason: Unknown");
}else if (reason == kAudioSessionRouteChangeReason_CategoryChange) {
NSLog(@"] Logic: audio route change reason: CategoryChange");
}else if (reason == kAudioSessionRouteChangeReason_Override) {
NSLog(@"] Logic: audio route change reason: Override");
}else if (reason == kAudioSessionRouteChangeReason_WakeFromSleep) {
NSLog(@"] Logic: audio route change reason: WakeFromSleep");
}else if (reason == kAudioSessionRouteChangeReason_NoSuitableRouteForCategory) {
NSLog(@"] Logic: audio route chang reasone: NoSuitableRouteForCategory");
}
// ************************************************************************************************
// Check output type ******************************************************************************
// ************************************************************************************************
CFDictionaryRef currentRouteDescriptionDictionary = nil;
UInt32 dataSize = sizeof(currentRouteDescriptionDictionary);
AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &dataSize, ¤tRouteDescriptionDictionary);
if (currentRouteDescriptionDictionary) {
CFArrayRef outputs = CFDictionaryGetValue(currentRouteDescriptionDictionary, kAudioSession_AudioRouteKey_Outputs);
if(CFArrayGetCount(outputs) > 0) {
CFDictionaryRef currentOutput = CFArrayGetValueAtIndex(outputs, 0);
CFStringRef outputType = CFDictionaryGetValue(currentOutput, kAudioSession_AudioRouteKey_Type);
if ((CFStringCompare(outputType, kAudioSessionOutputRoute_AirPlay, 0) == kCFCompareEqualTo)) { // if Airplay
NSLog(@"] Logic: output changed to Airplay");
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_BluetoothA2DP, 0) == kCFCompareEqualTo)) { // if Bluetooth A2DP
NSLog(@"] Logic: output changed to A2DP");
// Mix with others category
UInt32 doSetProperty = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(doSetProperty),&doSetProperty);
// Bluetooth support enable
UInt32 allowBluetoothInput = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,sizeof (allowBluetoothInput),&allowBluetoothInput);
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_BluetoothHFP, 0) == kCFCompareEqualTo)) { // if Bluetooth HFP
NSLog(@"] Logic: output changed to HFP");
// Mix with others category
UInt32 doSetProperty = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(doSetProperty),&doSetProperty);
// Bluetooth support enable
UInt32 allowBluetoothInput = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,sizeof (allowBluetoothInput),&allowBluetoothInput);
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_LineOut, 0) == kCFCompareEqualTo)) { // if Line Out
NSLog(@"] Logic: output changed to Line Out");
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_Headphones, 0) == kCFCompareEqualTo)) { // if Headphones
NSLog(@"] Logic: output changed to Headphone");
// Mix with others category
UInt32 doSetProperty = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(doSetProperty),&doSetProperty);
// Bluetooth support disable
UInt32 allowBluetoothInput = 0;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput,sizeof (allowBluetoothInput),&allowBluetoothInput);
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_BuiltInSpeaker, 0) == kCFCompareEqualTo)) { // if Built In Speaker
NSLog(@"] Logic: output changed to Built In Speaker");
// Mix with others category
UInt32 doSetProperty = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(doSetProperty),&doSetProperty);
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_USBAudio, 0) == kCFCompareEqualTo)) { // if USB audio
NSLog(@"] Logic: output changed to USB Audio");
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_HDMI, 0) == kCFCompareEqualTo)) { // if HDMI
NSLog(@"] Logic: output changed to HDMI");
}
else if ((CFStringCompare(outputType, kAudioSessionOutputRoute_BuiltInReceiver, 0) == kCFCompareEqualTo)) { // if Built in Reciever
NSLog(@"] Logic: output changed to Built in Reciever");
// Mix with others category
UInt32 doSetProperty = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(doSetProperty),&doSetProperty);
}
else { // Unknown audio type
NSLog(@"] Logic: WARNING: Unknown audio type: %@",(NSString*)outputType);
}
}
}
// ************************************************************************************************
// Check audio route ******************************************************************************
// ************************************************************************************************
UInt32 routeSize = sizeof(CFStringRef);
CFStringRef route;
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &routeSize, &route);
NSLog(@"] Logic: the audio route is: %@",(NSString*)route);
// ************************************************************************************************
NSLog(@"]--------------------------[ ]-----------------------------[");
}
}
las preguntas más interesantes e innovadores, naturalmente, quedarán sin respuesta. tendrás mucho trabajo por hacer solo. – cregox
La grabación a través del micrófono interno y la reproducción simultánea a través de los auriculares de un auricular (y el micrófono del auricular no está en uso) era imposible en iOS6. En iOS7, esto es posible a través de las extensiones de API que se encuentran en la clase AVAudioSession. –
@ Daniel S. ¿Cómo podemos grabar desde el micrófono interno y la reproducción a través de auriculares con auriculares? –