rtpvrawpay: Add missing break
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpmp1sdepay.c
1 /* GStreamer
2  * Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include <gst/rtp/gstrtpbuffer.h>
25
26 #include <string.h>
27 #include "gstrtpmp1sdepay.h"
28
29 /* RtpMP1SDepay signals and args */
30 enum
31 {
32   /* FILL ME */
33   LAST_SIGNAL
34 };
35
36 enum
37 {
38   PROP_0,
39   PROP_LAST
40 };
41
42 static GstStaticPadTemplate gst_rtp_mp1s_depay_src_template =
43 GST_STATIC_PAD_TEMPLATE ("src",
44     GST_PAD_SRC,
45     GST_PAD_ALWAYS,
46     GST_STATIC_CAPS ("video/mpeg,systemstream=(boolean)true")
47     );
48
49 /* The spec says video/MP1S but I have seen streams with other/MP1S so we will
50  * allow them both */
51 static GstStaticPadTemplate gst_rtp_mp1s_depay_sink_template =
52     GST_STATIC_PAD_TEMPLATE ("sink",
53     GST_PAD_SINK,
54     GST_PAD_ALWAYS,
55     GST_STATIC_CAPS ("application/x-rtp, "
56         "media = (string) \"other\", "
57         "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP1S\";"
58         "application/x-rtp, "
59         "media = (string) \"video\", "
60         "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP1S\"")
61     );
62
63 G_DEFINE_TYPE (GstRtpMP1SDepay, gst_rtp_mp1s_depay,
64     GST_TYPE_RTP_BASE_DEPAYLOAD);
65
66 static gboolean gst_rtp_mp1s_depay_setcaps (GstRTPBaseDepayload * depayload,
67     GstCaps * caps);
68 static GstBuffer *gst_rtp_mp1s_depay_process (GstRTPBaseDepayload * depayload,
69     GstBuffer * buf);
70
71 static void
72 gst_rtp_mp1s_depay_class_init (GstRtpMP1SDepayClass * klass)
73 {
74   GstElementClass *gstelement_class;
75   GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
76
77   gstelement_class = (GstElementClass *) klass;
78   gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
79
80   gstrtpbasedepayload_class->process = gst_rtp_mp1s_depay_process;
81   gstrtpbasedepayload_class->set_caps = gst_rtp_mp1s_depay_setcaps;
82
83   gst_element_class_add_pad_template (gstelement_class,
84       gst_static_pad_template_get (&gst_rtp_mp1s_depay_src_template));
85   gst_element_class_add_pad_template (gstelement_class,
86       gst_static_pad_template_get (&gst_rtp_mp1s_depay_sink_template));
87
88   gst_element_class_set_static_metadata (gstelement_class,
89       "RTP MPEG1 System Stream depayloader", "Codec/Depayloader/Network/RTP",
90       "Extracts MPEG1 System Streams from RTP packets (RFC 3555)",
91       "Wim Taymans <wim.taymans@gmail.com>");
92 }
93
94 static void
95 gst_rtp_mp1s_depay_init (GstRtpMP1SDepay * rtpmp1sdepay)
96 {
97 }
98
99 static gboolean
100 gst_rtp_mp1s_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
101 {
102   GstCaps *srccaps;
103   GstStructure *structure;
104   gint clock_rate;
105   gboolean res;
106
107   structure = gst_caps_get_structure (caps, 0);
108   if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
109     clock_rate = 90000;         /* default */
110   depayload->clock_rate = clock_rate;
111
112   srccaps = gst_caps_new_simple ("video/mpeg",
113       "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
114   res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
115   gst_caps_unref (srccaps);
116
117   return res;
118 }
119
120 static GstBuffer *
121 gst_rtp_mp1s_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
122 {
123   GstBuffer *outbuf;
124   GstRTPBuffer rtp = { NULL };
125
126   gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
127   outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
128   gst_rtp_buffer_unmap (&rtp);
129
130   if (outbuf)
131     GST_DEBUG ("gst_rtp_mp1s_depay_chain: pushing buffer of size %"
132         G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
133
134   return outbuf;
135 }
136
137 gboolean
138 gst_rtp_mp1s_depay_plugin_init (GstPlugin * plugin)
139 {
140   return gst_element_register (plugin, "rtpmp1sdepay",
141       GST_RANK_SECONDARY, GST_TYPE_RTP_MP1S_DEPAY);
142 }