stagefright的codec---1

多媒体文件经过解析后,需要根据mime寻找适合的codec,2.3的系统有两种方式 SoftwareCodec和omx的node codec,后者可以结合特殊硬件做优化处理,前者感觉就是比较标准的软解码。

下面是代码

omxcodec.cpp

omxcodec::create

Vector<String8> matchingCodecs;------系统对于某种mime的所有codec集合
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) {--------去其中遍历所有的codec,一般是omx的node先,然后是软解码
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;-----------------是软解码-返回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 to "
"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);------------------------生成一个omxcodec,这个需要后面再细细研究

observer->setCodec(codec);

err = codec->configureCodec(meta, flags);

if (err == OK) {
return codec;
}

LOGV("Failed to configure codec '%s'", componentName);
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值