rpicamsrc: Implement a bunch of the raspivid command-line params

Add properties for controlling various parts of the capture
This commit is contained in:
Jan Schmidt 2013-10-13 17:46:07 +11:00 committed by Tim-Philipp Müller
parent 42729b92f0
commit 5f871311c1
4 changed files with 336 additions and 5 deletions

View file

@ -0,0 +1,40 @@
/*** BEGIN file-header ***/
#include "gstrpicam-enum-types.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
#include "@filename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static GType the_type = 0;
if (the_type == 0)
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@,
"@VALUENAME@",
"@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
the_type = g_@type@_register_static (
g_intern_static_string ("@EnumName@"),
values);
}
return the_type;
}
/*** END value-tail ***/

View file

@ -0,0 +1,26 @@
/*** BEGIN file-header ***/
#ifndef __GSTRPICAM_ENUM_TYPES_H__
#define __GSTRPICAM_ENUM_TYPES_H__
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* Enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN enumeration-production ***/
#define GST_RPI_CAM_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
GType @enum_name@_get_type (void) G_GNUC_CONST;
/*** END enumeration-production ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* __GSTRPICAM_ENUM_TYPES_H__ */
/*** END file-tail ***/

View file

@ -0,0 +1,71 @@
#include "interface/mmal/util/mmal_util_params.h"
#include "interface/mmal/mmal_parameters_camera.h"
typedef enum {
GST_RPI_CAM_SRC_EXPOSURE_MODE_OFF = MMAL_PARAM_EXPOSUREMODE_OFF,
GST_RPI_CAM_SRC_EXPOSURE_MODE_AUTO = MMAL_PARAM_EXPOSUREMODE_AUTO,
GST_RPI_CAM_SRC_EXPOSURE_MODE_NIGHT = MMAL_PARAM_EXPOSUREMODE_NIGHT,
GST_RPI_CAM_SRC_EXPOSURE_MODE_NIGHTPREVIEW = MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
GST_RPI_CAM_SRC_EXPOSURE_MODE_BACKLIGHT = MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
GST_RPI_CAM_SRC_EXPOSURE_MODE_SPOTLIGHT = MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
GST_RPI_CAM_SRC_EXPOSURE_MODE_SPORTS = MMAL_PARAM_EXPOSUREMODE_SPORTS,
GST_RPI_CAM_SRC_EXPOSURE_MODE_SNOW = MMAL_PARAM_EXPOSUREMODE_SNOW,
GST_RPI_CAM_SRC_EXPOSURE_MODE_BEACH = MMAL_PARAM_EXPOSUREMODE_BEACH,
GST_RPI_CAM_SRC_EXPOSURE_MODE_VERYLONG = MMAL_PARAM_EXPOSUREMODE_VERYLONG,
GST_RPI_CAM_SRC_EXPOSURE_MODE_FIXEDFPS = MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
GST_RPI_CAM_SRC_EXPOSURE_MODE_ANTISHAKE = MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
GST_RPI_CAM_SRC_EXPOSURE_MODE_FIREWORKS = MMAL_PARAM_EXPOSUREMODE_FIREWORKS
} GstRpiCamSrcExposureMode;
typedef enum {
GST_RPI_CAM_SRC_EXPOSURE_METERING_MODE_AVERAGE = MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
GST_RPI_CAM_SRC_EXPOSURE_METERING_MODE_SPOT = MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
GST_RPI_CAM_SRC_EXPOSURE_METERING_MODE_BACKLIST = MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
GST_RPI_CAM_SRC_EXPOSURE_METERING_MODE_MATRIX = MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX
} GstRpiCamSrcExposureMeteringMode;
typedef enum {
GST_RPI_CAM_SRC_AWB_MODE_OFF = MMAL_PARAM_AWBMODE_OFF,
GST_RPI_CAM_SRC_AWB_MODE_AUTO = MMAL_PARAM_AWBMODE_AUTO,
GST_RPI_CAM_SRC_AWB_MODE_SUNLIGHT = MMAL_PARAM_AWBMODE_SUNLIGHT,
GST_RPI_CAM_SRC_AWB_MODE_CLOUDY = MMAL_PARAM_AWBMODE_CLOUDY,
GST_RPI_CAM_SRC_AWB_MODE_SHADE = MMAL_PARAM_AWBMODE_SHADE,
GST_RPI_CAM_SRC_AWB_MODE_TUNGSTEN = MMAL_PARAM_AWBMODE_TUNGSTEN,
GST_RPI_CAM_SRC_AWB_MODE_FLUORESCENT = MMAL_PARAM_AWBMODE_FLUORESCENT,
GST_RPI_CAM_SRC_AWB_MODE_INCANDESCENT = MMAL_PARAM_AWBMODE_INCANDESCENT,
GST_RPI_CAM_SRC_AWB_MODE_FLASH = MMAL_PARAM_AWBMODE_FLASH,
GST_RPI_CAM_SRC_AWB_MODE_HORIZON = MMAL_PARAM_AWBMODE_HORIZON
} GstRpiCamSrcAWBMode;
typedef enum {
GST_RPI_CAM_SRC_IMAGEFX_NONE = MMAL_PARAM_IMAGEFX_NONE,
GST_RPI_CAM_SRC_IMAGEFX_NEGATIVE = MMAL_PARAM_IMAGEFX_NEGATIVE,
GST_RPI_CAM_SRC_IMAGEFX_SOLARIZE = MMAL_PARAM_IMAGEFX_SOLARIZE,
GST_RPI_CAM_SRC_IMAGEFX_POSTERIZE = MMAL_PARAM_IMAGEFX_POSTERIZE,
GST_RPI_CAM_SRC_IMAGEFX_WHITEBOARD = MMAL_PARAM_IMAGEFX_WHITEBOARD,
GST_RPI_CAM_SRC_IMAGEFX_BLACKBOARD = MMAL_PARAM_IMAGEFX_BLACKBOARD,
GST_RPI_CAM_SRC_IMAGEFX_SKETCH = MMAL_PARAM_IMAGEFX_SKETCH,
GST_RPI_CAM_SRC_IMAGEFX_DENOISE = MMAL_PARAM_IMAGEFX_DENOISE,
GST_RPI_CAM_SRC_IMAGEFX_EMBOSS = MMAL_PARAM_IMAGEFX_EMBOSS,
GST_RPI_CAM_SRC_IMAGEFX_OILPAINT = MMAL_PARAM_IMAGEFX_OILPAINT,
GST_RPI_CAM_SRC_IMAGEFX_HATCH = MMAL_PARAM_IMAGEFX_HATCH,
GST_RPI_CAM_SRC_IMAGEFX_GPEN = MMAL_PARAM_IMAGEFX_GPEN,
GST_RPI_CAM_SRC_IMAGEFX_PASTEL = MMAL_PARAM_IMAGEFX_PASTEL,
GST_RPI_CAM_SRC_IMAGEFX_WATERCOLOUR = MMAL_PARAM_IMAGEFX_WATERCOLOUR,
GST_RPI_CAM_SRC_IMAGEFX_FILM = MMAL_PARAM_IMAGEFX_FILM,
GST_RPI_CAM_SRC_IMAGEFX_BLUR = MMAL_PARAM_IMAGEFX_BLUR,
GST_RPI_CAM_SRC_IMAGEFX_SATURATION = MMAL_PARAM_IMAGEFX_SATURATION,
GST_RPI_CAM_SRC_IMAGEFX_COLOURSWAP = MMAL_PARAM_IMAGEFX_COLOURSWAP,
GST_RPI_CAM_SRC_IMAGEFX_WASHEDOUT = MMAL_PARAM_IMAGEFX_WASHEDOUT,
GST_RPI_CAM_SRC_IMAGEFX_POSTERISE = MMAL_PARAM_IMAGEFX_POSTERISE,
GST_RPI_CAM_SRC_IMAGEFX_COLOURPOINT = MMAL_PARAM_IMAGEFX_COLOURPOINT,
GST_RPI_CAM_SRC_IMAGEFX_COLOURBALANCE = MMAL_PARAM_IMAGEFX_COLOURBALANCE,
GST_RPI_CAM_SRC_IMAGEFX_CARTOON = MMAL_PARAM_IMAGEFX_CARTOON
} GstRpiCamSrcImageEffect;
typedef enum {
GST_RPI_CAM_SRC_FLICKERAVOID_OFF = MMAL_PARAM_FLICKERAVOID_OFF,
GST_RPI_CAM_SRC_FLICKERAVOID_AUTO = MMAL_PARAM_FLICKERAVOID_AUTO,
GST_RPI_CAM_SRC_FLICKERAVOID_50HZ = MMAL_PARAM_FLICKERAVOID_50HZ,
GST_RPI_CAM_SRC_FLICKERAVOID_60HZ = MMAL_PARAM_FLICKERAVOID_60HZ
} GstRpiCamSrcFlickerAvoidance;

View file

@ -62,6 +62,8 @@
#include <gst/video/video.h>
#include "gstrpicamsrc.h"
#include "gstrpicam_types.h"
#include "gstrpicam-enum-types.h"
#include "RaspiCapture.h"
#include "bcm_host.h"
@ -89,6 +91,10 @@ enum
{
PROP_0,
PROP_BITRATE,
PROP_PREVIEW,
PROP_PREVIEW_ENCODED,
PROP_PREVIEW_OPACITY,
PROP_FULLSCREEN,
PROP_SHARPNESS,
PROP_CONTRAST,
PROP_BRIGHTNESS,
@ -96,6 +102,19 @@ enum
PROP_ISO,
PROP_VIDEO_STABILISATION,
PROP_EXPOSURE_COMPENSATION,
PROP_EXPOSURE_MODE,
PROP_EXPOSURE_METERING_MODE,
PROP_AWB_MODE,
PROP_IMAGE_EFFECT,
PROP_IMAGE_EFFECT_PARAMS,
PROP_COLOUR_EFFECTS,
PROP_ROTATION,
PROP_HFLIP,
PROP_VFLIP,
PROP_ROI_X,
PROP_ROI_Y,
PROP_ROI_W,
PROP_ROI_H,
};
#define BITRATE_DEFAULT 17000000 /* 17Mbit/s default for 1080p */
@ -107,7 +126,10 @@ enum
#define SATURATION_DEFAULT 0
#define ISO_DEFAULT 0
#define VIDEO_STABILISATION_DEFAULT FALSE
#define EXPOSURE_COMPENSATION_DEFAULT FALSE
#define EXPOSURE_COMPENSATION_DEFAULT 0
#define EXPOSURE_MODE_DEFAULT GST_RPI_CAM_SRC_EXPOSURE_MODE_AUTO
#define EXPOSURE_METERING_MODE_DEFAULT GST_RPI_CAM_SRC_EXPOSURE_METERING_MODE_AVERAGE
/*
params->exposureMode = MMAL_PARAM_EXPOSUREMODE_AUTO;
@ -177,26 +199,96 @@ gst_rpi_cam_src_class_init (GstRpiCamSrcClass * klass)
gobject_class->set_property = gst_rpi_cam_src_set_property;
gobject_class->get_property = gst_rpi_cam_src_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BITRATE,
g_object_class_install_property (gobject_class, PROP_BITRATE,
g_param_spec_int ("bitrate", "Bitrate", "Bitrate for encoding",
1, BITRATE_HIGHEST, BITRATE_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PREVIEW,
g_param_spec_boolean ("preview",
"Preview Window", "Display preview window overlay",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_FULLSCREEN,
g_param_spec_boolean ("fullscreen",
"Fullscreen Preview", "Display preview window full screen",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PREVIEW_ENCODED,
g_param_spec_boolean ("preview-encoded",
"Preview Encoded", "Display encoder output in the preview",
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PREVIEW_OPACITY,
g_param_spec_int ("preview-opacity", "Preview Opacity", "Opacity to use for the preview window",
0, 255, 255,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SHARPNESS,
g_param_spec_int ("sharpness", "Sharpness", "Image capture sharpness",
-100, 100, SHARPNESS_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CONTRAST,
g_object_class_install_property (gobject_class, PROP_CONTRAST,
g_param_spec_int ("contrast", "Contrast", "Image capture contrast",
-100, 100, CONTRAST_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BRIGHTNESS,
g_object_class_install_property (gobject_class, PROP_BRIGHTNESS,
g_param_spec_int ("brightness", "Brightness", "Image capture brightness",
0, 100, BRIGHTNESS_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SATURATION,
g_object_class_install_property (gobject_class, PROP_SATURATION,
g_param_spec_int ("saturation", "Saturation", "Image capture saturation",
-100, 100, SATURATION_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ISO,
g_param_spec_int ("iso", "ISO", "ISO value to use (0 = Auto)",
0, 3200, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_VIDEO_STABILISATION,
g_param_spec_boolean ("video-stabilisation",
"Video Stabilisation", "Enable or disable video stabilisation",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_EXPOSURE_COMPENSATION,
g_param_spec_int ("exposure-compensation", "EV compensation", "Exposure Value compensation",
-10, 10, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_EXPOSURE_MODE,
g_param_spec_enum ("exposure-mode", "Exposure Mode",
"Camera exposure mode to use",
GST_RPI_CAM_TYPE_RPI_CAM_SRC_EXPOSURE_MODE, EXPOSURE_MODE_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_EXPOSURE_METERING_MODE,
g_param_spec_enum ("metering-mode", "Exposure Metering Mode",
"Camera exposure metering mode to use",
GST_RPI_CAM_TYPE_RPI_CAM_SRC_EXPOSURE_METERING_MODE, EXPOSURE_METERING_MODE_DEFAULT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_AWB_MODE,
g_param_spec_enum ("awb-mode", "Automatic White Balance Mode",
"White Balance mode",
GST_RPI_CAM_TYPE_RPI_CAM_SRC_AWB_MODE, GST_RPI_CAM_SRC_AWB_MODE_AUTO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#if 0
PROP_IMAGE_EFFECT,
PROP_IMAGE_EFFECT_PARAMS,
PROP_COLOUR_EFFECTS,
#endif
g_object_class_install_property (gobject_class, PROP_ROTATION,
g_param_spec_int ("rotation", "Rotation", "Rotate captured image (0, 90, 180, 270 degrees)",
0, 270, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_HFLIP,
g_param_spec_boolean ("hflip",
"Horizontal Flip", "Flip capture horizontally",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_VFLIP,
g_param_spec_boolean ("vflip",
"Vertical Flip", "Flip capture vertically",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ROI_X,
g_param_spec_float ("roi-x", "ROI X", "Normalised region-of-interest X coord",
0, 1.0, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ROI_Y,
g_param_spec_float ("roi-y", "ROI Y", "Normalised region-of-interest Y coord",
0, 1.0, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ROI_W,
g_param_spec_float ("roi-w", "ROI W", "Normalised region-of-interest W coord",
0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_ROI_H,
g_param_spec_float ("roi-h", "ROI H", "Normalised region-of-interest H coord",
0, 1.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_set_static_metadata (gstelement_class,
"Raspberry Pi Camera Source",
@ -240,6 +332,18 @@ gst_rpi_cam_src_set_property (GObject * object, guint prop_id,
case PROP_BITRATE:
src->capture_config.bitrate = g_value_get_int(value);
break;
case PROP_PREVIEW:
src->capture_config.preview_parameters.wantPreview = g_value_get_boolean(value);
break;
case PROP_PREVIEW_ENCODED:
src->capture_config.immutableInput = g_value_get_boolean(value);
break;
case PROP_FULLSCREEN:
src->capture_config.preview_parameters.wantFullScreenPreview = g_value_get_boolean(value);
break;
case PROP_PREVIEW_OPACITY:
src->capture_config.preview_parameters.opacity = g_value_get_int(value);
break;
case PROP_SHARPNESS:
src->capture_config.camera_parameters.sharpness = g_value_get_int(value);
break;
@ -252,6 +356,45 @@ gst_rpi_cam_src_set_property (GObject * object, guint prop_id,
case PROP_SATURATION:
src->capture_config.camera_parameters.saturation = g_value_get_int(value);
break;
case PROP_ISO:
src->capture_config.camera_parameters.ISO = g_value_get_int(value);
break;
case PROP_VIDEO_STABILISATION:
src->capture_config.camera_parameters.videoStabilisation = g_value_get_boolean(value);
break;
case PROP_EXPOSURE_COMPENSATION:
src->capture_config.camera_parameters.exposureCompensation = g_value_get_int(value);
break;
case PROP_EXPOSURE_MODE:
src->capture_config.camera_parameters.exposureMode = g_value_get_enum(value);
break;
case PROP_EXPOSURE_METERING_MODE:
src->capture_config.camera_parameters.exposureMeterMode = g_value_get_enum(value);
break;
case PROP_ROTATION:
src->capture_config.camera_parameters.rotation = g_value_get_int(value);
break;
case PROP_AWB_MODE:
src->capture_config.camera_parameters.awbMode = g_value_get_enum(value);
break;
case PROP_HFLIP:
src->capture_config.camera_parameters.hflip = g_value_get_boolean(value);
break;
case PROP_VFLIP:
src->capture_config.camera_parameters.vflip = g_value_get_boolean(value);
break;
case PROP_ROI_X:
src->capture_config.camera_parameters.roi.x = g_value_get_float(value);
break;
case PROP_ROI_Y:
src->capture_config.camera_parameters.roi.y = g_value_get_float(value);
break;
case PROP_ROI_W:
src->capture_config.camera_parameters.roi.w = g_value_get_float(value);
break;
case PROP_ROI_H:
src->capture_config.camera_parameters.roi.h = g_value_get_float(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -268,6 +411,18 @@ gst_rpi_cam_src_get_property (GObject * object, guint prop_id,
case PROP_BITRATE:
g_value_set_int(value, src->capture_config.bitrate);
break;
case PROP_PREVIEW:
g_value_set_boolean(value, src->capture_config.preview_parameters.wantPreview);
break;
case PROP_PREVIEW_ENCODED:
g_value_set_boolean(value, src->capture_config.immutableInput);
break;
case PROP_FULLSCREEN:
g_value_set_boolean(value, src->capture_config.preview_parameters.wantFullScreenPreview);
break;
case PROP_PREVIEW_OPACITY:
g_value_set_int(value, src->capture_config.preview_parameters.opacity);
break;
case PROP_SHARPNESS:
g_value_set_int(value, src->capture_config.camera_parameters.sharpness);
break;
@ -280,6 +435,45 @@ gst_rpi_cam_src_get_property (GObject * object, guint prop_id,
case PROP_SATURATION:
g_value_set_int(value, src->capture_config.camera_parameters.saturation);
break;
case PROP_ISO:
g_value_set_int(value, src->capture_config.camera_parameters.ISO);
break;
case PROP_VIDEO_STABILISATION:
g_value_set_boolean(value, !!(src->capture_config.camera_parameters.videoStabilisation));
break;
case PROP_EXPOSURE_COMPENSATION:
g_value_set_int(value, src->capture_config.camera_parameters.exposureCompensation);
break;
case PROP_EXPOSURE_MODE:
g_value_set_enum(value, src->capture_config.camera_parameters.exposureMode);
break;
case PROP_EXPOSURE_METERING_MODE:
g_value_set_enum(value, src->capture_config.camera_parameters.exposureMeterMode);
break;
case PROP_ROTATION:
g_value_set_int(value, src->capture_config.camera_parameters.rotation);
break;
case PROP_AWB_MODE:
g_value_set_enum(value, src->capture_config.camera_parameters.awbMode);
break;
case PROP_HFLIP:
g_value_set_boolean(value, !!(src->capture_config.camera_parameters.hflip));
break;
case PROP_VFLIP:
g_value_set_boolean(value, !!(src->capture_config.camera_parameters.vflip));
break;
case PROP_ROI_X:
g_value_set_float(value, src->capture_config.camera_parameters.roi.x);
break;
case PROP_ROI_Y:
g_value_set_float(value, src->capture_config.camera_parameters.roi.y);
break;
case PROP_ROI_W:
g_value_set_float(value, src->capture_config.camera_parameters.roi.w);
break;
case PROP_ROI_H:
g_value_set_float(value, src->capture_config.camera_parameters.roi.h);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;