FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
hls.c File Reference

Apple HTTP Live Streaming demuxer http://tools.ietf.org/html/draft-pantos-http-live-streaming. More...

#include "libavutil/avstring.h"
#include "libavutil/avassert.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "libavutil/time.h"
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
#include "url.h"
#include "id3v2.h"

Go to the source code of this file.

Data Structures

struct  segment
 
struct  playlist
 
struct  rendition
 
struct  variant
 
struct  HLSContext
 
struct  variant_info
 
struct  key_info
 
struct  rendition_info
 

Macros

#define INITIAL_BUFFER_SIZE   32768
 
#define MAX_FIELD_LEN   64
 
#define MAX_CHARACTERISTICS_LEN   512
 
#define MPEG_TIME_BASE   90000
 
#define MPEG_TIME_BASE_Q   (AVRational){1, MPEG_TIME_BASE}
 
#define OFFSET(x)   offsetof(HLSContext, x)
 
#define FLAGS   AV_OPT_FLAG_DECODING_PARAM
 

Enumerations

enum  KeyType { KEY_NONE, KEY_AES_128, KEY_SAMPLE_AES }
 
enum  PlaylistType { PLS_TYPE_UNSPECIFIED, PLS_TYPE_EVENT, PLS_TYPE_VOD }
 
enum  ReadFromURLMode { READ_NORMAL, READ_COMPLETE }
 

Functions

static int read_chomp_line (AVIOContext *s, char *buf, int maxlen)
 
static void free_segment_list (struct playlist *pls)
 
static void free_playlist_list (HLSContext *c)
 
static void free_variant_list (HLSContext *c)
 
static void free_rendition_list (HLSContext *c)
 
static void reset_packet (AVPacket *pkt)
 
static struct playlistnew_playlist (HLSContext *c, const char *url, const char *base)
 
static struct variantnew_variant (HLSContext *c, struct variant_info *info, const char *url, const char *base)
 
static void handle_variant_args (struct variant_info *info, const char *key, int key_len, char **dest, int *dest_len)
 
static void handle_key_args (struct key_info *info, const char *key, int key_len, char **dest, int *dest_len)
 
static struct renditionnew_rendition (HLSContext *c, struct rendition_info *info, const char *url_base)
 
static void handle_rendition_args (struct rendition_info *info, const char *key, int key_len, char **dest, int *dest_len)
 
static int ensure_playlist (HLSContext *c, struct playlist **pls, const char *url)
 
static int parse_playlist (HLSContext *c, const char *url, struct playlist *pls, AVIOContext *in)
 
static int read_from_url (struct playlist *pls, uint8_t *buf, int buf_size, enum ReadFromURLMode mode)
 
static void parse_id3 (AVFormatContext *s, AVIOContext *pb, AVDictionary **metadata, int64_t *dts, ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta **extra_meta)
 
static int id3_has_changed_values (struct playlist *pls, AVDictionary *metadata, ID3v2ExtraMetaAPIC *apic)
 
static void handle_id3 (AVIOContext *pb, struct playlist *pls)
 
static void intercept_id3 (struct playlist *pls, uint8_t *buf, int buf_size, int *len)
 
static void update_options (char **dest, const char *name, void *src)
 
static int open_input (HLSContext *c, struct playlist *pls)
 
static int64_t default_reload_interval (struct playlist *pls)
 
static int read_data (void *opaque, uint8_t *buf, int buf_size)
 
static int playlist_in_multiple_variants (HLSContext *c, struct playlist *pls)
 
static void add_renditions_to_variant (HLSContext *c, struct variant *var, enum AVMediaType type, const char *group_id)
 
static void add_metadata_from_renditions (AVFormatContext *s, struct playlist *pls, enum AVMediaType type)
 
static int find_timestamp_in_playlist (HLSContext *c, struct playlist *pls, int64_t timestamp, int *seq_no)
 
static int select_cur_seq_no (HLSContext *c, struct playlist *pls)
 
static int hls_read_header (AVFormatContext *s)
 
static int recheck_discard_flags (AVFormatContext *s, int first)
 
static void fill_timing_for_id3_timestamped_stream (struct playlist *pls)
 
static AVRational get_timebase (struct playlist *pls)
 
static int compare_ts_with_wrapdetect (int64_t ts_a, struct playlist *pls_a, int64_t ts_b, struct playlist *pls_b)
 
static int hls_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int hls_close (AVFormatContext *s)
 
static int hls_read_seek (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 
static int hls_probe (AVProbeData *p)
 

Variables

static const AVOption hls_options []
 
static const AVClass hls_class
 
AVInputFormat ff_hls_demuxer
 

Detailed Description

Apple HTTP Live Streaming demuxer http://tools.ietf.org/html/draft-pantos-http-live-streaming.

Definition in file hls.c.

Macro Definition Documentation

#define INITIAL_BUFFER_SIZE   32768

Definition at line 42 of file hls.c.

Referenced by hls_read_header().

#define MAX_FIELD_LEN   64

Definition at line 44 of file hls.c.

#define MAX_CHARACTERISTICS_LEN   512

Definition at line 45 of file hls.c.

#define MPEG_TIME_BASE   90000

Definition at line 47 of file hls.c.

Referenced by hls_read_header().

#define MPEG_TIME_BASE_Q   (AVRational){1, MPEG_TIME_BASE}
#define OFFSET (   x)    offsetof(HLSContext, x)

Definition at line 1728 of file hls.c.

#define FLAGS   AV_OPT_FLAG_DECODING_PARAM

Definition at line 1729 of file hls.c.

Enumeration Type Documentation

enum KeyType
Enumerator
KEY_NONE 
KEY_AES_128 
KEY_SAMPLE_AES 

Definition at line 62 of file hls.c.

Enumerator
PLS_TYPE_UNSPECIFIED 
PLS_TYPE_EVENT 
PLS_TYPE_VOD 

Definition at line 80 of file hls.c.

Enumerator
READ_NORMAL 
READ_COMPLETE 

Definition at line 683 of file hls.c.

Function Documentation

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

Definition at line 187 of file hls.c.

Referenced by parse_playlist().

static void free_segment_list ( struct playlist pls)
static

Definition at line 195 of file hls.c.

Referenced by free_playlist_list(), and parse_playlist().

static void free_playlist_list ( HLSContext c)
static

Definition at line 207 of file hls.c.

Referenced by hls_close(), and hls_read_header().

static void free_variant_list ( HLSContext c)
static

Definition at line 233 of file hls.c.

Referenced by hls_close(), and hls_read_header().

static void free_rendition_list ( HLSContext c)
static

Definition at line 245 of file hls.c.

Referenced by hls_close(), and hls_read_header().

static void reset_packet ( AVPacket pkt)
static

Definition at line 258 of file hls.c.

Referenced by hls_read_packet(), hls_read_seek(), and new_playlist().

static struct playlist* new_playlist ( HLSContext c,
const char *  url,
const char *  base 
)
static

Definition at line 264 of file hls.c.

Referenced by new_rendition(), and new_variant().

static struct variant* new_variant ( HLSContext c,
struct variant_info info,
const char *  url,
const char *  base 
)
static

Definition at line 289 of file hls.c.

Referenced by ensure_playlist(), and parse_playlist().

static void handle_variant_args ( struct variant_info info,
const char *  key,
int  key_len,
char **  dest,
int *  dest_len 
)
static

Definition at line 315 of file hls.c.

Referenced by parse_playlist().

static void handle_key_args ( struct key_info info,
const char *  key,
int  key_len,
char **  dest,
int *  dest_len 
)
static

Definition at line 339 of file hls.c.

Referenced by parse_playlist().

static struct rendition* new_rendition ( HLSContext c,
struct rendition_info info,
const char *  url_base 
)
static

Definition at line 366 of file hls.c.

Referenced by parse_playlist().

static void handle_rendition_args ( struct rendition_info info,
const char *  key,
int  key_len,
char **  dest,
int *  dest_len 
)
static

Definition at line 443 of file hls.c.

Referenced by parse_playlist().

static int ensure_playlist ( HLSContext c,
struct playlist **  pls,
const char *  url 
)
static

Definition at line 485 of file hls.c.

Referenced by parse_playlist().

static int parse_playlist ( HLSContext c,
const char *  url,
struct playlist pls,
AVIOContext in 
)
static

Definition at line 497 of file hls.c.

Referenced by hls_read_header(), read_data(), and select_cur_seq_no().

static int read_from_url ( struct playlist pls,
uint8_t buf,
int  buf_size,
enum ReadFromURLMode  mode 
)
static

Definition at line 689 of file hls.c.

Referenced by intercept_id3(), and read_data().

static void parse_id3 ( AVFormatContext s,
AVIOContext pb,
AVDictionary **  metadata,
int64_t *  dts,
ID3v2ExtraMetaAPIC **  apic,
ID3v2ExtraMeta **  extra_meta 
)
static

Definition at line 711 of file hls.c.

Referenced by handle_id3().

static int id3_has_changed_values ( struct playlist pls,
AVDictionary metadata,
ID3v2ExtraMetaAPIC apic 
)
static

Definition at line 737 of file hls.c.

Referenced by handle_id3().

static void handle_id3 ( AVIOContext pb,
struct playlist pls 
)
static

Definition at line 766 of file hls.c.

Referenced by intercept_id3().

static void intercept_id3 ( struct playlist pls,
uint8_t buf,
int  buf_size,
int *  len 
)
static

Definition at line 808 of file hls.c.

Referenced by read_data().

static void update_options ( char **  dest,
const char *  name,
void src 
)
static

Definition at line 908 of file hls.c.

Referenced by hls_read_header(), and open_input().

static int open_input ( HLSContext c,
struct playlist pls 
)
static

Definition at line 916 of file hls.c.

Referenced by read_data().

static int64_t default_reload_interval ( struct playlist pls)
static

Definition at line 1013 of file hls.c.

Referenced by read_data(), and select_cur_seq_no().

static int read_data ( void opaque,
uint8_t buf,
int  buf_size 
)
static

Definition at line 1020 of file hls.c.

Referenced by hls_read_header(), and pulse_read_packet().

static int playlist_in_multiple_variants ( HLSContext c,
struct playlist pls 
)
static

Definition at line 1115 of file hls.c.

Referenced by hls_read_header().

static void add_renditions_to_variant ( HLSContext c,
struct variant var,
enum AVMediaType  type,
const char *  group_id 
)
static

Definition at line 1134 of file hls.c.

Referenced by hls_read_header().

static void add_metadata_from_renditions ( AVFormatContext s,
struct playlist pls,
enum AVMediaType  type 
)
static

Definition at line 1158 of file hls.c.

Referenced by hls_read_header().

static int find_timestamp_in_playlist ( HLSContext c,
struct playlist pls,
int64_t  timestamp,
int *  seq_no 
)
static

Definition at line 1190 of file hls.c.

Referenced by hls_read_seek(), and select_cur_seq_no().

static int select_cur_seq_no ( HLSContext c,
struct playlist pls 
)
static

Definition at line 1216 of file hls.c.

Referenced by hls_read_header(), and recheck_discard_flags().

static int hls_read_header ( AVFormatContext s)
static

Definition at line 1255 of file hls.c.

static int recheck_discard_flags ( AVFormatContext s,
int  first 
)
static

Definition at line 1449 of file hls.c.

Referenced by hls_read_packet().

static void fill_timing_for_id3_timestamped_stream ( struct playlist pls)
static

Definition at line 1490 of file hls.c.

Referenced by hls_read_packet().

static AVRational get_timebase ( struct playlist pls)
static

Definition at line 1515 of file hls.c.

Referenced by compare_ts_with_wrapdetect(), and hls_read_packet().

static int compare_ts_with_wrapdetect ( int64_t  ts_a,
struct playlist pls_a,
int64_t  ts_b,
struct playlist pls_b 
)
static

Definition at line 1523 of file hls.c.

Referenced by hls_read_packet().

static int hls_read_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 1532 of file hls.c.

static int hls_close ( AVFormatContext s)
static

Definition at line 1625 of file hls.c.

static int hls_read_seek ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 1635 of file hls.c.

static int hls_probe ( AVProbeData p)
static

Definition at line 1715 of file hls.c.

Variable Documentation

const AVOption hls_options[]
static
Initial value:
= {
{"live_start_index", "segment index to start live streams at (negative values are from the end)",
OFFSET(live_start_index), FF_OPT_TYPE_INT, {.i64 = -3}, INT_MIN, INT_MAX, FLAGS},
{NULL}
}
#define NULL
Definition: coverity.c:32
#define FLAGS
Definition: hls.c:1729
#define OFFSET(x)
Definition: hls.c:1728

Definition at line 1730 of file hls.c.

const AVClass hls_class
static
Initial value:
= {
.class_name = "hls,applehttp",
.item_name = av_default_item_name,
.option = hls_options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:62
av_default_item_name
static const AVOption hls_options[]
Definition: hls.c:1730

Definition at line 1736 of file hls.c.

AVInputFormat ff_hls_demuxer
Initial value:
= {
.name = "hls,applehttp",
.long_name = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"),
.priv_class = &hls_class,
.priv_data_size = sizeof(HLSContext),
}
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
static const AVClass hls_class
Definition: hls.c:1736
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
static int read_probe(AVProbeData *pd)
Definition: jvdec.c:55
static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: hls.c:1532
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:620
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
static int hls_read_header(AVFormatContext *s)
Definition: hls.c:1255
static int hls_probe(AVProbeData *p)
Definition: hls.c:1715
static int hls_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: hls.c:1635
static int hls_close(AVFormatContext *s)
Definition: hls.c:1625

Definition at line 1743 of file hls.c.