gstreamer/gst/rtp/gstrtpvrawdepay.c

636 lines
17 KiB
C
Raw Normal View History

/* GStreamer
* Copyright (C) <2008> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gst/rtp/gstrtpbuffer.h>
#include <string.h>
#include <stdlib.h>
#include "gstrtpvrawdepay.h"
GST_DEBUG_CATEGORY_STATIC (rtpvrawdepay_debug);
#define GST_CAT_DEFAULT (rtpvrawdepay_debug)
static GstStaticPadTemplate gst_rtp_vraw_depay_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw")
);
static GstStaticPadTemplate gst_rtp_vraw_depay_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-rtp, "
"media = (string) \"video\", "
"clock-rate = (int) 90000, " "encoding-name = (string) \"RAW\"")
);
2011-07-10 19:50:19 +00:00
#define gst_rtp_vraw_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpVRawDepay, gst_rtp_vraw_depay,
2011-11-11 11:25:01 +00:00
GST_TYPE_RTP_BASE_DEPAYLOAD);
2011-11-11 11:25:01 +00:00
static gboolean gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
2011-11-11 11:25:01 +00:00
static GstBuffer *gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
static GstStateChangeReturn gst_rtp_vraw_depay_change_state (GstElement *
element, GstStateChange transition);
2011-11-11 11:25:01 +00:00
static gboolean gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter,
GstEvent * event);
static void
gst_rtp_vraw_depay_class_init (GstRtpVRawDepayClass * klass)
{
GstElementClass *gstelement_class;
2011-11-11 11:25:01 +00:00
GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
gstelement_class = (GstElementClass *) klass;
2011-11-11 11:25:01 +00:00
gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gstelement_class->change_state = gst_rtp_vraw_depay_change_state;
2011-11-11 11:25:01 +00:00
gstrtpbasedepayload_class->set_caps = gst_rtp_vraw_depay_setcaps;
gstrtpbasedepayload_class->process = gst_rtp_vraw_depay_process;
gstrtpbasedepayload_class->handle_event = gst_rtp_vraw_depay_handle_event;
2011-07-10 19:50:19 +00:00
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_vraw_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_vraw_depay_sink_template));
gst_element_class_set_static_metadata (gstelement_class,
2011-07-10 19:50:19 +00:00
"RTP Raw Video depayloader", "Codec/Depayloader/Network/RTP",
"Extracts raw video from RTP packets (RFC 4175)",
"Wim Taymans <wim.taymans@gmail.com>");
GST_DEBUG_CATEGORY_INIT (rtpvrawdepay_debug, "rtpvrawdepay", 0,
"raw video RTP Depayloader");
}
static void
2011-07-10 19:50:19 +00:00
gst_rtp_vraw_depay_init (GstRtpVRawDepay * rtpvrawdepay)
{
}
static void
gst_rtp_vraw_depay_reset (GstRtpVRawDepay * rtpvrawdepay)
{
if (rtpvrawdepay->outbuf) {
gst_buffer_unref (rtpvrawdepay->outbuf);
rtpvrawdepay->outbuf = NULL;
}
rtpvrawdepay->timestamp = -1;
2011-07-10 19:50:19 +00:00
if (rtpvrawdepay->pool) {
gst_buffer_pool_set_active (rtpvrawdepay->pool, FALSE);
gst_object_unref (rtpvrawdepay->pool);
rtpvrawdepay->pool = NULL;
}
}
static GstFlowReturn
gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
GstVideoInfo * info)
{
GstQuery *query;
GstBufferPool *pool = NULL;
2012-03-15 19:37:56 +00:00
guint size, min, max;
2011-07-10 19:50:19 +00:00
GstStructure *config;
/* find a pool for the negotiated caps now */
query = gst_query_new_allocation (caps, TRUE);
2012-03-15 19:37:56 +00:00
if (!gst_pad_peer_query (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depay), query)) {
/* not a problem, we use the defaults of query */
GST_DEBUG_OBJECT (depay, "could not get downstream ALLOCATION hints");
}
if (gst_query_get_n_allocation_pools (query) > 0) {
2011-07-10 19:50:19 +00:00
/* we got configuration from our peer, parse them */
2012-03-15 19:37:56 +00:00
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
2011-07-10 19:50:19 +00:00
} else {
2012-03-15 19:37:56 +00:00
GST_DEBUG_OBJECT (depay, "didn't get downstream pool hints");
2011-07-10 19:50:19 +00:00
size = info->size;
min = max = 0;
}
if (pool == NULL) {
/* we did not get a pool, make one ourselves then */
2012-03-15 19:37:56 +00:00
pool = gst_video_buffer_pool_new ();
2011-07-10 19:50:19 +00:00
}
if (depay->pool)
gst_object_unref (depay->pool);
depay->pool = pool;
config = gst_buffer_pool_get_config (pool);
2012-03-15 21:11:17 +00:00
gst_buffer_pool_config_set_params (config, caps, size, min, max);
2012-07-06 09:26:46 +00:00
if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
2012-03-15 19:37:56 +00:00
/* just set the metadata, if the pool can support it we will transparently use
* it through the video info API. We could also see if the pool support this
* metadata and only activate it then. */
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
}
2011-07-10 19:50:19 +00:00
gst_buffer_pool_set_config (pool, config);
/* and activate */
gst_buffer_pool_set_active (pool, TRUE);
gst_query_unref (query);
return GST_FLOW_OK;
}
static gboolean
2011-11-11 11:25:01 +00:00
gst_rtp_vraw_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
{
GstStructure *structure;
GstRtpVRawDepay *rtpvrawdepay;
gst/rtp/gstrtpL16depay.c: Check if clock-rate and channels are valid. Original commit message from CVS: * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps), (gst_rtp_L16_depay_process): Check if clock-rate and channels are valid. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpL16pay.c: (gst_rtp_L16_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpac3depay.c: (gst_rtp_ac3_depay_setcaps), (gst_rtp_ac3_depay_process): Don't ignore the return value of set_caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_setcaps), (gst_rtp_amr_depay_process): * gst/rtp/gstrtpamrdepay.h: Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set output caps on the buffers, the base class does that for us. The subclass will make sure we are negotiated. * gst/rtp/gstrtpdvdepay.c: (gst_rtp_dv_depay_setcaps), (gst_rtp_dv_depay_process), (gst_rtp_dv_depay_reset): * gst/rtp/gstrtpdvdepay.h: Clean up caps negotiation. The subclass will make sure we are negotiated. * gst/rtp/gstrtpg726depay.c: (gst_rtp_g726_depay_setcaps), (gst_rtp_g726_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpg729depay.c: (gst_rtp_g729_depay_init), (gst_rtp_g729_depay_setcaps), (gst_rtp_g729_depay_process): * gst/rtp/gstrtpg729depay.h: The subclass will make sure we are negotiated. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmdepay.c: (gst_rtp_gsm_depay_setcaps), (gst_rtp_gsm_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmpay.c: (gst_rtp_gsm_pay_setcaps): Clean up caps negotiation. Don't ignore the return value of set_outcaps. * gst/rtp/gstrtph263depay.c: (gst_rtp_h263_depay_setcaps), (gst_rtp_h263_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263pay.c: (gst_rtp_h263_pay_setcaps), (gst_rtp_h263_pay_flush), (gst_rtp_h263_pay_handle_buffer): * gst/rtp/gstrtph263pay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_setcaps), (gst_rtp_h263p_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263ppay.c: (gst_rtp_h263p_pay_class_init), (gst_rtp_h263p_pay_setcaps), (gst_rtp_h263p_pay_flush), (gst_rtp_h263p_pay_handle_buffer): * gst/rtp/gstrtph263ppay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_setcaps), (gst_rtp_h264_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. Fix possible caps leak. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph264pay.c: (gst_rtp_h264_pay_setcaps): Add some more debug info. * gst/rtp/gstrtpilbcdepay.c: (gst_rtp_ilbc_depay_setcaps), (gst_rtp_ilbc_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_sink_setcaps): Clean up caps negotiation. * gst/rtp/gstrtpmp1sdepay.c: (gst_rtp_mp1s_depay_setcaps), (gst_rtp_mp1s_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_setcaps), (gst_rtp_mp2t_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4adepay.c: (gst_rtp_mp4a_depay_setcaps), (gst_rtp_mp4a_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmp4apay.c: (gst_rtp_mp4a_pay_new_caps), (gst_rtp_mp4a_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_setcaps), (gst_rtp_mp4g_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize), (gst_rtp_mp4g_pay_new_caps), (gst_rtp_mp4g_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_setcaps), (gst_rtp_mp4v_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4vpay.c: (gst_rtp_mp4v_pay_new_caps), (gst_rtp_mp4v_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_setcaps), (gst_rtp_mpa_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpmpapay.c: (gst_rtp_mpa_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpvdepay.c: (gst_rtp_mpv_depay_setcaps), (gst_rtp_mpv_depay_process): Clean up caps negotiation. Actually set output caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmpvpay.c: (gst_rtp_mpv_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmadepay.c: (gst_rtp_pcma_depay_setcaps), (gst_rtp_pcma_depay_process): Clean up caps negotiation. Set output buffer duration because we can. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmapay.c: (gst_rtp_pcma_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmudepay.c: (gst_rtp_pcmu_depay_setcaps), (gst_rtp_pcmu_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmupay.c: (gst_rtp_pcmu_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpspeexdepay.c: (gst_rtp_speex_depay_init), (gst_rtp_speex_depay_setcaps), (gst_rtp_speex_depay_process): Clean up caps negotiation. Set output caps on the pad and header buffers. Set duration on output buffers because we can. * gst/rtp/gstrtpspeexpay.c: (gst_rtp_speex_pay_parse_ident): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_setcaps), (gst_rtp_sv3v_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. No need to set caps out output buffers, subclass does that. * gst/rtp/gstrtptheoradepay.c: (gst_rtp_theora_depay_setcaps), (gst_rtp_theora_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtptheorapay.c: (gst_rtp_theora_pay_class_init), (gst_rtp_theora_pay_flush_packet), (encode_base64), (gst_rtp_theora_pay_finish_headers), (gst_rtp_theora_pay_parse_id), (gst_rtp_theora_pay_handle_buffer): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvorbisdepay.c: (gst_rtp_vorbis_depay_setcaps), (gst_rtp_vorbis_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpvorbispay.c: (gst_rtp_vorbis_pay_finish_headers): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvrawdepay.c: (gst_rtp_vraw_depay_setcaps): Clean up caps negotiation, don't ignore setcaps return. * gst/rtp/gstrtpvrawpay.c: (gst_rtp_vraw_pay_setcaps): Don't ignore the return value of set_outcaps.
2008-10-27 11:03:53 +00:00
gint clock_rate;
2011-07-10 19:50:19 +00:00
const gchar *str;
gint format, width, height, pgroup, xinc, yinc;
GstCaps *srccaps;
gst/rtp/gstrtpL16depay.c: Check if clock-rate and channels are valid. Original commit message from CVS: * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps), (gst_rtp_L16_depay_process): Check if clock-rate and channels are valid. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpL16pay.c: (gst_rtp_L16_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpac3depay.c: (gst_rtp_ac3_depay_setcaps), (gst_rtp_ac3_depay_process): Don't ignore the return value of set_caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_setcaps), (gst_rtp_amr_depay_process): * gst/rtp/gstrtpamrdepay.h: Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set output caps on the buffers, the base class does that for us. The subclass will make sure we are negotiated. * gst/rtp/gstrtpdvdepay.c: (gst_rtp_dv_depay_setcaps), (gst_rtp_dv_depay_process), (gst_rtp_dv_depay_reset): * gst/rtp/gstrtpdvdepay.h: Clean up caps negotiation. The subclass will make sure we are negotiated. * gst/rtp/gstrtpg726depay.c: (gst_rtp_g726_depay_setcaps), (gst_rtp_g726_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpg729depay.c: (gst_rtp_g729_depay_init), (gst_rtp_g729_depay_setcaps), (gst_rtp_g729_depay_process): * gst/rtp/gstrtpg729depay.h: The subclass will make sure we are negotiated. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmdepay.c: (gst_rtp_gsm_depay_setcaps), (gst_rtp_gsm_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmpay.c: (gst_rtp_gsm_pay_setcaps): Clean up caps negotiation. Don't ignore the return value of set_outcaps. * gst/rtp/gstrtph263depay.c: (gst_rtp_h263_depay_setcaps), (gst_rtp_h263_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263pay.c: (gst_rtp_h263_pay_setcaps), (gst_rtp_h263_pay_flush), (gst_rtp_h263_pay_handle_buffer): * gst/rtp/gstrtph263pay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_setcaps), (gst_rtp_h263p_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263ppay.c: (gst_rtp_h263p_pay_class_init), (gst_rtp_h263p_pay_setcaps), (gst_rtp_h263p_pay_flush), (gst_rtp_h263p_pay_handle_buffer): * gst/rtp/gstrtph263ppay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_setcaps), (gst_rtp_h264_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. Fix possible caps leak. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph264pay.c: (gst_rtp_h264_pay_setcaps): Add some more debug info. * gst/rtp/gstrtpilbcdepay.c: (gst_rtp_ilbc_depay_setcaps), (gst_rtp_ilbc_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_sink_setcaps): Clean up caps negotiation. * gst/rtp/gstrtpmp1sdepay.c: (gst_rtp_mp1s_depay_setcaps), (gst_rtp_mp1s_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_setcaps), (gst_rtp_mp2t_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4adepay.c: (gst_rtp_mp4a_depay_setcaps), (gst_rtp_mp4a_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmp4apay.c: (gst_rtp_mp4a_pay_new_caps), (gst_rtp_mp4a_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_setcaps), (gst_rtp_mp4g_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize), (gst_rtp_mp4g_pay_new_caps), (gst_rtp_mp4g_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_setcaps), (gst_rtp_mp4v_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4vpay.c: (gst_rtp_mp4v_pay_new_caps), (gst_rtp_mp4v_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_setcaps), (gst_rtp_mpa_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpmpapay.c: (gst_rtp_mpa_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpvdepay.c: (gst_rtp_mpv_depay_setcaps), (gst_rtp_mpv_depay_process): Clean up caps negotiation. Actually set output caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmpvpay.c: (gst_rtp_mpv_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmadepay.c: (gst_rtp_pcma_depay_setcaps), (gst_rtp_pcma_depay_process): Clean up caps negotiation. Set output buffer duration because we can. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmapay.c: (gst_rtp_pcma_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmudepay.c: (gst_rtp_pcmu_depay_setcaps), (gst_rtp_pcmu_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmupay.c: (gst_rtp_pcmu_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpspeexdepay.c: (gst_rtp_speex_depay_init), (gst_rtp_speex_depay_setcaps), (gst_rtp_speex_depay_process): Clean up caps negotiation. Set output caps on the pad and header buffers. Set duration on output buffers because we can. * gst/rtp/gstrtpspeexpay.c: (gst_rtp_speex_pay_parse_ident): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_setcaps), (gst_rtp_sv3v_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. No need to set caps out output buffers, subclass does that. * gst/rtp/gstrtptheoradepay.c: (gst_rtp_theora_depay_setcaps), (gst_rtp_theora_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtptheorapay.c: (gst_rtp_theora_pay_class_init), (gst_rtp_theora_pay_flush_packet), (encode_base64), (gst_rtp_theora_pay_finish_headers), (gst_rtp_theora_pay_parse_id), (gst_rtp_theora_pay_handle_buffer): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvorbisdepay.c: (gst_rtp_vorbis_depay_setcaps), (gst_rtp_vorbis_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpvorbispay.c: (gst_rtp_vorbis_pay_finish_headers): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvrawdepay.c: (gst_rtp_vraw_depay_setcaps): Clean up caps negotiation, don't ignore setcaps return. * gst/rtp/gstrtpvrawpay.c: (gst_rtp_vraw_pay_setcaps): Don't ignore the return value of set_outcaps.
2008-10-27 11:03:53 +00:00
gboolean res;
2011-07-10 19:50:19 +00:00
GstFlowReturn ret;
rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
structure = gst_caps_get_structure (caps, 0);
xinc = yinc = 1;
gst/rtp/gstrtpL16depay.c: Check if clock-rate and channels are valid. Original commit message from CVS: * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps), (gst_rtp_L16_depay_process): Check if clock-rate and channels are valid. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpL16pay.c: (gst_rtp_L16_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpac3depay.c: (gst_rtp_ac3_depay_setcaps), (gst_rtp_ac3_depay_process): Don't ignore the return value of set_caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_setcaps), (gst_rtp_amr_depay_process): * gst/rtp/gstrtpamrdepay.h: Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set output caps on the buffers, the base class does that for us. The subclass will make sure we are negotiated. * gst/rtp/gstrtpdvdepay.c: (gst_rtp_dv_depay_setcaps), (gst_rtp_dv_depay_process), (gst_rtp_dv_depay_reset): * gst/rtp/gstrtpdvdepay.h: Clean up caps negotiation. The subclass will make sure we are negotiated. * gst/rtp/gstrtpg726depay.c: (gst_rtp_g726_depay_setcaps), (gst_rtp_g726_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpg729depay.c: (gst_rtp_g729_depay_init), (gst_rtp_g729_depay_setcaps), (gst_rtp_g729_depay_process): * gst/rtp/gstrtpg729depay.h: The subclass will make sure we are negotiated. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmdepay.c: (gst_rtp_gsm_depay_setcaps), (gst_rtp_gsm_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmpay.c: (gst_rtp_gsm_pay_setcaps): Clean up caps negotiation. Don't ignore the return value of set_outcaps. * gst/rtp/gstrtph263depay.c: (gst_rtp_h263_depay_setcaps), (gst_rtp_h263_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263pay.c: (gst_rtp_h263_pay_setcaps), (gst_rtp_h263_pay_flush), (gst_rtp_h263_pay_handle_buffer): * gst/rtp/gstrtph263pay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_setcaps), (gst_rtp_h263p_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263ppay.c: (gst_rtp_h263p_pay_class_init), (gst_rtp_h263p_pay_setcaps), (gst_rtp_h263p_pay_flush), (gst_rtp_h263p_pay_handle_buffer): * gst/rtp/gstrtph263ppay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_setcaps), (gst_rtp_h264_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. Fix possible caps leak. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph264pay.c: (gst_rtp_h264_pay_setcaps): Add some more debug info. * gst/rtp/gstrtpilbcdepay.c: (gst_rtp_ilbc_depay_setcaps), (gst_rtp_ilbc_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_sink_setcaps): Clean up caps negotiation. * gst/rtp/gstrtpmp1sdepay.c: (gst_rtp_mp1s_depay_setcaps), (gst_rtp_mp1s_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_setcaps), (gst_rtp_mp2t_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4adepay.c: (gst_rtp_mp4a_depay_setcaps), (gst_rtp_mp4a_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmp4apay.c: (gst_rtp_mp4a_pay_new_caps), (gst_rtp_mp4a_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_setcaps), (gst_rtp_mp4g_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize), (gst_rtp_mp4g_pay_new_caps), (gst_rtp_mp4g_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_setcaps), (gst_rtp_mp4v_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4vpay.c: (gst_rtp_mp4v_pay_new_caps), (gst_rtp_mp4v_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_setcaps), (gst_rtp_mpa_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpmpapay.c: (gst_rtp_mpa_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpvdepay.c: (gst_rtp_mpv_depay_setcaps), (gst_rtp_mpv_depay_process): Clean up caps negotiation. Actually set output caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmpvpay.c: (gst_rtp_mpv_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmadepay.c: (gst_rtp_pcma_depay_setcaps), (gst_rtp_pcma_depay_process): Clean up caps negotiation. Set output buffer duration because we can. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmapay.c: (gst_rtp_pcma_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmudepay.c: (gst_rtp_pcmu_depay_setcaps), (gst_rtp_pcmu_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmupay.c: (gst_rtp_pcmu_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpspeexdepay.c: (gst_rtp_speex_depay_init), (gst_rtp_speex_depay_setcaps), (gst_rtp_speex_depay_process): Clean up caps negotiation. Set output caps on the pad and header buffers. Set duration on output buffers because we can. * gst/rtp/gstrtpspeexpay.c: (gst_rtp_speex_pay_parse_ident): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_setcaps), (gst_rtp_sv3v_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. No need to set caps out output buffers, subclass does that. * gst/rtp/gstrtptheoradepay.c: (gst_rtp_theora_depay_setcaps), (gst_rtp_theora_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtptheorapay.c: (gst_rtp_theora_pay_class_init), (gst_rtp_theora_pay_flush_packet), (encode_base64), (gst_rtp_theora_pay_finish_headers), (gst_rtp_theora_pay_parse_id), (gst_rtp_theora_pay_handle_buffer): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvorbisdepay.c: (gst_rtp_vorbis_depay_setcaps), (gst_rtp_vorbis_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpvorbispay.c: (gst_rtp_vorbis_pay_finish_headers): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvrawdepay.c: (gst_rtp_vraw_depay_setcaps): Clean up caps negotiation, don't ignore setcaps return. * gst/rtp/gstrtpvrawpay.c: (gst_rtp_vraw_pay_setcaps): Don't ignore the return value of set_outcaps.
2008-10-27 11:03:53 +00:00
if (!gst_structure_get_int (structure, "clock-rate", &clock_rate))
clock_rate = 90000; /* default */
depayload->clock_rate = clock_rate;
if (!(str = gst_structure_get_string (structure, "width")))
goto no_width;
width = atoi (str);
if (!(str = gst_structure_get_string (structure, "height")))
goto no_height;
height = atoi (str);
/* optional interlace value but we don't handle interlaced
* formats yet */
if (gst_structure_get_string (structure, "interlace"))
goto interlaced;
if (!(str = gst_structure_get_string (structure, "sampling")))
goto no_sampling;
if (!strcmp (str, "RGB")) {
format = GST_VIDEO_FORMAT_RGB;
pgroup = 3;
} else if (!strcmp (str, "RGBA")) {
format = GST_VIDEO_FORMAT_RGBA;
pgroup = 4;
} else if (!strcmp (str, "BGR")) {
format = GST_VIDEO_FORMAT_BGR;
pgroup = 3;
} else if (!strcmp (str, "BGRA")) {
format = GST_VIDEO_FORMAT_BGRA;
pgroup = 4;
} else if (!strcmp (str, "YCbCr-4:4:4")) {
format = GST_VIDEO_FORMAT_AYUV;
pgroup = 3;
} else if (!strcmp (str, "YCbCr-4:2:2")) {
format = GST_VIDEO_FORMAT_UYVY;
pgroup = 4;
xinc = 2;
} else if (!strcmp (str, "YCbCr-4:2:0")) {
format = GST_VIDEO_FORMAT_I420;
pgroup = 6;
xinc = yinc = 2;
} else if (!strcmp (str, "YCbCr-4:1:1")) {
format = GST_VIDEO_FORMAT_Y41B;
pgroup = 6;
xinc = 4;
} else
goto unknown_format;
2011-07-10 19:50:19 +00:00
gst_video_info_init (&rtpvrawdepay->vinfo);
gst_video_info_set_format (&rtpvrawdepay->vinfo, format, width, height);
GST_VIDEO_INFO_FPS_N (&rtpvrawdepay->vinfo) = 0;
GST_VIDEO_INFO_FPS_D (&rtpvrawdepay->vinfo) = 1;
rtpvrawdepay->pgroup = pgroup;
rtpvrawdepay->xinc = xinc;
rtpvrawdepay->yinc = yinc;
2011-07-10 19:50:19 +00:00
srccaps = gst_video_info_to_caps (&rtpvrawdepay->vinfo);
2011-11-11 11:25:01 +00:00
res = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
GST_DEBUG_OBJECT (depayload, "width %d, height %d, format %d", width, height,
format);
2011-07-10 19:50:19 +00:00
GST_DEBUG_OBJECT (depayload, "xinc %d, yinc %d, pgroup %d",
xinc, yinc, pgroup);
/* negotiate a bufferpool */
if ((ret = gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, srccaps,
2011-07-10 19:50:19 +00:00
&rtpvrawdepay->vinfo)) != GST_FLOW_OK)
goto no_bufferpool;
gst/rtp/gstrtpL16depay.c: Check if clock-rate and channels are valid. Original commit message from CVS: * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_setcaps), (gst_rtp_L16_depay_process): Check if clock-rate and channels are valid. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpL16pay.c: (gst_rtp_L16_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpac3depay.c: (gst_rtp_ac3_depay_setcaps), (gst_rtp_ac3_depay_process): Don't ignore the return value of set_caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_setcaps), (gst_rtp_amr_depay_process): * gst/rtp/gstrtpamrdepay.h: Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set output caps on the buffers, the base class does that for us. The subclass will make sure we are negotiated. * gst/rtp/gstrtpdvdepay.c: (gst_rtp_dv_depay_setcaps), (gst_rtp_dv_depay_process), (gst_rtp_dv_depay_reset): * gst/rtp/gstrtpdvdepay.h: Clean up caps negotiation. The subclass will make sure we are negotiated. * gst/rtp/gstrtpg726depay.c: (gst_rtp_g726_depay_setcaps), (gst_rtp_g726_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpg729depay.c: (gst_rtp_g729_depay_init), (gst_rtp_g729_depay_setcaps), (gst_rtp_g729_depay_process): * gst/rtp/gstrtpg729depay.h: The subclass will make sure we are negotiated. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmdepay.c: (gst_rtp_gsm_depay_setcaps), (gst_rtp_gsm_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpgsmpay.c: (gst_rtp_gsm_pay_setcaps): Clean up caps negotiation. Don't ignore the return value of set_outcaps. * gst/rtp/gstrtph263depay.c: (gst_rtp_h263_depay_setcaps), (gst_rtp_h263_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263pay.c: (gst_rtp_h263_pay_setcaps), (gst_rtp_h263_pay_flush), (gst_rtp_h263_pay_handle_buffer): * gst/rtp/gstrtph263pay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph263pdepay.c: (gst_rtp_h263p_depay_setcaps), (gst_rtp_h263p_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph263ppay.c: (gst_rtp_h263p_pay_class_init), (gst_rtp_h263p_pay_setcaps), (gst_rtp_h263p_pay_flush), (gst_rtp_h263p_pay_handle_buffer): * gst/rtp/gstrtph263ppay.h: Don't ignore the return value of set_outcaps. Do some more timestamps. * gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_setcaps), (gst_rtp_h264_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. Fix possible caps leak. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtph264pay.c: (gst_rtp_h264_pay_setcaps): Add some more debug info. * gst/rtp/gstrtpilbcdepay.c: (gst_rtp_ilbc_depay_setcaps), (gst_rtp_ilbc_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpilbcpay.c: (gst_rtpilbcpay_sink_setcaps): Clean up caps negotiation. * gst/rtp/gstrtpmp1sdepay.c: (gst_rtp_mp1s_depay_setcaps), (gst_rtp_mp1s_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_setcaps), (gst_rtp_mp2t_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4adepay.c: (gst_rtp_mp4a_depay_setcaps), (gst_rtp_mp4a_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmp4apay.c: (gst_rtp_mp4a_pay_new_caps), (gst_rtp_mp4a_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_setcaps), (gst_rtp_mp4g_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_finalize), (gst_rtp_mp4g_pay_new_caps), (gst_rtp_mp4g_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_setcaps), (gst_rtp_mp4v_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. No need to set caps on buffers, subclass does that for us. * gst/rtp/gstrtpmp4vpay.c: (gst_rtp_mp4v_pay_new_caps), (gst_rtp_mp4v_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_setcaps), (gst_rtp_mpa_depay_process): Clean up caps negotiation. Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtpmpapay.c: (gst_rtp_mpa_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpmpvdepay.c: (gst_rtp_mpv_depay_setcaps), (gst_rtp_mpv_depay_process): Clean up caps negotiation. Actually set output caps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpmpvpay.c: (gst_rtp_mpv_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmadepay.c: (gst_rtp_pcma_depay_setcaps), (gst_rtp_pcma_depay_process): Clean up caps negotiation. Set output buffer duration because we can. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmapay.c: (gst_rtp_pcma_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtppcmudepay.c: (gst_rtp_pcmu_depay_setcaps), (gst_rtp_pcmu_depay_process): Clean up caps negotiation. Use the marker bit to set the DISCONT flag on outgoing buffers. * gst/rtp/gstrtppcmupay.c: (gst_rtp_pcmu_pay_setcaps): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpspeexdepay.c: (gst_rtp_speex_depay_init), (gst_rtp_speex_depay_setcaps), (gst_rtp_speex_depay_process): Clean up caps negotiation. Set output caps on the pad and header buffers. Set duration on output buffers because we can. * gst/rtp/gstrtpspeexpay.c: (gst_rtp_speex_pay_parse_ident): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_setcaps), (gst_rtp_sv3v_depay_process): Clean up caps negotiation. No need to validate the buffer, the base class does that for us. No need to set caps out output buffers, subclass does that. * gst/rtp/gstrtptheoradepay.c: (gst_rtp_theora_depay_setcaps), (gst_rtp_theora_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtptheorapay.c: (gst_rtp_theora_pay_class_init), (gst_rtp_theora_pay_flush_packet), (encode_base64), (gst_rtp_theora_pay_finish_headers), (gst_rtp_theora_pay_parse_id), (gst_rtp_theora_pay_handle_buffer): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvorbisdepay.c: (gst_rtp_vorbis_depay_setcaps), (gst_rtp_vorbis_depay_process): Don't ignore the return value of setcaps. No need to validate the buffer, the base class does that for us. * gst/rtp/gstrtpvorbispay.c: (gst_rtp_vorbis_pay_finish_headers): Don't ignore the return value of set_outcaps. * gst/rtp/gstrtpvrawdepay.c: (gst_rtp_vraw_depay_setcaps): Clean up caps negotiation, don't ignore setcaps return. * gst/rtp/gstrtpvrawpay.c: (gst_rtp_vraw_pay_setcaps): Don't ignore the return value of set_outcaps.
2008-10-27 11:03:53 +00:00
return res;
/* ERRORS */
no_width:
{
GST_ERROR_OBJECT (depayload, "no width specified");
return FALSE;
}
no_height:
{
GST_ERROR_OBJECT (depayload, "no height specified");
return FALSE;
}
interlaced:
{
GST_ERROR_OBJECT (depayload, "interlaced formats not supported yet");
return FALSE;
}
no_sampling:
{
GST_ERROR_OBJECT (depayload, "no sampling specified");
return FALSE;
}
unknown_format:
{
GST_ERROR_OBJECT (depayload, "unknown sampling format '%s'", str);
return FALSE;
}
2011-07-10 19:50:19 +00:00
no_bufferpool:
{
GST_DEBUG_OBJECT (depayload, "no bufferpool");
return FALSE;
}
}
static GstBuffer *
2011-11-11 11:25:01 +00:00
gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpVRawDepay *rtpvrawdepay;
2011-07-10 19:50:19 +00:00
guint8 *payload, *yp, *up, *vp, *headers;
guint32 timestamp;
2010-09-07 11:55:04 +00:00
guint cont, ystride, uvstride, pgroup, payload_len;
gint width, height, xinc, yinc;
GstRTPBuffer rtp = { NULL };
2011-07-10 19:50:19 +00:00
GstVideoFrame frame;
gboolean marker;
GstBuffer *outbuf = NULL;
rtpvrawdepay = GST_RTP_VRAW_DEPAY (depayload);
2011-07-10 19:50:19 +00:00
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
timestamp = gst_rtp_buffer_get_timestamp (&rtp);
if (timestamp != rtpvrawdepay->timestamp || rtpvrawdepay->outbuf == NULL) {
GstBuffer *outbuf;
GstFlowReturn ret;
GST_LOG_OBJECT (depayload, "new frame with timestamp %u", timestamp);
/* new timestamp, flush old buffer and create new output buffer */
if (rtpvrawdepay->outbuf) {
2011-11-11 11:25:01 +00:00
gst_rtp_base_depayload_push (depayload, rtpvrawdepay->outbuf);
rtpvrawdepay->outbuf = NULL;
}
2011-11-11 11:25:01 +00:00
if (gst_pad_check_reconfigure (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload))) {
2011-07-10 19:50:19 +00:00
GstCaps *caps;
caps =
2011-11-11 11:25:01 +00:00
gst_pad_get_current_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
2011-07-10 19:50:19 +00:00
gst_rtp_vraw_depay_negotiate_pool (rtpvrawdepay, caps,
&rtpvrawdepay->vinfo);
gst_caps_unref (caps);
}
ret = gst_buffer_pool_acquire_buffer (rtpvrawdepay->pool, &outbuf, NULL);
if (G_UNLIKELY (ret != GST_FLOW_OK))
goto alloc_failed;
/* clear timestamp from alloc... */
GST_BUFFER_TIMESTAMP (outbuf) = -1;
rtpvrawdepay->outbuf = outbuf;
rtpvrawdepay->timestamp = timestamp;
}
2011-07-10 19:50:19 +00:00
if (!gst_video_frame_map (&frame, &rtpvrawdepay->vinfo, rtpvrawdepay->outbuf,
GST_MAP_WRITE))
goto invalid_frame;
/* get pointer and strides of the planes */
2011-07-10 19:50:19 +00:00
yp = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
up = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);
vp = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);
ystride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);
uvstride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 1);
pgroup = rtpvrawdepay->pgroup;
2011-07-10 19:50:19 +00:00
width = GST_VIDEO_INFO_WIDTH (&rtpvrawdepay->vinfo);
height = GST_VIDEO_INFO_HEIGHT (&rtpvrawdepay->vinfo);
xinc = rtpvrawdepay->xinc;
yinc = rtpvrawdepay->yinc;
2011-07-10 19:50:19 +00:00
payload = gst_rtp_buffer_get_payload (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
if (payload_len < 3)
goto short_packet;
/* skip extended seqnum */
payload += 2;
payload_len -= 2;
/* remember header position */
headers = payload;
/* find data start */
do {
if (payload_len < 6)
goto short_packet;
cont = payload[4] & 0x80;
payload += 6;
payload_len -= 6;
} while (cont);
while (TRUE) {
guint length, line, offs, plen;
guint8 *datap;
/* stop when we run out of data */
if (payload_len == 0)
break;
/* read length and cont. This should work because we iterated the headers
* above. */
length = (headers[0] << 8) | headers[1];
line = ((headers[2] & 0x7f) << 8) | headers[3];
offs = ((headers[4] & 0x7f) << 8) | headers[5];
cont = headers[4] & 0x80;
headers += 6;
/* length must be a multiple of pgroup */
if (length % pgroup != 0)
goto wrong_length;
if (length > payload_len)
length = payload_len;
/* sanity check */
if (line > (height - yinc)) {
GST_WARNING_OBJECT (depayload, "skipping line %d: out of range", line);
goto next;
}
if (offs > (width - xinc)) {
GST_WARNING_OBJECT (depayload, "skipping offset %d: out of range", offs);
goto next;
}
/* calculate the maximim amount of bytes we can use per line */
if (offs + ((length / pgroup) * xinc) > width) {
plen = ((width - offs) * pgroup) / xinc;
GST_WARNING_OBJECT (depayload, "clipping length %d, offset %d, plen %d",
length, offs, plen);
} else
plen = length;
GST_LOG_OBJECT (depayload,
"writing length %u/%u, line %u, offset %u, remaining %u", plen, length,
line, offs, payload_len);
2011-07-10 19:50:19 +00:00
switch (GST_VIDEO_INFO_FORMAT (&rtpvrawdepay->vinfo)) {
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_RGBA:
case GST_VIDEO_FORMAT_BGR:
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_UYVY:
/* samples are packed just like gstreamer packs them */
offs /= xinc;
datap = yp + (line * ystride) + (offs * pgroup);
memcpy (datap, payload, plen);
break;
case GST_VIDEO_FORMAT_AYUV:
{
gint i;
guint8 *p;
datap = yp + (line * ystride) + (offs * 4);
p = payload;
/* samples are packed in order Cb-Y-Cr for both interlaced and
* progressive frames */
for (i = 0; i < plen; i += pgroup) {
*datap++ = 0;
*datap++ = p[1];
*datap++ = p[0];
*datap++ = p[2];
p += pgroup;
}
break;
}
case GST_VIDEO_FORMAT_I420:
{
gint i;
guint uvoff;
guint8 *yd1p, *yd2p, *udp, *vdp, *p;
yd1p = yp + (line * ystride) + (offs);
yd2p = yd1p + ystride;
uvoff = (line / yinc * uvstride) + (offs / xinc);
udp = up + uvoff;
vdp = vp + uvoff;
p = payload;
/* line 0/1: Y00-Y01-Y10-Y11-Cb00-Cr00 Y02-Y03-Y12-Y13-Cb01-Cr01 ... */
for (i = 0; i < plen; i += pgroup) {
*yd1p++ = p[0];
*yd1p++ = p[1];
*yd2p++ = p[2];
*yd2p++ = p[3];
*udp++ = p[4];
*vdp++ = p[5];
p += pgroup;
}
break;
}
case GST_VIDEO_FORMAT_Y41B:
{
gint i;
guint uvoff;
guint8 *ydp, *udp, *vdp, *p;
ydp = yp + (line * ystride) + (offs);
uvoff = (line / yinc * uvstride) + (offs / xinc);
udp = up + uvoff;
vdp = vp + uvoff;
p = payload;
/* Samples are packed in order Cb0-Y0-Y1-Cr0-Y2-Y3 for both interlaced
* and progressive scan lines */
for (i = 0; i < plen; i += pgroup) {
*udp++ = p[0];
*ydp++ = p[1];
*ydp++ = p[2];
*vdp++ = p[3];
*ydp++ = p[4];
*ydp++ = p[5];
p += pgroup;
}
break;
}
default:
goto unknown_sampling;
}
next:
if (!cont)
break;
payload += length;
payload_len -= length;
}
2011-07-10 19:50:19 +00:00
gst_video_frame_unmap (&frame);
marker = gst_rtp_buffer_get_marker (&rtp);
2011-07-10 19:50:19 +00:00
gst_rtp_buffer_unmap (&rtp);
if (marker) {
GST_LOG_OBJECT (depayload, "marker, flushing frame");
outbuf = rtpvrawdepay->outbuf;
rtpvrawdepay->outbuf = NULL;
rtpvrawdepay->timestamp = -1;
}
return outbuf;
/* ERRORS */
unknown_sampling:
{
GST_ELEMENT_ERROR (depayload, STREAM, FORMAT,
(NULL), ("unimplemented sampling"));
2011-07-10 19:50:19 +00:00
gst_video_frame_unmap (&frame);
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
alloc_failed:
{
GST_WARNING_OBJECT (depayload, "failed to alloc output buffer");
2011-07-10 19:50:19 +00:00
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
invalid_frame:
{
GST_ERROR_OBJECT (depayload, "could not map video frame");
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
wrong_length:
{
GST_WARNING_OBJECT (depayload, "length not multiple of pgroup");
2011-07-10 19:50:19 +00:00
gst_video_frame_unmap (&frame);
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
short_packet:
{
GST_WARNING_OBJECT (depayload, "short packet");
2011-07-10 19:50:19 +00:00
gst_video_frame_unmap (&frame);
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
static gboolean
2011-11-11 11:25:01 +00:00
gst_rtp_vraw_depay_handle_event (GstRTPBaseDepayload * filter, GstEvent * event)
{
gboolean ret;
GstRtpVRawDepay *rtpvrawdepay;
rtpvrawdepay = GST_RTP_VRAW_DEPAY (filter);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
gst_rtp_vraw_depay_reset (rtpvrawdepay);
break;
default:
break;
}
ret =
2011-11-11 11:25:01 +00:00
GST_RTP_BASE_DEPAYLOAD_CLASS (parent_class)->handle_event (filter, event);
return ret;
}
static GstStateChangeReturn
gst_rtp_vraw_depay_change_state (GstElement * element,
GstStateChange transition)
{
GstRtpVRawDepay *rtpvrawdepay;
GstStateChangeReturn ret;
rtpvrawdepay = GST_RTP_VRAW_DEPAY (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_rtp_vraw_depay_reset (rtpvrawdepay);
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_rtp_vraw_depay_reset (rtpvrawdepay);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
}
gboolean
gst_rtp_vraw_depay_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "rtpvrawdepay",
GST_RANK_SECONDARY, GST_TYPE_RTP_VRAW_DEPAY);
}