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

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

Merge "Name changes to Media Metrics Keys"

parents 7929582f afb43f76
Loading
Loading
Loading
Loading
+33 −17
Original line number Diff line number Diff line
@@ -69,7 +69,23 @@ static const int kMaxNumVideoTemporalLayers = 8;
// key for media statistics
static const char *kKeyRecorder = "recorder";
// attrs for media statistics
//
static const char *kRecorderHeight = "android.media.mediarecorder.height";
static const char *kRecorderWidth = "android.media.mediarecorder.width";
static const char *kRecorderFrameRate = "android.media.mediarecorder.frame-rate";
static const char *kRecorderVideoBitrate = "android.media.mediarecorder.video-bitrate";
static const char *kRecorderAudioSampleRate = "android.media.mediarecorder.audio-samplerate";
static const char *kRecorderAudioChannels = "android.media.mediarecorder.audio-channels";
static const char *kRecorderAudioBitrate = "android.media.mediarecorder.audio-bitrate";
static const char *kRecorderVideoIframeInterval = "android.media.mediarecorder.video-iframe-interval";
static const char *kRecorderMovieTimescale = "android.media.mediarecorder.movie-timescale";
static const char *kRecorderAudioTimescale = "android.media.mediarecorder.audio-timescale";
static const char *kRecorderVideoTimescale = "android.media.mediarecorder.video-timescale";
static const char *kRecorderVideoProfile = "android.media.mediarecorder.video-encoder-profile";
static const char *kRecorderVideoLevel = "android.media.mediarecorder.video-encoder-level";
static const char *kRecorderCaptureFpsEnable = "android.media.mediarecorder.capture-fpsenable";
static const char *kRecorderCaptureFps = "android.media.mediarecorder.capture-fps";
static const char *kRecorderRotation = "android.media.mediarecorder.rotation";

// To collect the encoder usage for the battery app
static void addBatteryData(uint32_t params) {
    sp<IBinder> binder =
@@ -124,34 +140,34 @@ void StagefrightRecorder::updateMetrics() {
    // TBD mOutputFormat  = OUTPUT_FORMAT_THREE_GPP;
    // TBD mAudioEncoder  = AUDIO_ENCODER_AMR_NB;
    // TBD mVideoEncoder  = VIDEO_ENCODER_DEFAULT;
    mAnalyticsItem->setInt32("ht", mVideoHeight);
    mAnalyticsItem->setInt32("wid", mVideoWidth);
    mAnalyticsItem->setInt32("frame-rate", mFrameRate);
    mAnalyticsItem->setInt32("video-bitrate", mVideoBitRate);
    mAnalyticsItem->setInt32("audio-samplerate", mSampleRate);
    mAnalyticsItem->setInt32("audio-channels", mAudioChannels);
    mAnalyticsItem->setInt32("audio-bitrate", mAudioBitRate);
    mAnalyticsItem->setInt32(kRecorderHeight, mVideoHeight);
    mAnalyticsItem->setInt32(kRecorderWidth, mVideoWidth);
    mAnalyticsItem->setInt32(kRecorderFrameRate, mFrameRate);
    mAnalyticsItem->setInt32(kRecorderVideoBitrate, mVideoBitRate);
    mAnalyticsItem->setInt32(kRecorderAudioSampleRate, mSampleRate);
    mAnalyticsItem->setInt32(kRecorderAudioChannels, mAudioChannels);
    mAnalyticsItem->setInt32(kRecorderAudioBitrate, mAudioBitRate);
    // TBD mInterleaveDurationUs = 0;
    mAnalyticsItem->setInt32("video-iframe-interval", mIFramesIntervalSec);
    mAnalyticsItem->setInt32(kRecorderVideoIframeInterval, mIFramesIntervalSec);
    // TBD mAudioSourceNode = 0;
    // TBD mUse64BitFileOffset = false;
    mAnalyticsItem->setInt32("movie-timescale", mMovieTimeScale);
    mAnalyticsItem->setInt32("audio-timescale", mAudioTimeScale);
    mAnalyticsItem->setInt32("video-timescale", mVideoTimeScale);
    mAnalyticsItem->setInt32(kRecorderMovieTimescale, mMovieTimeScale);
    mAnalyticsItem->setInt32(kRecorderAudioTimescale, mAudioTimeScale);
    mAnalyticsItem->setInt32(kRecorderVideoTimescale, mVideoTimeScale);
    // TBD mCameraId        = 0;
    // TBD mStartTimeOffsetMs = -1;
    mAnalyticsItem->setInt32("video-encoder-profile", mVideoEncoderProfile);
    mAnalyticsItem->setInt32("video-encoder-level", mVideoEncoderLevel);
    mAnalyticsItem->setInt32(kRecorderVideoProfile, mVideoEncoderProfile);
    mAnalyticsItem->setInt32(kRecorderVideoLevel, mVideoEncoderLevel);
    // TBD mMaxFileDurationUs = 0;
    // TBD mMaxFileSizeBytes = 0;
    // TBD mTrackEveryTimeDurationUs = 0;
    mAnalyticsItem->setInt32("capture-fpsenable", mCaptureFpsEnable);
    mAnalyticsItem->setInt32("capture-fps", mCaptureFps);
    mAnalyticsItem->setInt32(kRecorderCaptureFpsEnable, mCaptureFpsEnable);
    mAnalyticsItem->setDouble(kRecorderCaptureFps, mCaptureFps);
    // TBD mTimeBetweenCaptureUs = -1;
    // TBD mCameraSourceTimeLapse = NULL;
    // TBD mMetaDataStoredInVideoBuffers = kMetadataBufferTypeInvalid;
    // TBD mEncoderProfiles = MediaProfiles::getInstance();
    mAnalyticsItem->setInt32("rotation", mRotationDegrees);
    mAnalyticsItem->setInt32(kRecorderRotation, mRotationDegrees);
    // PII mLatitudex10000 = -3600000;
    // PII mLongitudex10000 = -3600000;
    // TBD mTotalBitRate = 0;
+38 −13
Original line number Diff line number Diff line
@@ -38,6 +38,22 @@ static const int kDumpLockSleepUs = 20000;

namespace android {

// key for media statistics
static const char *kKeyPlayer = "nuplayer";
// attrs for media statistics
static const char *kPlayerVMime = "android.media.mediaplayer.video.mime";
static const char *kPlayerVCodec = "android.media.mediaplayer.video.codec";
static const char *kPlayerWidth = "android.media.mediaplayer.width";
static const char *kPlayerHeight = "android.media.mediaplayer.height";
static const char *kPlayerFrames = "android.media.mediaplayer.frames";
static const char *kPlayerFramesDropped = "android.media.mediaplayer.dropped";
static const char *kPlayerAMime = "android.media.mediaplayer.audio.mime";
static const char *kPlayerACodec = "android.media.mediaplayer.audio.codec";
static const char *kPlayerDuration = "android.media.mediaplayer.durationMs";
static const char *kPlayerPlaying = "android.media.mediaplayer.playingMs";
static const char *kPlayerError = "android.media.mediaplayer.err";
static const char *kPlayerErrorCode = "android.media.mediaplayer.errcode";


NuPlayerDriver::NuPlayerDriver(pid_t pid)
    : mState(STATE_IDLE),
@@ -59,7 +75,7 @@ NuPlayerDriver::NuPlayerDriver(pid_t pid)
    mLooper->setName("NuPlayerDriver Looper");

    // set up an analytics record
    mAnalyticsItem = new MediaAnalyticsItem("nuplayer");
    mAnalyticsItem = new MediaAnalyticsItem(kKeyPlayer);
    mAnalyticsItem->generateSessionID();

    mLooper->start(
@@ -499,7 +515,7 @@ void NuPlayerDriver::finalizeMetrics(const char *where) {
    if (where == NULL) {
        where = "unknown";
    }
    ALOGD("finalizeMetrics(%p) from %s at state %d", this, where, mState);
    ALOGV("finalizeMetrics(%p) from %s at state %d", this, where, mState);

    // gather the final stats for this record
    Vector<sp<AMessage>> trackStats;
@@ -517,15 +533,15 @@ void NuPlayerDriver::finalizeMetrics(const char *where) {

            if (mime.startsWith("video/")) {
                int32_t width, height;
                mAnalyticsItem->setCString("video/mime", mime.c_str());
                mAnalyticsItem->setCString(kPlayerVMime, mime.c_str());
                if (!name.empty()) {
                    mAnalyticsItem->setCString("video/codec", name.c_str());
                    mAnalyticsItem->setCString(kPlayerVCodec, name.c_str());
                }

                if (stats->findInt32("width", &width)
                        && stats->findInt32("height", &height)) {
                    mAnalyticsItem->setInt32("wid", width);
                    mAnalyticsItem->setInt32("ht", height);
                    mAnalyticsItem->setInt32(kPlayerWidth, width);
                    mAnalyticsItem->setInt32(kPlayerHeight, height);
                }

                int64_t numFramesTotal = 0;
@@ -533,14 +549,14 @@ void NuPlayerDriver::finalizeMetrics(const char *where) {
                stats->findInt64("frames-total", &numFramesTotal);
                stats->findInt64("frames-dropped-output", &numFramesDropped);

                mAnalyticsItem->setInt64("frames", numFramesTotal);
                mAnalyticsItem->setInt64("dropped", numFramesDropped);
                mAnalyticsItem->setInt64(kPlayerFrames, numFramesTotal);
                mAnalyticsItem->setInt64(kPlayerFramesDropped, numFramesDropped);


            } else if (mime.startsWith("audio/")) {
                mAnalyticsItem->setCString("audio/mime", mime.c_str());
                mAnalyticsItem->setCString(kPlayerAMime, mime.c_str());
                if (!name.empty()) {
                    mAnalyticsItem->setCString("audio/codec", name.c_str());
                    mAnalyticsItem->setCString(kPlayerACodec, name.c_str());
                }
            }
        }
@@ -549,11 +565,11 @@ void NuPlayerDriver::finalizeMetrics(const char *where) {
        int duration_ms = -1;
        getDuration(&duration_ms);
        if (duration_ms != -1) {
            mAnalyticsItem->setInt64("duration", duration_ms);
            mAnalyticsItem->setInt64(kPlayerDuration, duration_ms);
        }

        if (mPlayingTimeUs > 0) {
            mAnalyticsItem->setInt64("playing", (mPlayingTimeUs+500)/1000 );
            mAnalyticsItem->setInt64(kPlayerPlaying, (mPlayingTimeUs+500)/1000 );
        }
    }
}
@@ -563,7 +579,7 @@ void NuPlayerDriver::logMetrics(const char *where) {
    if (where == NULL) {
        where = "unknown";
    }
    ALOGD("logMetrics(%p) from %s at state %d", this, where, mState);
    ALOGV("logMetrics(%p) from %s at state %d", this, where, mState);

    if (mAnalyticsItem == NULL || mAnalyticsItem->isEnabled() == false) {
        return;
@@ -923,6 +939,15 @@ void NuPlayerDriver::notifyListener_l(

        case MEDIA_ERROR:
        {
            // when we have an error, add it to the analytics for this playback.
            // ext1 is our primary 'error type' value. Only add ext2 when non-zero.
            // [test against msg is due to fall through from previous switch value]
            if (msg == MEDIA_ERROR) {
                mAnalyticsItem->setInt32(kPlayerError, ext1);
                if (ext2 != 0) {
                    mAnalyticsItem->setInt32(kPlayerErrorCode, ext2);
                }
            }
            mAtEOS = true;
            break;
        }
+19 −13
Original line number Diff line number Diff line
@@ -62,10 +62,15 @@ namespace android {
// key for media statistics
static const char *kCodecKeyName = "codec";
// attrs for media statistics
static const char *kCodecCodec = "codec";               /* e.g. OMX.google.aac.decoder */
static const char *kCodecMime = "mime";                 /* e.g. audio/mime */
static const char *kCodecMode = "mode";                 /* audio, video */
static const char *kCodecSecure = "secure";             /* 0, 1 */
static const char *kCodecCodec = "android.media.mediacodec.codec";  /* e.g. OMX.google.aac.decoder */
static const char *kCodecMime = "android.media.mediacodec.mime";    /* e.g. audio/mime */
static const char *kCodecMode = "android.media.mediacodec.mode";    /* audio, video */
static const char *kCodecSecure = "android.media.mediacodec.secure";   /* 0, 1 */
static const char *kCodecHeight = "android.media.mediacodec.height";   /* 0..n */
static const char *kCodecWidth = "android.media.mediacodec.width";     /* 0..n */
static const char *kCodecRotation = "android.media.mediacodec.rotation-degrees";  /* 0/90/180/270 */
static const char *kCodecCrypto = "android.media.mediacodec.crypto";   /* 0,1 */
static const char *kCodecEncoder = "android.media.mediacodec.encoder"; /* 0,1 */



@@ -636,9 +641,8 @@ status_t MediaCodec::init(const AString &name, bool nameIsType, bool encoder) {
            mAnalyticsItem->setCString(kCodecCodec, name.c_str());
        }
        mAnalyticsItem->setCString(kCodecMode, mIsVideo ? "video" : "audio");
        //mAnalyticsItem->setInt32("type", nameIsType);
        if (nameIsType)
            mAnalyticsItem->setInt32("encoder", encoder);
            mAnalyticsItem->setInt32(kCodecEncoder, encoder);
    }

    status_t err;
@@ -698,14 +702,14 @@ status_t MediaCodec::configure(
    if (mIsVideo) {
        format->findInt32("width", &mVideoWidth);
        format->findInt32("height", &mVideoHeight);
        if (!format->findInt32("rotation-degrees", &mRotationDegrees)) {
        if (!format->findInt32(kCodecRotation, &mRotationDegrees)) {
            mRotationDegrees = 0;
        }

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

        // Prevent possible integer overflow in downstream code.
@@ -728,7 +732,7 @@ status_t MediaCodec::configure(
        }
        if (mAnalyticsItem != NULL) {
            // XXX: save indication that it's crypto in some way...
            mAnalyticsItem->setInt32("crypto", 1);
            mAnalyticsItem->setInt32(kCodecCrypto, 1);
        }
    }

@@ -1167,7 +1171,9 @@ status_t MediaCodec::getName(AString *name) const {
    return OK;
}

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

    reply = NULL;

    // shouldn't happen, but be safe
    if (mAnalyticsItem == NULL) {
@@ -1177,7 +1183,7 @@ status_t MediaCodec::getMetrics(Parcel *reply) {
    // XXX: go get current values for whatever in-flight data we want

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

    return OK;
}
+6 −3
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@ namespace android {
// key for media statistics
static const char *kKeyExtractor = "extractor";
// attrs for media statistics
static const char *kExtractorMime = "android.media.mediaextractor.mime";
static const char *kExtractorTracks = "android.media.mediaextractor.ntrk";
static const char *kExtractorFormat = "android.media.mediaextractor.fmt";

MediaExtractor::MediaExtractor() {
    if (!LOG_NDEBUG) {
@@ -265,9 +268,9 @@ sp<MediaExtractor> MediaExtractor::CreateFromService(
       if (MEDIA_LOG) {
          if (ret->mAnalyticsItem != NULL) {
              size_t ntracks = ret->countTracks();
              ret->mAnalyticsItem->setCString("fmt",  ret->name());
              ret->mAnalyticsItem->setCString(kExtractorFormat,  ret->name());
              // tracks (size_t)
              ret->mAnalyticsItem->setInt32("ntrk",  ntracks);
              ret->mAnalyticsItem->setInt32(kExtractorTracks,  ntracks);
              // metadata
              sp<MetaData> pMetaData = ret->getMetaData();
              if (pMetaData != NULL) {
@@ -276,7 +279,7 @@ sp<MediaExtractor> MediaExtractor::CreateFromService(
                // 'mime'
                const char *mime = NULL;
                if (pMetaData->findCString(kKeyMIMEType, &mime)) {
                    ret->mAnalyticsItem->setCString("mime",  mime);
                    ret->mAnalyticsItem->setCString(kExtractorMime,  mime);
                }
                // what else is interesting and not already available?
              }
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ struct MediaCodec : public AHandler {

    status_t getName(AString *componentName) const;

    status_t getMetrics(Parcel *reply);
    status_t getMetrics(MediaAnalyticsItem * &reply);

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