summaryrefslogtreecommitdiff
path: root/libavformat/smoothstreamingenc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/smoothstreamingenc.c')
-rw-r--r--libavformat/smoothstreamingenc.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 6af8b3991c..07173a96f9 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -2,20 +2,20 @@
* Live smooth streaming fragmenter
* Copyright (c) 2012 Martin Storsjo
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -179,13 +179,13 @@ static void ism_free(AVFormatContext *s)
if (os->ctx && os->ctx_inited)
av_write_trailer(os->ctx);
if (os->ctx && os->ctx->pb)
- av_free(os->ctx->pb);
+ av_freep(&os->ctx->pb);
if (os->ctx)
avformat_free_context(os->ctx);
- av_free(os->private_str);
+ av_freep(&os->private_str);
for (j = 0; j < os->nb_fragments; j++)
- av_free(os->fragments[j]);
- av_free(os->fragments);
+ av_freep(&os->fragments[j]);
+ av_freep(&os->fragments);
}
av_freep(&c->streams);
}
@@ -283,7 +283,7 @@ static int write_manifest(AVFormatContext *s, int final)
avio_printf(out, "</SmoothStreamingMedia>\n");
avio_flush(out);
avio_close(out);
- return ff_rename(temp_filename, filename);
+ return ff_rename(temp_filename, filename, s);
}
static int ism_write_header(AVFormatContext *s)
@@ -294,6 +294,7 @@ static int ism_write_header(AVFormatContext *s)
if (mkdir(s->filename, 0777) == -1 && errno != EEXIST) {
ret = AVERROR(errno);
+ av_log(s, AV_LOG_ERROR, "mkdir failed\n");
goto fail;
}
@@ -303,7 +304,7 @@ static int ism_write_header(AVFormatContext *s)
goto fail;
}
- c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
+ c->streams = av_mallocz_array(s->nb_streams, sizeof(*c->streams));
if (!c->streams) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -314,7 +315,6 @@ static int ism_write_header(AVFormatContext *s)
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
- char buf[10];
if (!s->streams[i]->codec->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
@@ -324,6 +324,7 @@ static int ism_write_header(AVFormatContext *s)
snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate);
if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) {
ret = AVERROR(errno);
+ av_log(s, AV_LOG_ERROR, "mkdir failed\n");
goto fail;
}
@@ -350,8 +351,7 @@ static int ism_write_header(AVFormatContext *s)
goto fail;
}
- snprintf(buf, sizeof(buf), "%d", c->lookahead_count);
- av_dict_set(&opts, "ism_lookahead", buf, 0);
+ av_dict_set_int(&opts, "ism_lookahead", c->lookahead_count, 0);
av_dict_set(&opts, "movflags", "frag_custom", 0);
if ((ret = avformat_write_header(ctx, &opts)) < 0) {
goto fail;
@@ -433,7 +433,7 @@ static int parse_fragment(AVFormatContext *s, const char *filename, int64_t *sta
if (len < 8 || len >= *moof_size)
goto fail;
if (tag == MKTAG('u','u','i','d')) {
- const uint8_t tfxd[] = {
+ static const uint8_t tfxd[] = {
0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
};
@@ -541,7 +541,7 @@ 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(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);
- ret = ff_rename(filename, target_filename);
+ ret = ff_rename(filename, target_filename, s);
if (ret < 0)
break;
add_fragment(os, target_filename, header_filename, start_ts, duration,
@@ -559,7 +559,7 @@ static int ism_flush(AVFormatContext *s, int final)
for (j = 0; j < remove; j++) {
unlink(os->fragments[j]->file);
unlink(os->fragments[j]->infofile);
- av_free(os->fragments[j]);
+ av_freep(&os->fragments[j]);
}
os->nb_fragments -= remove;
memmove(os->fragments, os->fragments + remove, os->nb_fragments * sizeof(*os->fragments));
@@ -596,7 +596,7 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt)
}
os->packets_written++;
- return ff_write_chained(os->ctx, 0, pkt, s);
+ return ff_write_chained(os->ctx, 0, pkt, s, 0);
}
static int ism_write_trailer(AVFormatContext *s)