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; }
/* Process a color balance command */ static void update_color_channel (const gchar *channel_name, gboolean increase, GstColorBalance *cb) { gdouble step; gint value; GstColorBalanceChannel *channel = NULL; const GList *channels, *l; /* Retrieve the list of channels and locate the requested one */ channels = gst_color_balance_list_channels (cb); for (l = channels; l != NULL; l = l->next) { GstColorBalanceChannel *tmp = (GstColorBalanceChannel *)l->data; if (g_strrstr (tmp->label, channel_name)) { channel = tmp; break; } } if (!channel) return; /* Change the channel's value */ step = 0.1 * (channel->max_value - channel->min_value); value = gst_color_balance_get_value (cb, channel); if (increase) { value = (gint)(value + step); if (value > channel->max_value) value = channel->max_value; } else { value = (gint)(value - step); if (value < channel->min_value) value = channel->min_value; } gst_color_balance_set_value (cb, channel, value); }
void empathy_video_src_set_channel (GstElement *src, EmpathyGstVideoSrcChannel channel, guint percent) { GstElement *color; GstColorBalance *balance; const GList *channels; GList *l; /* Find something supporting GstColorBalance */ color = gst_bin_get_by_interface (GST_BIN (src), GST_TYPE_COLOR_BALANCE); if (color == NULL) return; balance = GST_COLOR_BALANCE (color); channels = gst_color_balance_list_channels (balance); for (l = (GList *) channels; l != NULL; l = g_list_next (l)) { GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data); if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0) { gst_color_balance_set_value (balance, c, ((c->max_value - c->min_value) * percent)/100 + c->min_value); break; } } g_object_unref (color); }
void empathy_video_src_set_channel (GstElement *src, EmpathyGstVideoSrcChannel channel, guint percent) { GstColorBalance *balance; const GList *channels; GList *l; balance = dup_color_balance (src); if (balance == NULL) return; channels = gst_color_balance_list_channels (balance); for (l = (GList *) channels; l != NULL; l = g_list_next (l)) { GstColorBalanceChannel *c = GST_COLOR_BALANCE_CHANNEL (l->data); if (g_ascii_strcasecmp (c->label, channel_names[channel]) == 0) { gst_color_balance_set_value (balance, c, ((c->max_value - c->min_value) * percent)/100 + c->min_value); break; } } g_object_unref (balance); }
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; }
void gstreamer_set_color_balance(int channel, gdouble value) { if (color_balance_channel[channel] == NULL) return; gint v = color_balance_channel[channel]->min_value + value * 0.01 * (color_balance_channel[channel]->max_value - color_balance_channel[channel]->min_value); if (v != last_value_set[channel]) { gst_color_balance_set_value(GST_COLOR_BALANCE(color_balance_element), color_balance_channel[channel], v); last_value_set[channel] = v; } }
static void gst_gl_sink_bin_color_balance_set_value (GstColorBalance * balance, GstColorBalanceChannel * channel, gint value) { GstGLSinkBin *self = GST_GL_SINK_BIN (balance); GstColorBalance *balance_element = NULL; balance_element = GST_COLOR_BALANCE (gst_bin_get_by_interface (GST_BIN (self), GST_TYPE_COLOR_BALANCE)); if (balance_element) { gst_color_balance_set_value (balance_element, channel, value); gst_object_unref (balance_element); } }
static void run_options (char opt) { int res; switch (opt) { case 'f': { GstTuner *tuner = GST_TUNER (source); GstTunerChannel *channel; guint freq; channel = gst_tuner_get_channel (tuner); freq = gst_tuner_get_frequency (tuner, channel); printf ("\ntype the new frequency (current = %u) (-1 to cancel): ", freq); res = scanf ("%u", &freq); if (res != 1 || freq != -1) gst_tuner_set_frequency (tuner, channel, freq); } break; case 'n': { GstTuner *tuner = GST_TUNER (source); const GList *item, *list; const GstTunerNorm *current_norm; GstTunerNorm *norm = NULL; gint index, next_norm; list = gst_tuner_list_norms (tuner); current_norm = gst_tuner_get_norm (tuner); printf ("\nlist of norms:\n"); for (item = list, index = 0; item != NULL; item = item->next, ++index) { norm = item->data; if (current_norm == norm) { printf (" * %u - %s\n", index, norm->label); } else { printf (" %u - %s\n", index, norm->label); } } printf ("\ntype the number of norm you want (-1 to cancel): "); res = scanf ("%d", &next_norm); if (res != 1 || next_norm < 0) { break; } if (index <= next_norm) { printf ("Norm %d not available\n", next_norm); break; } for (item = list, index = 0; item != NULL && index <= next_norm; item = item->next, ++index) { norm = item->data; } if (norm) gst_tuner_set_norm (tuner, norm); } break; case 'i': { GstTuner *tuner = GST_TUNER (source); const GList *item, *list; const GstTunerChannel *current_channel; GstTunerChannel *channel = NULL; gint index, next_channel; list = gst_tuner_list_channels (tuner); current_channel = gst_tuner_get_channel (tuner); printf ("\nlist of inputs:\n"); for (item = list, index = 0; item != NULL; item = item->next, ++index) { channel = item->data; if (current_channel == channel) { printf (" * %u - %s\n", index, channel->label); } else { printf (" %u - %s\n", index, channel->label); } } printf ("\ntype the number of input you want (-1 to cancel): "); res = scanf ("%d", &next_channel); if (res != 1 || next_channel < 0) { break; } if (index <= next_channel) { printf ("Input %d not available\n", next_channel); break; } for (item = list, index = 0; item != NULL && index <= next_channel; item = item->next, ++index) { channel = item->data; } if (channel) gst_tuner_set_channel (tuner, channel); } break; case 'e': gst_element_set_state (pipeline, GST_STATE_NULL); g_main_loop_quit (loop); printf ("Bye\n"); g_thread_exit (0); break; case 'c': { GstColorBalance *balance = GST_COLOR_BALANCE (source); const GList *controls; GstColorBalanceChannel *channel; const GList *item; gint index, new_value; controls = gst_color_balance_list_channels (balance); printf ("\n"); if (controls == NULL) { printf ("There is no list of colorbalance controls\n"); goto done; } if (controls) { printf ("list of controls:\n"); for (item = controls, index = 0; item != NULL; item = item->next, ++index) { channel = item->data; printf (" %u - %s (%d - %d) = %d\n", index, channel->label, channel->min_value, channel->max_value, gst_color_balance_get_value (balance, channel)); } printf ("\ntype the number of color control you want (-1 to cancel): "); res = scanf ("%d", &new_value); if (res != 1 || new_value == -1) break; for (item = controls, index = 0; item != NULL && index <= new_value; item = item->next, ++index) { channel = item->data; } printf (" %u - %s (%d - %d) = %d, type the new value: ", index - 1, channel->label, channel->min_value, channel->max_value, gst_color_balance_get_value (balance, channel)); res = scanf ("%d", &new_value); if (res != 1 || new_value == -1) break; gst_color_balance_set_value (balance, channel, new_value); } } case 'v': { GstVideoOrientation *vidorient = GST_VIDEO_ORIENTATION (source); gboolean flip = FALSE; gint center = 0; printf ("\n"); if (gst_video_orientation_get_hflip (vidorient, &flip)) { gint new_value; printf ("Horizontal flip is %s\n", flip ? "on" : "off"); printf ("\ntype 1 to toggle (-1 to cancel): "); res = scanf ("%d", &new_value); if (res != 1 || new_value == 1) { flip = !flip; if (gst_video_orientation_set_hflip (vidorient, flip)) { gst_video_orientation_get_hflip (vidorient, &flip); printf ("Now horizontal flip is %s\n", flip ? "on" : "off"); } else { printf ("Error toggling horizontal flip\n"); } } else { } } else { printf ("Horizontal flip control not available\n"); } if (gst_video_orientation_get_vflip (vidorient, &flip)) { gint new_value; printf ("\nVertical flip is %s\n", flip ? "on" : "off"); printf ("\ntype 1 to toggle (-1 to cancel): "); res = scanf ("%d", &new_value); if (res != 1 || new_value == 1) { flip = !flip; if (gst_video_orientation_set_vflip (vidorient, flip)) { gst_video_orientation_get_vflip (vidorient, &flip); printf ("Now vertical flip is %s\n", flip ? "on" : "off"); } else { printf ("Error toggling vertical flip\n"); } } else { } } else { printf ("Vertical flip control not available\n"); } if (gst_video_orientation_get_hcenter (vidorient, ¢er)) { printf ("Horizontal center is %d\n", center); printf ("\ntype the new horizontal center value (-1 to cancel): "); res = scanf ("%d", ¢er); if (res != 1 || center != -1) { if (gst_video_orientation_set_hcenter (vidorient, center)) { gst_video_orientation_get_hcenter (vidorient, ¢er); printf ("Now horizontal center is %d\n", center); } else { printf ("Error setting horizontal center\n"); } } else { } } else { printf ("Horizontal center control not available\n"); } if (gst_video_orientation_get_vcenter (vidorient, ¢er)) { printf ("Vertical center is %d\n", center); printf ("\ntype the new vertical center value (-1 to cancel): "); res = scanf ("%d", ¢er); if (res != 1 || center != -1) { if (gst_video_orientation_set_vcenter (vidorient, center)) { gst_video_orientation_get_vcenter (vidorient, ¢er); printf ("Now vertical center is %d\n", center); } else { printf ("Error setting vertical center\n"); } } else { } } else { printf ("Vertical center control not available\n"); } } break; break; default: if (opt != 10) printf ("error: invalid option %c", opt); break; } done: return; }
void ColorBalance::setValue(const ColorBalanceChannelPtr & channel, int value) { gst_color_balance_set_value(object<GstColorBalance>(), channel, value); }