2 * Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
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.
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.
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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include <gst/rtp/gstrtpbuffer.h>
27 #include "gstrtpmp1sdepay.h"
29 /* RtpMP1SDepay signals and args */
42 static GstStaticPadTemplate gst_rtp_mp1s_depay_src_template =
43 GST_STATIC_PAD_TEMPLATE ("src",
46 GST_STATIC_CAPS ("video/mpeg,systemstream=(boolean)true")
49 /* The spec says video/MP1S but I have seen streams with other/MP1S so we will
51 static GstStaticPadTemplate gst_rtp_mp1s_depay_sink_template =
52 GST_STATIC_PAD_TEMPLATE ("sink",
55 GST_STATIC_CAPS ("application/x-rtp, "
56 "media = (string) \"other\", "
57 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
58 "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP1S\";"
60 "media = (string) \"video\", "
61 "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
62 "clock-rate = (int) [1, MAX ], " "encoding-name = (string) \"MP1S\"")
65 G_DEFINE_TYPE (GstRtpMP1SDepay, gst_rtp_mp1s_depay,
66 GST_TYPE_BASE_RTP_DEPAYLOAD);
68 static gboolean gst_rtp_mp1s_depay_setcaps (GstBaseRTPDepayload * depayload,
70 static GstBuffer *gst_rtp_mp1s_depay_process (GstBaseRTPDepayload * depayload,
74 gst_rtp_mp1s_depay_class_init (GstRtpMP1SDepayClass * klass)
76 GstElementClass *gstelement_class;
77 GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
79 gstelement_class = (GstElementClass *) klass;
80 gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
82 gstbasertpdepayload_class->process = gst_rtp_mp1s_depay_process;
83 gstbasertpdepayload_class->set_caps = gst_rtp_mp1s_depay_setcaps;
85 gst_element_class_add_pad_template (gstelement_class,
86 gst_static_pad_template_get (&gst_rtp_mp1s_depay_src_template));
87 gst_element_class_add_pad_template (gstelement_class,
88 gst_static_pad_template_get (&gst_rtp_mp1s_depay_sink_template));
90 gst_element_class_set_details_simple (gstelement_class,
91 "RTP MPEG1 System Stream depayloader", "Codec/Depayloader/Network/RTP",
92 "Extracts MPEG1 System Streams from RTP packets (RFC 3555)",
93 "Wim Taymans <wim.taymans@gmail.com>");
97 gst_rtp_mp1s_depay_init (GstRtpMP1SDepay * rtpmp1sdepay)
102 gst_rtp_mp1s_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
105 GstStructure *structure;
109 structure = gst_caps_get_structure (caps, 0);
110 if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
111 clock_rate = 90000; /* default */
112 depayload->clock_rate = clock_rate;
114 srccaps = gst_caps_new_simple ("video/mpeg",
115 "systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
116 res = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
117 gst_caps_unref (srccaps);
123 gst_rtp_mp1s_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
128 gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
129 outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
130 gst_rtp_buffer_unmap (&rtp);
133 GST_DEBUG ("gst_rtp_mp1s_depay_chain: pushing buffer of size %d",
134 gst_buffer_get_size (outbuf));
140 gst_rtp_mp1s_depay_plugin_init (GstPlugin * plugin)
142 return gst_element_register (plugin, "rtpmp1sdepay",
143 GST_RANK_SECONDARY, GST_TYPE_RTP_MP1S_DEPAY);