@slomo, many thanks for the tips!
Successfully ran my app with gST_DEBUG=6 against same stream with either Opus or M4a encoding and collected the gst logs.
Saw that the two logs are almost identical all the way to PLAYING state. Then m4a logs show it fails with no negotiation.
0:00:00.583755000 93327 0x6000035159f0 DEBUG GST_CAPS gstpad.c:2743:gst_pad_get_current_caps:<rtspAppSrc_audio:src> get current pad caps application/x-rtp, media=(string)audio, payload=(int)97, encoding-name=(string)MPEG4-GENERIC, clock-rate=(int)44100, mode=(string)aac-hbr
0:00:00.583775000 93327 0x6000035159f0 DEBUG GST_PADS gstpad.c:4311:gst_pad_peer_query:<rtspAppSrc_audio:src> peer query 0x60000357c320 (allocation)
0:00:00.584485000 93327 0x6000035159f0 DEBUG GST_PADS gstpad.c:4373:gst_pad_peer_query:<rtspAppSrc_audio:src> query failed
0:00:00.584487000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:3314:gst_base_src_prepare_allocation:<rtspAppSrc_audio> peer ALLOCATION query failed
0:00:00.584718000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:3321:gst_base_src_prepare_allocation:<rtspAppSrc_audio> ALLOCATION (1) params: allocation query: 0x60000357c320, GstQueryAllocation, caps=(GstCaps)"application/x-rtp\,\ media\=\(string\)audio\,\ payload\=\(int\)97\,\ encoding-name\=\(string\)MPEG4-GENERIC\,\ clock-rate\=\(int\)44100\,\ mode\=\(string\)aac-hbr", need-pool=(boolean)true, allocator=(GArray)NULL, pool=(GArray)NULL;
0:00:00.584736000 93327 0x6000035159f0 LOG basesrc gstbasesrc.c:2908:gst_base_src_loop:<rtspAppSrc_audio> next_ts 99:99:99.999999999 size 4096
0:00:00.584814000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:2586:gst_base_src_get_range:<rtspAppSrc_audio> calling create offset 18446744073709551615 length 4096, time 0
0:00:00.584822000 93327 0x6000035159f0 LOG appsrc gstappsrc.c:1389:gst_app_src_update_queued_pop:<rtspAppSrc_audio> have buffer 0x1440080f0 of size 964
0:00:00.584829000 93327 0x6000035159f0 DEBUG appsrc gstappsrc.c:1455:gst_app_src_update_queued_pop:<rtspAppSrc_audio> Currently queued: 6880 bytes, 6 buffers, 0:00:00.301859411
0:00:00.584831000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:2440:gst_base_src_do_sync:<rtspAppSrc_audio> no sync needed
0:00:00.584833000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:2677:gst_base_src_get_range:<rtspAppSrc_audio> buffer ok
0:00:00.586413000 93327 0x6000035159f0 DEBUG GST_PADS gstpad.c:1658:gst_pad_needs_reconfigure:<rtspAppSrc_audio:src> peeking RECONFIGURE flag 0
0:00:00.586426000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:3070:gst_base_src_loop:<rtspAppSrc_audio> Not negotiated
0:00:00.586474000 93327 0x6000035159f0 DEBUG basesrc gstbasesrc.c:3085:gst_base_src_loop:<rtspAppSrc_audio> pausing task, reason not-negotiated
0:00:00.586477000 93327 0x6000035159f0 DEBUG GST_PADS gstpad.c:6382:gst_pad_pause_task:<rtspAppSrc_audio:src> pause task
0:00:00.586492000 93327 0x6000035159f0 DEBUG task gsttask.c:729:gst_task_set_state_unlocked:<rtspAppSrc_audio:src> Changing task 0x142f056e0 to state 2
0:00:00.586505000 93327 0x6000035159f0 WARN basesrc gstbasesrc.c:3132:gst_base_src_loop:<rtspAppSrc_audio> error: Internal data stream error.
0:00:00.586601000 93327 0x6000035159f0 WARN basesrc gstbasesrc.c:3132:gst_base_src_loop:<rtspAppSrc_audio> error: streaming stopped, reason not-negotiated (-4)
The Opus logs seems no issue.
0:00:00.664667000 93534 0x60000203d720 DEBUG GST_CAPS gstpad.c:2743:gst_pad_get_current_caps:<rtspAppSrc_audio:src> get current pad caps application/x-rtp, media=(string)audio, payload=(int)97, encoding-name=(string)OPUS, clock-rate=(int)48000
0:00:00.664721000 93534 0x60000203d720 DEBUG GST_PADS gstpad.c:4311:gst_pad_peer_query:<rtspAppSrc_audio:src> peer query 0x60000202bde0 (allocation)
0:00:00.665515000 93534 0x60000203d720 DEBUG GST_PADS gstpad.c:4373:gst_pad_peer_query:<rtspAppSrc_audio:src> query failed
0:00:00.665519000 93534 0x60000203d720 DEBUG basesrc gstbasesrc.c:3314:gst_base_src_prepare_allocation:<rtspAppSrc_audio> peer ALLOCATION query failed
0:00:00.665652000 93534 0x60000203d720 DEBUG basesrc gstbasesrc.c:3321:gst_base_src_prepare_allocation:<rtspAppSrc_audio> ALLOCATION (1) params: allocation query: 0x60000202bde0, GstQueryAllocation, caps=(GstCaps)"application/x-rtp\,\ media\=\(string\)audio\,\ payload\=\(int\)97\,\ encoding-name\=\(string\)OPUS\,\ clock-rate\=\(int\)48000", need-pool=(boolean)true, allocator=(GArray)NULL, pool=(GArray)NULL;
0:00:00.678988000 93534 0x60000205d9f0 LOG basesrc gstbasesrc.c:761:gst_base_src_query_latency:<rtspAppSrc_audio> latency: live 1, min 0:00:00.000000000, max 0:00:00.000000000
0:00:00.678994000 93534 0x60000205d9f0 DEBUG GST_PADS gstpad.c:4207:gst_pad_query:<rtspAppSrc_audio:src> sent query 0x600002004c80 (latency), result 1
0:00:00.684284000 93534 0x60000205d9f0 LOG GST_PADS gstpad.c:5570:gst_pad_push_event_unchecked:<decodebin3-0:sink> sending event 0x6000028192d0 (latency) to peerpad <rtspAppSrc_audio:src>
0:00:00.684287000 93534 0x60000205d9f0 DEBUG GST_EVENT gstpad.c:5861:gst_pad_send_event_unchecked:<rtspAppSrc_audio:src> have event type latency event: 0x6000028192d0, time 99:99:99.999999999, seq-num 237, GstEventLatency, latency=(guint64)40000000;
0:00:00.684502000 93534 0x60000205d9f0 DEBUG basesrc gstbasesrc.c:2107:gst_base_src_default_event:<rtspAppSrc_audio> handle event latency event: 0x6000028192d0, time 99:99:99.999999999, seq-num 237, GstEventLatency, latency=(guint64)40000000;
0:00:00.684542000 93534 0x60000205d9f0 DEBUG GST_PADS gstpad.c:5954:gst_pad_send_event_unchecked:<rtspAppSrc_audio:src> sent event, ret ok
0:00:00.684546000 93534 0x60000205d9f0 LOG GST_PADS gstpad.c:5578:gst_pad_push_event_unchecked:<decodebin3-0:sink> sent event 0x6000028192d0 (latency) to peerpad <rtspAppSrc_audio:src>, ret ok
0:00:00.695600000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2286:update_degree:<input> element rtspAppSrc_audio not linked on any sinkpads
0:00:00.695656000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2263:update_degree:<input> change element rtspAppSrc_audio, degree 0->1, linked to decodebin3-0
0:00:00.701559000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2263:update_degree:<input> change element rtspAppSrc_audio, degree 1->0, linked to decodebin3-0
0:00:00.701602000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2146:add_to_queue:<input> adding 'rtspAppSrc_audio' to queue
0:00:00.705071000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2353:gst_bin_sort_iterator_next:<input> queue head gives rtspAppSrc_audio
0:00:00.705095000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2286:update_degree:<input> element rtspAppSrc_audio not linked on any sinkpads
0:00:00.713577000 93534 0x60000205d9f0 INFO GST_STATES gstbin.c:2484:gst_bin_element_set_state:<rtspAppSrc_audio> current PLAYING pending VOID_PENDING, desired next PLAYING
0:00:00.713636000 93534 0x60000205d9f0 INFO GST_STATES gstbin.c:2608:gst_bin_element_set_state:<rtspAppSrc_audio> skipping transition from PLAYING to PLAYING
0:00:00.713683000 93534 0x60000205d9f0 INFO GST_STATES gstbin.c:2939:gst_bin_change_state_func:<input> child 'rtspAppSrc_audio' changed state to 4(PLAYING) successfully
.
.
.
0:00:01.092291000 93534 0x60000205d9f0 LOG GST_PADS gstpad.c:5570:gst_pad_push_event_unchecked:<decodebin3-0:sink> sending event 0x60000281f1e0 (latency) to peerpad <rtspAppSrc_audio:src>
0:00:01.092310000 93534 0x60000205d9f0 DEBUG GST_EVENT gstpad.c:5861:gst_pad_send_event_unchecked:<rtspAppSrc_audio:src> have event type latency event: 0x60000281f1e0, time 99:99:99.999999999, seq-num 498, GstEventLatency, latency=(guint64)219999998;
0:00:01.092571000 93534 0x60000205d9f0 DEBUG basesrc gstbasesrc.c:2107:gst_base_src_default_event:<rtspAppSrc_audio> handle event latency event: 0x60000281f1e0, time 99:99:99.999999999, seq-num 498, GstEventLatency, latency=(guint64)219999998;
0:00:01.092621000 93534 0x60000205d9f0 DEBUG GST_PADS gstpad.c:5954:gst_pad_send_event_unchecked:<rtspAppSrc_audio:src> sent event, ret ok
0:00:01.092704000 93534 0x60000205d9f0 LOG GST_PADS gstpad.c:5578:gst_pad_push_event_unchecked:<decodebin3-0:sink> sent event 0x60000281f1e0 (latency) to peerpad <rtspAppSrc_audio:src>, ret ok
0:00:01.153830000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2286:update_degree:<input> element rtspAppSrc_audio not linked on any sinkpads
0:00:01.153839000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2263:update_degree:<input> change element rtspAppSrc_audio, degree 0->1, linked to decodebin3-0
0:00:01.155442000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2263:update_degree:<input> change element rtspAppSrc_audio, degree 1->0, linked to decodebin3-0
0:00:01.155486000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2146:add_to_queue:<input> adding 'rtspAppSrc_audio' to queue
0:00:01.158799000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2353:gst_bin_sort_iterator_next:<input> queue head gives rtspAppSrc_audio
0:00:01.158801000 93534 0x60000205d9f0 DEBUG bin gstbin.c:2286:update_degree:<input> element rtspAppSrc_audio not linked on any sinkpads
0:00:01.158818000 93534 0x60000205d9f0 INFO GST_STATES gstbin.c:2484:gst_bin_element_set_state:<rtspAppSrc_audio> current PLAYING pending VOID_PENDING, desired next PLAYING
0:00:01.158855000 93534 0x60000205d9f0 INFO GST_STATES gstbin.c:2608:gst_bin_element_set_state:<rtspAppSrc_audio> skipping transition from PLAYING to PLAYING
0:00:01.158873000 93534 0x60000205d9f0 INFO GST_STATES gstbin.c:2939:gst_bin_change_state_func:<input> child 'rtspAppSrc_audio' changed state to 4(PLAYING) successfully
Still can’t see what’s the reason that will cause the difference between the two codecs.
BTW: How to enclose the whole logs here?