if (keys.get(index) != null) { Sample encSample = parent.get(index); final ByteBuffer encSampleBuffer = encSample.asByteBuffer(); encSampleBuffer.rewind(); final ByteBuffer decSampleBuffer = ByteBuffer.allocate(encSampleBuffer.limit()); final CencSampleAuxiliaryDataFormat sencEntry = sencInfo.get(index); Cipher cipher = getCipher(keys.get(index), sencEntry.iv, encSample.getSampleEntry()); System.err.println("Decrypted sample " + index + " but still data remaining: " + encSample.getSize()); byte[] fullyEncryptedSample = new byte[encSampleBuffer.limit()]; encSampleBuffer.get(fullyEncryptedSample); String schemeType = getSchemeType(encSample.getSampleEntry()); if ("cbc1".equals(schemeType)) { int encryptedLength = fullyEncryptedSample.length / 16 * 16;
public ByteBuffer asByteBuffer() { int spsPpsSize = 0; for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { spsPpsSize += len + bytes.limit(); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { spsPpsSize += len + bytes.limit(); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { spsPpsSize += len + bytes.limit(); } ByteBuffer data = ByteBuffer.allocate(l2i(orignalSample.getSize()) + spsPpsSize); for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), data, len); data.put(bytes); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { IsoTypeWriterVariable.write(bytes.limit(), data, len); data.put(bytes); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), data, len); data.put(bytes); } data.put(orignalSample.asByteBuffer()); return (ByteBuffer) data.rewind(); } };
@Override public Sample get(final int index) { final Sample orignalSample = parentSamples.get(index); if (orignalSample.getSampleEntry().getType().equals("avc1") && Arrays.binarySearch(Avc1ToAvc3TrackImpl.this.getSyncSamples(), index + 1) >= 0) { final AvcConfigurationBox avcC = orignalSample.getSampleEntry().getBoxes(AvcConfigurationBox.class).get(0); final int len = avcC.getLengthSizeMinusOne() + 1; final ByteBuffer buf = ByteBuffer.allocate(len); final SampleEntry se = avc1toavc3.get(orignalSample.getSampleEntry());
public long getSize() { return clearSample.getSize(); }
public static void main(String[] args) throws IOException { Movie movie = MovieCreator.build(DumpAmf0TrackToPropertyFile.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/example.f4v"); for (Track track : movie.getTracks()) { if (track.getHandler().equals("data") ) { long time = 0; Iterator<Sample> samples = track.getSamples().iterator(); Properties properties = new Properties(); File f = File.createTempFile(DumpAmf0TrackToPropertyFile.class.getSimpleName(), "" + track.getTrackMetaData().getTrackId()); for (long decodingTime : track.getSampleDurations()) { ByteBuffer sample = samples.next().asByteBuffer(); byte[] sampleBytes = new byte[sample.limit()]; sample.reset(); sample.get(sampleBytes); properties.put("" + time, new String(Base64.encodeBase64(sampleBytes, false, false))); time += decodingTime; } FileOutputStream fos = new FileOutputStream(f); System.err.println(properties); properties.store(fos, ""); } } }
for (int i = 0; i < sourceSamples.size(); i++) { Sample origSample = sourceSamples.get(i); int nalLengthSize = nalLengthSizes.get(origSample.getSampleEntry()); CencSampleAuxiliaryDataFormat e = new CencSampleAuxiliaryDataFormat(); this.cencSampleAuxiliaryData.add(e); UUID keyId = indexToKeyId.get(i); if (keyId != null) { SampleEntry correct = tx.transform(origSample.getSampleEntry(), encryptionAlgo, indexToKeyId.get(i)); sampleEntries.add(correct); if (previousSampleEntry != correct) { ByteBuffer sample = (ByteBuffer) origSample.asByteBuffer().rewind(); } else { SampleEntry correct = origSample.getSampleEntry(); sampleEntries.add(correct); if (previousSampleEntry != correct) {
public void writeTo(WritableByteChannel channel) throws IOException { for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), (ByteBuffer) buf.rewind(), len); channel.write((ByteBuffer) buf.rewind()); channel.write(bytes); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { IsoTypeWriterVariable.write(bytes.limit(), (ByteBuffer) buf.rewind(), len); channel.write((ByteBuffer) buf.rewind()); channel.write((bytes)); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), (ByteBuffer) buf.rewind(), len); channel.write((ByteBuffer) buf.rewind()); channel.write((bytes)); } orignalSample.writeTo(channel); }
DecoderSpecificInfo decoderSpecificInfo = new DecoderSpecificInfo(); Sample s = createSampleObject(esdsStuff); byte[] data = new byte[l2i(s.getSize())]; s.asByteBuffer().get(data); decoderSpecificInfo.setData(data); decoderConfigDescriptor.setDecoderSpecificInfo(decoderSpecificInfo);
protected void createStsc(Track track, Map<Track, int[]> chunks, SampleTableBox stbl) { int[] tracksChunkSizes = chunks.get(track); SampleToChunkBox stsc = new SampleToChunkBox(); stsc.setEntries(new LinkedList<SampleToChunkBox.Entry>()); long lastChunkSize = Integer.MIN_VALUE; // to be sure the first chunks hasn't got the same size long lastSampleDescriptionIndex = Integer.MIN_VALUE; List<Sample> samples = track.getSamples(); int currentSampleIndex = 0; List<SampleEntry> sampleEntries = track.getSampleEntries(); for (int i = 0; i < tracksChunkSizes.length; i++) { Sample sample = samples.get(currentSampleIndex); int currentSampleDescriptionIndex = sampleEntries.indexOf(sample.getSampleEntry()) + 1; // one base if (lastChunkSize != tracksChunkSizes[i] || lastSampleDescriptionIndex != currentSampleDescriptionIndex) { stsc.getEntries().add(new SampleToChunkBox.Entry(i + 1, tracksChunkSizes[i], currentSampleDescriptionIndex)); lastChunkSize = tracksChunkSizes[i]; lastSampleDescriptionIndex = currentSampleDescriptionIndex; } currentSampleIndex += tracksChunkSizes[i]; } stbl.addBox(stsc); }
/** * Gets the sizes of a sequence of samples. * * @param startSample low endpoint (inclusive) of the sample sequence * @param endSample high endpoint (exclusive) of the sample sequence * @param track source of the samples * @param sequenceNumber the fragment index of the requested list of samples * @return the sample sizes in the given interval */ protected long[] getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber) { List<Sample> samples = getSamples(startSample, endSample, track); long[] sampleSizes = new long[samples.size()]; for (int i = 0; i < sampleSizes.length; i++) { sampleSizes[i] = samples.get(i).getSize(); } return sampleSizes; }
ByteBuffer bb = sample.asByteBuffer(); while (bb.remaining() > 0) { int length = (int) IsoTypeReaderVariable.read(bb, hevc.getLengthSizeMinusOne() + 1);
for (int i = 0; i < sourceSamples.size(); i++) { Sample origSample = sourceSamples.get(i); int nalLengthSize = nalLengthSizes.get(origSample.getSampleEntry()); CencSampleAuxiliaryDataFormat e = new CencSampleAuxiliaryDataFormat(); this.cencSampleAuxiliaryData.add(e); UUID keyId = indexToKeyId.get(i); if (keyId != null) { SampleEntry correct = tx.transform(origSample.getSampleEntry(), encryptionAlgo, indexToKeyId.get(i)); sampleEntries.add(correct); if (previousSampleEntry != correct) { ByteBuffer sample = (ByteBuffer) origSample.asByteBuffer().rewind(); } else { SampleEntry correct = origSample.getSampleEntry(); sampleEntries.add(correct); if (previousSampleEntry != correct) {
public void writeTo(WritableByteChannel channel) throws IOException { for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), (ByteBuffer) buf.rewind(), len); channel.write((ByteBuffer) buf.rewind()); channel.write(bytes); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { IsoTypeWriterVariable.write(bytes.limit(), (ByteBuffer) buf.rewind(), len); channel.write((ByteBuffer) buf.rewind()); channel.write((bytes)); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), (ByteBuffer) buf.rewind(), len); channel.write((ByteBuffer) buf.rewind()); channel.write((bytes)); } orignalSample.writeTo(channel); }
if (keys.get(index) != null) { Sample encSample = parent.get(index); final ByteBuffer encSampleBuffer = encSample.asByteBuffer(); encSampleBuffer.rewind(); final ByteBuffer decSampleBuffer = ByteBuffer.allocate(encSampleBuffer.limit()); final CencSampleAuxiliaryDataFormat sencEntry = sencInfo.get(index); Cipher cipher = getCipher(keys.get(index), sencEntry.iv, encSample.getSampleEntry()); System.err.println("Decrypted sample " + index + " but still data remaining: " + encSample.getSize()); byte[] fullyEncryptedSample = new byte[encSampleBuffer.limit()]; encSampleBuffer.get(fullyEncryptedSample); String schemeType = getSchemeType(encSample.getSampleEntry()); if ("cbc1".equals(schemeType)) { int encryptedLength = fullyEncryptedSample.length / 16 * 16;
public ByteBuffer asByteBuffer() { int spsPpsSize = 0; for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { spsPpsSize += len + bytes.limit(); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { spsPpsSize += len + bytes.limit(); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { spsPpsSize += len + bytes.limit(); } ByteBuffer data = ByteBuffer.allocate(l2i(orignalSample.getSize()) + spsPpsSize); for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), data, len); data.put(bytes); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { IsoTypeWriterVariable.write(bytes.limit(), data, len); data.put(bytes); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { IsoTypeWriterVariable.write(bytes.limit(), data, len); data.put(bytes); } data.put(orignalSample.asByteBuffer()); return (ByteBuffer) data.rewind(); } };
public ReplaceSampleTrack(Track origTrack, long sampleNumber, ByteBuffer content) { super("replace(" + origTrack.getName() + ")"); this.origTrack = origTrack; this.sampleNumber = sampleNumber; this.sampleContent = new SampleImpl(content, this.origTrack.getSamples().get(l2i(sampleNumber)).getSampleEntry()); this.samples = new ReplaceASingleEntryList(); }
public long getSize() { int spsPpsSize = 0; for (ByteBuffer bytes : avcC.getSequenceParameterSets()) { spsPpsSize += len + bytes.limit(); } for (ByteBuffer bytes : avcC.getSequenceParameterSetExts()) { spsPpsSize += len + bytes.limit(); } for (ByteBuffer bytes : avcC.getPictureParameterSets()) { spsPpsSize += len + bytes.limit(); } return orignalSample.getSize() + spsPpsSize; }
public ByteBuffer asByteBuffer() { ByteBuffer sample = (ByteBuffer) clearSample.asByteBuffer().rewind(); ByteBuffer encSample = ByteBuffer.allocate(sample.limit());