<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I've been trying to add audio capturing to the qtcapture module. So far, I can successfully initialize my audio device, add it to the QTCaptureSession (<span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">p_sys->session</span>), add it to the elementary stream (<span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">es_out_Add</span>) and control/send data (<span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">es_out_Control / </span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">es_out_Send</span>). I've created another audio interface just like the working VLCDecompressedVideoOutput (<span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "><span style="color: #bc319c">@interface</span></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "> VLCDecompressedAudioOutput : QTCaptureDecompressedAudioOutput</span>) with the QTKit delegate method:  <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">- (</span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "><span style="color: #bc319c">void</span></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection;</span>. It gets called and I read the <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">AudioBufferList</span> from the passed <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">(QTSampleBuffer *)sampleBuffer</span> . From this point on I am having problems correctly passing the raw audio Bytes to the Buffer with (<span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">- (mtime_t)copyCurrentAudioBytesToBuffer:(</span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "><span style="color: #bc319c">void</span></span><span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; "> *)buffer</span>) . I created a new AudioBuffer which I fill with the data given by the sampleBuffer and work with that.</div><div><br></div><div>However when listening to the audio data it's all scrambled artefacts. Am I passing the correct data; using the correct acodec?</div><div><br></div><div>I've looked at other modules such as (dc1394.c; auhal.c and araw.c) to try and understand how audio data is being processed there.</div><div>The <span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">QTFormatDescriptionAudioStreamBasicDescriptionAttribute</span> returns the following data for the QTSampleBuffer:</div><div><br></div><div><div>2011-07-29 14:52:39.983 VLC[11466:ee0b]   Format ID:                 lpcm</div><div>2011-07-29 14:52:39.983 VLC[11466:ee0b]   Format Flags:                29</div><div>2011-07-29 14:52:39.984 VLC[11466:ee0b]   Bytes per Packet:             4</div><div>2011-07-29 14:52:39.984 VLC[11466:ee0b]   Frames per Packet:            1</div><div>2011-07-29 14:52:39.984 VLC[11466:ee0b]   Bytes per Frame:              4</div><div>2011-07-29 14:52:39.985 VLC[11466:ee0b]   Channels per Frame:           2</div><div>2011-07-29 14:52:39.985 VLC[11466:ee0b]   Bits per Channel:            32</div></div><div><br></div><div>I've also looked into Apple example projects such as: <a href="http://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html">http://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html</a> to see how they work with the AudioBuffer and so.</div><div>As I am no C expert (actually I have no experience in C) and only have experience with basic Objective-C and Java, I am kind of stuck here. I've attached my qtcapture.m file (I know it's probably really bad code - I've been shamelessly trying to hack till it works).</div><div><br></div><div>If someone could point me in the right direction or help me out with the last step of copying the audio data to the buffer I would be really grateful.</div><div><br></div><div>To my understanding the workflow would work as follows:</div><div>- in the delegate method from QTKit somehow get the correct audioBytes (from Core Audio AudioBuffer)</div><div>- calculate/get the correct i_pts</div><div>- copy those bytes to buffer (<span class="Apple-style-span" style="font-family: Menlo; font-size: 11px; ">copyCurrentAudioBytesToBuffer</span>)</div><div>- in Demux send i_pts and buffer</div><div><br></div><div>Thanks for your time!</div><div><br></div><div>Regards</div><div>Michael Feurstein</div></body></html>