PROP_LAST
};
-static const GstElementDetails gst_rtp_g726_pay_details =
-GST_ELEMENT_DETAILS ("RTP G.726 payloader",
- "Codec/Payloader/Network",
- "Payload-encodes G.726 audio into a RTP packet",
- "Axis Communications <dev-gstreamer@axis.com>");
-
static GstStaticPadTemplate gst_rtp_g726_pay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
static void gst_rtp_g726_pay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
-static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_g726_pay_setcaps (GstRTPBasePayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload *
payload, GstBuffer * buffer);
-GST_BOILERPLATE (GstRtpG726Pay, gst_rtp_g726_pay, GstBaseRTPAudioPayload,
- GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
-
-static void
-gst_rtp_g726_pay_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
- gst_element_class_set_details (element_class, &gst_rtp_g726_pay_details);
-}
+#define gst_rtp_g726_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG726Pay, gst_rtp_g726_pay,
+ GST_TYPE_RTP_BASE_AUDIO_PAYLOAD);
static void
gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstRTPBasePayloadClass *gstrtpbasepayload_class;
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_pay_set_property;
gobject_class->get_property = gst_rtp_g726_pay_get_property;
"Force AAL2 encoding for compatibility with bad depayloaders",
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gstbasertppayload_class->set_caps = gst_rtp_g726_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
+
+ gst_element_class_set_details_simple (gstelement_class, "RTP G.726 payloader",
+ "Codec/Payloader/Network/RTP",
+ "Payload-encodes G.726 audio into a RTP packet",
+ "Axis Communications <dev-gstreamer@axis.com>");
+
+ gstrtpbasepayload_class->set_caps = gst_rtp_g726_pay_setcaps;
+ gstrtpbasepayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
GST_DEBUG_CATEGORY_INIT (rtpg726pay_debug, "rtpg726pay", 0,
"G.726 RTP Payloader");
}
static void
-gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay, GstRtpG726PayClass * klass)
+gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay)
{
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpg726pay);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpg726pay);
- GST_BASE_RTP_PAYLOAD (rtpg726pay)->clock_rate = 8000;
+ GST_RTP_BASE_PAYLOAD (rtpg726pay)->clock_rate = 8000;
rtpg726pay->force_aal2 = DEFAULT_FORCE_AAL2;
/* sample based codec */
- gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
+ gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
}
static gboolean
-gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_g726_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
{
gchar *encoding_name;
GstStructure *structure;
- GstBaseRTPAudioPayload *basertpaudiopayload;
+ GstRTPBaseAudioPayload *rtpbaseaudiopayload;
GstRtpG726Pay *pay;
GstCaps *peercaps;
+ gboolean res;
- basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (payload);
+ rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (payload);
pay = GST_RTP_G726_PAY (payload);
structure = gst_caps_get_structure (caps, 0);
switch (pay->bitrate) {
case 16000:
encoding_name = g_strdup ("G726-16");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
2);
break;
case 24000:
encoding_name = g_strdup ("G726-24");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
3);
break;
case 32000:
encoding_name = g_strdup ("G726-32");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
4);
break;
case 40000:
encoding_name = g_strdup ("G726-40");
- gst_base_rtp_audio_payload_set_samplebits_options (basertpaudiopayload,
+ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload,
5);
break;
default:
GST_DEBUG_OBJECT (payload, "selected base encoding %s", encoding_name);
/* now see if we need to produce AAL2 or not */
- peercaps = gst_pad_peer_get_caps (payload->srcpad);
+ peercaps = gst_pad_peer_query_caps (payload->srcpad, NULL);
if (peercaps) {
GstCaps *filter, *intersect;
gchar *capsstr;
GST_DEBUG_OBJECT (payload, "no peer caps, AAL2 %d", pay->aal2);
}
- gst_basertppayload_set_options (payload, "audio", TRUE, encoding_name, 8000);
- gst_basertppayload_set_outcaps (payload, NULL);
+ gst_rtp_base_payload_set_options (payload, "audio", TRUE, encoding_name,
+ 8000);
+ res = gst_rtp_base_payload_set_outcaps (payload, NULL);
g_free (encoding_name);
- return TRUE;
+ return res;
/* ERRORS */
invalid_bitrate:
}
static GstFlowReturn
-gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
+gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
{
GstFlowReturn res;
GstRtpG726Pay *pay;
pay = GST_RTP_G726_PAY (payload);
if (!pay->aal2) {
+ GstMapInfo map;
guint8 *data, tmp;
- guint len;
+ gsize size;
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place
* when the buffer is writable. */
buffer = gst_buffer_make_writable (buffer);
- data = GST_BUFFER_DATA (buffer);
- len = GST_BUFFER_SIZE (buffer);
+ gst_buffer_map (buffer, &map, GST_MAP_READWRITE);
+ data = map.data;
+ size = map.size;
- GST_LOG_OBJECT (pay, "packing %u bytes of data", len);
+ GST_LOG_OBJECT (pay, "packing %" G_GSIZE_FORMAT " bytes of data", map.size);
/* we need to reshuffle the bytes, output is of the form:
* A B C D .. with the number of bits depending on the bitrate. */
* |0 1|0 1|0 1|0 1|
* +-+-+-+-+-+-+-+-+-
*/
- while (len > 0) {
+ while (size > 0) {
tmp = *data;
*data++ = ((tmp & 0xc0) >> 6) |
((tmp & 0x30) >> 2) | ((tmp & 0x0c) << 2) | ((tmp & 0x03) << 6);
- len--;
+ size--;
}
break;
}
* |1 2|0 1 2|0 1 2|2|0 1 2|0 1 2|0|0 1 2|0 1 2|0 1|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
*/
- while (len > 2) {
+ while (size > 2) {
tmp = *data;
*data++ = ((tmp & 0xc0) >> 6) |
((tmp & 0x38) >> 1) | ((tmp & 0x07) << 5);
tmp = *data;
*data++ = ((tmp & 0xe0) >> 5) |
((tmp & 0x1c) >> 2) | ((tmp & 0x03) << 6);
- len -= 3;
+ size -= 3;
}
break;
}
* |0 1 2 3|0 1 2 3|0 1 2 3|0 1 2 3|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
*/
- while (len > 0) {
+ while (size > 0) {
tmp = *data;
*data++ = ((tmp & 0xf0) >> 4) | ((tmp & 0x0f) << 4);
- len--;
+ size--;
}
break;
}
* |2 3 4|0 1 2 3 4|4|0 1 2 3 4|0 1|1 2 3 4|0 1 2 3|3 4|0 1 2 3 4|0|0 1 2 3 4|0 1 2|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
*/
- while (len > 4) {
+ while (size > 4) {
tmp = *data;
*data++ = ((tmp & 0xe0) >> 5) | ((tmp & 0x1f) << 3);
tmp = *data;
((tmp & 0x3e) << 2) | ((tmp & 0x01) << 7);
tmp = *data;
*data++ = ((tmp & 0xf8) >> 3) | ((tmp & 0x07) << 5);
- len -= 5;
+ size -= 5;
}
break;
}
}
+ gst_buffer_unmap (buffer, &map);
}
res =
- GST_BASE_RTP_PAYLOAD_CLASS (parent_class)->handle_buffer (payload,
+ GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->handle_buffer (payload,
buffer);
return res;
gst_rtp_g726_pay_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "rtpg726pay",
- GST_RANK_NONE, GST_TYPE_RTP_G726_PAY);
+ GST_RANK_SECONDARY, GST_TYPE_RTP_G726_PAY);
}