blob: a09a673981abd848ed49c358f3090dd5e2ca7d79 [file] [log] [blame]
Andy Hungb68f5eb2019-12-03 16:49:17 -08001/*
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 Hungea840382020-05-05 21:50:17 -070040// Device related key prefix.
41#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_DEVICE AMEDIAMETRICS_KEY_PREFIX_AUDIO "device."
42
Andy Hungc2b11cb2020-04-22 09:04:01 -070043// The AudioMmap key appends the "trackId" to the prefix.
44// This is the AudioFlinger equivalent of the AAudio Stream.
45// TODO: unify with AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM
46#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_MMAP AMEDIAMETRICS_KEY_PREFIX_AUDIO "mmap."
47
Andy Hungb68f5eb2019-12-03 16:49:17 -080048// The AudioRecord key appends the "trackId" to the prefix.
49#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD AMEDIAMETRICS_KEY_PREFIX_AUDIO "record."
50
Phil Burka9876702020-04-20 18:16:15 -070051// The AudioStream key appends the "streamId" to the prefix.
52#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM AMEDIAMETRICS_KEY_PREFIX_AUDIO "stream."
53
Andy Hungb68f5eb2019-12-03 16:49:17 -080054// The AudioThread key appends the "threadId" to the prefix.
55#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_THREAD AMEDIAMETRICS_KEY_PREFIX_AUDIO "thread."
56
57// The AudioTrack key appends the "trackId" to the prefix.
58#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK AMEDIAMETRICS_KEY_PREFIX_AUDIO "track."
59
60// Keys are strings used for MediaMetrics Item Keys
61#define AMEDIAMETRICS_KEY_AUDIO_FLINGER AMEDIAMETRICS_KEY_PREFIX_AUDIO "flinger"
62#define AMEDIAMETRICS_KEY_AUDIO_POLICY AMEDIAMETRICS_KEY_PREFIX_AUDIO "policy"
63
64/*
65 * MediaMetrics Properties are unified space for consistency and readability.
66 */
67
68// Property prefixes may be applied before a property name to indicate a specific
69// category to which it is associated.
70#define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective."
71#define AMEDIAMETRICS_PROP_PREFIX_HAL "hal."
72#define AMEDIAMETRICS_PROP_PREFIX_HAPTIC "haptic."
73#define AMEDIAMETRICS_PROP_PREFIX_SERVER "server."
74
75// Properties within mediametrics are string constants denoted by
76// a macro name beginning with AMEDIAMETRICS_PROP_*
77//
78// For a property name like "auxEffectId" we write this as a single upper case word
79// at the end of the macro name, such as AMEDIAMETRICS_PROP_AUXEFFECTID.
80//
81// Underscores after the AMEDIAMETRICS_PROP_* prefix indicate
82// a "dot" in the property name. For example AMEDIAMETRICS_PROP_VOLUME_LEFT
83// corresponds to "volume.left".
Andy Hung333bb3d2020-01-31 20:17:48 -080084//
85// The property names are camel case, typically a lowercase letter [a-z]
86// followed by one or more characters in the range [a-zA-Z0-9_.].
87// Special symbols such as !@#$%^&*()[]{}<>,:;'"\/?|+-=~ are reserved.
88//
Andy Hung8f069622020-02-10 15:44:01 -080089// Properties within this header should include special suffixes like '#'
90// directly in the string for brevity. Code outside of this header should
91// use the macro constant for the special symbols for searchability.
92
93// Any property that ends with a # will have duplicate values listed instead
Andy Hung333bb3d2020-01-31 20:17:48 -080094// of suppressed in the Time Machine.
Andy Hung8f069622020-02-10 15:44:01 -080095#define AMEDIAMETRICS_PROP_SUFFIX_CHAR_DUPLICATES_ALLOWED '#'
96
Andy Hungd203eb62020-04-27 09:12:46 -070097#define AMEDIAMETRICS_PROP_ALLOWUID "_allowUid" // int32_t, allow client uid to post
Joey Poomarin52989982020-03-05 17:40:49 +080098#define AMEDIAMETRICS_PROP_AUDIOMODE "audioMode" // string (audio.flinger)
Andy Hungb68f5eb2019-12-03 16:49:17 -080099#define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack)
Phil Burka9876702020-04-20 18:16:15 -0700100#define AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES "bufferSizeFrames" // int32
101#define AMEDIAMETRICS_PROP_BUFFERCAPACITYFRAMES "bufferCapacityFrames" // int32
102#define AMEDIAMETRICS_PROP_BURSTFRAMES "burstFrames" // int32
Phil Burkd3813f32020-04-23 16:26:15 -0700103#define AMEDIAMETRICS_PROP_CALLERNAME "callerName" // string, eg. "aaudio"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800104#define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32
105#define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32
106#define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack)
Andy Hungc2b11cb2020-04-22 09:04:01 -0700107#define AMEDIAMETRICS_PROP_CUMULATIVETIMENS "cumulativeTimeNs" // int64_t playback/record time
108 // since start
109// DEVICE values are averaged since starting on device
110#define AMEDIAMETRICS_PROP_DEVICELATENCYMS "deviceLatencyMs" // double - avg latency time
111#define AMEDIAMETRICS_PROP_DEVICESTARTUPMS "deviceStartupMs" // double - avg startup time
112#define AMEDIAMETRICS_PROP_DEVICETIMENS "deviceTimeNs" // int64_t playback/record time
113#define AMEDIAMETRICS_PROP_DEVICEVOLUME "deviceVolume" // double - average device volume
114
Phil Burka9876702020-04-20 18:16:15 -0700115#define AMEDIAMETRICS_PROP_DIRECTION "direction" // string AAudio input or output
Andy Hungb68f5eb2019-12-03 16:49:17 -0800116#define AMEDIAMETRICS_PROP_DURATIONNS "durationNs" // int64 duration time span
117#define AMEDIAMETRICS_PROP_ENCODING "encoding" // string value of format
Andy Hung8f069622020-02-10 15:44:01 -0800118#define AMEDIAMETRICS_PROP_EVENT "event#" // string value (often func name)
Andy Hungea840382020-05-05 21:50:17 -0700119#define AMEDIAMETRICS_PROP_EXECUTIONTIMENS "executionTimeNs" // time to execute the event
Andy Hungb68f5eb2019-12-03 16:49:17 -0800120
121// TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32, AudioThread string
122#define AMEDIAMETRICS_PROP_FLAGS "flags"
123
124#define AMEDIAMETRICS_PROP_FRAMECOUNT "frameCount" // int32
125#define AMEDIAMETRICS_PROP_INPUTDEVICES "inputDevices" // string value
Andy Hung5837c7f2021-02-25 10:48:24 -0800126#define AMEDIAMETRICS_PROP_INTERNALTRACKID "internalTrackId" // int32
Andy Hungc2b11cb2020-04-22 09:04:01 -0700127#define AMEDIAMETRICS_PROP_INTERVALCOUNT "intervalCount" // int32
Andy Hungb68f5eb2019-12-03 16:49:17 -0800128#define AMEDIAMETRICS_PROP_LATENCYMS "latencyMs" // double value
Andy Hung3a5c2f32021-02-17 15:06:42 -0800129#define AMEDIAMETRICS_PROP_LOGSESSIONID "logSessionId" // hex string, "" none
Andy Hungc2b11cb2020-04-22 09:04:01 -0700130#define AMEDIAMETRICS_PROP_NAME "name" // string value
Andy Hungb68f5eb2019-12-03 16:49:17 -0800131#define AMEDIAMETRICS_PROP_ORIGINALFLAGS "originalFlags" // int32
132#define AMEDIAMETRICS_PROP_OUTPUTDEVICES "outputDevices" // string value
Phil Burka9876702020-04-20 18:16:15 -0700133#define AMEDIAMETRICS_PROP_PERFORMANCEMODE "performanceMode" // string value, "none", lowLatency"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800134#define AMEDIAMETRICS_PROP_PLAYBACK_PITCH "playback.pitch" // double value (AudioTrack)
135#define AMEDIAMETRICS_PROP_PLAYBACK_SPEED "playback.speed" // double value (AudioTrack)
Andy Hung839a3062021-02-17 11:15:16 -0800136#define AMEDIAMETRICS_PROP_PLAYERIID "playerIId" // int32 (-1 invalid/unset IID)
Andy Hungb68f5eb2019-12-03 16:49:17 -0800137#define AMEDIAMETRICS_PROP_ROUTEDDEVICEID "routedDeviceId" // int32
138#define AMEDIAMETRICS_PROP_SAMPLERATE "sampleRate" // int32
139#define AMEDIAMETRICS_PROP_SELECTEDDEVICEID "selectedDeviceId" // int32
140#define AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION "selectedMicDirection" // int32
141#define AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION "selectedMicFieldDimension" // double
142#define AMEDIAMETRICS_PROP_SESSIONID "sessionId" // int32
Phil Burka9876702020-04-20 18:16:15 -0700143#define AMEDIAMETRICS_PROP_SHARINGMODE "sharingMode" // string value, "exclusive", shared"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800144#define AMEDIAMETRICS_PROP_SOURCE "source" // string (AudioAttributes)
Andy Hung3c7f47a2021-03-16 17:30:09 -0700145#define AMEDIAMETRICS_PROP_STARTTHRESHOLDFRAMES "startThresholdFrames" // int32 (AudioTrack)
Andy Hungb68f5eb2019-12-03 16:49:17 -0800146#define AMEDIAMETRICS_PROP_STARTUPMS "startupMs" // double value
147// State is "ACTIVE" or "STOPPED" for AudioRecord
148#define AMEDIAMETRICS_PROP_STATE "state" // string
149#define AMEDIAMETRICS_PROP_STATUS "status" // int32 status_t
150#define AMEDIAMETRICS_PROP_STREAMTYPE "streamType" // string (AudioTrack)
151#define AMEDIAMETRICS_PROP_THREADID "threadId" // int32 value io handle
152#define AMEDIAMETRICS_PROP_THROTTLEMS "throttleMs" // double
153#define AMEDIAMETRICS_PROP_TRACKID "trackId" // int32 port id of track/record
Andy Hunga629bd12020-06-05 16:03:53 -0700154#define AMEDIAMETRICS_PROP_TRAITS "traits" // string
Andy Hungb68f5eb2019-12-03 16:49:17 -0800155#define AMEDIAMETRICS_PROP_TYPE "type" // string (thread type)
156#define AMEDIAMETRICS_PROP_UNDERRUN "underrun" // int32
Andy Hungc2b11cb2020-04-22 09:04:01 -0700157#define AMEDIAMETRICS_PROP_UNDERRUNFRAMES "underrunFrames" // int64_t from Thread
Andy Hungb68f5eb2019-12-03 16:49:17 -0800158#define AMEDIAMETRICS_PROP_USAGE "usage" // string attributes (ATrack)
Joey Poomarin52989982020-03-05 17:40:49 +0800159#define AMEDIAMETRICS_PROP_VOICEVOLUME "voiceVolume" // double (audio.flinger)
Andy Hungb68f5eb2019-12-03 16:49:17 -0800160#define AMEDIAMETRICS_PROP_VOLUME_LEFT "volume.left" // double (AudioTrack)
161#define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack)
162#define AMEDIAMETRICS_PROP_WHERE "where" // string value
jiabinef348b82021-04-19 16:53:08 +0000163// EncodingClient is the encoding format requested by the client
164#define AMEDIAMETRICS_PROP_ENCODINGCLIENT "encodingClient" // string
165// PerformanceModeActual is the actual selected performance mode, could be "none', "lowLatency" or
jiabin97247ea2021-04-07 00:33:38 +0000166// "powerSaving"
167#define AMEDIAMETRICS_PROP_PERFORMANCEMODEACTUAL "performanceModeActual" // string
168#define AMEDIAMETRICS_PROP_FRAMESTRANSFERRED "framesTransferred" // int64_t, transferred frames
jiabinc8da9032021-04-28 20:42:36 +0000169// string value, "exclusive", "shared". the actual selected sharing mode by the server
170#define AMEDIAMETRICS_PROP_SHARINGMODEACTUAL "sharingModeActual"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800171
172// Timing values: millisecond values are suffixed with MS and the type is double
173// nanosecond values are suffixed with NS and the type is int64.
174
175// Values are strings accepted for a given property.
176
177// An event is a general description, which often is a function name.
Andy Hungc2b11cb2020-04-22 09:04:01 -0700178#define AMEDIAMETRICS_PROP_EVENT_VALUE_BEGINAUDIOINTERVALGROUP "beginAudioIntervalGroup"
Phil Burka9876702020-04-20 18:16:15 -0700179#define AMEDIAMETRICS_PROP_EVENT_VALUE_CLOSE "close"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800180#define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE "create"
181#define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATEAUDIOPATCH "createAudioPatch"
182#define AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR "ctor"
Phil Burka9876702020-04-20 18:16:15 -0700183#define AMEDIAMETRICS_PROP_EVENT_VALUE_DISCONNECT "disconnect"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800184#define AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR "dtor"
jiabin515eb092020-11-18 17:55:52 -0800185#define AMEDIAMETRICS_PROP_EVENT_VALUE_ENDAAUDIOSTREAM "endAAudioStream" // AAudioStream
Andy Hungc2b11cb2020-04-22 09:04:01 -0700186#define AMEDIAMETRICS_PROP_EVENT_VALUE_ENDAUDIOINTERVALGROUP "endAudioIntervalGroup"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800187#define AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH "flush" // AudioTrack
188#define AMEDIAMETRICS_PROP_EVENT_VALUE_INVALIDATE "invalidate" // server track, record
Phil Burka9876702020-04-20 18:16:15 -0700189#define AMEDIAMETRICS_PROP_EVENT_VALUE_OPEN "open"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800190#define AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE "pause" // AudioTrack
191#define AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS "readParameters" // Thread
Phil Burk64e16a72020-06-01 13:25:51 -0700192#define AMEDIAMETRICS_PROP_EVENT_VALUE_RELEASE "release"
Andy Hungb68f5eb2019-12-03 16:49:17 -0800193#define AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE "restore"
Joey Poomarin52989982020-03-05 17:40:49 +0800194#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETMODE "setMode" // AudioFlinger
Phil Burk64e16a72020-06-01 13:25:51 -0700195#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETBUFFERSIZE "setBufferSize" // AudioTrack
Andy Hung3a5c2f32021-02-17 15:06:42 -0800196#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETLOGSESSIONID "setLogSessionId" // AudioTrack, Record
Andy Hungb68f5eb2019-12-03 16:49:17 -0800197#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM "setPlaybackParam" // AudioTrack
Andy Hung839a3062021-02-17 11:15:16 -0800198#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYERIID "setPlayerIId" // AudioTrack
Andy Hung3c7f47a2021-03-16 17:30:09 -0700199#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETSTARTTHRESHOLD "setStartThreshold" // AudioTrack
Phil Burk64e16a72020-06-01 13:25:51 -0700200#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOICEVOLUME "setVoiceVolume" // AudioFlinger
Andy Hungb68f5eb2019-12-03 16:49:17 -0800201#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME "setVolume" // AudioTrack
202#define AMEDIAMETRICS_PROP_EVENT_VALUE_START "start" // AudioTrack, AudioRecord
203#define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord
204#define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread
205
Andy Hunga6b27032020-04-27 10:34:24 -0700206// Possible values for AMEDIAMETRICS_PROP_CALLERNAME
207// Check within the framework for these strings as this header file may not be explicitly
208// included to avoid unnecessary cross-project dependencies.
209#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_AAUDIO "aaudio" // Native AAudio
210#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_JAVA "java" // Java API layer
211#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_MEDIA "media" // libmedia
212#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_OPENSLES "opensles" // Open SLES
213#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP "rtp" // RTP communication
214#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL "soundpool" // SoundPool
215#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_TONEGENERATOR "tonegenerator" // dial tones
216#define AMEDIAMETRICS_PROP_CALLERNAME_VALUE_UNKNOWN "unknown" // callerName not set
217
Andy Hungb68f5eb2019-12-03 16:49:17 -0800218#endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H