2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2005> Edgard Lima <edgard.lima@gmail.com>
4 * Copyright (C) <2005> Nokia Corporation <kai.vehmanen@nokia.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
28 #include <gst/rtp/gstrtpbuffer.h>
30 #include "gstrtppcmupay.h"
32 static GstStaticPadTemplate gst_rtp_pcmu_pay_sink_template =
33 GST_STATIC_PAD_TEMPLATE ("sink",
36 GST_STATIC_CAPS ("audio/x-mulaw, channels=(int)1, rate=(int)8000")
39 static GstStaticPadTemplate gst_rtp_pcmu_pay_src_template =
40 GST_STATIC_PAD_TEMPLATE ("src",
43 GST_STATIC_CAPS ("application/x-rtp, "
44 "media = (string) \"audio\", "
45 "payload = (int) " GST_RTP_PAYLOAD_PCMU_STRING ", "
46 "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMU\"; "
48 "media = (string) \"audio\", "
49 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
50 "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"PCMU\"")
53 static gboolean gst_rtp_pcmu_pay_setcaps (GstRTPBasePayload * payload,
56 #define gst_rtp_pcmu_pay_parent_class parent_class
57 G_DEFINE_TYPE (GstRtpPcmuPay, gst_rtp_pcmu_pay,
58 GST_TYPE_RTP_BASE_AUDIO_PAYLOAD);
61 gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
63 GstElementClass *gstelement_class;
64 GstRTPBasePayloadClass *gstrtpbasepayload_class;
66 gstelement_class = (GstElementClass *) klass;
67 gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
69 gst_element_class_add_static_pad_template (gstelement_class,
70 &gst_rtp_pcmu_pay_sink_template);
71 gst_element_class_add_static_pad_template (gstelement_class,
72 &gst_rtp_pcmu_pay_src_template);
74 gst_element_class_set_static_metadata (gstelement_class, "RTP PCMU payloader",
75 "Codec/Payloader/Network/RTP",
76 "Payload-encodes PCMU audio into a RTP packet",
77 "Edgard Lima <edgard.lima@gmail.com>");
79 gstrtpbasepayload_class->set_caps = gst_rtp_pcmu_pay_setcaps;
83 gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay)
85 GstRTPBaseAudioPayload *rtpbaseaudiopayload;
87 rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtppcmupay);
89 GST_RTP_BASE_PAYLOAD (rtppcmupay)->pt = GST_RTP_PAYLOAD_PCMU;
90 GST_RTP_BASE_PAYLOAD (rtppcmupay)->clock_rate = 8000;
92 /* tell rtpbaseaudiopayload that this is a sample based codec */
93 gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
95 /* octet-per-sample is 1 for PCM */
96 gst_rtp_base_audio_payload_set_sample_options (rtpbaseaudiopayload, 1);
100 gst_rtp_pcmu_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
104 gst_rtp_base_payload_set_options (payload, "audio",
105 payload->pt != GST_RTP_PAYLOAD_PCMU, "PCMU", 8000);
106 res = gst_rtp_base_payload_set_outcaps (payload, NULL);
112 gst_rtp_pcmu_pay_plugin_init (GstPlugin * plugin)
114 return gst_element_register (plugin, "rtppcmupay",
115 GST_RANK_SECONDARY, GST_TYPE_RTP_PCMU_PAY);