mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-09-12 02:14:56 +02:00
Merge commit '7785ce1c769369abf85b276148548a5510aabb5f'
* commit '7785ce1c769369abf85b276148548a5510aabb5f':
lavf: replace rename() with ff_rename()
Conflicts:
libavformat/hdsenc.c
libavformat/internal.h
See: 95d2fc6a76
Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
97a8f4dd11
@ -204,11 +204,7 @@ static int write_manifest(AVFormatContext *s, int final)
|
|||||||
avio_printf(out, "</manifest>\n");
|
avio_printf(out, "</manifest>\n");
|
||||||
avio_flush(out);
|
avio_flush(out);
|
||||||
avio_close(out);
|
avio_close(out);
|
||||||
if (rename(temp_filename, filename) == -1) {
|
return ff_rename(temp_filename, filename);
|
||||||
av_log(s, AV_LOG_ERROR, "failed to rename file %s to %s\n", temp_filename, filename);
|
|
||||||
return AVERROR(errno);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_size(AVIOContext *out, int64_t pos)
|
static void update_size(AVIOContext *out, int64_t pos)
|
||||||
@ -289,11 +285,7 @@ static int write_abst(AVFormatContext *s, OutputStream *os, int final)
|
|||||||
update_size(out, afrt_pos);
|
update_size(out, afrt_pos);
|
||||||
update_size(out, 0);
|
update_size(out, 0);
|
||||||
avio_close(out);
|
avio_close(out);
|
||||||
if (rename(temp_filename, filename) == -1) {
|
return ff_rename(temp_filename, filename);
|
||||||
av_log(s, AV_LOG_ERROR, "failed to rename file %s to %s\n", temp_filename, filename);
|
|
||||||
return AVERROR(errno);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init_file(AVFormatContext *s, OutputStream *os, int64_t start_ts)
|
static int init_file(AVFormatContext *s, OutputStream *os, int64_t start_ts)
|
||||||
@ -488,10 +480,9 @@ static int hds_flush(AVFormatContext *s, OutputStream *os, int final,
|
|||||||
|
|
||||||
snprintf(target_filename, sizeof(target_filename),
|
snprintf(target_filename, sizeof(target_filename),
|
||||||
"%s/stream%dSeg1-Frag%d", s->filename, index, os->fragment_index);
|
"%s/stream%dSeg1-Frag%d", s->filename, index, os->fragment_index);
|
||||||
if (rename(os->temp_filename, target_filename) == -1) {
|
ret = ff_rename(os->temp_filename, target_filename);
|
||||||
av_log(s, AV_LOG_ERROR, "failed to rename file %s to %s\n", os->temp_filename, target_filename);
|
if (ret < 0)
|
||||||
return AVERROR(errno);
|
return ret;
|
||||||
}
|
|
||||||
add_fragment(os, target_filename, os->frag_start_ts, end_ts - os->frag_start_ts);
|
add_fragment(os, target_filename, os->frag_start_ts, end_ts - os->frag_start_ts);
|
||||||
|
|
||||||
if (!final) {
|
if (!final) {
|
||||||
|
@ -371,6 +371,20 @@ AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precisio
|
|||||||
*/
|
*/
|
||||||
int ff_generate_avci_extradata(AVStream *st);
|
int ff_generate_avci_extradata(AVStream *st);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap errno on rename() error.
|
||||||
|
*
|
||||||
|
* @param oldpath source path
|
||||||
|
* @param newpath destination path
|
||||||
|
* @return 0 or AVERROR on failure
|
||||||
|
*/
|
||||||
|
static inline int ff_rename(const char *oldpath, const char *newpath)
|
||||||
|
{
|
||||||
|
if (rename(oldpath, newpath) == -1)
|
||||||
|
return AVERROR(errno);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end
|
* Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end
|
||||||
* which is always set to 0.
|
* which is always set to 0.
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
|
#include "libavutil/file.h"
|
||||||
#include "libavutil/mathematics.h"
|
#include "libavutil/mathematics.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
|
|
||||||
@ -282,8 +283,7 @@ static int write_manifest(AVFormatContext *s, int final)
|
|||||||
avio_printf(out, "</SmoothStreamingMedia>\n");
|
avio_printf(out, "</SmoothStreamingMedia>\n");
|
||||||
avio_flush(out);
|
avio_flush(out);
|
||||||
avio_close(out);
|
avio_close(out);
|
||||||
rename(temp_filename, filename);
|
return ff_rename(temp_filename, filename);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ism_write_header(AVFormatContext *s)
|
static int ism_write_header(AVFormatContext *s)
|
||||||
@ -540,7 +540,9 @@ static int ism_flush(AVFormatContext *s, int final)
|
|||||||
snprintf(header_filename, sizeof(header_filename), "%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
|
snprintf(header_filename, sizeof(header_filename), "%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
|
||||||
snprintf(target_filename, sizeof(target_filename), "%s/Fragments(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
|
snprintf(target_filename, sizeof(target_filename), "%s/Fragments(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
|
||||||
copy_moof(s, filename, header_filename, moof_size);
|
copy_moof(s, filename, header_filename, moof_size);
|
||||||
rename(filename, target_filename);
|
ret = ff_rename(filename, target_filename);
|
||||||
|
if (ret < 0)
|
||||||
|
break;
|
||||||
add_fragment(os, target_filename, header_filename, start_ts, duration,
|
add_fragment(os, target_filename, header_filename, start_ts, duration,
|
||||||
os->cur_start_pos, size);
|
os->cur_start_pos, size);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user