+2006-02-23 Philippe Kalaf <philippe.kalaf at collabora.co.uk>
+
+ * rtp/gst/gstrtppcmadepay.c:
+ * rtp/gst/gstrtppcmadepay.h:
+ * rtp/gst/gstgstrtppcmapay.c:
+ * rtp/gst/gstgstrtppcmapay.h:
+ * rtp/gst/gstrtppcmudepay.c:
+ * rtp/gst/gstrtppcmudepay.h:
+ * rtp/gst/gstrtppcmupay.c:
+ * rtp/gst/gstrtppcmupay.h:
+ * rtp/gst/Makefile.am:
+ * rtp/gst/gstrtp.c:
+ * rtp/gst/README:
+ Separated the G711 payloaders/depayloaders into separate elements for
+ mulaw/alaw. Also removed the old g711 payloaders/depayloaders.
+
2006-02-22 Wim Taymans <wim@fluendo.com>
* ext/dv/gstdvdec.c: (gst_dvdec_base_init), (gst_dvdec_init),
gstrtpdepay.c \
gstrtpmpadepay.c \
gstrtpmpapay.c \
- gstrtpg711depay.c \
- gstrtpg711pay.c \
+ gstrtppcmadepay.c \
+ gstrtppcmudepay.c \
+ gstrtppcmupay.c \
+ gstrtppcmapay.c \
gstrtpgsmdepay.c \
gstrtpgsmpay.c \
gstrtpamrdepay.c \
gstrtpL16pay.h \
gstrtpamrdepay.h \
gstrtpamrpay.h \
- gstrtpg711depay.h \
- gstrtpg711pay.h \
+ gstrtppcmadepay.h \
+ gstrtppcmudepay.h \
+ gstrtppcmupay.h \
+ gstrtppcmapay.h \
gstrtpgsmdepay.h \
gstrtpgsmpay.h \
gstrtpmpadepay.h \
+This directory contains some RTP payloaders/depayloaders for different payload
+types. Use one payloader/depayloder pair per payload. If several payloads can be
+payloaded/depayloaded by the same element, make different copies of it, one for
+each payload.
+
The application/x-rtp mime type
-------------------------------
#endif
#include "gstrtpdepay.h"
-#include "gstrtpg711pay.h"
-#include "gstrtpg711depay.h"
+#include "gstrtppcmupay.h"
+#include "gstrtppcmapay.h"
+#include "gstrtppcmadepay.h"
+#include "gstrtppcmudepay.h"
#include "gstrtpgsmpay.h"
#include "gstrtpgsmdepay.h"
#include "gstrtpamrpay.h"
if (!gst_rtp_amr_pay_plugin_init (plugin))
return FALSE;
- if (!gst_rtp_g711_depay_plugin_init (plugin))
+ if (!gst_rtp_pcma_depay_plugin_init (plugin))
return FALSE;
- if (!gst_rtp_g711_pay_plugin_init (plugin))
+ if (!gst_rtp_pcmu_depay_plugin_init (plugin))
+ return FALSE;
+
+ if (!gst_rtp_pcmu_pay_plugin_init (plugin))
+ return FALSE;
+
+ if (!gst_rtp_pcma_pay_plugin_init (plugin))
return FALSE;
if (!gst_rtp_mpa_depay_plugin_init (plugin))
+++ /dev/null
-/* GStreamer
- * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more
- */
-
-#ifndef __GST_RTP_G711_DEPAY_H__
-#define __GST_RTP_G711_DEPAY_H__
-
-#include <gst/gst.h>
-#include <gst/rtp/gstbasertpdepayload.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GstRtpG711Depay GstRtpG711Depay;
-typedef struct _GstRtpG711DepayClass GstRtpG711DepayClass;
-
-#define GST_TYPE_RTP_G711_DEPAY \
- (gst_rtp_g711_depay_get_type())
-#define GST_RTP_G711_DEPAY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_G711_DEPAY,GstRtpG711Depay))
-#define GST_RTP_G711_DEPAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_G711_DEPAY,GstRtpG711Depay))
-#define GST_IS_RTP_G711_DEPAY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_G711_DEPAY))
-#define GST_IS_RTP_G711_DEPAY_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_G711_DEPAY))
-
-struct _GstRtpG711Depay
-{
- GstBaseRTPDepayload depayload;
-};
-
-struct _GstRtpG711DepayClass
-{
- GstBaseRTPDepayloadClass parent_class;
-};
-
-gboolean gst_rtp_g711_depay_plugin_init (GstPlugin * plugin);
-
-G_END_DECLS
-
-#endif /* __GST_RTP_G711_DEPAY_H__ */
#include <string.h>
#include <gst/rtp/gstrtpbuffer.h>
-#include "gstrtpg711depay.h"
+#include "gstrtppcmadepay.h"
/* elementfactory information */
-static GstElementDetails gst_rtp_g711depay_details = {
+static GstElementDetails gst_rtp_pcmadepay_details = {
"RTP packet parser",
"Codec/Depayr/Network",
- "Extracts PCMU/PCMA audio from RTP packets",
+ "Extracts PCMA audio from RTP packets",
"Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>"
};
-/* RtpG711Depay signals and args */
+/* RtpPcmaDepay signals and args */
enum
{
/* FILL ME */
ARG_0
};
-static GstStaticPadTemplate gst_rtp_g711_depay_sink_template =
- GST_STATIC_PAD_TEMPLATE ("sink",
+static GstStaticPadTemplate gst_rtp_pcma_depay_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
- "clock-rate = (int) 8000, "
- "encoding-name = (string) \"PCMU\"; "
- "application/x-rtp, "
- "media = (string) \"audio\", "
"clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
-
);
-static GstStaticPadTemplate gst_rtp_g711_depay_src_template =
- GST_STATIC_PAD_TEMPLATE ("src",
+static GstStaticPadTemplate gst_rtp_pcma_depay_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-mulaw, "
- "channels = (int) 1; " "audio/x-alaw, " "channels = (int) 1")
+ GST_STATIC_CAPS ("audio/x-alaw, " "channels = (int) 1")
);
-static GstBuffer *gst_rtp_g711_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtp_g711_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps);
-GST_BOILERPLATE (GstRtpG711Depay, gst_rtp_g711_depay, GstBaseRTPDepayload,
+GST_BOILERPLATE (GstRtpPcmaDepay, gst_rtp_pcma_depay, GstBaseRTPDepayload,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
-gst_rtp_g711_depay_base_init (gpointer klass)
+gst_rtp_pcma_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_g711_depay_src_template));
+ gst_static_pad_template_get (&gst_rtp_pcma_depay_src_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_g711_depay_sink_template));
- gst_element_class_set_details (element_class, &gst_rtp_g711depay_details);
+ gst_static_pad_template_get (&gst_rtp_pcma_depay_sink_template));
+ gst_element_class_set_details (element_class, &gst_rtp_pcmadepay_details);
}
static void
-gst_rtp_g711_depay_class_init (GstRtpG711DepayClass * klass)
+gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
- gstbasertpdepayload_class->process = gst_rtp_g711_depay_process;
- gstbasertpdepayload_class->set_caps = gst_rtp_g711_depay_setcaps;
+ gstbasertpdepayload_class->process = gst_rtp_pcma_depay_process;
+ gstbasertpdepayload_class->set_caps = gst_rtp_pcma_depay_setcaps;
}
static void
-gst_rtp_g711_depay_init (GstRtpG711Depay * rtpg711depay,
- GstRtpG711DepayClass * klass)
+gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay,
+ GstRtpPcmaDepayClass * klass)
{
GstBaseRTPDepayload *depayload;
- depayload = GST_BASE_RTP_DEPAYLOAD (rtpg711depay);
+ depayload = GST_BASE_RTP_DEPAYLOAD (rtppcmadepay);
depayload->clock_rate = 8000;
gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtp_g711_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
- const gchar *pay_name;
- GstStructure *structure;
gboolean ret;
- structure = gst_caps_get_structure (caps, 0);
- pay_name = gst_structure_get_string (structure, "encoding-name");
-
- if (NULL == pay_name) {
- return FALSE;
- }
-
- if (0 == strcmp ("PCMU", pay_name)) {
- srccaps = gst_caps_new_simple ("audio/x-mulaw",
- "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
- } else if (0 == strcmp ("PCMA", pay_name)) {
- srccaps = gst_caps_new_simple ("audio/x-alaw",
- "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
- } else {
- return FALSE;
- }
+ srccaps = gst_caps_new_simple ("audio/x-alaw",
+ "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
}
static GstBuffer *
-gst_rtp_g711_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
GstCaps *srccaps;
GstBuffer *outbuf = NULL;
}
gboolean
-gst_rtp_g711_depay_plugin_init (GstPlugin * plugin)
+gst_rtp_pcma_depay_plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "rtpg711depay",
- GST_RANK_NONE, GST_TYPE_RTP_G711_DEPAY);
+ return gst_element_register (plugin, "rtppcmadepay",
+ GST_RANK_NONE, GST_TYPE_RTP_PCMA_DEPAY);
}
--- /dev/null
+/* GStreamer
+ * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more
+ */
+
+#ifndef __GST_RTP_PCMA_DEPAY_H__
+#define __GST_RTP_PCMA_DEPAY_H__
+
+#include <gst/gst.h>
+#include <gst/rtp/gstbasertpdepayload.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstRtpPcmaDepay GstRtpPcmaDepay;
+typedef struct _GstRtpPcmaDepayClass GstRtpPcmaDepayClass;
+
+#define GST_TYPE_RTP_PCMA_DEPAY \
+ (gst_rtp_pcma_depay_get_type())
+#define GST_RTP_PCMA_DEPAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_PCMA_DEPAY,GstRtpPcmaDepay))
+#define GST_RTP_PCMA_DEPAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_PCMA_DEPAY,GstRtpPcmaDepay))
+#define GST_IS_RTP_PCMA_DEPAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_PCMA_DEPAY))
+#define GST_IS_RTP_PCMA_DEPAY_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_PCMA_DEPAY))
+
+struct _GstRtpPcmaDepay
+{
+ GstBaseRTPDepayload depayload;
+};
+
+struct _GstRtpPcmaDepayClass
+{
+ GstBaseRTPDepayloadClass parent_class;
+};
+
+gboolean gst_rtp_pcma_depay_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_RTP_PCMA_DEPAY_H__ */
#include <string.h>
#include <gst/rtp/gstrtpbuffer.h>
-#include "gstrtpg711pay.h"
+#include "gstrtppcmapay.h"
/* elementfactory information */
-static GstElementDetails gst_rtp_g711_pay_details = {
+static GstElementDetails gst_rtp_pcma_pay_details = {
"RTP packet parser",
"Codec/Payloader/Network",
- "Payload-encodes PCMU/PCMA audio into a RTP packet",
+ "Payload-encodes PCMA audio into a RTP packet",
"Edgard Lima <edgard.lima@indt.org.br>"
};
-static GstStaticPadTemplate gst_rtp_g711_pay_sink_template =
- GST_STATIC_PAD_TEMPLATE ("sink",
+static GstStaticPadTemplate gst_rtp_pcma_pay_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-mulaw, channels=(int)1, rate=(int)8000 ;"
- "audio/x-alaw, channels=(int)1, rate=(int)8000")
+ GST_STATIC_CAPS ("audio/x-alaw, channels=(int)1, rate=(int)8000")
);
-static GstStaticPadTemplate gst_rtp_g711_pay_src_template =
- GST_STATIC_PAD_TEMPLATE ("src",
+static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
- "payload = (int) " GST_RTP_PAYLOAD_PCMU_STRING ", "
- "clock-rate = (int) 8000, "
- "encoding-name = (string) \"PCMU\"; "
- "application/x-rtp, "
- "media = (string) \"audio\", "
"payload = (int) " GST_RTP_PAYLOAD_PCMA_STRING ", "
- "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
+ "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\" ")
);
-static gboolean gst_rtp_g711_pay_setcaps (GstBaseRTPPayload * payload,
+static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
-static GstFlowReturn gst_rtp_g711_pay_handle_buffer (GstBaseRTPPayload *
+static GstFlowReturn gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload *
payload, GstBuffer * buffer);
-static void gst_rtp_g711_pay_finalize (GObject * object);
+static void gst_rtp_pcma_pay_finalize (GObject * object);
-GST_BOILERPLATE (GstRtpG711Pay, gst_rtp_g711_pay, GstBaseRTPPayload,
+GST_BOILERPLATE (GstRtpPmcaPay, gst_rtp_pcma_pay, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
/* The lower limit for number of octet to put in one packet
* (clock-rate=8000, octet-per-sample=1). The default 80 is equal
* to to 10msec (see RFC3551) */
-#define GST_RTP_G711_MIN_PTIME_OCTETS 80
+#define GST_RTP_PCMA_MIN_PTIME_OCTETS 80
static void
-gst_rtp_g711_pay_base_init (gpointer klass)
+gst_rtp_pcma_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_g711_pay_sink_template));
+ gst_static_pad_template_get (&gst_rtp_pcma_pay_sink_template));
gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_g711_pay_src_template));
- gst_element_class_set_details (element_class, &gst_rtp_g711_pay_details);
+ gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
+ gst_element_class_set_details (element_class, &gst_rtp_pcma_pay_details);
}
static void
-gst_rtp_g711_pay_class_init (GstRtpG711PayClass * klass)
+gst_rtp_pcma_pay_class_init (GstRtpPmcaPayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
- gobject_class->finalize = gst_rtp_g711_pay_finalize;
+ gobject_class->finalize = gst_rtp_pcma_pay_finalize;
- gstbasertppayload_class->set_caps = gst_rtp_g711_pay_setcaps;
- gstbasertppayload_class->handle_buffer = gst_rtp_g711_pay_handle_buffer;
+ gstbasertppayload_class->set_caps = gst_rtp_pcma_pay_setcaps;
+ gstbasertppayload_class->handle_buffer = gst_rtp_pcma_pay_handle_buffer;
}
static void
-gst_rtp_g711_pay_init (GstRtpG711Pay * rtpg711pay, GstRtpG711PayClass * klass)
+gst_rtp_pcma_pay_init (GstRtpPmcaPay * rtppcmapay, GstRtpPmcaPayClass * klass)
{
- rtpg711pay->adapter = gst_adapter_new ();
- GST_BASE_RTP_PAYLOAD (rtpg711pay)->clock_rate = 8000;
+ rtppcmapay->adapter = gst_adapter_new ();
+ GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate = 8000;
}
static void
-gst_rtp_g711_pay_finalize (GObject * object)
+gst_rtp_pcma_pay_finalize (GObject * object)
{
- GstRtpG711Pay *rtpg711pay;
+ GstRtpPmcaPay *rtppcmapay;
- rtpg711pay = GST_RTP_G711_PAY (object);
+ rtppcmapay = GST_RTP_PCMA_PAY (object);
- g_object_unref (rtpg711pay->adapter);
- rtpg711pay->adapter = NULL;
+ g_object_unref (rtppcmapay->adapter);
+ rtppcmapay->adapter = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
-gst_rtp_g711_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
{
-
- const char *stname;
- GstStructure *structure;
-
- structure = gst_caps_get_structure (caps, 0);
-
- stname = gst_structure_get_name (structure);
-
- if (0 == strcmp ("audio/x-mulaw", stname)) {
- payload->pt = GST_RTP_PAYLOAD_PCMU;
- gst_basertppayload_set_options (payload, "audio", FALSE, "PCMU", 8000);
- } else if (0 == strcmp ("audio/x-alaw", stname)) {
- payload->pt = GST_RTP_PAYLOAD_PCMA;
- gst_basertppayload_set_options (payload, "audio", FALSE, "PCMA", 8000);
- } else {
- return FALSE;
- }
+ payload->pt = GST_RTP_PAYLOAD_PCMA;
+ gst_basertppayload_set_options (payload, "audio", FALSE, "PCMA", 8000);
gst_basertppayload_set_outcaps (payload, NULL);
}
static GstFlowReturn
-gst_rtp_g711_pay_flush (GstRtpG711Pay * rtpg711pay)
+gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
{
guint avail;
GstBuffer *outbuf;
GstFlowReturn ret;
guint maxptime_octets = G_MAXUINT;
- guint minptime_octets = GST_RTP_G711_MIN_PTIME_OCTETS;
+ guint minptime_octets = GST_RTP_PCMA_MIN_PTIME_OCTETS;
- if (GST_BASE_RTP_PAYLOAD (rtpg711pay)->max_ptime > 0) {
+ if (GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime > 0) {
/* calculate octet count with:
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
maxptime_octets =
- GST_BASE_RTP_PAYLOAD (rtpg711pay)->max_ptime *
- GST_BASE_RTP_PAYLOAD (rtpg711pay)->clock_rate / GST_SECOND;
+ GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime *
+ GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate / GST_SECOND;
}
/* the data available in the adapter is either smaller
* than the MTU or bigger. In the case it is smaller, the complete
* adapter contents can be put in one packet. */
- avail = gst_adapter_available (rtpg711pay->adapter);
+ avail = gst_adapter_available (rtppcmapay->adapter);
ret = GST_FLOW_OK;
/* fill one MTU or all available bytes */
payload_len =
- MIN (MIN (GST_BASE_RTP_PAYLOAD_MTU (rtpg711pay), maxptime_octets),
+ MIN (MIN (GST_BASE_RTP_PAYLOAD_MTU (rtppcmapay), maxptime_octets),
avail);
/* this will be the total lenght of the packet */
/* copy payload */
gst_rtp_buffer_set_payload_type (outbuf,
- GST_BASE_RTP_PAYLOAD_PT (rtpg711pay));
+ GST_BASE_RTP_PAYLOAD_PT (rtppcmapay));
payload = gst_rtp_buffer_get_payload (outbuf);
- data = (guint8 *) gst_adapter_peek (rtpg711pay->adapter, payload_len);
+ data = (guint8 *) gst_adapter_peek (rtppcmapay->adapter, payload_len);
memcpy (payload, data, payload_len);
- gst_adapter_flush (rtpg711pay->adapter, payload_len);
+ gst_adapter_flush (rtppcmapay->adapter, payload_len);
avail -= payload_len;
- GST_BUFFER_TIMESTAMP (outbuf) = rtpg711pay->first_ts;
- ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpg711pay), outbuf);
+ GST_BUFFER_TIMESTAMP (outbuf) = rtppcmapay->first_ts;
+ ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmapay), outbuf);
}
return ret;
}
static GstFlowReturn
-gst_rtp_g711_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload * basepayload,
GstBuffer * buffer)
{
- GstRtpG711Pay *rtpg711pay;
+ GstRtpPmcaPay *rtppcmapay;
guint size, packet_len, avail;
GstFlowReturn ret;
GstClockTime duration;
- rtpg711pay = GST_RTP_G711_PAY (basepayload);
+ rtppcmapay = GST_RTP_PCMA_PAY (basepayload);
size = GST_BUFFER_SIZE (buffer);
duration = GST_BUFFER_TIMESTAMP (buffer);
- avail = gst_adapter_available (rtpg711pay->adapter);
+ avail = gst_adapter_available (rtppcmapay->adapter);
if (avail == 0) {
- rtpg711pay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
- rtpg711pay->duration = 0;
+ rtppcmapay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ rtppcmapay->duration = 0;
}
/* get packet length of data and see if we exceeded MTU. */
/* if this buffer is going to overflow the packet, flush what we
* have. */
if (gst_basertppayload_is_filled (basepayload,
- packet_len, rtpg711pay->duration + duration)) {
- ret = gst_rtp_g711_pay_flush (rtpg711pay);
- rtpg711pay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
- rtpg711pay->duration = 0;
+ packet_len, rtppcmapay->duration + duration)) {
+ ret = gst_rtp_pcma_pay_flush (rtppcmapay);
+ rtppcmapay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ rtppcmapay->duration = 0;
} else {
ret = GST_FLOW_OK;
}
- gst_adapter_push (rtpg711pay->adapter, buffer);
- rtpg711pay->duration += duration;
+ gst_adapter_push (rtppcmapay->adapter, buffer);
+ rtppcmapay->duration += duration;
return ret;
}
gboolean
-gst_rtp_g711_pay_plugin_init (GstPlugin * plugin)
+gst_rtp_pcma_pay_plugin_init (GstPlugin * plugin)
{
- return gst_element_register (plugin, "rtpg711pay",
- GST_RANK_NONE, GST_TYPE_RTP_G711_PAY);
+ return gst_element_register (plugin, "rtppcmapay",
+ GST_RANK_NONE, GST_TYPE_RTP_PCMA_PAY);
}
*/
-#ifndef __GST_RTP_G711_PAY_H__
-#define __GST_RTP_G711_PAY_H__
+#ifndef __GST_RTP_PCMA_PAY_H__
+#define __GST_RTP_PCMA_PAY_H__
#include <gst/gst.h>
#include <gst/rtp/gstbasertppayload.h>
G_BEGIN_DECLS
-typedef struct _GstRtpG711Pay GstRtpG711Pay;
-typedef struct _GstRtpG711PayClass GstRtpG711PayClass;
-
-#define GST_TYPE_RTP_G711_PAY \
- (gst_rtp_g711_pay_get_type())
-#define GST_RTP_G711_PAY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_G711_PAY,GstRtpG711Pay))
-#define GST_RTP_G711_PAY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_G711_PAY,GstRtpG711Pay))
-#define GST_IS_RTP_G711_PAY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_G711_PAY))
-#define GST_IS_RTP_G711_PAY_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_G711_PAY))
-
-struct _GstRtpG711Pay
+typedef struct _GstRtpPmcaPay GstRtpPmcaPay;
+typedef struct _GstRtpPmcaPayClass GstRtpPmcaPayClass;
+
+#define GST_TYPE_RTP_PCMA_PAY \
+ (gst_rtp_pcma_pay_get_type())
+#define GST_RTP_PCMA_PAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_PCMA_PAY,GstRtpPmcaPay))
+#define GST_RTP_PCMA_PAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_PCMA_PAY,GstRtpPmcaPay))
+#define GST_IS_RTP_PCMA_PAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_PCMA_PAY))
+#define GST_IS_RTP_PCMA_PAY_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_PCMA_PAY))
+
+struct _GstRtpPmcaPay
{
GstBaseRTPPayload payload;
GstAdapter *adapter;
GstClockTime duration;
};
-struct _GstRtpG711PayClass
+struct _GstRtpPmcaPayClass
{
GstBaseRTPPayloadClass parent_class;
};
-gboolean gst_rtp_g711_pay_plugin_init (GstPlugin * plugin);
+gboolean gst_rtp_pcma_pay_plugin_init (GstPlugin * plugin);
G_END_DECLS
-#endif /* __GST_RTP_G711_PAY_H__ */
+#endif /* __GST_RTP_PCMA_PAY_H__ */
--- /dev/null
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ * Copyright (C) <2005> Zeeshan Ali <zeenix@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string.h>
+#include <gst/rtp/gstrtpbuffer.h>
+#include "gstrtppcmudepay.h"
+
+/* elementfactory information */
+static GstElementDetails gst_rtp_pcmudepay_details = {
+ "RTP packet parser",
+ "Codec/Depayr/Network",
+ "Extracts PCMU audio from RTP packets",
+ "Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>"
+};
+
+/* RtpPcmuDepay signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ ARG_0
+};
+
+static GstStaticPadTemplate gst_rtp_pcmu_depay_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("application/x-rtp, "
+ "media = (string) \"audio\", "
+ "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMU\"")
+
+ );
+
+static GstStaticPadTemplate gst_rtp_pcmu_depay_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-mulaw, " "channels = (int) 1")
+ );
+
+static GstBuffer *gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload,
+ GstBuffer * buf);
+static gboolean gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload,
+ GstCaps * caps);
+
+GST_BOILERPLATE (GstRtpPcmuDepay, gst_rtp_pcmu_depay, GstBaseRTPDepayload,
+ GST_TYPE_BASE_RTP_DEPAYLOAD);
+
+static void
+gst_rtp_pcmu_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_pcmu_depay_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_rtp_pcmu_depay_sink_template));
+ gst_element_class_set_details (element_class, &gst_rtp_pcmudepay_details);
+}
+
+static void
+gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+
+ parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
+
+ gstbasertpdepayload_class->process = gst_rtp_pcmu_depay_process;
+ gstbasertpdepayload_class->set_caps = gst_rtp_pcmu_depay_setcaps;
+}
+
+static void
+gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay,
+ GstRtpPcmuDepayClass * klass)
+{
+ GstBaseRTPDepayload *depayload;
+
+ depayload = GST_BASE_RTP_DEPAYLOAD (rtppcmudepay);
+
+ depayload->clock_rate = 8000;
+ gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+}
+
+static gboolean
+gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+{
+ GstCaps *srccaps;
+ gboolean ret;
+
+ srccaps = gst_caps_new_simple ("audio/x-mulaw",
+ "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
+
+ ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ gst_caps_unref (srccaps);
+
+ return ret;
+}
+
+static GstBuffer *
+gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+{
+ GstCaps *srccaps;
+ GstBuffer *outbuf = NULL;
+ gint payload_len;
+ guint8 *payload;
+
+ GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
+ GST_BUFFER_SIZE (buf),
+ gst_rtp_buffer_get_marker (buf),
+ gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+
+ srccaps = GST_PAD_CAPS (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+ if (!srccaps) {
+ /* Set the default caps */
+ srccaps = gst_caps_new_simple ("audio/x-mulaw",
+ "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
+ gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+ gst_caps_unref (srccaps);
+ }
+
+ payload_len = gst_rtp_buffer_get_payload_len (buf);
+ payload = gst_rtp_buffer_get_payload (buf);
+
+ outbuf = gst_buffer_new_and_alloc (payload_len);
+ memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+ return outbuf;
+}
+
+gboolean
+gst_rtp_pcmu_depay_plugin_init (GstPlugin * plugin)
+{
+ return gst_element_register (plugin, "rtppcmudepay",
+ GST_RANK_NONE, GST_TYPE_RTP_PCMU_DEPAY);
+}
--- /dev/null
+/* GStreamer
+ * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more
+ */
+
+#ifndef __GST_RTP_PCMU_DEPAY_H__
+#define __GST_RTP_PCMU_DEPAY_H__
+
+#include <gst/gst.h>
+#include <gst/rtp/gstbasertpdepayload.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstRtpPcmuDepay GstRtpPcmuDepay;
+typedef struct _GstRtpPcmuDepayClass GstRtpPcmuDepayClass;
+
+#define GST_TYPE_RTP_PCMU_DEPAY \
+ (gst_rtp_pcmu_depay_get_type())
+#define GST_RTP_PCMU_DEPAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_PCMU_DEPAY,GstRtpPcmuDepay))
+#define GST_RTP_PCMU_DEPAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_PCMU_DEPAY,GstRtpPcmuDepay))
+#define GST_IS_RTP_PCMU_DEPAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_PCMU_DEPAY))
+#define GST_IS_RTP_PCMU_DEPAY_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_PCMU_DEPAY))
+
+struct _GstRtpPcmuDepay
+{
+ GstBaseRTPDepayload depayload;
+};
+
+struct _GstRtpPcmuDepayClass
+{
+ GstBaseRTPDepayloadClass parent_class;
+};
+
+gboolean gst_rtp_pcmu_depay_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_RTP_PCMU_DEPAY_H__ */
--- /dev/null
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ * Copyright (C) <2005> Nokia Corporation <kai.vehmanen@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <gst/rtp/gstrtpbuffer.h>
+
+#include "gstrtppcmupay.h"
+
+/* elementfactory information */
+static GstElementDetails gst_rtp_pcmu_pay_details = {
+ "RTP packet parser",
+ "Codec/Payloader/Network",
+ "Payload-encodes PCMU audio into a RTP packet",
+ "Edgard Lima <edgard.lima@indt.org.br>"
+};
+
+static GstStaticPadTemplate gst_rtp_pcmu_pay_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("audio/x-mulaw, channels=(int)1, rate=(int)8000")
+ );
+
+static GstStaticPadTemplate gst_rtp_pcmu_pay_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("application/x-rtp, "
+ "media = (string) \"audio\", "
+ "payload = (int) " GST_RTP_PAYLOAD_PCMU_STRING ", "
+ "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMU\"")
+ );
+
+static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload,
+ GstCaps * caps);
+static GstFlowReturn gst_rtp_pcmu_pay_handle_buffer (GstBaseRTPPayload *
+ payload, GstBuffer * buffer);
+static void gst_rtp_pcmu_pay_finalize (GObject * object);
+
+GST_BOILERPLATE (GstRtpPcmuPay, gst_rtp_pcmu_pay, GstBaseRTPPayload,
+ GST_TYPE_BASE_RTP_PAYLOAD);
+
+/* The lower limit for number of octet to put in one packet
+ * (clock-rate=8000, octet-per-sample=1). The default 80 is equal
+ * to to 10msec (see RFC3551) */
+#define GST_RTP_PCMU_MIN_PTIME_OCTETS 80
+
+static void
+gst_rtp_pcmu_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_pcmu_pay_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_rtp_pcmu_pay_src_template));
+ gst_element_class_set_details (element_class, &gst_rtp_pcmu_pay_details);
+}
+
+static void
+gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstBaseRTPPayloadClass *gstbasertppayload_class;
+
+ gobject_class = (GObjectClass *) klass;
+ gstelement_class = (GstElementClass *) klass;
+ gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
+
+ parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
+ gobject_class->finalize = gst_rtp_pcmu_pay_finalize;
+
+ gstbasertppayload_class->set_caps = gst_rtp_pcmu_pay_setcaps;
+ gstbasertppayload_class->handle_buffer = gst_rtp_pcmu_pay_handle_buffer;
+}
+
+static void
+gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay, GstRtpPcmuPayClass * klass)
+{
+ rtppcmupay->adapter = gst_adapter_new ();
+ GST_BASE_RTP_PAYLOAD (rtppcmupay)->clock_rate = 8000;
+}
+
+static void
+gst_rtp_pcmu_pay_finalize (GObject * object)
+{
+ GstRtpPcmuPay *rtppcmupay;
+
+ rtppcmupay = GST_RTP_PCMU_PAY (object);
+
+ g_object_unref (rtppcmupay->adapter);
+ rtppcmupay->adapter = NULL;
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static gboolean
+gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
+{
+ payload->pt = GST_RTP_PAYLOAD_PCMU;
+ gst_basertppayload_set_options (payload, "audio", FALSE, "PCMU", 8000);
+
+ gst_basertppayload_set_outcaps (payload, NULL);
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay)
+{
+ guint avail;
+ GstBuffer *outbuf;
+ GstFlowReturn ret;
+ guint maxptime_octets = G_MAXUINT;
+ guint minptime_octets = GST_RTP_PCMU_MIN_PTIME_OCTETS;
+
+ if (GST_BASE_RTP_PAYLOAD (rtppcmupay)->max_ptime > 0) {
+ /* calculate octet count with:
+ maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
+ maxptime_octets =
+ GST_BASE_RTP_PAYLOAD (rtppcmupay)->max_ptime *
+ GST_BASE_RTP_PAYLOAD (rtppcmupay)->clock_rate / GST_SECOND;
+ }
+
+ /* the data available in the adapter is either smaller
+ * than the MTU or bigger. In the case it is smaller, the complete
+ * adapter contents can be put in one packet. */
+ avail = gst_adapter_available (rtppcmupay->adapter);
+
+ ret = GST_FLOW_OK;
+
+ while (avail >= minptime_octets) {
+ guint8 *payload;
+ guint8 *data;
+ guint payload_len;
+ guint packet_len;
+
+ /* fill one MTU or all available bytes */
+ payload_len =
+ MIN (MIN (GST_BASE_RTP_PAYLOAD_MTU (rtppcmupay), maxptime_octets),
+ avail);
+
+ /* this will be the total lenght of the packet */
+ packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
+
+ /* create buffer to hold the payload */
+ outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
+
+ /* copy payload */
+ gst_rtp_buffer_set_payload_type (outbuf,
+ GST_BASE_RTP_PAYLOAD_PT (rtppcmupay));
+ payload = gst_rtp_buffer_get_payload (outbuf);
+ data = (guint8 *) gst_adapter_peek (rtppcmupay->adapter, payload_len);
+ memcpy (payload, data, payload_len);
+ gst_adapter_flush (rtppcmupay->adapter, payload_len);
+
+ avail -= payload_len;
+
+ GST_BUFFER_TIMESTAMP (outbuf) = rtppcmupay->first_ts;
+ ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmupay), outbuf);
+ }
+
+ return ret;
+}
+
+static GstFlowReturn
+gst_rtp_pcmu_pay_handle_buffer (GstBaseRTPPayload * basepayload,
+ GstBuffer * buffer)
+{
+ GstRtpPcmuPay *rtppcmupay;
+ guint size, packet_len, avail;
+ GstFlowReturn ret;
+ GstClockTime duration;
+
+ rtppcmupay = GST_RTP_PCMU_PAY (basepayload);
+
+ size = GST_BUFFER_SIZE (buffer);
+ duration = GST_BUFFER_TIMESTAMP (buffer);
+
+ avail = gst_adapter_available (rtppcmupay->adapter);
+ if (avail == 0) {
+ rtppcmupay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ rtppcmupay->duration = 0;
+ }
+
+ /* get packet length of data and see if we exceeded MTU. */
+ packet_len = gst_rtp_buffer_calc_packet_len (avail + size, 0, 0);
+
+ /* if this buffer is going to overflow the packet, flush what we
+ * have. */
+ if (gst_basertppayload_is_filled (basepayload,
+ packet_len, rtppcmupay->duration + duration)) {
+ ret = gst_rtp_pcmu_pay_flush (rtppcmupay);
+ rtppcmupay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
+ rtppcmupay->duration = 0;
+ } else {
+ ret = GST_FLOW_OK;
+ }
+
+ gst_adapter_push (rtppcmupay->adapter, buffer);
+ rtppcmupay->duration += duration;
+
+ return ret;
+}
+
+gboolean
+gst_rtp_pcmu_pay_plugin_init (GstPlugin * plugin)
+{
+ return gst_element_register (plugin, "rtppcmupay",
+ GST_RANK_NONE, GST_TYPE_RTP_PCMU_PAY);
+}
--- /dev/null
+/* GStreamer
+ * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more
+ */
+
+
+#ifndef __GST_RTP_PCMU_PAY_H__
+#define __GST_RTP_PCMU_PAY_H__
+
+#include <gst/gst.h>
+#include <gst/rtp/gstbasertppayload.h>
+#include <gst/base/gstadapter.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstRtpPcmuPay GstRtpPcmuPay;
+typedef struct _GstRtpPcmuPayClass GstRtpPcmuPayClass;
+
+#define GST_TYPE_RTP_PCMU_PAY \
+ (gst_rtp_pcmu_pay_get_type())
+#define GST_RTP_PCMU_PAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_PCMU_PAY,GstRtpPcmuPay))
+#define GST_RTP_PCMU_PAY_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_PCMU_PAY,GstRtpPcmuPay))
+#define GST_IS_RTP_PCMU_PAY(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_PCMU_PAY))
+#define GST_IS_RTP_PCMU_PAY_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_PCMU_PAY))
+
+struct _GstRtpPcmuPay
+{
+ GstBaseRTPPayload payload;
+ GstAdapter *adapter;
+
+ GstClockTime first_ts;
+ GstClockTime duration;
+};
+
+struct _GstRtpPcmuPayClass
+{
+ GstBaseRTPPayloadClass parent_class;
+};
+
+gboolean gst_rtp_pcmu_pay_plugin_init (GstPlugin * plugin);
+
+G_END_DECLS
+
+#endif /* __GST_RTP_PCMU_PAY_H__ */