rtpsource: get clock-rate from pt if needed to generate SR
authorMiguel París Díaz <mparisdiaz@gmail.com>
Wed, 15 Mar 2017 17:58:55 +0000 (18:58 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 16 Mar 2017 13:48:37 +0000 (15:48 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=780105

gst/rtpmanager/rtpsource.c
gst/rtpmanager/rtpsource.h

index 172449d..876437f 100644 (file)
@@ -304,6 +304,8 @@ rtp_source_init (RTPSource * src)
   src->last_keyframe_request = GST_CLOCK_TIME_NONE;
 
   rtp_source_reset (src);
+
+  src->pt_set = FALSE;
 }
 
 void
@@ -1277,6 +1279,13 @@ rtp_source_send_rtp (RTPSource * src, RTPPacketInfo * pinfo)
   if (!update_receiver_stats (src, pinfo, FALSE))
     return GST_FLOW_OK;
 
+  if (src->pt_set && src->pt != pinfo->pt) {
+    GST_WARNING ("Changing pt to %u for SSRC %u", src->ssrc, pinfo->pt);
+  }
+
+  src->pt = pinfo->pt;
+  src->pt_set = TRUE;
+
   /* update stats for the SR */
   src->stats.packets_sent += pinfo->packets;
   src->stats.octets_sent += pinfo->payload_len;
@@ -1482,6 +1491,12 @@ rtp_source_get_new_sr (RTPSource * src, guint64 ntpnstime,
   GST_DEBUG ("last_rtime %" GST_TIME_FORMAT ", last_rtptime %"
       G_GUINT64_FORMAT, GST_TIME_ARGS (src->last_rtime), t_rtp);
 
+  if (src->clock_rate == -1 && src->pt_set) {
+    GST_INFO ("no clock-rate, getting for pt %u and SSRC %u", src->pt,
+        src->ssrc);
+    get_clock_rate (src, src->pt);
+  }
+
   if (src->clock_rate != -1) {
     /* get the diff between the clock running_time and the buffer running_time.
      * This is the elapsed time, as measured against the pipeline clock, between
index f5f093a..282267e 100644 (file)
@@ -199,6 +199,8 @@ struct _RTPSource {
   gboolean     send_nack;
   GArray      *nacks;
 
+  gboolean      pt_set;
+  guint8        pt;
 };
 
 struct _RTPSourceClass {