Go to the documentation of this file.
22 #include <libxml/parser.h>
31 #define INITIAL_BUFFER_SIZE 32768
32 #define MAX_MANIFEST_SIZE 50 * 1024
33 #define DEFAULT_MANIFEST_SIZE 8 * 1024
173 return ((
val + 0x3F) >> 6) << 6;
196 ret = sscanf(datetime,
"%d-%d-%dT%d:%d:%fZ", &year, &month, &day, &hour, &minute, &second);
201 timeinfo.tm_year = year - 1900;
202 timeinfo.tm_mon = month - 1;
203 timeinfo.tm_mday = day;
204 timeinfo.tm_hour = hour;
205 timeinfo.tm_min = minute;
206 timeinfo.tm_sec = (
int)second;
224 if (*ptr ==
'P' || *ptr ==
'T') {
235 days = (uint32_t)
value;
241 mins = (uint32_t)
value;
244 secs = (uint32_t)
value;
252 return ((days * 24 +
hours) * 60 + mins) * 60 + secs;
267 if (num == cur_seq_no)
279 if (num == cur_seq_no)
372 for (
i = 0;
i <
c->n_videos;
i++) {
383 for (
i = 0;
i <
c->n_audios;
i++) {
394 for (
i = 0;
i <
c->n_subtitles;
i++) {
407 const char *proto_name =
NULL;
414 if (url[6] ==
'+' || url[6] ==
':')
426 if (strcmp(
c->allowed_extensions,
"ALL") && !
av_match_ext(url,
c->allowed_extensions)) {
428 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n"
429 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
438 if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] ==
':')
440 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] ==
':')
442 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
449 char *new_cookies =
NULL;
472 char *rep_bandwidth_val,
481 if (!tmp_str || !tmp_str_2) {
485 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
486 if (baseurl_nodes[
i] &&
487 baseurl_nodes[
i]->children &&
488 baseurl_nodes[
i]->children->type == XML_TEXT_NODE) {
489 text = xmlNodeGetContent(baseurl_nodes[
i]->children);
491 memset(tmp_str, 0, max_url_size);
492 memset(tmp_str_2, 0, max_url_size);
504 url =
av_strireplace(tmp_str,
"$RepresentationID$", (
const char*)rep_id_val);
510 if (rep_bandwidth_val && tmp_str[0] !=
'\0') {
513 url =
av_strireplace(tmp_str,
"$Bandwidth$", (
const char*)rep_bandwidth_val);
529 for (
i = 0;
i < n_nodes; ++
i) {
531 val = xmlGetProp(nodes[
i], attrname);
542 xmlNodePtr node = rootnode;
547 node = xmlFirstElementChild(node);
552 node = xmlNextElementSibling(node);
565 for (
i = 0;
i < 2;
i++) {
566 attr =
i ?
"mimeType" :
"contentType";
567 val = xmlGetProp(node, attr);
592 char *str_end_offset;
593 char *str_offset =
av_strtok(range,
"-", &str_end_offset);
602 xmlNodePtr fragmenturl_node,
603 xmlNodePtr *baseurl_nodes,
605 char *rep_bandwidth_val)
608 char *initialization_val =
NULL;
609 char *media_val =
NULL;
610 char *range_val =
NULL;
613 if (!
av_strcasecmp(fragmenturl_node->name, (
const char *)
"Initialization")) {
614 initialization_val = xmlGetProp(fragmenturl_node,
"sourceURL");
615 range_val = xmlGetProp(fragmenturl_node,
"range");
616 if (initialization_val || range_val) {
619 xmlFree(initialization_val);
631 xmlFree(initialization_val);
635 xmlFree(initialization_val);
638 }
else if (!
av_strcasecmp(fragmenturl_node->name, (
const char *)
"SegmentURL")) {
639 media_val = xmlGetProp(fragmenturl_node,
"media");
640 range_val = xmlGetProp(fragmenturl_node,
"mediaRange");
641 if (media_val || range_val) {
669 xmlNodePtr fragment_timeline_node)
671 xmlAttrPtr attr =
NULL;
674 if (!
av_strcasecmp(fragment_timeline_node->name, (
const char *)
"S")) {
679 attr = fragment_timeline_node->properties;
681 val = xmlGetProp(fragment_timeline_node, attr->name);
684 av_log(
s,
AV_LOG_WARNING,
"parse_manifest_segmenttimeline attr->name = %s val is NULL\n", attr->name);
706 char *tmp_str =
NULL;
708 char *mpdName =
NULL;
709 xmlNodePtr node =
NULL;
710 char *baseurl =
NULL;
711 char *root_url =
NULL;
721 int tmp_max_url_size = strlen(url);
723 for (
i = n_baseurl_nodes-1;
i >= 0 ;
i--) {
724 text = xmlNodeGetContent(baseurl_nodes[
i]);
727 tmp_max_url_size += strlen(text);
735 tmp_max_url_size =
aligned(tmp_max_url_size);
744 size = strlen(mpdName);
750 if (!tmp_str || !path) {
756 for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
757 if (!(node = baseurl_nodes[rootId])) {
760 text = xmlNodeGetContent(node);
768 node = baseurl_nodes[rootId];
769 baseurl = xmlNodeGetContent(node);
772 xmlNodeSetContent(node, root_url);
776 size = strlen(root_url);
777 isRootHttp =
ishttp(root_url);
779 if (root_url[
size - 1] != token) {
784 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
788 text = xmlNodeGetContent(baseurl_nodes[
i]);
790 memset(tmp_str, 0, strlen(tmp_str));
791 if (!
ishttp(text) && isRootHttp) {
794 start = (text[0] == token);
803 memset(p + 1, 0, strlen(p));
805 av_strlcat(tmp_str, text + start, tmp_max_url_size);
806 xmlNodeSetContent(baseurl_nodes[
i], tmp_str);
813 if (tmp_max_url_size > *max_url_size) {
814 *max_url_size = tmp_max_url_size;
825 xmlNodePtr adaptionset_node,
826 xmlNodePtr mpd_baseurl_node,
827 xmlNodePtr period_baseurl_node,
828 xmlNodePtr period_segmenttemplate_node,
829 xmlNodePtr period_segmentlist_node,
830 xmlNodePtr fragment_template_node,
831 xmlNodePtr content_component_node,
832 xmlNodePtr adaptionset_baseurl_node,
833 xmlNodePtr adaptionset_segmentlist_node,
834 xmlNodePtr adaptionset_supplementalproperty_node)
843 xmlNodePtr representation_segmenttemplate_node =
NULL;
844 xmlNodePtr representation_baseurl_node =
NULL;
845 xmlNodePtr representation_segmentlist_node =
NULL;
846 xmlNodePtr segmentlists_tab[3];
847 xmlNodePtr fragment_timeline_node =
NULL;
848 xmlNodePtr fragment_templates_tab[5];
849 char *duration_val =
NULL;
850 char *presentation_timeoffset_val =
NULL;
851 char *startnumber_val =
NULL;
852 char *timescale_val =
NULL;
853 char *initialization_val =
NULL;
854 char *media_val =
NULL;
856 xmlNodePtr baseurl_nodes[4];
857 xmlNodePtr representation_node = node;
858 char *rep_id_val = xmlGetProp(representation_node,
"id");
859 char *rep_bandwidth_val = xmlGetProp(representation_node,
"bandwidth");
860 char *rep_framerate_val = xmlGetProp(representation_node,
"frameRate");
881 if (
c->adaptionset_lang) {
895 baseurl_nodes[0] = mpd_baseurl_node;
896 baseurl_nodes[1] = period_baseurl_node;
897 baseurl_nodes[2] = adaptionset_baseurl_node;
898 baseurl_nodes[3] = representation_baseurl_node;
901 c->max_url_size =
aligned(
c->max_url_size
902 + (rep_id_val ? strlen(rep_id_val) : 0)
903 + (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
907 if (representation_segmenttemplate_node || fragment_template_node || period_segmenttemplate_node) {
908 fragment_timeline_node =
NULL;
909 fragment_templates_tab[0] = representation_segmenttemplate_node;
910 fragment_templates_tab[1] = adaptionset_segmentlist_node;
911 fragment_templates_tab[2] = fragment_template_node;
912 fragment_templates_tab[3] = period_segmenttemplate_node;
913 fragment_templates_tab[4] = period_segmentlist_node;
915 presentation_timeoffset_val =
get_val_from_nodes_tab(fragment_templates_tab, 4,
"presentationTimeOffset");
922 if (initialization_val) {
929 c->max_url_size =
aligned(
c->max_url_size + strlen(initialization_val));
938 xmlFree(initialization_val);
942 c->max_url_size =
aligned(
c->max_url_size + strlen(media_val));
947 if (presentation_timeoffset_val) {
950 xmlFree(presentation_timeoffset_val);
955 xmlFree(duration_val);
960 xmlFree(timescale_val);
962 if (startnumber_val) {
965 xmlFree(startnumber_val);
967 if (adaptionset_supplementalproperty_node) {
968 if (!
av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,
"schemeIdUri"),
"http://dashif.org/guidelines/last-segment-number")) {
969 val = xmlGetProp(adaptionset_supplementalproperty_node,
"value");
971 av_log(
s,
AV_LOG_ERROR,
"Missing value attribute in adaptionset_supplementalproperty_node\n");
981 if (!fragment_timeline_node)
983 if (!fragment_timeline_node)
985 if (!fragment_timeline_node)
987 if (fragment_timeline_node) {
988 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
989 while (fragment_timeline_node) {
994 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
997 }
else if (representation_baseurl_node && !representation_segmentlist_node) {
1011 }
else if (representation_segmentlist_node) {
1014 xmlNodePtr fragmenturl_node =
NULL;
1015 segmentlists_tab[0] = representation_segmentlist_node;
1016 segmentlists_tab[1] = adaptionset_segmentlist_node;
1017 segmentlists_tab[2] = period_segmentlist_node;
1025 xmlFree(duration_val);
1027 if (timescale_val) {
1030 xmlFree(timescale_val);
1032 if (startnumber_val) {
1035 xmlFree(startnumber_val);
1038 fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
1039 while (fragmenturl_node) {
1047 fragmenturl_node = xmlNextElementSibling(fragmenturl_node);
1052 if (!fragment_timeline_node)
1054 if (!fragment_timeline_node)
1056 if (!fragment_timeline_node)
1058 if (fragment_timeline_node) {
1059 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1060 while (fragment_timeline_node) {
1065 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1071 av_log(
s,
AV_LOG_ERROR,
"Unknown format of Representation node id[%s] \n", (
const char *)rep_id_val);
1077 rep->
bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
1078 strncpy(rep->
id, rep_id_val ? rep_id_val :
"",
sizeof(rep->
id));
1096 rep->
rep_idx = subtitle_rep_idx;
1112 xmlFree(rep_id_val);
1113 if (rep_bandwidth_val)
1114 xmlFree(rep_bandwidth_val);
1115 if (rep_framerate_val)
1116 xmlFree(rep_framerate_val);
1125 if (!adaptionset_node) {
1129 c->adaptionset_lang = xmlGetProp(adaptionset_node,
"lang");
1135 xmlNodePtr adaptionset_node,
1136 xmlNodePtr mpd_baseurl_node,
1137 xmlNodePtr period_baseurl_node,
1138 xmlNodePtr period_segmenttemplate_node,
1139 xmlNodePtr period_segmentlist_node)
1143 xmlNodePtr fragment_template_node =
NULL;
1144 xmlNodePtr content_component_node =
NULL;
1145 xmlNodePtr adaptionset_baseurl_node =
NULL;
1146 xmlNodePtr adaptionset_segmentlist_node =
NULL;
1147 xmlNodePtr adaptionset_supplementalproperty_node =
NULL;
1148 xmlNodePtr node =
NULL;
1154 node = xmlFirstElementChild(adaptionset_node);
1156 if (!
av_strcasecmp(node->name, (
const char *)
"SegmentTemplate")) {
1157 fragment_template_node = node;
1158 }
else if (!
av_strcasecmp(node->name, (
const char *)
"ContentComponent")) {
1159 content_component_node = node;
1160 }
else if (!
av_strcasecmp(node->name, (
const char *)
"BaseURL")) {
1161 adaptionset_baseurl_node = node;
1162 }
else if (!
av_strcasecmp(node->name, (
const char *)
"SegmentList")) {
1163 adaptionset_segmentlist_node = node;
1164 }
else if (!
av_strcasecmp(node->name, (
const char *)
"SupplementalProperty")) {
1165 adaptionset_supplementalproperty_node = node;
1166 }
else if (!
av_strcasecmp(node->name, (
const char *)
"Representation")) {
1170 period_baseurl_node,
1171 period_segmenttemplate_node,
1172 period_segmentlist_node,
1173 fragment_template_node,
1174 content_component_node,
1175 adaptionset_baseurl_node,
1176 adaptionset_segmentlist_node,
1177 adaptionset_supplementalproperty_node);
1181 node = xmlNextElementSibling(node);
1193 node = xmlFirstElementChild(node);
1196 val = xmlNodeGetContent(node);
1201 val = xmlNodeGetContent(node);
1206 val = xmlNodeGetContent(node);
1211 node = xmlNextElementSibling(node);
1224 int64_t filesize = 0;
1228 xmlNodePtr root_element =
NULL;
1229 xmlNodePtr node =
NULL;
1230 xmlNodePtr period_node =
NULL;
1231 xmlNodePtr tmp_node =
NULL;
1232 xmlNodePtr mpd_baseurl_node =
NULL;
1233 xmlNodePtr period_baseurl_node =
NULL;
1234 xmlNodePtr period_segmenttemplate_node =
NULL;
1235 xmlNodePtr period_segmentlist_node =
NULL;
1236 xmlNodePtr adaptionset_node =
NULL;
1237 xmlAttrPtr attr =
NULL;
1239 uint32_t period_duration_sec = 0;
1240 uint32_t period_start_sec = 0;
1268 (filesize = buf.len) == 0) {
1275 doc = xmlReadMemory(buf.str, filesize,
c->base_url,
NULL, 0);
1276 root_element = xmlDocGetRootElement(doc);
1277 node = root_element;
1285 if (node->type != XML_ELEMENT_NODE ||
1288 av_log(
s,
AV_LOG_ERROR,
"Unable to parse '%s' - wrong root node name[%s] type[%d]\n",
url, node->name, (
int)node->type);
1292 val = xmlGetProp(node,
"type");
1302 attr = node->properties;
1304 val = xmlGetProp(node, attr->name);
1306 if (!
av_strcasecmp(attr->name, (
const char *)
"availabilityStartTime")) {
1308 av_log(
s,
AV_LOG_TRACE,
"c->availability_start_time = [%"PRId64
"]\n",
c->availability_start_time);
1309 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"availabilityEndTime")) {
1312 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"publishTime")) {
1315 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"minimumUpdatePeriod")) {
1318 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"timeShiftBufferDepth")) {
1320 av_log(
s,
AV_LOG_TRACE,
"c->time_shift_buffer_depth = [%"PRId64
"]\n",
c->time_shift_buffer_depth);
1321 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"minBufferTime")) {
1324 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"suggestedPresentationDelay")) {
1326 av_log(
s,
AV_LOG_TRACE,
"c->suggested_presentation_delay = [%"PRId64
"]\n",
c->suggested_presentation_delay);
1327 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"mediaPresentationDuration")) {
1329 av_log(
s,
AV_LOG_TRACE,
"c->media_presentation_duration = [%"PRId64
"]\n",
c->media_presentation_duration);
1337 mpd_baseurl_node = xmlCopyNode(tmp_node,1);
1339 mpd_baseurl_node = xmlNewNode(
NULL,
"BaseURL");
1343 node = xmlFirstElementChild(node);
1346 period_duration_sec = 0;
1347 period_start_sec = 0;
1348 attr = node->properties;
1350 val = xmlGetProp(node, attr->name);
1353 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"start")) {
1359 if ((period_duration_sec) >= (
c->period_duration)) {
1361 c->period_duration = period_duration_sec;
1362 c->period_start = period_start_sec;
1363 if (
c->period_start > 0)
1364 c->media_presentation_duration =
c->period_duration;
1366 }
else if (!
av_strcasecmp(node->name,
"ProgramInformation")) {
1369 node = xmlNextElementSibling(node);
1377 adaptionset_node = xmlFirstElementChild(period_node);
1378 while (adaptionset_node) {
1379 if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"BaseURL")) {
1380 period_baseurl_node = adaptionset_node;
1381 }
else if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"SegmentTemplate")) {
1382 period_segmenttemplate_node = adaptionset_node;
1383 }
else if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"SegmentList")) {
1384 period_segmentlist_node = adaptionset_node;
1385 }
else if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"AdaptationSet")) {
1388 adaptionset_node = xmlNextElementSibling(adaptionset_node);
1394 xmlFreeNode(mpd_baseurl_node);
1409 int64_t start_time_offset = 0;
1427 }
else if (
c->publish_time > 0 && !
c->availability_start_time) {
1428 if (
c->min_buffer_time) {
1469 num =
c->period_duration / length_of_each_segment;
1485 if (rep_dest && rep_src ) {
1499 if (rep_dest && rep_src ) {
1520 int n_videos =
c->n_videos;
1522 int n_audios =
c->n_audios;
1524 int n_subtitles =
c->n_subtitles;
1526 char *base_url =
c->base_url;
1534 c->subtitles =
NULL;
1539 if (
c->n_videos != n_videos) {
1541 "new manifest has mismatched no. of video representations, %d -> %d\n",
1542 n_videos,
c->n_videos);
1545 if (
c->n_audios != n_audios) {
1547 "new manifest has mismatched no. of audio representations, %d -> %d\n",
1548 n_audios,
c->n_audios);
1551 if (
c->n_subtitles != n_subtitles) {
1553 "new manifest has mismatched no. of subtitles representations, %d -> %d\n",
1554 n_subtitles,
c->n_subtitles);
1558 for (
i = 0;
i < n_videos;
i++) {
1574 for (
i = 0;
i < n_audios;
i++) {
1596 c->base_url = base_url;
1605 c->n_subtitles = n_subtitles;
1606 c->subtitles = subtitles;
1607 c->n_audios = n_audios;
1609 c->n_videos = n_videos;
1616 int64_t min_seq_no = 0;
1617 int64_t max_seq_no = 0;
1637 }
else if (
c->is_live) {
1717 if (seg->
size >= 0) {
1739 static const int max_init_section_size = 1024 * 1024;
1751 "Failed to open an initialization section in playlist %d\n",
1761 sec_size = max_init_section_size;
1764 "Downloading an initialization section of size %"PRId64
"\n",
1767 sec_size =
FFMIN(sec_size, max_init_section_size);
1860 const char *
opts[] = {
1861 "headers",
"user_agent",
"cookies",
"http_proxy",
"referer",
"rw_timeout",
"icy",
NULL };
1862 const char **opt =
opts;
1868 if (buf[0] !=
'\0') {
1888 "A DASH playlist item '%s' referred to an external file '%s'. "
1889 "Opening this file was forbidden for security reasons\n",
1927 if (!avio_ctx_buffer ) {
1944 pls->
ctx->
probesize =
s->probesize > 0 ?
s->probesize : 1024 * 4;
1963 #if FF_API_R_FRAME_RATE
2019 if (first_init_section ==
NULL || n_pls == 0)
2022 url = first_init_section->
url;
2025 for (
i=0;
i<n_pls;
i++) {
2057 c->interrupt_callback = &
s->interrupt_callback;
2068 s->duration = (int64_t)
c->media_presentation_duration *
AV_TIME_BASE;
2077 for (
i = 0;
i <
c->n_videos;
i++) {
2079 if (
i > 0 &&
c->is_init_section_common_video) {
2095 for (
i = 0;
i <
c->n_audios;
i++) {
2097 if (
i > 0 &&
c->is_init_section_common_audio) {
2113 for (
i = 0;
i <
c->n_subtitles;
i++) {
2114 rep =
c->subtitles[
i];
2115 if (
i > 0 &&
c->is_init_section_common_audio) {
2141 for (
i = 0;
i <
c->n_videos;
i++) {
2150 for (
i = 0;
i <
c->n_audios;
i++) {
2163 for (
i = 0;
i <
c->n_subtitles;
i++) {
2164 rep =
c->subtitles[
i];
2185 for (
i = 0;
i < n;
i++) {
2193 for (j = 0; j < n; j++) {
2218 for (
i = 0;
i <
c->n_videos;
i++) {
2227 for (
i = 0;
i <
c->n_audios;
i++) {
2237 for (
i = 0;
i <
c->n_subtitles;
i++) {
2238 rep =
c->subtitles[
i];
2287 seek_pos_msec, pls->
rep_idx, dry_run ?
" (dry)" :
"");
2305 "last_seq_no[%"PRId64
"], playlist %d.\n",
2355 for (
i = 0;
i <
c->n_videos;
i++) {
2359 for (
i = 0;
i <
c->n_audios;
i++) {
2363 for (
i = 0;
i <
c->n_subtitles;
i++) {
2376 if (
av_stristr(p->
buf,
"dash:profile:isoff-on-demand:2011") ||
2390 #define OFFSET(x) offsetof(DASHContext, x)
2391 #define FLAGS AV_OPT_FLAG_DECODING_PARAM
2393 {
"allowed_extensions",
"List of file extensions that dash is allowed to access",
2395 {.str =
"aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
2396 INT_MIN, INT_MAX,
FLAGS},
static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls)
static void close_demux_for_component(struct representation *pls)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
static int64_t calc_next_seg_no_from_timelines(struct representation *pls, int64_t cur_time)
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)
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
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static uint64_t get_current_time_in_sec(void)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
static int ishttp(char *url)
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.
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 av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_cold int end(AVCodecContext *avctx)
static int dash_close(AVFormatContext *s)
static av_cold void cleanup(FlashSV2Context *s)
AVStream ** streams
A list of all streams in the file.
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 size of the data read from input for determining the input container format.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
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.
uint64_t availability_end_time
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
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
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)
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
@ AV_ROUND_UP
Round toward +infinity.
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
AVProgram * av_new_program(AVFormatContext *s, int id)
static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char *datetime)
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...
uint64_t suggested_presentation_delay
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)
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)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
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.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static uint32_t get_duration_insec(AVFormatContext *s, const char *duration)
struct representation ** videos
#define INITIAL_BUFFER_SIZE
uint32_t init_sec_buf_size
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
@ AVDISCARD_ALL
discard all
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally hours
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
#define MAX_MANIFEST_SIZE
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Rational number (pair of numerator and denominator).
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
uint64_t minimum_update_period
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary *opts, AVDictionary *opts2, int *is_http)
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
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)
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.
uint64_t time_shift_buffer_depth
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)
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))
#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.
uint64_t media_presentation_duration
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
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.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static int copy_init_section(struct representation *rep_dest, struct representation *rep_src)
uint64_t availability_start_time
AVInputFormat ff_dash_demuxer
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.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
#define AV_LOG_INFO
Standard information.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
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
static void free_subtitle_list(DASHContext *c)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static int dash_probe(const AVProbeData *p)
#define AV_TIME_BASE
Internal time base represented as integer.
struct representation ** audios
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
@ AV_ROUND_DOWN
Round toward -infinity.
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.
static int save_avio_options(AVFormatContext *s)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
int id
Format-specific stream ID.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
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 struct fragment * get_Fragment(char *range)
static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representation *rep, xmlNodePtr fragment_timeline_node)
void 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.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
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
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.
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)
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
char * av_strdup(const char *s)
Duplicate a string.
unsigned char * buffer
Start of the buffer.
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.
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.
#define flags(name, subs,...)
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.
int pts_wrap_bits
number of bits in pts (used for wrapping control)
struct fragment ** fragments
void * priv_data
Format private data.
static const AVClass dash_class
int64_t presentation_timeoffset
#define DEFAULT_MANIFEST_SIZE
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx)