mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 18:10:13 +01:00
avformat: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@@ -192,6 +192,8 @@ static int set_segment_filename(AVFormatContext *s)
|
||||
AVFormatContext *oc = seg->avf;
|
||||
size_t size;
|
||||
int ret;
|
||||
char buf[1024];
|
||||
char *new_name;
|
||||
|
||||
if (seg->segment_idx_wrap)
|
||||
seg->segment_idx %= seg->segment_idx_wrap;
|
||||
@@ -200,18 +202,22 @@ static int set_segment_filename(AVFormatContext *s)
|
||||
struct tm *tm, tmpbuf;
|
||||
time(&now0);
|
||||
tm = localtime_r(&now0, &tmpbuf);
|
||||
if (!strftime(oc->filename, sizeof(oc->filename), s->filename, tm)) {
|
||||
if (!strftime(buf, sizeof(buf), s->url, tm)) {
|
||||
av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
} else if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
|
||||
s->filename, seg->segment_idx) < 0) {
|
||||
av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->filename);
|
||||
} else if (av_get_frame_filename(buf, sizeof(buf),
|
||||
s->url, seg->segment_idx) < 0) {
|
||||
av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->url);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
new_name = av_strdup(buf);
|
||||
if (!new_name)
|
||||
return AVERROR(ENOMEM);
|
||||
ff_format_set_url(oc, new_name);
|
||||
|
||||
/* copy modified name in list entry */
|
||||
size = strlen(av_basename(oc->filename)) + 1;
|
||||
size = strlen(av_basename(oc->url)) + 1;
|
||||
if (seg->entry_prefix)
|
||||
size += strlen(seg->entry_prefix);
|
||||
|
||||
@@ -219,7 +225,7 @@ static int set_segment_filename(AVFormatContext *s)
|
||||
return ret;
|
||||
snprintf(seg->cur_entry.filename, size, "%s%s",
|
||||
seg->entry_prefix ? seg->entry_prefix : "",
|
||||
av_basename(oc->filename));
|
||||
av_basename(oc->url));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -245,8 +251,8 @@ static int segment_start(AVFormatContext *s, int write_header)
|
||||
if ((err = set_segment_filename(s)) < 0)
|
||||
return err;
|
||||
|
||||
if ((err = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, NULL)) < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename);
|
||||
if ((err = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, NULL)) < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->url);
|
||||
return err;
|
||||
}
|
||||
if (!seg->individual_header_trailer)
|
||||
@@ -360,7 +366,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
|
||||
|
||||
if (ret < 0)
|
||||
av_log(s, AV_LOG_ERROR, "Failure occurred when ending segment '%s'\n",
|
||||
oc->filename);
|
||||
oc->url);
|
||||
|
||||
if (seg->list) {
|
||||
if (seg->list_size || seg->list_type == LIST_TYPE_M3U8) {
|
||||
@@ -403,7 +409,7 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
|
||||
}
|
||||
|
||||
av_log(s, AV_LOG_VERBOSE, "segment:'%s' count:%d ended\n",
|
||||
seg->avf->filename, seg->segment_count);
|
||||
seg->avf->url, seg->segment_count);
|
||||
seg->segment_count++;
|
||||
|
||||
if (seg->increment_tc) {
|
||||
@@ -726,7 +732,7 @@ static int seg_init(AVFormatContext *s)
|
||||
seg->reference_stream_index,
|
||||
av_get_media_type_string(s->streams[seg->reference_stream_index]->codecpar->codec_type));
|
||||
|
||||
seg->oformat = av_guess_format(seg->format, s->filename, NULL);
|
||||
seg->oformat = av_guess_format(seg->format, s->url, NULL);
|
||||
|
||||
if (!seg->oformat)
|
||||
return AVERROR_MUXER_NOT_FOUND;
|
||||
@@ -745,9 +751,9 @@ static int seg_init(AVFormatContext *s)
|
||||
|
||||
if (seg->write_header_trailer) {
|
||||
if ((ret = s->io_open(s, &oc->pb,
|
||||
seg->header_filename ? seg->header_filename : oc->filename,
|
||||
seg->header_filename ? seg->header_filename : oc->url,
|
||||
AVIO_FLAG_WRITE, NULL)) < 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename);
|
||||
av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->url);
|
||||
return ret;
|
||||
}
|
||||
if (!seg->individual_header_trailer)
|
||||
@@ -830,7 +836,7 @@ static int seg_write_header(AVFormatContext *s)
|
||||
} else {
|
||||
close_null_ctxp(&oc->pb);
|
||||
}
|
||||
if ((ret = oc->io_open(oc, &oc->pb, oc->filename, AVIO_FLAG_WRITE, NULL)) < 0)
|
||||
if ((ret = oc->io_open(oc, &oc->pb, oc->url, AVIO_FLAG_WRITE, NULL)) < 0)
|
||||
return ret;
|
||||
if (!seg->individual_header_trailer)
|
||||
oc->pb->seekable = 0;
|
||||
@@ -917,7 +923,7 @@ calc_times:
|
||||
|
||||
if (seg->segment_frame_count == 0) {
|
||||
av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet stream:%d pts:%s pts_time:%s frame:%d\n",
|
||||
seg->avf->filename, pkt->stream_index,
|
||||
seg->avf->url, pkt->stream_index,
|
||||
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base), seg->frame_count);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user