Audio-resampling isn't actually performed?

Matthew Waters ystreet00 at gmail.com
Thu Nov 12 09:44:57 UTC 2020



On 12/11/20 8:00 pm, Lusine wrote:
> 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;
> 	GST_OBJECT_LOCK(agg);
> 	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.

No, the buffer size is not a direct relation with the sample rate of the 
audio.  There can be any number of samples within an audio buffer that 
still have the same sample rate.

It sounds like you probably want to base your element on 
GstAudioAggregator though for the audio-specifics.

> 				g_print("outbuf map.size %d\n", map.size);
> 			}
> 		}	
> 	}
> }
>
> Please see my comments in the above code. Thank you very much for your time.
> Regads,
> Lusine
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20201112/7d481f84/attachment.sig>


More information about the gstreamer-devel mailing list