mercredi 5 août 2015

CMSampleBufferRef to aac ADTs and RTP payload


Need help on below queries..

I m trying to build an RTSP based application for mac. I am capturing audio through the mac inbuilt mic using AVCaptureSession class.

I am using following code to set the delegate of the audiooutput

AVCaptureAudioDataOutput *audioOut = [[AVCaptureAudioDataOutput alloc] init];

dispatch_queue_t audioCaptureQueue = dispatch_queue_create("Audio Capture Queue", DISPATCH_QUEUE_SERIAL);
[audioOut setSampleBufferDelegate:self queue:audioCaptureQueue];
if ([self.captureWebCamSession canAddOutput:audioOut])
    [self.captureWebCamSession addOutput:audioOut];

AudioChannelLayout channelLayout;
memset(&channelLayout, 0, sizeof(AudioChannelLayout));
channelLayout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;

NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                [ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
                                [ NSNumber numberWithInt: 1 ], AVNumberOfChannelsKey,
                                [ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
                                [NSData dataWithBytes:&channelLayout length:sizeof(AudioChannelLayout)], AVChannelLayoutKey,
                                [ NSNumber numberWithInt: 128000 ], AVEncoderBitRateKey,nil];

audioOut.audioSettings = outputSettings;

Now I am getting aac encoded buffer in the

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

Now can someone tell me how can i get the aac adts data from the sample buffer and than convert it into the RTP payload which can be transferred to rtsp server for broadcasting.

Thanks in advance for any help..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire