diff options
author | Praveen Chavan <pchavan@codeaurora.org> | 2015-05-19 19:09:48 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2015-06-10 16:48:59 -0700 |
commit | e1e5d7a3d3d4d6d644e6c731f977422e004140d5 (patch) | |
tree | 687a0b028303a6560b09701e1a7689fd9291fa9b /media/libmediaplayerservice | |
parent | 4a4265e9fc4e72d069eb2de37c8484d67fd3a9fc (diff) | |
download | frameworks_av-e1e5d7a3d3d4d6d644e6c731f977422e004140d5.zip frameworks_av-e1e5d7a3d3d4d6d644e6c731f977422e004140d5.tar.gz frameworks_av-e1e5d7a3d3d4d6d644e6c731f977422e004140d5.tar.bz2 |
NuPlayer: Enhance dumpsys statistics
Account for dropped output-frames (rather than input-frames)
in percentage dropped frames.
Print mime and component name for each active track
Change-Id: I3491d336c696d8ed0fd1503b80afe1df47c787c8
Diffstat (limited to 'media/libmediaplayerservice')
9 files changed, 86 insertions, 45 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 8760cbb..ef96a28 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1729,13 +1729,15 @@ status_t NuPlayer::getCurrentPosition(int64_t *mediaUs) { return renderer->getCurrentPosition(mediaUs); } -void NuPlayer::getStats(int64_t *numFramesTotal, int64_t *numFramesDropped) { - sp<DecoderBase> decoder = getDecoder(false /* audio */); - if (decoder != NULL) { - decoder->getStats(numFramesTotal, numFramesDropped); - } else { - *numFramesTotal = 0; - *numFramesDropped = 0; +void NuPlayer::getStats(Vector<sp<AMessage> > *mTrackStats) { + CHECK(mTrackStats != NULL); + + mTrackStats->clear(); + if (mVideoDecoder != NULL) { + mTrackStats->push_back(mVideoDecoder->getStats()); + } + if (mAudioDecoder != NULL) { + mTrackStats->push_back(mAudioDecoder->getStats()); } } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index d7aa830..298ea6d 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -77,7 +77,7 @@ struct NuPlayer : public AHandler { status_t getSelectedTrack(int32_t type, Parcel* reply) const; status_t selectTrack(size_t trackIndex, bool select, int64_t timeUs); status_t getCurrentPosition(int64_t *mediaUs); - void getStats(int64_t *mNumFramesTotal, int64_t *mNumFramesDropped); + void getStats(Vector<sp<AMessage> > *mTrackStats); sp<MetaData> getFileMeta(); float getFrameRate(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp index c649c62..99a2a84 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp @@ -58,7 +58,10 @@ NuPlayer::Decoder::Decoder( mCCDecoder(ccDecoder), mSkipRenderingUntilMediaTimeUs(-1ll), mNumFramesTotal(0ll), - mNumFramesDropped(0ll), + mNumInputFramesDropped(0ll), + mNumOutputFramesDropped(0ll), + mVideoWidth(0), + mVideoHeight(0), mIsAudio(true), mIsVideoAVC(false), mIsSecure(false), @@ -77,11 +80,11 @@ NuPlayer::Decoder::~Decoder() { releaseAndResetMediaBuffers(); } -void NuPlayer::Decoder::getStats( - int64_t *numFramesTotal, - int64_t *numFramesDropped) const { - *numFramesTotal = mNumFramesTotal; - *numFramesDropped = mNumFramesDropped; +sp<AMessage> NuPlayer::Decoder::getStats() const { + mStats->setInt64("frames-total", mNumFramesTotal); + mStats->setInt64("frames-dropped-input", mNumInputFramesDropped); + mStats->setInt64("frames-dropped-output", mNumOutputFramesDropped); + return mStats; } void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) { @@ -237,6 +240,18 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) { CHECK_EQ((status_t)OK, mCodec->getOutputFormat(&mOutputFormat)); CHECK_EQ((status_t)OK, mCodec->getInputFormat(&mInputFormat)); + mStats->setString("mime", mime.c_str()); + mStats->setString("component-name", mComponentName.c_str()); + + if (!mIsAudio) { + int32_t width, height; + if (mOutputFormat->findInt32("width", &width) + && mOutputFormat->findInt32("height", &height)) { + mStats->setInt32("width", width); + mStats->setInt32("height", height); + } + } + sp<AMessage> reply = new AMessage(kWhatCodecNotify, this); mCodec->setCallback(reply); @@ -520,6 +535,8 @@ bool NuPlayer::Decoder::handleAnOutputBuffer( mSkipRenderingUntilMediaTimeUs = -1; } + mNumFramesTotal += !mIsAudio; + // wait until 1st frame comes out to signal resume complete notifyResumeCompleteIfNecessary(); @@ -536,6 +553,12 @@ bool NuPlayer::Decoder::handleAnOutputBuffer( void NuPlayer::Decoder::handleOutputFormatChange(const sp<AMessage> &format) { if (!mIsAudio) { + int32_t width, height; + if (format->findInt32("width", &width) + && format->findInt32("height", &height)) { + mStats->setInt32("width", width); + mStats->setInt32("height", height); + } sp<AMessage> notify = mNotify->dup(); notify->setInt32("what", kWhatVideoSizeChanged); notify->setMessage("format", format); @@ -654,10 +677,6 @@ status_t NuPlayer::Decoder::fetchInputData(sp<AMessage> &reply) { return ERROR_END_OF_STREAM; } - if (!mIsAudio) { - ++mNumFramesTotal; - } - dropAccessUnit = false; if (!mIsAudio && !mIsSecure @@ -665,7 +684,7 @@ status_t NuPlayer::Decoder::fetchInputData(sp<AMessage> &reply) { && mIsVideoAVC && !IsAVCReferenceFrame(accessUnit)) { dropAccessUnit = true; - ++mNumFramesDropped; + ++mNumInputFramesDropped; } } while (dropAccessUnit); @@ -833,6 +852,7 @@ void NuPlayer::Decoder::onRenderBuffer(const sp<AMessage> &msg) { CHECK(msg->findInt64("timestampNs", ×tampNs)); err = mCodec->renderOutputBufferAndRelease(bufferIx, timestampNs); } else { + mNumOutputFramesDropped += !mIsAudio; err = mCodec->releaseOutputBuffer(bufferIx); } if (err != OK) { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h index 070d51a..ceccb7a 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h @@ -30,9 +30,7 @@ struct NuPlayer::Decoder : public DecoderBase { const sp<Surface> &surface = NULL, const sp<CCDecoder> &ccDecoder = NULL); - virtual void getStats( - int64_t *mNumFramesTotal, - int64_t *mNumFramesDropped) const; + virtual sp<AMessage> getStats() const; protected: virtual ~Decoder(); @@ -77,7 +75,10 @@ private: int64_t mSkipRenderingUntilMediaTimeUs; int64_t mNumFramesTotal; - int64_t mNumFramesDropped; + int64_t mNumInputFramesDropped; + int64_t mNumOutputFramesDropped; + int32_t mVideoWidth; + int32_t mVideoHeight; bool mIsAudio; bool mIsVideoAVC; bool mIsSecure; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.cpp index 9d509bf..7e76842 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.cpp @@ -31,6 +31,7 @@ namespace android { NuPlayer::DecoderBase::DecoderBase(const sp<AMessage> ¬ify) : mNotify(notify), mBufferGeneration(0), + mStats(new AMessage), mRequestInputBuffersPending(false) { // Every decoder has its own looper because MediaCodec operations // are blocking, but NuPlayer needs asynchronous operations. diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h index b52e7f7..8f030f0 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderBase.h @@ -42,9 +42,9 @@ struct NuPlayer::DecoderBase : public AHandler { void signalResume(bool notifyComplete); void initiateShutdown(); - virtual void getStats( - int64_t *mNumFramesTotal, - int64_t *mNumFramesDropped) const = 0; + virtual sp<AMessage> getStats() const { + return mStats; + } enum { kWhatInputDiscontinuity = 'inDi', @@ -76,6 +76,7 @@ protected: sp<AMessage> mNotify; int32_t mBufferGeneration; + sp<AMessage> mStats; private: enum { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp index d7b070e..30146c4 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.cpp @@ -59,12 +59,6 @@ NuPlayer::DecoderPassThrough::DecoderPassThrough( NuPlayer::DecoderPassThrough::~DecoderPassThrough() { } -void NuPlayer::DecoderPassThrough::getStats( - int64_t *numFramesTotal, int64_t *numFramesDropped) const { - *numFramesTotal = 0; - *numFramesDropped = 0; -} - void NuPlayer::DecoderPassThrough::onConfigure(const sp<AMessage> &format) { ALOGV("[%s] onConfigure", mComponentName.c_str()); mCachedBytes = 0; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h index 2f6df2c..db33e87 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoderPassThrough.h @@ -29,10 +29,6 @@ struct NuPlayer::DecoderPassThrough : public DecoderBase { const sp<Source> &source, const sp<Renderer> &renderer); - virtual void getStats( - int64_t *mNumFramesTotal, - int64_t *mNumFramesDropped) const; - protected: virtual ~DecoderPassThrough(); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index 84ae25e..6a38e68 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -652,20 +652,46 @@ void NuPlayerDriver::notifySeekComplete_l() { status_t NuPlayerDriver::dump( int fd, const Vector<String16> & /* args */) const { - int64_t numFramesTotal; - int64_t numFramesDropped; - mPlayer->getStats(&numFramesTotal, &numFramesDropped); + + Vector<sp<AMessage> > trackStats; + mPlayer->getStats(&trackStats); FILE *out = fdopen(dup(fd), "w"); fprintf(out, " NuPlayer\n"); - fprintf(out, " numFramesTotal(%" PRId64 "), numFramesDropped(%" PRId64 "), " - "percentageDropped(%.2f)\n", - numFramesTotal, - numFramesDropped, - numFramesTotal == 0 - ? 0.0 : (double)numFramesDropped / numFramesTotal); + for (size_t i = 0; i < trackStats.size(); ++i) { + const sp<AMessage> &stats = trackStats.itemAt(i); + + AString mime; + if (stats->findString("mime", &mime)) { + fprintf(out, " mime(%s)\n", mime.c_str()); + } + + AString name; + if (stats->findString("component-name", &name)) { + fprintf(out, " decoder(%s)\n", name.c_str()); + } + if (mime.startsWith("video/")) { + int32_t width, height; + if (stats->findInt32("width", &width) + && stats->findInt32("height", &height)) { + fprintf(out, " resolution(%d x %d)\n", width, height); + } + + int64_t numFramesTotal = 0; + int64_t numFramesDropped = 0; + + stats->findInt64("frames-total", &numFramesTotal); + stats->findInt64("frames-dropped-output", &numFramesDropped); + fprintf(out, " numFramesTotal(%lld), numFramesDropped(%lld), " + "percentageDropped(%.2f%%)\n", + (long long)numFramesTotal, + (long long)numFramesDropped, + numFramesTotal == 0 + ? 0.0 : (double)(numFramesDropped * 100) / numFramesTotal); + } + } fclose(out); out = NULL; |