I have an app requirement that Implementing a VOIP functionality in iPhone application.

I have little bit success for connect server using socket.

I facing a few problem in that.

I have implement below code for audio recording.

-(void)open {
    NSError *error;

    m_capture = [[AVCaptureSession alloc]init];
    AVCaptureDevice *audioDev = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
    if (audioDev == nil)
    {
        printf("Couldn't create audio capture device");
        return ;
    }
    //m_capture.sessionPreset = AVCaptureSessionPresetLow;

    // create mic device
    AVCaptureDeviceInput *audioIn = [AVCaptureDeviceInput deviceInputWithDevice:audioDev error:&error];
    if (error != nil)
    {
        printf("Couldn't create audio input");
        return ;
    }

    // add mic device in capture object
    if ([m_capture canAddInput:audioIn] == NO)
    {
        printf("Couldn't add audio input");
        return ;
    }

    [m_capture addInput:audioIn];
    // export audio data
    AVCaptureAudioDataOutput *audioOutput = [[AVCaptureAudioDataOutput alloc] init];
    [audioOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];

    if ([m_capture canAddOutput:audioOutput] == NO)
    {
        printf("Couldn't add audio output");
        return ;
    }

    [m_capture addOutput:audioOutput];
    [audioOutput connectionWithMediaType:AVMediaTypeAudio];
    [m_capture startRunning];
    return ;
}

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection{


}

Above code have captureOutput function. This function is continuous capture audio.

I have no idea how to send PCM Raw Audio Data to server and get back PCM Raw Audio Data and play an audio in iPhone.

Server coding is done. Server get back me PCM Raw Audio Data.

0

There are 0 answers