1/*
2 * Copyright (C) 2023 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
17syntax = "proto2";
18
19package android.os.statsd.media;
20
21import "frameworks/proto_logging/stats/atoms.proto";
22import "frameworks/proto_logging/stats/atom_field_options.proto";
23import "frameworks/proto_logging/stats/enums/media/codec/enums.proto";
24
25extend Atom {
26  optional MediaCodecReclaimRequestCompleted
27      media_codec_reclaim_request_completed = 600
28        [(module) = "framework", (module) = "media_metrics"];
29
30  optional MediaCodecStarted media_codec_started = 641
31        [(module) = "framework", (module) = "media_metrics"];
32
33  optional MediaCodecStopped media_codec_stopped = 642
34        [(module) = "framework", (module) = "media_metrics"];
35
36  optional MediaCodecRendered media_codec_rendered = 684
37        [(module) = "framework", (module) = "media_metrics"];
38}
39
40/**
41 * MediaResourceManagerService (media.resource_manager) logs this event
42 * when a client requests to reclaim codec(s) from other process(es).
43 *
44 * To decide from which process to reclaim the resources, the
45 * MediaResourceManagerService uses "out of memory" score to prioritize
46 * the requesting processes. Lower the oom score, higher the priority.
47 *
48 * If multiple codecs are reclaimed to satisfy the current (codec) reclaim
49 * request, then there will be one MediaCodecReclaimRequestCompleted atom logged
50 * for each codec reclaimed.
51 * The target_index will index through the reclaimed codecs.
52 *
53 * Logged from:
54 *   frameworks/av/services/mediaresourcemanager/ResourceManagerService.cpp
55 *
56 * @since U
57 */
58message MediaCodecReclaimRequestCompleted {
59    // Requester Information: Process that triggered codec reclaim event.
60    // The uid of the Requester.
61    optional int32 requester_uid = 1 [(is_uid) = true];
62
63    // The oom score of the Requester.
64    optional int32 requester_oom_score = 2;
65
66    // Codec Information: Codec that the Requester wants to initialize.
67    // The name of the codec that requester needs.
68    // eg. `OMX.google.aac.decoder`
69    optional string codec = 3;
70
71    // The number of concurrent instances of this codec, when the
72    // reclaim request was made.
73    optional int32 no_of_concurrent_codecs = 4;
74
75    // Reclaim Information:
76    // Status of reclaim request.
77    optional android.media.codec.ReclaimStatus reclaim_status = 5;
78
79    // If it was a successful reclaim, the number of codecs that have been reclaimed.
80    optional int32 no_of_codecs_reclaimed = 6;
81
82    // Information of the (target) process that it belonged to.
83    // If no_of_codecs_reclaimed is more than 1, this will be target index.
84    optional int32 target_index = 7;
85    // The uid of the Target.
86    optional int32 target_uid = 8 [(is_uid) = true];
87    // The oom score of the Target.
88    optional int32 target_oom_score = 9;
89}
90
91/**
92 * MediaResourceManagerService (media.resource_manager) logs this event
93 * when a client starts a codec.
94 *
95 * Logged from:
96 *   frameworks/av/services/mediaresourcemanager/ResourceManagerService.cpp
97 *
98 * @since U
99 */
100message MediaCodecStarted {
101    // Reporter Information: Application/Process that started the codec.
102    // The uid of the Requester.
103    optional int32 requester_uid = 1 [(is_uid) = true];
104
105    // Randomly generated Codec ID for:
106    // - finding the corresponding MediaCodecStopped atom.
107    // - correlating MediaCodecReported for more codec configuration parameters.
108    optional int64 codec_id = 2;
109
110    // The name of the codec that the requester starts.
111    // eg. `OMX.google.aac.decoder`
112    optional string codec_name = 3;
113
114    // Type of codec (Audio/Video/Image).
115    optional android.media.codec.CodecType codec_type = 4;
116
117    // true if this is an encoder, false if this is a decoder.
118    optional bool is_encoder = 5;
119
120    // true if this is hardware codec, false otherwise (software or neither)
121    optional bool is_hardware = 6;
122
123    // Resolution as width x height.
124    optional int32 width = 7;
125    optional int32 height = 8;
126
127    // Total number of concurrent codecs in the system.
128    optional int32 system_concurrent_codec_count = 9;
129
130    // Total number of concurrent codecs owned by this application.
131    optional int32 app_concurrent_codec_count = 10;
132
133    // Current total pixel count for this application.
134    optional int64 total_pixel_count = 11;
135
136    // Total number of concurrent HW Video codecs owned by this application.
137    optional int32 app_concurrent_hw_video_codec_count = 12;
138
139    // Total number of concurrent SW Video codecs owned by this application.
140    optional int32 app_concurrent_sw_video_codec_count = 13;
141
142    // Total number of concurrent Video codecs owned by this application.
143    optional int32 app_concurrent_video_codec_count = 14;
144
145    // Total number of concurrent Audio codecs owned by this application.
146    optional int32 app_concurrent_audio_codec_count = 15;
147
148    // Total number of concurrent Image codecs owned by this application.
149    optional int32 app_concurrent_image_codec_count = 16;
150}
151
152/**
153 * MediaResourceManagerService (media.resource_manager) logs this event
154 * when a client stops a codec.
155 *
156 * Logged from:
157 *   frameworks/av/services/mediaresourcemanager/ResourceManagerService.cpp
158 *
159 * @since U
160 */
161message MediaCodecStopped {
162    // Reporter Information: Application/Process that stopped the codec.
163    // The uid of the Requester.
164    optional int32 requester_uid = 1 [(is_uid) = true];
165
166    // Randomly generated Codec ID for:
167    // - finding the corresponding MediaCodecStarted atom.
168    // - correlating MediaCodecReported for more codec configuration parameters.
169    optional int64 codec_id = 2;
170
171    // The name of the codec that the requester starts.
172    // eg. `OMX.google.aac.decoder`
173    optional string codec_name = 3;
174
175    // Type of codec (Audio/Video/Image).
176    optional android.media.codec.CodecType codec_type = 4;
177
178    // true if this is an encoder, false if this is a decoder.
179    optional bool is_encoder = 5;
180
181    // true if this is hardware codec, false otherwise (software or neither)
182    optional bool is_hardware = 6;
183
184    // Resolution as width x height.
185    optional int32 width = 7;
186    optional int32 height = 8;
187
188    // Total number of concurrent codecs in the system.
189    optional int32 system_concurrent_codec_count = 9;
190
191    // Total number of concurrent codecs owned by this application.
192    optional int32 app_concurrent_codec_count = 10;
193
194    // Current total pixel count for this application.
195    optional int64 total_pixel_count = 11;
196
197    // Time elapsed between codec start to stop, in microseconds
198    optional int64 codec_operation_duration_ms = 12;
199}
200
201/**
202 * MediaCodec logs this event when a codec that has rendered video to the display has been closed.
203 *
204 * Logged from:
205 *   frameworks/av/media/libstagefright/MediaCodec.cpp
206 */
207message MediaCodecRendered {
208    // Application/Process that owns the media codec.
209    optional int32 uid = 1 [(is_uid) = true];
210
211    // Randomly generated Codec ID for:
212    // - finding the corresponding MediaCodecReported for more codec configuration parameters
213    optional int64 codec_id = 2;
214
215    // Framework generated random temporary id for joining related atoms from media playback.
216    optional string log_session_id = 3;
217
218    //
219    // DIMENSIONS
220    //
221    // Whether or not the codec was a hardware codec.
222    optional int32 is_hardware = 4;
223    // Whether or not a secure codec was used.
224    optional int32 is_secure = 5;
225    // Whether or not the codec is tunneled.
226    optional int32 is_tunneled = 6;
227    // The type of codec that was used.
228    optional android.media.codec.Codec codec = 7;
229    // The maximum resolution during playback.
230    optional android.media.codec.Resolution resolution = 8;
231    // The bitrate.
232    optional android.media.codec.Bitrate bitrate = 9;
233    // The framerate as computed by the presentation timestamps in the content stream.
234    optional android.media.codec.Framerate content_framerate = 10;
235    // The framerate as computed by the presentation timestamps.
236    optional android.media.codec.Framerate actual_framerate = 11;
237    // Any HDR format used during playback.
238    optional android.media.codec.HdrFormat hdr_format = 12;
239
240    //
241    // SINGULARS
242    //
243    optional int64 first_render_timestamp_ns = 13;
244    // The playback duration in seconds.
245    optional int64 playback_duration_seconds = 14;
246    // The number of total frames output by the decoder.
247    optional int64 frames_total = 15;
248    // The number of frames sent to SurfaceFlinger for rendering.
249    optional int64 frames_released = 16;
250    // The number of frames rendered sent to Composer HAL for rendering.
251    optional int64 frames_rendered = 17;
252    // The number of frames dropped.
253    optional int64 frames_dropped = 18;
254    // The number of frames skipped by the app.
255    optional int64 frames_skipped = 19;
256    // The frame drop rate.
257    optional float frame_drop_rate = 20;
258    // The frame skip rate.
259    optional float frame_skip_rate = 21;
260    // The frame skip+drop rate.
261    optional float frame_skip_drop_rate = 22;
262
263    //
264    // FREEZE
265    //
266    // The overall freeze score.
267    optional int64 freeze_score = 23;
268    // The duration of freezes divided by the total duration of playback.
269    optional float freeze_rate = 24;
270    // The histogram of freeze durations.
271    repeated int32 freeze_duration_ms_histogram = 25;
272    // The histogram bucket limits for freeze durations.
273    repeated int32 freeze_duration_ms_histogram_buckets = 26;
274    // The histogram of durations between freezes.
275    repeated int32 freeze_distance_ms_histogram = 27;
276    // The histogram bucket limits for durations between freezes.
277    repeated int32 freeze_distance_ms_histogram_buckets = 28;
278
279    //
280    // JUDDER
281    //
282    // The overall judder score.
283    optional int64 judder_score = 29;
284    // The number of frames that have judder divided by the total number of frames.
285    optional float judder_rate = 30;
286    // The histogram of judder scores for each frame.
287    repeated int32 judder_score_histogram = 31;
288    // The histogram bucket limits for judder scores.
289    repeated int32 judder_score_histogram_buckets = 32;
290}
291