Commit 7cf758f8 by christosts Committed by tonihei

Log Format.colorInfo

Log Format.colorInfo in EventLogger and the demo app's debug text.

#minor-release

PiperOrigin-RevId: 516172936
parent d1534680
...@@ -238,6 +238,23 @@ public final class ColorInfo implements Bundleable { ...@@ -238,6 +238,23 @@ public final class ColorInfo implements Bundleable {
&& colorTransfer != Format.NO_VALUE; && colorTransfer != Format.NO_VALUE;
} }
/**
* Returns a prettier {@link String} than {@link #toString()}, intended for logging.
*
* @see Format#toLogString(Format)
*/
public String toLogString() {
if (!isValid()) {
return "NA";
}
return Util.formatInvariant(
"%s/%s/%s",
colorSpaceToString(colorSpace),
colorRangeToString(colorRange),
colorTransferToString(colorTransfer));
}
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (this == obj) { if (this == obj) {
......
...@@ -1277,6 +1277,8 @@ public final class Format implements Bundleable { ...@@ -1277,6 +1277,8 @@ public final class Format implements Bundleable {
+ height + height
+ ", " + ", "
+ frameRate + frameRate
+ ", "
+ colorInfo
+ "]" + "]"
+ ", [" + ", ["
+ channelCount + channelCount
...@@ -1443,6 +1445,9 @@ public final class Format implements Bundleable { ...@@ -1443,6 +1445,9 @@ public final class Format implements Bundleable {
if (format.width != NO_VALUE && format.height != NO_VALUE) { if (format.width != NO_VALUE && format.height != NO_VALUE) {
builder.append(", res=").append(format.width).append("x").append(format.height); builder.append(", res=").append(format.width).append("x").append(format.height);
} }
if (format.colorInfo != null && format.colorInfo.isValid()) {
builder.append(", color=").append(format.colorInfo.toLogString());
}
if (format.frameRate != NO_VALUE) { if (format.frameRate != NO_VALUE) {
builder.append(", fps=").append(format.frameRate); builder.append(", fps=").append(format.frameRate);
} }
......
...@@ -18,6 +18,8 @@ package androidx.media3.exoplayer.util; ...@@ -18,6 +18,8 @@ package androidx.media3.exoplayer.util;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.os.Looper; import android.os.Looper;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.media3.common.ColorInfo;
import androidx.media3.common.Format; import androidx.media3.common.Format;
import androidx.media3.common.Player; import androidx.media3.common.Player;
import androidx.media3.common.util.Assertions; import androidx.media3.common.util.Assertions;
...@@ -137,6 +139,7 @@ public class DebugTextViewHelper { ...@@ -137,6 +139,7 @@ public class DebugTextViewHelper {
+ format.width + format.width
+ "x" + "x"
+ format.height + format.height
+ getColorInfoString(format.colorInfo)
+ getPixelAspectRatioString(format.pixelWidthHeightRatio) + getPixelAspectRatioString(format.pixelWidthHeightRatio)
+ getDecoderCountersBufferCountString(decoderCounters) + getDecoderCountersBufferCountString(decoderCounters)
+ " vfpo: " + " vfpo: "
...@@ -185,6 +188,10 @@ public class DebugTextViewHelper { ...@@ -185,6 +188,10 @@ public class DebugTextViewHelper {
+ counters.droppedToKeyframeCount; + counters.droppedToKeyframeCount;
} }
private static String getColorInfoString(@Nullable ColorInfo colorInfo) {
return colorInfo != null && colorInfo.isValid() ? " colr:" + colorInfo.toLogString() : "";
}
private static String getPixelAspectRatioString(float pixelAspectRatio) { private static String getPixelAspectRatioString(float pixelAspectRatio) {
return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f
? "" ? ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment