Add debug trace log for AssetLoader Renderer format events.

PiperOrigin-RevId: 634474584
This commit is contained in:
samrobinson 2024-05-16 11:29:36 -07:00 committed by Copybara-Service
parent 2ac8247cf4
commit 1abcf5c22c
3 changed files with 23 additions and 14 deletions

View File

@ -126,11 +126,11 @@ public final class DebugTraceUtil {
@Documented
@Retention(RetentionPolicy.SOURCE)
@StringDef({
COMPONENT_ASSET_LOADER,
COMPONENT_AUDIO_DECODER,
COMPONENT_AUDIO_GRAPH,
COMPONENT_AUDIO_MIXER,
COMPONENT_AUDIO_ENCODER,
COMPONENT_VIDEO,
COMPONENT_VIDEO_DECODER,
COMPONENT_VFP,
COMPONENT_BITMAP_TEXTURE_MANAGER,
@ -143,9 +143,7 @@ public final class DebugTraceUtil {
@Target(TYPE_USE)
public @interface Component {}
// TODO - b/339639306: Migrate COMPONENT_VIDEO usage to COMPONENT_ASSETLOADER.
public static final String COMPONENT_VIDEO = "Video";
public static final String COMPONENT_ASSET_LOADER = "AssetLoader";
public static final String COMPONENT_AUDIO_DECODER = "AudioDecoder";
public static final String COMPONENT_AUDIO_GRAPH = "AudioGraph";
public static final String COMPONENT_AUDIO_MIXER = "AudioMixer";
@ -162,6 +160,7 @@ public final class DebugTraceUtil {
// 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.<String, List<String>>builder()
.put(COMPONENT_ASSET_LOADER, ImmutableList.of(EVENT_INPUT_FORMAT, EVENT_OUTPUT_FORMAT))
.put(
COMPONENT_AUDIO_DECODER,
ImmutableList.of(
@ -187,7 +186,6 @@ public final class DebugTraceUtil {
EVENT_PRODUCED_OUTPUT,
EVENT_INPUT_ENDED,
EVENT_OUTPUT_ENDED))
.put(COMPONENT_VIDEO, ImmutableList.of(EVENT_INPUT_FORMAT))
.put(
COMPONENT_VIDEO_DECODER,
ImmutableList.of(

View File

@ -17,8 +17,6 @@ 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_VIDEO;
import static androidx.media3.effect.DebugTraceUtil.EVENT_INPUT_FORMAT;
import static androidx.media3.transformer.TransformerUtil.getDecoderOutputColor;
import android.media.MediaCodec;
@ -27,7 +25,6 @@ import androidx.media3.common.C;
import androidx.media3.common.ColorInfo;
import androidx.media3.common.Format;
import androidx.media3.decoder.DecoderInputBuffer;
import androidx.media3.effect.DebugTraceUtil;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@ -87,12 +84,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override
protected void onInputFormatRead(Format inputFormat) {
DebugTraceUtil.logEvent(
COMPONENT_VIDEO,
EVENT_INPUT_FORMAT,
C.TIME_UNSET,
/* extraFormat= */ "%s",
/* extraArgs...= */ inputFormat);
if (flattenForSlowMotion) {
sefVideoSlowMotionFlattener = new SefSlowMotionFlattener(inputFormat);
}

View File

@ -19,6 +19,9 @@ 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.common.util.Assertions.checkStateNotNull;
import static androidx.media3.effect.DebugTraceUtil.COMPONENT_ASSET_LOADER;
import static androidx.media3.effect.DebugTraceUtil.EVENT_INPUT_FORMAT;
import static androidx.media3.effect.DebugTraceUtil.EVENT_OUTPUT_FORMAT;
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_AVAILABLE;
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NOT_STARTED;
import static androidx.media3.transformer.TransformerUtil.getProcessedTrackType;
@ -37,6 +40,7 @@ import androidx.media3.common.util.HandlerWrapper;
import androidx.media3.common.util.TimestampIterator;
import androidx.media3.common.util.Util;
import androidx.media3.decoder.DecoderInputBuffer;
import androidx.media3.effect.DebugTraceUtil;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
@ -215,6 +219,14 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override
public boolean onTrackAdded(Format inputFormat, @SupportedOutputTypes int supportedOutputTypes) {
boolean isAudio = getProcessedTrackType(inputFormat.sampleMimeType) == C.TRACK_TYPE_AUDIO;
DebugTraceUtil.logEvent(
COMPONENT_ASSET_LOADER,
EVENT_INPUT_FORMAT,
C.TIME_UNSET,
"%s:%s",
isAudio ? "audio" : "video",
inputFormat);
if (!isCurrentAssetFirstAsset) {
return isAudio ? decodeAudio : decodeVideo;
}
@ -249,6 +261,14 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override
public SampleConsumerWrapper onOutputFormat(Format format) throws ExportException {
@C.TrackType int trackType = getProcessedTrackType(format.sampleMimeType);
DebugTraceUtil.logEvent(
COMPONENT_ASSET_LOADER,
EVENT_OUTPUT_FORMAT,
C.TIME_UNSET,
"%s:%s",
Util.getTrackTypeString(trackType),
format);
SampleConsumerWrapper sampleConsumer;
if (isCurrentAssetFirstAsset) {
@Nullable