Remove unused variables in _class_init
[platform/upstream/gstreamer.git] / gst / rtp / gstrtppcmapay.c
1 /* GStreamer
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>
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #  include "config.h"
24 #endif
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <gst/rtp/gstrtpbuffer.h>
29
30 #include "gstrtppcmapay.h"
31
32 /* elementfactory information */
33 static const GstElementDetails gst_rtp_pcma_pay_details =
34 GST_ELEMENT_DETAILS ("RTP PCMA payloader",
35     "Codec/Payloader/Network",
36     "Payload-encodes PCMA audio into a RTP packet",
37     "Edgard Lima <edgard.lima@indt.org.br>");
38
39 static GstStaticPadTemplate gst_rtp_pcma_pay_sink_template =
40 GST_STATIC_PAD_TEMPLATE ("sink",
41     GST_PAD_SINK,
42     GST_PAD_ALWAYS,
43     GST_STATIC_CAPS ("audio/x-alaw, channels=(int)1, rate=(int)8000")
44     );
45
46 static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
47     GST_STATIC_PAD_TEMPLATE ("src",
48     GST_PAD_SRC,
49     GST_PAD_ALWAYS,
50     GST_STATIC_CAPS ("application/x-rtp, "
51         "media = (string) \"audio\", "
52         "payload = (int) " GST_RTP_PAYLOAD_PCMA_STRING ", "
53         "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"; "
54         "application/x-rtp, "
55         "media = (string) \"audio\", "
56         "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
57         "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
58     );
59
60 static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload,
61     GstCaps * caps);
62
63 GST_BOILERPLATE (GstRtpPmcaPay, gst_rtp_pcma_pay, GstBaseRTPAudioPayload,
64     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
65
66 static void
67 gst_rtp_pcma_pay_base_init (gpointer klass)
68 {
69   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
70
71   gst_element_class_add_pad_template (element_class,
72       gst_static_pad_template_get (&gst_rtp_pcma_pay_sink_template));
73   gst_element_class_add_pad_template (element_class,
74       gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
75   gst_element_class_set_details (element_class, &gst_rtp_pcma_pay_details);
76 }
77
78 static void
79 gst_rtp_pcma_pay_class_init (GstRtpPmcaPayClass * klass)
80 {
81   GstBaseRTPPayloadClass *gstbasertppayload_class;
82
83   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
84
85   parent_class = g_type_class_peek_parent (klass);
86
87   gstbasertppayload_class->set_caps = gst_rtp_pcma_pay_setcaps;
88 }
89
90 static void
91 gst_rtp_pcma_pay_init (GstRtpPmcaPay * rtppcmapay, GstRtpPmcaPayClass * klass)
92 {
93   GstBaseRTPAudioPayload *basertpaudiopayload;
94
95   basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtppcmapay);
96
97   GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate = 8000;
98
99   /* tell basertpaudiopayload that this is a sample based codec */
100   gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
101
102   /* octet-per-sample is 1 for PCM */
103   gst_base_rtp_audio_payload_set_sample_options (basertpaudiopayload, 1);
104 }
105
106 static gboolean
107 gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
108 {
109   gboolean res;
110
111   payload->pt = GST_RTP_PAYLOAD_PCMA;
112
113   gst_basertppayload_set_options (payload, "audio", FALSE, "PCMA", 8000);
114   res = gst_basertppayload_set_outcaps (payload, NULL);
115
116   return res;
117 }
118
119 gboolean
120 gst_rtp_pcma_pay_plugin_init (GstPlugin * plugin)
121 {
122   return gst_element_register (plugin, "rtppcmapay",
123       GST_RANK_NONE, GST_TYPE_RTP_PCMA_PAY);
124 }