Esempio n. 1
0
MediaCodecList::MediaCodecList()
    : mInitCheck(NO_INIT) {
    FILE *file = fopen("/etc/media_codecs.xml", "r");

    if (file == NULL) {
        ALOGW("unable to open media codecs configuration xml file.");
        return;
    }

    parseXMLFile(file);

    if (mInitCheck == OK) {
        // These are currently still used by the video editing suite.

        addMediaCodec(true /* encoder */, "AACEncoder", "audio/mp4a-latm");

        addMediaCodec(
                false /* encoder */, "OMX.google.raw.decoder", "audio/raw");
    }
	
	// for CTS 
#ifndef ANDROID_DEFAULT_CODE
#ifdef MTK_REMOVE_WMA_COMPONENT
		ALOGD("ASF BUILD OPTION IS CLOSED");
		const char* wma_name = "OMX.MTK.AUDIO.DECODER.WMA";
		size_t indexForWma = findCodecByName(wma_name);
		if(indexForWma >= 0)
			mCodecInfos.removeAt(indexForWma);
#endif
#ifndef MTK_AUDIO_RAW_SUPPORT
		ALOGD("PCM Component BUILD OPTION IS CLOSED");
		const char* pcm_name = "OMX.MTK.AUDIO.DECODER.RAW";
		size_t indexForRaw = findCodecByName(pcm_name);
		if(indexForRaw >= 0)
			mCodecInfos.removeAt(indexForRaw);
#endif
#endif

#if 0
    for (size_t i = 0; i < mCodecInfos.size(); ++i) {
        const CodecInfo &info = mCodecInfos.itemAt(i);

        AString line = info.mName;
        line.append(" supports ");
        for (size_t j = 0; j < mTypes.size(); ++j) {
            uint32_t value = mTypes.valueAt(j);

            if (info.mTypes & (1ul << value)) {
                line.append(mTypes.keyAt(j));
                line.append(" ");
            }
        }

        ALOGI("%s", line.c_str());
    }
#endif

    fclose(file);
    file = NULL;
}
Esempio n. 2
0
status_t MediaCodecList::deleteByType(const char *name)
{
    ALOGD("deleteByType: name is %s", name);
    for(;;)
    {
        ssize_t index = findCodecByName(name);
        if(index >= 0)
        {
            mCodecInfos.removeAt(index);
        }
        else
            break;
    }

    return OK;
}
status_t BnMediaCodecList::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
        case COUNT_CODECS:
        {
            CHECK_INTERFACE(IMediaCodecList, data, reply);
            size_t count = countCodecs();
            if (count > INT32_MAX) {
                count = INT32_MAX;
            }
            reply->writeInt32(count);
            return NO_ERROR;
        }
        break;

        case GET_CODEC_INFO:
        {
            CHECK_INTERFACE(IMediaCodecList, data, reply);
            size_t index = static_cast<size_t>(data.readInt32());
            const sp<MediaCodecInfo> info = getCodecInfo(index);
            if (info != NULL) {
                reply->writeInt32(OK);
                info->writeToParcel(reply);
            } else {
                reply->writeInt32(-ERANGE);
            }
            return NO_ERROR;
        }
        break;

        case FIND_CODEC_BY_TYPE:
        {
            CHECK_INTERFACE(IMediaCodecList, data, reply);
            const char *type = data.readCString();
            bool isEncoder = static_cast<bool>(data.readInt32());
            size_t startIndex = static_cast<size_t>(data.readInt32());
            ssize_t index = findCodecByType(type, isEncoder, startIndex);
            if (index > INT32_MAX || index < 0) {
                index = NAME_NOT_FOUND;
            }
            reply->writeInt32(index);
            return NO_ERROR;
        }
        break;

        case FIND_CODEC_BY_NAME:
        {
            CHECK_INTERFACE(IMediaCodecList, data, reply);
            const char *name = data.readCString();
            ssize_t index = findCodecByName(name);
            if (index > INT32_MAX || index < 0) {
                index = NAME_NOT_FOUND;
            }
            reply->writeInt32(index);
            return NO_ERROR;
        }
        break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}