예제 #1
0
void
config_set_boolean(boolean *result, char *arg)
	{
	if (!strcasecmp(arg, "toggle"))
			*result = *result ? 0 : 1;
	else *result = config_boolean_value(arg);
	}
예제 #2
0
MMAL_STATUS_T
flip_control_set(char *option, char *setting)
	{
	MMAL_PARAMETER_MIRROR_T mirror =
                    {{MMAL_PARAMETER_MIRROR, sizeof(MMAL_PARAMETER_MIRROR_T)},
                    MMAL_PARAM_MIRROR_NONE};
	CameraParameter *param;
	int             hflip = FALSE,
	                vflip = FALSE;
	int             i;
	MMAL_STATUS_T   status = MMAL_EINVAL;

	if (!strcmp(option, "hflip"))
		{
		hflip = config_boolean_value(setting);
		if (!hflip)
			setting = "off";	/* config transition */
		param = mmalcam_config_parameter_get("hflip");
		dup_string(&param->arg, setting);

		param = mmalcam_config_parameter_get("vflip");
		vflip = config_boolean_value(param->arg);
		}
	else
		{
		vflip = config_boolean_value(setting);
		param = mmalcam_config_parameter_get("vflip");
		dup_string(&param->arg, setting);

		param = mmalcam_config_parameter_get("hflip");
		hflip = config_boolean_value(param->arg);
		}
	if (hflip && vflip)
		mirror.value = MMAL_PARAM_MIRROR_BOTH;
	else if (hflip)
		mirror.value = MMAL_PARAM_MIRROR_HORIZONTAL;
	else if (vflip)
		mirror.value = MMAL_PARAM_MIRROR_VERTICAL;

	for (i = 0; i < MAX_CAMERA_PORTS; ++i)
		if ((status = mmal_port_parameter_set(camera.component->output[i],
				&mirror.hdr)) != MMAL_SUCCESS)
			break;

	return status;
	}
예제 #3
0
MMAL_STATUS_T
color_effect_set(char *option, char *setting)
	{
	MMAL_PARAMETER_COLOURFX_T colfx =
			{{MMAL_PARAMETER_COLOUR_EFFECT,sizeof(colfx)}, 0, 0, 0};
	char			enable[8];
	MMAL_STATUS_T	status = MMAL_EINVAL;

	if (sscanf(setting, "%7s %d %d", enable, &colfx.u, &colfx.v) == 3)
		{
		colfx.enable = config_boolean_value(enable);
		status = mmal_port_parameter_set(camera.control_port, &colfx.hdr);
		}
	return status;
	}
예제 #4
0
MMAL_STATUS_T
boolean_control_set(char *option, char *setting)
	{
	int				value, param;
	MMAL_STATUS_T	status = MMAL_EINVAL;

	value = config_boolean_value(setting);
	param = find_param(option, parameter_table, PARAMETER_TABLE_SIZE);
	if (param >= 0)
		{
		status = mmal_port_parameter_set_boolean(camera.control_port,
							param, value);
		}
	return status;
	}
예제 #5
0
void
command_process(char *command_line)
	{
	VideoCircularBuffer	*vcb = &video_circular_buffer;
	Command	*cmd;
	char	command[64], args[128], buf[32], *path;
	int		i, n;

	if (!command_line || *command_line == '\0')
		return;

	n = sscanf(command_line, "%63s %[^\n]", command, args);
	if (n < 1 || command[0] == '#')
		return;
	for (cmd = NULL, i = 0; i < COMMAND_SIZE; cmd = NULL, ++i)
		{
		cmd = &commands[i];
		if (!strcmp(command, cmd->name))
			{
			if (cmd->n_args != n - 1)
				{
				log_printf("Wrong number of args for command: %s\n", command);
				return;
				}
			break;
			}
		}
	if (!cmd)
		{
		if (   !config_set_option(command, args, FALSE)
		    && !mmalcam_config_parameter_set(command, args, TRUE)
	       )
			log_printf("Bad command: [%s] [%s]\n", command, args);
		return;
		}
	if (cmd->code != display_cmd)
		log_printf("command_process: %s\n", command_line);

	if (cmd->code < display_cmd && !display_is_default())
		{
		display_set_default();
		return;
		}

	switch (cmd->code)
		{
		case record:
			pthread_mutex_lock(&vcb->mutex);
			if (config_boolean_value(args) == TRUE)
				{
				if (vcb->pause)
					vcb->pause = FALSE;
				else
					{
					if (vcb->state == VCB_STATE_MOTION_RECORD)
						video_record_stop(vcb);
					video_record_start(vcb, VCB_STATE_MANUAL_RECORD_START);
					}
				}
			else
				video_record_stop(vcb);
			pthread_mutex_unlock(&vcb->mutex);
			break;

		case record_pause:
			/* Can pause manual record only.  Because of event_gap/capture
			|  times, I'm not even sure what it would mean to pause a
			|  motion record.
			*/
			pthread_mutex_lock(&vcb->mutex);
			if (vcb->state == VCB_STATE_MANUAL_RECORD)
				vcb->pause = vcb->pause ? FALSE : TRUE;
			else
				vcb->pause = FALSE;
			pthread_mutex_unlock(&vcb->mutex);
			break;

		case still:
			snprintf(buf, sizeof(buf), "%d", pikrellcam.still_sequence);
			path = media_pathname(pikrellcam.still_dir, pikrellcam.still_filename,
							'N',  buf,
							'\0', NULL);
			pikrellcam.still_sequence += 1;
			still_capture(path);
			free(path);
			break;

		case tl_start:
			if ((n = atoi(args)) < 1)
				n = 0;
			time_lapse.activated = TRUE;
			time_lapse.on_hold = FALSE;
			if (!time_lapse.event && n > 0)
				{
				time_lapse.sequence = 0;
				++time_lapse.series;
				time_lapse.event = event_add("timelapse",
							pikrellcam.t_now, n, timelapse_capture, NULL);
				}
			else if (n > 0)		/* Change the period */
				{
				time_lapse.event->time += (n - time_lapse.period);
				time_lapse.event->period = n;
				}
			if (n > 0)
				time_lapse.period = n;	/* n == 0 just sets on_hold FALSE */
			config_timelapse_save_status();	
			break;

		case tl_hold:
				config_set_boolean(&time_lapse.on_hold, args);
				config_timelapse_save_status();
			break;

		case tl_end:
			if (time_lapse.activated)
				{
				event_remove(time_lapse.event);
				time_lapse.event = NULL;
				time_lapse.activated = FALSE;
				time_lapse.on_hold = FALSE;
				config_timelapse_save_status();
				exec_no_wait(pikrellcam.on_timelapse_end_cmd, NULL);
				}
			break;

		case tl_inform_convert:
			if (!strcmp(args, "done"))
				{
				event_remove(time_lapse.inform_event);
				dup_string(&time_lapse.convert_name, "");
				time_lapse.convert_size = 0;
				}
			else
				{
				dup_string(&time_lapse.convert_name, args);
				time_lapse.inform_event = event_add("tl_inform_convert",
						pikrellcam.t_now, 5, timelapse_inform_convert, NULL);
				}
			break;

		case tl_show_status:
			config_set_boolean(&time_lapse.show_status, args);
			break;

		case display_cmd:
			display_command(args);
			break;

		case motion_cmd:
			motion_command(args);
			break;

		case motion_enable:
			n = motion_frame.motion_enable;
			config_set_boolean(&motion_frame.motion_enable, args);

			if (n && !motion_frame.motion_enable)
				{
				pthread_mutex_lock(&vcb->mutex);
				if (vcb->state == VCB_STATE_MOTION_RECORD)
					video_record_stop(vcb);
				pthread_mutex_unlock(&vcb->mutex);
				}
			break;

		case save_config:
			config_save(pikrellcam.config_file);
			break;

		case quit:
			config_timelapse_save_status();
			if (pikrellcam.config_modified)
				config_save(pikrellcam.config_file);
			display_quit();
			exit(0);
			break;

		default:
			log_printf("command in table with no action!\n");
			break;
		}
	}
예제 #6
0
static boolean
config_value_bool_set(char *arg, ConfigResult *result)
	{
	*result->value = config_boolean_value(arg);
	return TRUE;
	}