title: How to get max resolution of MediaCodec before configuring
body: <p>My app create several instance of <a href="https://developer.android.com/reference/android/media/MediaCodec.html" rel="nofollow noreferrer">MediaCodec</a> which work parallel as video/audio decoders and encoders.</p>
  
  <p>I know that video codec has limiting buffer space and this limit depends on device.</p>
  
  <p>For example on tab Samsung SM-P600 I can create four MediaCodecs with resolution 720p:</p>
  
  <blockquote>
    <p>1280*720*4=3686400</p>
  </blockquote>
  
  <p>but not five:</p>
  
  <blockquote>
    <p>1280*720*5=4608000</p>
  </blockquote>
  
  <p>Because codec will return error during configuring:</p>
  
  <pre><code>E/OMX:  setParam  sum(4608000) &gt; max resolution(4177920)
  E/ACodec: [OMX.Exynos.AVC.Encoder] failed to set input port definition parameters.
  E/ACodec:  configureCodec multi window instance fail  appPid : 17054
  E/ACodec: [OMX.Exynos.AVC.Encoder] configureCodec returning error -1021
  E/ACodec: signalError(omxError 0x80001001, internalError -1021)
  E/MediaCodec: Codec reported err 0xfffffc03, actionCode 0, while in state 3
  E/MediaCodec: configure failed with err 0xfffffc03, resetting...
  </code></pre>
  
  <p>How can I get <strong>max resolution(4177920)</strong> before configuring MediaCodecs to count max available resolutions for all MediaCodecs I need?</p>