Commit 7625c1b8 by olly Committed by Oliver Woodman

Remove unnecessary configuration parameter.

- It's always fine to prefer the manifest drm init data. In
  DASH we always do this anyway. In SS the manifest and sample
  formats are identical.
- Optimized the case where the manifest and sample formats are
  identical by avoiding the format copy.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=147385282
parent 8cb3b6ed
...@@ -438,16 +438,19 @@ public final class Format implements Parcelable { ...@@ -438,16 +438,19 @@ public final class Format implements Parcelable {
drmInitData, metadata); drmInitData, metadata);
} }
public Format copyWithManifestFormatInfo(Format manifestFormat, public Format copyWithManifestFormatInfo(Format manifestFormat) {
boolean preferManifestDrmInitData) { if (this == manifestFormat) {
// No need to copy from ourselves.
return this;
}
String id = manifestFormat.id; String id = manifestFormat.id;
String codecs = this.codecs == null ? manifestFormat.codecs : this.codecs; String codecs = this.codecs == null ? manifestFormat.codecs : this.codecs;
int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate;
float frameRate = this.frameRate == NO_VALUE ? manifestFormat.frameRate : this.frameRate; float frameRate = this.frameRate == NO_VALUE ? manifestFormat.frameRate : this.frameRate;
@C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags;
String language = this.language == null ? manifestFormat.language : this.language; String language = this.language == null ? manifestFormat.language : this.language;
DrmInitData drmInitData = (preferManifestDrmInitData && manifestFormat.drmInitData != null) DrmInitData drmInitData = manifestFormat.drmInitData != null ? manifestFormat.drmInitData
|| this.drmInitData == null ? manifestFormat.drmInitData : this.drmInitData; : this.drmInitData;
return new Format(id, containerMimeType, sampleMimeType, codecs, bitrate, maxInputSize, width, return new Format(id, containerMimeType, sampleMimeType, codecs, bitrate, maxInputSize, width,
height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode,
channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, selectionFlags, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, selectionFlags,
......
...@@ -312,8 +312,7 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> { ...@@ -312,8 +312,7 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
final boolean isWebm = mimeType.startsWith(MimeTypes.VIDEO_WEBM) final boolean isWebm = mimeType.startsWith(MimeTypes.VIDEO_WEBM)
|| mimeType.startsWith(MimeTypes.AUDIO_WEBM); || mimeType.startsWith(MimeTypes.AUDIO_WEBM);
final Extractor extractor = isWebm ? new MatroskaExtractor() : new FragmentedMp4Extractor(); final Extractor extractor = isWebm ? new MatroskaExtractor() : new FragmentedMp4Extractor();
return new ChunkExtractorWrapper(extractor, format, trackType, return new ChunkExtractorWrapper(extractor, format, trackType);
false /* preferManifestDrmInitData */);
} }
} }
...@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.source.chunk; ...@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.source.chunk;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.extractor.DummyTrackOutput; import com.google.android.exoplayer2.extractor.DummyTrackOutput;
import com.google.android.exoplayer2.extractor.Extractor; import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ExtractorInput; import com.google.android.exoplayer2.extractor.ExtractorInput;
...@@ -39,7 +38,6 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput ...@@ -39,7 +38,6 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput
private final Format manifestFormat; private final Format manifestFormat;
private final int primaryTrackType; private final int primaryTrackType;
private final boolean preferManifestDrmInitData;
private boolean extractorInitialized; private boolean extractorInitialized;
private TrackOutput trackOutput; private TrackOutput trackOutput;
...@@ -56,15 +54,11 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput ...@@ -56,15 +54,11 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput
* sample {@link Format} output from the {@link Extractor}. * sample {@link Format} output from the {@link Extractor}.
* @param primaryTrackType The type of the primary track. Typically one of the {@link C} * @param primaryTrackType The type of the primary track. Typically one of the {@link C}
* {@code TRACK_TYPE_*} constants. * {@code TRACK_TYPE_*} constants.
* @param preferManifestDrmInitData Whether {@link DrmInitData} defined in {@code manifestFormat}
* should be preferred when the sample and manifest {@link Format}s are merged.
*/ */
public ChunkExtractorWrapper(Extractor extractor, Format manifestFormat, int primaryTrackType, public ChunkExtractorWrapper(Extractor extractor, Format manifestFormat, int primaryTrackType) {
boolean preferManifestDrmInitData) {
this.extractor = extractor; this.extractor = extractor;
this.manifestFormat = manifestFormat; this.manifestFormat = manifestFormat;
this.primaryTrackType = primaryTrackType; this.primaryTrackType = primaryTrackType;
this.preferManifestDrmInitData = preferManifestDrmInitData;
} }
/** /**
...@@ -127,7 +121,7 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput ...@@ -127,7 +121,7 @@ public final class ChunkExtractorWrapper implements ExtractorOutput, TrackOutput
@Override @Override
public void format(Format format) { public void format(Format format) {
sampleFormat = format.copyWithManifestFormatInfo(manifestFormat, preferManifestDrmInitData); sampleFormat = format.copyWithManifestFormatInfo(manifestFormat);
if (trackOutput != null) { if (trackOutput != null) {
trackOutput.format(sampleFormat); trackOutput.format(sampleFormat);
} }
......
...@@ -382,8 +382,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -382,8 +382,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
} }
// Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream, // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream,
// as per DASH IF Interoperability Recommendations V3.0, 7.5.3. // as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
extractorWrapper = new ChunkExtractorWrapper(extractor, representation.format, extractorWrapper = new ChunkExtractorWrapper(extractor, representation.format, trackType);
trackType, true /* preferManifestDrmInitData */);
} }
segmentIndex = representation.getIndex(); segmentIndex = representation.getIndex();
} }
......
...@@ -102,8 +102,7 @@ public class DefaultSsChunkSource implements SsChunkSource { ...@@ -102,8 +102,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
FragmentedMp4Extractor extractor = new FragmentedMp4Extractor( FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
| FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, null, track); | FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, null, track);
extractorWrappers[i] = new ChunkExtractorWrapper(extractor, format, streamElement.type, extractorWrappers[i] = new ChunkExtractorWrapper(extractor, format, streamElement.type);
false);
} }
} }
......
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