Commit fc158bc3 authored by Wim Taymans's avatar Wim Taymans

Updates to payloader/depayloaders, make payloaders use the base classes.

Original commit message from CVS:
Updates to payloader/depayloaders, make payloaders use
the base classes.
Updated README with suggested RTP caps and how to convert
to/from SDP.
Added config descriptor in mp4v payloader.
parent c7468729
2005-09-15 Wim Taymans <wim@fluendo.com>
* gst/rtp/Makefile.am:
* gst/rtp/README:
* gst/rtp/gstrtp.c: (plugin_init):
* gst/rtp/gstrtpamrdec.c: (gst_rtpamrdec_init),
(gst_rtpamrdec_sink_setcaps), (gst_rtpamrdec_chain),
(gst_rtpamrdec_change_state):
* gst/rtp/gstrtpamrenc.c: (gst_rtpamrenc_get_type),
(gst_rtpamrenc_class_init), (gst_rtpamrenc_init),
(gst_rtpamrenc_setcaps), (gst_rtpamrenc_handle_buffer):
* gst/rtp/gstrtpamrenc.h:
* gst/rtp/gstrtpgsmenc.c: (gst_rtpgsmenc_get_type),
(gst_rtpgsmenc_class_init), (gst_rtpgsmenc_init),
(gst_rtpgsmenc_setcaps), (gst_rtpgsmenc_handle_buffer):
* gst/rtp/gstrtpgsmenc.h:
* gst/rtp/gstrtpgsmparse.c: (gst_rtpgsmparse_class_init),
(gst_rtpgsm_caps_nego), (gst_rtpgsmparse_chain),
(gst_rtpgsmparse_set_property), (gst_rtpgsmparse_get_property),
(gst_rtpgsmparse_change_state):
* gst/rtp/gstrtpgsmparse.h:
* gst/rtp/gstrtph263pdec.c: (gst_rtph263pdec_class_init),
(gst_rtph263pdec_finalize), (gst_rtph263pdec_change_state):
* gst/rtp/gstrtph263penc.c: (gst_rtph263penc_get_type),
(gst_rtph263penc_class_init), (gst_rtph263penc_init),
(gst_rtph263penc_finalize), (gst_rtph263penc_setcaps),
(gst_rtph263penc_flush), (gst_rtph263penc_handle_buffer):
* gst/rtp/gstrtph263penc.h:
* gst/rtp/gstrtpmp4vdec.c: (gst_rtpmp4vdec_setcaps),
(gst_rtpmp4vdec_chain), (gst_rtpmp4vdec_change_state):
* gst/rtp/gstrtpmp4venc.c: (gst_rtpmp4venc_get_type),
(gst_rtpmp4venc_class_init), (gst_rtpmp4venc_init),
(gst_rtpmp4venc_finalize), (gst_rtpmp4venc_new_caps),
(gst_rtpmp4venc_setcaps), (gst_rtpmp4venc_flush),
(gst_rtpmp4venc_parse_data), (gst_rtpmp4venc_handle_buffer):
* gst/rtp/gstrtpmp4venc.h:
* gst/rtp/gstrtpmpadec.c:
* gst/rtp/gstrtpmpaenc.c: (gst_rtpmpaenc_get_type),
(gst_rtpmpaenc_class_init), (gst_rtpmpaenc_init),
(gst_rtpmpaenc_finalize), (gst_rtpmpaenc_setcaps),
(gst_rtpmpaenc_flush), (gst_rtpmpaenc_handle_buffer):
* gst/rtp/gstrtpmpaenc.h:
Updates to payloader/depayloaders, make payloaders use
the base classes.
Updated README with suggested RTP caps and how to convert
to/from SDP.
Added config descriptor in mp4v payloader.
2005-09-15 Andy Wingo <wingo@pobox.com>
* gst/autodetect/gstautoaudiosink.c (gst_auto_audio_sink_find_best):
......
common @ 9a5025a2
Subproject commit 97fbc2dd78ea0cc2225b63ff383802b7c376d9b7
Subproject commit 9a5025a2d276796d8d21243ef598e679ff7477bc
......@@ -4,6 +4,8 @@ libgstrtp_la_SOURCES = gstrtp.c \
gstrtpdec.c \
gstrtpmpadec.c \
gstrtpmpaenc.c \
gstrtpgsmenc.c \
gstrtpgsmparse.c \
gstrtpamrdec.c \
gstrtpamrenc.c \
gstrtph263pdec.c \
......
The application/x-rtp mime type
-------------------------------
For valid RTP packets encapsulated in GstBuffers, we use the caps with
mime type application/x-rtp.
The following fields can or must (*) be specified in the structure:
* media: (String) [ "audio", "video", "application", "data", "control" ]
Defined in RFC 2327 in the SDP media announcement field.
* payload: (int) [0, 255]
For audio and video, these will normally be a media payload type as
defined in the RTP Audio/Video Profile. For dynamicaly allocated
payload types, this value will be >= 96 and the encoding_name must be
set.
* clock_rate: (int) [0 - MAXINT]
the RTP clock rate
ssrc: (uint) [0 - MAXINT]
The ssrc value currently in use.
clock_base: (uint) [0 - MAXINT]
The RTP time representing time 0
seqnum_base:
The RTP sequence number representing the first rtp packet
encoding_name: (String) ANY
typically second part of the mime type. ex. MP4V-ES. only required if
payload type >= 96
encoding_params: (String) ANY
extra encoding parameters (as in the SDP a=rtpmap: field). only required
if different from the default of the encoding_name.
Optional parameters as key/value pairs, media type specific.
Example:
"application/x-rtp",
"media", G_TYPE_STRING, "audio", -]
"payload", G_TYPE_INT, 96, ] - required
"clock_rate", G_TYPE_INT, 8000, -]
"encoding_name", G_TYPE_STRING, "AMR", -] - required since payload >= 96
"encoding_params", G_TYPE_STRING, "1", -] - optional param for AMR
"octet-align", G_TYPE_BOOLEAN, TRUE, -]
"crc", G_TYPE_BOOLEAN, FALSE, ]
"robust-sorting", G_TYPE_BOOLEAN, FALSE, ] AMR specific params.
"interleaving", G_TYPE_BOOLEAN, FALSE, -]
Mapping of caps to and from SDP fields:
m=<media> <udp port> RTP/AVP <payload> -] media and payload from caps
a=rtpmap:<payload> <encoding_name>/<clock_rate>[/<encoding_params>]
-> when <payload> >= 96
a=fmtp:<payload> <param>=<value>;...
For above caps:
m=audio <udp port> RTP/AVP 96
a=rtpmap:96 AMR/8000/1
a=fmtp:96 octet-align=1;crc=0;robust-sorting=0;interleaving=0
in RTSP, the SSRC is also sent.
TODO
----
......
......@@ -22,6 +22,8 @@
#endif
#include "gstrtpdec.h"
#include "gstrtpgsmenc.h"
#include "gstrtpgsmparse.h"
#include "gstrtpamrenc.h"
#include "gstrtpamrdec.h"
#include "gstrtpmpaenc.h"
......@@ -37,6 +39,12 @@ plugin_init (GstPlugin * plugin)
if (!gst_rtpdec_plugin_init (plugin))
return FALSE;
if (!gst_rtpgsmparse_plugin_init (plugin))
return FALSE;
if (!gst_rtpgsmenc_plugin_init (plugin))
return FALSE;
if (!gst_rtpamrdec_plugin_init (plugin))
return FALSE;
......
......@@ -32,7 +32,7 @@
static GstElementDetails gst_rtp_amrdec_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Extracts MPEG audio from RTP packets",
"Extracts AMR audio from RTP packets (RFC 3267)",
"Wim Taymans <wim@fluendo.com>"
};
......@@ -58,11 +58,14 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
"payload = (int) [ 96, 255 ], "
"clock_rate = (int) 8000, "
"encoding_name = (string) \"AMR\", "
"encoding_params = (string) \"1\", "
"octet-align = (boolean) TRUE, "
"crc = (boolean) FALSE, "
"robust-sorting = (boolean) FALSE, "
"interleaving = (boolean) FALSE, "
"channels = (int) 1, " "rate = (int) 8000"
"robust-sorting = (boolean) FALSE, " "interleaving = (boolean) FALSE"
/* following options are not needed for a decoder
*
"mode-set = (int) [ 0, 7 ], "
......@@ -156,18 +159,10 @@ gst_rtpamrdec_class_init (GstRtpAMRDecClass * klass)
static void
gst_rtpamrdec_init (GstRtpAMRDec * rtpamrdec)
{
GstCaps *srccaps;
rtpamrdec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rtpamrdec_src_template), "src");
/* FIXME */
srccaps = gst_caps_new_simple ("audio/AMR",
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
gst_pad_set_caps (rtpamrdec->srcpad, srccaps);
gst_caps_unref (srccaps);
gst_element_add_pad (GST_ELEMENT (rtpamrdec), rtpamrdec->srcpad);
rtpamrdec->sinkpad =
......@@ -184,6 +179,7 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
GstCaps *srccaps;
GstRtpAMRDec *rtpamrdec;
const gchar *params;
rtpamrdec = GST_RTP_AMR_DEC (GST_OBJECT_PARENT (pad));
......@@ -193,10 +189,6 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
&rtpamrdec->octet_align))
rtpamrdec->octet_align = FALSE;
/* FIXME, force octect align for now until all elements negotiate
* correctly*/
rtpamrdec->octet_align = TRUE;
if (!gst_structure_get_boolean (structure, "crc", &rtpamrdec->crc))
rtpamrdec->crc = FALSE;
......@@ -223,9 +215,13 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
rtpamrdec->octet_align = TRUE;
}
if (!gst_structure_get_int (structure, "channels", &rtpamrdec->channels))
if (!(params = gst_structure_get_string (structure, "encoding_params")))
rtpamrdec->channels = 1;
if (!gst_structure_get_int (structure, "rate", &rtpamrdec->rate))
else {
rtpamrdec->channels = atoi (params);
}
if (!gst_structure_get_int (structure, "clock_rate", &rtpamrdec->rate))
rtpamrdec->rate = 8000;
/* we require 1 channel, 8000 Hz, octet aligned, no CRC,
......@@ -288,7 +284,7 @@ gst_rtpamrdec_chain (GstPad * pad, GstBuffer * buf)
/* parse header
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+..
* | CMR=6 |R|R|R|R|0|FT#1=5 |Q|P|P|
* | CMR |R|R|R|R|F| FT |Q|P|P|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+..
*/
CMR = (payload[0] & 0xf0) >> 4;
......@@ -314,7 +310,7 @@ gst_rtpamrdec_chain (GstPad * pad, GstBuffer * buf)
outbuf = gst_buffer_new_and_alloc (payload_len);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp * GST_SECOND / 8000;
GST_BUFFER_TIMESTAMP (outbuf) = timestamp * GST_SECOND / rtpamrdec->rate;
memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
......@@ -392,9 +388,6 @@ gst_rtpamrdec_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
/* FIXME, don't require negotiation until all elements
* do */
rtpamrdec->negotiated = TRUE;
break;
default:
break;
......
......@@ -32,7 +32,7 @@
static GstElementDetails gst_rtp_amrdec_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Extracts MPEG audio from RTP packets",
"Extracts AMR audio from RTP packets (RFC 3267)",
"Wim Taymans <wim@fluendo.com>"
};
......@@ -58,11 +58,14 @@ GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
"payload = (int) [ 96, 255 ], "
"clock_rate = (int) 8000, "
"encoding_name = (string) \"AMR\", "
"encoding_params = (string) \"1\", "
"octet-align = (boolean) TRUE, "
"crc = (boolean) FALSE, "
"robust-sorting = (boolean) FALSE, "
"interleaving = (boolean) FALSE, "
"channels = (int) 1, " "rate = (int) 8000"
"robust-sorting = (boolean) FALSE, " "interleaving = (boolean) FALSE"
/* following options are not needed for a decoder
*
"mode-set = (int) [ 0, 7 ], "
......@@ -156,18 +159,10 @@ gst_rtpamrdec_class_init (GstRtpAMRDecClass * klass)
static void
gst_rtpamrdec_init (GstRtpAMRDec * rtpamrdec)
{
GstCaps *srccaps;
rtpamrdec->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rtpamrdec_src_template), "src");
/* FIXME */
srccaps = gst_caps_new_simple ("audio/AMR",
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
gst_pad_set_caps (rtpamrdec->srcpad, srccaps);
gst_caps_unref (srccaps);
gst_element_add_pad (GST_ELEMENT (rtpamrdec), rtpamrdec->srcpad);
rtpamrdec->sinkpad =
......@@ -184,6 +179,7 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
GstCaps *srccaps;
GstRtpAMRDec *rtpamrdec;
const gchar *params;
rtpamrdec = GST_RTP_AMR_DEC (GST_OBJECT_PARENT (pad));
......@@ -193,10 +189,6 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
&rtpamrdec->octet_align))
rtpamrdec->octet_align = FALSE;
/* FIXME, force octect align for now until all elements negotiate
* correctly*/
rtpamrdec->octet_align = TRUE;
if (!gst_structure_get_boolean (structure, "crc", &rtpamrdec->crc))
rtpamrdec->crc = FALSE;
......@@ -223,9 +215,13 @@ gst_rtpamrdec_sink_setcaps (GstPad * pad, GstCaps * caps)
rtpamrdec->octet_align = TRUE;
}
if (!gst_structure_get_int (structure, "channels", &rtpamrdec->channels))
if (!(params = gst_structure_get_string (structure, "encoding_params")))
rtpamrdec->channels = 1;
if (!gst_structure_get_int (structure, "rate", &rtpamrdec->rate))
else {
rtpamrdec->channels = atoi (params);
}
if (!gst_structure_get_int (structure, "clock_rate", &rtpamrdec->rate))
rtpamrdec->rate = 8000;
/* we require 1 channel, 8000 Hz, octet aligned, no CRC,
......@@ -288,7 +284,7 @@ gst_rtpamrdec_chain (GstPad * pad, GstBuffer * buf)
/* parse header
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+..
* | CMR=6 |R|R|R|R|0|FT#1=5 |Q|P|P|
* | CMR |R|R|R|R|F| FT |Q|P|P|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+..
*/
CMR = (payload[0] & 0xf0) >> 4;
......@@ -314,7 +310,7 @@ gst_rtpamrdec_chain (GstPad * pad, GstBuffer * buf)
outbuf = gst_buffer_new_and_alloc (payload_len);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp * GST_SECOND / 8000;
GST_BUFFER_TIMESTAMP (outbuf) = timestamp * GST_SECOND / rtpamrdec->rate;
memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
......@@ -392,9 +388,6 @@ gst_rtpamrdec_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
/* FIXME, don't require negotiation until all elements
* do */
rtpamrdec->negotiated = TRUE;
break;
default:
break;
......
......@@ -33,29 +33,10 @@
static GstElementDetails gst_rtp_amrenc_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Encode AMR audio into RTP packets",
"Encode AMR audio into RTP packets (RFC 3267)",
"Wim Taymans <wim@fluendo.com>"
};
/* RtpAMREnc signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
#define DEFAULT_MTU 1024
#define DEFAULT_PT 96
#define DEFAULT_SSRC 0
enum
{
PROP_0,
PROP_MTU,
PROP_PT,
PROP_SSRC
};
static GstStaticPadTemplate gst_rtpamrenc_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
......@@ -68,34 +49,31 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
"payload = (int) [ 96, 255 ], "
"clock_rate = (int) 8000, "
"encoding_name = (string) \"AMR\", "
"encoding_params = (string) \"1\", "
"octet-align = (boolean) TRUE, "
"crc = (boolean) FALSE, "
"robust-sorting = (boolean) FALSE, "
"interleaving = (boolean) FALSE, "
"channels = (int) 1, "
"rate = (int) 8000, "
"mode-set = (int) [ 0, 7 ], "
"mode-change-period = (int) [ 1, MAX ], "
"mode-change-neighbor = (boolean) { TRUE, FALSE }, "
"maxptime = (int) [ 20, MAX ], " "ptime = (int) [ 20, MAX ]")
);
static void gst_rtpamrenc_class_init (GstRtpAMREncClass * klass);
static void gst_rtpamrenc_base_init (GstRtpAMREncClass * klass);
static void gst_rtpamrenc_init (GstRtpAMREnc * rtpamrenc);
static GstFlowReturn gst_rtpamrenc_chain (GstPad * pad, GstBuffer * buffer);
static void gst_rtpamrenc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_rtpamrenc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_rtpamrenc_setcaps (GstBaseRTPPayload * basepayload,
GstCaps * caps);
static GstFlowReturn gst_rtpamrenc_handle_buffer (GstBaseRTPPayload * pad,
GstBuffer * buffer);
static GstStateChangeReturn gst_rtpamrenc_change_state (GstElement * element,
GstStateChange transition);
static GstElementClass *parent_class = NULL;
static GstBaseRTPPayloadClass *parent_class = NULL;
static GType
gst_rtpamrenc_get_type (void)
......@@ -116,7 +94,7 @@ gst_rtpamrenc_get_type (void)
};
rtpamrenc_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstRtpAMREnc",
g_type_register_static (GST_TYPE_BASE_RTP_PAYLOAD, "GstRtpAMREnc",
&rtpamrenc_info, 0);
}
return rtpamrenc_type;
......@@ -140,64 +118,44 @@ gst_rtpamrenc_class_init (GstRtpAMREncClass * 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);
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_rtpamrenc_set_property;
gobject_class->get_property = gst_rtpamrenc_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MTU,
g_param_spec_uint ("mtu", "MTU",
"Maximum size of one packet",
28, G_MAXUINT, DEFAULT_MTU, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PT,
g_param_spec_uint ("pt", "payload type",
"The payload type of the packets",
0, 0x80, DEFAULT_PT, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SSRC,
g_param_spec_uint ("ssrc", "SSRC",
"The SSRC of the packets",
0, G_MAXUINT, DEFAULT_SSRC, G_PARAM_READWRITE));
gstelement_class->change_state = gst_rtpamrenc_change_state;
gstbasertppayload_class->set_caps = gst_rtpamrenc_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtpamrenc_handle_buffer;
}
static void
gst_rtpamrenc_init (GstRtpAMREnc * rtpamrenc)
{
GstCaps *caps;
}
rtpamrenc->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rtpamrenc_src_template), "src");
static gboolean
gst_rtpamrenc_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
{
GstRtpAMREnc *rtpamrenc;
caps = gst_caps_new_simple ("application/x-rtp",
rtpamrenc = GST_RTP_AMR_ENC (basepayload);
gst_basertppayload_set_options (basepayload, "audio", TRUE, "AMR", 8000);
gst_basertppayload_set_outcaps (basepayload,
"encoding_params", G_TYPE_STRING, "1",
"octet-align", G_TYPE_BOOLEAN, TRUE,
"crc", G_TYPE_BOOLEAN, FALSE,
"robust-sorting", G_TYPE_BOOLEAN, FALSE,
"interleaving", G_TYPE_BOOLEAN, FALSE,
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
gst_pad_set_caps (rtpamrenc->srcpad, caps);
gst_caps_unref (caps);
gst_element_add_pad (GST_ELEMENT (rtpamrenc), rtpamrenc->srcpad);
rtpamrenc->sinkpad =
gst_pad_new_from_template (gst_static_pad_template_get
(&gst_rtpamrenc_sink_template), "sink");
gst_pad_set_chain_function (rtpamrenc->sinkpad, gst_rtpamrenc_chain);
gst_element_add_pad (GST_ELEMENT (rtpamrenc), rtpamrenc->sinkpad);
rtpamrenc->mtu = DEFAULT_MTU;
rtpamrenc->pt = DEFAULT_PT;
rtpamrenc->ssrc = DEFAULT_SSRC;
"interleaving", G_TYPE_BOOLEAN, FALSE, NULL);
return TRUE;
}
static GstFlowReturn
gst_rtpamrenc_chain (GstPad * pad, GstBuffer * buffer)
gst_rtpamrenc_handle_buffer (GstBaseRTPPayload * basepayload,
GstBuffer * buffer)
{
GstRtpAMREnc *rtpamrenc;
GstFlowReturn ret;
......@@ -206,7 +164,7 @@ gst_rtpamrenc_chain (GstPad * pad, GstBuffer * buffer)
guint8 *payload, *data;
GstClockTime timestamp;
rtpamrenc = GST_RTP_AMR_ENC (gst_pad_get_parent (pad));
rtpamrenc = GST_RTP_AMR_ENC (basepayload);
size = GST_BUFFER_SIZE (buffer);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
......@@ -221,12 +179,7 @@ gst_rtpamrenc_chain (GstPad * pad, GstBuffer * buffer)
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
g_assert (GST_BUFFER_SIZE (outbuf) < rtpamrenc->mtu);
gst_rtpbuffer_set_payload_type (outbuf, rtpamrenc->pt);
gst_rtpbuffer_set_ssrc (outbuf, rtpamrenc->ssrc);
gst_rtpbuffer_set_seq (outbuf, rtpamrenc->seqnum++);
gst_rtpbuffer_set_timestamp (outbuf, timestamp * 8000 / GST_SECOND);
g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpamrenc));
/* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
......@@ -256,89 +209,8 @@ gst_rtpamrenc_chain (GstPad * pad, GstBuffer * buffer)
gst_buffer_unref (buffer);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (rtpamrenc->srcpad));
ret = gst_pad_push (rtpamrenc->srcpad, outbuf);
gst_object_unref (rtpamrenc);
return ret;
}
static void
gst_rtpamrenc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstRtpAMREnc *rtpamrenc;
ret = gst_basertppayload_push (basepayload, outbuf);
rtpamrenc = GST_RTP_AMR_ENC (object);
switch (prop_id) {
case PROP_MTU:
rtpamrenc->mtu = g_value_get_uint (value);
break;
case PROP_PT:
rtpamrenc->pt = g_value_get_uint (value);
break;
case PROP_SSRC:
rtpamrenc->ssrc = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_rtpamrenc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstRtpAMREnc *rtpamrenc;
rtpamrenc = GST_RTP_AMR_ENC (object);
switch (prop_id) {
case PROP_MTU:
g_value_set_uint (value, rtpamrenc->mtu);
break;
case PROP_PT:
g_value_set_uint (value, rtpamrenc->pt);
break;
case PROP_SSRC:
g_value_set_uint (value, rtpamrenc->ssrc);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstStateChangeReturn
gst_rtpamrenc_change_state (GstElement * element, GstStateChange transition)
{
GstRtpAMREnc *rtpamrenc;
GstStateChangeReturn ret;
rtpamrenc = GST_RTP_AMR_ENC (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
rtpamrenc->seqnum = 0;
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
}
......
......@@ -21,6 +21,7 @@
#define __GST_RTP_AMR_ENC_H__
#include <gst/gst.h>
#include <gst/rtp/gstbasertppayload.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
......@@ -41,21 +42,12 @@ typedef struct _GstRtpAMREncClass GstRtpAMREncClass;
struct _GstRtpAMREnc
{
GstElement element;
GstPad *sinkpad;
GstPad *srcpad;
guint16 seqnum;
guint pt;
guint ssrc;
guint mtu;
GstBaseRTPPayload payload;
};
struct _GstRtpAMREncClass
{
GstElementClass parent_class;
GstBaseRTPPayloadClass parent_class;
};
gboolean gst_rtpamrenc_plugin_init (GstPlugin * plugin);
......
......@@ -33,29 +33,10 @@
static GstElementDetails gst_rtp_amrenc_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Encode AMR audio into RTP packets",
"Encode AMR audio into RTP packets (RFC 3267)",
"Wim Taymans <wim@fluendo.com>"
};
/* RtpAMREnc signals and args */
enum
{
/* FILL ME */
LAST_SIGNAL
};
#define DEFAULT_MTU 1024
#define DEFAULT_PT 96
#define DEFAULT_SSRC 0
enum
{
PROP_0,
PROP_MTU,
PROP_PT,
PROP_SSRC
};
static GstStaticPadTemplate gst_rtpamrenc_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
......@@ -68,34 +49,31 @@ GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"audio\", "
"payload = (int) [ 96, 255 ], "
"clock_rate = (int) 8000, "
"encoding_name = (string) \"AMR\", "
"encoding_params = (string) \"1\", "
"octet-align = (boolean) TRUE, "
"crc = (boolean) FALSE, "
"robust-sorting = (boolean) FALSE, "
"interleaving = (boolean) FALSE, "
"channels = (int) 1, "
"rate = (int) 8000, "
"mode-set = (int) [ 0, 7 ], "
"mode-change-period = (int) [ 1, MAX ], "
"mode-change-neighbor = (boolean) { TRUE, FALSE }, "
"maxptime = (int) [ 20, MAX ], " "ptime = (int) [ 20, MAX ]")
);
static void gst_rtpamrenc_class_init (GstRtpAMREncClass * klass);
static void gst_rtpamrenc_base_init (GstRtpAMREncClass * klass);
static void gst_rtpamrenc_init (GstRtpAMREnc * rtpamrenc);
static GstFlowReturn gst_rtpamrenc_chain (GstPad * pad, GstBuffer * buffer);
static void gst_rtpamrenc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_rtpamrenc_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_rtpamrenc_setcaps (GstBaseRTPPayload * basepayload,
GstCaps * caps);
static GstFlowReturn gst_rtpamrenc_handle_buffer (GstBaseRTPPayload * pad,
GstBuffer * buffer);
static GstStateChangeReturn gst_rtpamrenc_change_state (GstElement * element,
GstStateChange transition);