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

Commit 3a0a8b4c authored by Ray Essick's avatar Ray Essick Committed by Android (Google) Code Review
Browse files

Merge "Media Metrics for NuPlayer, Codec, Extractor"

parents 45cc284a db122147
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <media/hardware/CryptoAPI.h>
#include <media/MediaCodecInfo.h>
#include <media/MediaResource.h>
#include <media/MediaAnalyticsItem.h>
#include <media/stagefright/foundation/AHandler.h>
#include <media/stagefright/FrameRenderTracker.h>
#include <utils/Vector.h>
@@ -172,6 +173,8 @@ struct MediaCodec : public AHandler {

    status_t getName(AString *componentName) const;

    status_t getMetrics(Parcel *reply);

    status_t setParameters(const sp<AMessage> &params);

    // Create a MediaCodec notification message from a list of rendered or dropped render infos
@@ -298,6 +301,8 @@ private:
    sp<Surface> mSurface;
    SoftwareRenderer *mSoftRenderer;

    MediaAnalyticsItem *mAnalyticsItem;

    sp<AMessage> mOutputFormat;
    sp<AMessage> mInputFormat;
    sp<AMessage> mCallback;
+4 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include <media/IMediaExtractor.h>
#include <media/IMediaSource.h>
#include <media/MediaAnalyticsItem.h>

namespace android {

@@ -69,7 +70,9 @@ public:

protected:
    MediaExtractor();
    virtual ~MediaExtractor() {}
    virtual ~MediaExtractor();

    MediaAnalyticsItem *mAnalyticsItem;

private:

+6 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#include <media/AudioSystem.h>
#include <media/AVSyncSettings.h>
#include <media/IDataSource.h>
#include <media/MediaAnalyticsItem.h>

#include <binder/MemoryBase.h>

@@ -810,7 +811,11 @@ status_t MediaPlayer::getParameter(int key, Parcel *reply)
    ALOGV("MediaPlayer::getParameter(%d)", key);
    Mutex::Autolock _l(mLock);
    if (mPlayer != NULL) {
        return  mPlayer->getParameter(key, reply);
        status_t status =  mPlayer->getParameter(key, reply);
        if (status != OK) {
            ALOGD("getParameter returns %d", status);
        }
        return status;
    }
    ALOGV("getParameter: no active player");
    return INVALID_OPERATION;
+10 −1
Original line number Diff line number Diff line
@@ -706,7 +706,16 @@ status_t NuPlayerDriver::setParameter(
    return INVALID_OPERATION;
}

status_t NuPlayerDriver::getParameter(int /* key */, Parcel * /* reply */) {
status_t NuPlayerDriver::getParameter(int key, Parcel *reply) {

    if (key == FOURCC('m','t','r','X')) {
        // mtrX -- a play on 'metrics' (not matrix)
        // gather current info all together, parcel it, and send it back
        finalizeMetrics("api");
        mAnalyticsItem->writeToParcel(reply);
        return OK;
    }

    return INVALID_OPERATION;
}

+62 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include <media/IOMX.h>
#include <media/IResourceManagerService.h>
#include <media/MediaCodecBuffer.h>
#include <media/MediaAnalyticsItem.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
@@ -57,6 +58,13 @@

namespace android {

// key for media statistics
static const char *CodecKeyName = "codec";
// attrs for media statistics
static const char *CodecMime = "mime";
static const char *CodecCodec = "codec";


static int64_t getId(const sp<IResourceManagerClient> &client) {
    return (int64_t) client.get();
}
@@ -476,11 +484,27 @@ MediaCodec::MediaCodec(const sp<ALooper> &looper, pid_t pid, uid_t uid)
    } else {
        mUid = uid;
    }
    // set up our new record, get a sessionID, put it into the in-progress list
    mAnalyticsItem = new MediaAnalyticsItem(CodecKeyName);
    if (mAnalyticsItem != NULL) {
        (void) mAnalyticsItem->generateSessionID();
        // don't record it yet; only at the end, when we have decided that we have
        // data worth writing (e.g. .count() > 0)
    }
}

MediaCodec::~MediaCodec() {
    CHECK_EQ(mState, UNINITIALIZED);
    mResourceManagerService->removeResource(getId(mResourceManagerClient));

    if (mAnalyticsItem != NULL ) {
        if (mAnalyticsItem->count() > 0) {
            mAnalyticsItem->setFinalized(true);
            mAnalyticsItem->selfrecord();
        }
        delete mAnalyticsItem;
        mAnalyticsItem = NULL;
    }
}

// static
@@ -600,6 +624,19 @@ status_t MediaCodec::init(const AString &name, bool nameIsType, bool encoder) {
        msg->setInt32("encoder", encoder);
    }

    if (mAnalyticsItem != NULL) {
        if (nameIsType) {
            // name is the mime type
            mAnalyticsItem->setCString(CodecMime, name.c_str());
        } else {
            mAnalyticsItem->setCString(CodecCodec, name.c_str());
        }
        mAnalyticsItem->setCString("mode", mIsVideo ? "video" : "audio");
        //mAnalyticsItem->setInt32("type", nameIsType);
        if (nameIsType)
            mAnalyticsItem->setInt32("encoder", encoder);
    }

    status_t err;
    Vector<MediaResource> resources;
    MediaResource::Type type =
@@ -652,6 +689,12 @@ status_t MediaCodec::configure(
            mRotationDegrees = 0;
        }

        if (mAnalyticsItem != NULL) {
            mAnalyticsItem->setInt32("width", mVideoWidth);
            mAnalyticsItem->setInt32("height", mVideoHeight);
            mAnalyticsItem->setInt32("rotation", mRotationDegrees);
        }

        // Prevent possible integer overflow in downstream code.
        if (mInitIsEncoder
                && (uint64_t)mVideoWidth * mVideoHeight > (uint64_t)INT32_MAX / 4) {
@@ -666,6 +709,10 @@ status_t MediaCodec::configure(

    if (crypto != NULL) {
        msg->setPointer("crypto", crypto.get());
        if (mAnalyticsItem != NULL) {
            // XXX: save indication that it's crypto in some way...
            mAnalyticsItem->setInt32("crypto", 1);
        }
    }

    // save msg for reset
@@ -1058,6 +1105,21 @@ status_t MediaCodec::getName(AString *name) const {
    return OK;
}

status_t MediaCodec::getMetrics(Parcel *reply) {

    // shouldn't happen, but be safe
    if (mAnalyticsItem == NULL) {
        return UNKNOWN_ERROR;
    }

    // XXX: go get current values for whatever in-flight data we want

    // send it back to the caller.
    mAnalyticsItem->writeToParcel(reply);

    return OK;
}

status_t MediaCodec::getInputBuffers(Vector<sp<MediaCodecBuffer> > *buffers) const {
    sp<AMessage> msg = new AMessage(kWhatGetBuffers, this);
    msg->setInt32("portIndex", kPortIndexInput);
Loading