$ git clone http://tcclient.ion.nu/tc_client.git
commit d0cd8c348685f19ae2956a21fed82448c576ee55
Author: Alicia <...>
Date:   Fri Sep 23 18:43:30 2016 +0200

    Moved the backward compatibility code for avcodec_{send,receive}_{frame,packet} into a separate source file to avoid pulling libavcodec into utilities that don't use it.

diff --git a/ChangeLog b/ChangeLog
index 19d3f49..647e269 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 0.40:
+Moved the backward compatibility code for avcodec_{send,receive}_{frame,packet} into a separate source file to avoid pulling libavcodec into utilities that don't use it.
 tc_client-gtk: merged camera_remove() and camera_removebynick() into a single function, merged the deallocation of camera data into camera_free()
 tc_client-gtk: moved the postprocessing code into its own source file.
 tc_client-gtk: added greenscreen postprocessor.
diff --git a/Makefile b/Makefile
index 8e7055b..ac68cc2 100644
--- a/Makefile
+++ b/Makefile
@@ -14,9 +14,9 @@ endif
 OBJ=client.o amfparser.o rtmp.o numlist.o amfwriter.o idlist.o colors.o endian.o media.o utilities/compat.o
 IRCHACK_OBJ=utilities/irchack/irchack.o utilities/compat.o
 MODBOT_OBJ=utilities/modbot/modbot.o utilities/list.o utilities/modbot/queue.o
-CAMVIEWER_OBJ=utilities/camviewer/camviewer.o utilities/compat.o libcamera.a
+CAMVIEWER_OBJ=utilities/camviewer/camviewer.o utilities/compat.o utilities/compat_av.o libcamera.a
 CURSEDCHAT_OBJ=utilities/cursedchat/cursedchat.o utilities/cursedchat/buffer.o utilities/compat.o utilities/list.o
-TC_CLIENT_GTK_OBJ=utilities/gtk/camviewer.o utilities/gtk/userlist.o utilities/gtk/media.o utilities/gtk/compat.o utilities/gtk/config.o utilities/gtk/gui.o utilities/stringutils.o utilities/gtk/logging.o utilities/gtk/postproc.o utilities/compat.o utilities/gtk/inputhistory.o libcamera.a
+TC_CLIENT_GTK_OBJ=utilities/gtk/camviewer.o utilities/gtk/userlist.o utilities/gtk/media.o utilities/gtk/compat.o utilities/gtk/config.o utilities/gtk/gui.o utilities/stringutils.o utilities/gtk/logging.o utilities/gtk/postproc.o utilities/compat.o utilities/compat_av.o utilities/gtk/inputhistory.o libcamera.a
 LIBCAMERA_OBJ=utilities/libcamera/camera.o utilities/libcamera/camera_img.o
 UTILS=irchack modbot
 CONFINFO=|Will enable the IRC utility irchack|Will enable the bot utility modbot
@@ -150,7 +150,7 @@ SOURCES+=utilities/camviewer/camviewer.c
 SOURCES+=utilities/cursedchat/cursedchat.c utilities/cursedchat/buffer.c utilities/cursedchat/buffer.h
 SOURCES+=utilities/gtk/camviewer.c utilities/gtk/userlist.c utilities/gtk/media.c utilities/gtk/compat.c utilities/gtk/config.c utilities/gtk/gui.c utilities/gtk/logging.c utilities/gtk/postproc.c utilities/gtk/inputhistory.c utilities/gtk/userlist.h utilities/gtk/media.h utilities/gtk/compat.h utilities/gtk/config.h utilities/gtk/gui.h utilities/gtk/logging.h utilities/gtk/postproc.h utilities/gtk/inputhistory.h gtkgui.glade
 SOURCES+=utilities/gtk/gencamplaceholder.sh utilities/gtk/camplaceholder.xcf utilities/gtk/spinnerdot.xcf
-SOURCES+=utilities/compat.c utilities/compat.h utilities/list.c utilities/list.h utilities/stringutils.c utilities/stringutils.h
+SOURCES+=utilities/compat.c utilities/compat.h utilities/list.c utilities/list.h utilities/stringutils.c utilities/stringutils.h utilities/compat_av.c utilities/compat_av.h
 SOURCES+=utilities/libcamera/camera.c utilities/libcamera/camera.h utilities/libcamera/camera_v4l2.c utilities/libcamera/camera_v4l2.h utilities/libcamera/camera_img.c utilities/libcamera/camera_img.h utilities/libcamera/camera_escapi.cpp utilities/libcamera/camera_escapi.h
 tarball:
  tar -cJf tc_client-$(VERSION).tar.xz --transform='s|^|tc_client-$(VERSION)/|' $(SOURCES)
diff --git a/utilities/camviewer/camviewer.c b/utilities/camviewer/camviewer.c
index a395578..2a9a0d9 100644
--- a/utilities/camviewer/camviewer.c
+++ b/utilities/camviewer/camviewer.c
@@ -45,6 +45,7 @@
   #include "../libcamera/camera.h"
 #endif
 #include "../compat.h"
+#include "../compat_av.h"
 
 #if GTK_MAJOR_VERSION==2
   #define GTK_ORIENTATION_HORIZONTAL 0
diff --git a/utilities/compat.c b/utilities/compat.c
index 198e55b..5fe6ca3 100644
--- a/utilities/compat.c
+++ b/utilities/compat.c
@@ -50,41 +50,3 @@ char* strndup(const char* in, unsigned int length)
   return out;
 }
 #endif
-
-#ifdef AVCODEC_NO_SEND_RECEIVE_API
-void* compat_sendreceive_object=0;
-
-int compat_avcodec_send_packet(AVCodecContext* ctx, AVPacket* packet)
-{
-  compat_sendreceive_object=packet;
-  return 0;
-}
-
-int compat_avcodec_receive_frame(AVCodecContext* ctx, AVFrame* frame)
-{
-  int got;
-  if(ctx->codec_type==AVMEDIA_TYPE_VIDEO)
-  {
-    avcodec_decode_video2(ctx, frame, &got, compat_sendreceive_object);
-  }else{
-    avcodec_decode_audio4(ctx, frame, &got, compat_sendreceive_object);
-  }
-  return !got;
-}
-
-int compat_avcodec_send_frame(AVCodecContext* ctx, AVFrame* frame)
-{
-  compat_sendreceive_object=frame;
-  return 0;
-}
-
-int compat_avcodec_receive_packet(AVCodecContext* ctx, AVPacket* packet)
-{
-  int got;
-  if(ctx->codec_type==AVMEDIA_TYPE_VIDEO)
-  {
-    avcodec_encode_video2(ctx, packet, compat_sendreceive_object, &got);
-  }
-  return !got;
-}
-#endif
diff --git a/utilities/compat.h b/utilities/compat.h
index ef0c72d..0b6c66b 100644
--- a/utilities/compat.h
+++ b/utilities/compat.h
@@ -34,13 +34,3 @@
 #if GLIB_MAJOR_VERSION<2 || (GLIB_MAJOR_VERSION==2 && GLIB_MINOR_VERSION<2)
   #define g_io_channel_read_chars(a,b,c,d,e) g_io_channel_read(a,b,c,d)
 #endif
-#ifdef AVCODEC_NO_SEND_RECEIVE_API
-  #define avcodec_send_packet compat_avcodec_send_packet
-  #define avcodec_receive_frame compat_avcodec_receive_frame
-  #define avcodec_send_frame compat_avcodec_send_frame
-  #define avcodec_receive_packet compat_avcodec_receive_packet
-  extern int compat_avcodec_send_packet(AVCodecContext* ctx, AVPacket* packet);
-  extern int compat_avcodec_receive_frame(AVCodecContext* ctx, AVFrame* frame);
-  extern int compat_avcodec_send_frame(AVCodecContext* ctx, AVFrame* frame);
-  extern int compat_avcodec_receive_packet(AVCodecContext* ctx, AVPacket* packet);
-#endif
diff --git a/utilities/compat_av.c b/utilities/compat_av.c
new file mode 100644
index 0000000..a976ad6
--- /dev/null
+++ b/utilities/compat_av.c
@@ -0,0 +1,56 @@
+/*
+    Some compatibility code for older libav* versions
+    Copyright (C) 2016  alicia@ion.nu
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, version 3 of the License.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "compat_av.h"
+
+#ifdef AVCODEC_NO_SEND_RECEIVE_API
+#include <libavcodec/avcodec.h>
+void* compat_sendreceive_object=0;
+
+int compat_avcodec_send_packet(AVCodecContext* ctx, AVPacket* packet)
+{
+  compat_sendreceive_object=packet;
+  return 0;
+}
+
+int compat_avcodec_receive_frame(AVCodecContext* ctx, AVFrame* frame)
+{
+  int got;
+  if(ctx->codec_type==AVMEDIA_TYPE_VIDEO)
+  {
+    avcodec_decode_video2(ctx, frame, &got, compat_sendreceive_object);
+  }else{
+    avcodec_decode_audio4(ctx, frame, &got, compat_sendreceive_object);
+  }
+  return !got;
+}
+
+int compat_avcodec_send_frame(AVCodecContext* ctx, AVFrame* frame)
+{
+  compat_sendreceive_object=frame;
+  return 0;
+}
+
+int compat_avcodec_receive_packet(AVCodecContext* ctx, AVPacket* packet)
+{
+  int got;
+  if(ctx->codec_type==AVMEDIA_TYPE_VIDEO)
+  {
+    avcodec_encode_video2(ctx, packet, compat_sendreceive_object, &got);
+  }
+  return !got;
+}
+#endif
diff --git a/utilities/compat_av.h b/utilities/compat_av.h
new file mode 100644
index 0000000..0ff731a
--- /dev/null
+++ b/utilities/compat_av.h
@@ -0,0 +1,29 @@
+/*
+    Some compatibility code for older libav* versions
+    Copyright (C) 2016  alicia@ion.nu
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, version 3 of the License.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "../config.h"
+
+#ifdef AVCODEC_NO_SEND_RECEIVE_API
+  #include <libavcodec/avcodec.h>
+  #define avcodec_send_packet compat_avcodec_send_packet
+  #define avcodec_receive_frame compat_avcodec_receive_frame
+  #define avcodec_send_frame compat_avcodec_send_frame
+  #define avcodec_receive_packet compat_avcodec_receive_packet
+  extern int compat_avcodec_send_packet(AVCodecContext* ctx, AVPacket* packet);
+  extern int compat_avcodec_receive_frame(AVCodecContext* ctx, AVFrame* frame);
+  extern int compat_avcodec_send_frame(AVCodecContext* ctx, AVFrame* frame);
+  extern int compat_avcodec_receive_packet(AVCodecContext* ctx, AVPacket* packet);
+#endif
diff --git a/utilities/gtk/camviewer.c b/utilities/gtk/camviewer.c
index ba02661..daa6ab1 100644
--- a/utilities/gtk/camviewer.c
+++ b/utilities/gtk/camviewer.c
@@ -54,6 +54,7 @@
 #include "logging.h"
 #include "../stringutils.h"
 #include "../compat.h"
+#include "../compat_av.h"
 #include "inputhistory.h"
 
 struct viddata
diff --git a/utilities/gtk/media.c b/utilities/gtk/media.c
index ea01daa..78b2f27 100644
--- a/utilities/gtk/media.c
+++ b/utilities/gtk/media.c
@@ -30,6 +30,7 @@
 #include "../libcamera/camera.h"
 #include "compat.h"
 #include "../compat.h"
+#include "../compat_av.h"
 #include "gui.h"
 #include "media.h"