Index: gstdivxenc.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-plugins/ext/divx/gstdivxenc.c,v
retrieving revision 1.5
diff -u -r1.5 gstdivxenc.c
--- gstdivxenc.c	1 Jun 2003 13:20:37 -0000	1.5
+++ gstdivxenc.c	1 Jun 2003 17:43:58 -0000
@@ -86,7 +86,9 @@
 static void             gst_divxenc_dispose      (GObject         *object);
 static void             gst_divxenc_chain        (GstPad          *pad,
                                                   GstBuffer       *buf);
-static GstPadLinkReturn gst_divxenc_connect      (GstPad          *pad,
+static GstPadLinkReturn gst_divxenc_connect_sink (GstPad          *pad,
+                                                  GstCaps         *vscapslist);
+static GstPadLinkReturn gst_divxenc_connect_src  (GstPad          *pad,
                                                   GstCaps         *vscapslist);
 
 /* properties */
@@ -217,13 +219,14 @@
   gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->sinkpad);
 
   gst_pad_set_chain_function(divxenc->sinkpad, gst_divxenc_chain);
-  gst_pad_set_link_function(divxenc->sinkpad, gst_divxenc_connect);
+  gst_pad_set_link_function(divxenc->sinkpad, gst_divxenc_connect_sink);
 
   /* create the src pad */
   divxenc->srcpad = gst_pad_new_from_template(
                       GST_PAD_TEMPLATE_GET(src_template),
                       "src");
   gst_element_add_pad(GST_ELEMENT(divxenc), divxenc->srcpad);
+  gst_pad_set_link_function(divxenc->sinkpad, gst_divxenc_connect_src);
 
   /* bitrate, etc. */
   divxenc->width = divxenc->height = divxenc->csp = divxenc->bitcnt = -1;
@@ -378,8 +381,8 @@
 
 
 static GstPadLinkReturn
-gst_divxenc_connect (GstPad  *pad,
-                     GstCaps *vscaps)
+gst_divxenc_connect_sink (GstPad  *pad,
+			  GstCaps *vscaps)
 {
   GstDivxEnc *divxenc;
   GstCaps *caps;
@@ -446,11 +449,7 @@
     divxenc->bitcnt = bitcnt;
     divxenc->width = w;
     divxenc->height = h;
-    return gst_pad_try_set_caps(divxenc->srcpad,
-                                GST_CAPS_NEW("divxenc_src_caps",
-                                             "video/divx",
-                                               "width",  GST_PROPS_INT(w),
-                                               "height", GST_PROPS_INT(h)));
+    return GST_PAD_LINK_OK;
 
 trynext:
     continue;
@@ -460,6 +459,23 @@
   return GST_PAD_LINK_REFUSED;
 }
 
+static GstPadLinkReturn
+gst_divxenc_connect_src (GstPad  *pad,
+			 GstCaps *caps)
+{
+  GstDivxEnc *divxenc;
+
+  divxenc = GST_DIVXENC(gst_pad_get_parent (pad));
+
+  if (divxenc->width < 0)
+    return GST_PAD_LINK_DELAYED;
+
+  return gst_pad_try_set_caps (divxenc->srcpad,
+			       GST_CAPS_NEW("divxenc_src_caps",
+					   "video/divx",
+					     "width",  GST_PROPS_INT (divxenc->width),
+					     "height", GST_PROPS_INT (divxenc->height)));
+}
 
 static void
 gst_divxenc_set_property (GObject      *object,
