FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
dashenc.c File Reference
#include "config.h"
#include "libavutil/avassert.h"
#include "libavutil/avutil.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/rational.h"
#include "libavutil/time.h"
#include "libavutil/time_internal.h"
#include "av1.h"
#include "avc.h"
#include "avformat.h"
#include "avio_internal.h"
#include "hlsplaylist.h"
#include "internal.h"
#include "isom.h"
#include "os_support.h"
#include "url.h"
#include "vpcc.h"
#include "dash.h"

Go to the source code of this file.

Data Structures

struct  Segment
 
struct  AdaptationSet
 
struct  OutputStream
 
struct  DASHContext
 
struct  codec_string
 
struct  format_string
 

Macros

#define OFFSET(x)   offsetof(DASHContext, x)
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  SegmentType {
  PALETTE_SEGMENT = 0x14, OBJECT_SEGMENT = 0x15, PRESENTATION_SEGMENT = 0x16, WINDOW_SEGMENT = 0x17,
  DISPLAY_SEGMENT = 0x80, SEGMENT_TYPE_AUTO = 0, SEGMENT_TYPE_MP4, SEGMENT_TYPE_WEBM,
  SEGMENT_TYPE_NB, SEGMENT_TYPE_MPEGTS, SEGMENT_TYPE_FMP4
}
 

Functions

static int dashenc_io_open (AVFormatContext *s, AVIOContext **pb, char *filename, AVDictionary **options)
 
static void dashenc_io_close (AVFormatContext *s, AVIOContext **pb, char *filename)
 
static const char * get_format_str (SegmentType segment_type)
 
static const char * get_extension_str (SegmentType type, int single_file)
 
static int handle_io_open_error (AVFormatContext *s, int err, char *url)
 
static SegmentType select_segment_type (SegmentType segment_type, enum AVCodecID codec_id)
 
static int init_segment_types (AVFormatContext *s)
 
static int check_file_extension (const char *filename, const char *extension)
 
static void set_vp9_codec_str (AVFormatContext *s, AVCodecParameters *par, AVRational *frame_rate, char *str, int size)
 
static void set_codec_str (AVFormatContext *s, AVCodecParameters *par, AVRational *frame_rate, char *str, int size)
 
static int flush_dynbuf (DASHContext *c, OutputStream *os, int *range_length)
 
static void set_http_options (AVDictionary **options, DASHContext *c)
 
static void get_hls_playlist_name (char *playlist_name, int string_size, const char *base_url, int id)
 
static void get_start_index_number (OutputStream *os, DASHContext *c, int *start_index, int *start_number)
 
static void write_hls_media_playlist (OutputStream *os, AVFormatContext *s, int representation_id, int final, char *prefetch_url)
 
static int flush_init_segment (AVFormatContext *s, OutputStream *os)
 
static void dash_free (AVFormatContext *s)
 
static void output_segment_list (OutputStream *os, AVIOContext *out, AVFormatContext *s, int representation_id, int final)
 
static char * xmlescape (const char *str)
 
static void write_time (AVIOContext *out, int64_t time)
 
static void format_date_now (char *buf, int size)
 
static int write_adaptation_set (AVFormatContext *s, AVIOContext *out, int as_index, int final)
 
static int add_adaptation_set (AVFormatContext *s, AdaptationSet **as, enum AVMediaType type)
 
static int adaptation_set_add_stream (AVFormatContext *s, int as_idx, int i)
 
static int parse_adaptation_sets (AVFormatContext *s)
 
static int write_manifest (AVFormatContext *s, int final)
 
static int dict_copy_entry (AVDictionary **dst, const AVDictionary *src, const char *key)
 
static int dash_init (AVFormatContext *s)
 
static int dash_write_header (AVFormatContext *s)
 
static int add_segment (OutputStream *os, const char *file, int64_t time, int64_t duration, int64_t start_pos, int64_t range_length, int64_t index_length, int next_exp_index)
 
static void write_styp (AVIOContext *pb)
 
static void find_index_range (AVFormatContext *s, const char *full_path, int64_t pos, int *index_length)
 
static int update_stream_extradata (AVFormatContext *s, OutputStream *os, AVPacket *pkt, AVRational *frame_rate)
 
static void dashenc_delete_file (AVFormatContext *s, char *filename)
 
static int dashenc_delete_segment_file (AVFormatContext *s, const char *file)
 
static void dashenc_delete_media_segments (AVFormatContext *s, OutputStream *os, int remove_count)
 
static int dash_flush (AVFormatContext *s, int final, int stream)
 
static int dash_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int dash_write_trailer (AVFormatContext *s)
 
static int dash_check_bitstream (struct AVFormatContext *s, const AVPacket *avpkt)
 

Variables

static struct codec_string codecs []
 
static struct format_string formats []
 
static const AVOption options []
 
static const AVClass dash_class
 
AVOutputFormat ff_dash_muxer
 

Macro Definition Documentation

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

Definition at line 1910 of file dashenc.c.

Definition at line 1911 of file dashenc.c.

Enumeration Type Documentation

Enumerator
PALETTE_SEGMENT 
OBJECT_SEGMENT 
PRESENTATION_SEGMENT 
WINDOW_SEGMENT 
DISPLAY_SEGMENT 
SEGMENT_TYPE_AUTO 
SEGMENT_TYPE_MP4 
SEGMENT_TYPE_WEBM 
SEGMENT_TYPE_NB 
SEGMENT_TYPE_MPEGTS 
SEGMENT_TYPE_FMP4 

Definition at line 53 of file dashenc.c.

Function Documentation

static int dashenc_io_open ( AVFormatContext s,
AVIOContext **  pb,
char *  filename,
AVDictionary **  options 
)
static
static void dashenc_io_close ( AVFormatContext s,
AVIOContext **  pb,
char *  filename 
)
static
static const char* get_format_str ( SegmentType  segment_type)
static

Definition at line 215 of file dashenc.c.

Referenced by init_segment_types().

static const char* get_extension_str ( SegmentType  type,
int  single_file 
)
static

Definition at line 223 of file dashenc.c.

Referenced by init_segment_types().

static int handle_io_open_error ( AVFormatContext s,
int  err,
char *  url 
)
static

Definition at line 233 of file dashenc.c.

Referenced by dash_write_packet(), write_hls_media_playlist(), and write_manifest().

static SegmentType select_segment_type ( SegmentType  segment_type,
enum AVCodecID  codec_id 
)
inlinestatic

Definition at line 242 of file dashenc.c.

Referenced by init_segment_types().

static int init_segment_types ( AVFormatContext s)
static

Definition at line 256 of file dashenc.c.

Referenced by dash_init().

static int check_file_extension ( const char *  filename,
const char *  extension 
)
static

Definition at line 287 of file dashenc.c.

Referenced by dash_init().

static void set_vp9_codec_str ( AVFormatContext s,
AVCodecParameters par,
AVRational frame_rate,
char *  str,
int  size 
)
static

Definition at line 297 of file dashenc.c.

Referenced by set_codec_str().

static void set_codec_str ( AVFormatContext s,
AVCodecParameters par,
AVRational frame_rate,
char *  str,
int  size 
)
static

Definition at line 312 of file dashenc.c.

Referenced by dash_init(), and update_stream_extradata().

static int flush_dynbuf ( DASHContext c,
OutputStream os,
int range_length 
)
static

Definition at line 408 of file dashenc.c.

Referenced by dash_flush(), and flush_init_segment().

static void set_http_options ( AVDictionary **  options,
DASHContext c 
)
static
static void get_hls_playlist_name ( char *  playlist_name,
int  string_size,
const char *  base_url,
int  id 
)
static

Definition at line 449 of file dashenc.c.

Referenced by dash_write_trailer(), write_hls_media_playlist(), and write_manifest().

static void get_start_index_number ( OutputStream os,
DASHContext c,
int start_index,
int start_number 
)
static

Definition at line 457 of file dashenc.c.

Referenced by dash_flush(), output_segment_list(), and write_hls_media_playlist().

static void write_hls_media_playlist ( OutputStream os,
AVFormatContext s,
int  representation_id,
int  final,
char *  prefetch_url 
)
static

Definition at line 467 of file dashenc.c.

Referenced by dash_write_packet(), and output_segment_list().

static int flush_init_segment ( AVFormatContext s,
OutputStream os 
)
static

Definition at line 548 of file dashenc.c.

Referenced by dash_write_header(), and dash_write_packet().

static void dash_free ( AVFormatContext s)
static

Definition at line 566 of file dashenc.c.

static void output_segment_list ( OutputStream os,
AVIOContext out,
AVFormatContext s,
int  representation_id,
int  final 
)
static

Definition at line 606 of file dashenc.c.

Referenced by write_adaptation_set().

static char* xmlescape ( const char *  str)
static

Definition at line 675 of file dashenc.c.

Referenced by write_manifest().

static void write_time ( AVIOContext out,
int64_t  time 
)
static

Definition at line 715 of file dashenc.c.

Referenced by write_manifest().

static void format_date_now ( char *  buf,
int  size 
)
static

Definition at line 731 of file dashenc.c.

Referenced by dash_write_packet(), and write_manifest().

static int write_adaptation_set ( AVFormatContext s,
AVIOContext out,
int  as_index,
int  final 
)
static

Definition at line 750 of file dashenc.c.

Referenced by write_manifest().

static int add_adaptation_set ( AVFormatContext s,
AdaptationSet **  as,
enum AVMediaType  type 
)
static

Definition at line 804 of file dashenc.c.

Referenced by parse_adaptation_sets().

static int adaptation_set_add_stream ( AVFormatContext s,
int  as_idx,
int  i 
)
static

Definition at line 821 of file dashenc.c.

Referenced by parse_adaptation_sets().

static int parse_adaptation_sets ( AVFormatContext s)
static

Definition at line 839 of file dashenc.c.

Referenced by dash_init().

static int write_manifest ( AVFormatContext s,
int  final 
)
static

Definition at line 953 of file dashenc.c.

Referenced by dash_flush().

static int dict_copy_entry ( AVDictionary **  dst,
const AVDictionary src,
const char *  key 
)
static

Definition at line 1131 of file dashenc.c.

Referenced by dash_init().

static int dash_init ( AVFormatContext s)
static

Definition at line 1139 of file dashenc.c.

static int dash_write_header ( AVFormatContext s)
static

Definition at line 1380 of file dashenc.c.

static int add_segment ( OutputStream os,
const char *  file,
int64_t  time,
int64_t  duration,
int64_t  start_pos,
int64_t  range_length,
int64_t  index_length,
int  next_exp_index 
)
static

Definition at line 1399 of file dashenc.c.

Referenced by dash_flush().

static void write_styp ( AVIOContext pb)
static

Definition at line 1439 of file dashenc.c.

Referenced by dash_flush(), and dash_write_packet().

static void find_index_range ( AVFormatContext s,
const char *  full_path,
int64_t  pos,
int index_length 
)
static

Definition at line 1449 of file dashenc.c.

Referenced by dash_flush().

static int update_stream_extradata ( AVFormatContext s,
OutputStream os,
AVPacket pkt,
AVRational frame_rate 
)
static

Definition at line 1472 of file dashenc.c.

Referenced by dash_write_packet().

static void dashenc_delete_file ( AVFormatContext s,
char *  filename 
)
static

Definition at line 1497 of file dashenc.c.

Referenced by dash_write_trailer(), and dashenc_delete_segment_file().

static int dashenc_delete_segment_file ( AVFormatContext s,
const char *  file 
)
static

Definition at line 1524 of file dashenc.c.

Referenced by dash_write_trailer(), and dashenc_delete_media_segments().

static void dashenc_delete_media_segments ( AVFormatContext s,
OutputStream os,
int  remove_count 
)
inlinestatic

Definition at line 1552 of file dashenc.c.

Referenced by dash_flush(), and dash_write_trailer().

static int dash_flush ( AVFormatContext s,
int  final,
int  stream 
)
static

Definition at line 1565 of file dashenc.c.

Referenced by dash_write_packet(), and dash_write_trailer().

static int dash_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 1699 of file dashenc.c.

static int dash_write_trailer ( AVFormatContext s)
static

Definition at line 1845 of file dashenc.c.

static int dash_check_bitstream ( struct AVFormatContext s,
const AVPacket avpkt 
)
static

Definition at line 1887 of file dashenc.c.

Variable Documentation

struct codec_string codecs[]
static
Initial value:
= {
{ AV_CODEC_ID_VP8, "vp8" },
{ AV_CODEC_ID_VP9, "vp9" },
{ AV_CODEC_ID_VORBIS, "vorbis" },
{ AV_CODEC_ID_OPUS, "opus" },
{ AV_CODEC_ID_FLAC, "flac" },
{ 0, NULL }
}
#define NULL
Definition: coverity.c:32

Referenced by get_codecs_sorted(), print_codecs(), set_codec_str(), and show_codecs().

struct format_string formats[]
static
Initial value:
= {
{ SEGMENT_TYPE_AUTO, "auto" },
{ SEGMENT_TYPE_MP4, "mp4" },
{ SEGMENT_TYPE_WEBM, "webm" },
{ 0, NULL }
}
#define NULL
Definition: coverity.c:32
const AVOption options[]
static

Definition at line 1912 of file dashenc.c.

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

Definition at line 1947 of file dashenc.c.

AVOutputFormat ff_dash_muxer
Initial value:
= {
.name = "dash",
.long_name = NULL_IF_CONFIG_SMALL("DASH Muxer"),
.extensions = "mpd",
.priv_data_size = sizeof(DASHContext),
.audio_codec = AV_CODEC_ID_AAC,
.video_codec = AV_CODEC_ID_H264,
.deinit = dash_free,
.check_bitstream = dash_check_bitstream,
.priv_class = &dash_class,
}
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:689
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static int dash_init(AVFormatContext *s)
Definition: dashenc.c:1139
static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: dashenc.c:1699
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static int dash_check_bitstream(struct AVFormatContext *s, const AVPacket *avpkt)
Definition: dashenc.c:1887
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:466
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:463
static int dash_write_header(AVFormatContext *s)
Definition: dashenc.c:1380
static int dash_write_trailer(AVFormatContext *s)
Definition: dashenc.c:1845
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:337
static void dash_free(AVFormatContext *s)
Definition: dashenc.c:566
#define AVFMT_TS_NEGATIVE
Format allows muxing negative timestamps.
Definition: avformat.h:482
static const AVClass dash_class
Definition: dashenc.c:1947

Definition at line 1954 of file dashenc.c.