Go to the documentation of this file.
22 #include <libxml/parser.h>
32 #define INITIAL_BUFFER_SIZE 32768
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;
411 if (url[6] ==
'+' || url[6] ==
':')
421 proto_name_len = strlen(proto_name);
424 if (strcmp(
c->allowed_extensions,
"ALL") && !
av_match_ext(url,
c->allowed_extensions)) {
426 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n"
427 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
436 if (!strncmp(proto_name, url, proto_name_len) && url[proto_name_len] ==
':')
438 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, proto_name_len) && url[7 + proto_name_len] ==
':')
440 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
449 char *new_cookies =
NULL;
472 char *rep_bandwidth_val,
483 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
484 if (baseurl_nodes[
i] &&
485 baseurl_nodes[
i]->children &&
486 baseurl_nodes[
i]->children->type == XML_TEXT_NODE) {
487 text = xmlNodeGetContent(baseurl_nodes[
i]->children);
489 memset(tmp_str, 0, max_url_size);
506 if (rep_bandwidth_val && tmp_str[0] !=
'\0') {
524 for (
i = 0;
i < n_nodes; ++
i) {
526 val = xmlGetProp(nodes[
i], attrname);
537 xmlNodePtr node = rootnode;
542 node = xmlFirstElementChild(node);
547 node = xmlNextElementSibling(node);
560 for (
i = 0;
i < 2;
i++) {
561 attr =
i ?
"mimeType" :
"contentType";
562 val = xmlGetProp(node, attr);
587 char *str_end_offset;
588 char *str_offset =
av_strtok(range,
"-", &str_end_offset);
597 xmlNodePtr fragmenturl_node,
598 xmlNodePtr *baseurl_nodes,
600 char *rep_bandwidth_val)
603 char *initialization_val =
NULL;
604 char *media_val =
NULL;
605 char *range_val =
NULL;
609 if (!
av_strcasecmp(fragmenturl_node->name,
"Initialization")) {
610 initialization_val = xmlGetProp(fragmenturl_node,
"sourceURL");
611 range_val = xmlGetProp(fragmenturl_node,
"range");
612 if (initialization_val || range_val) {
617 xmlFree(initialization_val);
625 xmlFree(initialization_val);
631 }
else if (!
av_strcasecmp(fragmenturl_node->name,
"SegmentURL")) {
632 media_val = xmlGetProp(fragmenturl_node,
"media");
633 range_val = xmlGetProp(fragmenturl_node,
"mediaRange");
634 if (media_val || range_val) {
663 xmlNodePtr fragment_timeline_node)
665 xmlAttrPtr attr =
NULL;
674 attr = fragment_timeline_node->properties;
676 val = xmlGetProp(fragment_timeline_node, attr->name);
679 av_log(
s,
AV_LOG_WARNING,
"parse_manifest_segmenttimeline attr->name = %s val is NULL\n", attr->name);
705 char *tmp_str =
NULL;
707 char *mpdName =
NULL;
708 xmlNodePtr node =
NULL;
709 char *baseurl =
NULL;
710 char *root_url =
NULL;
720 int tmp_max_url_size = strlen(url);
722 for (
i = n_baseurl_nodes-1;
i >= 0 ;
i--) {
723 text = xmlNodeGetContent(baseurl_nodes[
i]);
726 tmp_max_url_size += strlen(text);
734 tmp_max_url_size =
aligned(tmp_max_url_size);
743 size = strlen(mpdName);
749 if (!tmp_str || !path) {
755 for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
756 if (!(node = baseurl_nodes[rootId])) {
759 text = xmlNodeGetContent(node);
767 node = baseurl_nodes[rootId];
768 baseurl = xmlNodeGetContent(node);
771 xmlNodeSetContent(node, root_url);
775 size = strlen(root_url);
776 isRootHttp =
ishttp(root_url);
778 if (
size > 0 && root_url[
size - 1] != token) {
783 for (
i = 0;
i < n_baseurl_nodes; ++
i) {
787 text = xmlNodeGetContent(baseurl_nodes[
i]);
789 memset(tmp_str, 0, strlen(tmp_str));
790 if (!
ishttp(text) && isRootHttp) {
793 start = (text[0] == token);
802 memset(p + 1, 0, strlen(p));
804 av_strlcat(tmp_str, text + start, tmp_max_url_size);
805 xmlNodeSetContent(baseurl_nodes[
i], tmp_str);
812 if (tmp_max_url_size > *max_url_size) {
813 *max_url_size = tmp_max_url_size;
824 xmlNodePtr adaptionset_node,
825 xmlNodePtr mpd_baseurl_node,
826 xmlNodePtr period_baseurl_node,
827 xmlNodePtr period_segmenttemplate_node,
828 xmlNodePtr period_segmentlist_node,
829 xmlNodePtr fragment_template_node,
830 xmlNodePtr content_component_node,
831 xmlNodePtr adaptionset_baseurl_node,
832 xmlNodePtr adaptionset_segmentlist_node,
833 xmlNodePtr adaptionset_supplementalproperty_node)
839 xmlNodePtr representation_segmenttemplate_node =
NULL;
840 xmlNodePtr representation_baseurl_node =
NULL;
841 xmlNodePtr representation_segmentlist_node =
NULL;
842 xmlNodePtr segmentlists_tab[3];
843 xmlNodePtr fragment_timeline_node =
NULL;
844 xmlNodePtr fragment_templates_tab[5];
846 xmlNodePtr baseurl_nodes[4];
847 xmlNodePtr representation_node = node;
848 char *rep_bandwidth_val;
870 if (
c->adaptionset_lang) {
882 rep_bandwidth_val = xmlGetProp(representation_node,
"bandwidth");
883 val = xmlGetProp(representation_node,
"id");
891 baseurl_nodes[0] = mpd_baseurl_node;
892 baseurl_nodes[1] = period_baseurl_node;
893 baseurl_nodes[2] = adaptionset_baseurl_node;
894 baseurl_nodes[3] = representation_baseurl_node;
897 c->max_url_size =
aligned(
c->max_url_size
898 + (rep->
id ? strlen(rep->
id) : 0)
899 + (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
902 if (representation_segmenttemplate_node || fragment_template_node || period_segmenttemplate_node) {
903 fragment_timeline_node =
NULL;
904 fragment_templates_tab[0] = representation_segmenttemplate_node;
905 fragment_templates_tab[1] = adaptionset_segmentlist_node;
906 fragment_templates_tab[2] = fragment_template_node;
907 fragment_templates_tab[3] = period_segmenttemplate_node;
908 fragment_templates_tab[4] = period_segmentlist_node;
917 c->max_url_size =
aligned(
c->max_url_size + strlen(
val));
919 c->max_url_size, rep->
id,
920 rep_bandwidth_val,
val);
928 c->max_url_size =
aligned(
c->max_url_size + strlen(
val));
930 c->max_url_size, rep->
id,
931 rep_bandwidth_val,
val);
958 if (adaptionset_supplementalproperty_node) {
959 if (!
av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,
"schemeIdUri"),
"http://dashif.org/guidelines/last-segment-number")) {
960 val = xmlGetProp(adaptionset_supplementalproperty_node,
"value");
962 av_log(
s,
AV_LOG_ERROR,
"Missing value attribute in adaptionset_supplementalproperty_node\n");
972 if (!fragment_timeline_node)
974 if (!fragment_timeline_node)
976 if (!fragment_timeline_node)
978 if (fragment_timeline_node) {
979 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
980 while (fragment_timeline_node) {
984 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
987 }
else if (representation_baseurl_node && !representation_segmentlist_node) {
997 rep->
id, rep_bandwidth_val,
NULL);
1001 }
else if (representation_segmentlist_node) {
1004 xmlNodePtr fragmenturl_node =
NULL;
1005 segmentlists_tab[0] = representation_segmentlist_node;
1006 segmentlists_tab[1] = adaptionset_segmentlist_node;
1007 segmentlists_tab[2] = period_segmentlist_node;
1028 fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
1029 while (fragmenturl_node) {
1031 baseurl_nodes, rep->
id,
1035 fragmenturl_node = xmlNextElementSibling(fragmenturl_node);
1039 if (!fragment_timeline_node)
1041 if (fragment_timeline_node) {
1042 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1043 while (fragment_timeline_node) {
1047 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1052 rep->
id ? rep->
id :
"");
1058 rep->
bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
1061 char *rep_framerate_val = xmlGetProp(representation_node,
"frameRate");
1062 if (rep_framerate_val) {
1066 xmlFree(rep_framerate_val);
1085 if (rep_bandwidth_val)
1086 xmlFree(rep_bandwidth_val);
1100 if (!adaptionset_node) {
1104 c->adaptionset_lang = xmlGetProp(adaptionset_node,
"lang");
1110 xmlNodePtr adaptionset_node,
1111 xmlNodePtr mpd_baseurl_node,
1112 xmlNodePtr period_baseurl_node,
1113 xmlNodePtr period_segmenttemplate_node,
1114 xmlNodePtr period_segmentlist_node)
1118 xmlNodePtr fragment_template_node =
NULL;
1119 xmlNodePtr content_component_node =
NULL;
1120 xmlNodePtr adaptionset_baseurl_node =
NULL;
1121 xmlNodePtr adaptionset_segmentlist_node =
NULL;
1122 xmlNodePtr adaptionset_supplementalproperty_node =
NULL;
1123 xmlNodePtr node =
NULL;
1129 node = xmlFirstElementChild(adaptionset_node);
1132 fragment_template_node = node;
1133 }
else if (!
av_strcasecmp(node->name,
"ContentComponent")) {
1134 content_component_node = node;
1136 adaptionset_baseurl_node = node;
1138 adaptionset_segmentlist_node = node;
1139 }
else if (!
av_strcasecmp(node->name,
"SupplementalProperty")) {
1140 adaptionset_supplementalproperty_node = node;
1145 period_baseurl_node,
1146 period_segmenttemplate_node,
1147 period_segmentlist_node,
1148 fragment_template_node,
1149 content_component_node,
1150 adaptionset_baseurl_node,
1151 adaptionset_segmentlist_node,
1152 adaptionset_supplementalproperty_node);
1156 node = xmlNextElementSibling(node);
1160 xmlFree(
c->adaptionset_lang);
1161 c->adaptionset_lang =
NULL;
1169 node = xmlFirstElementChild(node);
1172 val = xmlNodeGetContent(node);
1177 val = xmlNodeGetContent(node);
1182 val = xmlNodeGetContent(node);
1187 node = xmlNextElementSibling(node);
1202 xmlNodePtr root_element =
NULL;
1203 xmlNodePtr node =
NULL;
1204 xmlNodePtr period_node =
NULL;
1205 xmlNodePtr tmp_node =
NULL;
1206 xmlNodePtr mpd_baseurl_node =
NULL;
1207 xmlNodePtr period_baseurl_node =
NULL;
1208 xmlNodePtr period_segmenttemplate_node =
NULL;
1209 xmlNodePtr period_segmentlist_node =
NULL;
1210 xmlNodePtr adaptionset_node =
NULL;
1211 xmlAttrPtr attr =
NULL;
1213 uint32_t period_duration_sec = 0;
1214 uint32_t period_start_sec = 0;
1239 doc = xmlReadMemory(buf.str, buf.len,
c->base_url,
NULL, 0);
1240 root_element = xmlDocGetRootElement(doc);
1241 node = root_element;
1249 if (node->type != XML_ELEMENT_NODE ||
1252 av_log(
s,
AV_LOG_ERROR,
"Unable to parse '%s' - wrong root node name[%s] type[%d]\n",
url, node->name, (
int)node->type);
1256 val = xmlGetProp(node,
"type");
1266 attr = node->properties;
1268 val = xmlGetProp(node, attr->name);
1272 av_log(
s,
AV_LOG_TRACE,
"c->availability_start_time = [%"PRId64
"]\n",
c->availability_start_time);
1273 }
else if (!
av_strcasecmp(attr->name,
"availabilityEndTime")) {
1279 }
else if (!
av_strcasecmp(attr->name,
"minimumUpdatePeriod")) {
1282 }
else if (!
av_strcasecmp(attr->name,
"timeShiftBufferDepth")) {
1284 av_log(
s,
AV_LOG_TRACE,
"c->time_shift_buffer_depth = [%"PRId64
"]\n",
c->time_shift_buffer_depth);
1288 }
else if (!
av_strcasecmp(attr->name,
"suggestedPresentationDelay")) {
1290 av_log(
s,
AV_LOG_TRACE,
"c->suggested_presentation_delay = [%"PRId64
"]\n",
c->suggested_presentation_delay);
1291 }
else if (!
av_strcasecmp(attr->name,
"mediaPresentationDuration")) {
1293 av_log(
s,
AV_LOG_TRACE,
"c->media_presentation_duration = [%"PRId64
"]\n",
c->media_presentation_duration);
1301 mpd_baseurl_node = xmlCopyNode(tmp_node,1);
1303 mpd_baseurl_node = xmlNewNode(
NULL,
"BaseURL");
1307 node = xmlFirstElementChild(node);
1310 period_duration_sec = 0;
1311 period_start_sec = 0;
1312 attr = node->properties;
1314 val = xmlGetProp(node, attr->name);
1323 if ((period_duration_sec) >= (
c->period_duration)) {
1325 c->period_duration = period_duration_sec;
1326 c->period_start = period_start_sec;
1327 if (
c->period_start > 0)
1328 c->media_presentation_duration =
c->period_duration;
1330 }
else if (!
av_strcasecmp(node->name,
"ProgramInformation")) {
1333 node = xmlNextElementSibling(node);
1341 adaptionset_node = xmlFirstElementChild(period_node);
1342 while (adaptionset_node) {
1344 period_baseurl_node = adaptionset_node;
1345 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentTemplate")) {
1346 period_segmenttemplate_node = adaptionset_node;
1347 }
else if (!
av_strcasecmp(adaptionset_node->name,
"SegmentList")) {
1348 period_segmentlist_node = adaptionset_node;
1349 }
else if (!
av_strcasecmp(adaptionset_node->name,
"AdaptationSet")) {
1352 adaptionset_node = xmlNextElementSibling(adaptionset_node);
1358 xmlFreeNode(mpd_baseurl_node);
1372 int64_t start_time_offset = 0;
1390 }
else if (
c->publish_time > 0 && !
c->availability_start_time) {
1391 if (
c->min_buffer_time) {
1432 num =
c->period_duration / length_of_each_segment;
1448 if (rep_dest && rep_src ) {
1462 if (rep_dest && rep_src ) {
1483 int n_videos =
c->n_videos;
1485 int n_audios =
c->n_audios;
1487 int n_subtitles =
c->n_subtitles;
1489 char *base_url =
c->base_url;
1497 c->subtitles =
NULL;
1502 if (
c->n_videos != n_videos) {
1504 "new manifest has mismatched no. of video representations, %d -> %d\n",
1505 n_videos,
c->n_videos);
1508 if (
c->n_audios != n_audios) {
1510 "new manifest has mismatched no. of audio representations, %d -> %d\n",
1511 n_audios,
c->n_audios);
1514 if (
c->n_subtitles != n_subtitles) {
1516 "new manifest has mismatched no. of subtitles representations, %d -> %d\n",
1517 n_subtitles,
c->n_subtitles);
1521 for (
i = 0;
i < n_videos;
i++) {
1537 for (
i = 0;
i < n_audios;
i++) {
1559 c->base_url = base_url;
1568 c->n_subtitles = n_subtitles;
1569 c->subtitles = subtitles;
1570 c->n_audios = n_audios;
1572 c->n_videos = n_videos;
1579 int64_t min_seq_no = 0;
1580 int64_t max_seq_no = 0;
1600 }
else if (
c->is_live) {
1661 uint8_t *buf,
int buf_size)
1688 if (seg->
size >= 0) {
1710 static const int max_init_section_size = 1024 * 1024;
1722 "Failed to open an initialization section\n");
1731 sec_size = max_init_section_size;
1734 "Downloading an initialization section of size %"PRId64
"\n",
1737 sec_size =
FFMIN(sec_size, max_init_section_size);
1764 static int read_data(
void *opaque, uint8_t *buf,
int buf_size)
1831 "A DASH playlist item '%s' referred to an external file '%s'. "
1832 "Opening this file was forbidden for security reasons\n",
1841 memset(&pls->
pb, 0x00,
sizeof(pls->
pb));
1851 uint8_t *avio_ctx_buffer =
NULL;
1869 if (!avio_ctx_buffer ) {
1883 pls->
ctx->
probesize =
s->probesize > 0 ?
s->probesize : 1024 * 4;
1897 if (
c->cenc_decryption_key)
1898 av_dict_set(&in_fmt_opts,
"decryption_key",
c->cenc_decryption_key, 0);
1906 #if FF_API_R_FRAME_RATE
1959 memcpy(dst_data, sd_src->
data, sd_src->
size);
1976 if (first_init_section ==
NULL || n_pls == 0)
1979 url = first_init_section->
url;
1982 for (
i=0;
i<n_pls;
i++) {
1983 if (!pls[
i]->init_section)
2027 c->interrupt_callback = &
s->interrupt_callback;
2038 s->duration = (int64_t)
c->media_presentation_duration *
AV_TIME_BASE;
2047 for (
i = 0;
i <
c->n_videos;
i++) {
2049 if (
i > 0 &&
c->is_init_section_common_video) {
2065 for (
i = 0;
i <
c->n_audios;
i++) {
2067 if (
i > 0 &&
c->is_init_section_common_audio) {
2083 for (
i = 0;
i <
c->n_subtitles;
i++) {
2084 rep =
c->subtitles[
i];
2085 if (
i > 0 &&
c->is_init_section_common_subtitle) {
2106 for (
i = 0;
i <
c->n_videos;
i++) {
2114 for (
i = 0;
i <
c->n_audios;
i++) {
2123 for (
i = 0;
i <
c->n_subtitles;
i++) {
2124 rep =
c->subtitles[
i];
2138 for (
i = 0;
i < n;
i++) {
2146 for (j = 0; j < n; j++) {
2171 for (
i = 0;
i <
c->n_videos;
i++) {
2180 for (
i = 0;
i <
c->n_audios;
i++) {
2190 for (
i = 0;
i <
c->n_subtitles;
i++) {
2191 rep =
c->subtitles[
i];
2241 seek_pos_msec, dry_run ?
" (dry)" :
"");
2259 "last_seq_no[%"PRId64
"].\n",
2309 for (
i = 0;
i <
c->n_videos;
i++) {
2313 for (
i = 0;
i <
c->n_audios;
i++) {
2317 for (
i = 0;
i <
c->n_subtitles;
i++) {
2330 if (
av_stristr(p->
buf,
"dash:profile:isoff-on-demand:2011") ||
2344 #define OFFSET(x) offsetof(DASHContext, x)
2345 #define FLAGS AV_OPT_FLAG_DECODING_PARAM
2347 {
"allowed_extensions",
"List of file extensions that dash is allowed to access",
2349 {.str =
"aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
2350 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.
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)
int ffio_copy_url_options(AVIOContext *pb, AVDictionary **avio_opts)
Read url related dictionary options from the AVIOContext and write to the given dictionary.
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 is_init_section_common_subtitle
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
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 number of bytes read from input in order to determine stream properties.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
void ff_read_frame_flush(AVFormatContext *s)
Flush the frame reader.
static int read_from_url(struct representation *pls, struct fragment *seg, uint8_t *buf, int buf_size)
int64_t avio_size(AVIOContext *s)
Get the filesize.
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.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
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 *ac, 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)
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static void move_metadata(AVStream *st, const char *key, char **value)
char * allowed_extensions
static void move_segments(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int flags
Flags modifying the (de)muxer behaviour.
static void free_fragment_list(struct representation *pls)
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)
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
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
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)
enum AVPacketSideDataType type
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 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)
#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
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.
int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Like av_probe_input_buffer2() but returns 0 on success.
#define AV_LOG_INFO
Standard information.
char * cenc_decryption_key
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary **opts, AVDictionary *opts2, int *is_http)
static void free_subtitle_list(DASHContext *c)
#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...
static int dash_probe(const AVProbeData *p)
#define AV_TIME_BASE
Internal time base represented as integer.
struct representation ** audios
void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
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)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
New fields can be added to the end with minor version bumps.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
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,...
int nb_side_data
The number of elements in the AVStream.side_data array.
static struct fragment * get_Fragment(char *range)
static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representation *rep, xmlNodePtr fragment_timeline_node)
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
static int parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr adaptionset_node)
const AVInputFormat ff_dash_demuxer
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 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.
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
uint8_t * av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, size_t size)
Allocate new information from stream.
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 timestamps.
struct fragment ** fragments
void * priv_data
Format private data.
static const AVClass dash_class
int64_t presentation_timeoffset
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.