segment: Use the public av_write_header/av_write_trailer functions
With this change, the segmenter muxer doesn't rely on anything not available/supported to libavformat external users, making the segmenter muxer do things just like a normal segmenter application using libavformat would do. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
0edae4e628
commit
73871dc96f
1 changed files with 3 additions and 27 deletions
|
@ -62,42 +62,18 @@ static int segment_start(AVFormatContext *s)
|
||||||
&s->interrupt_callback, NULL)) < 0)
|
&s->interrupt_callback, NULL)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (!oc->priv_data && oc->oformat->priv_data_size > 0) {
|
if ((err = avformat_write_header(oc, NULL)) < 0)
|
||||||
oc->priv_data = av_mallocz(oc->oformat->priv_data_size);
|
return err;
|
||||||
if (!oc->priv_data) {
|
|
||||||
avio_close(oc->pb);
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
|
||||||
if (oc->oformat->priv_class) {
|
|
||||||
*(const AVClass**)oc->priv_data = oc->oformat->priv_class;
|
|
||||||
av_opt_set_defaults(oc->priv_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((err = oc->oformat->write_header(oc)) < 0) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
avio_close(oc->pb);
|
|
||||||
av_freep(&oc->priv_data);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int segment_end(AVFormatContext *oc)
|
static int segment_end(AVFormatContext *oc)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (oc->oformat->write_trailer)
|
av_write_trailer(oc);
|
||||||
ret = oc->oformat->write_trailer(oc);
|
|
||||||
|
|
||||||
avio_close(oc->pb);
|
avio_close(oc->pb);
|
||||||
if (oc->oformat->priv_class)
|
|
||||||
av_opt_free(oc->priv_data);
|
|
||||||
av_freep(&oc->priv_data);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue