Fix glimagesink window size

glimagesink size will be adjusted by the sink cap instead of the fixed
320x240 window.

Cherrypick patch from 1.15.1 release.

Change-Id: I7dc405f88f96909fbda940ec18b86ad8e0eacdbe
diff --git a/debian/patches/0002-1.15-1-glimagesink.patch b/debian/patches/0002-1.15-1-glimagesink.patch
new file mode 100644
index 0000000..dcf2b7c
--- /dev/null
+++ b/debian/patches/0002-1.15-1-glimagesink.patch
@@ -0,0 +1,92 @@
+From 08ebb8264debb3b03d31a3a66ad61c0ac3e23812 Mon Sep 17 00:00:00 2001
+From: memeka <mihailescu2m@gmail.com>
+Date: Tue, 24 Oct 2017 17:39:50 +1030
+Subject: [PATCH] gl/wayland: add preferred window size, and set it according
+ to video size
+
+The glimagesink wayland backend lacks the implementation of
+gst_gl_window_wayland_egl_set_preferred_size. Because of this, glimagesink windows on
+wayland are created with a fixed window size of 320x240.
+
+[Matthew Waters]: gst-indent sources
+
+https://bugzilla.gnome.org/show_bug.cgi?id=789384
+---
+ .../gst/gl/wayland/gstglwindow_wayland_egl.c  | 22 +++++++++++++++++++
+ .../gst/gl/wayland/gstglwindow_wayland_egl.h  |  1 +
+ 2 files changed, 23 insertions(+)
+
+diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
+index 385281869f..beac6f7ead 100644
+--- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
++++ b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c
+@@ -57,6 +57,8 @@ static gboolean gst_gl_window_wayland_egl_open (GstGLWindow * window,
+ static guintptr gst_gl_window_wayland_egl_get_display (GstGLWindow * window);
+ static gboolean gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow *
+     window, gint x, gint y, gint width, gint height);
++static void gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window,
++    gint width, gint height);
+ 
+ #if 0
+ static void
+@@ -306,12 +308,16 @@ create_surfaces (GstGLWindowWaylandEGL * window_egl)
+ 
+   if (window_egl->window.window_width > 0)
+     width = window_egl->window.window_width;
++  else if (window_egl->window.preferred_width > 0)
++    width = window_egl->window.preferred_width;
+   else
+     width = 320;
+   window_egl->window.window_width = width;
+ 
+   if (window_egl->window.window_height > 0)
+     height = window_egl->window.window_height;
++  else if (window_egl->window.preferred_height > 0)
++    height = window_egl->window.preferred_height;
+   else
+     height = 240;
+   window_egl->window.window_height = height;
+@@ -344,6 +350,8 @@ gst_gl_window_wayland_egl_class_init (GstGLWindowWaylandEGLClass * klass)
+       GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_get_display);
+   window_class->set_render_rectangle =
+       GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_render_rectangle);
++  window_class->set_preferred_size =
++      GST_DEBUG_FUNCPTR (gst_gl_window_wayland_egl_set_preferred_size);
+ }
+ 
+ static void
+@@ -584,6 +592,20 @@ gst_gl_window_wayland_egl_set_render_rectangle (GstGLWindow * window,
+   return TRUE;
+ }
+ 
++static void
++gst_gl_window_wayland_egl_set_preferred_size (GstGLWindow * window, gint width,
++    gint height)
++{
++  GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
++
++  window_egl->window.preferred_width = width;
++  window_egl->window.preferred_height = height;
++  if (window_egl->window.window_height != height
++      || window_egl->window.window_width != width) {
++    window_resize (window_egl, width, height);
++  }
++}
++
+ static guintptr
+ gst_gl_window_wayland_egl_get_display (GstGLWindow * window)
+ {
+diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h
+index 07c7ad1b95..09858e8298 100644
+--- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h
++++ b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.h
+@@ -72,6 +72,7 @@ struct window {
+   struct wl_callback        *callback;
+   int fullscreen, configured;
+   int window_width, window_height;
++  int preferred_width, preferred_height;
+   int window_x, window_y;
+ };
+ 
+-- 
+2.26.2
diff --git a/debian/patches/series b/debian/patches/series
index 3a66f82..bfea053 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 0001-gstrtspconnection-Security-loophole-making-heap-over.patch
 0001-mtk.patch
+0002-1.15.1-glimagesink.patch