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), HLS_SPLIT_BY_TIME = (1 << 5), HLS_APPEND_LIST = (1 << 6)
}
 
enum  PlaylistType {
  PLS_TYPE_UNSPECIFIED, PLS_TYPE_EVENT, PLS_TYPE_VOD, PLAYLIST_TYPE_NONE,
  PLAYLIST_TYPE_EVENT, PLAYLIST_TYPE_VOD, PLAYLIST_TYPE_NB
}
 

Functions

static int hls_delete_old_segments (HLSContext *hls)
 
static int hls_encryption_start (AVFormatContext *s)
 
static int read_chomp_line (AVIOContext *s, char *buf, int maxlen)
 
static int hls_mux_init (AVFormatContext *s)
 
static int hls_append_segment (struct AVFormatContext *s, HLSContext *hls, double duration, int64_t pos, int64_t size)
 
static int parse_playlist (AVFormatContext *s, const char *url)
 
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 970 of file hlsenc.c.

Definition at line 971 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 
HLS_SPLIT_BY_TIME 
HLS_APPEND_LIST 

Definition at line 58 of file hlsenc.c.

Enumerator
PLS_TYPE_UNSPECIFIED 
PLS_TYPE_EVENT 
PLS_TYPE_VOD 
PLAYLIST_TYPE_NONE 
PLAYLIST_TYPE_EVENT 
PLAYLIST_TYPE_VOD 
PLAYLIST_TYPE_NB 

Definition at line 69 of file hlsenc.c.

Function Documentation

static int hls_delete_old_segments ( HLSContext hls)
static

Definition at line 132 of file hlsenc.c.

Referenced by hls_append_segment().

static int hls_encryption_start ( AVFormatContext s)
static

Definition at line 217 of file hlsenc.c.

Referenced by hls_start().

static int read_chomp_line ( AVIOContext s,
char *  buf,
int  maxlen 
)
static

Definition at line 269 of file hlsenc.c.

Referenced by parse_playlist().

static int hls_mux_init ( AVFormatContext s)
static

Definition at line 277 of file hlsenc.c.

Referenced by hls_write_header().

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

Definition at line 326 of file hlsenc.c.

Referenced by hls_write_packet(), hls_write_trailer(), and parse_playlist().

static int parse_playlist ( AVFormatContext s,
const char *  url 
)
static

Definition at line 401 of file hlsenc.c.

Referenced by hls_write_header().

static void hls_free_segments ( HLSSegment p)
static

Definition at line 449 of file hlsenc.c.

Referenced by hls_write_trailer().

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

Definition at line 460 of file hlsenc.c.

Referenced by hls_start(), and hls_window().

static int hls_window ( AVFormatContext s,
int  last 
)
static

Definition at line 466 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static int hls_start ( AVFormatContext s)
static

Definition at line 581 of file hlsenc.c.

Referenced by hls_write_header(), and hls_write_packet().

static int hls_write_header ( AVFormatContext s)
static

Definition at line 696 of file hlsenc.c.

static int hls_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 856 of file hlsenc.c.

static int hls_write_trailer ( struct AVFormatContext s)
static

Definition at line 934 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"},
{"split_by_time", "split the hls segment by time which user set by hls_time", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SPLIT_BY_TIME }, 0, UINT_MAX, E, "flags"},
{"append_list", "append the new segments into old hls segment list", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_APPEND_LIST }, 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 },
{"use_localtime_mkdir", "create last directory component in strftime-generated filename", OFFSET(use_localtime_mkdir), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
{"hls_playlist_type", "set the HLS playlist type", OFFSET(pl_type), AV_OPT_TYPE_INT, {.i64 = PLAYLIST_TYPE_NONE }, 0, PLAYLIST_TYPE_NB-1, E, "pl_type" },
{"event", "EVENT playlist", 0, AV_OPT_TYPE_CONST, {.i64 = PLAYLIST_TYPE_EVENT }, INT_MIN, INT_MAX, E, "pl_type" },
{"vod", "VOD playlist", 0, AV_OPT_TYPE_CONST, {.i64 = PLAYLIST_TYPE_VOD }, INT_MIN, INT_MAX, E, "pl_type" },
{"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:970
#define wrap(func)
Definition: neontest.h:65
#define E
Definition: hlsenc.c:971
static int flags
Definition: cpu.c:47
static const uint8_t start_sequence[]
Definition: rtpdec_h264.c:65

Definition at line 972 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:972
av_default_item_name

Definition at line 1002 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:934
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:495
static int hls_write_header(AVFormatContext *s)
Definition: hlsenc.c:696
#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:856
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:478
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:344
static const AVClass hls_class
Definition: hlsenc.c:1002
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: v4l2enc.c:86

Definition at line 1010 of file hlsenc.c.