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/intreadwrite.h"
#include "libavutil/random_seed.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 HLS_MICROSECOND_UNIT   1000000
 
#define OFFSET(x)   offsetof(HLSContext, x)
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 

Enumerations

enum  StartSequenceSourceType { HLS_START_SEQUENCE_AS_START_NUMBER = 0, HLS_START_SEQUENCE_AS_SECONDS_SINCE_EPOCH = 1, HLS_START_SEQUENCE_AS_FORMATTED_DATETIME = 2 }
 
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), HLS_PROGRAM_DATE_TIME = (1 << 7),
  HLS_SECOND_LEVEL_SEGMENT_INDEX = (1 << 8), HLS_SECOND_LEVEL_SEGMENT_DURATION = (1 << 9), HLS_SECOND_LEVEL_SEGMENT_SIZE = (1 << 10), HLS_TEMP_FILE = (1 << 11),
  HLS_PERIODIC_REKEY = (1 << 12)
}
 
enum  SegmentType {
  PALETTE_SEGMENT = 0x14, OBJECT_SEGMENT = 0x15, PRESENTATION_SEGMENT = 0x16, WINDOW_SEGMENT = 0x17,
  DISPLAY_SEGMENT = 0x80, SEGMENT_TYPE_MPEGTS, SEGMENT_TYPE_FMP4
}
 
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 get_int_from_double (double val)
 
static int mkdir_p (const char *path)
 
static void set_http_options (AVFormatContext *s, AVDictionary **options, HLSContext *c)
 
static int replace_int_data_in_filename (char *buf, int buf_size, const char *filename, char placeholder, int64_t number)
 
static void write_styp (AVIOContext *pb)
 
static int hls_delete_old_segments (AVFormatContext *s, HLSContext *hls)
 
static int randomize (uint8_t *buf, int len)
 
static int do_encrypt (AVFormatContext *s)
 
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 HLSSegmentfind_segment_by_filename (HLSSegment *segment, const char *filename)
 
static int sls_flags_filename_process (struct AVFormatContext *s, HLSContext *hls, HLSSegment *en, double duration, int64_t pos, int64_t size)
 
static int sls_flag_check_duration_size_index (HLSContext *hls)
 
static int sls_flag_check_duration_size (HLSContext *hls)
 
static void sls_flag_file_rename (HLSContext *hls, char *old_filename)
 
static int sls_flag_use_localtime_filename (AVFormatContext *oc, HLSContext *c)
 
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 write_m3u8_head_block (HLSContext *hls, AVIOContext *out, int version, int target_duration, int64_t sequence)
 
static void hls_rename_temp_file (AVFormatContext *s, AVFormatContext *oc)
 
static int hls_window (AVFormatContext *s, int last)
 
static int hls_start (AVFormatContext *s)
 
static const char * get_default_pattern_localtime_fmt (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 56 of file hlsenc.c.

Referenced by do_encrypt(), hls_encryption_start(), and hls_start().

#define LINE_BUFFER_SIZE   1024

Definition at line 57 of file hlsenc.c.

#define HLS_MICROSECOND_UNIT   1000000

Definition at line 58 of file hlsenc.c.

Referenced by sls_flags_filename_process().

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

Definition at line 1804 of file hlsenc.c.

Definition at line 1805 of file hlsenc.c.

Enumeration Type Documentation

Enumerator
HLS_START_SEQUENCE_AS_START_NUMBER 
HLS_START_SEQUENCE_AS_SECONDS_SINCE_EPOCH 
HLS_START_SEQUENCE_AS_FORMATTED_DATETIME 

Definition at line 50 of file hlsenc.c.

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 
HLS_PROGRAM_DATE_TIME 
HLS_SECOND_LEVEL_SEGMENT_INDEX 
HLS_SECOND_LEVEL_SEGMENT_DURATION 
HLS_SECOND_LEVEL_SEGMENT_SIZE 
HLS_TEMP_FILE 
HLS_PERIODIC_REKEY 

Definition at line 74 of file hlsenc.c.

Enumerator
PALETTE_SEGMENT 
OBJECT_SEGMENT 
PRESENTATION_SEGMENT 
WINDOW_SEGMENT 
DISPLAY_SEGMENT 
SEGMENT_TYPE_MPEGTS 
SEGMENT_TYPE_FMP4 

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

Function Documentation

static int get_int_from_double ( double  val)
static

Definition at line 183 of file hlsenc.c.

Referenced by hls_window().

static int mkdir_p ( const char *  path)
static

Definition at line 188 of file hlsenc.c.

Referenced by hls_start().

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

Definition at line 221 of file hlsenc.c.

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

static int replace_int_data_in_filename ( char *  buf,
int  buf_size,
const char *  filename,
char  placeholder,
int64_t  number 
)
static
static void write_styp ( AVIOContext pb)
static

Definition at line 289 of file hlsenc.c.

Referenced by hls_start().

static int hls_delete_old_segments ( AVFormatContext s,
HLSContext hls 
)
static

Definition at line 299 of file hlsenc.c.

Referenced by hls_append_segment().

static int randomize ( uint8_t buf,
int  len 
)
static

Definition at line 406 of file hlsenc.c.

Referenced by do_encrypt().

static int do_encrypt ( AVFormatContext s)
static

Definition at line 420 of file hlsenc.c.

Referenced by hls_start().

static int hls_encryption_start ( AVFormatContext s)
static

Definition at line 489 of file hlsenc.c.

Referenced by hls_start().

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

Definition at line 541 of file hlsenc.c.

Referenced by parse_playlist().

static int hls_mux_init ( AVFormatContext s)
static

Definition at line 549 of file hlsenc.c.

Referenced by hls_write_header().

static HLSSegment* find_segment_by_filename ( HLSSegment segment,
const char *  filename 
)
static

Definition at line 652 of file hlsenc.c.

Referenced by hls_append_segment().

static int sls_flags_filename_process ( struct AVFormatContext s,
HLSContext hls,
HLSSegment en,
double  duration,
int64_t  pos,
int64_t  size 
)
static

Definition at line 662 of file hlsenc.c.

Referenced by hls_append_segment().

static int sls_flag_check_duration_size_index ( HLSContext hls)
static

Definition at line 708 of file hlsenc.c.

Referenced by hls_write_header().

static int sls_flag_check_duration_size ( HLSContext hls)
static

Definition at line 731 of file hlsenc.c.

Referenced by hls_write_header().

static void sls_flag_file_rename ( HLSContext hls,
char *  old_filename 
)
static

Definition at line 751 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static int sls_flag_use_localtime_filename ( AVFormatContext oc,
HLSContext c 
)
static

Definition at line 758 of file hlsenc.c.

Referenced by hls_start().

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

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

Referenced by hls_write_header().

static void hls_free_segments ( HLSSegment p)
static

Definition at line 983 of file hlsenc.c.

Referenced by hls_write_trailer().

static void write_m3u8_head_block ( HLSContext hls,
AVIOContext out,
int  version,
int  target_duration,
int64_t  sequence 
)
static

Definition at line 994 of file hlsenc.c.

Referenced by hls_window().

static void hls_rename_temp_file ( AVFormatContext s,
AVFormatContext oc 
)
static

Definition at line 1007 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static int hls_window ( AVFormatContext s,
int  last 
)
static

Definition at line 1018 of file hlsenc.c.

Referenced by hls_write_packet(), and hls_write_trailer().

static int hls_start ( AVFormatContext s)
static

Definition at line 1163 of file hlsenc.c.

Referenced by hls_write_header(), and hls_write_packet().

static const char* get_default_pattern_localtime_fmt ( AVFormatContext s)
static

Definition at line 1319 of file hlsenc.c.

Referenced by hls_write_header().

static int hls_write_header ( AVFormatContext s)
static

Definition at line 1335 of file hlsenc.c.

static int hls_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 1604 of file hlsenc.c.

static int hls_write_trailer ( struct AVFormatContext s)
static

Definition at line 1750 of file hlsenc.c.

Variable Documentation

const AVOption options[]
static

Definition at line 1806 of file hlsenc.c.

Referenced by hls_delete_old_segments(), hls_mux_init(), hls_start(), and hls_window().

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:86
static const AVOption options[]
Definition: hlsenc.c:1806
av_default_item_name

Definition at line 1858 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 void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:671
static int hls_write_trailer(struct AVFormatContext *s)
Definition: hlsenc.c:1750
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:495
static int flags
Definition: log.c:57
static int hls_write_header(AVFormatContext *s)
Definition: hlsenc.c:1335
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:485
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: hlsenc.c:1604
#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:337
static const AVClass hls_class
Definition: hlsenc.c:1858

Definition at line 1866 of file hlsenc.c.