MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ drain_packets()

bool MayaFlux::IO::AudioEncodeContext::drain_packets ( FFmpegMuxContext mux)
private

Drain all packets currently available from the encoder into mux.

Definition at line 385 of file AudioEncodeContext.cpp.

386{
387 AVPacket* pkt = av_packet_alloc();
388 if (!pkt) {
389 m_last_error = "av_packet_alloc failed";
390 return false;
391 }
392
393 bool ok = true;
394 while (true) {
395 int ret = avcodec_receive_packet(codec_context, pkt);
396 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
397 break;
398 if (ret < 0) {
399 char errbuf[AV_ERROR_MAX_STRING_SIZE];
400 av_strerror(ret, errbuf, sizeof(errbuf));
401 m_last_error = std::string("avcodec_receive_packet failed: ") + errbuf;
402 ok = false;
403 break;
404 }
405
406 pkt->stream_index = m_stream_index;
407 av_packet_rescale_ts(pkt,
408 codec_context->time_base,
409 stream->time_base);
410
411 if (!mux.write_packet(pkt)) {
412 m_last_error = mux.last_error();
413 ok = false;
414 break;
415 }
416
417 av_packet_unref(pkt);
418 }
419
420 av_packet_free(&pkt);
421 return ok;
422}
AVCodecContext * codec_context
Owned; freed in destructor.
AVStream * stream
Owned by mux; pointer cached here.

References codec_context, MayaFlux::IO::FFmpegMuxContext::last_error(), m_last_error, m_stream_index, stream, and MayaFlux::IO::FFmpegMuxContext::write_packet().

Referenced by drain(), and send_fifo_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: