FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
hlsenc.c File Reference
#include "config.h"
#include <float.h>
#include <stdint.h>
#include "libavutil/avassert.h"
#include "libavutil/mathematics.h"
#include "libavutil/parseutils.h"
#include "libavutil/avstring.h"
#include "libavutil/opt.h"
#include "libavutil/log.h"
#include "libavutil/time_internal.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "os_support.h"

Go to the source code of this file.

Data Structures

struct  HLSSegment
 
struct  HLSContext
 

Macros

#define KEYSIZE   16
 
#define LINE_BUFFER_SIZE   1024
 
#define OFFSET(x)   offsetof(HLSContext, x)
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  HLSFlags {
  HLS_SINGLE_FILE = (1 << 0), HLS_DELETE_SEGMENTS = (1 << 1), HLS_ROUND_DURATIONS = (1 << 2), HLS_DISCONT_START = (1 << 3),
  HLS_OMIT_ENDLIST = (1 << 4)
}
 

Functions

static int hls_delete_old_segments (HLSContext *hls)
 
static int hls_encryption_start (AVFormatContext *s)
 
static int hls_mux_init (AVFormatContext *s)
 
static int hls_append_segment (HLSContext *hls, double duration, int64_t pos, int64_t size)
 
static void hls_free_segments (HLSSegment *p)
 
static void set_http_options (AVDictionary **options, HLSContext *c)
 
static int hls_window (AVFormatContext *s, int last)
 
static int hls_start (AVFormatContext *s)
 
static int hls_write_header (AVFormatContext *s)
 
static int hls_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static int hls_write_trailer (struct AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass hls_class
 
AVOutputFormat ff_hls_muxer
 

Macro Definition Documentation

#define KEYSIZE   16

Definition at line 42 of file hlsenc.c.

Referenced by hls_encryption_start(), and hls_start().

#define LINE_BUFFER_SIZE   1024

Definition at line 43 of file hlsenc.c.

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

Definition at line 854 of file hlsenc.c.

Definition at line 855 of file hlsenc.c.

Enumeration Type Documentation

enum HLSFlags
Enumerator
HLS_SINGLE_FILE 
HLS_DELETE_SEGMENTS 
HLS_ROUND_DURATIONS 
HLS_DISCONT_START 
HLS_OMIT_ENDLIST 

Definition at line 58 of file hlsenc.c.

Function Documentation

static int hls_delete_old_segments ( HLSContext hls)
static

Definition at line 121 of file hlsenc.c.

Referenced by hls_append_segment().

static int hls_encryption_start ( AVFormatContext s)
static

Definition at line 206 of file hlsenc.c.

Referenced by hls_start().

static int hls_mux_init ( AVFormatContext s)
static

Definition at line 258 of file hlsenc.c.

Referenced by hls_write_header().

static int hls_append_segment ( HLSContext hls,
double  duration,
int64_t  pos,
int64_t  size 
)
static

Definition at line 307 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static void hls_free_segments ( HLSSegment p)
static

Definition at line 359 of file hlsenc.c.

Referenced by hls_write_trailer().

static void set_http_options ( AVDictionary **  options,
HLSContext c 
)
static

Definition at line 370 of file hlsenc.c.

Referenced by hls_start(), and hls_window().

static int hls_window ( AVFormatContext s,
int  last 
)
static

Definition at line 376 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static int hls_start ( AVFormatContext s)
static

Definition at line 486 of file hlsenc.c.

Referenced by hls_write_header(), and hls_write_packet().

static int hls_write_header ( AVFormatContext s)
static

Definition at line 584 of file hlsenc.c.

static int hls_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 740 of file hlsenc.c.

static int hls_write_trailer ( struct AVFormatContext s)
static

Definition at line 818 of file hlsenc.c.

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{"start_number", "set first number in the sequence", OFFSET(start_sequence),AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, E},
{"hls_time", "set segment length in seconds", OFFSET(time), AV_OPT_TYPE_FLOAT, {.dbl = 2}, 0, FLT_MAX, E},
{"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E},
{"hls_ts_options","set hls mpegts list of options for the container format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{"hls_vtt_options","set hls vtt list of options for the container format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{"hls_wrap", "set number after which the index wraps", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E},
{"hls_allow_cache", "explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, E},
{"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{"hls_segment_filename", "filename template for segment files", OFFSET(segment_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{"hls_key_info_file", "file with key URI and key file path", OFFSET(key_info_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{"hls_subtitle_path", "set path of hls subtitles", OFFSET(subtitle_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{"hls_flags", "set flags affecting HLS playlist and media file generation", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX, E, "flags"},
{"single_file", "generate a single media file indexed with byte ranges", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SINGLE_FILE }, 0, UINT_MAX, E, "flags"},
{"delete_segments", "delete segment files that are no longer part of the playlist", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DELETE_SEGMENTS }, 0, UINT_MAX, E, "flags"},
{"round_durations", "round durations in m3u8 to whole numbers", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_ROUND_DURATIONS }, 0, UINT_MAX, E, "flags"},
{"discont_start", "start the playlist with a discontinuity tag", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX, E, "flags"},
{"omit_endlist", "Do not append an endlist when ending stream", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_OMIT_ENDLIST }, 0, UINT_MAX, E, "flags"},
{ "use_localtime", "set filename expansion with strftime at segment creation", OFFSET(use_localtime), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
{"method", "set the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: hlsenc.c:854
#define wrap(func)
Definition: neontest.h:65
#define E
Definition: hlsenc.c:855
static int flags
Definition: cpu.c:47
static const uint8_t start_sequence[]
Definition: rtpdec_h264.c:65

Definition at line 856 of file hlsenc.c.

Referenced by hls_start(), hls_window(), and hls_write_header().

const AVClass hls_class
static
Initial value:
= {
.class_name = "hls muxer",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:70
static const AVOption options[]
Definition: hlsenc.c:856
av_default_item_name

Definition at line 880 of file hlsenc.c.

AVOutputFormat ff_hls_muxer
Initial value:
= {
.name = "hls",
.long_name = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
.extensions = "m3u8",
.priv_data_size = sizeof(HLSContext),
.audio_codec = AV_CODEC_ID_AAC,
.video_codec = AV_CODEC_ID_H264,
.subtitle_codec = AV_CODEC_ID_WEBVTT,
.priv_class = &hls_class,
}
static int hls_write_trailer(struct AVFormatContext *s)
Definition: hlsenc.c:818
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:494
static int hls_write_header(AVFormatContext *s)
Definition: hlsenc.c:584
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: hlsenc.c:740
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:477
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:497
static const AVClass hls_class
Definition: hlsenc.c:880
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: v4l2enc.c:86

Definition at line 888 of file hlsenc.c.