mirror of
https://github.com/androidx/media.git
synced 2025-05-17 12:39:52 +08:00
Improve track naming when sampleMimeType unset
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=195346555
This commit is contained in:
parent
bef4a20c31
commit
fdbea33a14
@ -22,7 +22,6 @@ import com.google.android.exoplayer2.Format;
|
|||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/** A default {@link TrackNameProvider}. */
|
/** A default {@link TrackNameProvider}. */
|
||||||
@ -38,9 +37,10 @@ public class DefaultTrackNameProvider implements TrackNameProvider {
|
|||||||
@Override
|
@Override
|
||||||
public String getTrackName(Format format) {
|
public String getTrackName(Format format) {
|
||||||
String trackName;
|
String trackName;
|
||||||
if (MimeTypes.isVideo(format.sampleMimeType)) {
|
int trackType = inferPrimaryTrackType(format);
|
||||||
|
if (trackType == C.TRACK_TYPE_VIDEO) {
|
||||||
trackName = joinWithSeparator(buildResolutionString(format), buildBitrateString(format));
|
trackName = joinWithSeparator(buildResolutionString(format), buildBitrateString(format));
|
||||||
} else if (MimeTypes.isAudio(format.sampleMimeType)) {
|
} else if (trackType == C.TRACK_TYPE_AUDIO) {
|
||||||
trackName =
|
trackName =
|
||||||
joinWithSeparator(
|
joinWithSeparator(
|
||||||
buildLanguageString(format),
|
buildLanguageString(format),
|
||||||
@ -112,4 +112,24 @@ public class DefaultTrackNameProvider implements TrackNameProvider {
|
|||||||
}
|
}
|
||||||
return itemList;
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int inferPrimaryTrackType(Format format) {
|
||||||
|
int trackType = MimeTypes.getTrackType(format.sampleMimeType);
|
||||||
|
if (trackType != C.TRACK_TYPE_UNKNOWN) {
|
||||||
|
return trackType;
|
||||||
|
}
|
||||||
|
if (MimeTypes.getVideoMediaMimeType(format.codecs) != null) {
|
||||||
|
return C.TRACK_TYPE_VIDEO;
|
||||||
|
}
|
||||||
|
if (MimeTypes.getAudioMediaMimeType(format.codecs) != null) {
|
||||||
|
return C.TRACK_TYPE_AUDIO;
|
||||||
|
}
|
||||||
|
if (format.width != Format.NO_VALUE || format.height != Format.NO_VALUE) {
|
||||||
|
return C.TRACK_TYPE_VIDEO;
|
||||||
|
}
|
||||||
|
if (format.channelCount != Format.NO_VALUE || format.sampleRate != Format.NO_VALUE) {
|
||||||
|
return C.TRACK_TYPE_AUDIO;
|
||||||
|
}
|
||||||
|
return C.TRACK_TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user