| 207 | } |
| 208 | |
| 209 | static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt) |
| 210 | { |
| 211 | MuxStream *ms = ms_from_ost(ost); |
| 212 | AVFormatContext *s = mux->fc; |
| 213 | int64_t fs; |
| 214 | uint64_t frame_num; |
| 215 | int ret; |
| 216 | |
| 217 | fs = filesize(s->pb); |
| 218 | atomic_store(&mux->last_filesize, fs); |
| 219 | if (fs >= mux->limit_filesize) { |
| 220 | ret = AVERROR_EOF; |
| 221 | goto fail; |
| 222 | } |
| 223 | |
| 224 | ret = mux_fixup_ts(mux, ms, pkt); |
| 225 | if (ret < 0) |
| 226 | goto fail; |
| 227 | |
| 228 | ms->data_size_mux += pkt->size; |
| 229 | frame_num = atomic_fetch_add(&ost->packets_written, 1); |
| 230 | |
| 231 | pkt->stream_index = ost->index; |
| 232 | |
| 233 | if (ms->stats.io) |
| 234 | enc_stats_write(ost, &ms->stats, NULL, pkt, frame_num); |
| 235 | |
| 236 | ret = av_interleaved_write_frame(s, pkt); |
| 237 | if (ret < 0) { |
| 238 | av_log(ost, AV_LOG_ERROR, |
| 239 | "Error submitting a packet to the muxer: %s\n", |
| 240 | av_err2str(ret)); |
| 241 | goto fail; |
| 242 | } |
| 243 | |
| 244 | return 0; |
| 245 | fail: |
| 246 | av_packet_unref(pkt); |
| 247 | return ret; |
| 248 | } |
| 249 | |
| 250 | static int sync_queue_process(Muxer *mux, MuxStream *ms, AVPacket *pkt, int *stream_eof) |
| 251 | { |
no test coverage detected