Audio-resampling isn't actually performed?

Lusine lusinehayrapetyan1992 at
Thu Nov 12 09:00:56 UTC 2020

Hi Matt,
Thanks for your answer. I will try to provide more details:
I have 2 audio streams with 22050 and 48000 audio sample rates and I have my
custom audio plugin based on GstAudioAggregator class where I only overwrite
aggregate() virtual method - it's called when buffers are queued on all
sinkpads. Please note that before connecting to my custom plugin both
streams are resampled to 48000 rate with audioresample element. Here is the
aggregate function:

static GstFlowReturn aggregate(GstAggregator * agg, gboolean timeout)
	GstFlowReturn ret;
	gboolean pad_eos = false;
	GstBuffer *outbuf = NULL;
	for (size_t i = 0; i < g_list_length(GST_ELEMENT(agg)->sinkpads); ++i)
		GstAudioAggregatorPad *aaggpad = (GstAudioAggregatorPad *)
(g_list_nth_data(GST_ELEMENT(agg)->sinkpads, i));
		// This prints 48000 for both of the pads. Which is expected because
streams are resampled before.
		g_print("GST_AUDIO_INFO_RATE %d\n", GST_AUDIO_INFO_RATE (&aaggpad->info));
		GstAggregatorPad *aggpad = (GstAggregatorPad *)
(g_list_nth_data(GST_ELEMENT(agg)->sinkpads, i));
		pad_eos = gst_aggregator_pad_is_eos(aggpad);
		if (!pad_eos)
			outbuf = gst_aggregator_pad_pop_buffer(aggpad);
			GstMapInfo map;
			if (gst_buffer_map(outbuf, &map, GST_MAP_READ))
				// Here audio buffer size is 4096 for the first input and 8916 for the
second input.
				// Is it expected? Why audio buffers have different sizes? Isn't it
expected to have the same size because they have the same audio rate.
				g_print("outbuf map.size %d\n", map.size);

Please see my comments in the above code. Thank you very much for your time.

Sent from:

More information about the gstreamer-devel mailing list