Commit 493a786a authored by Justin Kim's avatar Justin Kim

ahc2src: implement scene_mode

Signed-off-by: Justin Kim's avatarJustin Kim <justin.kim@collabora.com>
parent 454409da
......@@ -630,6 +630,162 @@ gst_ahc2_src_set_flash_mode (GstPhotography * photo,
return TRUE;
}
static gboolean
gst_ahc2_src_get_scene_mode (GstPhotography * photo,
GstPhotographySceneMode * scene_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_SCENE_MODE, &entry) != ACAMERA_OK) {
GST_ERROR_OBJECT (self, "Failed to get SCENE MODE");
return FALSE;
}
switch (entry.data.u8[0]) {
case ACAMERA_CONTROL_SCENE_MODE_DISABLED:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_MANUAL;
break;
case ACAMERA_CONTROL_SCENE_MODE_ACTION:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_ACTION;
break;
case ACAMERA_CONTROL_SCENE_MODE_PORTRAIT:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT;
break;
case ACAMERA_CONTROL_SCENE_MODE_LANDSCAPE:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE;
break;
case ACAMERA_CONTROL_SCENE_MODE_NIGHT:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_NIGHT;
break;
case ACAMERA_CONTROL_SCENE_MODE_NIGHT_PORTRAIT:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_NIGHT_PORTRAIT;
break;
case ACAMERA_CONTROL_SCENE_MODE_THEATRE:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_THEATRE;
break;
case ACAMERA_CONTROL_SCENE_MODE_BEACH:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_BEACH;
break;
case ACAMERA_CONTROL_SCENE_MODE_SNOW:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_SNOW;
break;
case ACAMERA_CONTROL_SCENE_MODE_SUNSET:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_SUNSET;
break;
case ACAMERA_CONTROL_SCENE_MODE_STEADYPHOTO:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_STEADY_PHOTO;
break;
case ACAMERA_CONTROL_SCENE_MODE_FIREWORKS:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_FIREWORKS;
break;
case ACAMERA_CONTROL_SCENE_MODE_SPORTS:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_SPORT;
break;
case ACAMERA_CONTROL_SCENE_MODE_PARTY:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_PARTY;
break;
case ACAMERA_CONTROL_SCENE_MODE_CANDLELIGHT:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_CANDLELIGHT;
break;
case ACAMERA_CONTROL_SCENE_MODE_BARCODE:
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_BARCODE;
break;
case ACAMERA_CONTROL_SCENE_MODE_HDR:
case ACAMERA_CONTROL_SCENE_MODE_FACE_PRIORITY:
GST_WARNING_OBJECT (self,
"Device returns scene mode (%d), but no proper interface is defined", entry.data.u8[0]);
*scene_mode = GST_PHOTOGRAPHY_SCENE_MODE_MANUAL;
break;
default:
g_assert_not_reached ();
break;
}
return TRUE;
}
static gboolean
gst_ahc2_src_set_scene_mode (GstPhotography * photo,
GstPhotographySceneMode scene_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 (scene_mode) {
case GST_PHOTOGRAPHY_SCENE_MODE_MANUAL:
mode = ACAMERA_CONTROL_SCENE_MODE_DISABLED;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT:
mode = ACAMERA_CONTROL_SCENE_MODE_PORTRAIT;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE:
mode = ACAMERA_CONTROL_SCENE_MODE_LANDSCAPE;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_SPORT:
mode = ACAMERA_CONTROL_SCENE_MODE_SPORTS;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_NIGHT:
mode = ACAMERA_CONTROL_SCENE_MODE_NIGHT;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_ACTION:
mode = ACAMERA_CONTROL_SCENE_MODE_ACTION;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_NIGHT_PORTRAIT:
mode = ACAMERA_CONTROL_SCENE_MODE_NIGHT_PORTRAIT;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_THEATRE:
mode = ACAMERA_CONTROL_SCENE_MODE_THEATRE;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_BEACH:
mode = ACAMERA_CONTROL_SCENE_MODE_BEACH;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_SNOW:
mode = ACAMERA_CONTROL_SCENE_MODE_SNOW;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_SUNSET:
mode = ACAMERA_CONTROL_SCENE_MODE_SUNSET;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_STEADY_PHOTO:
mode = ACAMERA_CONTROL_SCENE_MODE_STEADYPHOTO;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_FIREWORKS:
mode = ACAMERA_CONTROL_SCENE_MODE_FIREWORKS;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_PARTY:
mode = ACAMERA_CONTROL_SCENE_MODE_PARTY;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_CANDLELIGHT:
mode = ACAMERA_CONTROL_SCENE_MODE_CANDLELIGHT;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_BARCODE:
mode = ACAMERA_CONTROL_SCENE_MODE_BARCODE;
break;
case GST_PHOTOGRAPHY_SCENE_MODE_AUTO:
case GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP:
default:
GST_WARNING_OBJECT (self, "Unsupported scene mode (%d)", scene_mode);
return FALSE;
}
ACameraCaptureSession_stopRepeating (priv->camera_capture_session);
ACaptureRequest_setEntry_u8 (priv->capture_request,
ACAMERA_CONTROL_SCENE_MODE, 1, &mode);
ACameraCaptureSession_setRepeatingRequest (priv->camera_capture_session,
NULL, 1, &priv->capture_request, NULL);
return TRUE;
}
static gboolean
gst_ahc2_src_get_white_balance_mode (GstPhotography * photo,
GstPhotographyWhiteBalanceMode * mode)
......@@ -1243,6 +1399,11 @@ gst_ahc2_src_set_property (GObject * object,
gst_ahc2_src_set_ev_compensation (GST_PHOTOGRAPHY (self), ev);
break;
}
case PROP_SCENE_MODE: {
GstPhotographySceneMode scene = g_value_get_enum (value);
gst_ahc2_src_set_scene_mode (GST_PHOTOGRAPHY (self), scene);
break;
}
case PROP_WHITE_BALANCE_MODE: {
GstPhotographyWhiteBalanceMode wb = g_value_get_enum (value);
gst_ahc2_src_set_white_balance_mode (GST_PHOTOGRAPHY (self), wb);
......@@ -1326,6 +1487,12 @@ gst_ahc2_src_get_property (GObject * object,
g_value_set_enum (value, focus);
break;
}
case PROP_SCENE_MODE: {
GstPhotographySceneMode scene;
if (gst_ahc2_src_get_scene_mode (GST_PHOTOGRAPHY (self), &scene))
g_value_set_enum (value, scene);
break;
}
case PROP_ZOOM: {
gfloat zoom;
if (gst_ahc2_src_get_zoom (GST_PHOTOGRAPHY (self), &zoom))
......@@ -1795,6 +1962,9 @@ gst_ahc2_src_photography_init (gpointer g_iface, gpointer iface_data)
iface->get_flash_mode = gst_ahc2_src_get_flash_mode;
iface->set_flash_mode = gst_ahc2_src_set_flash_mode;
iface->get_scene_mode = gst_ahc2_src_get_scene_mode;
iface->set_scene_mode = gst_ahc2_src_set_scene_mode;
iface->get_white_balance_mode = gst_ahc2_src_get_white_balance_mode;
iface->set_white_balance_mode = gst_ahc2_src_set_white_balance_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