Go to the documentation of this file.
22 #include <libxml/parser.h>
36 #define INITIAL_BUFFER_SIZE 32768
180 return ((
val + 0x3F) >> 6) << 6;
203 ret = sscanf(datetime,
"%d-%d-%dT%d:%d:%fZ", &year, &month, &day, &hour, &minute, &second);
208 timeinfo.tm_year = year - 1900;
209 timeinfo.tm_mon = month - 1;
210 timeinfo.tm_mday = day;
211 timeinfo.tm_hour = hour;
212 timeinfo.tm_min = minute;
213 timeinfo.tm_sec = (int)second;
231 if (*ptr ==
'P' || *ptr ==
'T') {
242 days = (uint32_t)
value;
245 hours = (uint32_t)
value;
248 mins = (uint32_t)
value;
251 secs = (uint32_t)
value;
259 return ((days * 24 + hours) * 60 + mins) * 60 + secs;
275 if (num == cur_seq_no)
287 if (num == cur_seq_no)
385 for (
i = 0;
i <
c->n_videos;
i++) {
396 for (
i = 0;
i <
c->n_audios;
i++) {
407 for (
i = 0;
i <
c->n_subtitles;
i++) {
420 const char *proto_name =
NULL;
425 if (url[6] ==
'+' || url[6] ==
':')
435 proto_name_len = strlen(proto_name);
438 if (strcmp(
c->allowed_extensions,
"ALL") && !
av_match_ext(url,
c->allowed_extensions)) {
440 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n"
441 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
450 if (!strncmp(proto_name, url, proto_name_len) && url[proto_name_len] ==
':')
452 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, proto_name_len) && url[7 + proto_name_len] ==
':')
454 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
463 char *new_cookies =
NULL;
486 char *rep_bandwidth_val,
497 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
498 if (baseurl_nodes[
i] &&
499 baseurl_nodes[
i]->children &&
500 baseurl_nodes[
i]->children->type == XML_TEXT_NODE) {
501 text = xmlNodeGetContent(baseurl_nodes[
i]->children);
503 memset(tmp_str, 0, max_url_size);
520 if (rep_bandwidth_val && tmp_str[0] !=
'\0') {
538 for (
i = 0;
i < n_nodes; ++
i) {
540 val = xmlGetProp(nodes[
i], attrname);
551 xmlNodePtr node = rootnode;
556 node = xmlFirstElementChild(node);
561 node = xmlNextElementSibling(node);
574 for (
i = 0;
i < 2;
i++) {
575 attr =
i ?
"mimeType" :
"contentType";
576 val = xmlGetProp(node, attr);
601 char *str_end_offset;
603 if (!str_offset || !str_end_offset) {
616 xmlNodePtr fragmenturl_node,
617 xmlNodePtr *baseurl_nodes,
619 char *rep_bandwidth_val)
622 char *initialization_val =
NULL;
623 char *media_val =
NULL;
624 char *range_val =
NULL;
628 if (!
av_strcasecmp(fragmenturl_node->name,
"Initialization")) {
629 initialization_val = xmlGetProp(fragmenturl_node,
"sourceURL");
630 range_val = xmlGetProp(fragmenturl_node,
"range");
631 if (initialization_val || range_val) {
636 xmlFree(initialization_val);
644 xmlFree(initialization_val);
650 }
else if (!
av_strcasecmp(fragmenturl_node->name,
"SegmentURL")) {
651 media_val = xmlGetProp(fragmenturl_node,
"media");
652 range_val = xmlGetProp(fragmenturl_node,
"mediaRange");
653 if (media_val || range_val) {
682 xmlNodePtr fragment_timeline_node)
684 xmlAttrPtr attr =
NULL;
693 attr = fragment_timeline_node->properties;
695 val = xmlGetProp(fragment_timeline_node, attr->name);
698 av_log(
s,
AV_LOG_WARNING,
"parse_manifest_segmenttimeline attr->name = %s val is NULL\n", attr->name);
724 char *tmp_str =
NULL;
726 char *mpdName =
NULL;
727 xmlNodePtr node =
NULL;
728 char *baseurl =
NULL;
729 char *root_url =
NULL;
739 int tmp_max_url_size = strlen(url);
741 for (
i = n_baseurl_nodes-1;
i >= 0 ;
i--) {
742 text = xmlNodeGetContent(baseurl_nodes[
i]);
745 tmp_max_url_size += strlen(text);
753 tmp_max_url_size =
aligned(tmp_max_url_size);
762 size = strlen(mpdName);
768 if (!tmp_str || !path) {
774 for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
775 if (!(node = baseurl_nodes[rootId])) {
778 text = xmlNodeGetContent(node);
786 node = baseurl_nodes[rootId];
787 baseurl = xmlNodeGetContent(node);
789 size_t len = xmlStrlen(baseurl)+2;
790 char *
tmp = xmlRealloc(baseurl,
len);
799 xmlChar *escaped = xmlEncodeSpecialChars(
NULL, root_url);
804 xmlNodeSetContent(node, escaped);
809 size = strlen(root_url);
810 isRootHttp =
ishttp(root_url);
812 if (
size > 0 && root_url[
size - 1] != token) {
817 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
821 text = xmlNodeGetContent(baseurl_nodes[
i]);
823 memset(tmp_str, 0, strlen(tmp_str));
824 if (!
ishttp(text) && isRootHttp) {
827 start = (text[0] == token);
836 memset(
p + 1, 0, strlen(
p));
838 av_strlcat(tmp_str, text + start, tmp_max_url_size);
840 xmlChar* escaped = xmlEncodeSpecialChars(
NULL, tmp_str);
845 xmlNodeSetContent(baseurl_nodes[
i], escaped);
852 if (tmp_max_url_size > *max_url_size) {
853 *max_url_size = tmp_max_url_size;
862 #define SET_REPRESENTATION_SEQUENCE_BASE_INFO(arg, cnt) { \
863 val = get_val_from_nodes_tab((arg), (cnt), "duration"); \
865 int64_t fragment_duration = (int64_t) strtoll(val, NULL, 10); \
866 if (fragment_duration < 0) { \
867 av_log(s, AV_LOG_WARNING, "duration invalid, autochanged to 0.\n"); \
868 fragment_duration = 0; \
870 rep->fragment_duration = fragment_duration; \
871 av_log(s, AV_LOG_TRACE, "rep->fragment_duration = [%"PRId64"]\n", rep->fragment_duration); \
874 val = get_val_from_nodes_tab((arg), (cnt), "timescale"); \
876 int64_t fragment_timescale = (int64_t) strtoll(val, NULL, 10); \
877 if (fragment_timescale < 0) { \
878 av_log(s, AV_LOG_WARNING, "timescale invalid, autochanged to 0.\n"); \
879 fragment_timescale = 0; \
881 rep->fragment_timescale = fragment_timescale; \
882 av_log(s, AV_LOG_TRACE, "rep->fragment_timescale = [%"PRId64"]\n", rep->fragment_timescale); \
885 val = get_val_from_nodes_tab((arg), (cnt), "startNumber"); \
887 int64_t start_number = (int64_t) strtoll(val, NULL, 10); \
888 if (start_number < 0) { \
889 av_log(s, AV_LOG_WARNING, "startNumber invalid, autochanged to 0.\n"); \
892 rep->start_number = rep->first_seq_no = start_number; \
893 av_log(s, AV_LOG_TRACE, "rep->first_seq_no = [%"PRId64"]\n", rep->first_seq_no); \
901 xmlNodePtr adaptionset_node,
902 xmlNodePtr mpd_baseurl_node,
903 xmlNodePtr period_baseurl_node,
904 xmlNodePtr period_segmenttemplate_node,
905 xmlNodePtr period_segmentlist_node,
906 xmlNodePtr fragment_template_node,
907 xmlNodePtr content_component_node,
908 xmlNodePtr adaptionset_baseurl_node,
909 xmlNodePtr adaptionset_segmentlist_node,
910 xmlNodePtr adaptionset_supplementalproperty_node)
916 xmlNodePtr representation_segmenttemplate_node =
NULL;
917 xmlNodePtr representation_baseurl_node =
NULL;
918 xmlNodePtr representation_segmentlist_node =
NULL;
919 xmlNodePtr segmentlists_tab[3];
920 xmlNodePtr fragment_timeline_node =
NULL;
921 xmlNodePtr fragment_templates_tab[5];
923 xmlNodePtr baseurl_nodes[4];
924 xmlNodePtr representation_node = node;
925 char *rep_bandwidth_val;
926 char *rep_codecs_val;
927 char *rep_dependencyid_val;
949 if (
c->adaptionset_lang) {
961 rep_bandwidth_val = xmlGetProp(representation_node,
"bandwidth");
962 rep_dependencyid_val = xmlGetProp(representation_node,
"dependencyId");
963 rep_codecs_val = xmlGetProp(representation_node,
"codecs");
965 rep_codecs_val = xmlGetProp(adaptionset_node,
"codecs");
966 val = xmlGetProp(representation_node,
"id");
974 baseurl_nodes[0] = mpd_baseurl_node;
975 baseurl_nodes[1] = period_baseurl_node;
976 baseurl_nodes[2] = adaptionset_baseurl_node;
977 baseurl_nodes[3] = representation_baseurl_node;
980 c->max_url_size =
aligned(
c->max_url_size
981 + (rep->
id ? strlen(rep->
id) : 0)
982 + (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
985 if (representation_segmenttemplate_node || fragment_template_node || period_segmenttemplate_node) {
986 fragment_timeline_node =
NULL;
987 fragment_templates_tab[0] = representation_segmenttemplate_node;
988 fragment_templates_tab[1] = adaptionset_segmentlist_node;
989 fragment_templates_tab[2] = fragment_template_node;
990 fragment_templates_tab[3] = period_segmenttemplate_node;
991 fragment_templates_tab[4] = period_segmentlist_node;
1000 c->max_url_size =
aligned(
c->max_url_size + strlen(
val));
1002 c->max_url_size, rep->
id,
1003 rep_bandwidth_val,
val);
1011 c->max_url_size =
aligned(
c->max_url_size + strlen(
val));
1013 c->max_url_size, rep->
id,
1014 rep_bandwidth_val,
val);
1020 if (presentation_timeoffset < 0) {
1022 presentation_timeoffset = 0;
1030 if (adaptionset_supplementalproperty_node) {
1031 char *scheme_id_uri = xmlGetProp(adaptionset_supplementalproperty_node,
"schemeIdUri");
1032 if (scheme_id_uri) {
1033 int is_last_segment_number = !
av_strcasecmp(scheme_id_uri,
"http://dashif.org/guidelines/last-segment-number");
1034 xmlFree(scheme_id_uri);
1035 if (is_last_segment_number) {
1036 val = xmlGetProp(adaptionset_supplementalproperty_node,
"value");
1038 av_log(
s,
AV_LOG_ERROR,
"Missing value attribute in adaptionset_supplementalproperty_node\n");
1049 if (!fragment_timeline_node)
1051 if (!fragment_timeline_node)
1053 if (!fragment_timeline_node)
1055 if (fragment_timeline_node) {
1056 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1057 while (fragment_timeline_node) {
1061 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1064 }
else if (representation_baseurl_node && !representation_segmentlist_node) {
1074 rep->
id, rep_bandwidth_val,
NULL);
1078 }
else if (representation_segmentlist_node) {
1081 xmlNodePtr fragmenturl_node =
NULL;
1082 segmentlists_tab[0] = representation_segmentlist_node;
1083 segmentlists_tab[1] = adaptionset_segmentlist_node;
1084 segmentlists_tab[2] = period_segmentlist_node;
1087 fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
1088 while (fragmenturl_node) {
1090 baseurl_nodes, rep->
id,
1094 fragmenturl_node = xmlNextElementSibling(fragmenturl_node);
1098 if (!fragment_timeline_node)
1100 if (fragment_timeline_node) {
1101 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1102 while (fragment_timeline_node) {
1106 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1111 rep->
id ? rep->
id :
"");
1117 rep->
bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
1118 if (rep_dependencyid_val) {
1121 xmlFree(rep_dependencyid_val);
1125 if (rep_codecs_val) {
1128 xmlFree(rep_codecs_val);
1134 char *rep_framerate_val = xmlGetProp(representation_node,
"frameRate");
1135 if (rep_framerate_val) {
1139 xmlFree(rep_framerate_val);
1158 if (rep_bandwidth_val)
1159 xmlFree(rep_bandwidth_val);
1160 if (rep_dependencyid_val)
1161 xmlFree(rep_dependencyid_val);
1163 xmlFree(rep_codecs_val);
1177 if (!adaptionset_node) {
1181 c->adaptionset_lang = xmlGetProp(adaptionset_node,
"lang");
1187 xmlNodePtr adaptionset_node,
1188 xmlNodePtr mpd_baseurl_node,
1189 xmlNodePtr period_baseurl_node,
1190 xmlNodePtr period_segmenttemplate_node,
1191 xmlNodePtr period_segmentlist_node)
1195 xmlNodePtr fragment_template_node =
NULL;
1196 xmlNodePtr content_component_node =
NULL;
1197 xmlNodePtr adaptionset_baseurl_node =
NULL;
1198 xmlNodePtr adaptionset_segmentlist_node =
NULL;
1199 xmlNodePtr adaptionset_supplementalproperty_node =
NULL;
1200 xmlNodePtr node =
NULL;
1206 node = xmlFirstElementChild(adaptionset_node);
1209 fragment_template_node = node;
1210 }
else if (!
av_strcasecmp(node->name,
"ContentComponent")) {
1211 content_component_node = node;
1213 adaptionset_baseurl_node = node;
1215 adaptionset_segmentlist_node = node;
1216 }
else if (!
av_strcasecmp(node->name,
"SupplementalProperty")) {
1217 adaptionset_supplementalproperty_node = node;
1222 period_baseurl_node,
1223 period_segmenttemplate_node,
1224 period_segmentlist_node,
1225 fragment_template_node,
1226 content_component_node,
1227 adaptionset_baseurl_node,
1228 adaptionset_segmentlist_node,
1229 adaptionset_supplementalproperty_node);
1233 node = xmlNextElementSibling(node);
1237 xmlFree(
c->adaptionset_lang);
1238 c->adaptionset_lang =
NULL;
1246 node = xmlFirstElementChild(node);
1249 val = xmlNodeGetContent(node);
1254 val = xmlNodeGetContent(node);
1259 val = xmlNodeGetContent(node);
1264 node = xmlNextElementSibling(node);
1279 xmlNodePtr root_element =
NULL;
1280 xmlNodePtr node =
NULL;
1281 xmlNodePtr period_node =
NULL;
1282 xmlNodePtr tmp_node =
NULL;
1283 xmlNodePtr mpd_baseurl_node =
NULL;
1284 xmlNodePtr period_baseurl_node =
NULL;
1285 xmlNodePtr period_segmenttemplate_node =
NULL;
1286 xmlNodePtr period_segmentlist_node =
NULL;
1287 xmlNodePtr adaptionset_node =
NULL;
1288 xmlAttrPtr attr =
NULL;
1290 uint32_t period_duration_sec = 0;
1291 uint32_t period_start_sec = 0;
1316 doc = xmlReadMemory(buf.str, buf.len,
c->base_url,
NULL, 0);
1317 root_element = xmlDocGetRootElement(doc);
1318 node = root_element;
1326 if (node->type != XML_ELEMENT_NODE ||
1329 av_log(
s,
AV_LOG_ERROR,
"Unable to parse '%s' - wrong root node name[%s] type[%d]\n",
url, node->name, (
int)node->type);
1333 val = xmlGetProp(node,
"type");
1343 attr = node->properties;
1345 val = xmlGetProp(node, attr->name);
1349 av_log(
s,
AV_LOG_TRACE,
"c->availability_start_time = [%"PRId64
"]\n",
c->availability_start_time);
1350 }
else if (!
av_strcasecmp(attr->name,
"availabilityEndTime")) {
1356 }
else if (!
av_strcasecmp(attr->name,
"minimumUpdatePeriod")) {
1359 }
else if (!
av_strcasecmp(attr->name,
"timeShiftBufferDepth")) {
1361 av_log(
s,
AV_LOG_TRACE,
"c->time_shift_buffer_depth = [%"PRId64
"]\n",
c->time_shift_buffer_depth);
1365 }
else if (!
av_strcasecmp(attr->name,
"suggestedPresentationDelay")) {
1367 av_log(
s,
AV_LOG_TRACE,
"c->suggested_presentation_delay = [%"PRId64
"]\n",
c->suggested_presentation_delay);
1368 }
else if (!
av_strcasecmp(attr->name,
"mediaPresentationDuration")) {
1370 av_log(
s,
AV_LOG_TRACE,
"c->media_presentation_duration = [%"PRId64
"]\n",
c->media_presentation_duration);
1378 mpd_baseurl_node = xmlCopyNode(tmp_node,1);
1380 mpd_baseurl_node = xmlNewNode(
NULL,
"BaseURL");
1384 node = xmlFirstElementChild(node);
1387 period_duration_sec = 0;
1388 period_start_sec = 0;
1389 attr = node->properties;
1391 val = xmlGetProp(node, attr->name);
1400 if ((period_duration_sec) >= (
c->period_duration)) {
1402 c->period_duration = period_duration_sec;
1403 c->period_start = period_start_sec;
1404 if (
c->period_start > 0)
1405 c->media_presentation_duration =
c->period_duration;
1407 }
else if (!
av_strcasecmp(node->name,
"ProgramInformation")) {
1410 node = xmlNextElementSibling(node);
1418 adaptionset_node = xmlFirstElementChild(period_node);
1419 while (adaptionset_node) {
1421 period_baseurl_node = adaptionset_node;
1422 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentTemplate")) {
1423 period_segmenttemplate_node = adaptionset_node;
1424 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentList")) {
1425 period_segmentlist_node = adaptionset_node;
1426 }
else if (!
av_strcasecmp(adaptionset_node->name,
"AdaptationSet")) {
1429 adaptionset_node = xmlNextElementSibling(adaptionset_node);
1435 xmlFreeNode(mpd_baseurl_node);
1449 int64_t start_time_offset = 0;
1465 }
else if (
c->publish_time > 0 && !
c->availability_start_time) {
1466 if (
c->min_buffer_time) {
1522 if (rep_dest && rep_src ) {
1536 if (rep_dest && rep_src ) {
1557 int n_videos =
c->n_videos;
1559 int n_audios =
c->n_audios;
1561 int n_subtitles =
c->n_subtitles;
1563 char *base_url =
c->base_url;
1571 c->subtitles =
NULL;
1576 if (
c->n_videos != n_videos) {
1578 "new manifest has mismatched no. of video representations, %d -> %d\n",
1579 n_videos,
c->n_videos);
1582 if (
c->n_audios != n_audios) {
1584 "new manifest has mismatched no. of audio representations, %d -> %d\n",
1585 n_audios,
c->n_audios);
1588 if (
c->n_subtitles != n_subtitles) {
1590 "new manifest has mismatched no. of subtitles representations, %d -> %d\n",
1591 n_subtitles,
c->n_subtitles);
1595 for (
i = 0;
i < n_videos;
i++) {
1611 for (
i = 0;
i < n_audios;
i++) {
1633 c->base_url = base_url;
1642 c->n_subtitles = n_subtitles;
1643 c->subtitles = subtitles;
1644 c->n_audios = n_audios;
1646 c->n_videos = n_videos;
1658 int reload_count = 0;
1675 }
else if (
c->is_live) {
1676 if (reload_count++ >=
c->max_reload) {
1678 "Reached max manifest reloads (%d) at seq %"PRId64
"\n",
1742 uint8_t *buf,
int buf_size)
1769 if (seg->
size >= 0) {
1791 static const int max_init_section_size = 1024 * 1024;
1803 "Failed to open an initialization section\n");
1812 sec_size = max_init_section_size;
1815 "Downloading an initialization section of size %"PRId64
"\n",
1818 sec_size =
FFMIN(sec_size, max_init_section_size);
1845 static int read_data(
void *opaque, uint8_t *buf,
int buf_size)
1874 "Reached max consecutive fragment open failures (%d), giving up\n",
1920 "A DASH playlist item '%s' referred to an external file '%s'. "
1921 "Opening this file was forbidden for security reasons\n",
1930 memset(&pls->
pb, 0x00,
sizeof(pls->
pb));
1940 uint8_t *avio_ctx_buffer =
NULL;
1958 if (!avio_ctx_buffer ) {
1972 pls->
ctx->
probesize =
s->probesize > 0 ?
s->probesize : 1024 * 4;
1986 if (
c->cenc_decryption_key)
1987 av_dict_set(&in_fmt_opts,
"decryption_key",
c->cenc_decryption_key, 0);
1988 if (
c->cenc_decryption_keys)
1989 av_dict_set(&in_fmt_opts,
"decryption_keys",
c->cenc_decryption_keys, 0);
1997 #if FF_API_R_FRAME_RATE
2059 stg->
id =
s->nb_stream_groups;
2069 switch (stg->
type) {
2079 av_unreachable(
"Unsupported Stream Group type should have been checked above");
2097 if (first_init_section ==
NULL || n_pls == 0)
2100 url = first_init_section->
url;
2103 for (
i=0;
i<n_pls;
i++) {
2104 if (!pls[
i]->init_section)
2148 c->interrupt_callback = &
s->interrupt_callback;
2168 for (
i = 0;
i <
c->n_videos;
i++) {
2170 if (
i > 0 &&
c->is_init_section_common_video) {
2188 for (
i = 0;
i <
c->n_audios;
i++) {
2190 if (
i > 0 &&
c->is_init_section_common_audio) {
2208 for (
i = 0;
i <
c->n_subtitles;
i++) {
2209 rep =
c->subtitles[
i];
2210 if (
i > 0 &&
c->is_init_section_common_subtitle) {
2233 for (
i = 0;
i <
c->n_videos;
i++) {
2247 for (
i = 0;
i <
c->n_audios;
i++) {
2262 for (
i = 0;
i <
c->n_subtitles;
i++) {
2263 rep =
c->subtitles[
i];
2277 for (
i = 0;
i <
c->n_videos;
i++) {
2282 for (j = 0; j <
c->n_videos; j++) {
2286 if (!
ref->nb_assoc_stream)
2317 for (
i = 0;
i < n;
i++) {
2328 for (j = 0; j < n; j++) {
2353 for (
i = 0;
i <
c->n_videos;
i++) {
2362 for (
i = 0;
i <
c->n_audios;
i++) {
2372 for (
i = 0;
i <
c->n_subtitles;
i++) {
2373 rep =
c->subtitles[
i];
2423 seek_pos_msec, dry_run ?
" (dry)" :
"");
2441 "last_seq_no[%"PRId64
"].\n",
2491 for (
i = 0;
i <
c->n_videos;
i++) {
2495 for (
i = 0;
i <
c->n_audios;
i++) {
2499 for (
i = 0;
i <
c->n_subtitles;
i++) {
2512 if (
av_stristr(
p->buf,
"dash:profile:isoff-on-demand:2011") ||
2513 av_stristr(
p->buf,
"dash:profile:isoff-live:2011") ||
2514 av_stristr(
p->buf,
"dash:profile:isoff-live:2012") ||
2515 av_stristr(
p->buf,
"dash:profile:isoff-main:2011") ||
2526 #define OFFSET(x) offsetof(DASHContext, x)
2527 #define FLAGS AV_OPT_FLAG_DECODING_PARAM
2529 {
"allowed_extensions",
"List of file extensions that dash is allowed to access",
2531 {.str =
"aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
2532 INT_MIN, INT_MAX,
FLAGS},
2533 {
"cenc_decryption_key",
"Media default decryption key (hex)",
OFFSET(cenc_decryption_key),
AV_OPT_TYPE_STRING, {.str =
NULL}, INT_MIN, INT_MAX, .flags =
FLAGS },
2534 {
"cenc_decryption_keys",
"Media decryption keys by KID (hex)",
OFFSET(cenc_decryption_keys),
AV_OPT_TYPE_STRING, {.str =
NULL}, INT_MIN, INT_MAX, .flags =
FLAGS },
2535 {
"max_reload",
"Maximum number of manifest reloads in get_current_fragment() before giving up",
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls)
@ AV_ROUND_UP
Round toward +infinity.
static void close_demux_for_component(struct representation *pls)
#define AV_LOG_WARNING
Something somehow does not look correct.
AVStreamGroup ** stream_groups
A list of all stream groups in the file.
static int64_t calc_next_seg_no_from_timelines(struct representation *pls, int64_t cur_time)
int64_t id
Group type-specific group ID.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C program
static int open_demux_for_component(AVFormatContext *s, struct representation *pls)
static int read_data(void *opaque, uint8_t *buf, int buf_size)
void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, const uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
int ffio_copy_url_options(AVIOContext *pb, AVDictionary **avio_opts)
Read url related dictionary options from the AVIOContext and write to the given dictionary.
AVStreamGroupLayeredVideo is meant to define the relation between a base layer video stream and a sep...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int64_t get_utc_date_time_insec(AVFormatContext *s, const char *datetime)
static int ishttp(char *url)
static int64_t get_current_time_in_sec(void)
static int64_t calc_min_seg_no(AVFormatContext *s, struct representation *pls)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
static void free_video_list(DASHContext *c)
#define AVERROR_EOF
End of file.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
uint32_t init_sec_buf_read_offset
static struct fragment * get_current_fragment(struct representation *pls)
int is_init_section_common_subtitle
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int disposition
Stream group disposition - a combination of AV_DISPOSITION_* flags.
static int dash_close(AVFormatContext *s)
static av_cold void cleanup(FlashSV2Context *s)
AVStream ** streams
A list of all streams in the file.
int64_t minimum_update_period
AVIOInterruptCB * interrupt_callback
static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representation *rep, xmlNodePtr fragmenturl_node, xmlNodePtr *baseurl_nodes, char *rep_id_val, char *rep_bandwidth_val)
#define AV_LOG_VERBOSE
Detailed information.
int64_t probesize
Maximum number of bytes read from input in order to determine stream properties.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
void ff_read_frame_flush(AVFormatContext *s)
Flush the frame reader.
static int read_from_url(struct representation *pls, struct fragment *seg, uint8_t *buf, int buf_size)
int64_t avio_size(AVIOContext *s)
Get the filesize.
static xmlNodePtr find_child_node_by_name(xmlNodePtr rootnode, const char *nodename)
Callback for checking whether to abort blocking functions.
static int64_t get_segment_start_time_based_on_timeline(struct representation *pls, int64_t cur_seq_no)
struct representation ** subtitles
int64_t media_presentation_duration
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
struct fragment * init_section
static void free_timelines_list(struct representation *pls)
static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
static void free_fragment(struct fragment **seg)
static int64_t calc_cur_seg_no(AVFormatContext *s, struct representation *pls)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_cold int read_close(AVFormatContext *ctx)
int64_t availability_start_time
static double val(void *priv, double ch)
static void recheck_discard_flags(AVFormatContext *s, struct representation **p, int n)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
AVProgram * av_new_program(AVFormatContext *ac, int id)
static enum AVMediaType get_content_type(xmlNodePtr node)
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
static const AVOption dash_options[]
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int64_t seek_data(void *opaque, int64_t offset, int whence)
static int aligned(int val)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void free_representation(struct representation *pls)
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static void move_metadata(AVStream *st, const char *key, char **value)
char * allowed_extensions
static void move_segments(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int flags
Flags modifying the (de)muxer behaviour.
static void free_fragment_list(struct representation *pls)
int width
The width of the video frame in pixels.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
unsigned int index
Group index in AVFormatContext.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
static uint32_t get_duration_insec(AVFormatContext *s, const char *duration)
struct representation ** videos
#define INITIAL_BUFFER_SIZE
uint32_t init_sec_buf_size
struct AVStreamGroupLayeredVideo * layered_video
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
enum AVStreamParseType need_parsing
@ AVDISCARD_ALL
discard all
static AVDictionary * opts
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Rational number (pair of numerator and denominator).
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
char * av_strireplace(const char *str, const char *from, const char *to)
Locale-independent strings replace.
static int is_common_init_section_exist(struct representation **pls, int n_pls)
const char * av_default_item_name(void *ptr)
Return the context name.
static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
static void move_timelines(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
struct timeline ** timelines
const FFInputFormat ff_dash_demuxer
static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int64_t suggested_presentation_delay
int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st)
Add an already allocated stream to a stream group.
int av_opt_copy(void *dst, const void *src)
Copy options from src object into dest object.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static char * get_val_from_nodes_tab(xmlNodePtr *nodes, const int n_nodes, const char *attrname)
@ AV_ROUND_DOWN
Round toward -infinity.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
static int resolve_content_path(AVFormatContext *s, const char *url, int *max_url_size, xmlNodePtr *baseurl_nodes, int n_baseurl_nodes)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define SET_REPRESENTATION_SEQUENCE_BASE_INFO(arg, cnt)
int64_t time_shift_buffer_depth
#define i(width, name, range_min, range_max)
static int64_t start_time
static AVRational av_make_q(int num, int den)
Create an AVRational.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
static int copy_init_section(struct representation *rep_dest, struct representation *rep_src)
uint32_t init_sec_data_len
static int dash_read_header(AVFormatContext *s)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static void free_audio_list(DASHContext *c)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static int read_header(FFV1Context *f, RangeCoder *c)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Like av_probe_input_buffer2() but returns 0 on success.
AVStream ** streams
A list of streams in the group.
static struct fragment * get_fragment(AVFormatContext *s, char *range)
#define AV_LOG_INFO
Standard information.
char * cenc_decryption_key
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary **opts, AVDictionary *opts2, int *is_http)
static void free_subtitle_list(DASHContext *c)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int dash_probe(const AVProbeData *p)
int height
The height of the video frame in pixels.
#define AV_TIME_BASE
Internal time base represented as integer.
struct representation ** audios
#define av_malloc_array(a, b)
int64_t fragment_timescale
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is needed
int width
Width of the final stream for presentation.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
int is_init_section_common_audio
static int parse_manifest_adaptationset(AVFormatContext *s, const char *url, xmlNodePtr adaptionset_node, xmlNodePtr mpd_baseurl_node, xmlNodePtr period_baseurl_node, xmlNodePtr period_segmenttemplate_node, xmlNodePtr period_segmentlist_node)
New fields can be added to the end with minor version bumps.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
char * cenc_decryption_keys
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
int id
Format-specific stream ID.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int height
Height of the final image for presentation.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representation *rep, xmlNodePtr fragment_timeline_node)
int64_t availability_end_time
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
int index
stream index in AVFormatContext
union AVStreamGroup::@459 params
Group type-specific parameters.
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
static int parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr adaptionset_node)
struct fragment * cur_seg
static char * get_content_url(xmlNodePtr *baseurl_nodes, int n_baseurl_nodes, int max_url_size, char *rep_id_val, char *rep_bandwidth_val, char *val)
int is_init_section_common_video
@ AV_OPT_TYPE_INT
Underlying C type is int.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int ref[MAX_W *MAX_W]
AVRational r_frame_rate
Real base framerate of the stream.
static int refresh_manifest(AVFormatContext *s)
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
static int update_init_section(struct representation *pls)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static int parse_manifest_representation(AVFormatContext *s, const char *url, xmlNodePtr node, xmlNodePtr adaptionset_node, xmlNodePtr mpd_baseurl_node, xmlNodePtr period_baseurl_node, xmlNodePtr period_segmenttemplate_node, xmlNodePtr period_segmentlist_node, xmlNodePtr fragment_template_node, xmlNodePtr content_component_node, xmlNodePtr adaptionset_baseurl_node, xmlNodePtr adaptionset_segmentlist_node, xmlNodePtr adaptionset_supplementalproperty_node)
static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
static int open_input(DASHContext *c, struct representation *pls, struct fragment *seg)
int64_t av_gettime(void)
Get the current time in microseconds.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
#define AVIO_FLAG_READ
read-only
static int read_probe(const AVProbeData *p)
enum AVStreamGroupParamsType type
Group type.
unsigned char * buffer
Start of the buffer.
AVStreamGroup * avformat_stream_group_create(AVFormatContext *s, enum AVStreamGroupParamsType type, AVDictionary **options)
Add a new empty stream group to a media file.
unsigned int nb_stream_groups
Number of elements in AVFormatContext.stream_groups.
int ff_make_absolute_url(char *buf, int size, const char *base, const char *rel)
Convert a relative url into an absolute url, given a base url.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
void ff_dash_fill_tmpl_params(char *dst, size_t buffer_size, const char *template, int rep_id, int number, int bit_rate, int64_t time)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int64_t fragment_duration
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t seek_pos_msec, int flags, int dry_run)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
int pts_wrap_bits
Number of bits in timestamps.
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
struct fragment ** fragments
void * priv_data
Format private data.
static const AVClass dash_class
int64_t presentation_timeoffset
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.