mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00
Fix HLS encryption method detection
Issue:#4145 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193494319
This commit is contained in:
parent
cdb13dd548
commit
d2c6871ce6
@ -66,8 +66,11 @@
|
||||
([#4022][https://github.com/google/ExoPlayer/issues/4022]).
|
||||
* Fix handling of 307/308 redirects when making license requests
|
||||
([#4108](https://github.com/google/ExoPlayer/issues/4108)).
|
||||
* HLS: Fix playlist loading error propagation when the current selection does
|
||||
not include all of the playlist's variants.
|
||||
* HLS:
|
||||
* Fix playlist loading error propagation when the current selection does
|
||||
not include all of the playlist's variants.
|
||||
* Fix SAMPLE-AES-CENC and SAMPLE-AES-CTR EXT-X-KEY methods
|
||||
([#4145](https://github.com/google/ExoPlayer/issues/4145)).
|
||||
* Fix ClearKey decryption error if the key contains a forward slash
|
||||
([#4075](https://github.com/google/ExoPlayer/issues/4075)).
|
||||
* Fix crash when switching surface on Huawei P9 Lite
|
||||
|
@ -123,7 +123,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
+ METHOD_SAMPLE_AES_CENC
|
||||
+ "|"
|
||||
+ METHOD_SAMPLE_AES_CTR
|
||||
+ ")");
|
||||
+ ")"
|
||||
+ "\\s*(,|$)");
|
||||
private static final Pattern REGEX_KEYFORMAT = Pattern.compile("KEYFORMAT=\"(.+?)\"");
|
||||
private static final Pattern REGEX_URI = Pattern.compile("URI=\"(.+?)\"");
|
||||
private static final Pattern REGEX_IV = Pattern.compile("IV=([^,.*]+)");
|
||||
|
@ -140,6 +140,78 @@ public class HlsMediaPlaylistParserTest {
|
||||
assertThat(segment.url).isEqualTo("https://priv.example.com/fileSequence2683.ts");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseSampleAesMethod() throws Exception {
|
||||
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
||||
String playlistString =
|
||||
"#EXTM3U\n"
|
||||
+ "#EXT-X-MEDIA-SEQUENCE:0\n"
|
||||
+ "#EXTINF:8,\n"
|
||||
+ "https://priv.example.com/1.ts\n"
|
||||
+ "\n"
|
||||
+ "#EXT-X-KEY:METHOD=SAMPLE-AES,URI="
|
||||
+ "\"data:text/plain;base64,VGhpcyBpcyBhbiBlYXN0ZXIgZWdn\","
|
||||
+ "IV=0x9358382AEB449EE23C3D809DA0B9CCD3,KEYFORMATVERSIONS=\"1\","
|
||||
+ "KEYFORMAT=\"com.widevine\",IV=0x1566B\n"
|
||||
+ "#EXTINF:8,\n"
|
||||
+ "https://priv.example.com/2.ts\n"
|
||||
+ "#EXT-X-ENDLIST\n";
|
||||
InputStream inputStream =
|
||||
new ByteArrayInputStream(playlistString.getBytes(Charset.forName(C.UTF8_NAME)));
|
||||
HlsMediaPlaylist playlist =
|
||||
(HlsMediaPlaylist) new HlsPlaylistParser().parse(playlistUri, inputStream);
|
||||
assertThat(playlist.drmInitData.schemeType).isEqualTo(C.CENC_TYPE_cbcs);
|
||||
assertThat(playlist.drmInitData.get(0).matches(C.WIDEVINE_UUID)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseSampleAesCencMethod() throws Exception {
|
||||
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
||||
String playlistString =
|
||||
"#EXTM3U\n"
|
||||
+ "#EXT-X-MEDIA-SEQUENCE:0\n"
|
||||
+ "#EXTINF:8,\n"
|
||||
+ "https://priv.example.com/1.ts\n"
|
||||
+ "\n"
|
||||
+ "#EXT-X-KEY:URI=\"data:text/plain;base64,VGhpcyBpcyBhbiBlYXN0ZXIgZWdn\","
|
||||
+ "IV=0x9358382AEB449EE23C3D809DA0B9CCD3,KEYFORMATVERSIONS=\"1\","
|
||||
+ "KEYFORMAT=\"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed\","
|
||||
+ "IV=0x1566B,METHOD=SAMPLE-AES-CENC \n"
|
||||
+ "#EXTINF:8,\n"
|
||||
+ "https://priv.example.com/2.ts\n"
|
||||
+ "#EXT-X-ENDLIST\n";
|
||||
InputStream inputStream =
|
||||
new ByteArrayInputStream(playlistString.getBytes(Charset.forName(C.UTF8_NAME)));
|
||||
HlsMediaPlaylist playlist =
|
||||
(HlsMediaPlaylist) new HlsPlaylistParser().parse(playlistUri, inputStream);
|
||||
assertThat(playlist.drmInitData.schemeType).isEqualTo(C.CENC_TYPE_cenc);
|
||||
assertThat(playlist.drmInitData.get(0).matches(C.WIDEVINE_UUID)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseSampleAesCtrMethod() throws Exception {
|
||||
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
||||
String playlistString =
|
||||
"#EXTM3U\n"
|
||||
+ "#EXT-X-MEDIA-SEQUENCE:0\n"
|
||||
+ "#EXTINF:8,\n"
|
||||
+ "https://priv.example.com/1.ts\n"
|
||||
+ "\n"
|
||||
+ "#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="
|
||||
+ "\"data:text/plain;base64,VGhpcyBpcyBhbiBlYXN0ZXIgZWdn\","
|
||||
+ "IV=0x9358382AEB449EE23C3D809DA0B9CCD3,KEYFORMATVERSIONS=\"1\","
|
||||
+ "KEYFORMAT=\"com.widevine\",IV=0x1566B\n"
|
||||
+ "#EXTINF:8,\n"
|
||||
+ "https://priv.example.com/2.ts\n"
|
||||
+ "#EXT-X-ENDLIST\n";
|
||||
InputStream inputStream =
|
||||
new ByteArrayInputStream(playlistString.getBytes(Charset.forName(C.UTF8_NAME)));
|
||||
HlsMediaPlaylist playlist =
|
||||
(HlsMediaPlaylist) new HlsPlaylistParser().parse(playlistUri, inputStream);
|
||||
assertThat(playlist.drmInitData.schemeType).isEqualTo(C.CENC_TYPE_cenc);
|
||||
assertThat(playlist.drmInitData.get(0).matches(C.WIDEVINE_UUID)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGapTag() throws IOException {
|
||||
Uri playlistUri = Uri.parse("https://example.com/test2.m3u8");
|
||||
|
Loading…
x
Reference in New Issue
Block a user