User talk:KennyTM~

From iPhone Development Wiki
Jump to: navigation, search

Dear Kenny,

I have an idea of an application which can record audio stream of the phone call. What do you think? Is it realistic?

From the list of the devices I can see that iPhone has "AppleBasebandAudio" device. I can open this device. I wrote a simple application based on your FLASH example but I cannot find selector address anywhere.

#include <stdlib.h>
#include <stdio.h>
#include <CoreFoundation/CFDictionary.h>
#include <IOKit/IOKitLib.h>

int main(int argc, char *argv[])
  // Get the service named "AppleBasebandAudio".
  CFMutableDictionaryRef matching = IOServiceMatching("AppleBasebandAudio");
  io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);

  // Open a connection to the AppleBasebandAudio service
  io_connect_t connect;
  kern_return_t errcode = IOServiceOpen(service, mach_task_self(), 0, &connect);

  // Send some message to the service and get the result.
  // using one of the IOConnectCall*** methods.
  if (errcode == 0) {

    size_t infoSize;
    size_t osize = sizeof(infoSize);
    errcode = IOConnectCallStructMethod(
                                      connect, 0xFE000200, // selector
                                      NULL, 0,             // input
                                      &infoSize, &osize);  // output
    if (errcode == 0) {
      void* info = malloc(infoSize);
      IOConnectCallStructMethod(connect, 0xFE000100, NULL, 0, info, &infoSize);

      // do_something_with(info);
      FILE *f;
      f = fopen ( "audioBuf.bin", "wb" ) ;
      if ( f == NULL )
        printf ( "Cannot open source file" ) ;
        fclose ( f ) ;
        exit ( 1 );
        fwrite( info, sizeof(char), infoSize, f );
      printf("Error code 1 %i\n", errcode);

    printf("Error code 2 %i\n", errcode);


  return 0;

I'm still puzzled with the selector. What address should I use?

Is this the right device responsible for the audio during phone call? Is there any event generated when the the phone accepts/makes a phone call? I looked at the files in \IOKit\hid\ but could not find any phone call specific events.

Could you advice some documentation which might help me? I would be grateful any information on this topic.

Kind regards,


I don't think you can get the audio streams via IOHID. IOHID is meant to pass messages or similar Even on a mac there is no straight forward solution for capturing audio. Instead developers of apps like Sunflower and Jock OS X had to go via coding drivers (either kext or userland), making that driver accept the audio stream of apps...