void CameraBinImageProcessing::updateColorBalanceValues() { if (!GST_IS_COLOR_BALANCE(m_session->cameraBin())) { // Camerabin doesn't implement gstcolorbalance interface return; } GstColorBalance *balance = GST_COLOR_BALANCE(m_session->cameraBin()); const GList *controls = gst_color_balance_list_channels(balance); const GList *item; GstColorBalanceChannel *channel; gint cur_value; for (item = controls; item; item = g_list_next (item)) { channel = (GstColorBalanceChannel *)item->data; cur_value = gst_color_balance_get_value (balance, channel); if (!g_ascii_strcasecmp (channel->label, "brightness")) { m_values[QCameraImageProcessingControl::Brightness] = cur_value; } else if (!g_ascii_strcasecmp (channel->label, "contrast")) { m_values[QCameraImageProcessingControl::Contrast] = cur_value; } else if (!g_ascii_strcasecmp (channel->label, "saturation")) { m_values[QCameraImageProcessingControl::Saturation] = cur_value; } } }
bool CameraBinImageProcessing::setColorBalanceValue(const QString& channel, int value) { if (!GST_IS_COLOR_BALANCE(m_session->cameraBin())) { // Camerabin doesn't implement gstcolorbalance interface return false; } GstColorBalance *balance = GST_COLOR_BALANCE(m_session->cameraBin()); const GList *controls = gst_color_balance_list_channels(balance); const GList *item; GstColorBalanceChannel *colorBalanceChannel; for (item = controls; item; item = g_list_next (item)) { colorBalanceChannel = (GstColorBalanceChannel *)item->data; if (!g_ascii_strcasecmp (colorBalanceChannel->label, channel.toAscii())) { gst_color_balance_set_value (balance, colorBalanceChannel, value); return true; } } return false; }
void CameraBinImageProcessing::updateColorBalanceValues() { if (!GST_IS_COLOR_BALANCE(m_session->cameraBin())) { // Camerabin doesn't implement gstcolorbalance interface return; } GstColorBalance *balance = GST_COLOR_BALANCE(m_session->cameraBin()); const GList *controls = gst_color_balance_list_channels(balance); const GList *item; GstColorBalanceChannel *channel; gint cur_value; qreal scaledValue = 0; for (item = controls; item; item = g_list_next (item)) { channel = (GstColorBalanceChannel *)item->data; cur_value = gst_color_balance_get_value (balance, channel); //map the [min_value..max_value] range to [-1.0 .. 1.0] if (channel->min_value != channel->max_value) { scaledValue = qreal(cur_value - channel->min_value) / (channel->max_value - channel->min_value) * 2 - 1; } if (!g_ascii_strcasecmp (channel->label, "brightness")) { m_values[QCameraImageProcessingControl::BrightnessAdjustment] = scaledValue; } else if (!g_ascii_strcasecmp (channel->label, "contrast")) { m_values[QCameraImageProcessingControl::ContrastAdjustment] = scaledValue; } else if (!g_ascii_strcasecmp (channel->label, "saturation")) { m_values[QCameraImageProcessingControl::SaturationAdjustment] = scaledValue; } } }
bool CameraBinImageProcessing::setColorBalanceValue(const QString& channel, qreal value) { if (!GST_IS_COLOR_BALANCE(m_session->cameraBin())) { // Camerabin doesn't implement gstcolorbalance interface return false; } GstColorBalance *balance = GST_COLOR_BALANCE(m_session->cameraBin()); const GList *controls = gst_color_balance_list_channels(balance); const GList *item; GstColorBalanceChannel *colorBalanceChannel; for (item = controls; item; item = g_list_next (item)) { colorBalanceChannel = (GstColorBalanceChannel *)item->data; if (!g_ascii_strcasecmp (colorBalanceChannel->label, channel.toLatin1())) { //map the [-1.0 .. 1.0] range to [min_value..max_value] gint scaledValue = colorBalanceChannel->min_value + qRound( (value+1.0)/2.0 * (colorBalanceChannel->max_value - colorBalanceChannel->min_value)); gst_color_balance_set_value (balance, colorBalanceChannel, scaledValue); return true; } } return false; }
/** * gst_color_balance_value_changed: * @balance: A #GstColorBalance instance * @channel: A #GstColorBalanceChannel whose value has changed * @value: The new value of the channel * * A helper function called by implementations of the GstColorBalance * interface. It fires the #GstColorBalance::value-changed signal on the * instance, and the #GstColorBalanceChannel::value-changed signal on the * channel object. */ void gst_color_balance_value_changed (GstColorBalance * balance, GstColorBalanceChannel * channel, gint value) { g_return_if_fail (GST_IS_COLOR_BALANCE (balance)); g_signal_emit (G_OBJECT (balance), gst_color_balance_signals[VALUE_CHANGED], 0, channel, value); g_signal_emit_by_name (G_OBJECT (channel), "value_changed", value); }
int gstreamer_prepare_color_balance() { if (color_balance_element) gst_object_unref(color_balance_element); color_balance_element = find_color_balance_element(); if (color_balance_element == NULL) return 0; if (!GST_IS_COLOR_BALANCE(color_balance_element)) return 0; GList *channel_list = gst_color_balance_list_channels( GST_COLOR_BALANCE(color_balance_element)); if (channel_list == NULL) return 0; for (int i = 0; i < 4; i++) color_balance_channel[i] = NULL; channel_list = g_list_first(channel_list); while (channel_list) { GstColorBalanceChannel *channel = channel_list->data; if (strcasestr(channel->label, "BRIGHTNESS") != NULL) color_balance_channel[CHANNEL_BRIGHTNESS] = channel; else if (strcasestr(channel->label, "CONTRAST") != NULL) color_balance_channel[CHANNEL_CONTRAST] = channel; else if (strcasestr(channel->label, "HUE") != NULL) color_balance_channel[CHANNEL_HUE] = channel; else if (strcasestr(channel->label, "SATURATION") != NULL) color_balance_channel[CHANNEL_SATURATION] = channel; else printf("gstplay: Unknown color balance channel %s detected.\n", channel->label); channel_list = g_list_next(channel_list); } int r = 0; for (int i = 0; i < 4; i++) { if (color_balance_channel[i] != NULL) { // printf("gstplay: Color balance channel %s found.\n", // color_balance_channel[i]->label); if (find_xvimagesink() && strncmp(color_balance_channel[i]->label, "XV_", 3) != 0) { char *s = g_malloc(strlen(color_balance_channel[i]->label) + 4); sprintf(s, "XV_%s", color_balance_channel[i]->label); g_free(color_balance_channel[i]->label); color_balance_channel[i]->label = s; printf("gstplay: Fixing mismatched xvimagesink color balance channel name to %s.\n", s); } gint v = gst_color_balance_get_value( GST_COLOR_BALANCE(color_balance_element), color_balance_channel[i]); r |= 1 << i; last_value_set[i] = v; } } return r; }
bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingControl::ProcessingParameter parameter, const QVariant &value) const { switch (parameter) { case ContrastAdjustment: case BrightnessAdjustment: case SaturationAdjustment: { const bool isGstColorBalanceValueSupported = GST_IS_COLOR_BALANCE(m_session->cameraBin()) && qAbs(value.toReal()) <= 1.0; #ifdef USE_V4L if (!isGstColorBalanceValueSupported) return m_v4lImageControl->isParameterValueSupported(parameter, value); #endif return isGstColorBalanceValueSupported; } case SharpeningAdjustment: { #ifdef USE_V4L return m_v4lImageControl->isParameterValueSupported(parameter, value); #else return false; #endif } case WhiteBalancePreset: { const QCameraImageProcessing::WhiteBalanceMode mode = value.value<QCameraImageProcessing::WhiteBalanceMode>(); const bool isPhotographyWhiteBalanceSupported = isWhiteBalanceModeSupported(mode); #ifdef USE_V4L if (!isPhotographyWhiteBalanceSupported) return m_v4lImageControl->isParameterValueSupported(parameter, value); #endif return isPhotographyWhiteBalanceSupported; } case ColorTemperature: { #ifdef USE_V4L return m_v4lImageControl->isParameterValueSupported(parameter, value); #else return false; #endif } case ColorFilter: { const QCameraImageProcessing::ColorFilter filter = value.value<QCameraImageProcessing::ColorFilter>(); #ifdef HAVE_GST_PHOTOGRAPHY return m_filterMap.contains(filter); #else return filter == QCameraImageProcessing::ColorFilterNone; #endif } default: break; } return false; }
/** * gst_color_balance_get_balance_type: * @balance: The #GstColorBalance implementation * * Get the #GstColorBalanceType of this implementation. * * Returns: A the #GstColorBalanceType. */ GstColorBalanceType gst_color_balance_get_balance_type (GstColorBalance * balance) { GstColorBalanceInterface *iface; g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), GST_COLOR_BALANCE_SOFTWARE); iface = GST_COLOR_BALANCE_GET_INTERFACE (balance); g_return_val_if_fail (iface->get_balance_type != NULL, GST_COLOR_BALANCE_SOFTWARE); return iface->get_balance_type (balance); }
/** * gst_color_balance_list_channels: * @balance: A #GstColorBalance instance * * Retrieve a list of the available channels. * * Returns: A GList containing pointers to #GstColorBalanceChannel objects. * The list is owned by the #GstColorBalance instance and must not * be freed. */ const GList * gst_color_balance_list_channels (GstColorBalance * balance) { GstColorBalanceInterface *iface; g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), NULL); iface = GST_COLOR_BALANCE_GET_INTERFACE (balance); if (iface->list_channels) { return iface->list_channels (balance); } return NULL; }
/** * gst_color_balance_get_value: * @balance: A #GstColorBalance instance * @channel: A #GstColorBalanceChannel instance * * Retrieve the current value of the indicated channel, between min_value * and max_value. * * See Also: The #GstColorBalanceChannel.min_value and * #GstColorBalanceChannel.max_value members of the * #GstColorBalanceChannel object. * * Returns: The current value of the channel. */ gint gst_color_balance_get_value (GstColorBalance * balance, GstColorBalanceChannel * channel) { GstColorBalanceInterface *iface; g_return_val_if_fail (GST_IS_COLOR_BALANCE (balance), 0); iface = GST_COLOR_BALANCE_GET_INTERFACE (balance); if (iface->get_value) { return iface->get_value (balance, channel); } return channel->min_value; }
bool CameraBinImageProcessing::isParameterSupported(QCameraImageProcessingControl::ProcessingParameter parameter) const { #ifdef HAVE_GST_PHOTOGRAPHY if (parameter == QCameraImageProcessingControl::WhiteBalancePreset || parameter == QCameraImageProcessingControl::ColorFilter) return m_session->photography(); #endif if (parameter == QCameraImageProcessingControl::Contrast || parameter == QCameraImageProcessingControl::Brightness || parameter == QCameraImageProcessingControl::Saturation) { return GST_IS_COLOR_BALANCE(m_session->cameraBin()); } return false; }
/** * gst_base_camera_src_get_colorbalance: * @self: the camerasrc bin * * Get object implementing colorbalance interface, if there is one. Otherwise * returns NULL. */ GstColorBalance * gst_base_camera_src_get_color_balance (GstBaseCameraSrc * self) { GstElement *elem; if (GST_IS_COLOR_BALANCE (self)) { elem = GST_ELEMENT (self); } else { elem = gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_COLOR_BALANCE); } if (elem) { return GST_COLOR_BALANCE (self); } return NULL; }
static GstColorBalance * dup_color_balance (GstElement *src) { GstElement *color; /* Find something supporting GstColorBalance */ color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); if (color == NULL) return NULL; /* colorbalance is wrapped by GstImplementsInterface, we * need to check if it is actually supported for this instance * in its current state before trying to use it */ if (!GST_IS_COLOR_BALANCE (color)) { g_object_unref (color); return NULL; } return GST_COLOR_BALANCE (color); }
bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingControl::ProcessingParameter parameter, const QVariant &value) const { switch (parameter) { case ContrastAdjustment: case BrightnessAdjustment: case SaturationAdjustment: return GST_IS_COLOR_BALANCE(m_session->cameraBin()) && qAbs(value.toReal()) <= 1.0; case WhiteBalancePreset: return isWhiteBalanceModeSupported(value.value<QCameraImageProcessing::WhiteBalanceMode>()); case ColorFilter: { const QCameraImageProcessing::ColorFilter filter = value.value<QCameraImageProcessing::ColorFilter>(); #ifdef HAVE_GST_PHOTOGRAPHY return m_filterMap.contains(filter); #else return filter == QCameraImageProcessing::ColorFilterNone; #endif } default: break; } return false; }