rtpg726depay: add block_align to output caps

It is needed to correctly negotiate caps with matroskamux
and most other muxers.

https://bugzilla.gnome.org/show_bug.cgi?id=749129
This commit is contained in:
Nicola Murino 2015-05-08 19:13:00 +02:00 committed by Tim-Philipp Müller
parent e11a537b65
commit fefeda5e6c
2 changed files with 9 additions and 1 deletions

View file

@ -35,6 +35,7 @@ GST_DEBUG_CATEGORY_STATIC (rtpg726depay_debug);
#define GST_CAT_DEFAULT (rtpg726depay_debug) #define GST_CAT_DEFAULT (rtpg726depay_debug)
#define DEFAULT_BIT_RATE 32000 #define DEFAULT_BIT_RATE 32000
#define DEFAULT_BLOCK_ALIGN 4
#define SAMPLE_RATE 8000 #define SAMPLE_RATE 8000
#define LAYOUT_G726 "g726" #define LAYOUT_G726 "g726"
@ -72,7 +73,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
"channels = (int) 1, " "channels = (int) 1, "
"rate = (int) 8000, " "rate = (int) 8000, "
"bitrate = (int) { 16000, 24000, 32000, 40000 }, " "bitrate = (int) { 16000, 24000, 32000, 40000 }, "
"layout = (string) \"g726\"") "block_align = (int) { 2, 3, 4, 5 }, " "layout = (string) \"g726\"")
); );
static void gst_rtp_g726_depay_get_property (GObject * object, guint prop_id, static void gst_rtp_g726_depay_get_property (GObject * object, guint prop_id,
@ -159,6 +160,7 @@ gst_rtp_g726_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
encoding_name = gst_structure_get_string (structure, "encoding-name"); encoding_name = gst_structure_get_string (structure, "encoding-name");
if (encoding_name == NULL || g_ascii_strcasecmp (encoding_name, "G726") == 0) { if (encoding_name == NULL || g_ascii_strcasecmp (encoding_name, "G726") == 0) {
depay->bitrate = DEFAULT_BIT_RATE; depay->bitrate = DEFAULT_BIT_RATE;
depay->block_align = DEFAULT_BLOCK_ALIGN;
} else { } else {
if (g_str_has_prefix (encoding_name, "AAL2-")) { if (g_str_has_prefix (encoding_name, "AAL2-")) {
depay->aal2 = TRUE; depay->aal2 = TRUE;
@ -166,12 +168,16 @@ gst_rtp_g726_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
} }
if (g_ascii_strcasecmp (encoding_name, "G726-16") == 0) { if (g_ascii_strcasecmp (encoding_name, "G726-16") == 0) {
depay->bitrate = 16000; depay->bitrate = 16000;
depay->block_align = 2;
} else if (g_ascii_strcasecmp (encoding_name, "G726-24") == 0) { } else if (g_ascii_strcasecmp (encoding_name, "G726-24") == 0) {
depay->bitrate = 24000; depay->bitrate = 24000;
depay->block_align = 3;
} else if (g_ascii_strcasecmp (encoding_name, "G726-32") == 0) { } else if (g_ascii_strcasecmp (encoding_name, "G726-32") == 0) {
depay->bitrate = 32000; depay->bitrate = 32000;
depay->block_align = 4;
} else if (g_ascii_strcasecmp (encoding_name, "G726-40") == 0) { } else if (g_ascii_strcasecmp (encoding_name, "G726-40") == 0) {
depay->bitrate = 40000; depay->bitrate = 40000;
depay->block_align = 5;
} else } else
goto unknown_encoding; goto unknown_encoding;
} }
@ -182,6 +188,7 @@ gst_rtp_g726_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
"channels", G_TYPE_INT, 1, "channels", G_TYPE_INT, 1,
"rate", G_TYPE_INT, clock_rate, "rate", G_TYPE_INT, clock_rate,
"bitrate", G_TYPE_INT, depay->bitrate, "bitrate", G_TYPE_INT, depay->bitrate,
"block_align", G_TYPE_INT, depay->block_align,
"layout", G_TYPE_STRING, LAYOUT_G726, NULL); "layout", G_TYPE_STRING, LAYOUT_G726, NULL);
ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps); ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);

View file

@ -42,6 +42,7 @@ struct _GstRtpG726Depay
gboolean aal2; gboolean aal2;
gboolean force_aal2; gboolean force_aal2;
gint bitrate; gint bitrate;
guint block_align;
}; };
struct _GstRtpG726DepayClass struct _GstRtpG726DepayClass