summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2010-08-12 12:33:06 +0300
committerStefan Kost <ensonic@users.sf.net>2010-09-06 21:54:25 +0300
commit988f228da74f1aca62c69d50c5b67765580298b0 (patch)
tree8156b27dd1e397502a7837d9930d66304051e4d7
parent22560c473d8b1c2ed345afdbae87a9dbf5690dd0 (diff)
rtpmp4adepay: grab the sampling arte and put into caps
This is needed to be able to mux the received audio into mp4 (in the case of aac). Fixes #625825.
-rw-r--r--gst/rtp/gstrtpmp4adepay.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gst/rtp/gstrtpmp4adepay.c b/gst/rtp/gstrtpmp4adepay.c
index d85b15f4e..3e88fef44 100644
--- a/gst/rtp/gstrtpmp4adepay.c
+++ b/gst/rtp/gstrtpmp4adepay.c
@@ -165,6 +165,10 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
guint8 *data;
guint size;
gint i;
+ guint sr_idx;
+ static const guint aac_sample_rates[] = { 96000, 88200, 64000, 48000,
+ 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000
+ };
buffer = gst_value_get_buffer (&v);
gst_buffer_ref (buffer);
@@ -207,6 +211,15 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
data[i] = ((data[i + 1] & 1) << 7) | ((data[i + 2] & 0xfe) >> 1);
}
+ /* grab and set sampling rate */
+ sr_idx = ((data[0] & 0x07) << 1) | ((data[1] & 0x80) >> 7);
+ if (sr_idx < G_N_ELEMENTS (aac_sample_rates)) {
+ gst_caps_set_simple (srccaps,
+ "rate", G_TYPE_INT, (gint) aac_sample_rates[sr_idx], NULL);
+ } else {
+ GST_WARNING ("Invalid sample rate index %u", sr_idx);
+ }
+
/* ignore remaining bit, we're only interested in full bytes */
GST_BUFFER_SIZE (buffer) = size;