2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 #include <gst/rtp/gstrtpbuffer.h>
30 #include "gstrtppcmapay.h"
32 static GstStaticPadTemplate gst_rtp_pcma_pay_sink_template =
33 GST_STATIC_PAD_TEMPLATE ("sink",
36 GST_STATIC_CAPS ("audio/x-alaw, channels=(int)1, rate=(int)8000")
39 static GstStaticPadTemplate gst_rtp_pcma_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_PCMA_STRING ", "
46 "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"; "
48 "media = (string) \"audio\", "
49 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
50 "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"PCMA\"")
53 static gboolean gst_rtp_pcma_pay_setcaps (GstRTPBasePayload * payload,
56 #define gst_rtp_pcma_pay_parent_class parent_class
57 G_DEFINE_TYPE (GstRtpPcmaPay, gst_rtp_pcma_pay,
58 GST_TYPE_RTP_BASE_AUDIO_PAYLOAD);
61 gst_rtp_pcma_pay_class_init (GstRtpPcmaPayClass * klass)
63 GstElementClass *gstelement_class;
64 GstRTPBasePayloadClass *gstrtpbasepayload_class;
66 gstelement_class = (GstElementClass *) klass;
67 gstrtpbasepayload_class = (GstRTPBasePayloadClass *) klass;
69 gst_element_class_add_pad_template (gstelement_class,
70 gst_static_pad_template_get (&gst_rtp_pcma_pay_sink_template));
71 gst_element_class_add_pad_template (gstelement_class,
72 gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
74 gst_element_class_set_details_simple (gstelement_class, "RTP PCMA payloader",
75 "Codec/Payloader/Network/RTP",
76 "Payload-encodes PCMA audio into a RTP packet",
77 "Edgard Lima <edgard.lima@indt.org.br>");
79 gstrtpbasepayload_class->set_caps = gst_rtp_pcma_pay_setcaps;
83 gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay)
85 GstRTPBaseAudioPayload *rtpbaseaudiopayload;
87 rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtppcmapay);
89 GST_RTP_BASE_PAYLOAD (rtppcmapay)->clock_rate = 8000;
91 /* tell rtpbaseaudiopayload that this is a sample based codec */
92 gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
94 /* octet-per-sample is 1 for PCM */
95 gst_rtp_base_audio_payload_set_sample_options (rtpbaseaudiopayload, 1);
99 gst_rtp_pcma_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
103 payload->pt = GST_RTP_PAYLOAD_PCMA;
105 gst_rtp_base_payload_set_options (payload, "audio", FALSE, "PCMA", 8000);
106 res = gst_rtp_base_payload_set_outcaps (payload, NULL);
112 gst_rtp_pcma_pay_plugin_init (GstPlugin * plugin)
114 return gst_element_register (plugin, "rtppcmapay",
115 GST_RANK_SECONDARY, GST_TYPE_RTP_PCMA_PAY);