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)
}
 
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 hls_mux_init (AVFormatContext *s)
 
static int hls_append_segment (struct AVFormatContext *s, 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 906 of file hlsenc.c.

Definition at line 907 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.

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 67 of file hlsenc.c.

Function Documentation

static int hls_delete_old_segments ( HLSContext hls)
static

Definition at line 130 of file hlsenc.c.

Referenced by hls_append_segment().

static int hls_encryption_start ( AVFormatContext s)
static

Definition at line 215 of file hlsenc.c.

Referenced by hls_start().

static int hls_mux_init ( AVFormatContext s)
static

Definition at line 267 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 316 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static void hls_free_segments ( HLSSegment p)
static

Definition at line 391 of file hlsenc.c.

Referenced by hls_write_trailer().

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

Definition at line 402 of file hlsenc.c.

Referenced by hls_start(), and hls_window().

static int hls_window ( AVFormatContext s,
int  last 
)
static

Definition at line 408 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static int hls_start ( AVFormatContext s)
static

Definition at line 523 of file hlsenc.c.

Referenced by hls_write_header(), and hls_write_packet().

static int hls_write_header ( AVFormatContext s)
static

Definition at line 636 of file hlsenc.c.

static int hls_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 792 of file hlsenc.c.

static int hls_write_trailer ( struct AVFormatContext s)
static

Definition at line 870 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 },
{"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:906
#define wrap(func)
Definition: neontest.h:65
#define E
Definition: hlsenc.c:907
static int flags
Definition: cpu.c:47
static const uint8_t start_sequence[]
Definition: rtpdec_h264.c:65

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

Definition at line 936 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:870
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:493
static int hls_write_header(AVFormatContext *s)
Definition: hlsenc.c:636
#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:792
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:476
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:498
static const AVClass hls_class
Definition: hlsenc.c:936
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: v4l2enc.c:86

Definition at line 944 of file hlsenc.c.