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 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)
}
 
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 int replace_int_data_in_filename (char *buf, int buf_size, const char *filename, char placeholder, int64_t number)
 
static int hls_delete_old_segments (AVFormatContext *s, 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 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 set_http_options (AVFormatContext *s, AVDictionary **options, HLSContext *c)
 
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 (void)
 
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 48 of file hlsenc.c.

Referenced by hls_encryption_start(), and hls_start().

#define LINE_BUFFER_SIZE   1024

Definition at line 49 of file hlsenc.c.

#define HLS_MICROSECOND_UNIT   1000000

Definition at line 50 of file hlsenc.c.

Referenced by sls_flags_filename_process().

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

Definition at line 1489 of file hlsenc.c.

Definition at line 1490 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 42 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 

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

Function Documentation

static int get_int_from_double ( double  val)
static

Definition at line 155 of file hlsenc.c.

Referenced by hls_window().

static int mkdir_p ( const char *  path)
static

Definition at line 160 of file hlsenc.c.

Referenced by hls_start().

static int replace_int_data_in_filename ( char *  buf,
int  buf_size,
const char *  filename,
char  placeholder,
int64_t  number 
)
static
static int hls_delete_old_segments ( AVFormatContext s,
HLSContext hls 
)
static

Definition at line 245 of file hlsenc.c.

Referenced by hls_append_segment().

static int hls_encryption_start ( AVFormatContext s)
static

Definition at line 352 of file hlsenc.c.

Referenced by hls_start().

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

Definition at line 404 of file hlsenc.c.

Referenced by parse_playlist().

static int hls_mux_init ( AVFormatContext s)
static

Definition at line 412 of file hlsenc.c.

Referenced by hls_write_header().

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

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

Referenced by hls_append_segment().

static int sls_flag_check_duration_size_index ( HLSContext hls)
static

Definition at line 519 of file hlsenc.c.

Referenced by hls_write_header().

static int sls_flag_check_duration_size ( HLSContext hls)
static

Definition at line 542 of file hlsenc.c.

Referenced by hls_write_header().

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

Definition at line 562 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 569 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 623 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 708 of file hlsenc.c.

Referenced by hls_write_header().

static void hls_free_segments ( HLSSegment p)
static

Definition at line 769 of file hlsenc.c.

Referenced by hls_write_trailer().

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

Definition at line 780 of file hlsenc.c.

Referenced by hls_start(), and hls_window().

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

Definition at line 793 of file hlsenc.c.

Referenced by hls_window().

static void hls_rename_temp_file ( AVFormatContext s,
AVFormatContext oc 
)
static

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

Referenced by hls_write_packet(), and hls_write_trailer().

static int hls_start ( AVFormatContext s)
static

Definition at line 950 of file hlsenc.c.

Referenced by hls_write_header(), and hls_write_packet().

static const char* get_default_pattern_localtime_fmt ( void  )
static

Definition at line 1090 of file hlsenc.c.

Referenced by hls_write_header().

static int hls_write_header ( AVFormatContext s)
static

Definition at line 1101 of file hlsenc.c.

static int hls_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 1312 of file hlsenc.c.

static int hls_write_trailer ( struct AVFormatContext s)
static

Definition at line 1438 of file hlsenc.c.

Variable Documentation

const AVOption options[]
static

Definition at line 1491 of file hlsenc.c.

Referenced by hls_delete_old_segments(), 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:85
static const AVOption options[]
Definition: hlsenc.c:1491
av_default_item_name

Definition at line 1533 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:672
static int hls_write_trailer(struct AVFormatContext *s)
Definition: hlsenc.c:1438
#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:1101
#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
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: hlsenc.c:1312
#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:1533

Definition at line 1541 of file hlsenc.c.