Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f21345e authored by Chong Zhang's avatar Chong Zhang
Browse files

save codec info during codec construction -- DO NOT MERGE

Save the codec info used to create the codec for use
when get caps is called.

bug: 74073607
Change-Id: Id12a5b96f5a00226f8cf1e71f32655a14aeac014
parent b4cf4d66
Loading
Loading
Loading
Loading
+28 −3
Original line number Diff line number Diff line
@@ -422,14 +422,12 @@ sp<MediaCodec> MediaCodec::CreateByType(
        const sp<ALooper> &looper, const AString &mime, bool encoder, status_t *err, pid_t pid,
        uid_t uid) {
    Vector<AString> matchingCodecs;
    Vector<AString> owners;

    MediaCodecList::findMatchingCodecs(
            mime.c_str(),
            encoder,
            0,
            &matchingCodecs,
            &owners);
            &matchingCodecs);

    if (err != NULL) {
        *err = NAME_NOT_FOUND;
@@ -1217,6 +1215,22 @@ status_t MediaCodec::getName(AString *name) const {
    return OK;
}

status_t MediaCodec::getCodecInfo(sp<MediaCodecInfo> *codecInfo) const {
    sp<AMessage> msg = new AMessage(kWhatGetCodecInfo, this);

    sp<AMessage> response;
    status_t err;
    if ((err = PostAndAwaitResponse(msg, &response)) != OK) {
        return err;
    }

    sp<RefBase> obj;
    CHECK(response->findObject("codecInfo", &obj));
    *codecInfo = static_cast<MediaCodecInfo *>(obj.get());

    return OK;
}

status_t MediaCodec::getMetrics(MediaAnalyticsItem * &reply) {

    reply = NULL;
@@ -2610,6 +2624,17 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
            break;
        }

        case kWhatGetCodecInfo:
        {
            sp<AReplyToken> replyID;
            CHECK(msg->senderAwaitsResponse(&replyID));

            sp<AMessage> response = new AMessage;
            response->setObject("codecInfo", mCodecInfo);
            response->postReply(replyID);
            break;
        }

        case kWhatSetParameters:
        {
            sp<AReplyToken> replyID;
+1 −7
Original line number Diff line number Diff line
@@ -307,11 +307,8 @@ static int compareSoftwareCodecsFirst(const AString *name1, const AString *name2
//static
void MediaCodecList::findMatchingCodecs(
        const char *mime, bool encoder, uint32_t flags,
        Vector<AString> *matches, Vector<AString> *owners) {
        Vector<AString> *matches) {
    matches->clear();
    if (owners != nullptr) {
        owners->clear();
    }

    const sp<IMediaCodecList> list = getInstance();
    if (list == nullptr) {
@@ -337,9 +334,6 @@ void MediaCodecList::findMatchingCodecs(
            ALOGV("skipping SW codec '%s'", componentName.c_str());
        } else {
            matches->push(componentName);
            if (owners != nullptr) {
                owners->push(AString(info->getOwnerName()));
            }
            ALOGV("matching '%s'", componentName.c_str());
        }
    }
+3 −0
Original line number Diff line number Diff line
@@ -184,6 +184,8 @@ struct MediaCodec : public AHandler {

    status_t getName(AString *componentName) const;

    status_t getCodecInfo(sp<MediaCodecInfo> *codecInfo) const;

    status_t getMetrics(MediaAnalyticsItem * &reply);

    status_t setParameters(const sp<AMessage> &params);
@@ -248,6 +250,7 @@ private:
        kWhatRequestIDRFrame                = 'ridr',
        kWhatRequestActivityNotification    = 'racN',
        kWhatGetName                        = 'getN',
        kWhatGetCodecInfo                   = 'gCoI',
        kWhatSetParameters                  = 'setP',
        kWhatSetCallback                    = 'setC',
        kWhatSetNotification                = 'setN',
+1 −2
Original line number Diff line number Diff line
@@ -74,8 +74,7 @@ struct MediaCodecList : public BnMediaCodecList {
            const char *mime,
            bool createEncoder,
            uint32_t flags,
            Vector<AString> *matchingCodecs,
            Vector<AString> *owners = nullptr);
            Vector<AString> *matchingCodecs);

    static bool isSoftwareCodec(const AString &componentName);