mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Remove the modification on Format
According to Google's comments, removing the modification on Format.java since it is redundant.
This commit is contained in:
parent
79078c390d
commit
c18c6b31ef
@ -62,8 +62,6 @@ import java.util.UUID;
|
||||
* <li>{@link #averageBitrate}
|
||||
* <li>{@link #peakBitrate}
|
||||
* <li>{@link #codecs}
|
||||
* <li>{@link #supplementalCodecs}
|
||||
* <li>{@link #supplementalProfiles}
|
||||
* <li>{@link #metadata}
|
||||
* </ul>
|
||||
*
|
||||
@ -104,7 +102,6 @@ import java.util.UUID;
|
||||
* <li>{@link #projectionData}
|
||||
* <li>{@link #stereoMode}
|
||||
* <li>{@link #colorInfo}
|
||||
* <li>{@link #videoRange}
|
||||
* </ul>
|
||||
*
|
||||
* <h2 id="audio-formats">Fields relevant to audio formats</h2>
|
||||
@ -154,8 +151,6 @@ public final class Format {
|
||||
private int averageBitrate;
|
||||
private int peakBitrate;
|
||||
@Nullable private String codecs;
|
||||
@Nullable private String supplementalCodecs;
|
||||
@Nullable private String supplementalProfiles;
|
||||
@Nullable private Metadata metadata;
|
||||
@Nullable private Object customData;
|
||||
|
||||
@ -183,7 +178,6 @@ public final class Format {
|
||||
@Nullable private byte[] projectionData;
|
||||
private @C.StereoMode int stereoMode;
|
||||
@Nullable private ColorInfo colorInfo;
|
||||
@Nullable private String videoRange;
|
||||
|
||||
// Audio specific.
|
||||
|
||||
@ -252,8 +246,6 @@ public final class Format {
|
||||
this.averageBitrate = format.averageBitrate;
|
||||
this.peakBitrate = format.peakBitrate;
|
||||
this.codecs = format.codecs;
|
||||
this.supplementalCodecs = format.supplementalCodecs;
|
||||
this.supplementalProfiles = format.supplementalProfiles;
|
||||
this.metadata = format.metadata;
|
||||
this.customData = format.customData;
|
||||
// Container specific.
|
||||
@ -275,7 +267,6 @@ public final class Format {
|
||||
this.projectionData = format.projectionData;
|
||||
this.stereoMode = format.stereoMode;
|
||||
this.colorInfo = format.colorInfo;
|
||||
this.videoRange = format.videoRange;
|
||||
// Audio specific.
|
||||
this.channelCount = format.channelCount;
|
||||
this.sampleRate = format.sampleRate;
|
||||
@ -438,28 +429,6 @@ public final class Format {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link Format#supplementalCodecs}. The default value is {@code null}.
|
||||
*
|
||||
* @param supplementalCodecs The {@link Format#supplementalCodecs}.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setSupplementalCodecs(@Nullable String supplementalCodecs) {
|
||||
this.supplementalCodecs = supplementalCodecs;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link Format#supplementalProfiles}. The default value is {@code null}.
|
||||
*
|
||||
* @param supplementalProfiles The {@link Format#supplementalProfiles}.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setSupplementalProfiles(@Nullable String supplementalProfiles) {
|
||||
this.supplementalProfiles = supplementalProfiles;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link Format#metadata}. The default value is {@code null}.
|
||||
*
|
||||
@ -686,17 +655,6 @@ public final class Format {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link Format#videoRange}. The default value is {@code null}.
|
||||
*
|
||||
* @param videoRange The {@link Format#videoRange}.
|
||||
* @return The builder.
|
||||
*/
|
||||
public Builder setVideoRange(@Nullable String videoRange) {
|
||||
this.videoRange = videoRange;
|
||||
return this;
|
||||
}
|
||||
|
||||
// Audio specific.
|
||||
|
||||
/**
|
||||
@ -958,12 +916,6 @@ public final class Format {
|
||||
/** Codecs of the format as described in RFC 6381, or null if unknown or not applicable. */
|
||||
@Nullable public final String codecs;
|
||||
|
||||
/** The supplemental codecs for compatibility playback, or null if not applicable. */
|
||||
@Nullable public final String supplementalCodecs;
|
||||
|
||||
/** The supplemental profiles for compatibility playback, or null if not applicable. */
|
||||
@Nullable public final String supplementalProfiles;
|
||||
|
||||
/** Metadata, or null if unknown or not applicable. */
|
||||
@UnstableApi @Nullable public final Metadata metadata;
|
||||
|
||||
@ -1056,9 +1008,6 @@ public final class Format {
|
||||
/** The color metadata associated with the video, or null if not applicable. */
|
||||
@UnstableApi @Nullable public final ColorInfo colorInfo;
|
||||
|
||||
/** The reference opto-electronic transfer characteristic functions, or null if not applicable. */
|
||||
@Nullable public final String videoRange;
|
||||
|
||||
// Audio specific.
|
||||
|
||||
/** The number of audio channels, or {@link #NO_VALUE} if unknown or not applicable. */
|
||||
@ -1154,8 +1103,6 @@ public final class Format {
|
||||
peakBitrate = builder.peakBitrate;
|
||||
bitrate = peakBitrate != NO_VALUE ? peakBitrate : averageBitrate;
|
||||
codecs = builder.codecs;
|
||||
supplementalCodecs = builder.supplementalCodecs;
|
||||
supplementalProfiles = builder.supplementalProfiles;
|
||||
metadata = builder.metadata;
|
||||
customData = builder.customData;
|
||||
// Container specific.
|
||||
@ -1179,7 +1126,6 @@ public final class Format {
|
||||
projectionData = builder.projectionData;
|
||||
stereoMode = builder.stereoMode;
|
||||
colorInfo = builder.colorInfo;
|
||||
videoRange = builder.videoRange;
|
||||
// Audio specific.
|
||||
channelCount = builder.channelCount;
|
||||
sampleRate = builder.sampleRate;
|
||||
@ -1244,9 +1190,8 @@ public final class Format {
|
||||
codecs = codecsOfType;
|
||||
}
|
||||
}
|
||||
if (MimeTypes.VIDEO_DOLBY_VISION.equals(sampleMimeType) &&
|
||||
manifestFormat.supplementalCodecs != null) {
|
||||
codecs = manifestFormat.supplementalCodecs;
|
||||
if (MimeTypes.VIDEO_DOLBY_VISION.equals(sampleMimeType)) {
|
||||
codecs = manifestFormat.codecs;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -847,59 +847,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
return drmInitDataBySchemeType;
|
||||
}
|
||||
|
||||
private static boolean isDolbyVisionFormat(
|
||||
@Nullable String videoRange,
|
||||
@Nullable String codecs,
|
||||
@Nullable String supplementalCodecs,
|
||||
@Nullable String supplementalProfiles) {
|
||||
if (codecs == null) {
|
||||
return false;
|
||||
}
|
||||
if (codecs.startsWith("dvhe") || codecs.startsWith("dvh1")) {
|
||||
// profile 5
|
||||
return true;
|
||||
}
|
||||
|
||||
if (supplementalCodecs == null) {
|
||||
return false;
|
||||
}
|
||||
// For Dolby Vision, the compatibility brand (i.e. supplemental profiles) and the VIDEO-RANGE
|
||||
// attribute act as cross-checks. Leaving out either one is incorrect.
|
||||
if (videoRange == null || supplementalProfiles == null) {
|
||||
return false;
|
||||
}
|
||||
if ((videoRange.equals("PQ") && !supplementalProfiles.equals("db1p")) ||
|
||||
(videoRange.equals("SDR") && !supplementalProfiles.equals("db2g")) ||
|
||||
(videoRange.equals("HLG") && !supplementalProfiles.startsWith("db4"))) { // db4g or db4h
|
||||
return false;
|
||||
}
|
||||
|
||||
return (supplementalCodecs.startsWith("dvhe") && codecs.startsWith("hev1")) || // profile 8
|
||||
(supplementalCodecs.startsWith("dvh1") && codecs.startsWith("hvc1")) || // profile 8
|
||||
(supplementalCodecs.startsWith("dvav") && codecs.startsWith("avc3")) || // profile 9
|
||||
(supplementalCodecs.startsWith("dva1") && codecs.startsWith("avc1")) || // profile 9
|
||||
(supplementalCodecs.startsWith("dav1") && codecs.startsWith("av01")); // profile 10
|
||||
}
|
||||
|
||||
private static Format deriveVideoFormat(Format variantFormat) {
|
||||
@Nullable String videoRange = variantFormat.videoRange;
|
||||
@Nullable String codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_VIDEO);
|
||||
@Nullable String supplementalCodecs = variantFormat.supplementalCodecs;
|
||||
@Nullable String supplementalProfiles = variantFormat.supplementalProfiles;
|
||||
@Nullable String sampleMimeType = MimeTypes.getMediaMimeType(codecs);
|
||||
|
||||
if (isDolbyVisionFormat(videoRange, codecs, supplementalCodecs, supplementalProfiles)) {
|
||||
sampleMimeType = MimeTypes.VIDEO_DOLBY_VISION;
|
||||
codecs = supplementalCodecs != null ? supplementalCodecs : codecs;
|
||||
}
|
||||
|
||||
return new Format.Builder()
|
||||
.setId(variantFormat.id)
|
||||
.setLabel(variantFormat.label)
|
||||
.setLabels(variantFormat.labels)
|
||||
.setContainerMimeType(variantFormat.containerMimeType)
|
||||
.setSampleMimeType(sampleMimeType)
|
||||
.setVideoRange(videoRange)
|
||||
.setCodecs(codecs)
|
||||
.setMetadata(variantFormat.metadata)
|
||||
.setAverageBitrate(variantFormat.averageBitrate)
|
||||
|
@ -326,6 +326,40 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
return c;
|
||||
}
|
||||
|
||||
private static boolean isDolbyVisionFormat(
|
||||
@Nullable String videoRange,
|
||||
@Nullable String codecs,
|
||||
@Nullable String supplementalCodecs,
|
||||
@Nullable String supplementalProfiles) {
|
||||
if (codecs == null) {
|
||||
return false;
|
||||
}
|
||||
if (codecs.startsWith("dvhe") || codecs.startsWith("dvh1")) {
|
||||
// profile 5
|
||||
return true;
|
||||
}
|
||||
|
||||
if (supplementalCodecs == null) {
|
||||
return false;
|
||||
}
|
||||
// For Dolby Vision, the compatibility brand (i.e. supplemental profiles) and the VIDEO-RANGE
|
||||
// attribute act as cross-checks. Leaving out either one is incorrect.
|
||||
if (videoRange == null || supplementalProfiles == null) {
|
||||
return false;
|
||||
}
|
||||
if ((videoRange.equals("PQ") && !supplementalProfiles.equals("db1p")) ||
|
||||
(videoRange.equals("SDR") && !supplementalProfiles.equals("db2g")) ||
|
||||
(videoRange.equals("HLG") && !supplementalProfiles.startsWith("db4"))) { // db4g or db4h
|
||||
return false;
|
||||
}
|
||||
|
||||
return (supplementalCodecs.startsWith("dvhe") && codecs.startsWith("hev1")) || // profile 8
|
||||
(supplementalCodecs.startsWith("dvh1") && codecs.startsWith("hvc1")) || // profile 8
|
||||
(supplementalCodecs.startsWith("dvav") && codecs.startsWith("avc3")) || // profile 9
|
||||
(supplementalCodecs.startsWith("dva1") && codecs.startsWith("avc1")) || // profile 9
|
||||
(supplementalCodecs.startsWith("dav1") && codecs.startsWith("av01")); // profile 10
|
||||
}
|
||||
|
||||
private static HlsMultivariantPlaylist parseMultivariantPlaylist(
|
||||
LineIterator iterator, String baseUri) throws IOException {
|
||||
HashMap<Uri, ArrayList<VariantInfo>> urlToVariantInfos = new HashMap<>();
|
||||
@ -394,6 +428,10 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isDolbyVisionFormat(videoRange, codecs, supplementalCodecs, supplementalProfiles)) {
|
||||
codecs = supplementalCodecs != null ? supplementalCodecs : codecs;
|
||||
}
|
||||
|
||||
String resolutionString =
|
||||
parseOptionalStringAttr(line, REGEX_RESOLUTION, variableDefinitions);
|
||||
int width;
|
||||
@ -440,10 +478,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
new Format.Builder()
|
||||
.setId(variants.size())
|
||||
.setContainerMimeType(MimeTypes.APPLICATION_M3U8)
|
||||
.setVideoRange(videoRange)
|
||||
.setCodecs(codecs)
|
||||
.setSupplementalCodecs(supplementalCodecs)
|
||||
.setSupplementalProfiles(supplementalProfiles)
|
||||
.setAverageBitrate(averageBitrate)
|
||||
.setPeakBitrate(peakBitrate)
|
||||
.setWidth(width)
|
||||
|
Loading…
x
Reference in New Issue
Block a user