0

I am a noob in Core Audio, AudioUnit framework and I don't have much knowledge about it so please bear it with me.

I have a requirement where I need to access the live stream coming through a remote call using webRTC. In webRTC framework there is no way to access the audio stream.

So, what I have thought is to get an access on that audio stream through Apple audio frameworks, I am thinking of grabbing the audio before sending it to the speaker. Is that possible to get the audio buffers before being sent to the speaker.

I have to modify the audio buffers with some value and send it back to the speaker.

Please help!

Jassi
  • 537
  • 8
  • 21
  • You can get much help here, but need to describe a little more of your problem and your efforts. Sure you can grab the buffers and modify them, but the method depends on the construction of your audio processing chain. If you are new to CA, this [textbook](http://www.informit.com/store/learning-core-audio-a-hands-on-guide-to-audio-programming-9780321636843) may help clarify the basic concepts with working example code to learn from. – user3078414 Jul 04 '16 at 23:30

1 Answers1

0

You can set render callback to output AudioUnit and modify the audio buffers before sending it to speakers.

AURenderCallbackStruct callbackStruct;
        callbackStruct.inputProc = inputRemoteRenderCallback;
        callbackStruct.inputProcRefCon = sourceUnit;


        AudioUnitSetProperty(outputAudioUnit,
                             kAudioUnitProperty_SetRenderCallback,
                             kAudioUnitScope_Input,
                             0,
                             &callbackStruct,
                             sizeof(callbackStruct));

and callback:

static OSStatus inputRemoteRenderCallback  (void *inRefCon,
                                       AudioUnitRenderActionFlags *ioActionFlags,
                                       const AudioTimeStamp *inTimeStamp,
                                       UInt32 inBusNumber,
                                       UInt32 inNumberFrames,
                                       AudioBufferList *ioData
                                       ) {

AudioUnit au = (AudioUnit)inRefCon;

AudioUnitRender(au,
                ioActionFlags,
                inTimeStamp,
                0,
                inNumberFrames,
                ioData);

return noErr;
}
Dmitrii
  • 85
  • 1
  • 7