blob: fb26fae515f1dc0291454f595951d54756e3c866 [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
40// The AudioRecord key appends the "trackId" to the prefix.
41#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD AMEDIAMETRICS_KEY_PREFIX_AUDIO "record."
42
43// The AudioThread key appends the "threadId" to the prefix.
44#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_THREAD AMEDIAMETRICS_KEY_PREFIX_AUDIO "thread."
45
46// The AudioTrack key appends the "trackId" to the prefix.
47#define AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK AMEDIAMETRICS_KEY_PREFIX_AUDIO "track."
48
49// Keys are strings used for MediaMetrics Item Keys
50#define AMEDIAMETRICS_KEY_AUDIO_FLINGER AMEDIAMETRICS_KEY_PREFIX_AUDIO "flinger"
51#define AMEDIAMETRICS_KEY_AUDIO_POLICY AMEDIAMETRICS_KEY_PREFIX_AUDIO "policy"
52
53/*
54 * MediaMetrics Properties are unified space for consistency and readability.
55 */
56
57// Property prefixes may be applied before a property name to indicate a specific
58// category to which it is associated.
59#define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective."
60#define AMEDIAMETRICS_PROP_PREFIX_HAL "hal."
61#define AMEDIAMETRICS_PROP_PREFIX_HAPTIC "haptic."
62#define AMEDIAMETRICS_PROP_PREFIX_SERVER "server."
63
64// Properties within mediametrics are string constants denoted by
65// a macro name beginning with AMEDIAMETRICS_PROP_*
66//
67// For a property name like "auxEffectId" we write this as a single upper case word
68// at the end of the macro name, such as AMEDIAMETRICS_PROP_AUXEFFECTID.
69//
70// Underscores after the AMEDIAMETRICS_PROP_* prefix indicate
71// a "dot" in the property name. For example AMEDIAMETRICS_PROP_VOLUME_LEFT
72// corresponds to "volume.left".
Andy Hung333bb3d2020-01-31 20:17:48 -080073//
74// The property names are camel case, typically a lowercase letter [a-z]
75// followed by one or more characters in the range [a-zA-Z0-9_.].
76// Special symbols such as !@#$%^&*()[]{}<>,:;'"\/?|+-=~ are reserved.
77//
78// A property that ends with a ! will have duplicate values listed instead
79// of suppressed in the Time Machine.
80//
Andy Hungb68f5eb2019-12-03 16:49:17 -080081#define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack)
82#define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32
83#define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32
84#define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack)
85#define AMEDIAMETRICS_PROP_DURATIONNS "durationNs" // int64 duration time span
86#define AMEDIAMETRICS_PROP_ENCODING "encoding" // string value of format
Andy Hung333bb3d2020-01-31 20:17:48 -080087#define AMEDIAMETRICS_PROP_EVENT "event!" // string value (often func name)
Andy Hungb68f5eb2019-12-03 16:49:17 -080088
89// TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32, AudioThread string
90#define AMEDIAMETRICS_PROP_FLAGS "flags"
91
92#define AMEDIAMETRICS_PROP_FRAMECOUNT "frameCount" // int32
93#define AMEDIAMETRICS_PROP_INPUTDEVICES "inputDevices" // string value
94#define AMEDIAMETRICS_PROP_LATENCYMS "latencyMs" // double value
95#define AMEDIAMETRICS_PROP_ORIGINALFLAGS "originalFlags" // int32
96#define AMEDIAMETRICS_PROP_OUTPUTDEVICES "outputDevices" // string value
97#define AMEDIAMETRICS_PROP_PLAYBACK_PITCH "playback.pitch" // double value (AudioTrack)
98#define AMEDIAMETRICS_PROP_PLAYBACK_SPEED "playback.speed" // double value (AudioTrack)
99#define AMEDIAMETRICS_PROP_ROUTEDDEVICEID "routedDeviceId" // int32
100#define AMEDIAMETRICS_PROP_SAMPLERATE "sampleRate" // int32
101#define AMEDIAMETRICS_PROP_SELECTEDDEVICEID "selectedDeviceId" // int32
102#define AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION "selectedMicDirection" // int32
103#define AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION "selectedMicFieldDimension" // double
104#define AMEDIAMETRICS_PROP_SESSIONID "sessionId" // int32
105#define AMEDIAMETRICS_PROP_SOURCE "source" // string (AudioAttributes)
106#define AMEDIAMETRICS_PROP_STARTUPMS "startupMs" // double value
107// State is "ACTIVE" or "STOPPED" for AudioRecord
108#define AMEDIAMETRICS_PROP_STATE "state" // string
109#define AMEDIAMETRICS_PROP_STATUS "status" // int32 status_t
110#define AMEDIAMETRICS_PROP_STREAMTYPE "streamType" // string (AudioTrack)
111#define AMEDIAMETRICS_PROP_THREADID "threadId" // int32 value io handle
112#define AMEDIAMETRICS_PROP_THROTTLEMS "throttleMs" // double
113#define AMEDIAMETRICS_PROP_TRACKID "trackId" // int32 port id of track/record
114#define AMEDIAMETRICS_PROP_TYPE "type" // string (thread type)
115#define AMEDIAMETRICS_PROP_UNDERRUN "underrun" // int32
116#define AMEDIAMETRICS_PROP_USAGE "usage" // string attributes (ATrack)
117#define AMEDIAMETRICS_PROP_VOLUME_LEFT "volume.left" // double (AudioTrack)
118#define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack)
119#define AMEDIAMETRICS_PROP_WHERE "where" // string value
120
121// Timing values: millisecond values are suffixed with MS and the type is double
122// nanosecond values are suffixed with NS and the type is int64.
123
124// Values are strings accepted for a given property.
125
126// An event is a general description, which often is a function name.
127#define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE "create"
128#define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATEAUDIOPATCH "createAudioPatch"
129#define AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR "ctor"
130#define AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR "dtor"
131#define AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH "flush" // AudioTrack
132#define AMEDIAMETRICS_PROP_EVENT_VALUE_INVALIDATE "invalidate" // server track, record
133#define AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE "pause" // AudioTrack
134#define AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS "readParameters" // Thread
135#define AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE "restore"
136#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM "setPlaybackParam" // AudioTrack
137#define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME "setVolume" // AudioTrack
138#define AMEDIAMETRICS_PROP_EVENT_VALUE_START "start" // AudioTrack, AudioRecord
139#define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord
140#define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread
141
142#endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H