Clean up parseSampleEntryEncryptionData
It was a bit strange how it returned something via the return value and something else via the "out" variable, and doing it this way wasn't even saving any allocations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160645640
This commit is contained in:
parent
51b98e817c
commit
c7924bfe22
@ -674,15 +674,16 @@ import java.util.List;
|
|||||||
|
|
||||||
int childPosition = parent.getPosition();
|
int childPosition = parent.getPosition();
|
||||||
if (atomType == Atom.TYPE_encv) {
|
if (atomType == Atom.TYPE_encv) {
|
||||||
atomType = parseSampleEntryEncryptionData(parent, position, size, out, entryIndex);
|
Pair<Integer, TrackEncryptionBox> sampleEntryEncryptionData = parseSampleEntryEncryptionData(
|
||||||
TrackEncryptionBox encryptionBox = out.trackEncryptionBoxes[entryIndex];
|
parent, position, size);
|
||||||
String schemeType = encryptionBox != null ? encryptionBox.schemeType : null;
|
if (sampleEntryEncryptionData != null) {
|
||||||
if (schemeType != null) {
|
atomType = sampleEntryEncryptionData.first;
|
||||||
drmInitData = drmInitData.copyWithSchemeType(schemeType);
|
drmInitData = drmInitData.copyWithSchemeType(sampleEntryEncryptionData.second.schemeType);
|
||||||
|
out.trackEncryptionBoxes[entryIndex] = sampleEntryEncryptionData.second;
|
||||||
}
|
}
|
||||||
parent.setPosition(childPosition);
|
parent.setPosition(childPosition);
|
||||||
}
|
}
|
||||||
// TODO: Uncomment the following part when b/63092960 is fixed.
|
// TODO: Uncomment when [Internal: b/63092960] is fixed.
|
||||||
// else {
|
// else {
|
||||||
// drmInitData = null;
|
// drmInitData = null;
|
||||||
// }
|
// }
|
||||||
@ -852,15 +853,16 @@ import java.util.List;
|
|||||||
|
|
||||||
int childPosition = parent.getPosition();
|
int childPosition = parent.getPosition();
|
||||||
if (atomType == Atom.TYPE_enca) {
|
if (atomType == Atom.TYPE_enca) {
|
||||||
atomType = parseSampleEntryEncryptionData(parent, position, size, out, entryIndex);
|
Pair<Integer, TrackEncryptionBox> sampleEntryEncryptionData = parseSampleEntryEncryptionData(
|
||||||
TrackEncryptionBox encryptionBox = out.trackEncryptionBoxes[entryIndex];
|
parent, position, size);
|
||||||
String schemeType = encryptionBox != null ? encryptionBox.schemeType : null;
|
if (sampleEntryEncryptionData != null) {
|
||||||
if (schemeType != null) {
|
atomType = sampleEntryEncryptionData.first;
|
||||||
drmInitData = drmInitData.copyWithSchemeType(schemeType);
|
drmInitData = drmInitData.copyWithSchemeType(sampleEntryEncryptionData.second.schemeType);
|
||||||
|
out.trackEncryptionBoxes[entryIndex] = sampleEntryEncryptionData.second;
|
||||||
}
|
}
|
||||||
parent.setPosition(childPosition);
|
parent.setPosition(childPosition);
|
||||||
}
|
}
|
||||||
// TODO: Uncomment the following part when b/63092960 is fixed.
|
// TODO: Uncomment when [Internal: b/63092960] is fixed.
|
||||||
// else {
|
// else {
|
||||||
// drmInitData = null;
|
// drmInitData = null;
|
||||||
// }
|
// }
|
||||||
@ -1039,11 +1041,12 @@ import java.util.List;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses encryption data from an audio/video sample entry, populating {@code out} and returning
|
* Parses encryption data from an audio/video sample entry, returning a pair consisting of the
|
||||||
* the unencrypted atom type, or 0 if no common encryption sinf atom was present.
|
* unencrypted atom type and a {@link TrackEncryptionBox}. Null is returned if no common
|
||||||
|
* encryption sinf atom was present.
|
||||||
*/
|
*/
|
||||||
private static int parseSampleEntryEncryptionData(ParsableByteArray parent, int position,
|
private static Pair<Integer, TrackEncryptionBox> parseSampleEntryEncryptionData(
|
||||||
int size, StsdData out, int entryIndex) {
|
ParsableByteArray parent, int position, int size) {
|
||||||
int childPosition = parent.getPosition();
|
int childPosition = parent.getPosition();
|
||||||
while (childPosition - position < size) {
|
while (childPosition - position < size) {
|
||||||
parent.setPosition(childPosition);
|
parent.setPosition(childPosition);
|
||||||
@ -1054,14 +1057,12 @@ import java.util.List;
|
|||||||
Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition,
|
Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition,
|
||||||
childAtomSize);
|
childAtomSize);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
out.trackEncryptionBoxes[entryIndex] = result.second;
|
return result;
|
||||||
return result.first;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
childPosition += childAtomSize;
|
childPosition += childAtomSize;
|
||||||
}
|
}
|
||||||
// This enca/encv box does not have a data format so return an invalid atom type.
|
return null;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Pair<Integer, TrackEncryptionBox> parseSinfFromParent(ParsableByteArray parent,
|
private static Pair<Integer, TrackEncryptionBox> parseSinfFromParent(ParsableByteArray parent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user