static GstBuffer *gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
-GST_BOILERPLATE (GstRtpAMRDepay, gst_rtp_amr_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_amr_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpAMRDepay, gst_rtp_amr_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
-gst_rtp_amr_depay_base_init (gpointer klass)
+gst_rtp_amr_depay_class_init (GstRtpAMRDepayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_amr_depay_src_template));
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_amr_depay_sink_template));
- gst_element_class_set_details_simple (element_class, "RTP AMR depayloader",
+ gst_element_class_set_details_simple (gstelement_class, "RTP AMR depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts AMR or AMR-WB audio from RTP packets (RFC 3267)",
"Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_amr_depay_class_init (GstRtpAMRDepayClass * klass)
-{
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gstbasertpdepayload_class->process = gst_rtp_amr_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_amr_depay_setcaps;
}
static void
-gst_rtp_amr_depay_init (GstRtpAMRDepay * rtpamrdepay,
- GstRtpAMRDepayClass * klass)
+gst_rtp_amr_depay_init (GstRtpAMRDepay * rtpamrdepay)
{
GstBaseRTPDepayload *depayload;
const gint *frame_size;
GstBuffer *outbuf = NULL;
gint payload_len;
+ GstRTPBuffer rtp = { NULL };
+ guint8 *odata;
+ gsize osize;
rtpamrdepay = GST_RTP_AMR_DEPAY (depayload);
else
frame_size = wb_frame_size;
+ gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
/* when we get here, 1 channel, 8000/16000 Hz, octet aligned, no CRC,
* no robust sorting, no interleaving data is to be depayloaded */
{
gint amr_len;
gint ILL, ILP;
- payload_len = gst_rtp_buffer_get_payload_len (buf);
+ payload_len = gst_rtp_buffer_get_payload_len (&rtp);
/* need at least 2 bytes for the header */
if (payload_len < 2)
goto too_small;
- payload = gst_rtp_buffer_get_payload (buf);
+ payload = gst_rtp_buffer_get_payload (&rtp);
/* depay CMR. The CMR is used by the sender to request
* a new encoding mode.
outbuf = gst_buffer_new_and_alloc (payload_len);
/* point to destination */
- p = GST_BUFFER_DATA (outbuf);
+ odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
+
/* point to first data packet */
+ p = odata;
dp = payload + num_packets;
if (rtpamrdepay->crc) {
/* skip CRC if present */
dp += fr_size;
}
}
+ gst_buffer_unmap (outbuf, odata, osize);
+
/* we can set the duration because each packet is 20 milliseconds */
GST_BUFFER_DURATION (outbuf) = num_packets * 20 * GST_MSECOND;
- if (gst_rtp_buffer_get_marker (buf)) {
+ if (gst_rtp_buffer_get_marker (&rtp)) {
/* marker bit marks a discont buffer after a talkspurt. */
GST_DEBUG_OBJECT (depayload, "marker bit was set");
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
GST_DEBUG_OBJECT (depayload, "pushing buffer of size %d",
- GST_BUFFER_SIZE (outbuf));
+ gst_buffer_get_size (outbuf));
}
return outbuf;
static GstStateChangeReturn
gst_rtp_amr_pay_change_state (GstElement * element, GstStateChange transition);
-GST_BOILERPLATE (GstRtpAMRPay, gst_rtp_amr_pay, GstBaseRTPPayload,
- GST_TYPE_BASE_RTP_PAYLOAD);
+#define gst_rtp_amr_pay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpAMRPay, gst_rtp_amr_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
-gst_rtp_amr_pay_base_init (gpointer klass)
+gst_rtp_amr_pay_class_init (GstRtpAMRPayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstElementClass *gstelement_class;
+ GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+ gstelement_class = (GstElementClass *) klass;
+ gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
- gst_element_class_add_pad_template (element_class,
+ gstelement_class->change_state = gst_rtp_amr_pay_change_state;
+
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_amr_pay_src_template));
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_amr_pay_sink_template));
- gst_element_class_set_details_simple (element_class, "RTP AMR payloader",
+ gst_element_class_set_details_simple (gstelement_class, "RTP AMR payloader",
"Codec/Payloader/Network/RTP",
"Payload-encode AMR or AMR-WB audio into RTP packets (RFC 3267)",
"Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_amr_pay_class_init (GstRtpAMRPayClass * klass)
-{
- GstBaseRTPPayloadClass *gstbasertppayload_class;
- GstElementClass *gstelement_class;
-
- gstelement_class = (GstElementClass *) klass;
- gstelement_class->change_state = gst_rtp_amr_pay_change_state;
-
- gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gstbasertppayload_class->set_caps = gst_rtp_amr_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_amr_pay_handle_buffer;
}
static void
-gst_rtp_amr_pay_init (GstRtpAMRPay * rtpamrpay, GstRtpAMRPayClass * klass)
+gst_rtp_amr_pay_init (GstRtpAMRPay * rtpamrpay)
{
- /* needed because of GST_BOILERPLATE */
}
static void
GstRtpAMRPay *rtpamrpay;
const gint *frame_size;
GstFlowReturn ret;
- guint size, payload_len;
+ guint payload_len;
+ gsize size;
GstBuffer *outbuf;
- guint8 *payload, *data, *payload_amr;
+ guint8 *payload, *data, *ptr, *payload_amr;
GstClockTime timestamp, duration;
guint packet_len, mtu;
gint i, num_packets, num_nonempty_packets;
gint amr_len;
gboolean sid = FALSE;
+ GstRTPBuffer rtp = { NULL };
rtpamrpay = GST_RTP_AMR_PAY (basepayload);
mtu = GST_BASE_RTP_PAYLOAD_MTU (rtpamrpay);
- size = GST_BUFFER_SIZE (buffer);
- data = GST_BUFFER_DATA (buffer);
+ data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer);
/* now alloc output buffer */
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
+ gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
/* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
if (GST_BUFFER_IS_DISCONT (buffer)) {
GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit");
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
- gst_rtp_buffer_set_marker (outbuf, TRUE);
+ gst_rtp_buffer_set_marker (&rtp, TRUE);
gst_rtp_amr_pay_recalc_rtp_time (rtpamrpay, timestamp);
}
(num_packets * 160) << (rtpamrpay->mode == GST_RTP_AMR_P_MODE_WB);
/* get payload, this is now writable */
- payload = gst_rtp_buffer_get_payload (outbuf);
+ payload = gst_rtp_buffer_get_payload (&rtp);
/* 0 1 2 3 4 5 6 7
* +-+-+-+-+-+-+-+-+
/* copy data in payload, first we copy all the FTs then all
* the AMR data. The last FT has to have the F flag cleared. */
+ ptr = data;
for (i = 1; i <= num_packets; i++) {
guint8 FT;
gint fr_size;
* |F| FT |Q|P|P| more FT...
* +-+-+-+-+-+-+-+-+
*/
- FT = (*data & 0x78) >> 3;
+ FT = (*ptr & 0x78) >> 3;
fr_size = frame_size[FT];
if (i == num_packets)
/* last packet, clear F flag */
- payload[i] = *data & 0x7f;
+ payload[i] = *ptr & 0x7f;
else
/* set F flag */
- payload[i] = *data | 0x80;
+ payload[i] = *ptr | 0x80;
- memcpy (payload_amr, &data[1], fr_size);
+ memcpy (payload_amr, &ptr[1], fr_size);
/* all sizes are > 0 since we checked for that above */
- data += fr_size + 1;
+ ptr += fr_size + 1;
payload_amr += fr_size;
}
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
+ gst_rtp_buffer_unmap (&rtp);
+
ret = gst_basertppayload_push (basepayload, outbuf);
return ret;
{
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
(NULL), ("received AMR frame with size <= 0"));
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return GST_FLOW_ERROR;
{
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
(NULL), ("received incomplete AMR frames"));
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return GST_FLOW_ERROR;
{
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
(NULL), ("received too many AMR frames for MTU"));
+ gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return GST_FLOW_ERROR;
"clock-rate = (int) 90000, " "encoding-name = (string) \"H263\"")
);
-GST_BOILERPLATE (GstRtpH263Depay, gst_rtp_h263_depay, GstBaseRTPDepayload,
+#define gst_rtp_h263_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263Depay, gst_rtp_h263_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void gst_rtp_h263_depay_finalize (GObject * object);
GstCaps * caps);
static void
-gst_rtp_h263_depay_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_h263_depay_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_h263_depay_sink_template));
-
- gst_element_class_set_details_simple (element_class, "RTP H263 depayloader",
- "Codec/Depayloader/Network/RTP",
- "Extracts H263 video from RTP packets (RFC 2190)",
- "Philippe Kalaf <philippe.kalaf@collabora.co.uk>, "
- "Edward Hervey <bilboed@bilboed.com>");
-}
-
-static void
gst_rtp_h263_depay_class_init (GstRtpH263DepayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+ GST_DEBUG_CATEGORY_INIT (rtph263depay_debug, "rtph263depay", 0,
+ "H263 Video RTP Depayloader");
+
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
- gstbasertpdepayload_class->process = gst_rtp_h263_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_h263_depay_setcaps;
-
gobject_class->finalize = gst_rtp_h263_depay_finalize;
gstelement_class->change_state = gst_rtp_h263_depay_change_state;
- GST_DEBUG_CATEGORY_INIT (rtph263depay_debug, "rtph263depay", 0,
- "H263 Video RTP Depayloader");
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_h263_depay_src_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_h263_depay_sink_template));
+
+ gst_element_class_set_details_simple (gstelement_class,
+ "RTP H263 depayloader", "Codec/Depayloader/Network/RTP",
+ "Extracts H263 video from RTP packets (RFC 2190)",
+ "Philippe Kalaf <philippe.kalaf@collabora.co.uk>, "
+ "Edward Hervey <bilboed@bilboed.com>");
+
+ gstbasertpdepayload_class->process = gst_rtp_h263_depay_process;
+ gstbasertpdepayload_class->set_caps = gst_rtp_h263_depay_setcaps;
}
static void
)
);
-GST_BOILERPLATE (GstRtpH263PDepay, gst_rtp_h263p_depay, GstBaseRTPDepayload,
+#define gst_rtp_h263p_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpH263PDepay, gst_rtp_h263p_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void gst_rtp_h263p_depay_finalize (GObject * object);
GstCaps * caps);
static void
-gst_rtp_h263p_depay_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_h263p_depay_src_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_h263p_depay_sink_template));
-
-
- gst_element_class_set_details_simple (element_class, "RTP H263 depayloader",
- "Codec/Depayloader/Network/RTP",
- "Extracts H263/+/++ video from RTP packets (RFC 4629)",
- "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
gst_rtp_h263p_depay_class_init (GstRtpH263PDepayClass * klass)
{
GObjectClass *gobject_class;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
- gstbasertpdepayload_class->process = gst_rtp_h263p_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_h263p_depay_setcaps;
-
gobject_class->finalize = gst_rtp_h263p_depay_finalize;
gstelement_class->change_state = gst_rtp_h263p_depay_change_state;
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_h263p_depay_src_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_h263p_depay_sink_template));
+
+ gst_element_class_set_details_simple (gstelement_class,
+ "RTP H263 depayloader", "Codec/Depayloader/Network/RTP",
+ "Extracts H263/+/++ video from RTP packets (RFC 4629)",
+ "Wim Taymans <wim.taymans@gmail.com>");
+
+ gstbasertpdepayload_class->process = gst_rtp_h263p_depay_process;
+ gstbasertpdepayload_class->set_caps = gst_rtp_h263p_depay_setcaps;
}
static void
-gst_rtp_h263p_depay_init (GstRtpH263PDepay * rtph263pdepay,
- GstRtpH263PDepayClass * klass)
+gst_rtp_h263p_depay_init (GstRtpH263PDepay * rtph263pdepay)
{
rtph263pdepay->adapter = gst_adapter_new ();
}