mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Refactor track retrieval into a separate method
This will be be required when we add more method which required video track. PiperOrigin-RevId: 603024260
This commit is contained in:
parent
65c354029a
commit
61603f90f3
@ -43,6 +43,17 @@ public final class FileUtil {
|
|||||||
*/
|
*/
|
||||||
public static void assertFileHasColorTransfer(
|
public static void assertFileHasColorTransfer(
|
||||||
Context context, @Nullable String filePath, @C.ColorTransfer int expectedColorTransfer) {
|
Context context, @Nullable String filePath, @C.ColorTransfer int expectedColorTransfer) {
|
||||||
|
Format videoTrackFormat = retrieveVideoTrackFormat(context, filePath);
|
||||||
|
@Nullable ColorInfo colorInfo = videoTrackFormat.colorInfo;
|
||||||
|
@C.ColorTransfer
|
||||||
|
int actualColorTransfer =
|
||||||
|
colorInfo == null || colorInfo.colorTransfer == Format.NO_VALUE
|
||||||
|
? C.COLOR_TRANSFER_SDR
|
||||||
|
: colorInfo.colorTransfer;
|
||||||
|
assertThat(actualColorTransfer).isEqualTo(expectedColorTransfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Format retrieveVideoTrackFormat(Context context, @Nullable String filePath) {
|
||||||
TrackGroupArray trackGroupArray;
|
TrackGroupArray trackGroupArray;
|
||||||
try {
|
try {
|
||||||
trackGroupArray =
|
trackGroupArray =
|
||||||
@ -59,14 +70,7 @@ public final class FileUtil {
|
|||||||
TrackGroup trackGroup = trackGroupArray.get(i);
|
TrackGroup trackGroup = trackGroupArray.get(i);
|
||||||
if (trackGroup.type == C.TRACK_TYPE_VIDEO) {
|
if (trackGroup.type == C.TRACK_TYPE_VIDEO) {
|
||||||
assertThat(trackGroup.length).isEqualTo(1);
|
assertThat(trackGroup.length).isEqualTo(1);
|
||||||
@Nullable ColorInfo colorInfo = trackGroup.getFormat(0).colorInfo;
|
return trackGroup.getFormat(0);
|
||||||
@C.ColorTransfer
|
|
||||||
int actualColorTransfer =
|
|
||||||
colorInfo == null || colorInfo.colorTransfer == Format.NO_VALUE
|
|
||||||
? C.COLOR_TRANSFER_SDR
|
|
||||||
: colorInfo.colorTransfer;
|
|
||||||
assertThat(actualColorTransfer).isEqualTo(expectedColorTransfer);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Couldn't find video track");
|
throw new IllegalStateException("Couldn't find video track");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user