Commit 8449839a authored by Philippe Khalaf's avatar Philippe Khalaf
Browse files

rtp/gst/: Separated the G711 payloaders/depayloaders into separate elements...

rtp/gst/: Separated the G711 payloaders/depayloaders into separate elements for mulaw/alaw. Also removed the old g711...

Original commit message from CVS:
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.
parent ec24b0df
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),
......
......@@ -5,8 +5,10 @@ libgstrtp_la_SOURCES = \
gstrtpdepay.c \
gstrtpmpadepay.c \
gstrtpmpapay.c \
gstrtpg711depay.c \
gstrtpg711pay.c \
gstrtppcmadepay.c \
gstrtppcmudepay.c \
gstrtppcmupay.c \
gstrtppcmapay.c \
gstrtpgsmdepay.c \
gstrtpgsmpay.c \
gstrtpamrdepay.c \
......@@ -39,8 +41,10 @@ noinst_HEADERS = \
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
-------------------------------
......
......@@ -22,8 +22,10 @@
#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"
......@@ -58,10 +60,16 @@ plugin_init (GstPlugin * plugin)
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))
......
......@@ -20,17 +20,17 @@
#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 */
......@@ -42,50 +42,44 @@ enum
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;
......@@ -97,46 +91,30 @@ gst_rtp_g711_depay_class_init (GstRtpG711DepayClass * klass)
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);
......@@ -145,7 +123,7 @@ gst_rtp_g711_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
}
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;
......@@ -175,8 +153,8 @@ gst_rtp_g711_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
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);
}
......@@ -12,40 +12,40 @@
* Library General Public License for more
*/
#ifndef __GST_RTP_G711_DEPAY_H__
#define __GST_RTP_G711_DEPAY_H__
#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 _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
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 _GstRtpG711DepayClass
struct _GstRtpPcmaDepayClass
{
GstBaseRTPDepayloadClass parent_class;
};
gboolean gst_rtp_g711_depay_plugin_init (GstPlugin * plugin);
gboolean gst_rtp_pcma_depay_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif /* __GST_RTP_G711_DEPAY_H__ */
#endif /* __GST_RTP_PCMA_DEPAY_H__ */
......@@ -22,67 +22,61 @@
#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;
......@@ -93,52 +87,37 @@ gst_rtp_g711_pay_class_init (GstRtpG711PayClass * klass)
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);
......@@ -146,26 +125,26 @@ gst_rtp_g711_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
}
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;
......@@ -177,7 +156,7 @@ gst_rtp_g711_pay_flush (GstRtpG711Pay * rtpg711pay)
/* 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 */
......@@ -188,39 +167,39 @@ gst_rtp_g711_pay_flush (GstRtpG711Pay * rtpg711pay)
/* 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. */
......@@ -229,23 +208,23 @@ gst_rtp_g711_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* 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);
}
......@@ -13,8 +13,8 @@
*/
#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>
......@@ -22,21 +22,21 @@
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;