mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-12-04 17:46:45 +00:00
avformat/hls: split read_from_url() out of read_data()
Useful for ID3 parsing. Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
This commit is contained in:
parent
f7c7fc1369
commit
1cb8d986b8
@ -600,6 +600,24 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* read from URLContext, limiting read to current segment */
|
||||
static int read_from_url(struct playlist *pls, uint8_t *buf, int buf_size)
|
||||
{
|
||||
int ret;
|
||||
struct segment *seg = pls->segments[pls->cur_seq_no - pls->start_seq_no];
|
||||
|
||||
/* limit read if the segment was only a part of a file */
|
||||
if (seg->size >= 0)
|
||||
buf_size = FFMIN(buf_size, seg->size - pls->cur_seg_offset);
|
||||
|
||||
ret = ffurl_read(pls->input, buf, buf_size);
|
||||
|
||||
if (ret > 0)
|
||||
pls->cur_seg_offset += ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int open_input(HLSContext *c, struct playlist *pls)
|
||||
{
|
||||
AVDictionary *opts = NULL;
|
||||
@ -702,8 +720,6 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size)
|
||||
struct playlist *v = opaque;
|
||||
HLSContext *c = v->parent->priv_data;
|
||||
int ret, i;
|
||||
int actual_read_size;
|
||||
struct segment *seg;
|
||||
|
||||
if (!v->needed)
|
||||
return AVERROR_EOF;
|
||||
@ -754,16 +770,9 @@ reload:
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
/* limit read if the segment was only a part of a file */
|
||||
seg = v->segments[v->cur_seq_no - v->start_seq_no];
|
||||
if (seg->size >= 0)
|
||||
actual_read_size = FFMIN(buf_size, seg->size - v->cur_seg_offset);
|
||||
else
|
||||
actual_read_size = buf_size;
|
||||
|
||||
ret = ffurl_read(v->input, buf, actual_read_size);
|
||||
ret = read_from_url(v, buf, buf_size);
|
||||
if (ret > 0) {
|
||||
v->cur_seg_offset += ret;
|
||||
return ret;
|
||||
}
|
||||
ffurl_close(v->input);
|
||||
|
Loading…
Reference in New Issue
Block a user