Example #1
0
bool CScpMedia::Init( ISystemEnv *pEnv )
{
	_pEnv = pEnv ;

	char buf[1024] = {0};
	if ( ! pEnv->GetString( "cfs_ip" , buf ) ){
		printf( "get ftp ip failed, %s:%d\n", __FILE__, __LINE__ ) ;
		return false ;
	}
	_cfs_ip = buf ;

	if ( ! pEnv->GetString( "cfs_user" , buf ) ) {
		printf( "get ftp save dir failed, %s:%d\n" , __FILE__, __LINE__ ) ;
		return false ;
	}
	_cfs_user = buf ;

	if ( ! pEnv->GetString( "cfs_pwd" , buf ) ) {
		printf( "get ftp pwd failed, %s:%d\n" , __FILE__, __LINE__ ) ;
		return false ;
	}
	_cfs_pwd = buf ;

	int ntemp  = 0 ;
	if ( ! pEnv->GetInteger( "cfs_port" , ntemp ) ) {
		printf( " get scp port failed, %s:%d\n" , __FILE__, __LINE__ ) ;
		return false ;
	}
	_cfs_port = ntemp ;

	if ( pEnv->GetInteger( "cfs_thread" , ntemp ) ) {
		_thread_num = ntemp ;
	}
	// 是否开启FTP文件处理
	if ( pEnv->GetInteger( "cfs_enable" , ntemp ) ) {
		_cfs_enable = ( ntemp == 1 ) ;
	}
	// 是否开启日期水印,这里系统必须安装了imagemagick软件
	if ( pEnv->GetInteger( "water_enable", ntemp ) ) {
		_water_enable = ( ntemp == 1 ) ;
	}

	gdFTUseFontConfig(1);

	// 如果开启远程文件处理就初始化对象
	if ( _cfs_enable ) {
#ifdef _SYN_MODE_
		_netobj._pobj = NetFileMgr::getfileobj( NetFileMgr::SYN_MODE ) ;
#else
		_netobj._pobj = NetFileMgr::getfileobj( NetFileMgr::ASYN_MODE ) ;
#endif
	}
	// 初始SCP文件管理对象
	return _scp_manager.Init( pEnv ) ;
}
Example #2
0
int vista_fswc_init()
{
	/* Set the locale to the system default */
	setlocale(LC_ALL, "");
	
	/* Prepare the configuration structure. */
	config = calloc(sizeof(fswebcam_config_t), 1);
	if(!config)
	{
		WARN("Out of memory.");
		return(-1);
	}	

	/* Set the defaults. */
	config->loop = 0;
	config->offset = 0;
	config->background = 0;
	config->pidfile = NULL;
	config->logfile = NULL;
	config->gmt = 0;
	config->start = 0;
	config->device = strdup("/dev/video0");
	config->input = NULL;
	config->tuner = 0;
	config->frequency = 0;
	config->delay = 0;
	config->timeout = 10;
	config->use_read = 0;
	config->list = 0;
	config->width = VISTA_WIDTH;
	config->height = VISTA_HEIGHT;
	config->fps = 0;
	config->frames = 1;
	config->skipframes = 5;
	config->palette = SRC_PAL_ANY;
	config->option = NULL;
	config->dumpframe = NULL;
	config->jobs = 0;
	config->job = NULL;

	/* Setup signal handlers. */
//	if(fswc_setup_signals()) return(-1);
	
	/* Enable FontConfig support in GD */
	if(!gdFTUseFontConfig(1)) DEBUG("gd has no fontconfig support");
	return(0);
}	
Example #3
0
int main(int argc, char *argv[])
{
	fswebcam_config_t *config;
	
	/* Prepare the configuration structure. */
	config = calloc(sizeof(fswebcam_config_t), 1);
	if(!config)
	{
		WARN("Out of memory.");
		return(-1);
	}
	
	/* Set defaults and parse the command line. */
	if(fswc_getopts(config, argc, argv)) return(-1);
	
	/* Open the log file if one was specified. */
	if(config->logfile && fswc_openlog(config)) return(-1);
	
	/* Go into the background if requested. */
	if(config->background && fswc_background(config)) return(-1);
	
	/* Save PID of requested. */
	if(config->pidfile && fswc_savepid(config)) return(-1);
	
	/* Setup signal handlers. */
	if(fswc_setup_signals()) return(-1);
	
	/* Enable FontConfig support in GD */
	if(!gdFTUseFontConfig(1)) DEBUG("gd has no fontconfig support");
	
	/* Capture the image(s). */
	if(!config->loop) fswc_grab(config);
	else
	{
		/* Loop mode ... keep capturing images until terminated. */
		while(1 == 1)
		{
			time_t capturetime = time(NULL);
			char timestamp[32];
			
			/* Calculate when the next image is due. */
			capturetime -= (capturetime % config->loop);
			capturetime += config->loop + config->offset;
			
			/* Correct the capturetime if the offset pushes
			 * it to far into the future. */
			if(capturetime - time(NULL) > config->loop)
				capturetime -= config->loop;
			
			fswc_strftime(timestamp, 32, "%Y-%m-%d %H:%M:%S (%Z)",
			              capturetime, config->gmt);
			
			MSG(">>> Next image due: %s", timestamp);
			
			/* Wait until that time comes. */
			while(time(NULL) < capturetime)
			{
				usleep(250000);
				if(received_sighup)
				{
					/* Reload configuration. */
					MSG("Received HUP signal... reloading configuration.");
					fswc_free_config(config);
					fswc_getopts(config, argc, argv);
					
					/* Clear hup signal. */
					received_sighup = 0;
				}
				
				if(received_sigusr1)
				{
					MSG("Received USR1 signal... Capturing image.");
					break;
				}
				
				if(received_sigterm)
				{
					MSG("Received TERM signal... exiting.");
					break;
				}
			}
			
			if(received_sigterm) break;
			
			/* Clear usr1 signal. */
			received_sigusr1 = 0;
			
			/* Capture the image. */
			fswc_grab(config);
		}
	}
	
	/* Close the log file. */
	if(config->logfile) log_close();
	
	/* Free all used memory. */
	fswc_free_config(config);
	free(config);
	
	return(0);
}
Example #4
0
//this integer for image name
int main(int argc, char *argv[])
{
	
	fswebcam_config_t *config;

	/* Prepare the configuration structure. */
	config = calloc(sizeof(fswebcam_config_t), 1);

	if(!config)
	{
		WARN("Out of memory.");
		return(-1);
	}


//	config->width  = src.width;
//	config->height = src.height;
	/* Set the default values for this run. */
	if(config->font) free(config->font);
	if(config->title) free(config->title);
	if(config->subtitle) free(config->subtitle);
	if(config->timestamp) free(config->timestamp);
	if(config->info) free(config->info);
	if(config->underlay) free(config->underlay);
	if(config->overlay) free(config->overlay);
	if(config->filename) free(config->filename);

	config->banner       = BOTTOM_BANNER;
	config->bg_colour    = 0x40263A93;
	config->bl_colour    = 0x00FF0000;
	config->fg_colour    = 0x00FFFFFF;
	config->font         = strdup("sans");
	config->fontsize     = 10;
	config->shadow       = 1;
	config->title        = strdup("NicePhoto");
	config->subtitle     = strdup("By Charmyin");
	config->timestamp    = strdup("%Y-%m-%d %H:%M:%S (%Z)");
	config->info         = strdup("Charmyin Photo");;
	config->underlay     = NULL;
	config->overlay      = NULL;
	config->filename     = NULL;
	config->format       = FORMAT_JPEG;
	config->compression  = -1;

	MSG("Setting output format to JPEG, quality %i", 90);
	config->format = FORMAT_JPEG;
	config->compression = 90;

	/* Set defaults and parse the command line. */
	if(fswc_getopts(config, argc, argv)) return(-1);

	/* Open the log file if one was specified. */
	if(config->logfile && fswc_openlog(config)) return(-1);

	/* Go into the background if requested. */
	if(config->background && fswc_background(config)) return(-1);

	/* Save PID of requested. */
	if(config->pidfile && fswc_savepid(config)) return(-1);

	/* Setup signal handlers. */
	if(fswc_setup_signals()) return(-1);
	
	/* Enable FontConfig support in GD */
	if(!gdFTUseFontConfig(1)) DEBUG("gd has no fontconfig support");
	/* Capture the image(s). */
	/* Capture the image. */
	fswc_grab(config);

	/* Close the log file. */
	if(config->logfile) log_close();
	
	/* Free all used memory. */
	fswc_free_config(config);
	free(config);
	
	return(0);
}