예제 #1
0
static int _tdav_producer_video_v4l2_start(tmedia_producer_t* p_self)
{
    tdav_producer_video_v4l2_t* p_v4l2 = (tdav_producer_video_v4l2_t*)p_self;
    int ret = 0;

    if (!p_v4l2) {
        V4L2_DEBUG_ERROR("Invalid parameter");
        return -1;
    }

    tsk_safeobj_lock(p_v4l2);

    if (!p_v4l2->b_prepared) {
        V4L2_DEBUG_INFO("Not prepared");
        ret = -1;
        goto bail;
    }

    p_v4l2->b_paused = tsk_false;

    if (p_v4l2->b_started) {
        V4L2_DEBUG_INFO("Already started");
        goto bail;
    }

    if ((ret = tsk_timer_manager_start(p_v4l2->p_timer_mgr))) {
        goto bail;
    }

    // start()
    if ((ret = _v4l2_start(p_v4l2))) {
        goto bail;
    }

    p_v4l2->b_started = tsk_true;

    // Schedule frame grabbing
    p_v4l2->id_timer_grab = tsk_timer_manager_schedule(p_v4l2->p_timer_mgr, p_v4l2->u_timout_grab, _tdav_producer_video_v4l2_timer_cb, p_v4l2);
    if (!TSK_TIMER_ID_IS_VALID(p_v4l2->id_timer_grab)) {
        V4L2_DEBUG_ERROR("Failed to schedule timer with timeout=%llu", p_v4l2->u_timout_grab);
        ret = -2;
        goto bail;
    }

bail:
    if (ret) {
        _v4l2_stop(p_v4l2);
        p_v4l2->b_started = tsk_false;
        if (p_v4l2->p_timer_mgr) {
            tsk_timer_manager_stop(p_v4l2->p_timer_mgr);
        }
    }
    else {
        V4L2_DEBUG_INFO("Started :)");
    }
    tsk_safeobj_unlock(p_v4l2);

    return ret;
}
예제 #2
0
파일: u.c 프로젝트: Bhoft/lg.srv
/*
 * ------------------------------------------------------------------------
 */
int main( int argc, char ** argv )
{
	int		i;
	int		fg=0;
	char	*cmdname;
	char	*port	= "6260";
#if 0
	int		novideo=1;
#endif


	cmdname=strrchr(*argv,'/');
	if ( cmdname )
		cmdname ++;
	else
		cmdname = *argv;

	g_av=argv;
	g_ac=argc;

	i=0;

	if (( argc>1 ) && !strcmp(argv[1],"-version"))
		i=1;

	memset( cl_array, 0, sizeof(cl_array) );

	for( i=1; i < argc; i++ )
	{
		if ( (i<argc-1) && !strcmp(argv[i],"-port") )
		{
			port = strdup(argv[++i]);
		}
		else if ( !strcmp(argv[i],"-debug") )
		{
			debug = 1;
		}
		else if ( !strncmp(argv[i],"-debug=",7) )
		{
			debug = atoi(argv[i]+7);
		}
		else if ( !strcmp(argv[i],"-fg") )
		{
			fg = 1;
		}
#if 0
		else if ( !strcmp(argv[i],"+video") )
		{
			novideo=0;
		}
#endif
		else if ( !strcmp(argv[i],"-version") )
		{
			printf("%s\n",cstr);
			exit(0);
		}
		else
		{
			printf("usage: %s [-port <nr>] [-debug=mask] [-fg]\n", *argv);
			printf("  debug-mask :  1 : quiet debug\n");
			printf("  debug-mask :  2 : send mail\n");
			printf("  debug-mask :  4 : timer\n");
			printf("  debug-mask :  8 : http traffic\n");
			printf("  debug-mask : 16 : json traffic\n");
			return 1;
		}
	}

	signal( SIGCHLD, SIG_IGN );
	signal( SIGPIPE, SIG_IGN );
	signal( SIGHUP, SIG_IGN );

	memset(&json,0,sizeof(JsonVars));
	memset(&timer,0,sizeof(TimerVars));
	memset(&mail,0,sizeof(MailVars));

	ReadTimerFromFile();
	ReadMailConfigFromFile();
	HttpLoadCleaningRecord(0,0);

	system("ifconfig lo up");

#if 0
	if ( !novideo )
		_v4l2_start();
	else
		HttpSetNoCam();
#endif

	if ( !fg && fork() )
		return 0;

	listen_line = _lgListen( atol(port) );

	StartTimer();

	jsonSend(0);

	skMainLoop();

	return( 0 );
}