2003-07-13 00:20:44 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2005-10-26 20:28:32 +00:00
|
|
|
* Copyright (C) <2005> Zeeshan Ali <zeenix@gmail.com>
|
2003-07-13 00:20:44 +00:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-22 13:51:30 +00:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2003-07-13 00:20:44 +00:00
|
|
|
*/
|
|
|
|
|
2003-07-15 13:17:20 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-07-13 00:20:44 +00:00
|
|
|
#include <string.h>
|
2005-09-15 13:57:56 +00:00
|
|
|
#include <gst/rtp/gstrtpbuffer.h>
|
2005-12-01 14:39:30 +00:00
|
|
|
#include "gstrtpgsmdepay.h"
|
2003-07-13 00:20:44 +00:00
|
|
|
|
|
|
|
/* elementfactory information */
|
2005-12-01 14:39:30 +00:00
|
|
|
static GstElementDetails gst_rtp_gsmdepay_details = {
|
2006-11-08 01:30:39 +00:00
|
|
|
"RTP packet depayloader",
|
2006-09-23 15:30:40 +00:00
|
|
|
"Codec/Depayloader/Network",
|
2003-07-13 00:20:44 +00:00
|
|
|
"Extracts GSM audio from RTP packets",
|
2005-10-26 14:50:59 +00:00
|
|
|
"Zeeshan Ali <zeenix@gmail.com>"
|
2003-07-13 00:20:44 +00:00
|
|
|
};
|
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
/* RTPGSMDepay signals and args */
|
2003-07-13 00:20:44 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
static GstStaticPadTemplate gst_rtp_gsm_depay_src_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_SRC,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_ALWAYS,
|
2005-10-25 15:07:02 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-gsm, " "rate = (int) 8000, " "channels = 1")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
static GstStaticPadTemplate gst_rtp_gsm_depay_sink_template =
|
2007-01-24 12:22:51 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_SINK,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_ALWAYS,
|
2005-09-30 16:36:49 +00:00
|
|
|
GST_STATIC_CAPS ("application/x-rtp, "
|
|
|
|
"media = (string) \"audio\", "
|
2007-01-24 12:22:51 +00:00
|
|
|
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
|
|
|
|
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\";"
|
|
|
|
"application/x-rtp, "
|
|
|
|
"media = (string) \"audio\", "
|
|
|
|
"payload = (int) " GST_RTP_PAYLOAD_GSM_STRING ", "
|
|
|
|
"clock-rate = (int) 8000")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2003-12-22 01:47:09 +00:00
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
static GstBuffer *gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload,
|
2005-10-25 15:07:02 +00:00
|
|
|
GstBuffer * buf);
|
2005-12-01 14:39:30 +00:00
|
|
|
static gboolean gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload,
|
2005-10-25 15:07:02 +00:00
|
|
|
GstCaps * caps);
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
GST_BOILERPLATE (GstRTPGSMDepay, gst_rtp_gsm_depay, GstBaseRTPDepayload,
|
2005-10-26 14:50:59 +00:00
|
|
|
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2003-11-02 22:04:36 +00:00
|
|
|
static void
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_rtp_gsm_depay_base_init (gpointer klass)
|
2003-11-02 22:04:36 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_static_pad_template_get (&gst_rtp_gsm_depay_src_template));
|
2003-11-02 22:04:36 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_static_pad_template_get (&gst_rtp_gsm_depay_sink_template));
|
|
|
|
gst_element_class_set_details (element_class, &gst_rtp_gsmdepay_details);
|
2003-11-02 22:04:36 +00:00
|
|
|
}
|
|
|
|
|
2003-07-13 00:20:44 +00:00
|
|
|
static void
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
|
2003-07-13 00:20:44 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2005-12-01 14:30:01 +00:00
|
|
|
GstBaseRTPDepayloadClass *gstbasertp_depayload_class;
|
2003-07-13 00:20:44 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2005-12-01 14:30:01 +00:00
|
|
|
gstbasertp_depayload_class = (GstBaseRTPDepayloadClass *) klass;
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2006-04-08 21:21:45 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
gstbasertp_depayload_class->process = gst_rtp_gsm_depay_process;
|
|
|
|
gstbasertp_depayload_class->set_caps = gst_rtp_gsm_depay_setcaps;
|
2003-07-13 00:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay,
|
|
|
|
GstRTPGSMDepayClass * klass)
|
2003-07-13 00:20:44 +00:00
|
|
|
{
|
2005-12-01 14:39:30 +00:00
|
|
|
GST_BASE_RTP_DEPAYLOAD (rtpgsmdepay)->clock_rate = 8000;
|
2003-07-13 00:20:44 +00:00
|
|
|
}
|
|
|
|
|
2005-10-25 15:07:02 +00:00
|
|
|
static gboolean
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload, GstCaps * caps)
|
2003-07-13 00:20:44 +00:00
|
|
|
{
|
2005-10-25 15:07:02 +00:00
|
|
|
GstCaps *srccaps;
|
2005-10-26 14:50:59 +00:00
|
|
|
gboolean ret;
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-12-01 14:39:30 +00:00
|
|
|
srccaps = gst_static_pad_template_get_caps (&gst_rtp_gsm_depay_src_template);
|
2005-12-01 14:30:01 +00:00
|
|
|
ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (_depayload), srccaps);
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-10-26 14:50:59 +00:00
|
|
|
gst_caps_unref (srccaps);
|
|
|
|
return ret;
|
2003-07-13 00:20:44 +00:00
|
|
|
}
|
|
|
|
|
2005-10-25 15:07:02 +00:00
|
|
|
static GstBuffer *
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload, GstBuffer * buf)
|
2003-07-13 00:20:44 +00:00
|
|
|
{
|
2005-10-25 15:07:02 +00:00
|
|
|
GstBuffer *outbuf = NULL;
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-10-25 15:07:02 +00:00
|
|
|
GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
|
|
|
|
GST_BUFFER_SIZE (buf),
|
2005-12-01 14:30:01 +00:00
|
|
|
gst_rtp_buffer_get_marker (buf),
|
|
|
|
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2007-03-29 14:03:21 +00:00
|
|
|
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
2003-07-13 00:20:44 +00:00
|
|
|
|
2005-10-25 15:07:02 +00:00
|
|
|
return outbuf;
|
2003-07-13 00:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2005-12-01 14:39:30 +00:00
|
|
|
gst_rtp_gsm_depay_plugin_init (GstPlugin * plugin)
|
2003-07-13 00:20:44 +00:00
|
|
|
{
|
2005-12-01 14:39:30 +00:00
|
|
|
return gst_element_register (plugin, "rtpgsmdepay",
|
2006-09-23 15:30:40 +00:00
|
|
|
GST_RANK_MARGINAL, GST_TYPE_RTP_GSM_DEPAY);
|
2003-07-13 00:20:44 +00:00
|
|
|
}
|