|
|
@@ -93,7 +93,7 @@ struct variant { |
|
|
|
uint8_t key[16]; |
|
|
|
}; |
|
|
|
|
|
|
|
typedef struct AppleHTTPContext { |
|
|
|
typedef struct HLSContext { |
|
|
|
int n_variants; |
|
|
|
struct variant **variants; |
|
|
|
int cur_seq_no; |
|
|
@@ -101,7 +101,7 @@ typedef struct AppleHTTPContext { |
|
|
|
int first_packet; |
|
|
|
int64_t first_timestamp; |
|
|
|
AVIOInterruptCB *interrupt_callback; |
|
|
|
} AppleHTTPContext; |
|
|
|
} HLSContext; |
|
|
|
|
|
|
|
static int read_chomp_line(AVIOContext *s, char *buf, int maxlen) |
|
|
|
{ |
|
|
@@ -120,7 +120,7 @@ static void free_segment_list(struct variant *var) |
|
|
|
var->n_segments = 0; |
|
|
|
} |
|
|
|
|
|
|
|
static void free_variant_list(AppleHTTPContext *c) |
|
|
|
static void free_variant_list(HLSContext *c) |
|
|
|
{ |
|
|
|
int i; |
|
|
|
for (i = 0; i < c->n_variants; i++) { |
|
|
@@ -150,7 +150,7 @@ static void reset_packet(AVPacket *pkt) |
|
|
|
pkt->data = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
static struct variant *new_variant(AppleHTTPContext *c, int bandwidth, |
|
|
|
static struct variant *new_variant(HLSContext *c, int bandwidth, |
|
|
|
const char *url, const char *base) |
|
|
|
{ |
|
|
|
struct variant *var = av_mallocz(sizeof(struct variant)); |
|
|
@@ -197,7 +197,7 @@ static void handle_key_args(struct key_info *info, const char *key, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static int parse_playlist(AppleHTTPContext *c, const char *url, |
|
|
|
static int parse_playlist(HLSContext *c, const char *url, |
|
|
|
struct variant *var, AVIOContext *in) |
|
|
|
{ |
|
|
|
int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0; |
|
|
@@ -371,7 +371,7 @@ static int open_input(struct variant *var) |
|
|
|
static int read_data(void *opaque, uint8_t *buf, int buf_size) |
|
|
|
{ |
|
|
|
struct variant *v = opaque; |
|
|
|
AppleHTTPContext *c = v->parent->priv_data; |
|
|
|
HLSContext *c = v->parent->priv_data; |
|
|
|
int ret, i; |
|
|
|
|
|
|
|
restart: |
|
|
@@ -443,9 +443,9 @@ reload: |
|
|
|
goto restart; |
|
|
|
} |
|
|
|
|
|
|
|
static int applehttp_read_header(AVFormatContext *s) |
|
|
|
static int hls_read_header(AVFormatContext *s) |
|
|
|
{ |
|
|
|
AppleHTTPContext *c = s->priv_data; |
|
|
|
HLSContext *c = s->priv_data; |
|
|
|
int ret = 0, i, j, stream_offset = 0; |
|
|
|
|
|
|
|
c->interrupt_callback = &s->interrupt_callback; |
|
|
@@ -554,7 +554,7 @@ fail: |
|
|
|
|
|
|
|
static int recheck_discard_flags(AVFormatContext *s, int first) |
|
|
|
{ |
|
|
|
AppleHTTPContext *c = s->priv_data; |
|
|
|
HLSContext *c = s->priv_data; |
|
|
|
int i, changed = 0; |
|
|
|
|
|
|
|
/* Check if any new streams are needed */ |
|
|
@@ -587,9 +587,9 @@ static int recheck_discard_flags(AVFormatContext *s, int first) |
|
|
|
return changed; |
|
|
|
} |
|
|
|
|
|
|
|
static int applehttp_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
|
{ |
|
|
|
AppleHTTPContext *c = s->priv_data; |
|
|
|
HLSContext *c = s->priv_data; |
|
|
|
int ret, i, minvariant = -1; |
|
|
|
|
|
|
|
if (c->first_packet) { |
|
|
@@ -635,18 +635,18 @@ start: |
|
|
|
return AVERROR_EOF; |
|
|
|
} |
|
|
|
|
|
|
|
static int applehttp_close(AVFormatContext *s) |
|
|
|
static int hls_close(AVFormatContext *s) |
|
|
|
{ |
|
|
|
AppleHTTPContext *c = s->priv_data; |
|
|
|
HLSContext *c = s->priv_data; |
|
|
|
|
|
|
|
free_variant_list(c); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static int applehttp_read_seek(AVFormatContext *s, int stream_index, |
|
|
|
static int hls_read_seek(AVFormatContext *s, int stream_index, |
|
|
|
int64_t timestamp, int flags) |
|
|
|
{ |
|
|
|
AppleHTTPContext *c = s->priv_data; |
|
|
|
HLSContext *c = s->priv_data; |
|
|
|
int i, j, ret; |
|
|
|
|
|
|
|
if ((flags & AVSEEK_FLAG_BYTE) || !c->variants[0]->finished) |
|
|
@@ -686,7 +686,7 @@ static int applehttp_read_seek(AVFormatContext *s, int stream_index, |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
static int applehttp_probe(AVProbeData *p) |
|
|
|
static int hls_probe(AVProbeData *p) |
|
|
|
{ |
|
|
|
/* Require #EXTM3U at the start, and either one of the ones below |
|
|
|
* somewhere for a proper match. */ |
|
|
@@ -702,10 +702,10 @@ static int applehttp_probe(AVProbeData *p) |
|
|
|
AVInputFormat ff_hls_demuxer = { |
|
|
|
.name = "hls", |
|
|
|
.long_name = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming format"), |
|
|
|
.priv_data_size = sizeof(AppleHTTPContext), |
|
|
|
.read_probe = applehttp_probe, |
|
|
|
.read_header = applehttp_read_header, |
|
|
|
.read_packet = applehttp_read_packet, |
|
|
|
.read_close = applehttp_close, |
|
|
|
.read_seek = applehttp_read_seek, |
|
|
|
.priv_data_size = sizeof(HLSContext), |
|
|
|
.read_probe = hls_probe, |
|
|
|
.read_header = hls_read_header, |
|
|
|
.read_packet = hls_read_packet, |
|
|
|
.read_close = hls_close, |
|
|
|
.read_seek = hls_read_seek, |
|
|
|
}; |