22 #include <libxml/parser.h>
31 #define INITIAL_BUFFER_SIZE 32768
32 #define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
33 #define DEFAULT_MANIFEST_SIZE 8 * 1024
34 #define MAX_TIMELINE_SEGMENTS (1 << 24)
171 if (
len > INT_MAX - 0x3F - *url_size)
197 ret = sscanf(datetime,
"%d-%d-%dT%d:%d:%fZ", &year, &month, &day, &hour, &minute, &second);
202 timeinfo.tm_year = year - 1900;
203 timeinfo.tm_mon = month - 1;
204 timeinfo.tm_mday = day;
205 timeinfo.tm_hour = hour;
206 timeinfo.tm_min = minute;
207 timeinfo.tm_sec = (
int)second;
225 if (*ptr ==
'P' || *ptr ==
'T') {
236 days = (uint32_t)
value;
239 hours = (uint32_t)
value;
242 mins = (uint32_t)
value;
245 secs = (uint32_t)
value;
253 return ((days * 24 + hours) * 60 + mins) * 60 + secs;
269 if (num == cur_seq_no)
281 if (num == cur_seq_no)
376 for (
i = 0;
i <
c->n_videos;
i++) {
387 for (
i = 0;
i <
c->n_audios;
i++) {
398 for (
i = 0;
i <
c->n_subtitles;
i++) {
411 const char *proto_name =
NULL;
415 if (url[6] ==
'+' || url[6] ==
':')
427 if (strcmp(
c->allowed_extensions,
"ALL") && !
av_match_ext(url,
c->allowed_extensions)) {
429 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n"
430 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
439 if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] ==
':')
441 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] ==
':')
443 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
452 char *new_cookies =
NULL;
475 char *rep_bandwidth_val,
486 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
487 if (baseurl_nodes[
i] &&
488 baseurl_nodes[
i]->children &&
489 baseurl_nodes[
i]->children->type == XML_TEXT_NODE) {
490 text = xmlNodeGetContent(baseurl_nodes[
i]->children);
492 memset(tmp_str, 0, max_url_size);
509 if (rep_bandwidth_val && tmp_str[0] !=
'\0') {
527 for (
i = 0;
i < n_nodes; ++
i) {
529 val = xmlGetProp(nodes[
i], attrname);
540 xmlNodePtr node = rootnode;
545 node = xmlFirstElementChild(node);
550 node = xmlNextElementSibling(node);
563 for (
i = 0;
i < 2;
i++) {
564 attr =
i ?
"mimeType" :
"contentType";
565 val = xmlGetProp(node, attr);
590 char *str_end_offset;
591 char *str_offset =
av_strtok(range,
"-", &str_end_offset);
592 if (!str_offset || !str_end_offset) {
605 xmlNodePtr fragmenturl_node,
606 xmlNodePtr *baseurl_nodes,
608 char *rep_bandwidth_val)
611 char *initialization_val =
NULL;
612 char *media_val =
NULL;
613 char *range_val =
NULL;
617 if (!
av_strcasecmp(fragmenturl_node->name,
"Initialization")) {
618 initialization_val = xmlGetProp(fragmenturl_node,
"sourceURL");
619 range_val = xmlGetProp(fragmenturl_node,
"range");
620 if (initialization_val || range_val) {
625 xmlFree(initialization_val);
633 xmlFree(initialization_val);
639 }
else if (!
av_strcasecmp(fragmenturl_node->name,
"SegmentURL")) {
640 media_val = xmlGetProp(fragmenturl_node,
"media");
641 range_val = xmlGetProp(fragmenturl_node,
"mediaRange");
642 if (media_val || range_val) {
671 xmlNodePtr fragment_timeline_node)
673 xmlAttrPtr attr =
NULL;
682 attr = fragment_timeline_node->properties;
684 val = xmlGetProp(fragment_timeline_node, attr->name);
713 char *tmp_str =
NULL;
715 char *mpdName =
NULL;
716 xmlNodePtr node =
NULL;
717 char *baseurl =
NULL;
718 char *root_url =
NULL;
728 int tmp_max_url_size = 0;
729 uint64_t url_len = strlen(url);
731 for (
i = n_baseurl_nodes-1;
i >= 0 ;
i--) {
732 text = xmlNodeGetContent(baseurl_nodes[
i]);
735 url_len += strlen(text);
754 size = strlen(mpdName);
760 if (!tmp_str || !path) {
766 for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
767 if (!(node = baseurl_nodes[rootId])) {
770 text = xmlNodeGetContent(node);
782 node = baseurl_nodes[rootId];
783 baseurl = xmlNodeGetContent(node);
786 tmp = xmlRealloc(baseurl, xmlStrlen(baseurl) + 2);
794 xmlNodeSetContent(node, root_url);
798 size = strlen(root_url);
799 isRootHttp =
ishttp(root_url);
801 if (
size > 0 && root_url[
size - 1] != token) {
805 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
809 text = xmlNodeGetContent(baseurl_nodes[
i]);
811 memset(tmp_str, 0, strlen(tmp_str));
812 if (!
ishttp(text) && isRootHttp) {
813 av_strlcpy(tmp_str, root_url, tmp_max_url_size + 2);
815 start = (text[0] == token);
824 memset(p + 1, 0, strlen(p));
826 av_strlcat(tmp_str, text + start, tmp_max_url_size + 2);
827 xmlNodeSetContent(baseurl_nodes[
i], tmp_str);
834 if (tmp_max_url_size > *max_url_size) {
835 *max_url_size = tmp_max_url_size;
844 #define SET_REPRESENTATION_SEQUENCE_BASE_INFO(arg, cnt) { \
845 val = get_val_from_nodes_tab((arg), (cnt), "duration"); \
847 int64_t fragment_duration = (int64_t) strtoll(val, NULL, 10); \
848 if (fragment_duration < 0) { \
849 av_log(s, AV_LOG_WARNING, "duration invalid, autochanged to 0.\n"); \
850 fragment_duration = 0; \
852 rep->fragment_duration = fragment_duration; \
853 av_log(s, AV_LOG_TRACE, "rep->fragment_duration = [%"PRId64"]\n", rep->fragment_duration); \
856 val = get_val_from_nodes_tab((arg), (cnt), "timescale"); \
858 int64_t fragment_timescale = (int64_t) strtoll(val, NULL, 10); \
859 if (fragment_timescale < 0) { \
860 av_log(s, AV_LOG_WARNING, "timescale invalid, autochanged to 0.\n"); \
861 fragment_timescale = 0; \
863 rep->fragment_timescale = fragment_timescale; \
864 av_log(s, AV_LOG_TRACE, "rep->fragment_timescale = [%"PRId64"]\n", rep->fragment_timescale); \
867 val = get_val_from_nodes_tab((arg), (cnt), "startNumber"); \
869 int64_t start_number = (int64_t) strtoll(val, NULL, 10); \
870 if (start_number < 0) { \
871 av_log(s, AV_LOG_WARNING, "startNumber invalid, autochanged to 0.\n"); \
874 rep->start_number = rep->first_seq_no = start_number; \
875 av_log(s, AV_LOG_TRACE, "rep->first_seq_no = [%"PRId64"]\n", rep->first_seq_no); \
883 xmlNodePtr adaptionset_node,
884 xmlNodePtr mpd_baseurl_node,
885 xmlNodePtr period_baseurl_node,
886 xmlNodePtr period_segmenttemplate_node,
887 xmlNodePtr period_segmentlist_node,
888 xmlNodePtr fragment_template_node,
889 xmlNodePtr content_component_node,
890 xmlNodePtr adaptionset_baseurl_node,
891 xmlNodePtr adaptionset_segmentlist_node,
892 xmlNodePtr adaptionset_supplementalproperty_node)
898 xmlNodePtr representation_segmenttemplate_node =
NULL;
899 xmlNodePtr representation_baseurl_node =
NULL;
900 xmlNodePtr representation_segmentlist_node =
NULL;
901 xmlNodePtr segmentlists_tab[3];
902 xmlNodePtr fragment_timeline_node =
NULL;
903 xmlNodePtr fragment_templates_tab[5];
905 xmlNodePtr baseurl_nodes[4];
906 xmlNodePtr representation_node = node;
907 char *rep_bandwidth_val;
909 int64_t nb_timeline_segments = 0;
930 if (
c->adaptionset_lang) {
942 rep_bandwidth_val = xmlGetProp(representation_node,
"bandwidth");
943 val = xmlGetProp(representation_node,
"id");
951 baseurl_nodes[0] = mpd_baseurl_node;
952 baseurl_nodes[1] = period_baseurl_node;
953 baseurl_nodes[2] = adaptionset_baseurl_node;
954 baseurl_nodes[3] = representation_baseurl_node;
960 (rep->
id ? strlen(rep->
id) : 0) +
961 (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
964 if (representation_segmenttemplate_node || fragment_template_node || period_segmenttemplate_node) {
965 fragment_timeline_node =
NULL;
966 fragment_templates_tab[0] = representation_segmenttemplate_node;
967 fragment_templates_tab[1] = adaptionset_segmentlist_node;
968 fragment_templates_tab[2] = fragment_template_node;
969 fragment_templates_tab[3] = period_segmenttemplate_node;
970 fragment_templates_tab[4] = period_segmentlist_node;
985 c->max_url_size, rep->
id,
986 rep_bandwidth_val,
val);
1000 c->max_url_size, rep->
id,
1001 rep_bandwidth_val,
val);
1007 if (presentation_timeoffset < 0) {
1009 presentation_timeoffset = 0;
1017 if (adaptionset_supplementalproperty_node) {
1018 char *scheme_id_uri = xmlGetProp(adaptionset_supplementalproperty_node,
"schemeIdUri");
1019 if (scheme_id_uri) {
1020 int is_last_segment_number = !
av_strcasecmp(scheme_id_uri,
"http://dashif.org/guidelines/last-segment-number");
1021 xmlFree(scheme_id_uri);
1022 if (is_last_segment_number) {
1023 val = xmlGetProp(adaptionset_supplementalproperty_node,
"value");
1025 av_log(
s,
AV_LOG_ERROR,
"Missing value attribute in adaptionset_supplementalproperty_node\n");
1036 if (!fragment_timeline_node)
1038 if (!fragment_timeline_node)
1040 if (!fragment_timeline_node)
1042 if (fragment_timeline_node) {
1043 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1044 while (fragment_timeline_node) {
1048 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1051 }
else if (representation_baseurl_node && !representation_segmentlist_node) {
1061 rep->
id, rep_bandwidth_val,
NULL);
1065 }
else if (representation_segmentlist_node) {
1068 xmlNodePtr fragmenturl_node =
NULL;
1069 segmentlists_tab[0] = representation_segmentlist_node;
1070 segmentlists_tab[1] = adaptionset_segmentlist_node;
1071 segmentlists_tab[2] = period_segmentlist_node;
1074 fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
1075 while (fragmenturl_node) {
1077 baseurl_nodes, rep->
id,
1081 fragmenturl_node = xmlNextElementSibling(fragmenturl_node);
1085 if (!fragment_timeline_node)
1087 if (fragment_timeline_node) {
1088 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1089 while (fragment_timeline_node) {
1093 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1098 rep->
id ? rep->
id :
"");
1113 rep->
bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
1116 char *rep_framerate_val = xmlGetProp(representation_node,
"frameRate");
1117 if (rep_framerate_val) {
1121 xmlFree(rep_framerate_val);
1140 if (rep_bandwidth_val)
1141 xmlFree(rep_bandwidth_val);
1155 if (!adaptionset_node) {
1159 c->adaptionset_lang = xmlGetProp(adaptionset_node,
"lang");
1165 xmlNodePtr adaptionset_node,
1166 xmlNodePtr mpd_baseurl_node,
1167 xmlNodePtr period_baseurl_node,
1168 xmlNodePtr period_segmenttemplate_node,
1169 xmlNodePtr period_segmentlist_node)
1173 xmlNodePtr fragment_template_node =
NULL;
1174 xmlNodePtr content_component_node =
NULL;
1175 xmlNodePtr adaptionset_baseurl_node =
NULL;
1176 xmlNodePtr adaptionset_segmentlist_node =
NULL;
1177 xmlNodePtr adaptionset_supplementalproperty_node =
NULL;
1178 xmlNodePtr node =
NULL;
1184 node = xmlFirstElementChild(adaptionset_node);
1187 fragment_template_node = node;
1188 }
else if (!
av_strcasecmp(node->name,
"ContentComponent")) {
1189 content_component_node = node;
1191 adaptionset_baseurl_node = node;
1193 adaptionset_segmentlist_node = node;
1194 }
else if (!
av_strcasecmp(node->name,
"SupplementalProperty")) {
1195 adaptionset_supplementalproperty_node = node;
1200 period_baseurl_node,
1201 period_segmenttemplate_node,
1202 period_segmentlist_node,
1203 fragment_template_node,
1204 content_component_node,
1205 adaptionset_baseurl_node,
1206 adaptionset_segmentlist_node,
1207 adaptionset_supplementalproperty_node);
1211 node = xmlNextElementSibling(node);
1215 xmlFree(
c->adaptionset_lang);
1216 c->adaptionset_lang =
NULL;
1224 node = xmlFirstElementChild(node);
1227 val = xmlNodeGetContent(node);
1232 val = xmlNodeGetContent(node);
1237 val = xmlNodeGetContent(node);
1242 node = xmlNextElementSibling(node);
1258 xmlNodePtr root_element =
NULL;
1259 xmlNodePtr node =
NULL;
1260 xmlNodePtr period_node =
NULL;
1261 xmlNodePtr tmp_node =
NULL;
1262 xmlNodePtr mpd_baseurl_node =
NULL;
1263 xmlNodePtr period_baseurl_node =
NULL;
1264 xmlNodePtr period_segmenttemplate_node =
NULL;
1265 xmlNodePtr period_segmentlist_node =
NULL;
1266 xmlNodePtr adaptionset_node =
NULL;
1267 xmlAttrPtr attr =
NULL;
1269 uint32_t period_duration_sec = 0;
1270 uint32_t period_start_sec = 0;
1297 (filesize = buf.len) == 0) {
1304 doc = xmlReadMemory(buf.str, filesize,
c->base_url,
NULL, 0);
1305 root_element = xmlDocGetRootElement(doc);
1306 node = root_element;
1314 if (node->type != XML_ELEMENT_NODE ||
1317 av_log(
s,
AV_LOG_ERROR,
"Unable to parse '%s' - wrong root node name[%s] type[%d]\n",
url, node->name, (
int)node->type);
1321 val = xmlGetProp(node,
"type");
1331 attr = node->properties;
1333 val = xmlGetProp(node, attr->name);
1341 av_log(
s,
AV_LOG_TRACE,
"c->availability_start_time = [%"PRId64
"]\n",
c->availability_start_time);
1342 }
else if (!
av_strcasecmp(attr->name,
"availabilityEndTime")) {
1348 }
else if (!
av_strcasecmp(attr->name,
"minimumUpdatePeriod")) {
1351 }
else if (!
av_strcasecmp(attr->name,
"timeShiftBufferDepth")) {
1353 av_log(
s,
AV_LOG_TRACE,
"c->time_shift_buffer_depth = [%"PRId64
"]\n",
c->time_shift_buffer_depth);
1357 }
else if (!
av_strcasecmp(attr->name,
"suggestedPresentationDelay")) {
1359 av_log(
s,
AV_LOG_TRACE,
"c->suggested_presentation_delay = [%"PRId64
"]\n",
c->suggested_presentation_delay);
1360 }
else if (!
av_strcasecmp(attr->name,
"mediaPresentationDuration")) {
1362 av_log(
s,
AV_LOG_TRACE,
"c->media_presentation_duration = [%"PRId64
"]\n",
c->media_presentation_duration);
1370 mpd_baseurl_node = xmlCopyNode(tmp_node,1);
1372 mpd_baseurl_node = xmlNewNode(
NULL,
"BaseURL");
1376 node = xmlFirstElementChild(node);
1379 period_duration_sec = 0;
1380 period_start_sec = 0;
1381 attr = node->properties;
1383 val = xmlGetProp(node, attr->name);
1396 if ((period_duration_sec) >= (
c->period_duration)) {
1398 c->period_duration = period_duration_sec;
1399 c->period_start = period_start_sec;
1400 if (
c->period_start > 0)
1401 c->media_presentation_duration =
c->period_duration;
1403 }
else if (!
av_strcasecmp(node->name,
"ProgramInformation")) {
1406 node = xmlNextElementSibling(node);
1414 adaptionset_node = xmlFirstElementChild(period_node);
1415 while (adaptionset_node) {
1417 period_baseurl_node = adaptionset_node;
1418 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentTemplate")) {
1419 period_segmenttemplate_node = adaptionset_node;
1420 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentList")) {
1421 period_segmentlist_node = adaptionset_node;
1422 }
else if (!
av_strcasecmp(adaptionset_node->name,
"AdaptationSet")) {
1425 adaptionset_node = xmlNextElementSibling(adaptionset_node);
1431 xmlFreeNode(mpd_baseurl_node);
1445 int64_t start_time_offset = 0;
1461 }
else if (
c->publish_time > 0 && !
c->availability_start_time) {
1462 if (
c->min_buffer_time) {
1518 if (rep_dest && rep_src ) {
1532 if (rep_dest && rep_src ) {
1556 int n_videos =
c->n_videos;
1558 int n_audios =
c->n_audios;
1560 int n_subtitles =
c->n_subtitles;
1562 char *base_url =
c->base_url;
1570 c->subtitles =
NULL;
1575 if (
c->n_videos != n_videos) {
1577 "new manifest has mismatched no. of video representations, %d -> %d\n",
1578 n_videos,
c->n_videos);
1581 if (
c->n_audios != n_audios) {
1583 "new manifest has mismatched no. of audio representations, %d -> %d\n",
1584 n_audios,
c->n_audios);
1587 if (
c->n_subtitles != n_subtitles) {
1589 "new manifest has mismatched no. of subtitles representations, %d -> %d\n",
1590 n_subtitles,
c->n_subtitles);
1594 for (
i = 0;
i < n_videos;
i++) {
1610 for (
i = 0;
i < n_audios;
i++) {
1632 c->base_url = base_url;
1641 c->n_subtitles = n_subtitles;
1642 c->subtitles = subtitles;
1643 c->n_audios = n_audios;
1645 c->n_videos = n_videos;
1673 }
else if (
c->is_live) {
1742 if (seg->
size >= 0) {
1767 if (seg->
size >= 0) {
1789 static const int max_init_section_size = 1024 * 1024;
1801 "Failed to open an initialization section\n");
1810 sec_size = max_init_section_size;
1813 "Downloading an initialization section of size %"PRId64
"\n",
1816 sec_size =
FFMIN(sec_size, max_init_section_size);
1909 const char *
opts[] = {
1910 "headers",
"user_agent",
"cookies",
"http_proxy",
"referer",
"rw_timeout",
"icy",
NULL };
1911 const char **opt =
opts;
1917 if (buf[0] !=
'\0') {
1935 "A DASH playlist item '%s' referred to an external file '%s'. "
1936 "Opening this file was forbidden for security reasons\n",
1973 if (!avio_ctx_buffer ) {
1990 pls->
ctx->
probesize =
s->probesize > 0 ?
s->probesize : 1024 * 4;
2010 #if FF_API_R_FRAME_RATE
2067 memcpy(dst_data, sd_src->
data, sd_src->
size);
2084 if (first_init_section ==
NULL || n_pls == 0)
2087 url = first_init_section->
url;
2090 for (
i=0;
i<n_pls;
i++) {
2091 if (!pls[
i]->init_section)
2137 c->interrupt_callback = &
s->interrupt_callback;
2157 for (
i = 0;
i <
c->n_videos;
i++) {
2159 if (
i > 0 &&
c->is_init_section_common_video) {
2179 for (
i = 0;
i <
c->n_audios;
i++) {
2181 if (
i > 0 &&
c->is_init_section_common_audio) {
2201 for (
i = 0;
i <
c->n_subtitles;
i++) {
2202 rep =
c->subtitles[
i];
2203 if (
i > 0 &&
c->is_init_section_common_subtitle) {
2232 for (
i = 0;
i <
c->n_videos;
i++) {
2240 for (
i = 0;
i <
c->n_audios;
i++) {
2249 for (
i = 0;
i <
c->n_subtitles;
i++) {
2250 rep =
c->subtitles[
i];
2267 for (
i = 0;
i < n;
i++) {
2271 if (needed && !pls->
ctx) {
2275 for (j = 0; j < n; j++) {
2280 }
else if (!needed && pls->
ctx) {
2300 for (
i = 0;
i <
c->n_videos;
i++) {
2309 for (
i = 0;
i <
c->n_audios;
i++) {
2319 for (
i = 0;
i <
c->n_subtitles;
i++) {
2320 rep =
c->subtitles[
i];
2370 seek_pos_msec, dry_run ?
" (dry)" :
"");
2388 "last_seq_no[%"PRId64
"].\n",
2439 for (
i = 0;
i <
c->n_videos;
i++) {
2443 for (
i = 0;
i <
c->n_audios;
i++) {
2447 for (
i = 0;
i <
c->n_subtitles;
i++) {
2460 if (
av_stristr(p->
buf,
"dash:profile:isoff-on-demand:2011") ||
2474 #define OFFSET(x) offsetof(DASHContext, x)
2475 #define FLAGS AV_OPT_FLAG_DECODING_PARAM
2477 {
"allowed_extensions",
"List of file extensions that dash is allowed to access",
2479 {.str =
"aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
2480 INT_MIN, INT_MAX,
FLAGS},
static double val(void *priv, double ch)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
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 ffio_init_context(AVIOContext *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, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
#define AV_BPRINT_SIZE_UNLIMITED
#define flags(name, subs,...)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
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)
static int dash_read_header(AVFormatContext *s)
#define SET_REPRESENTATION_SEQUENCE_BASE_INFO(arg, cnt)
static enum AVMediaType get_content_type(xmlNodePtr node)
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary **opts, AVDictionary *opts2, int *is_http)
#define MAX_BPRINT_READ_SIZE
#define INITIAL_BUFFER_SIZE
static int is_common_init_section_exist(struct representation **pls, int n_pls)
static const AVOption dash_options[]
static int ishttp(char *url)
static int update_init_section(struct representation *pls)
static struct fragment * get_current_fragment(struct representation *pls)
AVInputFormat ff_dash_demuxer
static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t seek_pos_msec, int flags, int dry_run)
static int read_data(void *opaque, uint8_t *buf, int buf_size)
static int open_demux_for_component(AVFormatContext *s, struct representation *pls)
static int parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr adaptionset_node)
static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representation *rep, xmlNodePtr fragmenturl_node, xmlNodePtr *baseurl_nodes, char *rep_id_val, char *rep_bandwidth_val)
static void recheck_discard_flags(AVFormatContext *s, struct representation **p, int n)
static void move_metadata(AVStream *st, const char *key, char **value)
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 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)
static int copy_init_section(struct representation *rep_dest, struct representation *rep_src)
static const AVClass dash_class
static int64_t get_segment_start_time_based_on_timeline(struct representation *pls, int64_t cur_seq_no)
static uint64_t get_current_time_in_sec(void)
static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls)
static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
static int64_t calc_min_seg_no(AVFormatContext *s, struct representation *pls)
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
static void free_representation(struct representation *pls)
static void free_audio_list(DASHContext *c)
static uint32_t get_duration_insec(AVFormatContext *s, const char *duration)
static void move_timelines(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
static int64_t calc_cur_seg_no(AVFormatContext *s, struct representation *pls)
#define MAX_TIMELINE_SEGMENTS
static void free_subtitle_list(DASHContext *c)
static int dash_close(AVFormatContext *s)
static void close_demux_for_component(struct representation *pls)
static int add_url_size(int *url_size, uint64_t len)
static int64_t seek_data(void *opaque, int64_t offset, int whence)
static int dash_probe(const AVProbeData *p)
static char * get_val_from_nodes_tab(xmlNodePtr *nodes, const int n_nodes, const char *attrname)
static int open_input(DASHContext *c, struct representation *pls, struct fragment *seg)
static xmlNodePtr find_child_node_by_name(xmlNodePtr rootnode, const char *nodename)
static int refresh_manifest(AVFormatContext *s)
static int save_avio_options(AVFormatContext *s)
static int64_t calc_next_seg_no_from_timelines(struct representation *pls, int64_t cur_time)
static void free_fragment(struct fragment **seg)
static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
static void move_segments(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char *datetime)
static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
static struct fragment * get_Fragment(AVFormatContext *s, char *range)
static int read_from_url(struct representation *pls, struct fragment *seg, uint8_t *buf, int buf_size)
#define DEFAULT_MANIFEST_SIZE
static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
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)
static void free_fragment_list(struct representation *pls)
static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representation *rep, xmlNodePtr fragment_timeline_node)
static void free_timelines_list(struct representation *pls)
static void free_video_list(DASHContext *c)
static int resolve_content_path(AVFormatContext *s, const char *url, int *max_url_size, xmlNodePtr *baseurl_nodes, int n_baseurl_nodes)
static int64_t start_time
static int read_header(FFV1Context *f)
static av_cold void cleanup(FlashSV2Context *s)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
@ AVDISCARD_ALL
discard all
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, size_t size)
Allocate new information from stream.
AVProgram * av_new_program(AVFormatContext *s, int id)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int av_probe_input_buffer(AVIOContext *pb, ff_const59 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.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx)
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
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.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
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 AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
static AVRational av_make_q(int num, int den)
Create an AVRational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
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.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_UP
Round toward +infinity.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * av_strdup(const char *s)
Duplicate a string.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
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,...
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().
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
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_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
char * av_strireplace(const char *str, const char *from, const char *to)
Locale-independent strings replace.
#define AV_TIME_BASE
Internal time base represented as integer.
#define LIBAVUTIL_VERSION_INT
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVIOContext * pb
I/O context.
int flags
Flags modifying the (de)muxer behaviour.
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
void * priv_data
Format private data.
int64_t probesize
Maximum size of the data read from input for determining the input container format.
AVStream ** streams
A list of all streams in the file.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
unsigned char * buffer
Start of the buffer.
Callback for checking whether to abort blocking functions.
enum AVPacketSideDataType type
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
This structure contains the data a format has to probe a file.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
New fields can be added to the end with minor version bumps.
Rational number (pair of numerator and denominator).
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
int id
Format-specific stream ID.
int pts_wrap_bits
number of bits in pts (used for wrapping control)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int nb_side_data
The number of elements in the AVStream.side_data array.
AVRational r_frame_rate
Real base framerate of the stream.
int disposition
AV_DISPOSITION_* bit field.
int is_init_section_common_video
int is_init_section_common_audio
uint64_t availability_end_time
struct representation ** videos
struct representation ** subtitles
uint64_t time_shift_buffer_depth
uint64_t media_presentation_duration
int is_init_section_common_subtitle
uint64_t suggested_presentation_delay
uint64_t minimum_update_period
char * allowed_extensions
AVIOInterruptCB * interrupt_callback
uint64_t availability_start_time
struct representation ** audios
uint32_t init_sec_data_len
struct timeline ** timelines
struct fragment * cur_seg
uint32_t init_sec_buf_size
uint32_t init_sec_buf_read_offset
int64_t presentation_timeoffset
struct fragment ** fragments
int64_t fragment_timescale
struct fragment * init_section
int64_t fragment_duration
int64_t av_gettime(void)
Get the current time in microseconds.
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.
static const uint8_t offset[127][2]