aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-02-15 13:46:38 +0100
committerAnton Khirnov <anton@khirnov.net>2016-02-22 11:29:00 +0100
commitd082078a88da3b3e926197d0d2aa9fa322123b76 (patch)
tree9e5b7453e338c5afdceedf3ad54b324d30bdbd2a
parent7fbb3b5b9857276b4cd17b2a530c7e0880d2bc0a (diff)
downloadffmpeg-d082078a88da3b3e926197d0d2aa9fa322123b76.tar.gz
dashenc: eliminate ffurl_* usage
Now all IO should go through the IO callbacks and be interceptable by the caller.
-rw-r--r--libavformat/dashenc.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 12d3a8c45b..8c75d189b0 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -61,7 +61,7 @@ typedef struct OutputStream {
AVFormatContext *ctx;
int ctx_inited;
uint8_t iobuf[32768];
- URLContext *out;
+ AVIOContext *out;
int packets_written;
char initfile[1024];
int64_t init_start_pos;
@@ -100,7 +100,7 @@ static int dash_write(void *opaque, uint8_t *buf, int buf_size)
{
OutputStream *os = opaque;
if (os->out)
- ffurl_write(os->out, buf, buf_size);
+ avio_write(os->out, buf, buf_size);
return buf_size;
}
@@ -182,8 +182,7 @@ static void dash_free(AVFormatContext *s)
av_write_trailer(os->ctx);
if (os->ctx && os->ctx->pb)
av_free(os->ctx->pb);
- ffurl_close(os->out);
- os->out = NULL;
+ ff_format_io_close(s, &os->out);
if (os->ctx)
avformat_free_context(os->ctx);
for (j = 0; j < os->nb_segments; j++)
@@ -632,7 +631,7 @@ static int dash_write_header(AVFormatContext *s)
dash_fill_tmpl_params(os->initfile, sizeof(os->initfile), c->init_seg_name, i, 0, os->bit_rate, 0);
}
snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
- ret = ffurl_open(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
+ ret = s->io_open(s, &os->out, filename, AVIO_FLAG_WRITE, NULL);
if (ret < 0)
goto fail;
os->init_start_pos = 0;
@@ -726,18 +725,18 @@ static void find_index_range(AVFormatContext *s, const char *full_path,
int64_t pos, int *index_length)
{
uint8_t buf[8];
- URLContext *fd;
+ AVIOContext *pb;
int ret;
- ret = ffurl_open(&fd, full_path, AVIO_FLAG_READ, &s->interrupt_callback, NULL);
+ ret = s->io_open(s, &pb, full_path, AVIO_FLAG_READ, NULL);
if (ret < 0)
return;
- if (ffurl_seek(fd, pos, SEEK_SET) != pos) {
- ffurl_close(fd);
+ if (avio_seek(pb, pos, SEEK_SET) != pos) {
+ ff_format_io_close(s, &pb);
return;
}
- ret = ffurl_read(fd, buf, 8);
- ffurl_close(fd);
+ ret = avio_read(pb, buf, 8);
+ ff_format_io_close(s, &pb);
if (ret < 8)
return;
if (AV_RL32(&buf[4]) != MKTAG('s', 'i', 'd', 'x'))
@@ -800,10 +799,8 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
if (!os->init_range_length) {
av_write_frame(os->ctx, NULL);
os->init_range_length = avio_tell(os->ctx->pb);
- if (!c->single_file) {
- ffurl_close(os->out);
- os->out = NULL;
- }
+ if (!c->single_file)
+ ff_format_io_close(s, &os->out);
}
start_pos = avio_tell(os->ctx->pb);
@@ -812,7 +809,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
dash_fill_tmpl_params(filename, sizeof(filename), c->media_seg_name, i, os->segment_index, os->bit_rate, os->start_pts);
snprintf(full_path, sizeof(full_path), "%s%s", c->dirname, filename);
snprintf(temp_path, sizeof(temp_path), "%s.tmp", full_path);
- ret = ffurl_open(&os->out, temp_path, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
+ ret = s->io_open(s, &os->out, temp_path, AVIO_FLAG_WRITE, NULL);
if (ret < 0)
break;
write_styp(os->ctx->pb);
@@ -828,8 +825,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
if (c->single_file) {
find_index_range(s, full_path, start_pos, &index_length);
} else {
- ffurl_close(os->out);
- os->out = NULL;
+ ff_format_io_close(s, &os->out);
ret = ff_rename(temp_path, full_path);
if (ret < 0)
break;