$ git clone http://tcclient.ion.nu/tc_client.git
commit cf118363949455d3bc1d5d4f7d66a0b7b3a91b41
Author: Alicia <...>
Date:   Mon Sep 12 20:58:38 2016 +0200

    tc_client-gtk: limit the camera preview to 640 by 480, scaling down if the input is larger.

diff --git a/ChangeLog b/ChangeLog
index f05a866..ba9019a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@ tc_client-gtk: made the settings accessible from the start window (previously on
 tc_client-gtk: added an option to use the --cookies parameter of the core to keep/reuse HTTP cookies.
 tc_client-gtk: when automatically opening cameras is disabled don't open the ones that are active when joining either, and notify when someone cams up.
 tc_client-gtk: added menu item to hide a camera upon right-click.
+tc_client-gtk: limit the camera preview to 640 by 480, scaling down if the input is larger.
 tc_client-gtk and camviewer: fixed compatibility with newer libavutil.
 tc_client-gtk and camviewer: added compatibility fallbacks for av_image_get_buffer_size() and av_packet_unref()
 libcamera(v4l2): if we failed to read the frame, give grey instead.
diff --git a/utilities/gtk/media.c b/utilities/gtk/media.c
index 7ec5b2b..0380783 100644
--- a/utilities/gtk/media.c
+++ b/utilities/gtk/media.c
@@ -32,6 +32,9 @@
 #include "../compat.h"
 #include "gui.h"
 #include "media.h"
+
+#define PREVIEW_MAX_WIDTH 640
+#define PREVIEW_MAX_HEIGHT 480
 extern int tc_client_in[2];
 struct camera campreview={
   .postproc.min_brightness=0,
@@ -230,6 +233,16 @@ gboolean cam_encode(GIOChannel* iochannel, GIOCondition condition, gpointer data
   if(!preview) // Scale, unless we're previewing
   {
     gdkframe=gdk_pixbuf_scale_simple(gdkframe, camsize_scale.width, camsize_scale.height, GDK_INTERP_BILINEAR);
+  }else if(gdk_pixbuf_get_height(gdkframe)>PREVIEW_MAX_HEIGHT || gdk_pixbuf_get_width(gdkframe)>PREVIEW_MAX_WIDTH) // Scale anyway if the input is huge
+  {
+    unsigned int width=gdk_pixbuf_get_width(gdkframe);
+    unsigned int height=gdk_pixbuf_get_height(gdkframe);
+    if(height*PREVIEW_MAX_WIDTH/width>PREVIEW_MAX_HEIGHT)
+    {
+      gdkframe=gdk_pixbuf_scale_simple(gdkframe, width*PREVIEW_MAX_HEIGHT/height, PREVIEW_MAX_HEIGHT, GDK_INTERP_BILINEAR);
+    }else{
+      gdkframe=gdk_pixbuf_scale_simple(gdkframe, PREVIEW_MAX_WIDTH, height*PREVIEW_MAX_WIDTH/width, GDK_INTERP_BILINEAR);
+    }
   }
   gtk_image_set_from_pixbuf(GTK_IMAGE(cam->cam), gdkframe);
   g_object_unref(oldpixbuf);