gst/rtp/: Fix the descriptions and fix some email addresses.
[platform/upstream/gstreamer.git] / gst / rtp / gstrtppcmupay.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 "gstrtppcmupay.h"
31
32 /* elementfactory information */
33 static const GstElementDetails gst_rtp_pcmu_pay_details =
34 GST_ELEMENT_DETAILS ("RTP PCMU payloader",
35     "Codec/Payloader/Network",
36     "Payload-encodes PCMU audio into a RTP packet",
37     "Edgard Lima <edgard.lima@indt.org.br>");
38
39 static GstStaticPadTemplate gst_rtp_pcmu_pay_sink_template =
40 GST_STATIC_PAD_TEMPLATE ("sink",
41     GST_PAD_SINK,
42     GST_PAD_ALWAYS,
43     GST_STATIC_CAPS ("audio/x-mulaw, channels=(int)1, rate=(int)8000")
44     );
45
46 static GstStaticPadTemplate gst_rtp_pcmu_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_PCMU_STRING ", "
53         "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMU\"; "
54         "application/x-rtp, "
55         "media = (string) \"audio\", "
56         "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
57         "clock-rate = (int) 8000, " "encoding-name = (string) \"PCMU\"")
58     );
59
60 static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload,
61     GstCaps * caps);
62
63 GST_BOILERPLATE (GstRtpPcmuPay, gst_rtp_pcmu_pay, GstBaseRTPAudioPayload,
64     GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
65
66 static void
67 gst_rtp_pcmu_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_pcmu_pay_sink_template));
73   gst_element_class_add_pad_template (element_class,
74       gst_static_pad_template_get (&gst_rtp_pcmu_pay_src_template));
75   gst_element_class_set_details (element_class, &gst_rtp_pcmu_pay_details);
76 }
77
78 static void
79 gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
80 {
81   GObjectClass *gobject_class;
82   GstElementClass *gstelement_class;
83   GstBaseRTPPayloadClass *gstbasertppayload_class;
84
85   gobject_class = (GObjectClass *) klass;
86   gstelement_class = (GstElementClass *) klass;
87   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
88
89   parent_class = g_type_class_peek_parent (klass);
90
91   gstbasertppayload_class->set_caps = gst_rtp_pcmu_pay_setcaps;
92 }
93
94 static void
95 gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay, GstRtpPcmuPayClass * klass)
96 {
97   GstBaseRTPAudioPayload *basertpaudiopayload;
98
99   basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (rtppcmupay);
100
101   GST_BASE_RTP_PAYLOAD (rtppcmupay)->clock_rate = 8000;
102
103   /* tell basertpaudiopayload that this is a sample based codec */
104   gst_base_rtp_audio_payload_set_sample_based (basertpaudiopayload);
105
106   /* octet-per-sample is 1 for PCM */
107   gst_base_rtp_audio_payload_set_sample_options (basertpaudiopayload, 1);
108 }
109
110 static gboolean
111 gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
112 {
113   gboolean res;
114
115   payload->pt = GST_RTP_PAYLOAD_PCMU;
116
117   gst_basertppayload_set_options (payload, "audio", FALSE, "PCMU", 8000);
118   res = gst_basertppayload_set_outcaps (payload, NULL);
119
120   return res;
121 }
122
123 gboolean
124 gst_rtp_pcmu_pay_plugin_init (GstPlugin * plugin)
125 {
126   return gst_element_register (plugin, "rtppcmupay",
127       GST_RANK_NONE, GST_TYPE_RTP_PCMU_PAY);
128 }