| 147 | } |
| 148 | |
| 149 | static int segment_mux_init(AVFormatContext *s) |
| 150 | { |
| 151 | SegmentContext *seg = s->priv_data; |
| 152 | AVFormatContext *oc; |
| 153 | int i; |
| 154 | int ret; |
| 155 | |
| 156 | ret = avformat_alloc_output_context2(&seg->avf, seg->oformat, NULL, NULL); |
| 157 | if (ret < 0) |
| 158 | return ret; |
| 159 | oc = seg->avf; |
| 160 | |
| 161 | oc->interrupt_callback = s->interrupt_callback; |
| 162 | oc->max_delay = s->max_delay; |
| 163 | av_dict_copy(&oc->metadata, s->metadata, 0); |
| 164 | oc->opaque = s->opaque; |
| 165 | oc->io_close2 = s->io_close2; |
| 166 | oc->io_open = s->io_open; |
| 167 | oc->flags = s->flags; |
| 168 | |
| 169 | for (i = 0; i < s->nb_streams; i++) { |
| 170 | AVStream *st, *ist = s->streams[i]; |
| 171 | AVCodecParameters *ipar = ist->codecpar, *opar; |
| 172 | |
| 173 | st = ff_stream_clone(oc, ist); |
| 174 | if (!st) |
| 175 | return AVERROR(ENOMEM); |
| 176 | opar = st->codecpar; |
| 177 | if (!oc->oformat->codec_tag || |
| 178 | av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == opar->codec_id || |
| 179 | av_codec_get_tag(oc->oformat->codec_tag, ipar->codec_id) <= 0) { |
| 180 | opar->codec_tag = ipar->codec_tag; |
| 181 | } else { |
| 182 | opar->codec_tag = 0; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | static int set_segment_filename(AVFormatContext *s) |
| 190 | { |
no test coverage detected