diff options
author | Hangyu Kuang <hkuang@google.com> | 2019-05-07 16:06:16 -0700 |
---|---|---|
committer | Hangyu Kuang <hkuang@google.com> | 2019-05-08 10:49:55 -0700 |
commit | 8357764cc0d7ec9524556339e2c564e73becd29a (patch) | |
tree | edd151ed5fb2c4048ea51495134ebc3423f3b3d4 | |
parent | 5903f3939d93a1be58ccb690626e52651c137296 (diff) | |
download | av-8357764cc0d7ec9524556339e2c564e73becd29a.tar.gz |
[ECOService]: Add dumpsys support to ECOService.
Run "adb shell /vendor/bin/dumpsys media.ecoservice"
DUMP OF SERVICE media.ecoservice:
== ECO Service info: ==
Number of ECOServices: 1
== Session Info: ==
Width: 1280 Height: 720 isCameraRecording: 1, target-bitrate: 12000000 bps codetype: 1 profile: 8 level: 32768
Provider: QTIEncoder
===================
Bug:117877984
Test: Unit test
Change-Id: I9f578620a02ad6b71feadd063b0ca8d797f89e85
-rw-r--r-- | media/eco/ECOService.cpp | 32 | ||||
-rw-r--r-- | media/eco/ECOSession.cpp | 25 | ||||
-rw-r--r-- | media/eco/ECOUtils.cpp | 2 | ||||
-rw-r--r-- | media/eco/include/eco/ECODataKey.h | 2 | ||||
-rw-r--r-- | media/eco/include/eco/ECOService.h | 10 | ||||
-rw-r--r-- | media/eco/include/eco/ECOSession.h | 11 | ||||
-rw-r--r-- | media/eco/tests/FakeECOServiceStatsProvider.h | 1 |
7 files changed, 63 insertions, 20 deletions
diff --git a/media/eco/ECOService.cpp b/media/eco/ECOService.cpp index 59ae868..369ceb1 100644 --- a/media/eco/ECOService.cpp +++ b/media/eco/ECOService.cpp @@ -71,7 +71,7 @@ ECOService::ECOService() : BnECOService() { // invalid sessions. SanitizeSession([&](MapIterType iter) { if (iter->first == newCfg) { - sp<IECOSession> session = iter->second.promote(); + sp<ECOSession> session = iter->second.promote(); foundSession = true; *_aidl_return = session; } @@ -82,14 +82,15 @@ ECOService::ECOService() : BnECOService() { } // Create a new session and add it to the record. - *_aidl_return = ECOSession::createECOSession(width, height, isCameraRecording); - if (*_aidl_return == nullptr) { + sp<ECOSession> newSession = ECOSession::createECOSession(width, height, isCameraRecording); + if (newSession == nullptr) { ECOLOGE("ECOService failed to create ECOSession w: %d, h: %d, isCameraRecording: %d", width, height, isCameraRecording); return STATUS_ERROR(ERROR_UNSUPPORTED, "Failed to create eco session"); } + *_aidl_return = newSession; // Insert the new session into the map. - mSessionConfigToSessionMap[newCfg] = *_aidl_return; + mSessionConfigToSessionMap[newCfg] = newSession; ECOLOGD("session count after is %zu", mSessionConfigToSessionMap.size()); return binder::Status::ok(); @@ -109,19 +110,19 @@ ECOService::ECOService() : BnECOService() { Mutex::Autolock lock(mServiceLock); SanitizeSession([&](MapIterType iter) { - sp<IECOSession> session = iter->second.promote(); + sp<ECOSession> session = iter->second.promote(); _aidl_return->push_back(IInterface::asBinder(session)); }); return binder::Status::ok(); } -inline bool isEmptySession(const android::wp<IECOSession>& entry) { - sp<IECOSession> session = entry.promote(); +inline bool isEmptySession(const android::wp<ECOSession>& entry) { + sp<ECOSession> session = entry.promote(); return session == nullptr; } void ECOService::SanitizeSession( - const std::function<void(std::unordered_map<SessionConfig, wp<IECOSession>, + const std::function<void(std::unordered_map<SessionConfig, wp<ECOSession>, SessionConfigHash>::iterator it)>& callback) { for (auto it = mSessionConfigToSessionMap.begin(), end = mSessionConfigToSessionMap.end(); it != end;) { @@ -138,6 +139,21 @@ void ECOService::SanitizeSession( /*virtual*/ void ECOService::binderDied(const wp<IBinder>& /*who*/) {} +status_t ECOService::dump(int fd, const Vector<String16>& args) { + Mutex::Autolock lock(mServiceLock); + dprintf(fd, "\n== ECO Service info: ==\n\n"); + dprintf(fd, "Number of ECOServices: %zu\n", mSessionConfigToSessionMap.size()); + for (auto it = mSessionConfigToSessionMap.begin(), end = mSessionConfigToSessionMap.end(); + it != end; it++) { + sp<ECOSession> session = it->second.promote(); + if (session != nullptr) { + session->dump(fd, args); + } + } + + return NO_ERROR; +} + } // namespace eco } // namespace media } // namespace android
\ No newline at end of file diff --git a/media/eco/ECOSession.cpp b/media/eco/ECOSession.cpp index 1a1bc59..b184cdb 100644 --- a/media/eco/ECOSession.cpp +++ b/media/eco/ECOSession.cpp @@ -190,8 +190,8 @@ bool ECOSession::processSessionStats(const ECOData& stats) { mCodecLevel = std::get<int32_t>(value); ECOLOGV("codec level is %d", mCodecLevel); } else if (!key.compare(ENCODER_TARGET_BITRATE_BPS)) { - mBitrateBps = std::get<int32_t>(value); - ECOLOGV("codec bitrate is %d", mBitrateBps); + mTargetBitrateBps = std::get<int32_t>(value); + ECOLOGV("codec target bitrate is %d", mTargetBitrateBps); } else if (!key.compare(ENCODER_KFI_FRAMES)) { mKeyFrameIntervalFrames = std::get<int32_t>(value); ECOLOGV("codec kfi is %d", mKeyFrameIntervalFrames); @@ -255,8 +255,8 @@ ECOData ECOSession::generateLatestSessionInfoEcoData() { hasInfo = true; } - if (mBitrateBps != -1) { - info.setInt32(ENCODER_TARGET_BITRATE_BPS, mBitrateBps); + if (mTargetBitrateBps != -1) { + info.setInt32(ENCODER_TARGET_BITRATE_BPS, mTargetBitrateBps); hasInfo = true; } @@ -369,6 +369,7 @@ Status ECOSession::addStatsProvider( } mProvider = provider; + mProviderName = name; *status = true; return binder::Status::ok(); } @@ -436,6 +437,7 @@ Status ECOSession::addInfoListener( IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid()); mListener = listener; + mListenerName = name; mNewListenerAdded = true; mWorkerWaitCV.notify_all(); @@ -494,6 +496,21 @@ Status ECOSession::getNumOfProviders(int32_t* _aidl_return) { ECOLOGV("binderDied"); } +status_t ECOSession::dump(int fd, const Vector<String16>& /*args*/) { + std::scoped_lock<std::mutex> lock(mSessionLock); + dprintf(fd, "\n== Session Info: ==\n\n"); + dprintf(fd, + "Width: %d Height: %d isCameraRecording: %d, target-bitrate: %d bps codetype: %d " + "profile: %d level: %d\n", + mWidth, mHeight, mIsCameraRecording, mTargetBitrateBps, mCodecType, mCodecProfile, + mCodecLevel); + dprintf(fd, "Provider: %s \n", ::android::String8(mProviderName).string()); + dprintf(fd, "Listener: %s \n", ::android::String8(mListenerName).string()); + dprintf(fd, "\n===================\n\n"); + + return NO_ERROR; +} + void ECOSession::logStats(const ECOData& data) { // Check if mLogStats is true; if (!mLogStats || mLogStatsEntries == 0) return; diff --git a/media/eco/ECOUtils.cpp b/media/eco/ECOUtils.cpp index c8edac4..ab82252 100644 --- a/media/eco/ECOUtils.cpp +++ b/media/eco/ECOUtils.cpp @@ -19,6 +19,8 @@ #include "eco/ECOUtils.h" +#include <utils/Timers.h> + namespace android { namespace media { namespace eco { diff --git a/media/eco/include/eco/ECODataKey.h b/media/eco/include/eco/ECODataKey.h index 2bad8e4..b7831ba 100644 --- a/media/eco/include/eco/ECODataKey.h +++ b/media/eco/include/eco/ECODataKey.h @@ -22,8 +22,6 @@ #include <stdint.h> #include <sys/mman.h> -#include "ECOService.h" - namespace android { namespace media { namespace eco { diff --git a/media/eco/include/eco/ECOService.h b/media/eco/include/eco/ECOService.h index d7c129d..f83edff 100644 --- a/media/eco/include/eco/ECOService.h +++ b/media/eco/include/eco/ECOService.h @@ -18,13 +18,11 @@ #define ANDROID_MEDIA_ECO_SERVICE_H_ #include <android/media/eco/BnECOService.h> -#include <android/media/eco/BnECOSession.h> #include <binder/BinderService.h> #include <list> #include "eco/ECODebug.h" -#include "eco/ECOService.h" #include "eco/ECOSession.h" namespace android { @@ -33,6 +31,7 @@ namespace eco { using android::sp; using android::binder::Status; +using android::media::eco::ECOSession; /** * ECO (Encoder Camera Optimization) service. @@ -73,6 +72,8 @@ public: // IBinder::DeathRecipient implementation virtual void binderDied(const wp<IBinder>& who); + virtual status_t dump(int fd, const Vector<String16>& args); + private: // Lock guarding ECO service state Mutex mServiceLock; @@ -106,11 +107,10 @@ private: }; // Map from SessionConfig to session. - std::unordered_map<SessionConfig, wp<IECOSession>, SessionConfigHash> - mSessionConfigToSessionMap; + std::unordered_map<SessionConfig, wp<ECOSession>, SessionConfigHash> mSessionConfigToSessionMap; using MapIterType = - std::unordered_map<SessionConfig, wp<IECOSession>, SessionConfigHash>::iterator; + std::unordered_map<SessionConfig, wp<ECOSession>, SessionConfigHash>::iterator; // A helpful function to traverse the mSessionConfigToSessionMap, remove the entry that // does not exist any more and call |callback| when the entry is valid. diff --git a/media/eco/include/eco/ECOSession.h b/media/eco/include/eco/ECOSession.h index c801de2..0b423c4 100644 --- a/media/eco/include/eco/ECOSession.h +++ b/media/eco/include/eco/ECOSession.h @@ -93,6 +93,8 @@ private: // Only the ECOService could create ECOSession. ECOSession(int32_t width, int32_t height, bool isCameraRecording); + virtual status_t dump(int fd, const Vector<String16>& args); + // Start the main thread for processing the stats and pushing info to listener. static void startThread(ECOSession* session); @@ -133,7 +135,10 @@ private: QpCondition mListenerQpCondition; android::sp<IECOServiceInfoListener> mListener; + String16 mListenerName; + android::sp<IECOServiceStatsProvider> mProvider; + String16 mProviderName; // Main thread for processing the events from provider. std::thread mThread; @@ -164,7 +169,11 @@ private: // Target bitrate in bits per second. This should be provided by the provider. -1 means not // available. - int32_t mBitrateBps = -1; + int32_t mTargetBitrateBps = -1; + + // Actual bitrate in bits per second. This should be provided by the provider. -1 means not + // available. + int32_t mActualBitrateBps = -1; // Key frame interval in number of frames. -1 means not available. int32_t mKeyFrameIntervalFrames = -1; diff --git a/media/eco/tests/FakeECOServiceStatsProvider.h b/media/eco/tests/FakeECOServiceStatsProvider.h index e514605..0f60d02 100644 --- a/media/eco/tests/FakeECOServiceStatsProvider.h +++ b/media/eco/tests/FakeECOServiceStatsProvider.h @@ -37,6 +37,7 @@ #include "eco/ECOData.h" #include "eco/ECODataKey.h" +#include "eco/ECOService.h" namespace android { namespace media { |