title: Audio Queue Services recording to .mp4 file, that cannot be play. And Magic Cookie issue
body: <p>I am a newbie Mac programmer just for 3 months. I got a Audio Queue Services problem, hope anyone can help me.</p>
  <p>I using Audio Queue Services API created a recording program, and output AAC format data. It's seems good, everything work fine.</p>
  <p>Until I get to use the <strong><a href="http://code.google.com/p/mp4v2/" rel="nofollow noreferrer">MP4V2</a></strong> Library(an open source library) to output a .mp4 file, the problem is occur.</p>
  <p>Problem 1:</p>
  <blockquote>
  <p>I use <strong>magic cookie</strong> as a AAC header
  to input to MP4V2 library function
  <strong>MP4WriteSample()</strong>. Inside the .mp4 file has data, but the
  player(ex:Quicktime) <strong>can't</strong> recognized
  the .mp4 file, it can't play the audio data.</p>
  </blockquote>
  <hr />
  <p>Problem 2:</p>
  <p>I set my audio queue basic descriptions format in following :</p>
  <pre><code>    aqData.mDataFormat.mSampleRate = 44100.0;
      aqData.mDataFormat.mFormatID = kAudioFormatMPEG4AAC;  // AAC codec.
      aqData.mDataFormat.mChannelsPerFrame = 2;
      aqData.mDataFormat.mFramesPerPacket = 1024;
  </code></pre>
  <p>and use AudioQueueGetProperty() to get magic cookie.</p>
  <p>Than I print out my <strong>magic cookie</strong> contants, like that:</p>
  <pre><code>    &lt;03808080 22000000 04808080 14401500 18000001 f4000001 f4000580 80800212 10068080 800102&gt;
  </code></pre>
  <p>total 39 Bytes.</p>
  <blockquote>
  <p>What exactly it mean?</p>
  <p>What the 39 Bytes each represented mean?</p>
  <p>Can it convert to AAC header?</p>
  </blockquote>
  <p><em>Reference :</em></p>
  <p><em><a href="http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQRecord/RecordingAudio.html#//apple_ref/doc/uid/TP40005343-CH4-SW1" rel="nofollow noreferrer">Set a Magic Cookie for an Audio File</a></em></p>
  <p><em><a href="http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQPlayback/PlayingAudio.html#//apple_ref/doc/uid/TP40005343-CH3-SW1" rel="nofollow noreferrer">Set a Magic Cookie for a Playback Audio Queue</a></em></p>
  <p><em><a href="https://stackoverflow.com/questions/4189292/coreaudio-how-to-determine-the-end-of-the-playing-aac-file">CoreAudio - how to determine the end of the playing aac file</a></em></p>
  <hr />
  <p>Thanks a lot.</p>
  <p>Ryan</p>