Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 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 | /* |
| 29 | * Taxonomy of audio keys |
| 30 | * |
| 31 | * To build longer keys, we use compiler string concatenation of |
| 32 | * adjacent string literals. This is done in the translation phase |
| 33 | * of compilation to make a single string token. |
| 34 | */ |
| 35 | |
| 36 | // Key Prefixes are used for MediaMetrics Item Keys and ends with a ".". |
| 37 | // They must be appended with another value to make a key. |
| 38 | #define AMEDIAMETRICS_KEY_PREFIX_AUDIO "audio." |
| 39 | |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 40 | // The AudioMmap key appends the "trackId" to the prefix. |
| 41 | // This is the AudioFlinger equivalent of the AAudio Stream. |
| 42 | // TODO: unify with AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM |
| 43 | #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_MMAP AMEDIAMETRICS_KEY_PREFIX_AUDIO "mmap." |
| 44 | |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 45 | // The AudioRecord key appends the "trackId" to the prefix. |
| 46 | #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD AMEDIAMETRICS_KEY_PREFIX_AUDIO "record." |
| 47 | |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 48 | // The AudioStream key appends the "streamId" to the prefix. |
| 49 | #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM AMEDIAMETRICS_KEY_PREFIX_AUDIO "stream." |
| 50 | |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 51 | // The AudioThread key appends the "threadId" to the prefix. |
| 52 | #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_THREAD AMEDIAMETRICS_KEY_PREFIX_AUDIO "thread." |
| 53 | |
| 54 | // The AudioTrack key appends the "trackId" to the prefix. |
| 55 | #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK AMEDIAMETRICS_KEY_PREFIX_AUDIO "track." |
| 56 | |
| 57 | // Keys are strings used for MediaMetrics Item Keys |
| 58 | #define AMEDIAMETRICS_KEY_AUDIO_FLINGER AMEDIAMETRICS_KEY_PREFIX_AUDIO "flinger" |
| 59 | #define AMEDIAMETRICS_KEY_AUDIO_POLICY AMEDIAMETRICS_KEY_PREFIX_AUDIO "policy" |
| 60 | |
| 61 | /* |
| 62 | * MediaMetrics Properties are unified space for consistency and readability. |
| 63 | */ |
| 64 | |
| 65 | // Property prefixes may be applied before a property name to indicate a specific |
| 66 | // category to which it is associated. |
| 67 | #define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective." |
| 68 | #define AMEDIAMETRICS_PROP_PREFIX_HAL "hal." |
| 69 | #define AMEDIAMETRICS_PROP_PREFIX_HAPTIC "haptic." |
| 70 | #define AMEDIAMETRICS_PROP_PREFIX_SERVER "server." |
| 71 | |
| 72 | // Properties within mediametrics are string constants denoted by |
| 73 | // a macro name beginning with AMEDIAMETRICS_PROP_* |
| 74 | // |
| 75 | // For a property name like "auxEffectId" we write this as a single upper case word |
| 76 | // at the end of the macro name, such as AMEDIAMETRICS_PROP_AUXEFFECTID. |
| 77 | // |
| 78 | // Underscores after the AMEDIAMETRICS_PROP_* prefix indicate |
| 79 | // a "dot" in the property name. For example AMEDIAMETRICS_PROP_VOLUME_LEFT |
| 80 | // corresponds to "volume.left". |
Andy Hung | 333bb3d | 2020-01-31 20:17:48 -0800 | [diff] [blame] | 81 | // |
| 82 | // The property names are camel case, typically a lowercase letter [a-z] |
| 83 | // followed by one or more characters in the range [a-zA-Z0-9_.]. |
| 84 | // Special symbols such as !@#$%^&*()[]{}<>,:;'"\/?|+-=~ are reserved. |
| 85 | // |
Andy Hung | 8f06962 | 2020-02-10 15:44:01 -0800 | [diff] [blame] | 86 | // Properties within this header should include special suffixes like '#' |
| 87 | // directly in the string for brevity. Code outside of this header should |
| 88 | // use the macro constant for the special symbols for searchability. |
| 89 | |
| 90 | // Any property that ends with a # will have duplicate values listed instead |
Andy Hung | 333bb3d | 2020-01-31 20:17:48 -0800 | [diff] [blame] | 91 | // of suppressed in the Time Machine. |
Andy Hung | 8f06962 | 2020-02-10 15:44:01 -0800 | [diff] [blame] | 92 | #define AMEDIAMETRICS_PROP_SUFFIX_CHAR_DUPLICATES_ALLOWED '#' |
| 93 | |
Andy Hung | d203eb6 | 2020-04-27 09:12:46 -0700 | [diff] [blame] | 94 | #define AMEDIAMETRICS_PROP_ALLOWUID "_allowUid" // int32_t, allow client uid to post |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 95 | #define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack) |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 96 | #define AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES "bufferSizeFrames" // int32 |
| 97 | #define AMEDIAMETRICS_PROP_BUFFERCAPACITYFRAMES "bufferCapacityFrames" // int32 |
| 98 | #define AMEDIAMETRICS_PROP_BURSTFRAMES "burstFrames" // int32 |
Phil Burk | d3813f3 | 2020-04-23 16:26:15 -0700 | [diff] [blame] | 99 | #define AMEDIAMETRICS_PROP_CALLERNAME "callerName" // string, eg. "aaudio" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 100 | #define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32 |
| 101 | #define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32 |
| 102 | #define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack) |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 103 | #define AMEDIAMETRICS_PROP_CUMULATIVETIMENS "cumulativeTimeNs" // int64_t playback/record time |
| 104 | // since start |
| 105 | // DEVICE values are averaged since starting on device |
| 106 | #define AMEDIAMETRICS_PROP_DEVICELATENCYMS "deviceLatencyMs" // double - avg latency time |
| 107 | #define AMEDIAMETRICS_PROP_DEVICESTARTUPMS "deviceStartupMs" // double - avg startup time |
| 108 | #define AMEDIAMETRICS_PROP_DEVICETIMENS "deviceTimeNs" // int64_t playback/record time |
| 109 | #define AMEDIAMETRICS_PROP_DEVICEVOLUME "deviceVolume" // double - average device volume |
| 110 | |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 111 | #define AMEDIAMETRICS_PROP_DIRECTION "direction" // string AAudio input or output |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 112 | #define AMEDIAMETRICS_PROP_DURATIONNS "durationNs" // int64 duration time span |
| 113 | #define AMEDIAMETRICS_PROP_ENCODING "encoding" // string value of format |
Andy Hung | 8f06962 | 2020-02-10 15:44:01 -0800 | [diff] [blame] | 114 | #define AMEDIAMETRICS_PROP_EVENT "event#" // string value (often func name) |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 115 | |
| 116 | // TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32, AudioThread string |
| 117 | #define AMEDIAMETRICS_PROP_FLAGS "flags" |
| 118 | |
| 119 | #define AMEDIAMETRICS_PROP_FRAMECOUNT "frameCount" // int32 |
| 120 | #define AMEDIAMETRICS_PROP_INPUTDEVICES "inputDevices" // string value |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 121 | #define AMEDIAMETRICS_PROP_INTERVALCOUNT "intervalCount" // int32 |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 122 | #define AMEDIAMETRICS_PROP_LATENCYMS "latencyMs" // double value |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 123 | #define AMEDIAMETRICS_PROP_NAME "name" // string value |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 124 | #define AMEDIAMETRICS_PROP_ORIGINALFLAGS "originalFlags" // int32 |
| 125 | #define AMEDIAMETRICS_PROP_OUTPUTDEVICES "outputDevices" // string value |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 126 | #define AMEDIAMETRICS_PROP_PERFORMANCEMODE "performanceMode" // string value, "none", lowLatency" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 127 | #define AMEDIAMETRICS_PROP_PLAYBACK_PITCH "playback.pitch" // double value (AudioTrack) |
| 128 | #define AMEDIAMETRICS_PROP_PLAYBACK_SPEED "playback.speed" // double value (AudioTrack) |
| 129 | #define AMEDIAMETRICS_PROP_ROUTEDDEVICEID "routedDeviceId" // int32 |
| 130 | #define AMEDIAMETRICS_PROP_SAMPLERATE "sampleRate" // int32 |
| 131 | #define AMEDIAMETRICS_PROP_SELECTEDDEVICEID "selectedDeviceId" // int32 |
| 132 | #define AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION "selectedMicDirection" // int32 |
| 133 | #define AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION "selectedMicFieldDimension" // double |
| 134 | #define AMEDIAMETRICS_PROP_SESSIONID "sessionId" // int32 |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 135 | #define AMEDIAMETRICS_PROP_SHARINGMODE "sharingMode" // string value, "exclusive", shared" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 136 | #define AMEDIAMETRICS_PROP_SOURCE "source" // string (AudioAttributes) |
| 137 | #define AMEDIAMETRICS_PROP_STARTUPMS "startupMs" // double value |
| 138 | // State is "ACTIVE" or "STOPPED" for AudioRecord |
| 139 | #define AMEDIAMETRICS_PROP_STATE "state" // string |
| 140 | #define AMEDIAMETRICS_PROP_STATUS "status" // int32 status_t |
| 141 | #define AMEDIAMETRICS_PROP_STREAMTYPE "streamType" // string (AudioTrack) |
| 142 | #define AMEDIAMETRICS_PROP_THREADID "threadId" // int32 value io handle |
| 143 | #define AMEDIAMETRICS_PROP_THROTTLEMS "throttleMs" // double |
| 144 | #define AMEDIAMETRICS_PROP_TRACKID "trackId" // int32 port id of track/record |
| 145 | #define AMEDIAMETRICS_PROP_TYPE "type" // string (thread type) |
| 146 | #define AMEDIAMETRICS_PROP_UNDERRUN "underrun" // int32 |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 147 | #define AMEDIAMETRICS_PROP_UNDERRUNFRAMES "underrunFrames" // int64_t from Thread |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 148 | #define AMEDIAMETRICS_PROP_USAGE "usage" // string attributes (ATrack) |
| 149 | #define AMEDIAMETRICS_PROP_VOLUME_LEFT "volume.left" // double (AudioTrack) |
| 150 | #define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack) |
| 151 | #define AMEDIAMETRICS_PROP_WHERE "where" // string value |
| 152 | |
| 153 | // Timing values: millisecond values are suffixed with MS and the type is double |
| 154 | // nanosecond values are suffixed with NS and the type is int64. |
| 155 | |
| 156 | // Values are strings accepted for a given property. |
| 157 | |
| 158 | // An event is a general description, which often is a function name. |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 159 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_BEGINAUDIOINTERVALGROUP "beginAudioIntervalGroup" |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 160 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_CLOSE "close" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 161 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE "create" |
| 162 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATEAUDIOPATCH "createAudioPatch" |
| 163 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR "ctor" |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 164 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_DISCONNECT "disconnect" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 165 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR "dtor" |
Andy Hung | c2b11cb | 2020-04-22 09:04:01 -0700 | [diff] [blame^] | 166 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_ENDAUDIOINTERVALGROUP "endAudioIntervalGroup" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 167 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH "flush" // AudioTrack |
| 168 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_INVALIDATE "invalidate" // server track, record |
Phil Burk | a987670 | 2020-04-20 18:16:15 -0700 | [diff] [blame] | 169 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_OPEN "open" |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 170 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE "pause" // AudioTrack |
| 171 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS "readParameters" // Thread |
| 172 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE "restore" |
| 173 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM "setPlaybackParam" // AudioTrack |
| 174 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME "setVolume" // AudioTrack |
| 175 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_START "start" // AudioTrack, AudioRecord |
| 176 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord |
| 177 | #define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread |
| 178 | |
Andy Hung | a6b2703 | 2020-04-27 10:34:24 -0700 | [diff] [blame] | 179 | // Possible values for AMEDIAMETRICS_PROP_CALLERNAME |
| 180 | // Check within the framework for these strings as this header file may not be explicitly |
| 181 | // included to avoid unnecessary cross-project dependencies. |
| 182 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO "aaudio" // Native AAudio |
| 183 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_JAVA "java" // Java API layer |
| 184 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_MEDIA "media" // libmedia |
| 185 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_OPENSLES "opensles" // Open SLES |
| 186 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP "rtp" // RTP communication |
| 187 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL "soundpool" // SoundPool |
| 188 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_TONEGENERATOR "tonegenerator" // dial tones |
| 189 | #define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN "unknown" // callerName not set |
| 190 | |
Andy Hung | b68f5eb | 2019-12-03 16:49:17 -0800 | [diff] [blame] | 191 | #endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H |