void CPosSession::GetDefaultModuleIdL(const RMessage2& aMessage)
    {
    DEBUG_TRACE("EPositionServerGetDefaultModuleId", __LINE__)

    CPosModuleIdList* moduleList = iModuleSettings.ModuleIdListL();
    CleanupStack::PushL( moduleList );
    TInt nrOfModules = moduleList->Count();
    TInt res = KErrNotFound;

    for (TInt i = 0; (i < nrOfModules) && (res == KErrNotFound); i++)
        {
        TPositionModuleInfo candidate;
        iModuleSettings.GetModuleInfoL((*moduleList)[i], candidate);

        if (candidate.IsAvailable())
            {
            TPckg<TPositionModuleId> moduleId(candidate.ModuleId());
            User::LeaveIfError(Global::Write(aMessage, KParamModuleIdGetDefault, moduleId));
            res = KErrNone;
            }
        }

    CleanupStack::PopAndDestroy(moduleList);
    RequestComplete(aMessage, res);
    }   
Exemple #2
0
bool
ModuleInit( JSContext *cx, JS::HandleObject obj ) {

	JLDisableThreadNotifications();

	JL_ASSERT( jl::Host::getJLHost(cx)->checkCompatId( JL_HOST_VERSIONID ), E_MODULE, E_NOTCOMPATIBLE, E_HOST );

//	JL_ASSERT( vi == NULL, E_LIB, E_STR("videoinput"), E_INIT ); // "Invalid case: videoInput already initialized'"


	videoInput::setVerbose(false);
	videoInput *vi = new videoInput();
	JL_ASSERT_ALLOC( vi );
	jl::Host::getJLHost(cx)->moduleManager().modulePrivateT<videoInput*>( moduleId() ) = vi;

		
	struct ReleaseModule : jl::Callback {
		jl::HostRuntime &_hostRuntime;
		videoInput *_vi;
	
		ReleaseModule(jl::HostRuntime &hostRuntime, videoInput *vi)
		: _hostRuntime(hostRuntime), _vi(vi) {
		}

		bool operator()( EventType &ev ) {
		
			ASSERT( _hostRuntime );
			if ( _hostRuntime.skipCleanup() )
				return true;

			if ( _vi != NULL )
				delete _vi;

			return true;
		}
	};

	jl::HostRuntime &hostRuntime = jl::HostRuntime::getJLRuntime(cx);
	hostRuntime.addListener(jl::EventId::AFTER_DESTROY_RUNTIME, new ReleaseModule(hostRuntime, vi)); // frees mpv after rt and cx has been destroyed


	INIT_CLASS( VideoInput );

	return true;
	JL_BAD;
}
Exemple #3
0
/**doc
$TOC_MEMBER $INAME
 $Image $INAME( deviceId, [idealWidth], [idealHeight], [idealFPS], [flipImageY = true], [flipImageRedBlue = true] )
**/
DEFINE_CONSTRUCTOR() {

	JL_DEFINE_ARGS;

	Private *pv = NULL;

	JL_ASSERT_CONSTRUCTING();
	JL_DEFINE_CONSTRUCTOR_OBJ;
	JL_ASSERT_ARGC_RANGE(1,5);

	pv = new Private( jl::Host::getJLHost(cx)->moduleManager().modulePrivateT<videoInput*>( moduleId() ) );
	JL_ASSERT_ALLOC( pv );
	pv->deviceID = -1; // invalid device

	int numDevices = videoInput::listDevices(true);

	if ( !JL_ARG(1).isString() ) {
		
		JL_CHK( jl::getValue(cx, JL_ARG(1), &pv->deviceID) );
		JL_ASSERT_ARG_VAL_RANGE( pv->deviceID, 0, numDevices-1, 1 );
	} else {
	
		jl::StrData requiredDeviceName(cx);
		JL_CHK( jl::getValue(cx, JL_ARG(1), &requiredDeviceName) );
		for ( int i = 0; i < numDevices; i++ ) {

			if ( strstr(videoInput::getDeviceName(i), requiredDeviceName) != NULL ) {
				
				pv->deviceID = i;
				break;
			}
		}
		JL_CHKM( pv->deviceID != -1, E_ARG, E_NUM(1), E_NOTFOUND );
	}

	if ( JL_ARG_ISDEF(4) ) {

		int fps;
		JL_CHK( jl::getValue(cx, JL_ARG(4), &fps) );
		pv->vi->setIdealFramerate( pv->deviceID, fps ); // vi->VDList[deviceId]->requestedFrameTime;
	}
	
	if ( JL_ARG_ISDEF(2) && JL_ARG_ISDEF(3) ) {
		
		int width, height;
		JL_CHK( jl::getValue(cx, JL_ARG(2), &width) );
		JL_CHK( jl::getValue(cx, JL_ARG(3), &height) );
		pv->vi->setupDevice( pv->deviceID, width, height );
	} else {
	
		pv->vi->setupDevice( pv->deviceID ); // use default size
	}

	if ( JL_ARG_ISDEF(5) )
		JL_CHK( jl::getValue(cx, JL_ARG(1), &pv->flipImageY) );
	else
		pv->flipImageY = true;

	if ( JL_ARG_ISDEF(6) )
		JL_CHK( jl::getValue(cx, JL_ARG(1), &pv->flipImageRedBlue) );
	else
		pv->flipImageRedBlue = true;


	//	vi->setVideoSettingCameraPct(deviceId, vi->propBrightness, 100);
	// vi->setFormat(deviceId, VI_NTSC_M);

	JL_SetPrivate(JL_OBJ, pv);
	return true;

bad:
	if ( pv ) {
		
		ASSERT( pv->vi );

		if ( pv->deviceID != -1 )
			pv->vi->stopDevice( pv->deviceID );
		delete pv;
	}
	return false;
}