diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-11-25 02:14:15 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-11-25 02:14:15 +0100 |
commit | 71ecfcf2d31e4f906f52c3450f4fb46c5087f50e (patch) | |
tree | 2b1e8944703b072c4ce61b751147e912a08480ed /libavformat/dashenc.c | |
parent | b83beb131f0d3fdb2d472665f5325f02aeac7d7e (diff) | |
parent | b9d08c77a44390b0848c06f20bc0e9e951ba6a3c (diff) | |
download | ffmpeg-71ecfcf2d31e4f906f52c3450f4fb46c5087f50e.tar.gz |
Merge commit 'b9d08c77a44390b0848c06f20bc0e9e951ba6a3c'
* commit 'b9d08c77a44390b0848c06f20bc0e9e951ba6a3c':
lavf: Don't try to update files atomically with renames on windows
Conflicts:
libavformat/dashenc.c
libavformat/hdsenc.c
libavformat/internal.h
libavformat/smoothstreamingenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/dashenc.c')
-rw-r--r-- | libavformat/dashenc.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index b840db909e..0f31d2d397 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -296,13 +296,15 @@ static int write_manifest(AVFormatContext *s, int final) DASHContext *c = s->priv_data; AVIOContext *out; char temp_filename[1024]; + const char *write_filename; int ret, i; AVDictionaryEntry *title = av_dict_get(s->metadata, "title", NULL, 0); snprintf(temp_filename, sizeof(temp_filename), "%s.tmp", s->filename); - ret = avio_open2(&out, temp_filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL); + write_filename = USE_RENAME_REPLACE ? temp_filename : s->filename; + ret = avio_open2(&out, write_filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL); if (ret < 0) { - av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename); + av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", write_filename); return ret; } avio_printf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); @@ -392,7 +394,7 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "</MPD>\n"); avio_flush(out); avio_close(out); - return ff_rename(temp_filename, s->filename, s); + return USE_RENAME_REPLACE ? ff_rename(temp_filename, s->filename, s) : 0; } static int dash_write_header(AVFormatContext *s) @@ -608,6 +610,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream) for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; char filename[1024] = "", full_path[1024], temp_path[1024]; + const char *write_path; int64_t start_pos = avio_tell(os->ctx->pb); int range_length, index_length = 0; @@ -630,7 +633,8 @@ static int dash_flush(AVFormatContext *s, int final, int stream) snprintf(filename, sizeof(filename), "chunk-stream%d-%05d.m4s", i, os->segment_index); 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); + write_path = USE_RENAME_REPLACE ? temp_path : full_path; + ret = ffurl_open(&os->out, write_path, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL); if (ret < 0) break; write_styp(os->ctx->pb); @@ -645,7 +649,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream) } else { ffurl_close(os->out); os->out = NULL; - ret = ff_rename(temp_path, full_path, s); + ret = USE_RENAME_REPLACE ? ff_rename(temp_path, full_path, s) : 0; if (ret < 0) break; } |