No clock-rate in caps!, dropping buffer

I developed a custom source element and successfully connected to the rtpjitterbuffer. When sending rtp data through the source element, I encountered the following error:

0:00:07.175227900 28812 0000022AAE26E140 WARN rtpjitterbuffer gstrtpjitterbuffer.c:3687:gst_rtp_jitter_buffer_chain: No clock-rate in caps!, dropping buffer
0:00:07.189355600 28812 0000022AAE26E140 WARN rtpjitterbuffer gstrtpjitterbuffer.c:3687:gst_rtp_jitter_buffer_chain: No clock-rate in caps!, dropping buffer
0:00:07.203559300 28812 0000022AAE26E140 WARN rtpjitterbuffer gstrtpjitterbuffer.c:3687:gst_rtp_jitter_buffer_chain: No clock-rate in caps!, dropping buffer
0:00:07.225168100 28812 0000022AAE26E140 WARN rtpjitterbuffer gstrtpjitterbuffer.c:3687:gst_rtp_jitter_buffer_chain: No clock-rate in caps!, dropping buffer

May I ask how to configure the clock-rate?

Hi,

You do that by setting the the clock-rate field of the caps your are outputting in your element.

I configured “application/x-rtp, clock rate=90000” using GST STATIC-PAD-TEMPATE, but it doesn’t work either. Do I need to handle the GST QUERY-CAPS event? Can you give me more detailed suggestions or examples. Thank you!

you also need to set those caps on your source pad. The template won’t magically set those caps. See gst_pad_set_caps()

Here is my code,but gst_pad_set_caps return FALSE.

GstCaps* caps = gst_caps_new_simple("application/x-rtp", "clock-rate", G_TYPE_INT, 90000, NULL);
gst_pad_set_caps(filter->srcpad, caps);
gst_caps_unref(caps);

You can only do that once your pad is active (i.e. just before you’re pushing data)

Thank you for your suggestion. The problem has been resolved. Is it a bug that cannot set caps through templates?

No, the templates only advertise theoretically possible caps and is used for things like checking if elements can be linked. It’s up to the data producer to make sure correct caps are advertised/sent before data is being pushed to the next element. It can do internally by copying the template caps of course if the template caps are fixed and complete.

okay, thank you!