Pass component of event to debug trace logEvent as parameter.

PiperOrigin-RevId: 633176557
This commit is contained in:
samrobinson 2024-05-13 05:30:54 -07:00 committed by Copybara-Service
parent 0db23ae904
commit 30624aae6e
11 changed files with 165 additions and 71 deletions

View File

@ -18,6 +18,10 @@ package androidx.media3.effect;
import static androidx.media3.common.util.Assertions.checkArgument;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_BITMAP_TEXTURE_MANAGER;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VFP;
import static androidx.media3.effect.DebugTraceUtil.EVENT_BITMAP_TEXTURE_MANAGER_SIGNAL_EOS;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_QUEUE_BITMAP;
import android.graphics.Bitmap;
import androidx.media3.common.C;
@ -109,7 +113,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (pendingBitmaps.isEmpty()) {
checkNotNull(gainmapShaderProgram).signalEndOfCurrentInputStream();
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_BITMAP_TEXTURE_MANAGER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
COMPONENT_BITMAP_TEXTURE_MANAGER,
EVENT_BITMAP_TEXTURE_MANAGER_SIGNAL_EOS,
C.TIME_END_OF_SOURCE);
} else {
currentInputStreamEnded = true;
}
@ -156,7 +162,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
.queueInputFrame(
glObjectsProvider, checkNotNull(currentSdrGlTextureInfo), currentPresentationTimeUs);
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_VFP_QUEUE_BITMAP,
COMPONENT_VFP,
EVENT_VFP_QUEUE_BITMAP,
currentPresentationTimeUs,
/* extraFormat= */ "%dx%d",
/* extraArgs...= */ currentFrameInfo.width,
@ -170,7 +177,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Only signal end of stream after all pending bitmaps are processed.
checkNotNull(gainmapShaderProgram).signalEndOfCurrentInputStream();
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_BITMAP_TEXTURE_MANAGER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
COMPONENT_BITMAP_TEXTURE_MANAGER,
EVENT_BITMAP_TEXTURE_MANAGER_SIGNAL_EOS,
C.TIME_END_OF_SOURCE);
currentInputStreamEnded = false;
}
}

View File

@ -22,6 +22,7 @@ import static java.lang.annotation.ElementType.TYPE_USE;
import android.util.JsonWriter;
import androidx.annotation.GuardedBy;
import androidx.annotation.Nullable;
import androidx.annotation.StringDef;
import androidx.media3.common.C;
import androidx.media3.common.util.SystemClock;
@ -55,6 +56,7 @@ public final class DebugTraceUtil {
public static boolean enableTracing = false;
/** Events logged by {@link #logEvent}. */
@Documented
@Retention(RetentionPolicy.SOURCE)
@StringDef({
EVENT_VIDEO_INPUT_FORMAT,
@ -83,9 +85,8 @@ public final class DebugTraceUtil {
EVENT_MUXER_TRACK_ENDED_AUDIO,
EVENT_MUXER_TRACK_ENDED_VIDEO
})
@Documented
@Target(TYPE_USE)
public @interface DebugTraceEvent {}
public @interface Event {}
public static final String EVENT_VIDEO_INPUT_FORMAT = "VideoInputFormat";
public static final String EVENT_DECODER_DECODED_FRAME = "Decoder-DecodedFrame";
@ -117,19 +118,37 @@ public final class DebugTraceUtil {
public static final String EVENT_MUXER_TRACK_ENDED_AUDIO = "Muxer-TrackEnded_Audio";
public static final String EVENT_MUXER_TRACK_ENDED_VIDEO = "Muxer-TrackEnded_Video";
/** Components logged by {@link #logEvent}. */
@Documented
@Retention(RetentionPolicy.SOURCE)
@StringDef({
COMPONENT_VIDEO,
COMPONENT_DECODER,
COMPONENT_VFP,
COMPONENT_BITMAP_TEXTURE_MANAGER,
COMPONENT_EXTERNAL_TEXTURE_MANAGER,
COMPONENT_TEX_ID_TEXTURE_MANAGER,
COMPONENT_COMPOSITOR,
COMPONENT_ENCODER,
COMPONENT_MUXER
})
@Target(TYPE_USE)
public @interface Component {}
// TODO - b/339639306: Migrate COMPONENT_VIDEO usage to COMPONENT_ASSETLOADER.
private static final String COMPONENT_VIDEO = "Video";
public static final String COMPONENT_VIDEO = "Video";
private static final String COMPONENT_DECODER = "Decoder";
private static final String COMPONENT_VFP = "VFP";
private static final String COMPONENT_EXTERNAL_TEXTURE_MANAGER = "ExternalTextureManager";
private static final String COMPONENT_BITMAP_TEXTURE_MANAGER = "BitmapTextureManager";
private static final String COMPONENT_TEX_ID_TEXTURE_MANAGER = "TexIdTextureManager";
private static final String COMPONENT_COMPOSITOR = "Compositor";
private static final String COMPONENT_ENCODER = "Encoder";
private static final String COMPONENT_MUXER = "Muxer";
public static final String COMPONENT_DECODER = "Decoder";
public static final String COMPONENT_VFP = "VFP";
public static final String COMPONENT_EXTERNAL_TEXTURE_MANAGER = "ExternalTextureManager";
public static final String COMPONENT_BITMAP_TEXTURE_MANAGER = "BitmapTextureManager";
public static final String COMPONENT_TEX_ID_TEXTURE_MANAGER = "TexIdTextureManager";
public static final String COMPONENT_COMPOSITOR = "Compositor";
public static final String COMPONENT_ENCODER = "Encoder";
public static final String COMPONENT_MUXER = "Muxer";
private static final ImmutableMap<String, List<String>> COMPONENTS_TO_EVENTS =
// For a given component, events are in the rough expected order that they occur.
private static final ImmutableMap<@Component String, List<@Event String>> COMPONENTS_TO_EVENTS =
ImmutableMap.of(
COMPONENT_VIDEO, ImmutableList.of(EVENT_VIDEO_INPUT_FORMAT),
COMPONENT_DECODER,
@ -167,28 +186,32 @@ public final class DebugTraceUtil {
private static final int MAX_FIRST_LAST_LOGS = 10;
@GuardedBy("DebugTraceUtil.class")
private static final Map<String, EventLogger> events = new LinkedHashMap<>();
private static final Map<@Component String, Map<@Event String, EventLogger>>
componentsToEventsToLogs = new LinkedHashMap<>();
@GuardedBy("DebugTraceUtil.class")
private static long startTimeMs = SystemClock.DEFAULT.elapsedRealtime();
public static synchronized void reset() {
events.clear();
componentsToEventsToLogs.clear();
startTimeMs = SystemClock.DEFAULT.elapsedRealtime();
}
/**
* Logs a new event, if debug logging is enabled.
*
* @param eventName The {@linkplain DebugTraceEvent event name} to log.
* @param component The {@link Component} to log.
* @param event The {@link Event} to log.
* @param presentationTimeUs The current presentation time of the media. Use {@link C#TIME_UNSET}
* if unknown, {@link C#TIME_END_OF_SOURCE} if EOS.
* @param extraFormat Format string for optional extra information. See {@link
* Util#formatInvariant(String, Object...)}.
* @param extraArgs Arguments for optional extra information.
*/
@SuppressWarnings("ComputeIfAbsentContainsKey") // Avoid Java8 for visibility
public static synchronized void logEvent(
@DebugTraceEvent String eventName,
@Component String component,
@Event String event,
long presentationTimeUs,
String extraFormat,
Object... extraArgs) {
@ -196,10 +219,15 @@ public final class DebugTraceUtil {
return;
}
long eventTimeMs = SystemClock.DEFAULT.elapsedRealtime() - startTimeMs;
if (!events.containsKey(eventName)) {
events.put(eventName, new EventLogger());
if (!componentsToEventsToLogs.containsKey(component)) {
componentsToEventsToLogs.put(component, new LinkedHashMap<>());
}
EventLogger logger = events.get(eventName);
Map<@Event String, EventLogger> events = componentsToEventsToLogs.get(component);
if (!events.containsKey(event)) {
events.put(event, new EventLogger());
}
EventLogger logger = events.get(event);
String extra = Util.formatInvariant(extraFormat, extraArgs);
logger.addLog(new EventLog(presentationTimeUs, eventTimeMs, extra));
}
@ -207,13 +235,14 @@ public final class DebugTraceUtil {
/**
* Logs a new event, if debug logging is enabled.
*
* @param eventName The {@linkplain DebugTraceEvent event name} to log.
* @param component The {@link Component} to log.
* @param event The {@link Event} to log.
* @param presentationTimeUs The current presentation time of the media. Use {@link C#TIME_UNSET}
* if unknown, {@link C#TIME_END_OF_SOURCE} if EOS.
*/
public static synchronized void logEvent(
@DebugTraceEvent String eventName, long presentationTimeUs) {
logEvent(eventName, presentationTimeUs, /* extraFormat= */ "");
@Component String component, @Event String event, long presentationTimeUs) {
logEvent(component, event, presentationTimeUs, /* extraFormat= */ "");
}
/**
@ -228,14 +257,21 @@ public final class DebugTraceUtil {
JsonWriter jsonWriter = new JsonWriter(stringWriter);
try {
jsonWriter.beginObject();
for (Map.Entry<String, List<String>> componentToEvents : COMPONENTS_TO_EVENTS.entrySet()) {
jsonWriter.name(componentToEvents.getKey()).beginObject();
for (String eventType : componentToEvents.getValue()) {
jsonWriter.name(eventType);
if (!events.containsKey(eventType)) {
jsonWriter.value("No events");
for (Map.Entry<@Component String, List<@Event String>> componentToEvents :
COMPONENTS_TO_EVENTS.entrySet()) {
@Component String component = componentToEvents.getKey();
List<@Event String> componentEvents = componentToEvents.getValue();
jsonWriter.name(component);
@Nullable
Map<@Event String, EventLogger> eventsToLogs = componentsToEventsToLogs.get(component);
jsonWriter.beginObject();
for (@Event String event : componentEvents) {
jsonWriter.name(event);
if (eventsToLogs != null && eventsToLogs.containsKey(event)) {
checkNotNull(eventsToLogs.get(event)).toJson(jsonWriter);
} else {
checkNotNull(events.get(eventType)).toJson(jsonWriter);
jsonWriter.value("No events");
}
}
jsonWriter.endObject();
@ -249,27 +285,33 @@ public final class DebugTraceUtil {
}
}
/** Dumps all the logged events to a tsv file. */
/** Dumps all the logged events to the {@link Writer} as tab separated values (tsv). */
public static synchronized void dumpTsv(Writer writer) throws IOException {
if (!enableTracing) {
writer.write("Tracing disabled");
return;
}
writer.write("event\ttimestamp\tpresentation\textra\n");
for (Map.Entry<String, EventLogger> entry : events.entrySet()) {
ImmutableList<EventLog> eventLogs = entry.getValue().getLogs();
for (int i = 0; i < eventLogs.size(); i++) {
EventLog eventLog = eventLogs.get(i);
writer.write("component\tevent\ttimestamp\tpresentation\textra\n");
for (Map.Entry<@Component String, Map<@Event String, EventLogger>> componentToEventsToLogs :
componentsToEventsToLogs.entrySet()) {
@Component String component = componentToEventsToLogs.getKey();
Map<@Event String, EventLogger> eventsToLogs = componentToEventsToLogs.getValue();
for (Map.Entry<@Event String, EventLogger> eventToLogs : eventsToLogs.entrySet()) {
@Event String componentEvent = eventToLogs.getKey();
ImmutableList<EventLog> eventLogs = eventToLogs.getValue().getLogs();
for (EventLog eventLog : eventLogs) {
writer.write(
formatInvariant(
"%s\t%dms\t%s\t%s\n",
entry.getKey(),
"%s\t%s\t%dms\t%s\t%s\n",
component,
componentEvent,
eventLog.eventTimeMs,
presentationTimeToString(eventLog.presentationTimeUs),
eventLog.extra));
}
}
}
}
private static String presentationTimeToString(long presentationTimeUs) {
if (presentationTimeUs == C.TIME_UNSET) {

View File

@ -20,10 +20,10 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.SDK_INT;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VFP;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_RECEIVE_END_OF_INPUT;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_REGISTER_NEW_INPUT_STREAM;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_SIGNAL_ENDED;
import static androidx.media3.effect.DebugTraceUtil.logEvent;
import static com.google.common.collect.Iterables.getFirst;
import static java.lang.annotation.ElementType.TYPE_USE;
@ -427,7 +427,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
() -> {
if (inputStreamEnded) {
listenerExecutor.execute(listener::onEnded);
logEvent(EVENT_VFP_SIGNAL_ENDED, C.TIME_END_OF_SOURCE);
DebugTraceUtil.logEvent(COMPONENT_VFP, EVENT_VFP_SIGNAL_ENDED, C.TIME_END_OF_SOURCE);
} else {
synchronized (lock) {
if (pendingInputStreamInfo != null) {
@ -535,7 +535,8 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
@InputType int inputType, List<Effect> effects, FrameInfo frameInfo) {
// This method is only called after all samples in the current input stream are registered or
// queued.
logEvent(
DebugTraceUtil.logEvent(
COMPONENT_VFP,
EVENT_VFP_REGISTER_NEW_INPUT_STREAM,
/* presentationTimeUs= */ frameInfo.offsetToAddUs,
/* extraFormat= */ "InputType %s - %dx%d",
@ -621,7 +622,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
@Override
public void signalEndOfInput() {
logEvent(EVENT_VFP_RECEIVE_END_OF_INPUT, C.TIME_END_OF_SOURCE);
DebugTraceUtil.logEvent(COMPONENT_VFP, EVENT_VFP_RECEIVE_END_OF_INPUT, C.TIME_END_OF_SOURCE);
checkState(!inputStreamEnded);
inputStreamEnded = true;
inputSwitcher.signalEndOfInputStream();

View File

@ -19,6 +19,11 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.isRunningOnEmulator;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_EXTERNAL_TEXTURE_MANAGER;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VFP;
import static androidx.media3.effect.DebugTraceUtil.EVENT_EXTERNAL_TEXTURE_MANAGER_SIGNAL_EOS;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_QUEUE_FRAME;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_SURFACE_TEXTURE_INPUT;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import android.graphics.SurfaceTexture;
@ -126,7 +131,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
videoFrameProcessingTaskExecutor.submit(
() -> {
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_VFP_SURFACE_TEXTURE_INPUT, C.TIME_UNSET);
COMPONENT_VFP, EVENT_VFP_SURFACE_TEXTURE_INPUT, C.TIME_UNSET);
if (shouldRejectIncomingFrames) {
surfaceTexture.updateTexImage();
Log.w(
@ -201,7 +206,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
currentInputStreamEnded = false;
checkNotNull(externalShaderProgram).signalEndOfCurrentInputStream();
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_EXTERNAL_TEXTURE_MANAGER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
COMPONENT_EXTERNAL_TEXTURE_MANAGER,
EVENT_EXTERNAL_TEXTURE_MANAGER_SIGNAL_EOS,
C.TIME_END_OF_SOURCE);
cancelForceSignalEndOfStreamTimer();
} else {
maybeQueueFrameToExternalShaderProgram();
@ -246,7 +253,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (pendingFrames.isEmpty() && currentFrame == null) {
checkNotNull(externalShaderProgram).signalEndOfCurrentInputStream();
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_EXTERNAL_TEXTURE_MANAGER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
COMPONENT_EXTERNAL_TEXTURE_MANAGER,
EVENT_EXTERNAL_TEXTURE_MANAGER_SIGNAL_EOS,
C.TIME_END_OF_SOURCE);
cancelForceSignalEndOfStreamTimer();
} else {
currentInputStreamEnded = true;
@ -376,7 +385,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (!repeatLastRegisteredFrame) {
checkStateNotNull(pendingFrames.remove());
}
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_VFP_QUEUE_FRAME, presentationTimeUs);
DebugTraceUtil.logEvent(COMPONENT_VFP, EVENT_VFP_QUEUE_FRAME, presentationTimeUs);
// If the queued frame is the last frame, end of stream will be signaled onInputFrameProcessed.
}
}

View File

@ -17,6 +17,8 @@ package androidx.media3.effect;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VFP;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_RENDERED_TO_OUTPUT_SURFACE;
import static androidx.media3.effect.DefaultVideoFrameProcessor.WORKING_COLOR_SPACE_LINEAR;
import android.content.Context;
@ -390,7 +392,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
: renderTimeNs);
EGL14.eglSwapBuffers(eglDisplay, outputEglSurface);
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_VFP_RENDERED_TO_OUTPUT_SURFACE, presentationTimeUs);
COMPONENT_VFP, EVENT_VFP_RENDERED_TO_OUTPUT_SURFACE, presentationTimeUs);
}
private void renderFrameToOutputTexture(GlTextureInfo inputTexture, long presentationTimeUs)

View File

@ -22,9 +22,10 @@ import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.contains;
import static androidx.media3.common.util.Util.newSingleThreadScheduledExecutor;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_COMPOSITOR;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VFP;
import static androidx.media3.effect.DebugTraceUtil.EVENT_COMPOSITOR_OUTPUT_TEXTURE_RENDERED;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_OUTPUT_TEXTURE_RENDERED;
import static androidx.media3.effect.DebugTraceUtil.logEvent;
import static androidx.media3.effect.DefaultVideoFrameProcessor.WORKING_COLOR_SPACE_LINEAR;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@ -320,7 +321,7 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
GlTextureProducer textureProducer,
GlTextureInfo texture,
long presentationTimeUs) {
logEvent(EVENT_VFP_OUTPUT_TEXTURE_RENDERED, presentationTimeUs);
DebugTraceUtil.logEvent(COMPONENT_VFP, EVENT_VFP_OUTPUT_TEXTURE_RENDERED, presentationTimeUs);
checkNotNull(videoCompositor)
.queueInputTexture(
videoCompositorInputId,
@ -339,7 +340,8 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
long syncObject) {
checkStateNotNull(compositionVideoFrameProcessor);
checkState(!compositorEnded);
logEvent(EVENT_COMPOSITOR_OUTPUT_TEXTURE_RENDERED, presentationTimeUs);
DebugTraceUtil.logEvent(
COMPONENT_COMPOSITOR, EVENT_COMPOSITOR_OUTPUT_TEXTURE_RENDERED, presentationTimeUs);
compositorOutputTextures.add(
new CompositorOutputTextureInfo(outputTexture, presentationTimeUs));

View File

@ -16,6 +16,10 @@
package androidx.media3.effect;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_TEX_ID_TEXTURE_MANAGER;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VFP;
import static androidx.media3.effect.DebugTraceUtil.EVENT_TEX_ID_TEXTURE_MANAGER_SIGNAL_EOS;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VFP_QUEUE_TEXTURE;
import android.opengl.GLES10;
import androidx.media3.common.C;
@ -86,7 +90,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
frameInfo.height);
checkNotNull(frameConsumptionManager).queueInputFrame(inputTexture, presentationTimeUs);
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_VFP_QUEUE_TEXTURE,
COMPONENT_VFP,
EVENT_VFP_QUEUE_TEXTURE,
presentationTimeUs,
/* extraFormat= */ "%dx%d",
/* extraArgs...= */ frameInfo.width,
@ -115,7 +120,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
() -> {
checkNotNull(frameConsumptionManager).signalEndOfCurrentStream();
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_TEX_ID_TEXTURE_MANAGER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
COMPONENT_TEX_ID_TEXTURE_MANAGER,
EVENT_TEX_ID_TEXTURE_MANAGER_SIGNAL_EOS,
C.TIME_END_OF_SOURCE);
});
}

View File

@ -21,6 +21,10 @@ import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.SDK_INT;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_DECODER;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_ENCODER;
import static androidx.media3.effect.DebugTraceUtil.EVENT_DECODER_RECEIVE_EOS;
import static androidx.media3.effect.DebugTraceUtil.EVENT_ENCODER_RECEIVE_EOS;
import android.content.Context;
import android.media.MediaCodec;
@ -220,7 +224,8 @@ public final class DefaultCodec implements Codec {
if (isDecoder) {
if (isVideo) {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_DECODER_RECEIVE_EOS, C.TIME_END_OF_SOURCE);
DebugTraceUtil.logEvent(
COMPONENT_DECODER, EVENT_DECODER_RECEIVE_EOS, C.TIME_END_OF_SOURCE);
}
// EOS buffer on the decoder input should never carry data.
checkState(inputBuffer.data == null || !inputBuffer.data.hasRemaining());
@ -241,7 +246,7 @@ public final class DefaultCodec implements Codec {
@Override
public void signalEndOfInputStream() throws ExportException {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_ENCODER_RECEIVE_EOS, C.TIME_END_OF_SOURCE);
DebugTraceUtil.logEvent(COMPONENT_ENCODER, EVENT_ENCODER_RECEIVE_EOS, C.TIME_END_OF_SOURCE);
try {
mediaCodec.signalEndOfInputStream();
} catch (RuntimeException e) {

View File

@ -17,6 +17,11 @@ package androidx.media3.transformer;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_DECODER;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_VIDEO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_DECODER_DECODED_FRAME;
import static androidx.media3.effect.DebugTraceUtil.EVENT_DECODER_SIGNAL_EOS;
import static androidx.media3.effect.DebugTraceUtil.EVENT_VIDEO_INPUT_FORMAT;
import static androidx.media3.transformer.TransformerUtil.getDecoderOutputColor;
import android.media.MediaCodec;
@ -86,7 +91,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override
protected void onInputFormatRead(Format inputFormat) {
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_VIDEO_INPUT_FORMAT,
COMPONENT_VIDEO,
EVENT_VIDEO_INPUT_FORMAT,
C.TIME_UNSET,
/* extraFormat= */ "%s",
/* extraArgs...= */ inputFormat);
@ -151,7 +157,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@RequiresNonNull({"sampleConsumer", "decoder"})
protected boolean feedConsumerFromDecoder() throws ExportException {
if (decoder.isEnded()) {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_DECODER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
DebugTraceUtil.logEvent(COMPONENT_DECODER, EVENT_DECODER_SIGNAL_EOS, C.TIME_END_OF_SOURCE);
sampleConsumer.signalEndOfVideoInput();
isEnded = true;
return false;
@ -178,7 +184,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
decoder.releaseOutputBuffer(presentationTimeUs);
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_DECODER_DECODED_FRAME, presentationTimeUs);
DebugTraceUtil.logEvent(COMPONENT_DECODER, EVENT_DECODER_DECODED_FRAME, presentationTimeUs);
return true;
}

View File

@ -24,6 +24,13 @@ import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.areEqual;
import static androidx.media3.common.util.Util.contains;
import static androidx.media3.common.util.Util.usToMs;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_MUXER;
import static androidx.media3.effect.DebugTraceUtil.EVENT_MUXER_CAN_WRITE_SAMPLE_AUDIO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_MUXER_CAN_WRITE_SAMPLE_VIDEO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_MUXER_TRACK_ENDED_AUDIO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_MUXER_TRACK_ENDED_VIDEO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_MUXER_WRITE_SAMPLE_AUDIO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_MUXER_WRITE_SAMPLE_VIDEO;
import static java.lang.Math.max;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@ -524,7 +531,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
boolean canWriteSample = canWriteSample(trackType, presentationTimeUs);
if (trackType == C.TRACK_TYPE_VIDEO) {
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_MUXER_CAN_WRITE_SAMPLE_VIDEO,
COMPONENT_MUXER,
EVENT_MUXER_CAN_WRITE_SAMPLE_VIDEO,
presentationTimeUs,
/* extraFormat= */ "%s",
/* extraArgs...= */ canWriteSample);
@ -533,7 +541,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
} else if (trackType == C.TRACK_TYPE_AUDIO) {
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_MUXER_CAN_WRITE_SAMPLE_AUDIO,
COMPONENT_MUXER,
EVENT_MUXER_CAN_WRITE_SAMPLE_AUDIO,
presentationTimeUs,
/* extraFormat= */ "%s",
/* extraArgs...= */ canWriteSample);
@ -563,9 +572,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
TransformerUtil.getMediaCodecFlags(isKeyFrame ? C.BUFFER_FLAG_KEY_FRAME : 0));
muxer.writeSampleData(trackInfo.trackToken, data, bufferInfo);
if (trackType == C.TRACK_TYPE_VIDEO) {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_MUXER_WRITE_SAMPLE_VIDEO, presentationTimeUs);
DebugTraceUtil.logEvent(COMPONENT_MUXER, EVENT_MUXER_WRITE_SAMPLE_VIDEO, presentationTimeUs);
} else if (trackType == C.TRACK_TYPE_AUDIO) {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_MUXER_WRITE_SAMPLE_AUDIO, presentationTimeUs);
DebugTraceUtil.logEvent(COMPONENT_MUXER, EVENT_MUXER_WRITE_SAMPLE_AUDIO, presentationTimeUs);
}
previousTrackType = trackType;
return true;
@ -587,9 +596,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
listener.onTrackEnded(
trackType, trackInfo.format, trackInfo.getAverageBitrate(), trackInfo.sampleCount);
if (trackType == C.TRACK_TYPE_VIDEO) {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_MUXER_TRACK_ENDED_VIDEO, trackInfo.timeUs);
DebugTraceUtil.logEvent(COMPONENT_MUXER, EVENT_MUXER_TRACK_ENDED_VIDEO, trackInfo.timeUs);
} else if (trackType == C.TRACK_TYPE_AUDIO) {
DebugTraceUtil.logEvent(DebugTraceUtil.EVENT_MUXER_TRACK_ENDED_AUDIO, trackInfo.timeUs);
DebugTraceUtil.logEvent(COMPONENT_MUXER, EVENT_MUXER_TRACK_ENDED_AUDIO, trackInfo.timeUs);
}
if (muxerMode == MUXER_MODE_MUX_PARTIAL) {

View File

@ -24,6 +24,8 @@ import static androidx.media3.common.ColorInfo.SRGB_BT709_FULL;
import static androidx.media3.common.ColorInfo.isTransferHdr;
import static androidx.media3.common.util.Assertions.checkArgument;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_ENCODER;
import static androidx.media3.effect.DebugTraceUtil.EVENT_ENCODER_ENCODED_FRAME;
import static androidx.media3.transformer.Composition.HDR_MODE_KEEP_HDR;
import static androidx.media3.transformer.Composition.HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL;
import static androidx.media3.transformer.TransformerUtil.getOutputMimeTypeAndHdrModeAfterFallback;
@ -194,7 +196,7 @@ import org.checkerframework.dataflow.qual.Pure;
}
}
DebugTraceUtil.logEvent(
DebugTraceUtil.EVENT_ENCODER_ENCODED_FRAME, bufferInfo.presentationTimeUs);
COMPONENT_ENCODER, EVENT_ENCODER_ENCODED_FRAME, bufferInfo.presentationTimeUs);
encoderOutputBuffer.timeUs = bufferInfo.presentationTimeUs;
encoderOutputBuffer.setFlags(bufferInfo.flags);
return encoderOutputBuffer;