3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 02111-1307, USA.
23 #include "gstrtpg729pay.h"
24 #include <gst/rtp/gstrtpbuffer.h>
26 /* elementfactory information */
27 static GstElementDetails gst_rtpg729pay_details = {
28 "RTP Payloader for G729 Audio",
29 "Codec/Payloader/Network",
30 "Packetize G729 audio streams into RTP packets",
31 "Laurent Glayal <spglegle@yahoo.fr>"
34 GST_DEBUG_CATEGORY_STATIC (rtpg729pay_debug);
35 #define GST_CAT_DEFAULT (rtpg729pay_debug)
37 static GstStaticPadTemplate gst_rtpg729pay_sink_template =
38 GST_STATIC_PAD_TEMPLATE ("sink",
41 GST_STATIC_CAPS ("audio/G729, channels=(int)1, rate=(int)8000")
44 static GstStaticPadTemplate gst_rtpg729pay_src_template =
45 GST_STATIC_PAD_TEMPLATE ("src",
48 GST_STATIC_CAPS ("application/x-rtp, "
49 "media = (string) \"audio\", "
50 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
51 "clock-rate = (int) 8000, " "encoding-name = (string) \"G729\";"
53 "media = (string) \"audio\", "
54 "payload = (int) " GST_RTP_PAYLOAD_G729_STRING ", "
55 "clock-rate = (int) 8000")
58 static gboolean gst_rtpg729pay_setcaps (GstBaseRTPPayload * payload,
61 GST_BOILERPLATE (GstRtpG729Pay, gst_rtpg729pay, GstBaseRTPAudioPayload,
62 GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
65 gst_rtpg729pay_base_init (gpointer klass)
67 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
69 gst_element_class_add_pad_template (element_class,
70 gst_static_pad_template_get (&gst_rtpg729pay_sink_template));
71 gst_element_class_add_pad_template (element_class,
72 gst_static_pad_template_get (&gst_rtpg729pay_src_template));
73 gst_element_class_set_details (element_class, &gst_rtpg729pay_details);
77 gst_rtpg729pay_class_init (GstRtpG729PayClass * klass)
79 GObjectClass *gobject_class;
80 GstElementClass *gstelement_class;
81 GstBaseRTPPayloadClass *gstbasertppayload_class;
83 gobject_class = (GObjectClass *) klass;
84 gstelement_class = (GstElementClass *) klass;
85 gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
87 parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
89 gstbasertppayload_class->set_caps = gst_rtpg729pay_setcaps;
91 GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
92 "G729 audio RTP payloader");
96 gst_rtpg729pay_init (GstRtpG729Pay * rtpg729pay, GstRtpG729PayClass * klass)
98 GstBaseRTPPayload *basertppayload;
99 GstBaseRTPAudioPayload *basertpaudiopayload;
101 basertppayload = GST_BASE_RTP_PAYLOAD (rtpg729pay);
102 basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtpg729pay);
104 /* we don't set the payload type, it should be set by the application using
105 * the pt property or the default 96 will be used */
106 basertppayload->clock_rate = 8000;
108 /* tell basertpaudiopayload that this is a frame based codec */
109 gst_base_rtp_audio_payload_set_frame_based (basertpaudiopayload);
110 gst_basertppayload_set_options (basertppayload, "audio", FALSE, "G729", 8000);
111 gst_base_rtp_audio_payload_set_frame_options (basertpaudiopayload, 10, 10);
115 gst_rtpg729pay_setcaps (GstBaseRTPPayload * basertppayload, GstCaps * caps)
117 GstRtpG729Pay *rtpg729pay;
118 GstBaseRTPAudioPayload *basertpaudiopayload;
120 GstStructure *structure;
121 const char *payload_name;
123 rtpg729pay = GST_RTP_G729_PAY (basertppayload);
124 basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basertppayload);
126 structure = gst_caps_get_structure (caps, 0);
128 payload_name = gst_structure_get_name (structure);
129 if (g_strcasecmp ("audio/G729", payload_name) != 0)
132 ret = gst_basertppayload_set_outcaps (basertppayload, NULL);
139 GST_ERROR_OBJECT (rtpg729pay, "wrong name, expected 'audio/G729', got '%s'",
146 gst_rtp_g729_pay_plugin_init (GstPlugin * plugin)
148 return gst_element_register (plugin, "rtpg729pay",
149 GST_RANK_NONE, GST_TYPE_RTP_G729_PAY);