Methods Summary |
---|
public void | _parseDetails(java.nio.ByteBuffer content)
parseVersionAndFlags(content);
int useThisIvSize = -1;
if ((getFlags() & 0x1) > 0) {
algorithmId = IsoTypeReader.readUInt24(content);
ivSize = IsoTypeReader.readUInt8(content);
useThisIvSize = ivSize;
kid = new byte[16];
content.get(kid);
} else {
List<Box> tkhds = Path.getPaths(this, "/moov[0]/trak/tkhd");
for (Box tkhd : tkhds) {
if (((TrackHeaderBox) tkhd).getTrackId() == this.getParent().getBoxes(TrackFragmentHeaderBox.class).get(0).getTrackId()) {
AbstractTrackEncryptionBox tenc = (AbstractTrackEncryptionBox) Path.getPath(tkhd, "../mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schi[0]/tenc[0]");
if (tenc == null) {
tenc = (AbstractTrackEncryptionBox) Path.getPath(tkhd, "../mdia[0]/minf[0]/stbl[0]/stsd[0]/enc.[0]/sinf[0]/schi[0]/uuid[0]");
}
useThisIvSize = tenc.getDefaultIvSize();
}
}
}
long numOfEntries = IsoTypeReader.readUInt32(content);
while (numOfEntries-- > 0) {
Entry e = new Entry();
e.iv = new byte[useThisIvSize < 0 ? 8 : useThisIvSize]; // default to 8
content.get(e.iv);
if ((getFlags() & 0x2) > 0) {
int numOfPairs = IsoTypeReader.readUInt16(content);
e.pairs = new LinkedList<Entry.Pair>();
while (numOfPairs-- > 0) {
e.pairs.add(e.createPair(IsoTypeReader.readUInt16(content), IsoTypeReader.readUInt32(content)));
}
}
entries.add(e);
}
|
public com.googlecode.mp4parser.boxes.AbstractSampleEncryptionBox$Entry | createEntry()
return new Entry();
|
public boolean | equals(java.lang.Object o)
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AbstractSampleEncryptionBox that = (AbstractSampleEncryptionBox) o;
if (algorithmId != that.algorithmId) {
return false;
}
if (ivSize != that.ivSize) {
return false;
}
if (entries != null ? !entries.equals(that.entries) : that.entries != null) {
return false;
}
if (!Arrays.equals(kid, that.kid)) {
return false;
}
return true;
|
public int | getAlgorithmId()
return algorithmId;
|
public void | getBox(java.nio.channels.WritableByteChannel os)
super.getBox(os);
|
protected void | getContent(java.nio.ByteBuffer byteBuffer)
writeVersionAndFlags(byteBuffer);
if (isOverrideTrackEncryptionBoxParameters()) {
IsoTypeWriter.writeUInt24(byteBuffer, algorithmId);
IsoTypeWriter.writeUInt8(byteBuffer, ivSize);
byteBuffer.put(kid);
}
IsoTypeWriter.writeUInt32(byteBuffer, entries.size());
for (Entry entry : entries) {
if (isOverrideTrackEncryptionBoxParameters()) {
byte[] ivFull = new byte[ivSize];
System.arraycopy(entry.iv, 0, ivFull, ivSize - entry.iv.length, entry.iv.length);
byteBuffer.put(ivFull);
} else {
// just put the iv - i don't know any better
byteBuffer.put(entry.iv);
}
if (isSubSampleEncryption()) {
IsoTypeWriter.writeUInt16(byteBuffer, entry.pairs.size());
for (Entry.Pair pair : entry.pairs) {
IsoTypeWriter.writeUInt16(byteBuffer, pair.clear);
IsoTypeWriter.writeUInt32(byteBuffer, pair.encrypted);
}
}
}
|
protected long | getContentSize()
long contentSize = 4;
if (isOverrideTrackEncryptionBoxParameters()) {
contentSize += 4;
contentSize += kid.length;
}
contentSize += 4;
for (Entry entry : entries) {
contentSize += entry.getSize();
}
return contentSize;
|
public java.util.List | getEntries()
return entries;
|
public java.util.List | getEntrySizes()
List<Short> entrySizes = new ArrayList<Short>(entries.size());
for (Entry entry : entries) {
short size = (short) entry.iv.length;
if (isSubSampleEncryption()) {
size += 2; //numPairs
size += entry.pairs.size() * 6;
}
entrySizes.add(size);
}
return entrySizes;
|
public int | getIvSize()
return ivSize;
|
public byte[] | getKid()
return kid;
|
public int | getOffsetToFirstIV()
int offset = (getSize() > (1l << 32) ? 16 : 8);
offset += isOverrideTrackEncryptionBoxParameters() ? 20 : 0;
offset += 4; //num entries
return offset;
|
public int | getSampleCount()
return entries.size();
|
public int | hashCode()
int result = algorithmId;
result = 31 * result + ivSize;
result = 31 * result + (kid != null ? Arrays.hashCode(kid) : 0);
result = 31 * result + (entries != null ? entries.hashCode() : 0);
return result;
|
public boolean | isOverrideTrackEncryptionBoxParameters()
return (getFlags() & 0x1) > 0;
|
public boolean | isSubSampleEncryption()
return (getFlags() & 0x2) > 0;
|
public void | setAlgorithmId(int algorithmId)
this.algorithmId = algorithmId;
|
public void | setEntries(java.util.List entries)
this.entries = entries;
|
public void | setIvSize(int ivSize)
this.ivSize = ivSize;
|
public void | setKid(byte[] kid)
this.kid = kid;
|
public void | setOverrideTrackEncryptionBoxParameters(boolean b)
if (b) {
setFlags(getFlags() | 0x1);
} else {
setFlags(getFlags() & (0xffffff ^ 0x1));
}
|
public void | setSubSampleEncryption(boolean b)
if (b) {
setFlags(getFlags() | 0x2);
} else {
setFlags(getFlags() & (0xffffff ^ 0x2));
}
|