title: How to get the right channel while encoding AAC-HE-V1 by fdk on iOS?
body: <p>I use the fdk v2.0.101 to encode the AAC-HE-V1 on iOS by xcode Version 8.0 (8A218a), but i always got the stereo channel aac data even if i set mono as the channel. </p>
  
  <p>How to get the right channel while encoding AAC-HE-V1 by fdk?</p>
  
  <p>PS: AAC-LC is OK. Tested on iPhone 6 with iOS 9.3.</p>
  
  <p>The following is the code snippet:</p>
  
  <p>initialization part</p>
  
  <pre><code>    UINT channels = 1;
      HANDLE_AACENCODER encoder_handle;
      AACENC_InfoStruct encoder_info;
  
      int HE_AACv1 = 5;
  
      TRANSPORT_TYPE transport_type = TT_MP4_ADTS;
  
      CHANNEL_MODE mode;
  
      switch (channels) {
          case 1: mode = MODE_1;       break;
          case 2: mode = MODE_2;       break;
          case 3: mode = MODE_1_2;     break;
          case 4: mode = MODE_1_2_1;   break;
          case 5: mode = MODE_1_2_2;   break;
          case 6: mode = MODE_1_2_2_1; break;
      }
  
      CheckError(aacEncOpen(&amp;encoder_handle, 0, channels), @"Unable to open encoder : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_AOT, HE_AACv1), @"Unable to set the AOT : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_SAMPLERATE, 44100),
                 @"Unable to set the sample rate : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_CHANNELMODE, mode),
                 @"Unable to set the channel mode : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_CHANNELORDER, 1),
                 @"Unable to set the wav channel order : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_BITRATE, 90000),
                 @"Unable to set the bitrate : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_TRANSMUX, transport_type),
                 @"Unable to set the ADTS transmux : %i");
      CheckError(aacEncoder_SetParam(encoder_handle, AACENC_AFTERBURNER, 1),
                 @"Unable to set the afterburner mode : %i");
      CheckError(aacEncEncode(encoder_handle, NULL, NULL, NULL, NULL),
                 @"Unable to initialize the encoder : %i");
      CheckError(aacEncInfo(encoder_handle, &amp;encoder_info), @"Unable to get the encoder info : %i");
  </code></pre>
  
  <p>Enocoding part:</p>
  
  <pre><code>  AudioBuffer originBuffer = ...;
  
    AACENC_OutArgs out_args = { 0 };
    AACENC_ERROR err;
  
    int out_identifier = OUT_BITSTREAM_DATA;
  
    uint8_t *output_data = calloc(encoder_info.maxOutBufBytes, 1);
  
    int read = originBuffer.mDataByteSize;
  
    void *in_ptr = originBuffer.mData;
    int in_size = read;
    int in_elem_size = _sampleBytes;
  
    int in_identifier = IN_AUDIO_DATA;
  
    AACENC_InArgs in_args = { 0 };
    in_args.numInSamples = read / _sampleBytes;
  
    AACENC_BufDesc in_buf = { 0 }, out_buf = { 0 };
    in_buf.numBufs = 1;
    in_buf.bufs = &amp;in_ptr;
    in_buf.bufferIdentifiers = &amp;in_identifier;
    in_buf.bufSizes = &amp;in_size;
    in_buf.bufElSizes = &amp;in_elem_size;
  
    void *out_ptr;
    int out_size, out_elem_size;
  
    out_ptr = output_data;
    out_size = _encoder_info.maxOutBufBytes;
    out_elem_size = _sampleBytes;
    out_buf.numBufs = 1;
    out_buf.bufs = &amp;out_ptr;
    out_buf.bufferIdentifiers = &amp;out_identifier;
    out_buf.bufSizes = &amp;out_size;
    out_buf.bufElSizes = &amp;out_elem_size;
  
    AACENC_ERROR result = aacEncEncode(_encoder_handle, &amp;in_buf, &amp;out_buf, &amp;in_args, &amp;out_args);
  
    if (result != AACENC_OK) {
        free(output_data);
        NSLog(@"FDK-AAC encode fail %i", result);
        return;
    }
    if (out_args.numOutBytes &gt; 0) {
  
        // handle output_data
  
    } else {
        free(output_data);
    }
  </code></pre>