Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support DRM source with sample-aes-ctr encryption to download #108

Merged
merged 1 commit into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/hls.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ long get_hls_data_from_url(char *url, char **out, size_t *size, int type, char *

int is_playlist_FPS(char* source)
{
return strstr(source, "KEYFORMAT=\"com.apple.streamingkeydelivery\"");
return strstr(source, "KEYFORMAT=\"com.apple.streamingkeydelivery\"") ||
strstr(source, "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed") ||
strstr(source, "com.microsoft.playready");
}

int get_playlist_type(char *source)
Expand Down Expand Up @@ -247,6 +249,9 @@ static int parse_tag(hls_media_playlist_t *me, struct hls_media_segment *ms, cha
if (!strncmp(tag, "#EXT-X-KEY:METHOD=AES-128", 25)) {
enc_type = ENC_AES128;
me->enc_aes.iv_is_static = false;
} else if (!strncmp(tag, "#EXT-X-KEY:METHOD=SAMPLE-AES-CTR", 32)) {
enc_type = ENC_AES_SAMPLE_CTR;
me->enc_aes.iv_is_static = is_playlist_FPS(me->source);
} else if (!strncmp(tag, "#EXT-X-KEY:METHOD=SAMPLE-AES", 28)) {
enc_type = ENC_AES_SAMPLE;
me->enc_aes.iv_is_static = is_playlist_FPS(me->source);
Expand Down
1 change: 1 addition & 0 deletions src/hls.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern "C" {
#define MASTER_PLAYLIST 0
#define MEDIA_PLAYLIST 1

#define ENC_AES_SAMPLE_CTR 0x03
#define ENC_AES_SAMPLE 0x02
#define ENC_AES128 0x01
#define ENC_NONE 0x00
Expand Down
15 changes: 10 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include "msg.h"
#include "misc.h"

char* str_ecryption_type[] ={
"NONE",
"AES-128",
"SAMPLE-AES",
"SAMPLE-AES-CTR",
};


static size_t priv_write(const uint8_t *data, size_t len, void *opaque) {
return fwrite(data, 1, len, opaque);
}
Expand Down Expand Up @@ -370,11 +378,8 @@ int main(int argc, char *argv[])
return 1;
}

if (media_playlist.encryption) {
MSG_PRINT("HLS Stream is %s encrypted.\n",
media_playlist.encryptiontype == ENC_AES128 ? "AES-128" :
"SAMPLE-AES");
}
MSG_PRINT("HLS Stream is %s encrypted.\n",
str_ecryption_type[media_playlist.encryptiontype]);

MSG_VERBOSE("Media Playlist parsed successfully.\n");

Expand Down