|
Packit |
971217 |
/* GStreamer Color Balance
|
|
Packit |
971217 |
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* colorbalance.c: image color balance interface design
|
|
Packit |
971217 |
* virtual class function wrappers
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
971217 |
* modify it under the terms of the GNU Library General Public
|
|
Packit |
971217 |
* License as published by the Free Software Foundation; either
|
|
Packit |
971217 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
971217 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
971217 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
971217 |
* Library General Public License for more details.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* You should have received a copy of the GNU Library General Public
|
|
Packit |
971217 |
* License along with this library; if not, write to the
|
|
Packit |
971217 |
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
Packit |
971217 |
* Boston, MA 02110-1301, USA.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
971217 |
#include "config.h"
|
|
Packit |
971217 |
#endif
|
|
Packit |
971217 |
|
|
Packit |
971217 |
#include "colorbalance.h"
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* SECTION:gstcolorbalance
|
|
Packit |
971217 |
* @title: GstColorBalance
|
|
Packit |
971217 |
* @short_description: Interface for adjusting color balance settings
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* This interface is implemented by elements which can perform some color
|
|
Packit |
971217 |
* balance operation on video frames they process. For example, modifying
|
|
Packit |
971217 |
* the brightness, contrast, hue or saturation.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Example elements are 'xvimagesink' and 'colorbalance'
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* FIXME 0.11: check if we need to add API for sometimes-supportedness
|
|
Packit |
971217 |
* (aka making up for GstImplementsInterface removal) */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* FIXME 0.11: replace signals with messages (+ make API thread-safe) */
|
|
Packit |
971217 |
|
|
Packit |
971217 |
enum
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
VALUE_CHANGED,
|
|
Packit |
971217 |
LAST_SIGNAL
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void gst_color_balance_base_init (GstColorBalanceInterface * iface);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static guint gst_color_balance_signals[LAST_SIGNAL] = { 0 };
|
|
Packit |
971217 |
|
|
Packit |
971217 |
GType
|
|
Packit |
971217 |
gst_color_balance_get_type (void)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
static GType gst_color_balance_type = 0;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!gst_color_balance_type) {
|
|
Packit |
971217 |
static const GTypeInfo gst_color_balance_info = {
|
|
Packit |
971217 |
sizeof (GstColorBalanceInterface),
|
|
Packit |
971217 |
(GBaseInitFunc) gst_color_balance_base_init,
|
|
Packit |
971217 |
NULL,
|
|
Packit |
971217 |
NULL,
|
|
Packit |
971217 |
NULL,
|
|
Packit |
971217 |
NULL,
|
|
Packit |
971217 |
0,
|
|
Packit |
971217 |
0,
|
|
Packit |
971217 |
NULL,
|
|
Packit |
971217 |
};
|
|
Packit |
971217 |
|
|
Packit |
971217 |
gst_color_balance_type = g_type_register_static (G_TYPE_INTERFACE,
|
|
Packit |
971217 |
"GstColorBalance", &gst_color_balance_info, 0);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return gst_color_balance_type;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
static void
|
|
Packit |
971217 |
gst_color_balance_base_init (GstColorBalanceInterface * iface)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
static gboolean initialized = FALSE;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (!initialized) {
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* GstColorBalance::value-changed:
|
|
Packit |
971217 |
* @colorbalance: The GstColorBalance instance
|
|
Packit |
971217 |
* @channel: The #GstColorBalanceChannel
|
|
Packit |
971217 |
* @value: The new value
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Fired when the value of the indicated channel has changed.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
gst_color_balance_signals[VALUE_CHANGED] =
|
|
Packit |
971217 |
g_signal_new ("value-changed",
|
|
Packit |
971217 |
GST_TYPE_COLOR_BALANCE, G_SIGNAL_RUN_LAST,
|
|
Packit |
971217 |
G_STRUCT_OFFSET (GstColorBalanceInterface, value_changed),
|
|
Packit |
971217 |
NULL, NULL, NULL,
|
|
Packit |
971217 |
G_TYPE_NONE, 2, GST_TYPE_COLOR_BALANCE_CHANNEL, G_TYPE_INT);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
initialized = TRUE;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/* default virtual functions */
|
|
Packit |
971217 |
iface->list_channels = NULL;
|
|
Packit |
971217 |
iface->set_value = NULL;
|
|
Packit |
971217 |
iface->get_value = NULL;
|
|
Packit |
971217 |
iface->get_balance_type = NULL;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* gst_color_balance_list_channels:
|
|
Packit |
971217 |
* @balance: A #GstColorBalance instance
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Retrieve a list of the available channels.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Returns: (element-type GstColorBalanceChannel) (transfer none): A
|
|
Packit |
971217 |
* GList containing pointers to #GstColorBalanceChannel
|
|
Packit |
971217 |
* objects. The list is owned by the #GstColorBalance
|
|
Packit |
971217 |
* instance and must not be freed.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
const GList *
|
|
Packit |
971217 |
gst_color_balance_list_channels (GstColorBalance * balance)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstColorBalanceInterface *iface;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), NULL);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (iface->list_channels) {
|
|
Packit |
971217 |
return iface->list_channels (balance);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return NULL;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* gst_color_balance_set_value:
|
|
Packit |
971217 |
* @balance: A #GstColorBalance instance
|
|
Packit |
971217 |
* @channel: A #GstColorBalanceChannel instance
|
|
Packit |
971217 |
* @value: The new value for the channel.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Sets the current value of the channel to the passed value, which must
|
|
Packit |
971217 |
* be between min_value and max_value.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* See Also: The #GstColorBalanceChannel.min_value and
|
|
Packit |
971217 |
* #GstColorBalanceChannel.max_value members of the
|
|
Packit |
971217 |
* #GstColorBalanceChannel object.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
void
|
|
Packit |
971217 |
gst_color_balance_set_value (GstColorBalance * balance,
|
|
Packit |
971217 |
GstColorBalanceChannel * channel, gint value)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstColorBalanceInterface *iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (iface->set_value) {
|
|
Packit |
971217 |
iface->set_value (balance, channel, value);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* gst_color_balance_get_value:
|
|
Packit |
971217 |
* @balance: A #GstColorBalance instance
|
|
Packit |
971217 |
* @channel: A #GstColorBalanceChannel instance
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Retrieve the current value of the indicated channel, between min_value
|
|
Packit |
971217 |
* and max_value.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* See Also: The #GstColorBalanceChannel.min_value and
|
|
Packit |
971217 |
* #GstColorBalanceChannel.max_value members of the
|
|
Packit |
971217 |
* #GstColorBalanceChannel object.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Returns: The current value of the channel.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
gint
|
|
Packit |
971217 |
gst_color_balance_get_value (GstColorBalance * balance,
|
|
Packit |
971217 |
GstColorBalanceChannel * channel)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstColorBalanceInterface *iface;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), 0);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
if (iface->get_value) {
|
|
Packit |
971217 |
return iface->get_value (balance, channel);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return channel->min_value;
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* gst_color_balance_get_balance_type:
|
|
Packit |
971217 |
* @balance: The #GstColorBalance implementation
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Get the #GstColorBalanceType of this implementation.
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* Returns: A the #GstColorBalanceType.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
GstColorBalanceType
|
|
Packit |
971217 |
gst_color_balance_get_balance_type (GstColorBalance * balance)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
GstColorBalanceInterface *iface;
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance),
|
|
Packit |
971217 |
GST_COLOR_BALANCE_SOFTWARE);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
iface = GST_COLOR_BALANCE_GET_INTERFACE (balance);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_return_val_if_fail (iface->get_balance_type != NULL,
|
|
Packit |
971217 |
GST_COLOR_BALANCE_SOFTWARE);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
return iface->get_balance_type (balance);
|
|
Packit |
971217 |
}
|
|
Packit |
971217 |
|
|
Packit |
971217 |
/**
|
|
Packit |
971217 |
* gst_color_balance_value_changed:
|
|
Packit |
971217 |
* @balance: A #GstColorBalance instance
|
|
Packit |
971217 |
* @channel: A #GstColorBalanceChannel whose value has changed
|
|
Packit |
971217 |
* @value: The new value of the channel
|
|
Packit |
971217 |
*
|
|
Packit |
971217 |
* A helper function called by implementations of the GstColorBalance
|
|
Packit |
971217 |
* interface. It fires the #GstColorBalance::value-changed signal on the
|
|
Packit |
971217 |
* instance, and the #GstColorBalanceChannel::value-changed signal on the
|
|
Packit |
971217 |
* channel object.
|
|
Packit |
971217 |
*/
|
|
Packit |
971217 |
void
|
|
Packit |
971217 |
gst_color_balance_value_changed (GstColorBalance * balance,
|
|
Packit |
971217 |
GstColorBalanceChannel * channel, gint value)
|
|
Packit |
971217 |
{
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_return_if_fail (GST_IS_COLOR_BALANCE (balance));
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_signal_emit (G_OBJECT (balance),
|
|
Packit |
971217 |
gst_color_balance_signals[VALUE_CHANGED], 0, channel, value);
|
|
Packit |
971217 |
|
|
Packit |
971217 |
g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value);
|
|
Packit |
971217 |
}
|