mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
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.
This commit is contained in:
parent
ec24b0dfab
commit
8449839ab1
13 changed files with 698 additions and 209 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
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>
|
2006-02-22 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* ext/dv/gstdvdec.c: (gst_dvdec_base_init), (gst_dvdec_init),
|
* ext/dv/gstdvdec.c: (gst_dvdec_base_init), (gst_dvdec_init),
|
||||||
|
|
|
@ -5,8 +5,10 @@ libgstrtp_la_SOURCES = \
|
||||||
gstrtpdepay.c \
|
gstrtpdepay.c \
|
||||||
gstrtpmpadepay.c \
|
gstrtpmpadepay.c \
|
||||||
gstrtpmpapay.c \
|
gstrtpmpapay.c \
|
||||||
gstrtpg711depay.c \
|
gstrtppcmadepay.c \
|
||||||
gstrtpg711pay.c \
|
gstrtppcmudepay.c \
|
||||||
|
gstrtppcmupay.c \
|
||||||
|
gstrtppcmapay.c \
|
||||||
gstrtpgsmdepay.c \
|
gstrtpgsmdepay.c \
|
||||||
gstrtpgsmpay.c \
|
gstrtpgsmpay.c \
|
||||||
gstrtpamrdepay.c \
|
gstrtpamrdepay.c \
|
||||||
|
@ -39,8 +41,10 @@ noinst_HEADERS = \
|
||||||
gstrtpL16pay.h \
|
gstrtpL16pay.h \
|
||||||
gstrtpamrdepay.h \
|
gstrtpamrdepay.h \
|
||||||
gstrtpamrpay.h \
|
gstrtpamrpay.h \
|
||||||
gstrtpg711depay.h \
|
gstrtppcmadepay.h \
|
||||||
gstrtpg711pay.h \
|
gstrtppcmudepay.h \
|
||||||
|
gstrtppcmupay.h \
|
||||||
|
gstrtppcmapay.h \
|
||||||
gstrtpgsmdepay.h \
|
gstrtpgsmdepay.h \
|
||||||
gstrtpgsmpay.h \
|
gstrtpgsmpay.h \
|
||||||
gstrtpmpadepay.h \
|
gstrtpmpadepay.h \
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
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
|
The application/x-rtp mime type
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gstrtpdepay.h"
|
#include "gstrtpdepay.h"
|
||||||
#include "gstrtpg711pay.h"
|
#include "gstrtppcmupay.h"
|
||||||
#include "gstrtpg711depay.h"
|
#include "gstrtppcmapay.h"
|
||||||
|
#include "gstrtppcmadepay.h"
|
||||||
|
#include "gstrtppcmudepay.h"
|
||||||
#include "gstrtpgsmpay.h"
|
#include "gstrtpgsmpay.h"
|
||||||
#include "gstrtpgsmdepay.h"
|
#include "gstrtpgsmdepay.h"
|
||||||
#include "gstrtpamrpay.h"
|
#include "gstrtpamrpay.h"
|
||||||
|
@ -58,10 +60,16 @@ plugin_init (GstPlugin * plugin)
|
||||||
if (!gst_rtp_amr_pay_plugin_init (plugin))
|
if (!gst_rtp_amr_pay_plugin_init (plugin))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_rtp_g711_depay_plugin_init (plugin))
|
if (!gst_rtp_pcma_depay_plugin_init (plugin))
|
||||||
return FALSE;
|
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;
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_rtp_mpa_depay_plugin_init (plugin))
|
if (!gst_rtp_mpa_depay_plugin_init (plugin))
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
/* 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__ */
|
|
|
@ -20,17 +20,17 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/rtp/gstrtpbuffer.h>
|
#include <gst/rtp/gstrtpbuffer.h>
|
||||||
#include "gstrtpg711depay.h"
|
#include "gstrtppcmadepay.h"
|
||||||
|
|
||||||
/* elementfactory information */
|
/* elementfactory information */
|
||||||
static GstElementDetails gst_rtp_g711depay_details = {
|
static GstElementDetails gst_rtp_pcmadepay_details = {
|
||||||
"RTP packet parser",
|
"RTP packet parser",
|
||||||
"Codec/Depayr/Network",
|
"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>"
|
"Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* RtpG711Depay signals and args */
|
/* RtpPcmaDepay signals and args */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
|
@ -42,50 +42,44 @@ enum
|
||||||
ARG_0
|
ARG_0
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_g711_depay_sink_template =
|
static GstStaticPadTemplate gst_rtp_pcma_depay_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("application/x-rtp, "
|
GST_STATIC_CAPS ("application/x-rtp, "
|
||||||
"media = (string) \"audio\", "
|
|
||||||
"clock-rate = (int) 8000, "
|
|
||||||
"encoding-name = (string) \"PCMU\"; "
|
|
||||||
"application/x-rtp, "
|
|
||||||
"media = (string) \"audio\", "
|
"media = (string) \"audio\", "
|
||||||
"clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
|
"clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_g711_depay_src_template =
|
static GstStaticPadTemplate gst_rtp_pcma_depay_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-mulaw, "
|
GST_STATIC_CAPS ("audio/x-alaw, " "channels = (int) 1")
|
||||||
"channels = (int) 1; " "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);
|
GstBuffer * buf);
|
||||||
static gboolean gst_rtp_g711_depay_setcaps (GstBaseRTPDepayload * depayload,
|
static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload,
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstRtpG711Depay, gst_rtp_g711_depay, GstBaseRTPDepayload,
|
GST_BOILERPLATE (GstRtpPcmaDepay, gst_rtp_pcma_depay, GstBaseRTPDepayload,
|
||||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||||
|
|
||||||
static void
|
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);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
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_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&gst_rtp_g711_depay_sink_template));
|
gst_static_pad_template_get (&gst_rtp_pcma_depay_sink_template));
|
||||||
gst_element_class_set_details (element_class, &gst_rtp_g711depay_details);
|
gst_element_class_set_details (element_class, &gst_rtp_pcmadepay_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_g711_depay_class_init (GstRtpG711DepayClass * klass)
|
gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_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);
|
parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||||
|
|
||||||
gstbasertpdepayload_class->process = gst_rtp_g711_depay_process;
|
gstbasertpdepayload_class->process = gst_rtp_pcma_depay_process;
|
||||||
gstbasertpdepayload_class->set_caps = gst_rtp_g711_depay_setcaps;
|
gstbasertpdepayload_class->set_caps = gst_rtp_pcma_depay_setcaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_g711_depay_init (GstRtpG711Depay * rtpg711depay,
|
gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay,
|
||||||
GstRtpG711DepayClass * klass)
|
GstRtpPcmaDepayClass * klass)
|
||||||
{
|
{
|
||||||
GstBaseRTPDepayload *depayload;
|
GstBaseRTPDepayload *depayload;
|
||||||
|
|
||||||
depayload = GST_BASE_RTP_DEPAYLOAD (rtpg711depay);
|
depayload = GST_BASE_RTP_DEPAYLOAD (rtppcmadepay);
|
||||||
|
|
||||||
depayload->clock_rate = 8000;
|
depayload->clock_rate = 8000;
|
||||||
gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
|
gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_g711_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstCaps *srccaps;
|
GstCaps *srccaps;
|
||||||
const gchar *pay_name;
|
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
srccaps = gst_caps_new_simple ("audio/x-alaw",
|
||||||
pay_name = gst_structure_get_string (structure, "encoding-name");
|
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
|
ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
|
||||||
gst_caps_unref (srccaps);
|
gst_caps_unref (srccaps);
|
||||||
|
@ -145,7 +123,7 @@ gst_rtp_g711_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
gst_rtp_g711_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstCaps *srccaps;
|
GstCaps *srccaps;
|
||||||
GstBuffer *outbuf = NULL;
|
GstBuffer *outbuf = NULL;
|
||||||
|
@ -175,8 +153,8 @@ gst_rtp_g711_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_rtp_g711_depay_plugin_init (GstPlugin * plugin)
|
gst_rtp_pcma_depay_plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
return gst_element_register (plugin, "rtpg711depay",
|
return gst_element_register (plugin, "rtppcmadepay",
|
||||||
GST_RANK_NONE, GST_TYPE_RTP_G711_DEPAY);
|
GST_RANK_NONE, GST_TYPE_RTP_PCMA_DEPAY);
|
||||||
}
|
}
|
51
gst/rtp/gstrtppcmadepay.h
Normal file
51
gst/rtp/gstrtppcmadepay.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* 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__ */
|
|
@ -22,67 +22,61 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/rtp/gstrtpbuffer.h>
|
#include <gst/rtp/gstrtpbuffer.h>
|
||||||
|
|
||||||
#include "gstrtpg711pay.h"
|
#include "gstrtppcmapay.h"
|
||||||
|
|
||||||
/* elementfactory information */
|
/* elementfactory information */
|
||||||
static GstElementDetails gst_rtp_g711_pay_details = {
|
static GstElementDetails gst_rtp_pcma_pay_details = {
|
||||||
"RTP packet parser",
|
"RTP packet parser",
|
||||||
"Codec/Payloader/Network",
|
"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>"
|
"Edgard Lima <edgard.lima@indt.org.br>"
|
||||||
};
|
};
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_g711_pay_sink_template =
|
static GstStaticPadTemplate gst_rtp_pcma_pay_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-mulaw, channels=(int)1, rate=(int)8000 ;"
|
GST_STATIC_CAPS ("audio/x-alaw, channels=(int)1, rate=(int)8000")
|
||||||
"audio/x-alaw, channels=(int)1, rate=(int)8000")
|
|
||||||
);
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_rtp_g711_pay_src_template =
|
static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("application/x-rtp, "
|
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\", "
|
"media = (string) \"audio\", "
|
||||||
"payload = (int) " GST_RTP_PAYLOAD_PCMA_STRING ", "
|
"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);
|
GstCaps * caps);
|
||||||
static GstFlowReturn gst_rtp_g711_pay_handle_buffer (GstBaseRTPPayload *
|
static GstFlowReturn gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload *
|
||||||
payload, GstBuffer * buffer);
|
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);
|
GST_TYPE_BASE_RTP_PAYLOAD);
|
||||||
|
|
||||||
/* The lower limit for number of octet to put in one packet
|
/* The lower limit for number of octet to put in one packet
|
||||||
* (clock-rate=8000, octet-per-sample=1). The default 80 is equal
|
* (clock-rate=8000, octet-per-sample=1). The default 80 is equal
|
||||||
* to to 10msec (see RFC3551) */
|
* to to 10msec (see RFC3551) */
|
||||||
#define GST_RTP_G711_MIN_PTIME_OCTETS 80
|
#define GST_RTP_PCMA_MIN_PTIME_OCTETS 80
|
||||||
|
|
||||||
static void
|
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);
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
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_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&gst_rtp_g711_pay_src_template));
|
gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
|
||||||
gst_element_class_set_details (element_class, &gst_rtp_g711_pay_details);
|
gst_element_class_set_details (element_class, &gst_rtp_pcma_pay_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_rtp_g711_pay_class_init (GstRtpG711PayClass * klass)
|
gst_rtp_pcma_pay_class_init (GstRtpPmcaPayClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *gstelement_class;
|
GstElementClass *gstelement_class;
|
||||||
|
@ -93,52 +87,37 @@ gst_rtp_g711_pay_class_init (GstRtpG711PayClass * klass)
|
||||||
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
|
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
|
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->set_caps = gst_rtp_pcma_pay_setcaps;
|
||||||
gstbasertppayload_class->handle_buffer = gst_rtp_g711_pay_handle_buffer;
|
gstbasertppayload_class->handle_buffer = gst_rtp_pcma_pay_handle_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 ();
|
rtppcmapay->adapter = gst_adapter_new ();
|
||||||
GST_BASE_RTP_PAYLOAD (rtpg711pay)->clock_rate = 8000;
|
GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate = 8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
g_object_unref (rtppcmapay->adapter);
|
||||||
rtpg711pay->adapter = NULL;
|
rtppcmapay->adapter = NULL;
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_g711_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
|
gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||||
{
|
{
|
||||||
|
payload->pt = GST_RTP_PAYLOAD_PCMA;
|
||||||
const char *stname;
|
gst_basertppayload_set_options (payload, "audio", FALSE, "PCMA", 8000);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_basertppayload_set_outcaps (payload, NULL);
|
gst_basertppayload_set_outcaps (payload, NULL);
|
||||||
|
|
||||||
|
@ -146,26 +125,26 @@ gst_rtp_g711_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_rtp_g711_pay_flush (GstRtpG711Pay * rtpg711pay)
|
gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
|
||||||
{
|
{
|
||||||
guint avail;
|
guint avail;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
guint maxptime_octets = G_MAXUINT;
|
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:
|
/* calculate octet count with:
|
||||||
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
|
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
|
||||||
maxptime_octets =
|
maxptime_octets =
|
||||||
GST_BASE_RTP_PAYLOAD (rtpg711pay)->max_ptime *
|
GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime *
|
||||||
GST_BASE_RTP_PAYLOAD (rtpg711pay)->clock_rate / GST_SECOND;
|
GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate / GST_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the data available in the adapter is either smaller
|
/* the data available in the adapter is either smaller
|
||||||
* than the MTU or bigger. In the case it is smaller, the complete
|
* than the MTU or bigger. In the case it is smaller, the complete
|
||||||
* adapter contents can be put in one packet. */
|
* adapter contents can be put in one packet. */
|
||||||
avail = gst_adapter_available (rtpg711pay->adapter);
|
avail = gst_adapter_available (rtppcmapay->adapter);
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -177,7 +156,7 @@ gst_rtp_g711_pay_flush (GstRtpG711Pay * rtpg711pay)
|
||||||
|
|
||||||
/* fill one MTU or all available bytes */
|
/* fill one MTU or all available bytes */
|
||||||
payload_len =
|
payload_len =
|
||||||
MIN (MIN (GST_BASE_RTP_PAYLOAD_MTU (rtpg711pay), maxptime_octets),
|
MIN (MIN (GST_BASE_RTP_PAYLOAD_MTU (rtppcmapay), maxptime_octets),
|
||||||
avail);
|
avail);
|
||||||
|
|
||||||
/* this will be the total lenght of the packet */
|
/* this will be the total lenght of the packet */
|
||||||
|
@ -188,39 +167,39 @@ gst_rtp_g711_pay_flush (GstRtpG711Pay * rtpg711pay)
|
||||||
|
|
||||||
/* copy payload */
|
/* copy payload */
|
||||||
gst_rtp_buffer_set_payload_type (outbuf,
|
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);
|
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);
|
memcpy (payload, data, payload_len);
|
||||||
gst_adapter_flush (rtpg711pay->adapter, payload_len);
|
gst_adapter_flush (rtppcmapay->adapter, payload_len);
|
||||||
|
|
||||||
avail -= payload_len;
|
avail -= payload_len;
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = rtpg711pay->first_ts;
|
GST_BUFFER_TIMESTAMP (outbuf) = rtppcmapay->first_ts;
|
||||||
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtpg711pay), outbuf);
|
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmapay), outbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_rtp_g711_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstRtpG711Pay *rtpg711pay;
|
GstRtpPmcaPay *rtppcmapay;
|
||||||
guint size, packet_len, avail;
|
guint size, packet_len, avail;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
|
|
||||||
rtpg711pay = GST_RTP_G711_PAY (basepayload);
|
rtppcmapay = GST_RTP_PCMA_PAY (basepayload);
|
||||||
|
|
||||||
size = GST_BUFFER_SIZE (buffer);
|
size = GST_BUFFER_SIZE (buffer);
|
||||||
duration = GST_BUFFER_TIMESTAMP (buffer);
|
duration = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
avail = gst_adapter_available (rtpg711pay->adapter);
|
avail = gst_adapter_available (rtppcmapay->adapter);
|
||||||
if (avail == 0) {
|
if (avail == 0) {
|
||||||
rtpg711pay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
|
rtppcmapay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
rtpg711pay->duration = 0;
|
rtppcmapay->duration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get packet length of data and see if we exceeded MTU. */
|
/* 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
|
/* if this buffer is going to overflow the packet, flush what we
|
||||||
* have. */
|
* have. */
|
||||||
if (gst_basertppayload_is_filled (basepayload,
|
if (gst_basertppayload_is_filled (basepayload,
|
||||||
packet_len, rtpg711pay->duration + duration)) {
|
packet_len, rtppcmapay->duration + duration)) {
|
||||||
ret = gst_rtp_g711_pay_flush (rtpg711pay);
|
ret = gst_rtp_pcma_pay_flush (rtppcmapay);
|
||||||
rtpg711pay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
|
rtppcmapay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
rtpg711pay->duration = 0;
|
rtppcmapay->duration = 0;
|
||||||
} else {
|
} else {
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_adapter_push (rtpg711pay->adapter, buffer);
|
gst_adapter_push (rtppcmapay->adapter, buffer);
|
||||||
rtpg711pay->duration += duration;
|
rtppcmapay->duration += duration;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_rtp_g711_pay_plugin_init (GstPlugin * plugin)
|
gst_rtp_pcma_pay_plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
return gst_element_register (plugin, "rtpg711pay",
|
return gst_element_register (plugin, "rtppcmapay",
|
||||||
GST_RANK_NONE, GST_TYPE_RTP_G711_PAY);
|
GST_RANK_NONE, GST_TYPE_RTP_PCMA_PAY);
|
||||||
}
|
}
|
|
@ -13,8 +13,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __GST_RTP_G711_PAY_H__
|
#ifndef __GST_RTP_PCMA_PAY_H__
|
||||||
#define __GST_RTP_G711_PAY_H__
|
#define __GST_RTP_PCMA_PAY_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/rtp/gstbasertppayload.h>
|
#include <gst/rtp/gstbasertppayload.h>
|
||||||
|
@ -22,21 +22,21 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstRtpG711Pay GstRtpG711Pay;
|
typedef struct _GstRtpPmcaPay GstRtpPmcaPay;
|
||||||
typedef struct _GstRtpG711PayClass GstRtpG711PayClass;
|
typedef struct _GstRtpPmcaPayClass GstRtpPmcaPayClass;
|
||||||
|
|
||||||
#define GST_TYPE_RTP_G711_PAY \
|
#define GST_TYPE_RTP_PCMA_PAY \
|
||||||
(gst_rtp_g711_pay_get_type())
|
(gst_rtp_pcma_pay_get_type())
|
||||||
#define GST_RTP_G711_PAY(obj) \
|
#define GST_RTP_PCMA_PAY(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_G711_PAY,GstRtpG711Pay))
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_PCMA_PAY,GstRtpPmcaPay))
|
||||||
#define GST_RTP_G711_PAY_CLASS(klass) \
|
#define GST_RTP_PCMA_PAY_CLASS(klass) \
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_G711_PAY,GstRtpG711Pay))
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_PCMA_PAY,GstRtpPmcaPay))
|
||||||
#define GST_IS_RTP_G711_PAY(obj) \
|
#define GST_IS_RTP_PCMA_PAY(obj) \
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_G711_PAY))
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_PCMA_PAY))
|
||||||
#define GST_IS_RTP_G711_PAY_CLASS(obj) \
|
#define GST_IS_RTP_PCMA_PAY_CLASS(obj) \
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_G711_PAY))
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_PCMA_PAY))
|
||||||
|
|
||||||
struct _GstRtpG711Pay
|
struct _GstRtpPmcaPay
|
||||||
{
|
{
|
||||||
GstBaseRTPPayload payload;
|
GstBaseRTPPayload payload;
|
||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
|
@ -45,13 +45,13 @@ struct _GstRtpG711Pay
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstRtpG711PayClass
|
struct _GstRtpPmcaPayClass
|
||||||
{
|
{
|
||||||
GstBaseRTPPayloadClass parent_class;
|
GstBaseRTPPayloadClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean gst_rtp_g711_pay_plugin_init (GstPlugin * plugin);
|
gboolean gst_rtp_pcma_pay_plugin_init (GstPlugin * plugin);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_RTP_G711_PAY_H__ */
|
#endif /* __GST_RTP_PCMA_PAY_H__ */
|
161
gst/rtp/gstrtppcmudepay.c
Normal file
161
gst/rtp/gstrtppcmudepay.c
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/* 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);
|
||||||
|
}
|
51
gst/rtp/gstrtppcmudepay.h
Normal file
51
gst/rtp/gstrtppcmudepay.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* 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__ */
|
230
gst/rtp/gstrtppcmupay.c
Normal file
230
gst/rtp/gstrtppcmupay.c
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
/* 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);
|
||||||
|
}
|
57
gst/rtp/gstrtppcmupay.h
Normal file
57
gst/rtp/gstrtppcmupay.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/* 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__ */
|
Loading…
Reference in a new issue