public RangeStartMap(K k, V v) { this.put(k, v); }
private void handlePPS(ByteBuffer data) throws IOException { InputStream is = new ByteBufferBackedInputStream(data); is.read(); PictureParameterSet _pictureParameterSet = PictureParameterSet.read(is); if (firstPictureParameterSet == null) { firstPictureParameterSet = _pictureParameterSet; } currentPictureParameterSet = _pictureParameterSet; ByteBuffer oldPpsSameId = ppsIdToPpsBytes.get(_pictureParameterSet.pic_parameter_set_id); data.rewind(); if (oldPpsSameId != null && !oldPpsSameId.equals(data)) { throw new RuntimeException("OMG - I got two SPS with same ID but different settings! (AVC3 is the solution)"); } else { if (oldPpsSameId == null) { pictureParameterRangeMap.put(samples.size(), data); } ppsIdToPpsBytes.put(_pictureParameterSet.pic_parameter_set_id, data); ppsIdToPps.put(_pictureParameterSet.pic_parameter_set_id, _pictureParameterSet); } }
private void handleSPS(ByteBuffer data) throws IOException { InputStream spsInputStream = cleanBuffer(new ByteBufferBackedInputStream(data)); spsInputStream.read(); SeqParameterSet _seqParameterSet = SeqParameterSet.read(spsInputStream); if (firstSeqParameterSet == null) { firstSeqParameterSet = _seqParameterSet; configureFramerate(); } currentSeqParameterSet = _seqParameterSet; data.rewind(); ByteBuffer oldSpsSameId = spsIdToSpsBytes.get(_seqParameterSet.seq_parameter_set_id); if (oldSpsSameId != null && !oldSpsSameId.equals(data)) { throw new RuntimeException("OMG - I got two SPS with same ID but different settings!"); } else { if (oldSpsSameId != null) { seqParameterRangeMap.put(samples.size(), data); } spsIdToSpsBytes.put(_seqParameterSet.seq_parameter_set_id, data); spsIdToSps.put(_seqParameterSet.seq_parameter_set_id, _seqParameterSet); } }
private void init(Map<UUID, SecretKey> keys) { CencDecryptingSampleEntryTransformer tx = new CencDecryptingSampleEntryTransformer(); List<Sample> encSamples = original.getSamples(); RangeStartMap<Integer, SecretKey> indexToKey = new RangeStartMap<>(); RangeStartMap<Integer, SampleEntry> indexToSampleEntry = new RangeStartMap<>(); SampleEntry previousSampleEntry = null; for (int i = 0; i < encSamples.size(); i++) { Sample encSample = encSamples.get(i); SampleEntry current = encSample.getSampleEntry(); sampleEntries.add(tx.transform(encSample.getSampleEntry())); if (previousSampleEntry != current) { indexToSampleEntry.put(i, current); TrackEncryptionBox tenc = Path.getPath((Container) encSample.getSampleEntry(), "sinf[0]/schi[0]/tenc[0]"); if (tenc != null) { indexToKey.put(i, keys.get(tenc.getDefault_KID())); } else { indexToKey.put(i, null); } } previousSampleEntry = current; } samples = new CencDecryptingSampleList(indexToKey, indexToSampleEntry, encSamples, original.getSampleEncryptionEntries()); }
sampleEntries.add(correct); if (previousSampleEntry != correct) { indexToSampleEntry.put(i, correct); indexToKey.put(i, new KeyIdKeyPair(keyId, keys.get(indexToKeyId.get(i)))); sampleEntries.add(correct); if (previousSampleEntry != correct) { indexToSampleEntry.put(i, correct); indexToKey.put(i, null);
public RangeStartMap(K k, V v) { this.put(k, v); }
private void handlePPS(ByteBuffer data) throws IOException { InputStream is = new ByteBufferBackedInputStream(data); is.read(); PictureParameterSet _pictureParameterSet = PictureParameterSet.read(is); if (firstPictureParameterSet == null) { firstPictureParameterSet = _pictureParameterSet; } currentPictureParameterSet = _pictureParameterSet; ByteBuffer oldPpsSameId = ppsIdToPpsBytes.get(_pictureParameterSet.pic_parameter_set_id); data.rewind(); if (oldPpsSameId != null && !oldPpsSameId.equals(data)) { throw new RuntimeException("OMG - I got two SPS with same ID but different settings! (AVC3 is the solution)"); } else { if (oldPpsSameId == null) { pictureParameterRangeMap.put(samples.size(), data); } ppsIdToPpsBytes.put(_pictureParameterSet.pic_parameter_set_id, data); ppsIdToPps.put(_pictureParameterSet.pic_parameter_set_id, _pictureParameterSet); } }
private void handleSPS(ByteBuffer data) throws IOException { InputStream spsInputStream = cleanBuffer(new ByteBufferBackedInputStream(data)); spsInputStream.read(); SeqParameterSet _seqParameterSet = SeqParameterSet.read(spsInputStream); if (firstSeqParameterSet == null) { firstSeqParameterSet = _seqParameterSet; configureFramerate(); } currentSeqParameterSet = _seqParameterSet; data.rewind(); ByteBuffer oldSpsSameId = spsIdToSpsBytes.get(_seqParameterSet.seq_parameter_set_id); if (oldSpsSameId != null && !oldSpsSameId.equals(data)) { throw new RuntimeException("OMG - I got two SPS with same ID but different settings!"); } else { if (oldSpsSameId != null) { seqParameterRangeMap.put(samples.size(), data); } spsIdToSpsBytes.put(_seqParameterSet.seq_parameter_set_id, data); spsIdToSps.put(_seqParameterSet.seq_parameter_set_id, _seqParameterSet); } }
private Track encryptIfNeeded(Track in, long encStartSample) { if (in.getHandler().equals("soun")) { if (audioKeyId != null) { RangeStartMap<Integer, UUID> indexToKeyId = new RangeStartMap<>(0, null); indexToKeyId.put(l2i(encStartSample - 1), audioKeyId); Map<UUID, SecretKey> keys = Collections.singletonMap(audioKeyId, audioKey); return new CencEncryptingTrackImpl(in, indexToKeyId, keys, "cenc", false, false); } else { return in; } } else if (in.getHandler().equals("vide")) { if (videoKeyId != null) { RangeStartMap<Integer, UUID> indexToKeyId = new RangeStartMap<>(0, null); indexToKeyId.put(l2i(encStartSample - 1), videoKeyId); Map<UUID, SecretKey> keys = Collections.singletonMap(videoKeyId, videoKey); return new CencEncryptingTrackImpl(in, indexToKeyId, keys, "cenc", false, false); } else { return in; } } else { return in; } }
private void init(Map<UUID, SecretKey> keys) { CencDecryptingSampleEntryTransformer tx = new CencDecryptingSampleEntryTransformer(); List<Sample> encSamples = original.getSamples(); RangeStartMap<Integer, SecretKey> indexToKey = new RangeStartMap<>(); RangeStartMap<Integer, SampleEntry> indexToSampleEntry = new RangeStartMap<>(); SampleEntry previousSampleEntry = null; for (int i = 0; i < encSamples.size(); i++) { Sample encSample = encSamples.get(i); SampleEntry current = encSample.getSampleEntry(); sampleEntries.add(tx.transform(encSample.getSampleEntry())); if (previousSampleEntry != current) { indexToSampleEntry.put(i, current); TrackEncryptionBox tenc = Path.getPath((Container) encSample.getSampleEntry(), "sinf[0]/schi[0]/tenc[0]"); if (tenc != null) { indexToKey.put(i, keys.get(tenc.getDefault_KID())); } else { indexToKey.put(i, null); } } previousSampleEntry = current; } samples = new CencDecryptingSampleList(indexToKey, indexToSampleEntry, encSamples, original.getSampleEncryptionEntries()); }
sampleEntries.add(correct); if (previousSampleEntry != correct) { indexToSampleEntry.put(i, correct); indexToKey.put(i, new KeyIdKeyPair(keyId, keys.get(indexToKeyId.get(i)))); sampleEntries.add(correct); if (previousSampleEntry != correct) { indexToSampleEntry.put(i, correct); indexToKey.put(i, null);