After multimedia files are parsed, you need to find the appropriate codec according to mime. 2.3 of the system has two methods: SoftwareCodec and omx node codec. The latter can be optimized with special hardware, the former seems to be relatively standard soft decoding.
Below is the code
Omxcodec. cpp
Omxcodec: create
Vector <String8> matchingCodecs; ------ all the codec sets of a mime
FindMatchingCodecs (
Mime, createEncoder, matchComponentName, flags, & matchingCodecs );
If (matchingCodecs. isEmpty ()){
Return NULL;
}
Sp <OMXCodecObserver> observer = new OMXCodecObserver;
IOMX: node_id node = 0;
Const char * componentName;
For (size_t I = 0; I <matchingCodecs. size (); ++ I) {-------- traverse all the codec in it. Generally, the node of omx is first followed by soft decoding.
ComponentName = matchingCodecs [I]. string ();
Sp <MediaSource> softwareCodec = createEncoder?
InstantiateSoftwareEncoder (componentName, source, meta ):
InstantiateSoftwareCodec (componentName, source );
If (softwareCodec! = NULL ){
LOGV ("Successfully allocated software codec '% S'", componentName );
Return softwareCodec; ----------------- soft decoding-return codec
}
LOGV ("Attempting to allocate OMX node '% S'", componentName );
Uint32_t quirks = getComponentQuirks (componentName, createEncoder );
If (! CreateEncoder
& (Quirks & kOutputBuffersAreUnreadable)
& (Flags & kClientNeedsFramebuffer )){
If (strncmp (componentName, "OMX. SEC.", 8 )){
// For OMX. SEC. * decoders we can enable a special mode that
// Gives the client access to the framebuffer contents.
LOGW ("Component '% s' does not give the client access"
"The framebuffer contents. Skipping .",
ComponentName );
Continue;
}
}
Status_t err = omx-> allocateNode (componentName, observer, & node );
If (err = OK ){
LOGV ("Successfully allocated OMX node '% S'", componentName );
Sp <OMXCodec> codec = new OMXCodec (
Omx, node, quirks,
CreateEncoder, mime, componentName,
Source); ------------------------ generate an omxcodec, which needs to be further studied later
Observer-> setCodec (codec );
Err = codec-> configureCodec (meta, flags );
If (err = OK ){
Return codec;
}
LOGV ("Failed to configure codec '% S'", componentName );
}
}
From shcalm's column