protected void createSaiz(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent) { SampleEntry se = track.getSampleEntries().get(l2i(parent.getTrackFragmentHeaderBox().getSampleDescriptionIndex()-1)); TrackEncryptionBox tenc = Path.getPath((Container) se, "sinf[0]/schi[0]/tenc[0]"); SampleAuxiliaryInformationSizesBox saiz = new SampleAuxiliaryInformationSizesBox(); saiz.setAuxInfoType("cenc"); saiz.setFlags(1); if (track.hasSubSampleEncryption()) { short[] sizes = new short[l2i(endSample - startSample)]; List<CencSampleAuxiliaryDataFormat> auxs = track.getSampleEncryptionEntries().subList(l2i(startSample - 1), l2i(endSample - 1)); for (int i = 0; i < sizes.length; i++) { sizes[i] = (short) auxs.get(i).getSize(); } saiz.setSampleInfoSizes(sizes); } else { assert tenc != null; saiz.setDefaultSampleInfoSize(tenc.getDefaultIvSize()); saiz.setSampleCount(l2i(endSample - startSample)); } parent.addBox(saiz); }
public short getSize(int index) { if (getDefaultSampleInfoSize() == 0) { return sampleInfoSizes[index]; } else { return defaultSampleInfoSize; } }
public FindSaioSaizPair invoke() { List<SampleAuxiliaryInformationSizesBox> saizs = container.getBoxes(SampleAuxiliaryInformationSizesBox.class); List<SampleAuxiliaryInformationOffsetsBox> saios = container.getBoxes(SampleAuxiliaryInformationOffsetsBox.class); assert saizs.size() == saios.size(); saiz = null; saio = null; for (int i = 0; i < saizs.size(); i++) { if (saiz == null && (saizs.get(i).getAuxInfoType() == null) || "cenc".equals(saizs.get(i).getAuxInfoType())) { saiz = saizs.get(i); } else if (saiz != null && saiz.getAuxInfoType() == null && "cenc".equals(saizs.get(i).getAuxInfoType())) { saiz = saizs.get(i); } else { throw new RuntimeException("Are there two cenc labeled saiz?"); } if (saio == null && (saios.get(i).getAuxInfoType() == null) || "cenc".equals(saios.get(i).getAuxInfoType())) { saio = saios.get(i); } else if (saio != null && saio.getAuxInfoType() == null && "cenc".equals(saios.get(i).getAuxInfoType())) { saio = saios.get(i); } else { throw new RuntimeException("Are there two cenc labeled saio?"); } } return this; } }
@Override protected void getContent(ByteBuffer byteBuffer) { writeVersionAndFlags(byteBuffer); if ((getFlags() & 1) == 1) { byteBuffer.put(IsoFile.fourCCtoBytes(auxInfoType)); byteBuffer.put(IsoFile.fourCCtoBytes(auxInfoTypeParameter)); } IsoTypeWriter.writeUInt8(byteBuffer, defaultSampleInfoSize); if (defaultSampleInfoSize == 0) { IsoTypeWriter.writeUInt32(byteBuffer, sampleInfoSizes.length); for (short sampleInfoSize : sampleInfoSizes) { IsoTypeWriter.writeUInt8(byteBuffer, sampleInfoSize); } } else { IsoTypeWriter.writeUInt32(byteBuffer, sampleCount); } }
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); if ((getFlags() & 1) == 1) { auxInfoType = IsoTypeReader.read4cc(content); auxInfoTypeParameter = IsoTypeReader.read4cc(content); } defaultSampleInfoSize = (short) IsoTypeReader.readUInt8(content); sampleCount = CastUtils.l2i(IsoTypeReader.readUInt32(content)); if (defaultSampleInfoSize == 0) { sampleInfoSizes = new short[sampleCount]; for (int i = 0; i < sampleCount; i++) { sampleInfoSizes[i] = (short) IsoTypeReader.readUInt8(content); } } }
length += saiz.getSize(j); int auxInfoSize = saiz.getSize(j); if (tenc!=null) { sampleEncryptionEntries.add( long offset = saio.getOffsets()[0]; int sizeInTotal = 0; if (saiz.getDefaultSampleInfoSize() > 0) { sizeInTotal += saiz.getSampleCount() * saiz.getDefaultSampleInfoSize(); } else { for (int i = 0; i < saiz.getSampleCount(); i++) { sizeInTotal += saiz.getSampleInfoSizes()[i]; for (int i = 0; i < saiz.getSampleCount(); i++) { long auxInfoSize = saiz.getSize(i); SampleEntry _se = samples.get(i).getSampleEntry(); if (se != _se) { long offset = saio.getOffsets()[i]; long size = 0; if (saiz.getDefaultSampleInfoSize() > 0) { size += saiz.getSampleCount() * chunkSizes[i]; } else { for (int j = 0; j < chunkSizes[i]; j++) { size += saiz.getSize(currentSampleNo + j); long auxInfoSize = saiz.getSize(currentSampleNo + j); SampleEntry _se = samples.get(currentSampleNo + j).getSampleEntry();
@Override protected long getContentSize() { int size = 4; if ((getFlags() & 1) == 1) { size += 8; } size += 5; size += defaultSampleInfoSize == 0 ? sampleInfoSizes.length : 0; return size; }
length += saiz.getSize(j); int auxInfoSize = saiz.getSize(j); if (tenc!=null) { sampleEncryptionEntries.add( long offset = saio.getOffsets()[0]; int sizeInTotal = 0; if (saiz.getDefaultSampleInfoSize() > 0) { sizeInTotal += saiz.getSampleCount() * saiz.getDefaultSampleInfoSize(); } else { for (int i = 0; i < saiz.getSampleCount(); i++) { sizeInTotal += saiz.getSampleInfoSizes()[i]; for (int i = 0; i < saiz.getSampleCount(); i++) { long auxInfoSize = saiz.getSize(i); SampleEntry _se = samples.get(i).getSampleEntry(); if (se != _se) { long offset = saio.getOffsets()[i]; long size = 0; if (saiz.getDefaultSampleInfoSize() > 0) { size += saiz.getSampleCount() * chunkSizes[i]; } else { for (int j = 0; j < chunkSizes[i]; j++) { size += saiz.getSize(currentSampleNo + j); long auxInfoSize = saiz.getSize(currentSampleNo + j); SampleEntry _se = samples.get(currentSampleNo + j).getSampleEntry();
@Override public void _parseDetails(ByteBuffer content) { parseVersionAndFlags(content); if ((getFlags() & 1) == 1) { auxInfoType = IsoTypeReader.read4cc(content); auxInfoTypeParameter = IsoTypeReader.read4cc(content); } defaultSampleInfoSize = (short) IsoTypeReader.readUInt8(content); sampleCount = CastUtils.l2i(IsoTypeReader.readUInt32(content)); if (defaultSampleInfoSize == 0) { sampleInfoSizes = new short[sampleCount]; for (int i = 0; i < sampleCount; i++) { sampleInfoSizes[i] = (short) IsoTypeReader.readUInt8(content); } } }
@Override protected void getContent(ByteBuffer byteBuffer) { writeVersionAndFlags(byteBuffer); if ((getFlags() & 1) == 1) { byteBuffer.put(IsoFile.fourCCtoBytes(auxInfoType)); byteBuffer.put(IsoFile.fourCCtoBytes(auxInfoTypeParameter)); } IsoTypeWriter.writeUInt8(byteBuffer, defaultSampleInfoSize); if (defaultSampleInfoSize == 0) { IsoTypeWriter.writeUInt32(byteBuffer, sampleInfoSizes.length); for (short sampleInfoSize : sampleInfoSizes) { IsoTypeWriter.writeUInt8(byteBuffer, sampleInfoSize); } } else { IsoTypeWriter.writeUInt32(byteBuffer, sampleCount); } }
@Override protected long getContentSize() { int size = 4; if ((getFlags() & 1) == 1) { size += 8; } size += 5; size += defaultSampleInfoSize == 0 ? sampleInfoSizes.length : 0; return size; }
protected void createCencBoxes(CencEncryptedTrack track, SampleTableBox stbl, int[] chunkSizes) { SampleAuxiliaryInformationSizesBox saiz = new SampleAuxiliaryInformationSizesBox(); saiz.setAuxInfoType("cenc"); saiz.setFlags(1); List<CencSampleAuxiliaryDataFormat> sampleEncryptionEntries = track.getSampleEncryptionEntries(); if (track.hasSubSampleEncryption()) { sizes[i] = (short) sampleEncryptionEntries.get(i).getSize(); saiz.setSampleInfoSizes(sizes); } else { saiz.setDefaultSampleInfoSize(8); // 8 bytes iv saiz.setSampleCount(track.getSamples().size());
public short getSize(int index) { if (getDefaultSampleInfoSize() == 0) { return sampleInfoSizes[index]; } else { return defaultSampleInfoSize; } }
public FindSaioSaizPair invoke() { List<SampleAuxiliaryInformationSizesBox> saizs = container.getBoxes(SampleAuxiliaryInformationSizesBox.class); List<SampleAuxiliaryInformationOffsetsBox> saios = container.getBoxes(SampleAuxiliaryInformationOffsetsBox.class); assert saizs.size() == saios.size(); saiz = null; saio = null; for (int i = 0; i < saizs.size(); i++) { if (saiz == null && (saizs.get(i).getAuxInfoType() == null) || "cenc".equals(saizs.get(i).getAuxInfoType())) { saiz = saizs.get(i); } else if (saiz != null && saiz.getAuxInfoType() == null && "cenc".equals(saizs.get(i).getAuxInfoType())) { saiz = saizs.get(i); } else { throw new RuntimeException("Are there two cenc labeled saiz?"); } if (saio == null && (saios.get(i).getAuxInfoType() == null) || "cenc".equals(saios.get(i).getAuxInfoType())) { saio = saios.get(i); } else if (saio != null && saio.getAuxInfoType() == null && "cenc".equals(saios.get(i).getAuxInfoType())) { saio = saios.get(i); } else { throw new RuntimeException("Are there two cenc labeled saio?"); } } return this; } }
protected void createSaiz(long startSample, long endSample, CencEncryptedTrack track, TrackFragmentBox parent) { TrackEncryptionBox tenc = Path.getPath((Container) track.getSamples().get(l2i(startSample-1)).getSampleEntry(), "sinf[0]/schi[0]/tenc[0]"); if (tenc != null) { SampleAuxiliaryInformationSizesBox saiz = new SampleAuxiliaryInformationSizesBox(); saiz.setAuxInfoType("cenc"); saiz.setFlags(1); if (track.hasSubSampleEncryption()) { short[] sizes = new short[l2i(endSample - startSample)]; List<CencSampleAuxiliaryDataFormat> auxs = track.getSampleEncryptionEntries().subList(l2i(startSample - 1), l2i(endSample - 1)); for (int i = 0; i < sizes.length; i++) { sizes[i] = (short) auxs.get(i).getSize(); } saiz.setSampleInfoSizes(sizes); } else { saiz.setDefaultSampleInfoSize(tenc.getDefaultIvSize()); saiz.setSampleCount(l2i(endSample - startSample)); } parent.addBox(saiz); } }
protected void createSaiz(long startSample, long endSample, CencEncryptedTrack track, int sequenceNumber, TrackFragmentBox parent) { SampleEntry se = track.getSampleEntries().get(l2i(parent.getTrackFragmentHeaderBox().getSampleDescriptionIndex()-1)); TrackEncryptionBox tenc = Path.getPath((Container) se, "sinf[0]/schi[0]/tenc[0]"); SampleAuxiliaryInformationSizesBox saiz = new SampleAuxiliaryInformationSizesBox(); saiz.setAuxInfoType("cenc"); saiz.setFlags(1); if (track.hasSubSampleEncryption()) { short[] sizes = new short[l2i(endSample - startSample)]; List<CencSampleAuxiliaryDataFormat> auxs = track.getSampleEncryptionEntries().subList(l2i(startSample - 1), l2i(endSample - 1)); for (int i = 0; i < sizes.length; i++) { sizes[i] = (short) auxs.get(i).getSize(); } saiz.setSampleInfoSizes(sizes); } else { assert tenc != null; saiz.setDefaultSampleInfoSize(tenc.getDefaultIvSize()); saiz.setSampleCount(l2i(endSample - startSample)); } parent.addBox(saiz); }
protected void createCencBoxes(CencEncryptedTrack track, SampleTableBox stbl, int[] chunkSizes) { SampleAuxiliaryInformationSizesBox saiz = new SampleAuxiliaryInformationSizesBox(); saiz.setAuxInfoType("cenc"); saiz.setFlags(1); List<CencSampleAuxiliaryDataFormat> sampleEncryptionEntries = track.getSampleEncryptionEntries(); if (track.hasSubSampleEncryption()) { sizes[i] = (short) sampleEncryptionEntries.get(i).getSize(); saiz.setSampleInfoSizes(sizes); } else { saiz.setDefaultSampleInfoSize(8); // 8 bytes iv saiz.setSampleCount(track.getSamples().size());