Github user sreid8 commented on a diff in the pull request:
https://github.com/apache/guacamole-server/pull/159#discussion_r173988127
--- Diff: src/guacenc/ffmpeg-compat.c ---
@@ -51,8 +51,41 @@
*/
static int guacenc_write_packet(guacenc_video* video, void* data, int
size) {
- /* Write data, logging any errors */
- if (fwrite(data, 1, size, video->output) == 0) {
+ int ret;
+ AVPacket *pkt;
+
+
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,1,0)
+
+ pkt = malloc(sizeof(AVPacket));
+ /* have to create a packet around the encoded data we have */
+ av_init_packet(pkt);
+
+ if (video->context->coded_frame->pts != AV_NOPTS_VALUE) {
+ pkt->pts = av_rescale_q(video->context->coded_frame->pts,
+ video->context->time_base,
+ video->output_stream->time_base);
+ }
+ if (video->context->coded_frame->key_frame) {
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ }
+
+ pkt->data = data;
+ pkt->size = size;
+ pkt->stream_index = video->output_stream->index;
+ ret = av_interleaved_write_frame(video->container_format_context, pkt);
+ free(pkt);
--- End diff --
Great point. Changed to a stack variable.
---