FFmpeg
Loading...
Searching...
No Matches
dashdec.c File Reference
#include <libxml/parser.h>
#include <time.h>
#include "libavutil/avassert.h"
#include "libavutil/bprint.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "internal.h"
#include "avio_internal.h"
#include "dash.h"
#include "demux.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  fragment
 
struct  timeline
 
struct  representation
 
struct  DASHContext
 

Macros

#define INITIAL_BUFFER_SIZE   32768
 
#define SET_REPRESENTATION_SEQUENCE_BASE_INFO(arg, cnt)
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_DECODING_PARAM
 

Functions

static int ishttp (char *url)
 
static int aligned (int val)
 
static int64_t get_current_time_in_sec (void)
 
static int64_t get_utc_date_time_insec (AVFormatContext *s, const char *datetime)
 
static uint32_t get_duration_insec (AVFormatContext *s, const char *duration)
 
static int64_t get_segment_start_time_based_on_timeline (struct representation *pls, int64_t cur_seq_no)
 
static int64_t calc_next_seg_no_from_timelines (struct representation *pls, int64_t cur_time)
 
static void free_fragment (struct fragment **seg)
 
static void free_fragment_list (struct representation *pls)
 
static void free_timelines_list (struct representation *pls)
 
static void free_representation (struct representation *pls)
 
static void free_video_list (DASHContext *c)
 
static void free_audio_list (DASHContext *c)
 
static void free_subtitle_list (DASHContext *c)
 
static int open_url (AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary **opts, AVDictionary *opts2, int *is_http)
 
static char * get_content_url (xmlNodePtr *baseurl_nodes, int n_baseurl_nodes, int max_url_size, char *rep_id_val, char *rep_bandwidth_val, char *val)
 
static char * get_val_from_nodes_tab (xmlNodePtr *nodes, const int n_nodes, const char *attrname)
 
static xmlNodePtr find_child_node_by_name (xmlNodePtr rootnode, const char *nodename)
 
static enum AVMediaType get_content_type (xmlNodePtr node)
 
static struct fragmentget_fragment (AVFormatContext *s, char *range)
 
static int parse_manifest_segmenturlnode (AVFormatContext *s, struct representation *rep, xmlNodePtr fragmenturl_node, xmlNodePtr *baseurl_nodes, char *rep_id_val, char *rep_bandwidth_val)
 
static int parse_manifest_segmenttimeline (AVFormatContext *s, struct representation *rep, xmlNodePtr fragment_timeline_node)
 
static int resolve_content_path (AVFormatContext *s, const char *url, int *max_url_size, xmlNodePtr *baseurl_nodes, int n_baseurl_nodes)
 
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 parse_manifest_adaptationset_attr (AVFormatContext *s, xmlNodePtr adaptionset_node)
 
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 int parse_programinformation (AVFormatContext *s, xmlNodePtr node)
 
static int parse_manifest (AVFormatContext *s, const char *url, AVIOContext *in)
 
static int64_t calc_cur_seg_no (AVFormatContext *s, struct representation *pls)
 
static int64_t calc_min_seg_no (AVFormatContext *s, struct representation *pls)
 
static int64_t calc_max_seg_no (struct representation *pls, DASHContext *c)
 
static void move_timelines (struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
 
static void move_segments (struct representation *rep_src, struct representation *rep_dest, DASHContext *c)
 
static int refresh_manifest (AVFormatContext *s)
 
static struct fragmentget_current_fragment (struct representation *pls)
 
static int read_from_url (struct representation *pls, struct fragment *seg, uint8_t *buf, int buf_size)
 
static int open_input (DASHContext *c, struct representation *pls, struct fragment *seg)
 
static int update_init_section (struct representation *pls)
 
static int64_t seek_data (void *opaque, int64_t offset, int whence)
 
static int read_data (void *opaque, uint8_t *buf, int buf_size)
 
static int nested_io_open (AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
 
static void close_demux_for_component (struct representation *pls)
 
static int reopen_demux_for_component (AVFormatContext *s, struct representation *pls)
 
static int open_demux_for_component (AVFormatContext *s, struct representation *pls)
 
static int is_common_init_section_exist (struct representation **pls, int n_pls)
 
static int copy_init_section (struct representation *rep_dest, struct representation *rep_src)
 
static void move_metadata (AVStream *st, const char *key, char **value)
 
static int dash_read_header (AVFormatContext *s)
 
static void recheck_discard_flags (AVFormatContext *s, struct representation **p, int n)
 
static int dash_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int dash_close (AVFormatContext *s)
 
static int dash_seek (AVFormatContext *s, struct representation *pls, int64_t seek_pos_msec, int flags, int dry_run)
 
static int dash_read_seek (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 
static int dash_probe (const AVProbeData *p)
 

Variables

static const AVOption dash_options []
 
static const AVClass dash_class
 
const FFInputFormat ff_dash_demuxer
 

Macro Definition Documentation

◆ INITIAL_BUFFER_SIZE

#define INITIAL_BUFFER_SIZE   32768

Definition at line 36 of file dashdec.c.

Referenced by hls_read_header(), init_subtitle_context(), and reopen_demux_for_component().

◆ SET_REPRESENTATION_SEQUENCE_BASE_INFO

#define SET_REPRESENTATION_SEQUENCE_BASE_INFO ( arg,
cnt )

Definition at line 862 of file dashdec.c.

Referenced by parse_manifest_representation().

◆ OFFSET

#define OFFSET ( x)
Value:
offsetof(DASHContext, x)

Definition at line 2537 of file dashdec.c.

◆ FLAGS

#define FLAGS   AV_OPT_FLAG_DECODING_PARAM

Definition at line 2538 of file dashdec.c.

Function Documentation

◆ ishttp()

static int ishttp ( char * url)
static

Definition at line 172 of file dashdec.c.

Referenced by resolve_content_path().

◆ aligned()

◆ get_current_time_in_sec()

static int64_t get_current_time_in_sec ( void )
static

Definition at line 183 of file dashdec.c.

Referenced by calc_cur_seg_no(), calc_max_seg_no(), and calc_min_seg_no().

◆ get_utc_date_time_insec()

static int64_t get_utc_date_time_insec ( AVFormatContext * s,
const char * datetime )
static

Definition at line 188 of file dashdec.c.

Referenced by parse_manifest().

◆ get_duration_insec()

static uint32_t get_duration_insec ( AVFormatContext * s,
const char * duration )
static

Definition at line 218 of file dashdec.c.

Referenced by parse_manifest().

◆ get_segment_start_time_based_on_timeline()

static int64_t get_segment_start_time_based_on_timeline ( struct representation * pls,
int64_t cur_seq_no )
static

Definition at line 262 of file dashdec.c.

Referenced by calc_cur_seg_no(), get_current_fragment(), and refresh_manifest().

◆ calc_next_seg_no_from_timelines()

static int64_t calc_next_seg_no_from_timelines ( struct representation * pls,
int64_t cur_time )
static

Definition at line 298 of file dashdec.c.

Referenced by calc_cur_seg_no(), and refresh_manifest().

◆ free_fragment()

static void free_fragment ( struct fragment ** seg)
static

◆ free_fragment_list()

static void free_fragment_list ( struct representation * pls)
static

Definition at line 337 of file dashdec.c.

Referenced by free_representation(), and move_segments().

◆ free_timelines_list()

static void free_timelines_list ( struct representation * pls)
static

Definition at line 348 of file dashdec.c.

Referenced by free_representation(), and move_timelines().

◆ free_representation()

static void free_representation ( struct representation * pls)
static

◆ free_video_list()

static void free_video_list ( DASHContext * c)
static

Definition at line 382 of file dashdec.c.

Referenced by dash_close(), and refresh_manifest().

◆ free_audio_list()

static void free_audio_list ( DASHContext * c)
static

Definition at line 393 of file dashdec.c.

Referenced by dash_close(), and refresh_manifest().

◆ free_subtitle_list()

static void free_subtitle_list ( DASHContext * c)
static

Definition at line 404 of file dashdec.c.

Referenced by dash_close(), and refresh_manifest().

◆ open_url()

static int open_url ( AVFormatContext * s,
AVIOContext ** pb,
const char * url,
AVDictionary ** opts,
AVDictionary * opts2,
int * is_http )
static

Definition at line 415 of file dashdec.c.

Referenced by open_input().

◆ get_content_url()

static char * get_content_url ( xmlNodePtr * baseurl_nodes,
int n_baseurl_nodes,
int max_url_size,
char * rep_id_val,
char * rep_bandwidth_val,
char * val )
static

Definition at line 482 of file dashdec.c.

Referenced by parse_manifest_representation(), and parse_manifest_segmenturlnode().

◆ get_val_from_nodes_tab()

static char * get_val_from_nodes_tab ( xmlNodePtr * nodes,
const int n_nodes,
const char * attrname )
static

Definition at line 533 of file dashdec.c.

Referenced by parse_manifest_representation().

◆ find_child_node_by_name()

static xmlNodePtr find_child_node_by_name ( xmlNodePtr rootnode,
const char * nodename )
static

Definition at line 549 of file dashdec.c.

Referenced by parse_manifest(), and parse_manifest_representation().

◆ get_content_type()

static enum AVMediaType get_content_type ( xmlNodePtr node)
static

Definition at line 566 of file dashdec.c.

Referenced by parse_manifest_representation().

◆ get_fragment()

static struct fragment * get_fragment ( AVFormatContext * s,
char * range )
static

Definition at line 592 of file dashdec.c.

Referenced by parse_manifest_segmenturlnode().

◆ parse_manifest_segmenturlnode()

static int parse_manifest_segmenturlnode ( AVFormatContext * s,
struct representation * rep,
xmlNodePtr fragmenturl_node,
xmlNodePtr * baseurl_nodes,
char * rep_id_val,
char * rep_bandwidth_val )
static

Definition at line 615 of file dashdec.c.

Referenced by parse_manifest_representation().

◆ parse_manifest_segmenttimeline()

static int parse_manifest_segmenttimeline ( AVFormatContext * s,
struct representation * rep,
xmlNodePtr fragment_timeline_node )
static

Definition at line 681 of file dashdec.c.

Referenced by parse_manifest_representation().

◆ resolve_content_path()

static int resolve_content_path ( AVFormatContext * s,
const char * url,
int * max_url_size,
xmlNodePtr * baseurl_nodes,
int n_baseurl_nodes )
static

Definition at line 722 of file dashdec.c.

Referenced by parse_manifest_representation().

◆ parse_manifest_representation()

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

Definition at line 899 of file dashdec.c.

Referenced by parse_manifest_adaptationset().

◆ parse_manifest_adaptationset_attr()

static int parse_manifest_adaptationset_attr ( AVFormatContext * s,
xmlNodePtr adaptionset_node )
static

Definition at line 1173 of file dashdec.c.

Referenced by parse_manifest_adaptationset().

◆ parse_manifest_adaptationset()

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

Definition at line 1186 of file dashdec.c.

Referenced by parse_manifest().

◆ parse_programinformation()

static int parse_programinformation ( AVFormatContext * s,
xmlNodePtr node )
static

Definition at line 1242 of file dashdec.c.

Referenced by parse_manifest().

◆ parse_manifest()

static int parse_manifest ( AVFormatContext * s,
const char * url,
AVIOContext * in )
static

Definition at line 1271 of file dashdec.c.

Referenced by dash_read_header(), and refresh_manifest().

◆ calc_cur_seg_no()

static int64_t calc_cur_seg_no ( AVFormatContext * s,
struct representation * pls )
static

Definition at line 1445 of file dashdec.c.

Referenced by get_current_fragment(), and open_demux_for_component().

◆ calc_min_seg_no()

static int64_t calc_min_seg_no ( AVFormatContext * s,
struct representation * pls )
static

Definition at line 1481 of file dashdec.c.

Referenced by get_current_fragment().

◆ calc_max_seg_no()

static int64_t calc_max_seg_no ( struct representation * pls,
DASHContext * c )
static

◆ move_timelines()

static void move_timelines ( struct representation * rep_src,
struct representation * rep_dest,
DASHContext * c )
static

Definition at line 1520 of file dashdec.c.

Referenced by refresh_manifest().

◆ move_segments()

static void move_segments ( struct representation * rep_src,
struct representation * rep_dest,
DASHContext * c )
static

Definition at line 1534 of file dashdec.c.

Referenced by refresh_manifest().

◆ refresh_manifest()

static int refresh_manifest ( AVFormatContext * s)
static

Definition at line 1555 of file dashdec.c.

Referenced by get_current_fragment().

◆ get_current_fragment()

static struct fragment * get_current_fragment ( struct representation * pls)
static

Definition at line 1654 of file dashdec.c.

Referenced by read_data().

◆ read_from_url()

static int read_from_url ( struct representation * pls,
struct fragment * seg,
uint8_t * buf,
int buf_size )
static

Definition at line 1744 of file dashdec.c.

Referenced by read_data(), and update_init_section().

◆ open_input()

static int open_input ( DASHContext * c,
struct representation * pls,
struct fragment * seg )
static

Definition at line 1760 of file dashdec.c.

Referenced by read_data(), and update_init_section().

◆ update_init_section()

static int update_init_section ( struct representation * pls)
static

Definition at line 1792 of file dashdec.c.

Referenced by read_data().

◆ seek_data()

static int64_t seek_data ( void * opaque,
int64_t offset,
int whence )
static

Definition at line 1838 of file dashdec.c.

Referenced by reopen_demux_for_component().

◆ read_data()

static int read_data ( void * opaque,
uint8_t * buf,
int buf_size )
static

Definition at line 1848 of file dashdec.c.

Referenced by pulse_read_packet(), reopen_demux_for_component(), and tls_handshake_loop().

◆ nested_io_open()

static int nested_io_open ( AVFormatContext * s,
AVIOContext ** pb,
const char * url,
int flags,
AVDictionary ** opts )
static

Definition at line 1919 of file dashdec.c.

Referenced by hls_read_header(), init_subtitle_context(), and reopen_demux_for_component().

◆ close_demux_for_component()

static void close_demux_for_component ( struct representation * pls)
static

Definition at line 1929 of file dashdec.c.

Referenced by dash_read_packet(), recheck_discard_flags(), and reopen_demux_for_component().

◆ reopen_demux_for_component()

static int reopen_demux_for_component ( AVFormatContext * s,
struct representation * pls )
static

◆ open_demux_for_component()

static int open_demux_for_component ( AVFormatContext * s,
struct representation * pls )
static

Definition at line 2015 of file dashdec.c.

Referenced by dash_read_header().

◆ is_common_init_section_exist()

static int is_common_init_section_exist ( struct representation ** pls,
int n_pls )
static

Definition at line 2092 of file dashdec.c.

Referenced by dash_read_header().

◆ copy_init_section()

static int copy_init_section ( struct representation * rep_dest,
struct representation * rep_src )
static

Definition at line 2119 of file dashdec.c.

Referenced by dash_read_header().

◆ move_metadata()

static void move_metadata ( AVStream * st,
const char * key,
char ** value )
static

Definition at line 2134 of file dashdec.c.

Referenced by dash_read_header().

◆ dash_read_header()

static int dash_read_header ( AVFormatContext * s)
static

Definition at line 2142 of file dashdec.c.

◆ recheck_discard_flags()

static void recheck_discard_flags ( AVFormatContext * s,
struct representation ** p,
int n )
static

Definition at line 2316 of file dashdec.c.

Referenced by dash_read_packet().

◆ dash_read_packet()

static int dash_read_packet ( AVFormatContext * s,
AVPacket * pkt )
static

Definition at line 2344 of file dashdec.c.

◆ dash_close()

static int dash_close ( AVFormatContext * s)
static

Definition at line 2415 of file dashdec.c.

◆ dash_seek()

static int dash_seek ( AVFormatContext * s,
struct representation * pls,
int64_t seek_pos_msec,
int flags,
int dry_run )
static

Definition at line 2426 of file dashdec.c.

Referenced by dash_read_seek().

◆ dash_read_seek()

static int dash_read_seek ( AVFormatContext * s,
int stream_index,
int64_t timestamp,
int flags )
static

Definition at line 2490 of file dashdec.c.

◆ dash_probe()

static int dash_probe ( const AVProbeData * p)
static

Definition at line 2518 of file dashdec.c.

Variable Documentation

◆ dash_options

const AVOption dash_options[]
static
Initial value:
= {
{"allowed_extensions", "List of file extensions that dash is allowed to access",
OFFSET(allowed_extensions), AV_OPT_TYPE_STRING,
{.str = "aac,m4a,m4s,m4v,mov,mp4,webm,ts"},
INT_MIN, INT_MAX, FLAGS},
{ "cenc_decryption_key", "Media default decryption key (hex)", OFFSET(cenc_decryption_key), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS },
{ "cenc_decryption_keys", "Media decryption keys by KID (hex)", OFFSET(cenc_decryption_keys), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS },
{ "max_reload", "Maximum number of manifest reloads in get_current_fragment() before giving up",
OFFSET(max_reload), AV_OPT_TYPE_INT, { .i64 = 100 }, 0, INT_MAX, FLAGS },
{NULL}
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 2539 of file dashdec.c.

◆ dash_class

const AVClass dash_class
static
Initial value:
= {
.class_name = "dash",
.item_name = av_default_item_name,
.option = dash_options,
}
static const AVOption dash_options[]
Definition dashdec.c:2539
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 2551 of file dashdec.c.

◆ ff_dash_demuxer

const FFInputFormat ff_dash_demuxer
Initial value:
= {
.p.name = "dash",
.p.long_name = NULL_IF_CONFIG_SMALL("Dynamic Adaptive Streaming over HTTP"),
.p.priv_class = &dash_class,
.p.flags = AVFMT_NO_BYTE_SEEK,
.priv_data_size = sizeof(DASHContext),
.flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
}
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition avformat.h:506
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
static int dash_read_header(AVFormatContext *s)
Definition dashdec.c:2142
static const AVClass dash_class
Definition dashdec.c:2551
static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition dashdec.c:2344
static int dash_close(AVFormatContext *s)
Definition dashdec.c:2415
static int dash_probe(const AVProbeData *p)
Definition dashdec.c:2518
static int dash_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition dashdec.c:2490
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition demux.h:35
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151

Definition at line 2558 of file dashdec.c.