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

Commit 7ec98736 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Record profile, level, bytes for codecs" into oc-mr1-dev

parents ba248a45 002e413a
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -73,6 +73,11 @@ static const char *kCodecRotation = "android.media.mediacodec.rotation-degrees";
static const char *kCodecCrypto = "android.media.mediacodec.crypto";   /* 0,1 */
static const char *kCodecEncoder = "android.media.mediacodec.encoder"; /* 0,1 */

static const char *kCodecBytesIn = "android.media.mediacodec.bytesin";  /* 0..n */
static const char *kCodecProfile = "android.media.mediacodec.profile";  /* 0..n */
static const char *kCodecLevel = "android.media.mediacodec.level";  /* 0..n */
static const char *kCodecMaxWidth = "android.media.mediacodec.maxwidth";  /* 0..n */
static const char *kCodecMaxHeight = "android.media.mediacodec.maxheight";  /* 0..n */


static int64_t getId(const sp<IResourceManagerClient> &client) {
@@ -684,10 +689,21 @@ status_t MediaCodec::configure(
        uint32_t flags) {
    sp<AMessage> msg = new AMessage(kWhatConfigure, this);

    if (mAnalyticsItem != NULL) {
        int32_t profile = 0;
        if (format->findInt32("profile", &profile)) {
            mAnalyticsItem->setInt32(kCodecProfile, profile);
        }
        int32_t level = 0;
        if (format->findInt32("level", &level)) {
            mAnalyticsItem->setInt32(kCodecLevel, level);
        }
    }

    if (mIsVideo) {
        format->findInt32("width", &mVideoWidth);
        format->findInt32("height", &mVideoHeight);
        if (!format->findInt32(kCodecRotation, &mRotationDegrees)) {
        if (!format->findInt32("rotation-degrees", &mRotationDegrees)) {
            mRotationDegrees = 0;
        }

@@ -695,6 +711,14 @@ status_t MediaCodec::configure(
            mAnalyticsItem->setInt32(kCodecWidth, mVideoWidth);
            mAnalyticsItem->setInt32(kCodecHeight, mVideoHeight);
            mAnalyticsItem->setInt32(kCodecRotation, mRotationDegrees);
            int32_t maxWidth = 0;
            if (format->findInt32("max-width", &maxWidth)) {
                mAnalyticsItem->setInt32(kCodecMaxWidth, maxWidth);
            }
            int32_t maxHeight = 0;
            if (format->findInt32("max-height", &maxHeight)) {
                mAnalyticsItem->setInt32(kCodecMaxHeight, maxHeight);
            }
        }

        // Prevent possible integer overflow in downstream code.
@@ -2814,6 +2838,9 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
        Mutex::Autolock al(mBufferLock);
        info->mOwnedByClient = false;
        info->mData.clear();
        if (mAnalyticsItem != NULL) {
            mAnalyticsItem->addInt64(kCodecBytesIn, size);
        }
    }

    return err;
+22 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#define LOG_TAG "MetricsSummarizerCodec"
#include <utils/Log.h>

#include <stdint.h>
#include <inttypes.h>

#include <utils/threads.h>
#include <utils/Errors.h>
@@ -34,10 +36,30 @@

namespace android {

static const char *codec_ignorable[] = {
    "android.media.mediacodec.bytesin",
    0
};

MetricsSummarizerCodec::MetricsSummarizerCodec(const char *key)
    : MetricsSummarizer(key)
{
    ALOGV("MetricsSummarizerCodec::MetricsSummarizerCodec");
    setIgnorables(codec_ignorable);

}

void MetricsSummarizerCodec::mergeRecord(MediaAnalyticsItem &summation, MediaAnalyticsItem &item) {

    ALOGV("MetricsSummarizerCodec::mergeRecord()");

    int64_t bytesin = 0;
    if (item.getInt64("android.media.mediacodec.bytesin", &bytesin)) {
        ALOGV("found bytesin of %" PRId64, bytesin);
    }
    if (bytesin >= 0) {
        minMaxVar64(summation,"android.media.mediacodec.bytesin", bytesin);
    }
}


+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ class MetricsSummarizerCodec : public MetricsSummarizer
    MetricsSummarizerCodec(const char *key);
    virtual ~MetricsSummarizerCodec() {};

    virtual void mergeRecord(MediaAnalyticsItem &have, MediaAnalyticsItem &incoming);

};

// ----------------------------------------------------------------------------