mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Merge pull request #354 from canatella/aes-iv-fix
Fix AES decryption of HLS streams.
This commit is contained in:
commit
fabd470550
1 changed files with 9 additions and 4 deletions
|
|
@ -233,9 +233,6 @@ public final class HlsPlaylistParser implements NetworkLoadable.Parser<HlsPlayli
|
||||||
segmentEncryptionKeyUri = HlsParserUtil.parseStringAttr(line, URI_ATTR_REGEX,
|
segmentEncryptionKeyUri = HlsParserUtil.parseStringAttr(line, URI_ATTR_REGEX,
|
||||||
URI_ATTR);
|
URI_ATTR);
|
||||||
segmentEncryptionIV = HlsParserUtil.parseOptionalStringAttr(line, IV_ATTR_REGEX);
|
segmentEncryptionIV = HlsParserUtil.parseOptionalStringAttr(line, IV_ATTR_REGEX);
|
||||||
if (segmentEncryptionIV == null) {
|
|
||||||
segmentEncryptionIV = Integer.toHexString(segmentMediaSequence);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (line.startsWith(BYTERANGE_TAG)) {
|
} else if (line.startsWith(BYTERANGE_TAG)) {
|
||||||
String byteRange = HlsParserUtil.parseStringAttr(line, BYTERANGE_REGEX, BYTERANGE_TAG);
|
String byteRange = HlsParserUtil.parseStringAttr(line, BYTERANGE_REGEX, BYTERANGE_TAG);
|
||||||
|
|
@ -247,13 +244,21 @@ public final class HlsPlaylistParser implements NetworkLoadable.Parser<HlsPlayli
|
||||||
} else if (line.equals(DISCONTINUITY_TAG)) {
|
} else if (line.equals(DISCONTINUITY_TAG)) {
|
||||||
segmentDiscontinuity = true;
|
segmentDiscontinuity = true;
|
||||||
} else if (!line.startsWith("#")) {
|
} else if (!line.startsWith("#")) {
|
||||||
|
String thisSegmentEncryptionIV;
|
||||||
|
if (segmentEncryptionIV != null) {
|
||||||
|
thisSegmentEncryptionIV = segmentEncryptionIV;
|
||||||
|
} else if (HlsMediaPlaylist.ENCRYPTION_METHOD_AES_128.equals(segmentEncryptionMethod)) {
|
||||||
|
thisSegmentEncryptionIV = Integer.toHexString(segmentMediaSequence);
|
||||||
|
} else {
|
||||||
|
thisSegmentEncryptionIV = null;
|
||||||
|
}
|
||||||
segmentMediaSequence++;
|
segmentMediaSequence++;
|
||||||
if (segmentByterangeLength == C.LENGTH_UNBOUNDED) {
|
if (segmentByterangeLength == C.LENGTH_UNBOUNDED) {
|
||||||
segmentByterangeOffset = 0;
|
segmentByterangeOffset = 0;
|
||||||
}
|
}
|
||||||
segments.add(new Segment(line, segmentDurationSecs, segmentDiscontinuity,
|
segments.add(new Segment(line, segmentDurationSecs, segmentDiscontinuity,
|
||||||
segmentStartTimeUs, segmentEncryptionMethod, segmentEncryptionKeyUri,
|
segmentStartTimeUs, segmentEncryptionMethod, segmentEncryptionKeyUri,
|
||||||
segmentEncryptionIV, segmentByterangeOffset, segmentByterangeLength));
|
thisSegmentEncryptionIV, segmentByterangeOffset, segmentByterangeLength));
|
||||||
segmentStartTimeUs += (long) (segmentDurationSecs * C.MICROS_PER_SECOND);
|
segmentStartTimeUs += (long) (segmentDurationSecs * C.MICROS_PER_SECOND);
|
||||||
segmentDiscontinuity = false;
|
segmentDiscontinuity = false;
|
||||||
segmentDurationSecs = 0.0;
|
segmentDurationSecs = 0.0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue