title: Creating OMXCodec encoder in HW mode
body: <p>I'm trying to implement HW-accelrated H264 video encoding on Android ICS 4.0.4. Since MediaCodec class is not available I have to use stagefright API. But when I put <strong>HardwareCodecsOnly</strong> flag, OMXCodec::Create always returns NULL.
  If I call OMXCodec::findMatchingCodecs() with flag kHardwareCodecsOnly, I got following list:<br>
  - OMX.TI.DUCATI1.VIDEO.H264E<br>
  - OMX.qcom.7x30.video.encoder.avc<br>
  - OMX.qcom.video.encoder.avc<br>
  - OMX.TI.Video.encoder<br>
  - OMX.Nvidia.h264.encoder<br>
  - OMX.SEC.AVC.Encoder<br></p>
  
  <p>so I guess it means that HW-encoding supported by hardware.</p>
  
  <p>When I put no flags in <strong>OMXCodec::Create</strong> - codec created well, but I guess it is in software mode
  (btw, how can I check- which codec exactly was created?)</p>
  
  <p>Browsing OMXCodec sources I've found interesting lines:</p>
  
  <pre><code>if (createEncoder) {            
  sp&lt;MediaSource&gt; softwareCodec =
   InstantiateSoftwareEncoder(componentName, source, meta);
      if (softwareCodec != NULL) {   
      LOGV("Successfully allocated software codec '%s'", componentName);
      return softwareCodec;            
  }        
  }
  </code></pre>
  
  <p>it looks like for Encoder it always tries to instance Software codec first.
  What am I doing wrong? Any help wil be greatly appreciated. Thanks</p>
  
  <p>Here's a code of OMXCodec creation:</p>
  
  <pre><code>         mClient = new OMXClient();
          mClient-&gt;connect();
       logger-&gt;log("mClient.connect();");
  
        enc_meta = new MetaData;
       // frame size of target video file
      int width = 640; //720;
      int height = 480;
       int kFramerate = 15;
       int kVideoBitRate = 500000;
       int kIFramesIntervalSec = 5;
       int32_t colorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
  
      enc_meta-&gt;setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC); //MEDIA_MIMETYPE_VIDEO_MPEG4); //MEDIA_MIMETYPE_VIDEO_H263);//MEDIA_MIMETYPE_VIDEO_AVC);
      enc_meta-&gt;setInt32(kKeyWidth, width);
      enc_meta-&gt;setInt32(kKeyHeight, height);
      enc_meta-&gt;setInt32(kKeyFrameRate, kFramerate);
      enc_meta-&gt;setInt32(kKeySampleRate, 44100);
      enc_meta-&gt;setInt32(kKeyBitRate, kVideoBitRate);
      enc_meta-&gt;setInt32(kKeyStride, width);
      enc_meta-&gt;setInt32(kKeySliceHeight, height);
      enc_meta-&gt;setInt32(kKeyIFramesInterval, kIFramesIntervalSec);
      enc_meta-&gt;setInt32(kKeyColorFormat, colorFormat);
  
    mVideoSource = OMXCodec::Create(
              mClient-&gt;interface(), 
              enc_meta,
              true, 
              mSrc, 
              NULL, 
              OMXCodec::kHardwareCodecsOnly ); 
  
      logger-&gt;log("OMXCodec_CREATED result: %d", (mVideoSource!=NULL) ? 1 : 0);
  </code></pre>