• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //#define LOG_NDEBUG 0
18 #define LOG_TAG "ECOSession"
19 //#define DEBUG_ECO_SESSION
20 #include "eco/ECOSession.h"
21 
22 #include <binder/BinderService.h>
23 #include <cutils/atomic.h>
24 #include <inttypes.h>
25 #include <pthread.h>
26 #include <stdio.h>
27 #include <sys/types.h>
28 #include <utils/Log.h>
29 
30 #include <algorithm>
31 #include <climits>
32 #include <cstring>
33 #include <ctime>
34 #include <string>
35 
36 #include "eco/ECODataKey.h"
37 #include "eco/ECODebug.h"
38 
39 namespace android {
40 namespace media {
41 namespace eco {
42 
43 using android::binder::Status;
44 using android::sp;
45 
46 #define RETURN_IF_ERROR(expr)         \
47     {                                 \
48         status_t _errorCode = (expr); \
49         if (_errorCode != true) {     \
50             return _errorCode;        \
51         }                             \
52     }
53 
54 // static
createECOSession(int32_t width,int32_t height,bool isCameraRecording)55 sp<ECOSession> ECOSession::createECOSession(int32_t width, int32_t height, bool isCameraRecording) {
56     // Only support up to 720P.
57     // TODO: Support the same resolution as in EAF.
58     if (width <= 0 || height <= 0 || width > 5120 || height > 5120 ||
59         width > 1280 * 720 / height) {
60         ECOLOGE("Failed to create ECOSession with w: %d, h: %d, isCameraRecording: %d", width,
61                 height, isCameraRecording);
62         return nullptr;
63     }
64     return new ECOSession(width, height, isCameraRecording);
65 }
66 
ECOSession(int32_t width,int32_t height,bool isCameraRecording)67 ECOSession::ECOSession(int32_t width, int32_t height, bool isCameraRecording)
68       : BnECOSession(),
69         mStopThread(false),
70         mLastReportedQp(0),
71         mListener(nullptr),
72         mProvider(nullptr),
73         mWidth(width),
74         mHeight(height),
75         mIsCameraRecording(isCameraRecording) {
76     ECOLOGI("ECOSession created with w: %d, h: %d, isCameraRecording: %d", mWidth, mHeight,
77             mIsCameraRecording);
78     mThread = std::thread(startThread, this);
79 
80     // Read the debug properies.
81     mLogStats = property_get_bool(kDebugLogStats, false);
82     mLogStatsEntries = mLogStats ? property_get_int32(kDebugLogStatsSize, 0) : 0;
83 
84     mLogInfo = property_get_bool(kDebugLogStats, false);
85     mLogInfoEntries = mLogInfo ? property_get_int32(kDebugLogInfosSize, 0) : 0;
86 
87     ECOLOGI("ECOSession debug settings: logStats: %s, entries: %d, logInfo: %s entries: %d",
88             mLogStats ? "true" : "false", mLogStatsEntries, mLogInfo ? "true" : "false",
89             mLogInfoEntries);
90 }
91 
~ECOSession()92 ECOSession::~ECOSession() {
93     mStopThread = true;
94 
95     mWorkerWaitCV.notify_all();
96     if (mThread.joinable()) {
97         ECOLOGD("ECOSession: join the thread");
98         mThread.join();
99     }
100     ECOLOGI("ECOSession destroyed with w: %d, h: %d, isCameraRecording: %d", mWidth, mHeight,
101             mIsCameraRecording);
102 }
103 
104 // static
startThread(ECOSession * session)105 void ECOSession::startThread(ECOSession* session) {
106     session->run();
107 }
108 
run()109 void ECOSession::run() {
110     ECOLOGD("ECOSession: starting main thread");
111 
112     while (!mStopThread) {
113         std::unique_lock<std::mutex> runLock(mStatsQueueLock);
114 
115         mWorkerWaitCV.wait(runLock, [this] {
116             return mStopThread == true || !mStatsQueue.empty() || mNewListenerAdded;
117         });
118 
119         if (mStopThread) return;
120 
121         std::scoped_lock<std::mutex> lock(mSessionLock);
122         if (mNewListenerAdded) {
123             // Check if there is any session info available.
124             ECOData sessionInfo = generateLatestSessionInfoEcoData();
125             if (!sessionInfo.isEmpty()) {
126                 Status status = mListener->onNewInfo(sessionInfo);
127                 if (!status.isOk()) {
128                     ECOLOGE("%s: Failed to publish info: %s due to binder error", __FUNCTION__,
129                             sessionInfo.debugString().c_str());
130                     // Remove the listener. The lock has been acquired outside this function.
131                     mListener = nullptr;
132                 }
133             }
134             mNewListenerAdded = false;
135         }
136 
137         if (!mStatsQueue.empty()) {
138             ECOData stats = mStatsQueue.front();
139             mStatsQueue.pop_front();
140             processStats(stats);  // TODO: Handle the error from processStats
141         }
142     }
143 
144     ECOLOGD("ECOSession: exiting main thread");
145 }
146 
processStats(const ECOData & stats)147 bool ECOSession::processStats(const ECOData& stats) {
148     ECOLOGV("%s: receive stats: %s", __FUNCTION__, stats.debugString().c_str());
149 
150     if (stats.getDataType() != ECOData::DATA_TYPE_STATS) {
151         ECOLOGE("Invalid stats. ECOData with type: %s", stats.getDataTypeString().c_str());
152         return false;
153     }
154 
155     // Get the type of the stats.
156     std::string statsType;
157     if (stats.findString(KEY_STATS_TYPE, &statsType) != ECODataStatus::OK) {
158         ECOLOGE("Invalid stats ECOData without statsType");
159         return false;
160     }
161 
162     if (statsType.compare(VALUE_STATS_TYPE_SESSION) == 0) {
163         processSessionStats(stats);
164     } else if (statsType.compare(VALUE_STATS_TYPE_FRAME) == 0) {
165         processFrameStats(stats);
166     } else {
167         ECOLOGE("processStats:: Failed to process stats as ECOData contains unknown stats type");
168         return false;
169     }
170 
171     return true;
172 }
173 
processSessionStats(const ECOData & stats)174 void ECOSession::processSessionStats(const ECOData& stats) {
175     ECOLOGV("processSessionStats");
176 
177     ECOData info(ECOData::DATA_TYPE_INFO, systemTime(SYSTEM_TIME_BOOTTIME));
178     info.setString(KEY_INFO_TYPE, VALUE_INFO_TYPE_SESSION);
179 
180     ECODataKeyValueIterator iter(stats);
181     while (iter.hasNext()) {
182         ECOData::ECODataKeyValuePair entry = iter.next();
183         const std::string& key = entry.first;
184         const ECOData::ECODataValueType value = entry.second;
185         ECOLOGV("Processing key: %s", key.c_str());
186         if (!key.compare(KEY_STATS_TYPE)) {
187             // Skip the key KEY_STATS_TYPE as that has been parsed already.
188             continue;
189         } else if (!key.compare(ENCODER_TYPE)) {
190             mCodecType = std::get<int32_t>(value);
191             ECOLOGV("codec type is %d", mCodecType);
192         } else if (!key.compare(ENCODER_PROFILE)) {
193             mCodecProfile = std::get<int32_t>(value);
194             ECOLOGV("codec profile is %d", mCodecProfile);
195         } else if (!key.compare(ENCODER_LEVEL)) {
196             mCodecLevel = std::get<int32_t>(value);
197             ECOLOGV("codec level is %d", mCodecLevel);
198         } else if (!key.compare(ENCODER_TARGET_BITRATE_BPS)) {
199             mTargetBitrateBps = std::get<int32_t>(value);
200             ECOLOGV("codec target bitrate is %d", mTargetBitrateBps);
201         } else if (!key.compare(ENCODER_KFI_FRAMES)) {
202             mKeyFrameIntervalFrames = std::get<int32_t>(value);
203             ECOLOGV("codec kfi is %d", mKeyFrameIntervalFrames);
204         } else if (!key.compare(ENCODER_FRAMERATE_FPS)) {
205             mFramerateFps = std::get<float>(value);
206             ECOLOGV("codec framerate is %f", mFramerateFps);
207         } else if (!key.compare(ENCODER_INPUT_WIDTH)) {
208             int32_t width = std::get<int32_t>(value);
209             if (width != mWidth) {
210                 ECOLOGW("Codec width: %d, expected: %d", width, mWidth);
211             }
212             ECOLOGV("codec width is %d", width);
213         } else if (!key.compare(ENCODER_INPUT_HEIGHT)) {
214             int32_t height = std::get<int32_t>(value);
215             if (height != mHeight) {
216                 ECOLOGW("Codec height: %d, expected: %d", height, mHeight);
217             }
218             ECOLOGV("codec height is %d", height);
219         } else {
220             ECOLOGW("Unknown session stats key %s from provider.", key.c_str());
221             continue;
222         }
223         info.set(key, value);
224     }
225 
226     if (mListener != nullptr) {
227         Status status = mListener->onNewInfo(info);
228         if (!status.isOk()) {
229             ECOLOGE("%s: Failed to publish info: %s due to binder error", __FUNCTION__,
230                     info.debugString().c_str());
231             // Remove the listener. The lock has been acquired outside this function.
232             mListener = nullptr;
233         }
234     }
235 }
236 
generateLatestSessionInfoEcoData()237 ECOData ECOSession::generateLatestSessionInfoEcoData() {
238     bool hasInfo = false;
239 
240     ECOData info(ECOData::DATA_TYPE_INFO, systemTime(SYSTEM_TIME_BOOTTIME));
241 
242     if (mOutputWidth != -1) {
243         info.setInt32(ENCODER_OUTPUT_WIDTH, mOutputWidth);
244         hasInfo = true;
245     }
246 
247     if (mOutputHeight != -1) {
248         info.setInt32(ENCODER_OUTPUT_HEIGHT, mOutputHeight);
249         hasInfo = true;
250     }
251 
252     if (mCodecType != -1) {
253         info.setInt32(ENCODER_TYPE, mCodecType);
254         hasInfo = true;
255     }
256 
257     if (mCodecProfile != -1) {
258         info.setInt32(ENCODER_PROFILE, mCodecProfile);
259         hasInfo = true;
260     }
261 
262     if (mCodecLevel != -1) {
263         info.setInt32(ENCODER_LEVEL, mCodecLevel);
264         hasInfo = true;
265     }
266 
267     if (mTargetBitrateBps != -1) {
268         info.setInt32(ENCODER_TARGET_BITRATE_BPS, mTargetBitrateBps);
269         hasInfo = true;
270     }
271 
272     if (mKeyFrameIntervalFrames != -1) {
273         info.setInt32(ENCODER_KFI_FRAMES, mKeyFrameIntervalFrames);
274         hasInfo = true;
275     }
276 
277     if (mFramerateFps > 0) {
278         info.setFloat(ENCODER_FRAMERATE_FPS, mFramerateFps);
279         hasInfo = true;
280     }
281 
282     if (hasInfo) {
283         info.setString(KEY_INFO_TYPE, VALUE_INFO_TYPE_SESSION);
284     }
285     return info;
286 }
287 
processFrameStats(const ECOData & stats)288 void ECOSession::processFrameStats(const ECOData& stats) {
289     ECOLOGD("processFrameStats");
290 
291     bool needToNotifyListener = false;
292     ECOData info(ECOData::DATA_TYPE_INFO, systemTime(SYSTEM_TIME_BOOTTIME));
293     info.setString(KEY_INFO_TYPE, VALUE_INFO_TYPE_FRAME);
294 
295     ECODataKeyValueIterator iter(stats);
296     while (iter.hasNext()) {
297         ECOData::ECODataKeyValuePair entry = iter.next();
298         const std::string& key = entry.first;
299         const ECOData::ECODataValueType value = entry.second;
300         ECOLOGD("Processing %s key", key.c_str());
301 
302         if (!key.compare(KEY_STATS_TYPE)) {
303             // Skip the key KEY_STATS_TYPE as that has been parsed already.
304             continue;
305         } else if (!key.compare(FRAME_NUM) || !key.compare(FRAME_PTS_US) ||
306                    !key.compare(FRAME_TYPE) || !key.compare(FRAME_SIZE_BYTES) ||
307                    !key.compare(ENCODER_ACTUAL_BITRATE_BPS)) {
308             // Only process the keys that are supported by ECOService 1.0.
309             info.set(key, value);
310         } else if (!key.compare(FRAME_AVG_QP)) {
311             // Check the qp to see if need to notify the listener.
312             const int32_t currAverageQp = std::get<int32_t>(value);
313 
314             // Check if the delta between current QP and last reported QP is larger than the
315             // threshold specified by the listener.
316             const bool largeQPChangeDetected =
317                     abs(currAverageQp - mLastReportedQp) > mListenerQpCondition.mQpChangeThreshold;
318 
319             // Check if the qp is going from below threshold to beyond threshold.
320             const bool exceedQpBlockinessThreshold =
321                     (mLastReportedQp <= mListenerQpCondition.mQpBlocknessThreshold &&
322                      currAverageQp > mListenerQpCondition.mQpBlocknessThreshold);
323 
324             // Check if the qp is going from beyond threshold to below threshold.
325             const bool fallBelowQpBlockinessThreshold =
326                     (mLastReportedQp > mListenerQpCondition.mQpBlocknessThreshold &&
327                      currAverageQp <= mListenerQpCondition.mQpBlocknessThreshold);
328 
329             // Notify the listener if any of the above three conditions met.
330             if (largeQPChangeDetected || exceedQpBlockinessThreshold ||
331                 fallBelowQpBlockinessThreshold) {
332                 mLastReportedQp = currAverageQp;
333                 needToNotifyListener = true;
334             }
335 
336             info.set(key, value);
337         } else {
338             ECOLOGW("Unknown frame stats key %s from provider.", key.c_str());
339         }
340     }
341 
342     if (needToNotifyListener && mListener != nullptr) {
343         Status status = mListener->onNewInfo(info);
344         if (!status.isOk()) {
345             ECOLOGE("%s: Failed to publish info: %s due to binder error", __FUNCTION__,
346                     info.debugString().c_str());
347             // Remove the listener. The lock has been acquired outside this function.
348             mListener = nullptr;
349         }
350     }
351 }
352 
getIsCameraRecording(bool * _aidl_return)353 Status ECOSession::getIsCameraRecording(bool* _aidl_return) {
354     std::scoped_lock<std::mutex> lock(mSessionLock);
355     *_aidl_return = mIsCameraRecording;
356     return binder::Status::ok();
357 }
358 
addStatsProvider(const sp<::android::media::eco::IECOServiceStatsProvider> & provider,const::android::media::eco::ECOData & config,bool * status)359 Status ECOSession::addStatsProvider(
360         const sp<::android::media::eco::IECOServiceStatsProvider>& provider,
361         const ::android::media::eco::ECOData& config, bool* status) {
362     ::android::String16 name;
363     Status result = provider->getName(&name);
364     if (!result.isOk()) {
365         // This binder transaction failure may due to permission issue.
366         *status = false;
367         ALOGE("Failed to get provider name");
368         return STATUS_ERROR(ERROR_PERMISSION_DENIED, "Failed to get provider name");
369     }
370 
371     ECOLOGV("Try to add stats provider name: %s uid: %d pid %d", ::android::String8(name).string(),
372             IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid());
373 
374     if (provider == nullptr) {
375         ECOLOGE("%s: provider must not be null", __FUNCTION__);
376         *status = false;
377         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Null provider given to addStatsProvider");
378     }
379 
380     std::scoped_lock<std::mutex> lock(mSessionLock);
381 
382     if (mProvider != nullptr) {
383         ::android::String16 name;
384         mProvider->getName(&name);
385         String8 errorMsg = String8::format(
386                 "ECOService 1.0 only supports one stats provider, current provider: %s",
387                 ::android::String8(name).string());
388         ECOLOGE("%s", errorMsg.string());
389         *status = false;
390         return STATUS_ERROR(ERROR_ALREADY_EXISTS, errorMsg.string());
391     }
392 
393     // TODO: Handle the provider config.
394     if (config.getDataType() != ECOData::DATA_TYPE_STATS_PROVIDER_CONFIG) {
395         ECOLOGE("Provider config is invalid");
396         *status = false;
397         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Provider config is invalid");
398     }
399 
400     mProvider = provider;
401     mProviderName = name;
402     *status = true;
403     return binder::Status::ok();
404 }
405 
removeStatsProvider(const sp<::android::media::eco::IECOServiceStatsProvider> & provider,bool * status)406 Status ECOSession::removeStatsProvider(
407         const sp<::android::media::eco::IECOServiceStatsProvider>& provider, bool* status) {
408     std::scoped_lock<std::mutex> lock(mSessionLock);
409     // Check if the provider is the same as current provider for the session.
410     if (provider.get() != mProvider.get()) {
411         *status = false;
412         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Provider does not match");
413     }
414 
415     mProvider = nullptr;
416     *status = true;
417     return binder::Status::ok();
418 }
419 
addInfoListener(const sp<::android::media::eco::IECOServiceInfoListener> & listener,const::android::media::eco::ECOData & config,bool * status)420 Status ECOSession::addInfoListener(
421         const sp<::android::media::eco::IECOServiceInfoListener>& listener,
422         const ::android::media::eco::ECOData& config, bool* status) {
423     ALOGV("%s: Add listener %p", __FUNCTION__, listener.get());
424     std::scoped_lock<std::mutex> lock(mSessionLock);
425 
426     ::android::String16 name;
427     Status result = listener->getName(&name);
428     if (!result.isOk()) {
429         // This binder transaction failure may due to permission issue.
430         *status = false;
431         ALOGE("Failed to get listener name");
432         return STATUS_ERROR(ERROR_PERMISSION_DENIED, "Failed to get listener name");
433     }
434 
435     if (mListener != nullptr) {
436         ECOLOGE("ECOService 1.0 only supports one listener");
437         *status = false;
438         return STATUS_ERROR(ERROR_ALREADY_EXISTS, "ECOService 1.0 only supports one listener");
439     }
440 
441     if (listener == nullptr) {
442         ECOLOGE("%s: listener must not be null", __FUNCTION__);
443         *status = false;
444         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Null listener given to addInfoListener");
445     }
446 
447     if (config.getDataType() != ECOData::DATA_TYPE_INFO_LISTENER_CONFIG) {
448         *status = false;
449         ECOLOGE("%s: listener config is invalid", __FUNCTION__);
450         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "listener config is invalid");
451     }
452 
453     if (config.isEmpty()) {
454         *status = false;
455         ECOLOGE("Listener must provide listening criterion");
456         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "listener config is empty");
457     }
458 
459     // For ECOService 1.0, listener must specify the two threshold in order to receive info.
460     if (config.findInt32(KEY_LISTENER_QP_BLOCKINESS_THRESHOLD,
461                          &mListenerQpCondition.mQpBlocknessThreshold) != ECODataStatus::OK ||
462         config.findInt32(KEY_LISTENER_QP_CHANGE_THRESHOLD,
463                          &mListenerQpCondition.mQpChangeThreshold) != ECODataStatus::OK ||
464         mListenerQpCondition.mQpBlocknessThreshold < ENCODER_MIN_QP ||
465         mListenerQpCondition.mQpBlocknessThreshold > ENCODER_MAX_QP) {
466         *status = false;
467         ECOLOGE("%s: listener config is invalid", __FUNCTION__);
468         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "listener config is not valid");
469     }
470 
471     ECOLOGD("Info listener name: %s uid: %d pid %d", ::android::String8(name).string(),
472             IPCThreadState::self()->getCallingUid(), IPCThreadState::self()->getCallingPid());
473 
474     mListener = listener;
475     mListenerName = name;
476     mNewListenerAdded = true;
477     mWorkerWaitCV.notify_all();
478 
479     *status = true;
480     return binder::Status::ok();
481 }
482 
removeInfoListener(const sp<::android::media::eco::IECOServiceInfoListener> & listener,bool * _aidl_return)483 Status ECOSession::removeInfoListener(
484         const sp<::android::media::eco::IECOServiceInfoListener>& listener, bool* _aidl_return) {
485     std::scoped_lock<std::mutex> lock(mSessionLock);
486     // Check if the listener is the same as current listener for the session.
487     if (listener.get() != mListener.get()) {
488         *_aidl_return = false;
489         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, "Listener does not match");
490     }
491 
492     mListener = nullptr;
493     mNewListenerAdded = false;
494     *_aidl_return = true;
495     return binder::Status::ok();
496 }
497 
pushNewStats(const::android::media::eco::ECOData & stats,bool *)498 Status ECOSession::pushNewStats(const ::android::media::eco::ECOData& stats, bool*) {
499     ECOLOGV("ECOSession get new stats type: %s", stats.getDataTypeString().c_str());
500     std::unique_lock<std::mutex> lock(mStatsQueueLock);
501     mStatsQueue.push_back(stats);
502     mWorkerWaitCV.notify_all();
503     return binder::Status::ok();
504 }
505 
getWidth(int32_t * _aidl_return)506 Status ECOSession::getWidth(int32_t* _aidl_return) {
507     std::scoped_lock<std::mutex> lock(mSessionLock);
508     *_aidl_return = mWidth;
509     return binder::Status::ok();
510 }
511 
getHeight(int32_t * _aidl_return)512 Status ECOSession::getHeight(int32_t* _aidl_return) {
513     std::scoped_lock<std::mutex> lock(mSessionLock);
514     *_aidl_return = mHeight;
515     return binder::Status::ok();
516 }
517 
getNumOfListeners(int32_t * _aidl_return)518 Status ECOSession::getNumOfListeners(int32_t* _aidl_return) {
519     std::scoped_lock<std::mutex> lock(mSessionLock);
520     *_aidl_return = (mListener == nullptr ? 0 : 1);
521     return binder::Status::ok();
522 }
523 
getNumOfProviders(int32_t * _aidl_return)524 Status ECOSession::getNumOfProviders(int32_t* _aidl_return) {
525     std::scoped_lock<std::mutex> lock(mSessionLock);
526     *_aidl_return = (mProvider == nullptr ? 0 : 1);
527     return binder::Status::ok();
528 }
529 
binderDied(const wp<IBinder> &)530 /*virtual*/ void ECOSession::binderDied(const wp<IBinder>& /*who*/) {
531     ECOLOGV("binderDied");
532 }
533 
dump(int fd,const Vector<String16> &)534 status_t ECOSession::dump(int fd, const Vector<String16>& /*args*/) {
535     std::scoped_lock<std::mutex> lock(mSessionLock);
536     dprintf(fd, "\n== Session Info: ==\n\n");
537     dprintf(fd,
538             "Width: %d Height: %d isCameraRecording: %d, target-bitrate: %d bps codetype: %d "
539             "profile: %d level: %d\n",
540             mWidth, mHeight, mIsCameraRecording, mTargetBitrateBps, mCodecType, mCodecProfile,
541             mCodecLevel);
542     if (mProvider != nullptr) {
543         dprintf(fd, "Provider: %s \n", ::android::String8(mProviderName).string());
544     }
545     if (mListener != nullptr) {
546         dprintf(fd, "Listener: %s \n", ::android::String8(mListenerName).string());
547     }
548     dprintf(fd, "\n===================\n\n");
549 
550     return NO_ERROR;
551 }
552 
logStats(const ECOData & data)553 void ECOSession::logStats(const ECOData& data) {
554     // Check if mLogStats is true;
555     if (!mLogStats || mLogStatsEntries == 0) return;
556 
557     // Check if we need to remove the old entry.
558     if (mStatsDebugBuffer.size() >= mLogStatsEntries) {
559         mStatsDebugBuffer.pop_front();
560     }
561 
562     mStatsDebugBuffer.push_back(data);
563 }
564 
logInfos(const ECOData & data)565 void ECOSession::logInfos(const ECOData& data) {
566     // Check if mLogInfo is true;
567     if (!mLogInfo || mLogInfoEntries == 0) return;
568 
569     // Check if we need to remove the old entry.
570     if (mInfosDebugBuffer.size() >= mLogInfoEntries) {
571         mInfosDebugBuffer.pop_front();
572     }
573 
574     mInfosDebugBuffer.push_back(data);
575 }
576 
577 }  // namespace eco
578 }  // namespace media
579 }  // namespace android
580