2011-03-25 07:26:00 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2011> Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstplaysinkvideoconvert.h"
|
|
|
|
|
|
|
|
#include <gst/pbutils/pbutils.h>
|
|
|
|
#include <gst/gst-i18n-plugin.h>
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_play_sink_video_convert_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_play_sink_video_convert_debug
|
|
|
|
|
|
|
|
#define parent_class gst_play_sink_video_convert_parent_class
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstPlaySinkVideoConvert, gst_play_sink_video_convert,
|
2011-10-17 16:55:30 +00:00
|
|
|
GST_TYPE_PLAY_SINK_CONVERT_BIN);
|
2011-03-25 07:26:00 +00:00
|
|
|
|
|
|
|
static gboolean
|
2011-10-17 21:05:30 +00:00
|
|
|
gst_play_sink_video_convert_add_conversion_elements (GstPlaySinkVideoConvert *
|
|
|
|
self)
|
2011-03-25 07:26:00 +00:00
|
|
|
{
|
2011-10-17 21:05:30 +00:00
|
|
|
GstPlaySinkConvertBin *cbin = GST_PLAY_SINK_CONVERT_BIN (self);
|
2011-10-17 16:55:30 +00:00
|
|
|
GstElement *el, *prev = NULL;
|
|
|
|
|
|
|
|
el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
|
|
|
|
COLORSPACE, "conv");
|
|
|
|
if (el)
|
|
|
|
prev = el;
|
|
|
|
|
|
|
|
el = gst_play_sink_convert_bin_add_conversion_element_factory (cbin,
|
|
|
|
"videoscale", "scale");
|
|
|
|
if (el) {
|
|
|
|
/* Add black borders if necessary to keep the DAR */
|
|
|
|
g_object_set (el, "add-borders", TRUE, NULL);
|
|
|
|
if (prev) {
|
|
|
|
if (!gst_element_link_pads_full (prev, "src", el, "sink",
|
|
|
|
GST_PAD_LINK_CHECK_TEMPLATE_CAPS))
|
|
|
|
goto link_failed;
|
2011-03-25 07:26:00 +00:00
|
|
|
}
|
2011-10-17 16:55:30 +00:00
|
|
|
prev = el;
|
2011-03-25 07:26:00 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 16:55:30 +00:00
|
|
|
return TRUE;
|
2011-03-25 07:26:00 +00:00
|
|
|
|
|
|
|
link_failed:
|
2011-10-17 16:55:30 +00:00
|
|
|
return FALSE;
|
2011-03-25 07:26:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_sink_video_convert_class_init (GstPlaySinkVideoConvertClass * klass)
|
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_play_sink_video_convert_debug,
|
|
|
|
"playsinkvideoconvert", 0, "play bin");
|
|
|
|
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
|
|
|
gst_element_class_set_details_simple (gstelement_class,
|
|
|
|
"Player Sink Video Converter", "Video/Bin/Converter",
|
|
|
|
"Convenience bin for video conversion",
|
|
|
|
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_play_sink_video_convert_init (GstPlaySinkVideoConvert * self)
|
|
|
|
{
|
2011-10-17 16:55:30 +00:00
|
|
|
GstPlaySinkConvertBin *cbin = GST_PLAY_SINK_CONVERT_BIN (self);
|
|
|
|
cbin->audio = FALSE;
|
2011-10-17 21:05:30 +00:00
|
|
|
|
|
|
|
gst_play_sink_video_convert_add_conversion_elements (self);
|
|
|
|
gst_play_sink_convert_bin_cache_converter_caps (cbin);
|
2011-03-25 07:26:00 +00:00
|
|
|
}
|