mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 18:05:37 +00:00
rtp: add rtpisacdepay
Depayload for the iSAC audio codec. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/530>
This commit is contained in:
parent
a1e7b1fd61
commit
ba3919ecb2
4 changed files with 189 additions and 0 deletions
|
@ -70,6 +70,7 @@
|
||||||
#include "gstrtph264pay.h"
|
#include "gstrtph264pay.h"
|
||||||
#include "gstrtph265depay.h"
|
#include "gstrtph265depay.h"
|
||||||
#include "gstrtph265pay.h"
|
#include "gstrtph265pay.h"
|
||||||
|
#include "gstrtpisacdepay.h"
|
||||||
#include "gstrtpisacpay.h"
|
#include "gstrtpisacpay.h"
|
||||||
#include "gstrtpj2kdepay.h"
|
#include "gstrtpj2kdepay.h"
|
||||||
#include "gstrtpj2kpay.h"
|
#include "gstrtpj2kpay.h"
|
||||||
|
@ -397,6 +398,9 @@ plugin_init (GstPlugin * plugin)
|
||||||
if (!gst_rtp_isac_pay_plugin_init (plugin))
|
if (!gst_rtp_isac_pay_plugin_init (plugin))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (!gst_rtp_isac_depay_plugin_init (plugin))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (!gst_element_register (plugin, "rtpredenc", GST_RANK_NONE,
|
if (!gst_element_register (plugin, "rtpredenc", GST_RANK_NONE,
|
||||||
GST_TYPE_RTP_RED_ENC))
|
GST_TYPE_RTP_RED_ENC))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
151
gst/rtp/gstrtpisacdepay.c
Normal file
151
gst/rtp/gstrtpisacdepay.c
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2020 Collabora Ltd.
|
||||||
|
* Author: Guillaume Desmottes <guillaume.desmottes@collabora.com>, Collabora Ltd.
|
||||||
|
*
|
||||||
|
* 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 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., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:element-isacdepay
|
||||||
|
* @title: isacdepay
|
||||||
|
* @short_description: iSAC RTP Depayloader
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <gst/rtp/gstrtpbuffer.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
|
#include "gstrtpisacdepay.h"
|
||||||
|
#include "gstrtputils.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_STATIC (rtpisacdepay_debug);
|
||||||
|
#define GST_CAT_DEFAULT (rtpisacdepay_debug)
|
||||||
|
|
||||||
|
static GstStaticPadTemplate gst_rtp_isac_depay_sink_template =
|
||||||
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
|
GST_PAD_SINK,
|
||||||
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("application/x-rtp, "
|
||||||
|
"media = (string) \"audio\", "
|
||||||
|
"payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
|
||||||
|
"clock-rate = (int) { 16000, 32000 }, "
|
||||||
|
"encoding-name = (string) \"ISAC\"")
|
||||||
|
);
|
||||||
|
|
||||||
|
static GstStaticPadTemplate gst_rtp_isac_depay_src_template =
|
||||||
|
GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
|
GST_PAD_SRC,
|
||||||
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("audio/isac, "
|
||||||
|
"rate = (int) { 16000, 32000 }, " "channels = (int) 1")
|
||||||
|
);
|
||||||
|
|
||||||
|
struct _GstRtpIsacDepay
|
||||||
|
{
|
||||||
|
/*< private > */
|
||||||
|
GstRTPBaseDepayload parent;
|
||||||
|
|
||||||
|
guint64 packet;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define gst_rtp_isac_depay_parent_class parent_class
|
||||||
|
G_DEFINE_TYPE (GstRtpIsacDepay, gst_rtp_isac_depay,
|
||||||
|
GST_TYPE_RTP_BASE_DEPAYLOAD);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_rtp_isac_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
|
{
|
||||||
|
GstCaps *src_caps;
|
||||||
|
GstStructure *s;
|
||||||
|
gint rate;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (depayload, "sink caps: %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
|
s = gst_caps_get_structure (caps, 0);
|
||||||
|
if (!gst_structure_get_int (s, "clock-rate", &rate)) {
|
||||||
|
GST_ERROR_OBJECT (depayload, "Missing 'clock-rate' in caps");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
src_caps = gst_caps_new_simple ("audio/isac",
|
||||||
|
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, rate, NULL);
|
||||||
|
|
||||||
|
ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), src_caps);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (depayload,
|
||||||
|
"set caps on source: %" GST_PTR_FORMAT " (ret=%d)", src_caps, ret);
|
||||||
|
gst_caps_unref (src_caps);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstBuffer *
|
||||||
|
gst_rtp_isac_depay_process (GstRTPBaseDepayload * depayload,
|
||||||
|
GstRTPBuffer * rtp_buffer)
|
||||||
|
{
|
||||||
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
|
outbuf = gst_rtp_buffer_get_payload_buffer (rtp_buffer);
|
||||||
|
|
||||||
|
gst_rtp_drop_non_audio_meta (depayload, outbuf);
|
||||||
|
|
||||||
|
return outbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_rtp_isac_depay_class_init (GstRtpIsacDepayClass * klass)
|
||||||
|
{
|
||||||
|
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||||
|
GstRTPBaseDepayloadClass *depayload_class =
|
||||||
|
(GstRTPBaseDepayloadClass *) klass;
|
||||||
|
|
||||||
|
depayload_class->set_caps = gst_rtp_isac_depay_setcaps;
|
||||||
|
depayload_class->process_rtp_packet = gst_rtp_isac_depay_process;
|
||||||
|
|
||||||
|
gst_element_class_add_static_pad_template (gstelement_class,
|
||||||
|
&gst_rtp_isac_depay_sink_template);
|
||||||
|
gst_element_class_add_static_pad_template (gstelement_class,
|
||||||
|
&gst_rtp_isac_depay_src_template);
|
||||||
|
|
||||||
|
gst_element_class_set_static_metadata (gstelement_class,
|
||||||
|
"RTP iSAC depayloader", "Codec/Depayloader/Network/RTP",
|
||||||
|
"Extracts iSAC audio from RTP packets",
|
||||||
|
"Guillaume Desmottes <guillaume.desmottes@collabora.com>");
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (rtpisacdepay_debug, "rtpisacdepay", 0,
|
||||||
|
"iSAC RTP Depayloader");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_rtp_isac_depay_init (GstRtpIsacDepay * rtpisacdepay)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gst_rtp_isac_depay_plugin_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
return gst_element_register (plugin, "rtpisacdepay",
|
||||||
|
GST_RANK_SECONDARY, GST_TYPE_RTP_ISAC_DEPAY);
|
||||||
|
}
|
33
gst/rtp/gstrtpisacdepay.h
Normal file
33
gst/rtp/gstrtpisacdepay.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2020 Collabora Ltd.
|
||||||
|
* Author: Guillaume Desmottes <guillaume.desmottes@collabora.com>, Collabora Ltd.
|
||||||
|
*
|
||||||
|
* 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_ISAC_DEPAY_H__
|
||||||
|
#define __GST_RTP_ISAC_DEPAY_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/rtp/gstrtpbasedepayload.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_TYPE_RTP_ISAC_DEPAY gst_rtp_isac_depay_get_type ()
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GstRtpIsacDepay, gst_rtp_isac_depay, GST, RTP_ISAC_DEPAY,
|
||||||
|
GstRTPBaseDepayload);
|
||||||
|
|
||||||
|
gboolean gst_rtp_isac_depay_plugin_init (GstPlugin * plugin);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
#endif /* __GST_RTP_ISAC_DEPAY_H__ */
|
|
@ -102,6 +102,7 @@ rtp_sources = [
|
||||||
'rtpstorage.c',
|
'rtpstorage.c',
|
||||||
'rtpstoragestream.c',
|
'rtpstoragestream.c',
|
||||||
'gstrtpstorage.c',
|
'gstrtpstorage.c',
|
||||||
|
'gstrtpisacdepay.c',
|
||||||
'gstrtpisacpay.c',
|
'gstrtpisacpay.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue