FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
dashenc.c File Reference
#include "config.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/time_internal.h"
#include "avc.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "isom.h"
#include "os_support.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  Segment
 
struct  OutputStream
 
struct  DASHContext
 

Macros

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

Enumerations

enum  DASHTmplId {
  DASH_TMPL_ID_UNDEFINED = -1, DASH_TMPL_ID_ESCAPE, DASH_TMPL_ID_REP_ID, DASH_TMPL_ID_NUMBER,
  DASH_TMPL_ID_BANDWIDTH, DASH_TMPL_ID_TIME
}
 

Functions

static int dash_write (void *opaque, uint8_t *buf, int buf_size)
 
static void set_codec_str (AVFormatContext *s, AVCodecContext *codec, char *str, int size)
 
static void dash_free (AVFormatContext *s)
 
static void output_segment_list (OutputStream *os, AVIOContext *out, DASHContext *c)
 
static DASHTmplId dash_read_tmpl_id (const char *identifier, char *format_tag, size_t format_tag_size, const char **ptr)
 
static void 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 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_manifest (AVFormatContext *s, int final)
 
static int dash_write_header (AVFormatContext *s)
 
static int add_segment (OutputStream *os, const char *file, int64_t time, int duration, int64_t start_pos, int64_t range_length, int64_t index_length)
 
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, AVCodecContext *codec)
 
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)
 

Variables

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 978 of file dashenc.c.

Definition at line 979 of file dashenc.c.

Enumeration Type Documentation

enum DASHTmplId
Enumerator
DASH_TMPL_ID_UNDEFINED 
DASH_TMPL_ID_ESCAPE 
DASH_TMPL_ID_REP_ID 
DASH_TMPL_ID_NUMBER 
DASH_TMPL_ID_BANDWIDTH 
DASH_TMPL_ID_TIME 

Definition at line 42 of file dashenc.c.

Function Documentation

static int dash_write ( void opaque,
uint8_t buf,
int  buf_size 
)
static

Definition at line 99 of file dashenc.c.

Referenced by dash_write_header().

static void set_codec_str ( AVFormatContext s,
AVCodecContext codec,
char *  str,
int  size 
)
static

Definition at line 108 of file dashenc.c.

Referenced by dash_write_header(), and update_stream_extradata().

static void dash_free ( AVFormatContext s)
static

Definition at line 173 of file dashenc.c.

Referenced by dash_write_header(), and dash_write_trailer().

static void output_segment_list ( OutputStream os,
AVIOContext out,
DASHContext c 
)
static

Definition at line 196 of file dashenc.c.

Referenced by write_manifest().

static DASHTmplId dash_read_tmpl_id ( const char *  identifier,
char *  format_tag,
size_t  format_tag_size,
const char **  ptr 
)
static

Definition at line 258 of file dashenc.c.

Referenced by dash_fill_tmpl_params().

static void 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

Definition at line 310 of file dashenc.c.

Referenced by dash_flush(), and dash_write_header().

static char* xmlescape ( const char *  str)
static

Definition at line 371 of file dashenc.c.

Referenced by write_manifest().

static void write_time ( AVIOContext out,
int64_t  time 
)
static

Definition at line 411 of file dashenc.c.

Referenced by write_manifest().

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

Definition at line 427 of file dashenc.c.

Referenced by write_manifest().

static int write_manifest ( AVFormatContext s,
int  final 
)
static

Definition at line 438 of file dashenc.c.

Referenced by dash_flush(), and dash_write_header().

static int dash_write_header ( AVFormatContext s)
static

Definition at line 543 of file dashenc.c.

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

Definition at line 684 of file dashenc.c.

Referenced by dash_flush().

static void write_styp ( AVIOContext pb)
static

Definition at line 718 of file dashenc.c.

Referenced by dash_flush().

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

Definition at line 728 of file dashenc.c.

Referenced by dash_flush().

static int update_stream_extradata ( AVFormatContext s,
OutputStream os,
AVCodecContext codec 
)
static

Definition at line 751 of file dashenc.c.

Referenced by dash_write_packet().

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

Definition at line 774 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 869 of file dashenc.c.

static int dash_write_trailer ( AVFormatContext s)
static

Definition at line 945 of file dashenc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{ "window_size", "number of segments kept in the manifest", OFFSET(window_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, E },
{ "extra_window_size", "number of segments kept outside of the manifest before removing from disk", OFFSET(extra_window_size), AV_OPT_TYPE_INT, { .i64 = 5 }, 0, INT_MAX, E },
{ "min_seg_duration", "minimum segment duration (in microseconds)", OFFSET(min_seg_duration), AV_OPT_TYPE_INT64, { .i64 = 5000000 }, 0, INT_MAX, E },
{ "remove_at_exit", "remove all segments when finished", OFFSET(remove_at_exit), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
{ "use_template", "Use SegmentTemplate instead of SegmentList", OFFSET(use_template), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, E },
{ "use_timeline", "Use SegmentTimeline in SegmentTemplate", OFFSET(use_timeline), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, E },
{ "single_file", "Store all segments in one file, accessed using byte ranges", OFFSET(single_file), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
{ "single_file_name", "DASH-templated name to be used for baseURL. Implies storing all segments in one file, accessed using byte ranges", OFFSET(single_file_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
{ "init_seg_name", "DASH-templated name to used for the initialization segment", OFFSET(init_seg_name), AV_OPT_TYPE_STRING, {.str = "init-stream$RepresentationID$.m4s"}, 0, 0, E },
{ "media_seg_name", "DASH-templated name to used for the media segments", OFFSET(media_seg_name), AV_OPT_TYPE_STRING, {.str = "chunk-stream$RepresentationID$-$Number%05d$.m4s"}, 0, 0, E },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define E
Definition: dashenc.c:979
#define OFFSET(x)
Definition: dashenc.c:978

Definition at line 980 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:980
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
av_default_item_name

Definition at line 994 of file dashenc.c.

AVOutputFormat ff_dash_muxer
Initial value:
= {
.name = "dash",
.long_name = NULL_IF_CONFIG_SMALL("DASH Muxer"),
.priv_data_size = sizeof(DASHContext),
.audio_codec = AV_CODEC_ID_AAC,
.video_codec = AV_CODEC_ID_H264,
.codec_tag = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 },
.priv_class = &dash_class,
}
static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: dashenc.c:869
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
const AVCodecTag ff_mp4_obj_type[]
Definition: isom.c:34
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:471
static int flags
Definition: cpu.c:47
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:465
static int dash_write_header(AVFormatContext *s)
Definition: dashenc.c:543
static int dash_write_trailer(AVFormatContext *s)
Definition: dashenc.c:945
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:493
#define AVFMT_TS_NEGATIVE
Format allows muxing negative timestamps.
Definition: avformat.h:490
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: v4l2enc.c:86
static const AVClass dash_class
Definition: dashenc.c:994

Definition at line 1001 of file dashenc.c.