rtpg729pay: Support ptime from caps
authorOlivier Crête <olivier.crete@collabora.co.uk>
Thu, 31 Dec 2009 21:27:30 +0000 (16:27 -0500)
committerOlivier Crête <olivier.crete@collabora.co.uk>
Tue, 5 Jan 2010 18:23:26 +0000 (13:23 -0500)
https://bugzilla.gnome.org/show_bug.cgi?id=606050

gst/rtp/gstrtpg729pay.c

index 8337f98..3f64527 100644 (file)
@@ -190,9 +190,7 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
   /* min number of bytes based on a given ptime, has to be a multiple
      of frame duration */
   {
-    guint64 min_ptime;
-
-    g_object_get (G_OBJECT (payload), "min-ptime", &min_ptime, NULL);
+    guint64 min_ptime = payload->min_ptime;
 
     min_ptime = min_ptime / 1000000;
     minptime_octets = G729_FRAME_SIZE *
@@ -205,6 +203,18 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
     min_payload_len = max_payload_len;
   }
 
+  /* If the ptime is specified in the caps, tried to adhere to it exactly */
+  if (payload->abidata.ABI.ptime) {
+    guint ptime_in_bytes = G729_FRAME_SIZE *
+        (guint) (payload->abidata.ABI.ptime / G729_FRAME_DURATION_MS);
+
+    /* clip to computed min and max lengths */
+    ptime_in_bytes = MAX (min_payload_len, ptime_in_bytes);
+    ptime_in_bytes = MIN (max_payload_len, ptime_in_bytes);
+
+    min_payload_len = max_payload_len = ptime_in_bytes;
+  }
+
   GST_LOG_OBJECT (basertpaudiopayload,
       "Calculated min_payload_len %u and max_payload_len %u",
       min_payload_len, max_payload_len);