ducatimpeg4enc: set caps in configure
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 18 Oct 2012 10:52:17 +0000 (10:52 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 18 Oct 2012 10:52:17 +0000 (10:52 +0000)
If this is not done, then a buffer-alloc call will be done
downstream before caps are set, and downstream will not yet
know stream particularities such as width and height.

This fixes pipelines with ducatimpeg4enc ! ducatimpeg4dec
without an intervening mpeg4videoparse.

src/gstducatimpeg4enc.c

index d93ec0ebba745a2021efa63041c21acc2b6ae545..5ee040dd7eb58cb2351d61dea377db8b51d8f568 100644 (file)
@@ -237,10 +237,25 @@ gst_ducati_mpeg4enc_get_property (GObject * object, guint prop_id,
   }
 }
 
+static const char *
+get_profile_name (guint profile)
+{
+  switch (profile) {
+    case GST_DUCATI_MPEG4ENC_PROFILE_SIMPLE:
+      return "simple";
+    default:
+      return NULL;
+  }
+}
+
 static gboolean
 gst_ducati_mpeg4enc_configure (GstDucatiVidEnc * videnc)
 {
   GstDucatiMPEG4Enc *self = GST_DUCATIMPEG4ENC (videnc);
+  const GstVideoState *state;
+  GstCaps *caps;
+  const char *s;
+  gboolean ret = TRUE;
 
   if (!GST_DUCATIVIDENC_CLASS (parent_class)->configure (videnc))
     return FALSE;
@@ -251,7 +266,21 @@ gst_ducati_mpeg4enc_configure (GstDucatiVidEnc * videnc)
   videnc->dynParams->mvAccuracy = IVIDENC2_MOTIONVECTOR_HALFPEL;
   videnc->dynParams->interFrameInterval = 0;
 
-  return TRUE;
+  state = gst_base_video_encoder_get_state (GST_BASE_VIDEO_ENCODER (videnc));
+  caps = gst_caps_new_simple ("video/mpeg",
+      "mpegversion", G_TYPE_INT, 4,
+      "systemstream", G_TYPE_BOOLEAN, FALSE,
+      "width", G_TYPE_INT, videnc->rect.w,
+      "height", G_TYPE_INT, videnc->rect.h,
+      "framerate", GST_TYPE_FRACTION, state->fps_n, state->fps_d,
+      "pixel-aspect-ratio", GST_TYPE_FRACTION, state->par_n, state->par_d,
+      NULL);
+  s = get_profile_name (self->profile);
+  if (s)
+    gst_caps_set_simple (caps, "profile", G_TYPE_STRING, s, NULL);
+  ret = gst_pad_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD (self), caps);
+
+  return ret;
 }
 
 static gboolean