MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / hls_encryption_start

Function hls_encryption_start

libavformat/hlsenc.c:712–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710
711
712static int hls_encryption_start(AVFormatContext *s, VariantStream *vs)
713{
714 HLSContext *hls = s->priv_data;
715 int ret;
716 AVIOContext *pb;
717 uint8_t key[KEYSIZE];
718 AVDictionary *options = NULL;
719
720 set_http_options(s, &options, hls);
721 ret = s->io_open(s, &pb, hls->key_info_file, AVIO_FLAG_READ, &options);
722 av_dict_free(&options);
723 if (ret < 0) {
724 av_log(hls, AV_LOG_ERROR,
725 "error opening key info file %s\n", hls->key_info_file);
726 return ret;
727 }
728
729 ff_get_line(pb, vs->key_uri, sizeof(vs->key_uri));
730 vs->key_uri[strcspn(vs->key_uri, "\r\n")] = '\0';
731
732 ff_get_line(pb, vs->key_file, sizeof(vs->key_file));
733 vs->key_file[strcspn(vs->key_file, "\r\n")] = '\0';
734
735 ff_get_line(pb, vs->iv_string, sizeof(vs->iv_string));
736 vs->iv_string[strcspn(vs->iv_string, "\r\n")] = '\0';
737
738 ff_format_io_close(s, &pb);
739
740 if (!*vs->key_uri) {
741 av_log(hls, AV_LOG_ERROR, "no key URI specified in key info file\n");
742 return AVERROR(EINVAL);
743 }
744
745 if (!*vs->key_file) {
746 av_log(hls, AV_LOG_ERROR, "no key file specified in key info file\n");
747 return AVERROR(EINVAL);
748 }
749
750 set_http_options(s, &options, hls);
751 ret = s->io_open(s, &pb, vs->key_file, AVIO_FLAG_READ, &options);
752 av_dict_free(&options);
753 if (ret < 0) {
754 av_log(hls, AV_LOG_ERROR, "error opening key file %s\n", vs->key_file);
755 return ret;
756 }
757
758 ret = avio_read(pb, key, sizeof(key));
759 ff_format_io_close(s, &pb);
760 if (ret != sizeof(key)) {
761 av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", vs->key_file);
762 if (ret >= 0 || ret == AVERROR_EOF)
763 ret = AVERROR(EINVAL);
764 return ret;
765 }
766 ff_data_to_hex(vs->key_string, key, sizeof(key), 0);
767
768 return 0;
769}

Callers 1

hls_startFunction · 0.85

Calls 7

av_dict_freeFunction · 0.85
av_logFunction · 0.85
ff_get_lineFunction · 0.85
ff_format_io_closeFunction · 0.85
avio_readFunction · 0.85
ff_data_to_hexFunction · 0.85
set_http_optionsFunction · 0.70

Tested by

no test coverage detected