Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get the roles of codec information in Android NDK?
    text
    copied!<p>In Android 4.0(API level 15), there is no API to get the codec list. <a href="http://developer.android.com/reference/android/media/MediaCodecList.html" rel="nofollow">New API</a> only support API level 16 and later. But I have to support API level 15. So I have to use JNI to write some native code referring <a href="http://androidxref.com/4.0.4/xref/frameworks/base/media/libstagefright/omx/OMXMaster.cpp" rel="nofollow">here</a>.</p> <pre><code>struct OMXPluginBase { OMXPluginBase() {} virtual ~OMXPluginBase() {} virtual void dummy1() = 0; virtual void dummy2() = 0; virtual OMX_ERRORTYPE enumerateComponents( OMX_STRING name, size_t size, OMX_U32 index) = 0; virtual OMX_ERRORTYPE getRolesOfComponent( const char *name, Vector&lt;String8&gt; *roles) = 0; private: OMXPluginBase(const OMXPluginBase &amp;); OMXPluginBase &amp;operator=(const OMXPluginBase &amp;); }; </code></pre> <p>The code to get the name of the codec information:</p> <pre><code>void *handle = dlopen("libstagefrighthw.so", RTLD_NOW); if (handle == NULL) { return -1; } typedef OMXPluginBase *(*CreateOMXPluginFunc)(); CreateOMXPluginFunc createOMXPlugin = (CreateOMXPluginFunc)dlsym(handle, "createOMXPlugin"); if (!createOMXPlugin) { createOMXPlugin = (CreateOMXPluginFunc)dlsym( handle, "_ZN7android15createOMXPluginEv"); } OMXPluginBase *plugin = (*createOMXPlugin)(); if (plugin) { OMX_U32 index = -1; char name[128]; OMX_ERRORTYPE err; while ((err = plugin-&gt;enumerateComponents(name, sizeof(name), ++index)) == OMX_ErrorNone) { printf("%s\n", name); } if (err != OMX_ErrorNoMore) { printf("0x%x\n", err); } } </code></pre> <p>I can get the name of the codec information since the name is just of type <code>char *</code>. However, now I want to get the roles of the codec information using the function <code>OMX_ERRORTYPE getRolesOfComponent(const char *name, Vector&lt;String8&gt; *roles)</code> but I cannot do that because <code>roles</code> is of type <code>Vector&lt;String8&gt;</code> and I don't have this two class. More seriously, Android seems not provide the implementation of this two class in some shared library like <code>libutils.so</code>. So how can I call this function and get the information I want? Please help me. I have got headache for this for a whole day!</p> <p><strong>Update</strong></p> <p>Thanks to @Alex, finally I solved my problem. I put the code <a href="https://gist.github.com/itlodge/7652195" rel="nofollow">here</a>. Hope this will help those who met the same problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload