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

Commit a2b88283 authored by Girish's avatar Girish
Browse files

resourcemanager: map right codec type for metrics

ResourceSubType defined by the resource manager is correctly
mapped into media_metrics codec type using a function.

Bug: 324297311
Test: atest android.media.misc.cts.ResourceManagerTest
      atest android.media.misc.cts.ResourceManagerMultiTest
      /data/nativetest64/ResourceManagerService_test/ResourceManagerService_test
      /data/nativetest64/ResourceObserverService_test/ResourceObserverService_test
Change-Id: Ia2e1afaa3a7c0c1fd4b6d17550dc49472779a3f4
parent ada1d984
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -43,6 +43,28 @@ using stats::media_metrics::\
    MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED__RECLAIM_STATUS__RECLAIM_FAILED_NO_CLIENTS;
using stats::media_metrics::\
    MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED__RECLAIM_STATUS__RECLAIM_FAILED_RECLAIM_RESOURCES;
using stats::media_metrics::MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_UNSPECIFIED;
using stats::media_metrics::MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_AUDIO;
using stats::media_metrics::MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_VIDEO;
using stats::media_metrics::MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_IMAGE;

// Map MediaResourceSubType to stats::media_metrics::CodecType
inline int32_t getMetricsCodecType(MediaResourceSubType codecType) {
    switch (codecType) {
        case MediaResourceSubType::kHwAudioCodec:
        case MediaResourceSubType::kSwAudioCodec:
            return MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_AUDIO;
        case MediaResourceSubType::kHwVideoCodec:
        case MediaResourceSubType::kSwVideoCodec:
            return MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_VIDEO;
        case MediaResourceSubType::kHwImageCodec:
        case MediaResourceSubType::kSwImageCodec:
            return MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_IMAGE;
        case MediaResourceSubType::kUnspecifiedSubType:
            return MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_UNSPECIFIED;
    }
    return MEDIA_CODEC_STARTED__CODEC_TYPE__CODEC_TYPE_UNSPECIFIED;
}

inline const char* getCodecType(MediaResourceSubType codecType) {
    switch (codecType) {
@@ -229,7 +251,7 @@ void ResourceManagerMetrics::notifyClientStarted(const ClientConfigParcel& clien
         clientConfig.clientInfo.uid,
         clientConfig.id,
         clientConfig.clientInfo.name.c_str(),
         static_cast<int32_t>(clientConfig.codecType),
         getMetricsCodecType(clientConfig.codecType),
         clientConfig.isEncoder,
         isHardwareCodec(clientConfig.codecType),
         clientConfig.width, clientConfig.height,
@@ -311,7 +333,7 @@ void ResourceManagerMetrics::notifyClientStopped(const ClientConfigParcel& clien
         clientConfig.clientInfo.uid,
         clientConfig.id,
         clientConfig.clientInfo.name.c_str(),
         static_cast<int32_t>(clientConfig.codecType),
         getMetricsCodecType(clientConfig.codecType),
         clientConfig.isEncoder,
         isHardwareCodec(clientConfig.codecType),
         clientConfig.width, clientConfig.height,