public CencEncryptingSampleList( SecretKey defaultCek, List<Sample> parent, List<CencSampleAuxiliaryDataFormat> auxiliaryDataFormats) { this(new RangeStartMap<Integer, SecretKey>(0, defaultCek), parent, auxiliaryDataFormats, "cenc"); }
public RangeStartMap(K k, V v) { this.put(k, v); }
groupEntries.addAll(keyRotation.keySet()); indexToKey = new RangeStartMap<Integer, SecretKey>(); int lastSampleGroupDescriptionIndex = -1; for (int i = 0; i < source.getSamples().size(); i++) { indexToKey.put(i, keys.get(defaultKeyId)); } else { if (groupEntries.get(index - 1).getKid() != null) { throw new RuntimeException("Key " + groupEntries.get(index - 1).getKid() + " was not supplied for decryption"); indexToKey.put(i, sk); } else { indexToKey.put(i, null); CencSampleAuxiliaryDataFormat e = new CencSampleAuxiliaryDataFormat(); this.cencSampleAuxiliaryData.add(e); if (indexToKey.get(i) != null) { byte[] iv = ivInt.toByteArray(); byte[] eightByteIv = new byte[]{0, 0, 0, 0, 0, 0, 0, 0};
public V remove(Object k) { if (!(k instanceof Comparable)) { return null; } Comparable<K> key = (Comparable<K>) k; if (isEmpty()) { return null; } Iterator<K> keys = base.keySet().iterator(); K a = keys.next(); do { if (keys.hasNext()) { if (key.compareTo(a) < 0) { a = keys.next(); } else { return base.remove(a); } } else { return base.remove(a); } } while (true); }
public V get(Object k) { if (!(k instanceof Comparable)) { return null; } Comparable<K> key = (Comparable<K>) k; if (isEmpty()) { return null; } Iterator<K> keys = base.keySet().iterator(); K a = keys.next(); do { if (keys.hasNext()) { if (key.compareTo(a) < 0) { a = keys.next(); } else { return base.get(a); } } else { return base.get(a); } } while (true); }
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; byte[] ppsBytes = toArray((ByteBuffer) data.rewind()); byte[] oldPpsSameId = ppsIdToPpsBytes.get(_pictureParameterSet.pic_parameter_set_id); if (oldPpsSameId != null && !Arrays.equals(oldPpsSameId, ppsBytes)) { 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(), ppsBytes); } ppsIdToPpsBytes.put(_pictureParameterSet.pic_parameter_set_id, ppsBytes); ppsIdToPps.put(_pictureParameterSet.pic_parameter_set_id, _pictureParameterSet); } }
@Override public Sample get(int index) { if (keys.get(index) != null) { Sample encSample = parent.get(index); final ByteBuffer encSampleBuffer = encSample.asByteBuffer(); final ByteBuffer decSampleBuffer = ByteBuffer.allocate(encSampleBuffer.limit()); final CencSampleAuxiliaryDataFormat sencEntry = sencInfo.get(index); Cipher cipher = getCipher(keys.get(index), sencEntry.iv); try { if (sencEntry.pairs != null && sencEntry.pairs.length > 0) {
public CencDecryptingSampleList(SecretKey secretKey, List<Sample> parent, List<CencSampleAuxiliaryDataFormat> sencInfo) { this(new RangeStartMap<Integer, SecretKey>(0, secretKey), parent, sencInfo, "cenc"); }
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; byte[] spsBytes = toArray((ByteBuffer) data.rewind()); byte[] oldSpsSameId = spsIdToSpsBytes.get(_seqParameterSet.seq_parameter_set_id); if (oldSpsSameId != null && !Arrays.equals(oldSpsSameId, spsBytes)) { throw new RuntimeException("OMG - I got two SPS with same ID but different settings!"); } else { if (oldSpsSameId != null) { seqParameterRangeMap.put(samples.size(), spsBytes); } spsIdToSpsBytes.put(_seqParameterSet.seq_parameter_set_id, spsBytes); spsIdToSps.put(_seqParameterSet.seq_parameter_set_id, _seqParameterSet); } }
if (index == 0) { indexToKey.put(i, keys.get(original.getDefaultKeyId())); } else { if (groupEntries.get(index - 1).isEncrypted()) { throw new RuntimeException("Key " + groupEntries.get(index - 1).getKid() + " was not supplied for decryption"); indexToKey.put(i, sk); } else { indexToKey.put(i, null);