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

Commit e58b8d4c authored by Shalaj Jain's avatar Shalaj Jain
Browse files

stagefright: ExtendedStats: Only enable stats with property

Only enable the extendedstats when property:
persist.debug.sf.extendedstats is set to 1. Change the constructor
of AutoProfile to pass the MediaExtendedStats module and do the
NULL check inside it instead of at every call.

Change-Id: I0d41469e41f358506638d76dc995ed3acda2b403
parent fbd89226
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ namespace android {
 * and to report dropped frames etc.
 */
typedef int64_t statsDataType;
class MediaExtendedStats;

class ExtendedStats : public RefBase {

@@ -83,6 +84,12 @@ public:
        statsDataType mData;
    };

    // Supported type of MediaExtendedStats
    enum StatsType {
        PLAYER,
        RECORDER,
    };

    // Supported evaluations (and hence possible variants of 'LogEntry's)
    enum LogType {

@@ -186,7 +193,7 @@ public:
    };

    struct AutoProfile {
        AutoProfile(const char* eventName, sp<ExtendedStats> stats = NULL,
        AutoProfile(const char* eventName, sp<MediaExtendedStats> mediaExtendedStats = NULL,
                bool condition = true, bool profileOnce = false);
        ~AutoProfile();

@@ -225,6 +232,8 @@ public:
        log(PROFILE, name, PROFILE_STOP);
    }

    static MediaExtendedStats* Create(enum StatsType statsType, const char* name, pid_t tid);


protected:
    KeyedVector<AString, sp<LogEntry> > mLogEntry;
+12 −13
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ StagefrightRecorder::StagefrightRecorder()
    ALOGV("Constructor");
    reset();

    mRecorderExtendedStats = new RecorderExtendedStats("StagefrightRecorder", gettid());
    mRecorderExtendedStats = (RecorderExtendedStats *)ExtendedStats::Create(
            ExtendedStats::RECORDER, "StagefrightRecorder", gettid());
}

StagefrightRecorder::~StagefrightRecorder() {
@@ -866,8 +867,7 @@ status_t StagefrightRecorder::prepare() {

status_t StagefrightRecorder::start() {
    ALOGV("start");
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_START_LATENCY,
            mRecorderExtendedStats == NULL ? 0 : mRecorderExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_START_LATENCY, mRecorderExtendedStats);

    if (mOutputFd < 0) {
        ALOGE("Output file descriptor is invalid");
@@ -1330,8 +1330,8 @@ status_t StagefrightRecorder::checkVideoEncoderCapabilities(
    Vector<CodecCapabilities> codecs;
    OMXClient client;
    CHECK_EQ(client.connect(), (status_t)OK);
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_ALLOCATE_NODE(true) /* isVideo */,
            mRecorderExtendedStats == NULL ? 0 : mRecorderExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(
            STATS_PROFILE_ALLOCATE_NODE(true /* isVideo */), mRecorderExtendedStats);
    QueryCodecs(
            client.interface(),
            (mVideoEncoder == VIDEO_ENCODER_H263 ? MEDIA_MIMETYPE_VIDEO_H263 :
@@ -1551,8 +1551,8 @@ status_t StagefrightRecorder::setupMediaSource(

status_t StagefrightRecorder::setupCameraSource(
        sp<CameraSource> *cameraSource) {
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_SET_CAMERA_SOURCE,
            mRecorderExtendedStats == NULL ? 0 : mRecorderExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(
            STATS_PROFILE_SET_CAMERA_SOURCE, mRecorderExtendedStats);

    status_t err = OK;
    bool encoderSupportsCameraSourceMetaDataMode;
@@ -1616,8 +1616,8 @@ status_t StagefrightRecorder::setupCameraSource(
status_t StagefrightRecorder::setupVideoEncoder(
        sp<MediaSource> cameraSource,
        sp<MediaSource> *source) {
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_SET_ENCODER(true) /* isVideo */,
            mRecorderExtendedStats == NULL ? 0 : mRecorderExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(
            STATS_PROFILE_SET_ENCODER(true /* isVideo */), mRecorderExtendedStats);

    source->clear();

@@ -1745,8 +1745,8 @@ status_t StagefrightRecorder::setupVideoEncoder(
}

status_t StagefrightRecorder::setupAudioEncoder(const sp<MediaWriter>& writer) {
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_SET_ENCODER(false) /* isVideo */,
            mRecorderExtendedStats == NULL ? 0 : mRecorderExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(
            STATS_PROFILE_SET_ENCODER(false /* isVideo */), mRecorderExtendedStats);
    status_t status = BAD_VALUE;
    if (OK != (status = checkAudioEncoderCapabilities())) {
        return status;
@@ -1872,8 +1872,7 @@ void StagefrightRecorder::setupMPEG4orWEBMMetaData(sp<MetaData> *meta) {
}

status_t StagefrightRecorder::pause() {
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_PAUSE,
            mRecorderExtendedStats == NULL ? 0 : mRecorderExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_PAUSE, mRecorderExtendedStats);
    ALOGV("pause");
    status_t err = OK;
    if (mWriter == NULL) {
+2 −1
Original line number Diff line number Diff line
@@ -175,7 +175,8 @@ NuPlayer::NuPlayer()
      mStarted(false) {

    clearFlushComplete();
    mPlayerExtendedStats = new PlayerExtendedStats("NuPlayer", gettid());
    mPlayerExtendedStats = (PlayerExtendedStats *)ExtendedStats::Create(
            ExtendedStats::PLAYER, "NuPlayer", gettid());
}

NuPlayer::~NuPlayer() {
+2 −2
Original line number Diff line number Diff line
@@ -115,8 +115,8 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
            format->findObject(MEDIA_EXTENDED_STATS, (sp<RefBase>*)&mPlayerExtendedStats);
        }
        int32_t isVideo = !strncasecmp(mime.c_str(), "video/", 6);
        ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_ALLOCATE_NODE(isVideo),
                mPlayerExtendedStats == NULL ? NULL : mPlayerExtendedStats->getProfileTimes());
        ExtendedStats::AutoProfile autoProfile(
                STATS_PROFILE_ALLOCATE_NODE(isVideo), mPlayerExtendedStats);

        mCodec = MediaCodec::CreateByType(mCodecLooper, mime.c_str(), false /* encoder */);
    }
+3 −4
Original line number Diff line number Diff line
@@ -537,8 +537,7 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
    const char* portType = portIndex == kPortIndexInput ?
                                        STATS_PROFILE_ALLOCATE_INPUT(isVideo) :
                                        STATS_PROFILE_ALLOCATE_OUTPUT(isVideo);
    ExtendedStats::AutoProfile autoProfile(portType,
            mMediaExtendedStats == NULL ? NULL : mMediaExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(portType, mMediaExtendedStats);

    CHECK(portIndex == kPortIndexInput || portIndex == kPortIndexOutput);

@@ -1199,8 +1198,8 @@ status_t ACodec::configureCodec(
    }

    bool isVideo = mComponentName.find("video") != -1;
    ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_CONFIGURE_CODEC(isVideo),
                mMediaExtendedStats == NULL ? NULL : mMediaExtendedStats->getProfileTimes());
    ExtendedStats::AutoProfile autoProfile(
            STATS_PROFILE_CONFIGURE_CODEC(isVideo), mMediaExtendedStats);

    sp<AMessage> inputFormat = new AMessage();
    sp<AMessage> outputFormat = new AMessage();
Loading