1 /* 2 * Copyright (C) 2020 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 #ifndef ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H 18 #define ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H 19 20 /* 21 * MediaMetrics Keys and Properties. 22 * 23 * C/C++ friendly constants that ensure 24 * 1) Compilation error on misspelling 25 * 2) Consistent behavior and documentation. 26 */ 27 28 #define AMEDIAMETRICS_INITIAL_MAX_VOLUME (0.f) 29 #define AMEDIAMETRICS_INITIAL_MIN_VOLUME (1.f) 30 31 /* 32 * Taxonomy of audio keys 33 * 34 * To build longer keys, we use compiler string concatenation of 35 * adjacent string literals. This is done in the translation phase 36 * of compilation to make a single string token. 37 */ 38 39 // Key Prefixes are used for MediaMetrics Item Keys and ends with a ".". 40 // They must be appended with another value to make a key. 41 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO "audio." 42 43 // Device related key prefix. 44 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_DEVICE AMEDIAMETRICS_KEY_PREFIX_AUDIO "device." 45 46 // The AudioMmap key appends the "trackId" to the prefix. 47 // This is the AudioFlinger equivalent of the AAudio Stream. 48 // TODO: unify with AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM 49 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_MMAP AMEDIAMETRICS_KEY_PREFIX_AUDIO "mmap." 50 51 // The AudioRecord key appends the "trackId" to the prefix. 52 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD AMEDIAMETRICS_KEY_PREFIX_AUDIO "record." 53 54 // The Audio Sensor key appends the sensor handle integer. 55 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_SENSOR AMEDIAMETRICS_KEY_PREFIX_AUDIO "sensor." 56 57 // The Audio Spatializer key appends the spatializerId (currently 0) 58 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_SPATIALIZER AMEDIAMETRICS_KEY_PREFIX_AUDIO "spatializer." 59 60 // The Audio Spatializer device key appends the device type. 61 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_SPATIALIZER_DEVICE \ 62 AMEDIAMETRICS_KEY_PREFIX_AUDIO_SPATIALIZER "device." 63 64 // The AudioStream key appends the "streamId" to the prefix. 65 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM AMEDIAMETRICS_KEY_PREFIX_AUDIO "stream." 66 67 // The AudioThread key appends the "threadId" to the prefix. 68 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_THREAD AMEDIAMETRICS_KEY_PREFIX_AUDIO "thread." 69 70 // The AudioTrack key appends the "trackId" to the prefix. 71 #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK AMEDIAMETRICS_KEY_PREFIX_AUDIO "track." 72 73 // Keys are strings used for MediaMetrics Item Keys 74 #define AMEDIAMETRICS_KEY_AUDIO_FLINGER AMEDIAMETRICS_KEY_PREFIX_AUDIO "flinger" 75 #define AMEDIAMETRICS_KEY_AUDIO_POLICY AMEDIAMETRICS_KEY_PREFIX_AUDIO "policy" 76 77 // Error keys 78 #define AMEDIAMETRICS_KEY_AUDIO_TRACK_ERROR AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK "error" 79 #define AMEDIAMETRICS_KEY_AUDIO_RECORD_ERROR AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD "error" 80 81 /* 82 * MediaMetrics Properties are unified space for consistency and readability. 83 */ 84 85 // Property prefixes may be applied before a property name to indicate a specific 86 // category to which it is associated. 87 #define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective." 88 #define AMEDIAMETRICS_PROP_PREFIX_HAL "hal." 89 #define AMEDIAMETRICS_PROP_PREFIX_HAPTIC "haptic." 90 #define AMEDIAMETRICS_PROP_PREFIX_LAST "last." 91 #define AMEDIAMETRICS_PROP_PREFIX_SERVER "server." 92 93 // Properties within mediametrics are string constants denoted by 94 // a macro name beginning with AMEDIAMETRICS_PROP_* 95 // 96 // For a property name like "auxEffectId" we write this as a single upper case word 97 // at the end of the macro name, such as AMEDIAMETRICS_PROP_AUXEFFECTID. 98 // 99 // Underscores after the AMEDIAMETRICS_PROP_* prefix indicate 100 // a "dot" in the property name. For example AMEDIAMETRICS_PROP_VOLUME_LEFT 101 // corresponds to "volume.left". 102 // 103 // The property names are camel case, typically a lowercase letter [a-z] 104 // followed by one or more characters in the range [a-zA-Z0-9_.]. 105 // Special symbols such as !@#$%^&*()[]{}<>,:;'"\/?|+-=~ are reserved. 106 // 107 // Properties within this header should include special suffixes like '#' 108 // directly in the string for brevity. Code outside of this header should 109 // use the macro constant for the special symbols for searchability. 110 111 // Any property that ends with a # will have duplicate values listed instead 112 // of suppressed in the Time Machine. 113 #define AMEDIAMETRICS_PROP_SUFFIX_CHAR_DUPLICATES_ALLOWED '#' 114 115 #define AMEDIAMETRICS_PROP_ADDRESS "address" // string, for example MAC address 116 #define AMEDIAMETRICS_PROP_ALLOWUID "_allowUid" // int32_t, allow client uid to post 117 #define AMEDIAMETRICS_PROP_AUDIOMODE "audioMode" // string (audio.flinger) 118 #define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack) 119 #define AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES "bufferSizeFrames" // int32 120 #define AMEDIAMETRICS_PROP_BUFFERCAPACITYFRAMES "bufferCapacityFrames" // int32 121 #define AMEDIAMETRICS_PROP_BURSTFRAMES "burstFrames" // int32 122 #define AMEDIAMETRICS_PROP_CALLERNAME "callerName" // string, eg. "aaudio" 123 #define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32 124 #define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32 125 #define AMEDIAMETRICS_PROP_CHANNELMASKS "channelMasks" // string with channelMask values 126 // separated by |. 127 #define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack) 128 #define AMEDIAMETRICS_PROP_CUMULATIVETIMENS "cumulativeTimeNs" // int64_t playback/record time 129 // since start 130 // DEVICE values are averaged since starting on device 131 #define AMEDIAMETRICS_PROP_DEVICELATENCYMS "deviceLatencyMs" // double - avg latency time 132 #define AMEDIAMETRICS_PROP_DEVICESTARTUPMS "deviceStartupMs" // double - avg startup time 133 #define AMEDIAMETRICS_PROP_DEVICETIMENS "deviceTimeNs" // int64_t playback/record time 134 #define AMEDIAMETRICS_PROP_DEVICEVOLUME "deviceVolume" // double - average device volume 135 136 #define AMEDIAMETRICS_PROP_DEVICEMAXVOLUMEDURATIONNS "deviceMaxVolumeDurationNs" // int64_t 137 #define AMEDIAMETRICS_PROP_DEVICEMAXVOLUME "deviceMaxVolume" // double - maximum device volume 138 #define AMEDIAMETRICS_PROP_DEVICEMINVOLUMEDURATIONNS "deviceMinVolumeDurationNs" // int64_t 139 #define AMEDIAMETRICS_PROP_DEVICEMINVOLUME "deviceMinVolume" // double - minimum device volume 140 141 #define AMEDIAMETRICS_PROP_DIRECTION "direction" // string AAudio input or output 142 #define AMEDIAMETRICS_PROP_DURATIONNS "durationNs" // int64 duration time span 143 #define AMEDIAMETRICS_PROP_ENABLED "enabled" // string true/false. 144 #define AMEDIAMETRICS_PROP_ENCODING "encoding" // string value of format 145 146 #define AMEDIAMETRICS_PROP_EVENT "event#" // string value (often func name) 147 #define AMEDIAMETRICS_PROP_EXECUTIONTIMENS "executionTimeNs" // time to execute the event 148 149 // TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32, AudioThread string 150 #define AMEDIAMETRICS_PROP_FLAGS "flags" 151 152 #define AMEDIAMETRICS_PROP_FRAMECOUNT "frameCount" // int32 153 #define AMEDIAMETRICS_PROP_HASHEADTRACKER "hasHeadTracker" // string true/false 154 #define AMEDIAMETRICS_PROP_HEADTRACKERENABLED "headTrackerEnabled" // string true/false 155 #define AMEDIAMETRICS_PROP_HEADTRACKINGMODES "headTrackingModes" // string |, like modes. 156 #define AMEDIAMETRICS_PROP_INPUTDEVICES "inputDevices" // string value 157 #define AMEDIAMETRICS_PROP_INTERNALTRACKID "internalTrackId" // int32 158 #define AMEDIAMETRICS_PROP_INTERVALCOUNT "intervalCount" // int32 159 #define AMEDIAMETRICS_PROP_LATENCYMS "latencyMs" // double value 160 #define AMEDIAMETRICS_PROP_LEVELS "levels" // string | with levels 161 #define AMEDIAMETRICS_PROP_LOGSESSIONID "logSessionId" // hex string, "" none 162 #define AMEDIAMETRICS_PROP_METHODCODE "methodCode" // int64_t an int indicating method 163 #define AMEDIAMETRICS_PROP_METHODNAME "methodName" // string method name 164 #define AMEDIAMETRICS_PROP_MODE "mode" // string 165 #define AMEDIAMETRICS_PROP_MODES "modes" // string | with modes 166 #define AMEDIAMETRICS_PROP_NAME "name" // string value 167 #define AMEDIAMETRICS_PROP_ORIGINALFLAGS "originalFlags" // int32 168 #define AMEDIAMETRICS_PROP_OUTPUTDEVICES "outputDevices" // string value 169 #define AMEDIAMETRICS_PROP_PERFORMANCEMODE "performanceMode" // string value, "none", lowLatency" 170 #define AMEDIAMETRICS_PROP_PLAYBACK_PITCH "playback.pitch" // double value (AudioTrack) 171 #define AMEDIAMETRICS_PROP_PLAYBACK_SPEED "playback.speed" // double value (AudioTrack) 172 #define AMEDIAMETRICS_PROP_PLAYERIID "playerIId" // int32 (-1 invalid/unset IID) 173 #define AMEDIAMETRICS_PROP_ROUTEDDEVICEID "routedDeviceId" // int32 174 #define AMEDIAMETRICS_PROP_SAMPLERATE "sampleRate" // int32 175 #define AMEDIAMETRICS_PROP_SELECTEDDEVICEID "selectedDeviceId" // int32 176 #define AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION "selectedMicDirection" // int32 177 #define AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION "selectedMicFieldDimension" // double 178 #define AMEDIAMETRICS_PROP_SESSIONID "sessionId" // int32 179 #define AMEDIAMETRICS_PROP_SHARINGMODE "sharingMode" // string value, "exclusive", shared" 180 #define AMEDIAMETRICS_PROP_SOURCE "source" // string (AudioAttributes) 181 #define AMEDIAMETRICS_PROP_STARTTHRESHOLDFRAMES "startThresholdFrames" // int32 (AudioTrack) 182 #define AMEDIAMETRICS_PROP_STARTUPMS "startupMs" // double value 183 // State is "ACTIVE" or "STOPPED" for AudioRecord 184 #define AMEDIAMETRICS_PROP_STATE "state" // string 185 #define AMEDIAMETRICS_PROP_STATUS "status#" // int32 status_t 186 // AAudio uses their own status codes 187 // Supplemental information to the status code. 188 #define AMEDIAMETRICS_PROP_STATUSSUBCODE "statusSubCode" // int32, specific code 189 // used in conjunction with status. 190 #define AMEDIAMETRICS_PROP_STATUSMESSAGE "statusMessage" // string, supplemental info. 191 // Arbitrary information treated as 192 // informational, may be logcat msg, 193 // or an exception with stack trace. 194 // Treated as "debug" information. 195 196 #define AMEDIAMETRICS_PROP_STREAMTYPE "streamType" // string (AudioTrack) 197 #define AMEDIAMETRICS_PROP_THREADID "threadId" // int32 value io handle 198 #define AMEDIAMETRICS_PROP_THROTTLEMS "throttleMs" // double 199 #define AMEDIAMETRICS_PROP_TRACKID "trackId" // int32 port id of track/record 200 #define AMEDIAMETRICS_PROP_TRAITS "traits" // string 201 #define AMEDIAMETRICS_PROP_TYPE "type" // string (thread type) 202 #define AMEDIAMETRICS_PROP_UNDERRUN "underrun" // int32 203 #define AMEDIAMETRICS_PROP_UNDERRUNFRAMES "underrunFrames" // int64_t from Thread 204 #define AMEDIAMETRICS_PROP_USAGE "usage" // string attributes (ATrack) 205 #define AMEDIAMETRICS_PROP_VOICEVOLUME "voiceVolume" // double (audio.flinger) 206 #define AMEDIAMETRICS_PROP_VOLUME_LEFT "volume.left" // double (AudioTrack) 207 #define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack) 208 #define AMEDIAMETRICS_PROP_WHERE "where" // string value 209 // EncodingClient is the encoding format requested by the client 210 #define AMEDIAMETRICS_PROP_ENCODINGCLIENT "encodingClient" // string 211 // PerformanceModeActual is the actual selected performance mode, could be "none', "lowLatency" or 212 // "powerSaving" 213 #define AMEDIAMETRICS_PROP_PERFORMANCEMODEACTUAL "performanceModeActual" // string 214 #define AMEDIAMETRICS_PROP_FRAMESTRANSFERRED "framesTransferred" // int64_t, transferred frames 215 // string value, "exclusive", "shared". the actual selected sharing mode by the server 216 #define AMEDIAMETRICS_PROP_SHARINGMODEACTUAL "sharingModeActual" 217 218 // Timing values: millisecond values are suffixed with MS and the type is double 219 // nanosecond values are suffixed with NS and the type is int64. 220 221 // Values are strings accepted for a given property. 222 223 // An event is a general description, which often is a function name. 224 #define AMEDIAMETRICS_PROP_EVENT_VALUE_BEGINAUDIOINTERVALGROUP "beginAudioIntervalGroup" 225 #define AMEDIAMETRICS_PROP_EVENT_VALUE_CLOSE "close" 226 #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE "create" 227 #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATEAUDIOPATCH "createAudioPatch" 228 #define AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR "ctor" 229 #define AMEDIAMETRICS_PROP_EVENT_VALUE_DISCONNECT "disconnect" 230 #define AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR "dtor" 231 #define AMEDIAMETRICS_PROP_EVENT_VALUE_ENDAAUDIOSTREAM "endAAudioStream" // AAudioStream 232 #define AMEDIAMETRICS_PROP_EVENT_VALUE_ENDAUDIOINTERVALGROUP "endAudioIntervalGroup" 233 #define AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH "flush" // AudioTrack 234 #define AMEDIAMETRICS_PROP_EVENT_VALUE_INVALIDATE "invalidate" // server track, record 235 #define AMEDIAMETRICS_PROP_EVENT_VALUE_OPEN "open" 236 #define AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE "pause" // AudioTrack 237 #define AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS "readParameters" // Thread 238 #define AMEDIAMETRICS_PROP_EVENT_VALUE_RELEASE "release" 239 #define AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE "restore" 240 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETMODE "setMode" // AudioFlinger 241 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETBUFFERSIZE "setBufferSize" // AudioTrack 242 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETLOGSESSIONID "setLogSessionId" // AudioTrack, Record 243 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM "setPlaybackParam" // AudioTrack 244 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYERIID "setPlayerIId" // AudioTrack 245 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETSTARTTHRESHOLD "setStartThreshold" // AudioTrack 246 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOICEVOLUME "setVoiceVolume" // AudioFlinger 247 #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME "setVolume" // AudioTrack 248 #define AMEDIAMETRICS_PROP_EVENT_VALUE_START "start" // AudioTrack, AudioRecord 249 #define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord 250 #define AMEDIAMETRICS_PROP_EVENT_VALUE_TIMEOUT "timeout" // AudioFlinger, AudioPolicy 251 #define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread 252 253 // Possible values for AMEDIAMETRICS_PROP_CALLERNAME 254 // Check within the framework for these strings as this header file may not be explicitly 255 // included to avoid unnecessary cross-project dependencies. 256 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO "aaudio" // Native AAudio 257 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_JAVA "java" // Java API layer 258 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_MEDIA "media" // libmedia 259 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_OPENSLES "opensles" // Open SLES 260 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP "rtp" // RTP communication 261 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL "soundpool" // SoundPool 262 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_TONEGENERATOR "tonegenerator" // dial tones 263 #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN "unknown" // callerName not set 264 265 // Many properties are available for the sensor. 266 // The mode is how the sensor is being currently used. 267 #define AMEDIAMETRICS_PROP_MODE_VALUE_HEAD "head" // used for head tracking 268 #define AMEDIAMETRICS_PROP_MODE_VALUE_SCREEN "screen" // used for screen 269 270 // MediaMetrics errors are expected to cover the following sources: 271 // https://docs.oracle.com/javase/7/docs/api/java/lang/RuntimeException.html 272 // https://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html 273 // https://cs.android.com/android/platform/superproject/+/master:frameworks/native/libs/binder/include/binder/Status.h;drc=88e25c0861499ee3ab885814dddc097ab234cb7b;l=57 274 // https://cs.android.com/android/platform/superproject/+/master:frameworks/base/media/java/android/media/AudioSystem.java;drc=3ac246c43294d7f7012bdcb0ccb7bae1aa695bd4;l=785 275 // https://cs.android.com/android/platform/superproject/+/master:frameworks/av/media/libaaudio/include/aaudio/AAudio.h;drc=cfd3a6fa3aaaf712a890dc02452b38ef401083b8;l=120 276 // https://abseil.io/docs/cpp/guides/status-codes 277 278 // Status errors: 279 // An empty status string or "ok" is interpreted as no error. 280 #define AMEDIAMETRICS_PROP_STATUS_VALUE_OK "ok" 281 282 // Error category: argument 283 // IllegalArgumentException 284 // NullPointerException 285 // BAD_VALUE 286 // absl::INVALID_ARGUMENT 287 // absl::OUT_OF_RANGE 288 // Out of range, out of bounds. 289 #define AMEDIAMETRICS_PROP_STATUS_VALUE_ARGUMENT "argument" 290 291 // Error category: io 292 // IOException 293 // android.os.DeadObjectException, android.os.RemoteException 294 // DEAD_OBJECT 295 // FAILED_TRANSACTION 296 // IO_ERROR 297 // file or ioctl failure 298 // Service, rpc, binder, or socket failure. 299 // Hardware or device failure. 300 #define AMEDIAMETRICS_PROP_STATUS_VALUE_IO "io" 301 302 // Error category: outOfMemory 303 // OutOfMemoryException 304 // NO_MEMORY 305 // absl::RESOURCE_EXHAUSTED 306 #define AMEDIAMETRICS_PROP_STATUS_VALUE_MEMORY "memory" 307 308 // Error category: security 309 // SecurityException 310 // PERMISSION_DENIED 311 // absl::PERMISSION_DENIED 312 // absl::UNAUTHENTICATED 313 #define AMEDIAMETRICS_PROP_STATUS_VALUE_SECURITY "security" 314 315 // Error category: state 316 // IllegalStateException 317 // UnsupportedOperationException 318 // INVALID_OPERATION 319 // NO_INIT 320 // absl::NOT_FOUND 321 // absl::ALREADY_EXISTS 322 // absl::FAILED_PRECONDITION 323 // absl::UNAVAILABLE 324 // absl::UNIMPLEMENTED 325 // Functionality not implemented (argument may or may not be correct). 326 // Call unexpected or out of order. 327 #define AMEDIAMETRICS_PROP_STATUS_VALUE_STATE "state" 328 329 // Error category: timeout 330 // TimeoutException 331 // WOULD_BLOCK 332 // absl::DEADLINE_EXCEEDED 333 // absl::ABORTED 334 #define AMEDIAMETRICS_PROP_STATUS_VALUE_TIMEOUT "timeout" 335 336 // Error category: unknown 337 // Exception (Java specified not listed above, or custom app/service) 338 // UNKNOWN_ERROR 339 // absl::INTERNAL 340 // absl::DATA_LOSS 341 // Catch-all bucket for errors not listed above. 342 #define AMEDIAMETRICS_PROP_STATUS_VALUE_UNKNOWN "unknown" 343 344 #endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H 345