avformat/hls: remove redundant code

Reviewed-by: Jun Zhao <mypopydev@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
pull/298/head
Steven Liu 7 years ago
parent b3b3a3e3ce
commit 6fbfb20faf
  1. 27
      libavformat/hls.c

@ -937,14 +937,8 @@ static struct segment *next_segment(struct playlist *pls)
return pls->segments[n];
}
enum ReadFromURLMode {
READ_NORMAL,
READ_COMPLETE,
};
static int read_from_url(struct playlist *pls, struct segment *seg,
uint8_t *buf, int buf_size,
enum ReadFromURLMode mode)
uint8_t *buf, int buf_size)
{
int ret;
@ -952,12 +946,9 @@ static int read_from_url(struct playlist *pls, struct segment *seg,
if (seg->size >= 0)
buf_size = FFMIN(buf_size, seg->size - pls->cur_seg_offset);
if (mode == READ_COMPLETE) {
ret = avio_read(pls->input, buf, buf_size);
if (ret != buf_size)
av_log(NULL, AV_LOG_ERROR, "Could not read complete segment.\n");
} else
ret = avio_read(pls->input, buf, buf_size);
ret = avio_read(pls->input, buf, buf_size);
if (ret != buf_size)
av_log(NULL, AV_LOG_ERROR, "Could not read complete segment.\n");
if (ret > 0)
pls->cur_seg_offset += ret;
@ -1077,7 +1068,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf,
while (1) {
/* see if we can retrieve enough data for ID3 header */
if (*len < ID3v2_HEADER_SIZE && buf_size >= ID3v2_HEADER_SIZE) {
bytes = read_from_url(pls, seg, buf + *len, ID3v2_HEADER_SIZE - *len, READ_COMPLETE);
bytes = read_from_url(pls, seg, buf + *len, ID3v2_HEADER_SIZE - *len);
if (bytes > 0) {
if (bytes == ID3v2_HEADER_SIZE - *len)
@ -1129,7 +1120,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf,
if (remaining > 0) {
/* read the rest of the tag in */
if (read_from_url(pls, seg, pls->id3_buf + id3_buf_pos, remaining, READ_COMPLETE) != remaining)
if (read_from_url(pls, seg, pls->id3_buf + id3_buf_pos, remaining) != remaining)
break;
id3_buf_pos += remaining;
av_log(pls->ctx, AV_LOG_DEBUG, "Stripped additional %d HLS ID3 bytes\n", remaining);
@ -1143,7 +1134,7 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf,
/* re-fill buffer for the caller unless EOF */
if (*len >= 0 && (fill_buf || *len == 0)) {
bytes = read_from_url(pls, seg, buf + *len, buf_size - *len, READ_NORMAL);
bytes = read_from_url(pls, seg, buf + *len, buf_size - *len);
/* ignore error if we already had some data */
if (bytes >= 0)
@ -1303,7 +1294,7 @@ static int update_init_section(struct playlist *pls, struct segment *seg)
av_fast_malloc(&pls->init_sec_buf, &pls->init_sec_buf_size, sec_size);
ret = read_from_url(pls, seg->init_section, pls->init_sec_buf,
pls->init_sec_buf_size, READ_COMPLETE);
pls->init_sec_buf_size);
ff_format_io_close(pls->parent, &pls->input);
if (ret < 0)
@ -1498,7 +1489,7 @@ reload:
}
seg = current_segment(v);
ret = read_from_url(v, seg, buf, buf_size, READ_NORMAL);
ret = read_from_url(v, seg, buf, buf_size);
if (ret > 0) {
if (just_opened && v->is_id3_timestamped != 0) {
/* Intercept ID3 tags here, elementary audio streams are required

Loading…
Cancel
Save