Add guard to handle resetting AVPacket after use.

Also handle allocation failures.
This commit is contained in:
Doug Nazar
2022-07-28 00:37:02 -04:00
parent 110cc436a3
commit acbdf1854d
5 changed files with 63 additions and 15 deletions

View File

@@ -221,6 +221,8 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
return -1;
}
av_packet_guard pkt_guard{packet};
AVStream *stream = formatContextPtr->streams[packet->stream_index];
ZM_DUMP_STREAM_PACKET(stream, packet, "ffmpeg_camera in");
@@ -243,7 +245,6 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
mLastAudioPTS = packet->pts - mFirstAudioPTS;
}
}
zm_av_packet_unref(packet.get());
return 1;
} // FfmpegCamera::Capture