22 #include <libxml/parser.h> 31 #define INITIAL_BUFFER_SIZE 32768 180 return ((val + 0x3F) >> 6) << 6;
203 ret = sscanf(datetime,
"%d-%d-%dT%d:%d:%fZ", &year, &month, &day, &hour, &minute, &second);
208 timeinfo.tm_year = year - 1900;
209 timeinfo.tm_mon = month - 1;
210 timeinfo.tm_mday = day;
211 timeinfo.tm_hour = hour;
212 timeinfo.tm_min = minute;
213 timeinfo.tm_sec = (
int)second;
231 if (*ptr ==
'P' || *ptr ==
'T') {
236 if (sscanf(ptr,
"%f%c%n", &value, &type, &size) != 2) {
242 days = (uint32_t)value;
245 hours = (uint32_t)value;
248 mins = (uint32_t)value;
251 secs = (uint32_t)value;
259 return ((days * 24 + hours) * 60 + mins) * 60 + secs;
274 if (num == cur_seq_no)
286 if (num == cur_seq_no)
308 if (start_time > cur_time)
314 if (start_time > cur_time)
415 const char *proto_name =
NULL;
422 if (url[6] ==
'+' || url[6] ==
':')
436 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n" 437 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
446 if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] ==
':')
448 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] ==
':')
450 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
457 char *new_cookies =
NULL;
480 char *rep_bandwidth_val,
489 if (!tmp_str || !tmp_str_2) {
493 for (i = 0; i < n_baseurl_nodes; ++
i) {
494 if (baseurl_nodes[i] &&
495 baseurl_nodes[i]->children &&
496 baseurl_nodes[i]->children->type == XML_TEXT_NODE) {
497 text = xmlNodeGetContent(baseurl_nodes[i]->children);
499 memset(tmp_str, 0, max_url_size);
500 memset(tmp_str_2, 0, max_url_size);
512 url =
av_strireplace(tmp_str,
"$RepresentationID$", (
const char*)rep_id_val);
518 if (rep_bandwidth_val && tmp_str[0] !=
'\0') {
521 url =
av_strireplace(tmp_str,
"$Bandwidth$", (
const char*)rep_bandwidth_val);
537 for (i = 0; i < n_nodes; ++
i) {
539 val = xmlGetProp(nodes[i], attrname);
550 xmlNodePtr node = rootnode;
555 node = xmlFirstElementChild(node);
560 node = xmlNextElementSibling(node);
573 for (i = 0; i < 2; i++) {
574 attr = i ?
"mimeType" :
"contentType";
575 val = xmlGetProp(node, attr);
579 }
else if (
av_stristr((
const char *)val,
"audio")) {
581 }
else if (
av_stristr((
const char *)val,
"text")) {
600 char *str_end_offset;
601 char *str_offset =
av_strtok(range,
"-", &str_end_offset);
610 xmlNodePtr fragmenturl_node,
611 xmlNodePtr *baseurl_nodes,
613 char *rep_bandwidth_val)
616 char *initialization_val =
NULL;
617 char *media_val =
NULL;
618 char *range_val =
NULL;
621 if (!
av_strcasecmp(fragmenturl_node->name, (
const char *)
"Initialization")) {
622 initialization_val = xmlGetProp(fragmenturl_node,
"sourceURL");
623 range_val = xmlGetProp(fragmenturl_node,
"range");
624 if (initialization_val || range_val) {
627 xmlFree(initialization_val);
639 xmlFree(initialization_val);
643 xmlFree(initialization_val);
646 }
else if (!
av_strcasecmp(fragmenturl_node->name, (
const char *)
"SegmentURL")) {
647 media_val = xmlGetProp(fragmenturl_node,
"media");
648 range_val = xmlGetProp(fragmenturl_node,
"mediaRange");
649 if (media_val || range_val) {
677 xmlNodePtr fragment_timeline_node)
679 xmlAttrPtr attr =
NULL;
682 if (!
av_strcasecmp(fragment_timeline_node->name, (
const char *)
"S")) {
687 attr = fragment_timeline_node->properties;
689 val = xmlGetProp(fragment_timeline_node, attr->name);
692 av_log(s,
AV_LOG_WARNING,
"parse_manifest_segmenttimeline attr->name = %s val is NULL\n", attr->name);
699 tml->
repeat =(int64_t) strtoll(val,
NULL, 10);
714 char *tmp_str =
NULL;
716 char *mpdName =
NULL;
717 xmlNodePtr node =
NULL;
718 char *baseurl =
NULL;
719 char *root_url =
NULL;
729 int tmp_max_url_size = strlen(url);
731 for (i = n_baseurl_nodes-1; i >= 0 ; i--) {
732 text = xmlNodeGetContent(baseurl_nodes[i]);
735 tmp_max_url_size += strlen(text);
743 tmp_max_url_size =
aligned(tmp_max_url_size);
751 while (mpdName =
av_strtok(tmp,
"/", &tmp)) {
752 size = strlen(mpdName);
758 if (!tmp_str || !path) {
763 av_strlcpy (path, url, strlen(url) - size + 1);
764 for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
765 if (!(node = baseurl_nodes[rootId])) {
768 text = xmlNodeGetContent(node);
776 node = baseurl_nodes[rootId];
777 baseurl = xmlNodeGetContent(node);
780 xmlNodeSetContent(node, root_url);
784 size = strlen(root_url);
785 isRootHttp =
ishttp(root_url);
787 if (root_url[size - 1] != token) {
792 for (i = 0; i < n_baseurl_nodes; ++
i) {
796 text = xmlNodeGetContent(baseurl_nodes[i]);
798 memset(tmp_str, 0, strlen(tmp_str));
799 if (!
ishttp(text) && isRootHttp) {
802 start = (text[0] == token);
803 av_strlcat(tmp_str, text + start, tmp_max_url_size);
804 xmlNodeSetContent(baseurl_nodes[i], tmp_str);
811 if (tmp_max_url_size > *max_url_size) {
812 *max_url_size = tmp_max_url_size;
823 xmlNodePtr adaptionset_node,
824 xmlNodePtr mpd_baseurl_node,
825 xmlNodePtr period_baseurl_node,
826 xmlNodePtr period_segmenttemplate_node,
827 xmlNodePtr period_segmentlist_node,
828 xmlNodePtr fragment_template_node,
829 xmlNodePtr content_component_node,
830 xmlNodePtr adaptionset_baseurl_node,
831 xmlNodePtr adaptionset_segmentlist_node,
832 xmlNodePtr adaptionset_supplementalproperty_node)
841 xmlNodePtr representation_segmenttemplate_node =
NULL;
842 xmlNodePtr representation_baseurl_node =
NULL;
843 xmlNodePtr representation_segmentlist_node =
NULL;
844 xmlNodePtr segmentlists_tab[3];
845 xmlNodePtr fragment_timeline_node =
NULL;
846 xmlNodePtr fragment_templates_tab[5];
847 char *duration_val =
NULL;
848 char *presentation_timeoffset_val =
NULL;
849 char *startnumber_val =
NULL;
850 char *timescale_val =
NULL;
851 char *initialization_val =
NULL;
852 char *media_val =
NULL;
854 xmlNodePtr baseurl_nodes[4];
855 xmlNodePtr representation_node = node;
856 char *rep_id_val = xmlGetProp(representation_node,
"id");
857 char *rep_bandwidth_val = xmlGetProp(representation_node,
"bandwidth");
858 char *rep_framerate_val = xmlGetProp(representation_node,
"frameRate");
883 baseurl_nodes[0] = mpd_baseurl_node;
884 baseurl_nodes[1] = period_baseurl_node;
885 baseurl_nodes[2] = adaptionset_baseurl_node;
886 baseurl_nodes[3] = representation_baseurl_node;
890 + (rep_id_val ? strlen(rep_id_val) : 0)
891 + (rep_bandwidth_val ? strlen(rep_bandwidth_val) : 0));
892 if (ret ==
AVERROR(ENOMEM) || ret == 0) {
895 if (representation_segmenttemplate_node || fragment_template_node || period_segmenttemplate_node) {
896 fragment_timeline_node =
NULL;
897 fragment_templates_tab[0] = representation_segmenttemplate_node;
898 fragment_templates_tab[1] = adaptionset_segmentlist_node;
899 fragment_templates_tab[2] = fragment_template_node;
900 fragment_templates_tab[3] = period_segmenttemplate_node;
901 fragment_templates_tab[4] = period_segmentlist_node;
903 presentation_timeoffset_val =
get_val_from_nodes_tab(fragment_templates_tab, 4,
"presentationTimeOffset");
910 if (initialization_val) {
926 xmlFree(initialization_val);
935 if (presentation_timeoffset_val) {
938 xmlFree(presentation_timeoffset_val);
943 xmlFree(duration_val);
948 xmlFree(timescale_val);
950 if (startnumber_val) {
953 xmlFree(startnumber_val);
955 if (adaptionset_supplementalproperty_node) {
956 if (!
av_strcasecmp(xmlGetProp(adaptionset_supplementalproperty_node,
"schemeIdUri"),
"http://dashif.org/guidelines/last-segment-number")) {
957 val = xmlGetProp(adaptionset_supplementalproperty_node,
"value");
959 av_log(s,
AV_LOG_ERROR,
"Missing value attribute in adaptionset_supplementalproperty_node\n");
969 if (!fragment_timeline_node)
971 if (!fragment_timeline_node)
973 if (!fragment_timeline_node)
975 if (fragment_timeline_node) {
976 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
977 while (fragment_timeline_node) {
982 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
985 }
else if (representation_baseurl_node && !representation_segmentlist_node) {
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;
1012 xmlFree(duration_val);
1014 if (timescale_val) {
1017 xmlFree(timescale_val);
1019 fragmenturl_node = xmlFirstElementChild(representation_segmentlist_node);
1020 while (fragmenturl_node) {
1028 fragmenturl_node = xmlNextElementSibling(fragmenturl_node);
1033 if (!fragment_timeline_node)
1035 if (!fragment_timeline_node)
1037 if (!fragment_timeline_node)
1039 if (fragment_timeline_node) {
1040 fragment_timeline_node = xmlFirstElementChild(fragment_timeline_node);
1041 while (fragment_timeline_node) {
1046 fragment_timeline_node = xmlNextElementSibling(fragment_timeline_node);
1052 av_log(s,
AV_LOG_ERROR,
"Unknown format of Representation node id[%s] \n", (
const char *)rep_id_val);
1058 rep->
bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
1059 strncpy(rep->
id, rep_id_val ? rep_id_val :
"",
sizeof(rep->
id));
1077 rep->
rep_idx = subtitle_rep_idx;
1093 xmlFree(rep_id_val);
1094 if (rep_bandwidth_val)
1095 xmlFree(rep_bandwidth_val);
1096 if (rep_framerate_val)
1097 xmlFree(rep_framerate_val);
1103 xmlNodePtr adaptionset_node,
1104 xmlNodePtr mpd_baseurl_node,
1105 xmlNodePtr period_baseurl_node,
1106 xmlNodePtr period_segmenttemplate_node,
1107 xmlNodePtr period_segmentlist_node)
1111 xmlNodePtr fragment_template_node =
NULL;
1112 xmlNodePtr content_component_node =
NULL;
1113 xmlNodePtr adaptionset_baseurl_node =
NULL;
1114 xmlNodePtr adaptionset_segmentlist_node =
NULL;
1115 xmlNodePtr adaptionset_supplementalproperty_node =
NULL;
1116 xmlNodePtr node =
NULL;
1131 node = xmlFirstElementChild(adaptionset_node);
1133 if (!
av_strcasecmp(node->name, (
const char *)
"SegmentTemplate")) {
1134 fragment_template_node = node;
1135 }
else if (!
av_strcasecmp(node->name, (
const char *)
"ContentComponent")) {
1136 content_component_node = node;
1137 }
else if (!
av_strcasecmp(node->name, (
const char *)
"BaseURL")) {
1138 adaptionset_baseurl_node = node;
1139 }
else if (!
av_strcasecmp(node->name, (
const char *)
"SegmentList")) {
1140 adaptionset_segmentlist_node = node;
1141 }
else if (!
av_strcasecmp(node->name, (
const char *)
"SupplementalProperty")) {
1142 adaptionset_supplementalproperty_node = node;
1143 }
else if (!
av_strcasecmp(node->name, (
const char *)
"Representation")) {
1147 period_baseurl_node,
1148 period_segmenttemplate_node,
1149 period_segmentlist_node,
1150 fragment_template_node,
1151 content_component_node,
1152 adaptionset_baseurl_node,
1153 adaptionset_segmentlist_node,
1154 adaptionset_supplementalproperty_node);
1159 node = xmlNextElementSibling(node);
1168 node = xmlFirstElementChild(node);
1171 val = xmlNodeGetContent(node);
1176 val = xmlNodeGetContent(node);
1181 val = xmlNodeGetContent(node);
1186 node = xmlNextElementSibling(node);
1198 int64_t filesize = 0;
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;
1233 if (filesize <= 0) {
1234 filesize = 8 * 1024;
1243 filesize =
avio_read(in, buffer, filesize);
1244 if (filesize <= 0) {
1250 doc = xmlReadMemory(buffer, filesize, c->
base_url,
NULL, 0);
1251 root_element = xmlDocGetRootElement(doc);
1252 node = root_element;
1260 if (node->type != XML_ELEMENT_NODE ||
1263 av_log(s,
AV_LOG_ERROR,
"Unable to parse '%s' - wrong root node name[%s] type[%d]\n", url, node->name, (
int)node->type);
1267 val = xmlGetProp(node,
"type");
1277 attr = node->properties;
1279 val = xmlGetProp(node, attr->name);
1281 if (!
av_strcasecmp(attr->name, (
const char *)
"availabilityStartTime")) {
1284 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"availabilityEndTime")) {
1287 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"publishTime")) {
1290 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"minimumUpdatePeriod")) {
1293 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"timeShiftBufferDepth")) {
1296 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"minBufferTime")) {
1299 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"suggestedPresentationDelay")) {
1302 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"mediaPresentationDuration")) {
1312 mpd_baseurl_node = xmlCopyNode(tmp_node,1);
1314 mpd_baseurl_node = xmlNewNode(
NULL,
"BaseURL");
1318 node = xmlFirstElementChild(node);
1321 period_duration_sec = 0;
1322 period_start_sec = 0;
1323 attr = node->properties;
1325 val = xmlGetProp(node, attr->name);
1328 }
else if (!
av_strcasecmp(attr->name, (
const char *)
"start")) {
1341 }
else if (!
av_strcasecmp(node->name,
"ProgramInformation")) {
1344 node = xmlNextElementSibling(node);
1352 adaptionset_node = xmlFirstElementChild(period_node);
1353 while (adaptionset_node) {
1354 if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"BaseURL")) {
1355 period_baseurl_node = adaptionset_node;
1356 }
else if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"SegmentTemplate")) {
1357 period_segmenttemplate_node = adaptionset_node;
1358 }
else if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"SegmentList")) {
1359 period_segmentlist_node = adaptionset_node;
1360 }
else if (!
av_strcasecmp(adaptionset_node->name, (
const char *)
"AdaptationSet")) {
1361 parse_manifest_adaptationset(s, url, adaptionset_node, mpd_baseurl_node, period_baseurl_node, period_segmenttemplate_node, period_segmentlist_node);
1363 adaptionset_node = xmlNextElementSibling(adaptionset_node);
1369 xmlFreeNode(mpd_baseurl_node);
1384 int64_t start_time_offset = 0;
1460 if (rep_dest && rep_src ) {
1474 if (rep_dest && rep_src ) {
1516 "new manifest has mismatched no. of video representations, %d -> %d\n",
1522 "new manifest has mismatched no. of audio representations, %d -> %d\n",
1528 "new manifest has mismatched no. of subtitles representations, %d -> %d\n",
1533 for (
i = 0;
i < n_videos;
i++) {
1549 for (
i = 0;
i < n_audios;
i++) {
1591 int64_t min_seq_no = 0;
1592 int64_t max_seq_no = 0;
1692 if (seg->
size >= 0) {
1714 static const int max_init_section_size = 1024 * 1024;
1726 "Failed to open an initialization section in playlist %d\n",
1736 sec_size = max_init_section_size;
1739 "Downloading an initialization section of size %"PRId64
"\n",
1742 sec_size =
FFMIN(sec_size, max_init_section_size);
1835 const char *
opts[] = {
1836 "headers",
"user_agent",
"cookies",
"http_proxy",
"referer",
"rw_timeout",
NULL };
1837 const char **opt =
opts;
1843 if (buf[0] !=
'\0') {
1863 "A DASH playlist item '%s' referred to an external file '%s'. " 1864 "Opening this file was forbidden for security reasons\n",
1902 if (!avio_ctx_buffer ) {
1938 #if FF_API_R_FRAME_RATE 1994 if (first_init_section ==
NULL || n_pls == 0)
1997 url = first_init_section->
url;
2000 for (i=0;i<n_pls;i++) {
2052 for (i = 0; i < c->
n_videos; i++) {
2070 for (i = 0; i < c->
n_audios; i++) {
2103 if (!stream_index) {
2116 for (i = 0; i < c->
n_videos; i++) {
2125 for (i = 0; i < c->
n_audios; i++) {
2152 for (i = 0; i <
n; i++) {
2156 if (needed && !pls->
ctx) {
2160 for (j = 0; j <
n; j++) {
2165 }
else if (!needed && pls->
ctx) {
2256 seek_pos_msec, pls->
rep_idx, dry_run ?
" (dry)" :
"");
2275 "last_seq_no[%"PRId64
"], playlist %d.\n",
2346 if (
av_stristr(p->
buf,
"dash:profile:isoff-on-demand:2011") ||
2359 #define OFFSET(x) offsetof(DASHContext, x) 2360 #define FLAGS AV_OPT_FLAG_DECODING_PARAM 2362 {
"allowed_extensions",
"List of file extensions that dash is allowed to access",
2364 {.str =
"aac,m4a,m4s,m4v,mov,mp4,webm"},
2365 INT_MIN, INT_MAX,
FLAGS},
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
int64_t probesize
Maximum size of the data read from input for determining the input container format.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
const char const char void * val
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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
char * allowed_extensions
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static int64_t get_segment_start_time_based_on_timeline(struct representation *pls, int64_t cur_seq_no)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static int read_data(void *opaque, uint8_t *buf, int buf_size)
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle...
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static int ishttp(char *url)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
#define AVIO_FLAG_READ
read-only
unsigned char * buffer
Start of the buffer.
static struct fragment * get_current_fragment(struct representation *pls)
static int read_from_url(struct representation *pls, struct fragment *seg, uint8_t *buf, int buf_size)
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static const AVOption dash_options[]
static int64_t seek_data(void *opaque, int64_t offset, int whence)
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.
uint64_t availability_end_time
static int parse_manifest_segmenturlnode(AVFormatContext *s, struct representation *rep, xmlNodePtr fragmenturl_node, xmlNodePtr *baseurl_nodes, char *rep_id_val, char *rep_bandwidth_val)
int is_init_section_common_audio
static void free_fragment(struct fragment **seg)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
struct fragment * init_section
uint32_t init_sec_buf_read_offset
static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char *datetime)
static int64_t start_time
uint64_t suggested_presentation_delay
static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
uint64_t media_presentation_duration
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
char * adaptionset_maxframerate_val
int64_t presentation_timeoffset
int id
Format-specific stream ID.
static int dash_close(AVFormatContext *s)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
int flags
Flags modifying the (de)muxer behaviour.
AVProgram * av_new_program(AVFormatContext *s, int id)
struct timeline ** timelines
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
#define AV_LOG_VERBOSE
Detailed information.
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.
static void recheck_discard_flags(AVFormatContext *s, struct representation **p, int n)
uint64_t availability_start_time
static enum AVMediaType get_content_type(xmlNodePtr node)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
struct representation ** audios
#define INITIAL_BUFFER_SIZE
char * adaptionset_bitstreamswitching_val
static xmlNodePtr find_child_node_by_name(xmlNodePtr rootnode, const char *nodename)
static int aligned(int val)
struct representation ** subtitles
Callback for checking whether to abort blocking functions.
#define i(width, name, range_min, range_max)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
char * adaptionset_minbw_val
uint32_t init_sec_data_len
static void free_timelines_list(struct representation *pls)
static void move_segments(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int64_t calc_cur_seg_no(AVFormatContext *s, struct representation *pls)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
char * url
input or output URL.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int is_common_init_section_exist(struct representation **pls, int n_pls)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
char * av_strireplace(const char *str, const char *from, const char *to)
Locale-independent strings replace.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * adaptionset_par_val
static const uint8_t offset[127][2]
New fields can be added to the end with minor version bumps.
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.
char * adaptionset_segmentalignment_val
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
uint64_t minimum_update_period
struct fragment ** fragments
static void free_representation(struct representation *pls)
AVIOInterruptCB * interrupt_callback
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static void free_audio_list(DASHContext *c)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx)
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static void free_fragment_list(struct representation *pls)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static void move_timelines(struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
static int dash_probe(const AVProbeData *p)
static uint32_t get_duration_insec(AVFormatContext *s, const char *duration)
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)
Usually treated as AVMEDIA_TYPE_DATA.
static int save_avio_options(AVFormatContext *s)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
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.
char * adaptionset_contenttype_val
char * adaptionset_maxwidth_val
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
static char * get_val_from_nodes_tab(xmlNodePtr *nodes, const int n_nodes, const char *attrname)
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
static int read_header(FFV1Context *f)
int64_t av_gettime(void)
Get the current time in microseconds.
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 read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AV_LOG_INFO
Standard information.
char * av_strdup(const char *s)
Duplicate a string.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
AVIOContext * pb
I/O context.
static AVRational av_make_q(int num, int den)
Create an AVRational.
uint32_t init_sec_buf_size
static int copy_init_section(struct representation *rep_dest, struct representation *rep_src)
static int dash_read_header(AVFormatContext *s)
uint64_t time_shift_buffer_depth
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
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)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Describe the class of an AVClass context structure.
static int open_input(DASHContext *c, struct representation *pls, struct fragment *seg)
static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
Rational number (pair of numerator and denominator).
static int resolve_content_path(AVFormatContext *s, const char *url, int *max_url_size, xmlNodePtr *baseurl_nodes, int n_baseurl_nodes)
static struct fragment * get_Fragment(char *range)
static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representation *rep, xmlNodePtr fragment_timeline_node)
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.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
This structure contains the data a format has to probe a file.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
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...
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,...)
AVInputFormat ff_dash_demuxer
static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t seek_pos_msec, int flags, int dry_run)
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
char * adaptionset_lang_val
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()...
static int update_init_section(struct representation *pls)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
char * adaptionset_maxbw_val
char * adaptionset_minheight_val
char * adaptionset_minframerate_val
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))
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
static const AVClass dash_class
int64_t fragment_duration
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...
struct fragment * cur_seg
int pts_wrap_bits
number of bits in pts (used for wrapping control)
static void free_subtitle_list(DASHContext *c)
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int64_t fragment_timescale
static void close_demux_for_component(struct representation *pls)
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
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 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)
void * priv_data
Format private data.
static uint64_t get_current_time_in_sec(void)
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)
char * adaptionset_minwidth_val
static int64_t calc_min_seg_no(AVFormatContext *s, struct representation *pls)
struct representation ** videos
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
static void free_video_list(DASHContext *c)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int is_init_section_common_video
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
char * adaptionset_maxheight_val
static int reopen_demux_for_component(AVFormatContext *s, struct representation *pls)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
This structure stores compressed data.
static int64_t calc_next_seg_no_from_timelines(struct representation *pls, int64_t cur_time)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int open_demux_for_component(AVFormatContext *s, struct representation *pls)
static av_cold void cleanup(FlashSV2Context *s)
static int refresh_manifest(AVFormatContext *s)