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
170 return ((
val + 0x3F) >> 6) << 6;
193 ret = sscanf(datetime,
"%d-%d-%dT%d:%d:%fZ", &year, &month, &day, &hour, &minute, &second);
198 timeinfo.tm_year = year - 1900;
199 timeinfo.tm_mon = month - 1;
200 timeinfo.tm_mday = day;
201 timeinfo.tm_hour = hour;
202 timeinfo.tm_min = minute;
203 timeinfo.tm_sec = (
int)second;
221 if (*ptr ==
'P' || *ptr ==
'T') {
232 days = (uint32_t)
value;
235 hours = (uint32_t)
value;
238 mins = (uint32_t)
value;
241 secs = (uint32_t)
value;
249 return ((days * 24 + hours) * 60 + mins) * 60 + secs;
264 if (num == cur_seq_no)
276 if (num == cur_seq_no)
371 for (
i = 0;
i <
c->n_videos;
i++) {
382 for (
i = 0;
i <
c->n_audios;
i++) {
393 for (
i = 0;
i <
c->n_subtitles;
i++) {
406 const char *proto_name =
NULL;
410 if (url[6] ==
'+' || url[6] ==
':')
422 if (strcmp(
c->allowed_extensions,
"ALL") && !
av_match_ext(url,
c->allowed_extensions)) {
424 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n"
425 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
434 if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] ==
':')
436 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] ==
':')
438 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
447 char *new_cookies =
NULL;
470 char *rep_bandwidth_val,
481 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
482 if (baseurl_nodes[
i] &&
483 baseurl_nodes[
i]->children &&
484 baseurl_nodes[
i]->children->type == XML_TEXT_NODE) {
485 text = xmlNodeGetContent(baseurl_nodes[
i]->children);
487 memset(tmp_str, 0, max_url_size);
504 if (rep_bandwidth_val && tmp_str[0] !=
'\0') {
522 for (
i = 0;
i < n_nodes; ++
i) {
524 val = xmlGetProp(nodes[
i], attrname);
535 xmlNodePtr node = rootnode;
540 node = xmlFirstElementChild(node);
545 node = xmlNextElementSibling(node);
558 for (
i = 0;
i < 2;
i++) {
559 attr =
i ?
"mimeType" :
"contentType";
560 val = xmlGetProp(node, attr);
585 char *str_end_offset;
586 char *str_offset =
av_strtok(range,
"-", &str_end_offset);
595 xmlNodePtr fragmenturl_node,
596 xmlNodePtr *baseurl_nodes,
598 char *rep_bandwidth_val)
601 char *initialization_val =
NULL;
602 char *media_val =
NULL;
603 char *range_val =
NULL;
607 if (!
av_strcasecmp(fragmenturl_node->name,
"Initialization")) {
608 initialization_val = xmlGetProp(fragmenturl_node,
"sourceURL");
609 range_val = xmlGetProp(fragmenturl_node,
"range");
610 if (initialization_val || range_val) {
615 xmlFree(initialization_val);
623 xmlFree(initialization_val);
629 }
else if (!
av_strcasecmp(fragmenturl_node->name,
"SegmentURL")) {
630 media_val = xmlGetProp(fragmenturl_node,
"media");
631 range_val = xmlGetProp(fragmenturl_node,
"mediaRange");
632 if (media_val || range_val) {
661 xmlNodePtr fragment_timeline_node)
663 xmlAttrPtr attr =
NULL;
672 attr = fragment_timeline_node->properties;
674 val = xmlGetProp(fragment_timeline_node, attr->name);
677 av_log(
s,
AV_LOG_WARNING,
"parse_manifest_segmenttimeline attr->name = %s val is NULL\n", attr->name);
703 char *tmp_str =
NULL;
705 char *mpdName =
NULL;
706 xmlNodePtr node =
NULL;
707 char *baseurl =
NULL;
708 char *root_url =
NULL;
718 int tmp_max_url_size = strlen(url);
720 for (
i = n_baseurl_nodes-1;
i >= 0 ;
i--) {
721 text = xmlNodeGetContent(baseurl_nodes[
i]);
724 tmp_max_url_size += strlen(text);
732 tmp_max_url_size =
aligned(tmp_max_url_size);
741 size = strlen(mpdName);
747 if (!tmp_str || !path) {
753 for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
754 if (!(node = baseurl_nodes[rootId])) {
757 text = xmlNodeGetContent(node);
765 node = baseurl_nodes[rootId];
766 baseurl = xmlNodeGetContent(node);
769 xmlNodeSetContent(node, root_url);
773 size = strlen(root_url);
774 isRootHttp =
ishttp(root_url);
776 if (
size > 0 && root_url[
size - 1] != token) {
781 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
785 text = xmlNodeGetContent(baseurl_nodes[
i]);
787 memset(tmp_str, 0, strlen(tmp_str));
788 if (!
ishttp(text) && isRootHttp) {
791 start = (text[0] == token);
800 memset(p + 1, 0, strlen(p));
802 av_strlcat(tmp_str, text + start, tmp_max_url_size);
803 xmlNodeSetContent(baseurl_nodes[
i], tmp_str);
810 if (tmp_max_url_size > *max_url_size) {
811 *max_url_size = tmp_max_url_size;
822 xmlNodePtr adaptionset_node,
823 xmlNodePtr mpd_baseurl_node,
824 xmlNodePtr period_baseurl_node,
825 xmlNodePtr period_segmenttemplate_node,
826 xmlNodePtr period_segmentlist_node,
827 xmlNodePtr fragment_template_node,
828 xmlNodePtr content_component_node,
829 xmlNodePtr adaptionset_baseurl_node,
830 xmlNodePtr adaptionset_segmentlist_node,
831 xmlNodePtr adaptionset_supplementalproperty_node)
837 xmlNodePtr representation_segmenttemplate_node =
NULL;
838 xmlNodePtr representation_baseurl_node =
NULL;
839 xmlNodePtr representation_segmentlist_node =
NULL;
840 xmlNodePtr segmentlists_tab[3];
841 xmlNodePtr fragment_timeline_node =
NULL;
842 xmlNodePtr fragment_templates_tab[5];
844 xmlNodePtr baseurl_nodes[4];
845 xmlNodePtr representation_node = node;
846 char *rep_bandwidth_val;
868 if (
c->adaptionset_lang) {
880 rep_bandwidth_val = xmlGetProp(representation_node,
"bandwidth");
881 val = xmlGetProp(representation_node,
"id");
889 baseurl_nodes[0] = mpd_baseurl_node;
890 baseurl_nodes[1] = period_baseurl_node;
891 baseurl_nodes[2] = adaptionset_baseurl_node;
892 baseurl_nodes[3] = representation_baseurl_node;
895 c->max_url_size =
aligned(
c->max_url_size
896 + (rep->
id ? strlen(rep->
id) : 0)
897 + (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
898 if (ret ==
AVERROR(ENOMEM) || ret == 0)
900 if (representation_segmenttemplate_node || fragment_template_node || period_segmenttemplate_node) {
901 fragment_timeline_node =
NULL;
902 fragment_templates_tab[0] = representation_segmenttemplate_node;
903 fragment_templates_tab[1] = adaptionset_segmentlist_node;
904 fragment_templates_tab[2] = fragment_template_node;
905 fragment_templates_tab[3] = period_segmenttemplate_node;
906 fragment_templates_tab[4] = period_segmentlist_node;
915 c->max_url_size =
aligned(
c->max_url_size + strlen(
val));
917 c->max_url_size, rep->
id,
918 rep_bandwidth_val,
val);
926 c->max_url_size =
aligned(
c->max_url_size + strlen(
val));
928 c->max_url_size, rep->
id,
929 rep_bandwidth_val,
val);
956 if (adaptionset_supplementalproperty_node) {
957 if (!
av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,
"schemeIdUri"),
"http://dashif.org/guidelines/last-segment-number")) {
958 val = xmlGetProp(adaptionset_supplementalproperty_node,
"value");
960 av_log(
s,
AV_LOG_ERROR,
"Missing value attribute in adaptionset_supplementalproperty_node\n");
970 if (!fragment_timeline_node)
972 if (!fragment_timeline_node)
974 if (!fragment_timeline_node)
976 if (fragment_timeline_node) {
977 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
978 while (fragment_timeline_node) {
982 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
985 }
else if (representation_baseurl_node && !representation_segmentlist_node) {
995 rep->
id, rep_bandwidth_val,
NULL);
999 }
else if (representation_segmentlist_node) {
1002 xmlNodePtr fragmenturl_node =
NULL;
1003 segmentlists_tab[0] = representation_segmentlist_node;
1004 segmentlists_tab[1] = adaptionset_segmentlist_node;
1005 segmentlists_tab[2] = period_segmentlist_node;
1026 fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
1027 while (fragmenturl_node) {
1029 baseurl_nodes, rep->
id,
1033 fragmenturl_node = xmlNextElementSibling(fragmenturl_node);
1037 if (!fragment_timeline_node)
1039 if (fragment_timeline_node) {
1040 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1041 while (fragment_timeline_node) {
1045 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1050 rep->
id ? rep->
id :
"");
1056 rep->
bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
1059 char *rep_framerate_val = xmlGetProp(representation_node,
"frameRate");
1060 if (rep_framerate_val) {
1064 xmlFree(rep_framerate_val);
1083 if (rep_bandwidth_val)
1084 xmlFree(rep_bandwidth_val);
1098 if (!adaptionset_node) {
1102 c->adaptionset_lang = xmlGetProp(adaptionset_node,
"lang");
1108 xmlNodePtr adaptionset_node,
1109 xmlNodePtr mpd_baseurl_node,
1110 xmlNodePtr period_baseurl_node,
1111 xmlNodePtr period_segmenttemplate_node,
1112 xmlNodePtr period_segmentlist_node)
1116 xmlNodePtr fragment_template_node =
NULL;
1117 xmlNodePtr content_component_node =
NULL;
1118 xmlNodePtr adaptionset_baseurl_node =
NULL;
1119 xmlNodePtr adaptionset_segmentlist_node =
NULL;
1120 xmlNodePtr adaptionset_supplementalproperty_node =
NULL;
1121 xmlNodePtr node =
NULL;
1127 node = xmlFirstElementChild(adaptionset_node);
1130 fragment_template_node = node;
1131 }
else if (!
av_strcasecmp(node->name,
"ContentComponent")) {
1132 content_component_node = node;
1134 adaptionset_baseurl_node = node;
1136 adaptionset_segmentlist_node = node;
1137 }
else if (!
av_strcasecmp(node->name,
"SupplementalProperty")) {
1138 adaptionset_supplementalproperty_node = node;
1143 period_baseurl_node,
1144 period_segmenttemplate_node,
1145 period_segmentlist_node,
1146 fragment_template_node,
1147 content_component_node,
1148 adaptionset_baseurl_node,
1149 adaptionset_segmentlist_node,
1150 adaptionset_supplementalproperty_node);
1154 node = xmlNextElementSibling(node);
1158 xmlFree(
c->adaptionset_lang);
1159 c->adaptionset_lang =
NULL;
1167 node = xmlFirstElementChild(node);
1170 val = xmlNodeGetContent(node);
1175 val = xmlNodeGetContent(node);
1180 val = xmlNodeGetContent(node);
1185 node = xmlNextElementSibling(node);
1201 xmlNodePtr root_element =
NULL;
1202 xmlNodePtr node =
NULL;
1203 xmlNodePtr period_node =
NULL;
1204 xmlNodePtr tmp_node =
NULL;
1205 xmlNodePtr mpd_baseurl_node =
NULL;
1206 xmlNodePtr period_baseurl_node =
NULL;
1207 xmlNodePtr period_segmenttemplate_node =
NULL;
1208 xmlNodePtr period_segmentlist_node =
NULL;
1209 xmlNodePtr adaptionset_node =
NULL;
1210 xmlAttrPtr attr =
NULL;
1212 uint32_t period_duration_sec = 0;
1213 uint32_t period_start_sec = 0;
1240 (filesize = buf.len) == 0) {
1247 doc = xmlReadMemory(buf.str, filesize,
c->base_url,
NULL, 0);
1248 root_element = xmlDocGetRootElement(doc);
1249 node = root_element;
1257 if (node->type != XML_ELEMENT_NODE ||
1260 av_log(
s,
AV_LOG_ERROR,
"Unable to parse '%s' - wrong root node name[%s] type[%d]\n",
url, node->name, (
int)node->type);
1264 val = xmlGetProp(node,
"type");
1274 attr = node->properties;
1276 val = xmlGetProp(node, attr->name);
1280 av_log(
s,
AV_LOG_TRACE,
"c->availability_start_time = [%"PRId64
"]\n",
c->availability_start_time);
1281 }
else if (!
av_strcasecmp(attr->name,
"availabilityEndTime")) {
1287 }
else if (!
av_strcasecmp(attr->name,
"minimumUpdatePeriod")) {
1290 }
else if (!
av_strcasecmp(attr->name,
"timeShiftBufferDepth")) {
1292 av_log(
s,
AV_LOG_TRACE,
"c->time_shift_buffer_depth = [%"PRId64
"]\n",
c->time_shift_buffer_depth);
1296 }
else if (!
av_strcasecmp(attr->name,
"suggestedPresentationDelay")) {
1298 av_log(
s,
AV_LOG_TRACE,
"c->suggested_presentation_delay = [%"PRId64
"]\n",
c->suggested_presentation_delay);
1299 }
else if (!
av_strcasecmp(attr->name,
"mediaPresentationDuration")) {
1301 av_log(
s,
AV_LOG_TRACE,
"c->media_presentation_duration = [%"PRId64
"]\n",
c->media_presentation_duration);
1309 mpd_baseurl_node = xmlCopyNode(tmp_node,1);
1311 mpd_baseurl_node = xmlNewNode(
NULL,
"BaseURL");
1315 node = xmlFirstElementChild(node);
1318 period_duration_sec = 0;
1319 period_start_sec = 0;
1320 attr = node->properties;
1322 val = xmlGetProp(node, attr->name);
1331 if ((period_duration_sec) >= (
c->period_duration)) {
1333 c->period_duration = period_duration_sec;
1334 c->period_start = period_start_sec;
1335 if (
c->period_start > 0)
1336 c->media_presentation_duration =
c->period_duration;
1338 }
else if (!
av_strcasecmp(node->name,
"ProgramInformation")) {
1341 node = xmlNextElementSibling(node);
1349 adaptionset_node = xmlFirstElementChild(period_node);
1350 while (adaptionset_node) {
1352 period_baseurl_node = adaptionset_node;
1353 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentTemplate")) {
1354 period_segmenttemplate_node = adaptionset_node;
1355 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentList")) {
1356 period_segmentlist_node = adaptionset_node;
1357 }
else if (!
av_strcasecmp(adaptionset_node->name,
"AdaptationSet")) {
1360 adaptionset_node = xmlNextElementSibling(adaptionset_node);
1366 xmlFreeNode(mpd_baseurl_node);
1380 int64_t start_time_offset = 0;
1398 }
else if (
c->publish_time > 0 && !
c->availability_start_time) {
1399 if (
c->min_buffer_time) {
1440 num =
c->period_duration / length_of_each_segment;
1456 if (rep_dest && rep_src ) {
1470 if (rep_dest && rep_src ) {
1491 int n_videos =
c->n_videos;
1493 int n_audios =
c->n_audios;
1495 int n_subtitles =
c->n_subtitles;
1497 char *base_url =
c->base_url;
1505 c->subtitles =
NULL;
1510 if (
c->n_videos != n_videos) {
1512 "new manifest has mismatched no. of video representations, %d -> %d\n",
1513 n_videos,
c->n_videos);
1516 if (
c->n_audios != n_audios) {
1518 "new manifest has mismatched no. of audio representations, %d -> %d\n",
1519 n_audios,
c->n_audios);
1522 if (
c->n_subtitles != n_subtitles) {
1524 "new manifest has mismatched no. of subtitles representations, %d -> %d\n",
1525 n_subtitles,
c->n_subtitles);
1529 for (
i = 0;
i < n_videos;
i++) {
1545 for (
i = 0;
i < n_audios;
i++) {
1567 c->base_url = base_url;
1576 c->n_subtitles = n_subtitles;
1577 c->subtitles = subtitles;
1578 c->n_audios = n_audios;
1580 c->n_videos = n_videos;
1608 }
else if (
c->is_live) {
1696 if (seg->
size >= 0) {
1718 static const int max_init_section_size = 1024 * 1024;
1730 "Failed to open an initialization section\n");
1739 sec_size = max_init_section_size;
1742 "Downloading an initialization section of size %"PRId64
"\n",
1745 sec_size =
FFMIN(sec_size, max_init_section_size);
1838 const char *
opts[] = {
1839 "headers",
"user_agent",
"cookies",
"http_proxy",
"referer",
"rw_timeout",
"icy",
NULL };
1840 const char **opt =
opts;
1846 if (buf[0] !=
'\0') {
1864 "A DASH playlist item '%s' referred to an external file '%s'. "
1865 "Opening this file was forbidden for security reasons\n",
1902 if (!avio_ctx_buffer ) {
1916 pls->
ctx->
probesize =
s->probesize > 0 ?
s->probesize : 1024 * 4;
1936 #if FF_API_R_FRAME_RATE
1989 memcpy(dst_data, sd_src->
data, sd_src->
size);
2006 if (first_init_section ==
NULL || n_pls == 0)
2009 url = first_init_section->
url;
2012 for (
i=0;
i<n_pls;
i++) {
2013 if (!pls[
i]->init_section)
2059 c->interrupt_callback = &
s->interrupt_callback;
2079 for (
i = 0;
i <
c->n_videos;
i++) {
2081 if (
i > 0 &&
c->is_init_section_common_video) {
2097 for (
i = 0;
i <
c->n_audios;
i++) {
2099 if (
i > 0 &&
c->is_init_section_common_audio) {
2115 for (
i = 0;
i <
c->n_subtitles;
i++) {
2116 rep =
c->subtitles[
i];
2117 if (
i > 0 &&
c->is_init_section_common_subtitle) {
2142 for (
i = 0;
i <
c->n_videos;
i++) {
2150 for (
i = 0;
i <
c->n_audios;
i++) {
2159 for (
i = 0;
i <
c->n_subtitles;
i++) {
2160 rep =
c->subtitles[
i];
2177 for (
i = 0;
i < n;
i++) {
2181 if (needed && !pls->
ctx) {
2185 for (j = 0; j < n; j++) {
2190 }
else if (!needed && pls->
ctx) {
2210 for (
i = 0;
i <
c->n_videos;
i++) {
2219 for (
i = 0;
i <
c->n_audios;
i++) {
2229 for (
i = 0;
i <
c->n_subtitles;
i++) {
2230 rep =
c->subtitles[
i];
2280 seek_pos_msec, dry_run ?
" (dry)" :
"");
2298 "last_seq_no[%"PRId64
"].\n",
2348 for (
i = 0;
i <
c->n_videos;
i++) {
2352 for (
i = 0;
i <
c->n_audios;
i++) {
2356 for (
i = 0;
i <
c->n_subtitles;
i++) {
2369 if (
av_stristr(p->
buf,
"dash:profile:isoff-on-demand:2011") ||
2383 #define OFFSET(x) offsetof(DASHContext, x)
2384 #define FLAGS AV_OPT_FLAG_DECODING_PARAM
2386 {
"allowed_extensions",
"List of file extensions that dash is allowed to access",
2388 {.str =
"aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
2389 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_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
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_open_whitelist(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
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)
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 int aligned(int val)
static uint64_t get_current_time_in_sec(void)
static struct fragment * get_Fragment(char *range)
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)
static void free_subtitle_list(DASHContext *c)
static int dash_close(AVFormatContext *s)
static void close_demux_for_component(struct representation *pls)
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 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_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]