summaryrefslogtreecommitdiff
path: root/media/eco/ECOSession.cpp
diff options
context:
space:
mode:
authorHangyu Kuang <hkuang@google.com>2019-04-25 18:20:13 -0700
committerHangyu Kuang <hkuang@google.com>2019-04-30 11:07:16 -0700
commit546bfe07fce6fa9712edb2fbfa6a983cd34021b1 (patch)
treed85e528a65afb690999947ae298fcab70135070c /media/eco/ECOSession.cpp
parent8d0f95fb94175449fba42addbb54c43e513c0fbe (diff)
downloadav-546bfe07fce6fa9712edb2fbfa6a983cd34021b1.tar.gz
[ECOService]: Add better logging support through setprop.
adb shell setprop media.ecoservice.log.level 1 for debug log. adb shell setprop media.ecoservice.log.level 2 for verbose log. adb shell setprop media.ecoservice.log.level 3 for both debug log and verbose log. Bug: 117877984 Test: Unit test. Change-Id: If047476cd7957d0ef10940dbadc2bd36eeb320a1
Diffstat (limited to 'media/eco/ECOSession.cpp')
-rw-r--r--media/eco/ECOSession.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/media/eco/ECOSession.cpp b/media/eco/ECOSession.cpp
index 61820ae..319bac5 100644
--- a/media/eco/ECOSession.cpp
+++ b/media/eco/ECOSession.cpp
@@ -55,10 +55,10 @@ sp<ECOSession> ECOSession::createECOSession(int32_t width, int32_t height, bool
// Only support up to 720P and camera recording use case.
// TODO(hkuang): Support the same resolution as in EAF. Also relax the isCameraRecording
// as encoder may not konw it is from camera for some usage cases.
- if (width <= 0 || height <= 0 || width > 5120 || height > 5120 ||
- width > 1280 * 720 / height || isCameraRecording == false) {
- ALOGE("Failed to create ECOSession with w: %d, h: %d, isCameraRecording: %d", width, height,
- isCameraRecording);
+ if (width <= 0 || height <= 0 || width > 5120 || height > 5120 || width > 1280 * 720 / height ||
+ isCameraRecording == false) {
+ ECOLOGE("Failed to create ECOSession with w: %d, h: %d, isCameraRecording: %d", width,
+ height, isCameraRecording);
return nullptr;
}
return new ECOSession(width, height, isCameraRecording);
@@ -73,8 +73,8 @@ ECOSession::ECOSession(int32_t width, int32_t height, bool isCameraRecording)
mWidth(width),
mHeight(height),
mIsCameraRecording(isCameraRecording) {
- ALOGI("ECOSession created with w: %d, h: %d, isCameraRecording: %d", mWidth, mHeight,
- mIsCameraRecording);
+ ECOLOGI("ECOSession created with w: %d, h: %d, isCameraRecording: %d", mWidth, mHeight,
+ mIsCameraRecording);
mThread = std::thread(startThread, this);
}
@@ -83,11 +83,11 @@ ECOSession::~ECOSession() {
mStatsQueueWaitCV.notify_all();
if (mThread.joinable()) {
- ALOGD("ECOSession: join the thread");
+ ECOLOGD("ECOSession: join the thread");
mThread.join();
}
- ALOGI("ECOSession destroyed with w: %d, h: %d, isCameraRecording: %d", mWidth, mHeight,
- mIsCameraRecording);
+ ECOLOGI("ECOSession destroyed with w: %d, h: %d, isCameraRecording: %d", mWidth, mHeight,
+ mIsCameraRecording);
}
// static
@@ -96,7 +96,7 @@ void ECOSession::startThread(ECOSession* session) {
}
void ECOSession::run() {
- ALOGD("ECOSession: starting main thread");
+ ECOLOGD("ECOSession: starting main thread");
while (!mStopThread) {
std::unique_lock<std::mutex> runLock(mStatsQueueLock);
@@ -110,19 +110,19 @@ void ECOSession::run() {
}
}
- ALOGD("ECOSession: exiting main thread");
+ ECOLOGD("ECOSession: exiting main thread");
}
bool ECOSession::processStats(const ECOData& stats) {
if (stats.getDataType() != ECOData::DATA_TYPE_STATS) {
- ALOGE("Invalid stats. ECOData with type: %s", stats.getDataTypeString().c_str());
+ ECOLOGE("Invalid stats. ECOData with type: %s", stats.getDataTypeString().c_str());
return false;
}
// Get the type of the stats.
std::string statsType;
if (stats.findString(KEY_STATS_TYPE, &statsType) != ECODataStatus::OK) {
- ALOGE("Invalid stats ECOData without statsType");
+ ECOLOGE("Invalid stats ECOData without statsType");
return false;
}
@@ -131,7 +131,7 @@ bool ECOSession::processStats(const ECOData& stats) {
} else if (statsType.compare(VALUE_STATS_TYPE_FRAME) == 0) {
RETURN_IF_ERROR(processFrameStats(stats));
} else {
- ALOGE("processStats:: Failed to process stats as ECOData contains unknown stats type");
+ ECOLOGE("processStats:: Failed to process stats as ECOData contains unknown stats type");
return false;
}
@@ -139,7 +139,7 @@ bool ECOSession::processStats(const ECOData& stats) {
}
bool ECOSession::processSessionStats(const ECOData& stats) {
- ALOGV("processSessionStats");
+ ECOLOGV("processSessionStats");
ECOData info(ECOData::DATA_TYPE_INFO, systemTime(SYSTEM_TIME_BOOTTIME));
info.setString(KEY_INFO_TYPE, VALUE_INFO_TYPE_SESSION);
@@ -149,42 +149,42 @@ bool ECOSession::processSessionStats(const ECOData& stats) {
ECOData::ECODataKeyValuePair entry = iter.next();
const std::string& key = entry.first;
const ECOData::ECODataValueType value = entry.second;
- ALOGV("Processing key: %s", key.c_str());
+ ECOLOGV("Processing key: %s", key.c_str());
if (!key.compare(KEY_STATS_TYPE)) {
// Skip the key KEY_STATS_TYPE as that has been parsed already.
continue;
} else if (!key.compare(ENCODER_TYPE)) {
mCodecType = std::get<int32_t>(value);
- ALOGV("codec type is %d", mCodecType);
+ ECOLOGV("codec type is %d", mCodecType);
} else if (!key.compare(ENCODER_PROFILE)) {
mCodecProfile = std::get<int32_t>(value);
- ALOGV("codec profile is %d", mCodecProfile);
+ ECOLOGV("codec profile is %d", mCodecProfile);
} else if (!key.compare(ENCODER_LEVEL)) {
mCodecLevel = std::get<int32_t>(value);
- ALOGV("codec level is %d", mCodecLevel);
+ ECOLOGV("codec level is %d", mCodecLevel);
} else if (!key.compare(ENCODER_TARGET_BITRATE_BPS)) {
mBitrateBps = std::get<int32_t>(value);
- ALOGV("codec bitrate is %d", mBitrateBps);
+ ECOLOGV("codec bitrate is %d", mBitrateBps);
} else if (!key.compare(ENCODER_KFI_FRAMES)) {
mKeyFrameIntervalFrames = std::get<int32_t>(value);
- ALOGV("codec kfi is %d", mKeyFrameIntervalFrames);
+ ECOLOGV("codec kfi is %d", mKeyFrameIntervalFrames);
} else if (!key.compare(ENCODER_FRAMERATE_FPS)) {
mFramerateFps = std::get<float>(value);
- ALOGV("codec framerate is %f", mFramerateFps);
+ ECOLOGV("codec framerate is %f", mFramerateFps);
} else if (!key.compare(ENCODER_INPUT_WIDTH)) {
int32_t width = std::get<int32_t>(value);
if (width != mWidth) {
- ALOGW("Codec width: %d, expected: %d", width, mWidth);
+ ECOLOGW("Codec width: %d, expected: %d", width, mWidth);
}
- ALOGV("codec width is %d", width);
+ ECOLOGV("codec width is %d", width);
} else if (!key.compare(ENCODER_INPUT_HEIGHT)) {
int32_t height = std::get<int32_t>(value);
if (height != mHeight) {
- ALOGW("Codec height: %d, expected: %d", height, mHeight);
+ ECOLOGW("Codec height: %d, expected: %d", height, mHeight);
}
- ALOGV("codec height is %d", height);
+ ECOLOGV("codec height is %d", height);
} else {
- ALOGW("Unknown frame stats key %s from provider.", key.c_str());
+ ECOLOGW("Unknown session stats key %s from provider.", key.c_str());
continue;
}
info.set(key, value);
@@ -198,7 +198,7 @@ bool ECOSession::processSessionStats(const ECOData& stats) {
}
bool ECOSession::processFrameStats(const ECOData& stats) {
- ALOGD("processFrameStats");
+ ECOLOGD("processFrameStats");
bool needToNotifyListener = false;
ECOData info(ECOData::DATA_TYPE_INFO, systemTime(SYSTEM_TIME_BOOTTIME));
@@ -209,7 +209,7 @@ bool ECOSession::processFrameStats(const ECOData& stats) {
ECOData::ECODataKeyValuePair entry = iter.next();
const std::string& key = entry.first;
const ECOData::ECODataValueType value = entry.second;
- ALOGD("Processing %s key", key.c_str());
+ ECOLOGD("Processing %s key", key.c_str());
// Only process the keys that are supported by ECOService 1.0.
if (!key.compare(FRAME_NUM) || !key.compare(FRAME_PTS_US) || !key.compare(FRAME_TYPE) ||
@@ -243,7 +243,7 @@ bool ECOSession::processFrameStats(const ECOData& stats) {
info.set(key, value);
} else {
- ALOGW("Unknown frame stats key %s from provider.", key.c_str());
+ ECOLOGW("Unknown frame stats key %s from provider.", key.c_str());
}
}
@@ -260,11 +260,11 @@ Status ECOSession::addStatsProvider(
::android::String16 name;
provider->getName(&name);
- ALOGV("Try to add stats provider name: %s uid: %d pid %d", ::android::String8(name).string(),
- IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid());
+ ECOLOGV("Try to add stats provider name: %s uid: %d pid %d", ::android::String8(name).string(),
+ IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid());
if (provider == nullptr) {
- ALOGE("%s: provider must not be null", __FUNCTION__);
+ ECOLOGE("%s: provider must not be null", __FUNCTION__);
*status = false;
return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Null provider given to addStatsProvider");
}
@@ -277,14 +277,14 @@ Status ECOSession::addStatsProvider(
String8 errorMsg = String8::format(
"ECOService 1.0 only supports one stats provider, current provider: %s",
::android::String8(name).string());
- ALOGE("%s", errorMsg.string());
+ ECOLOGE("%s", errorMsg.string());
*status = false;
return STATUS_ERROR(ERROR_ALREADY_EXISTS, errorMsg.string());
}
// TODO: Handle the provider config.
if (config.getDataType() != ECOData::DATA_TYPE_STATS_PROVIDER_CONFIG) {
- ALOGE("Provider config is invalid");
+ ECOLOGE("Provider config is invalid");
*status = false;
return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Provider config is invalid");
}
@@ -315,26 +315,26 @@ Status ECOSession::addInfoListener(
std::scoped_lock<std::mutex> lock(mSessionLock);
if (mListener != nullptr) {
- ALOGE("ECOService 1.0 only supports one listener");
+ ECOLOGE("ECOService 1.0 only supports one listener");
*status = false;
return STATUS_ERROR(ERROR_ALREADY_EXISTS, "ECOService 1.0 only supports one listener");
}
if (listener == nullptr) {
- ALOGE("%s: listener must not be null", __FUNCTION__);
+ ECOLOGE("%s: listener must not be null", __FUNCTION__);
*status = false;
return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Null listener given to addInfoListener");
}
if (config.getDataType() != ECOData::DATA_TYPE_INFO_LISTENER_CONFIG) {
*status = false;
- ALOGE("%s: listener config is invalid", __FUNCTION__);
+ ECOLOGE("%s: listener config is invalid", __FUNCTION__);
return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "listener config is invalid");
}
if (config.isEmpty()) {
*status = false;
- ALOGE("Listener must provide listening criterion");
+ ECOLOGE("Listener must provide listening criterion");
return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "listener config is empty");
}
@@ -346,15 +346,15 @@ Status ECOSession::addInfoListener(
mListenerQpCondition.mQpBlocknessThreshold < ENCODER_MIN_QP ||
mListenerQpCondition.mQpBlocknessThreshold > ENCODER_MAX_QP) {
*status = false;
- ALOGE("%s: listener config is invalid", __FUNCTION__);
+ ECOLOGE("%s: listener config is invalid", __FUNCTION__);
return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "listener config is not valid");
}
::android::String16 name;
listener->getName(&name);
- ALOGD("Info listener name: %s uid: %d pid %d", ::android::String8(name).string(),
- IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid());
+ ECOLOGD("Info listener name: %s uid: %d pid %d", ::android::String8(name).string(),
+ IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid());
mListener = listener;
*status = true;
@@ -376,7 +376,7 @@ Status ECOSession::removeInfoListener(
}
Status ECOSession::pushNewStats(const ::android::media::eco::ECOData& stats, bool*) {
- ALOGV("ECOSession get new stats type: %s", stats.getDataTypeString().c_str());
+ ECOLOGV("ECOSession get new stats type: %s", stats.getDataTypeString().c_str());
std::unique_lock<std::mutex> lock(mStatsQueueLock);
mStatsQueue.push_back(stats);
mStatsQueueWaitCV.notify_all();
@@ -408,7 +408,7 @@ Status ECOSession::getNumOfProviders(int32_t* _aidl_return) {
}
/*virtual*/ void ECOSession::binderDied(const wp<IBinder>& /*who*/) {
- ALOGV("binderDied");
+ ECOLOGV("binderDied");
}
} // namespace eco