Commit 454409da authored by Justin Kim's avatar Justin Kim

ahc2src: implement color_tone

Signed-off-by: Justin Kim's avatarJustin Kim <justin.kim@collabora.com>
parent a04142e4
......@@ -215,6 +215,119 @@ gst_ahc2_src_get_capabilities (GstPhotography * photo)
return caps;
}
static gboolean
gst_ahc2_src_get_color_tone_mode (GstPhotography * photo,
GstPhotographyColorToneMode * tone_mode)
{
GstAHC2Src *self = GST_AHC2_SRC (photo);
GstAHC2SrcPrivate *priv = GST_AHC2_SRC_GET_PRIVATE (self);
ACameraMetadata_const_entry entry;
g_return_val_if_fail (priv->capture_request != NULL, FALSE);
if (ACaptureRequest_getConstEntry (priv->capture_request,
ACAMERA_CONTROL_EFFECT_MODE, &entry) != ACAMERA_OK) {
GST_WARNING_OBJECT (self, "Failed to get EFFECT MODE");
return FALSE;
}
switch (entry.data.u8[0]) {
case ACAMERA_CONTROL_EFFECT_MODE_OFF:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL;
break;
case ACAMERA_CONTROL_EFFECT_MODE_MONO:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRAYSCALE;
break;
case ACAMERA_CONTROL_EFFECT_MODE_NEGATIVE:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_NEGATIVE;
break;
case ACAMERA_CONTROL_EFFECT_MODE_SOLARIZE:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_SOLARIZE;
break;
case ACAMERA_CONTROL_EFFECT_MODE_SEPIA:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_SEPIA;
break;
case ACAMERA_CONTROL_EFFECT_MODE_POSTERIZE:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_POSTERIZE;
break;
case ACAMERA_CONTROL_EFFECT_MODE_WHITEBOARD:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_WHITEBOARD;
break;
case ACAMERA_CONTROL_EFFECT_MODE_BLACKBOARD:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_BLACKBOARD;
break;
case ACAMERA_CONTROL_EFFECT_MODE_AQUA:
*tone_mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_AQUA;
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
static gboolean
gst_ahc2_src_set_color_tone_mode (GstPhotography * photo,
GstPhotographyColorToneMode tone_mode)
{
GstAHC2Src *self = GST_AHC2_SRC (photo);
GstAHC2SrcPrivate *priv = GST_AHC2_SRC_GET_PRIVATE (self);
guint8 mode;
g_return_val_if_fail (priv->capture_request != NULL, FALSE);
switch (tone_mode) {
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL:
mode = ACAMERA_CONTROL_EFFECT_MODE_OFF;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_SEPIA:
mode = ACAMERA_CONTROL_EFFECT_MODE_SEPIA;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_NEGATIVE:
mode = ACAMERA_CONTROL_EFFECT_MODE_NEGATIVE;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRAYSCALE:
mode = ACAMERA_CONTROL_EFFECT_MODE_MONO;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_SOLARIZE:
mode = ACAMERA_CONTROL_EFFECT_MODE_SOLARIZE;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_POSTERIZE:
mode = GST_PHOTOGRAPHY_COLOR_TONE_MODE_POSTERIZE;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_WHITEBOARD:
mode = ACAMERA_CONTROL_EFFECT_MODE_WHITEBOARD;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_BLACKBOARD:
mode = ACAMERA_CONTROL_EFFECT_MODE_BLACKBOARD;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_AQUA:
mode = ACAMERA_CONTROL_EFFECT_MODE_AQUA;
break;
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_NATURAL:
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_VIVID:
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_COLORSWAP:
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_OUT_OF_FOCUS:
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKY_BLUE:
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_GRASS_GREEN:
case GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKIN_WHITEN:
default:
GST_WARNING_OBJECT (self, "Unsupported color tone (%d)", tone_mode);
return FALSE;
}
ACameraCaptureSession_stopRepeating (priv->camera_capture_session);
ACaptureRequest_setEntry_u8 (priv->capture_request,
ACAMERA_CONTROL_EFFECT_MODE, 1, &mode);
ACameraCaptureSession_setRepeatingRequest (priv->camera_capture_session,
NULL, 1, &priv->capture_request, NULL);
return TRUE;
}
static void
gst_ahc2_src_set_autofocus (GstPhotography * photo, gboolean on)
{
......@@ -1120,6 +1233,11 @@ gst_ahc2_src_set_property (GObject * object,
case PROP_MAX_IMAGES:
priv->max_images = g_value_get_int (value);
break;
case PROP_COLOR_TONE_MODE: {
GstPhotographyColorToneMode tone = g_value_get_enum (value);
gst_ahc2_src_set_color_tone_mode (GST_PHOTOGRAPHY (self), tone);
break;
}
case PROP_EV_COMPENSATION: {
gfloat ev = g_value_get_float (value);
gst_ahc2_src_set_ev_compensation (GST_PHOTOGRAPHY (self), ev);
......@@ -1176,6 +1294,12 @@ gst_ahc2_src_get_property (GObject * object,
break;
}
case PROP_COLOR_TONE_MODE: {
GstPhotographyColorToneMode tone;
if (gst_ahc2_src_get_color_tone_mode (GST_PHOTOGRAPHY (self), &tone))
g_value_set_enum (value, tone);
break;
}
case PROP_EV_COMPENSATION: {
gfloat ev;
......@@ -1661,6 +1785,9 @@ gst_ahc2_src_photography_init (gpointer g_iface, gpointer iface_data)
iface->get_capabilities = gst_ahc2_src_get_capabilities;
iface->get_color_tone_mode = gst_ahc2_src_get_color_tone_mode;
iface->set_color_tone_mode = gst_ahc2_src_set_color_tone_mode;
iface->set_autofocus = gst_ahc2_src_set_autofocus;
iface->get_focus_mode = gst_ahc2_src_get_focus_mode;
iface->set_focus_mode = gst_ahc2_src_set_focus_mode;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment