Ejemplo n.º 1
0
/********************************************************************************
 * TvCtrlPointStart
 *
 * Description: 
 *		Call this function to initialize the UPnP library and start the TV Control
 *		Point.  This function creates a timer thread and provides a callback
 *		handler to process any UPnP events that are received.
 *
 * Parameters:
 *		None
 *
 * Returns:
 *		TV_SUCCESS if everything went well, else TV_ERROR
 *
 ********************************************************************************/
int
TvCtrlPointStart( print_string printFunctionPtr,
                  state_update updateFunctionPtr )
{
    ithread_t timer_thread;
    int rc;
    unsigned short port = 0;
    char *ip_address = NULL;

    SampleUtil_Initialize( printFunctionPtr );
    SampleUtil_RegisterUpdateFunction( updateFunctionPtr );

    ithread_mutex_init( &DeviceListMutex, 0 );

    SampleUtil_Print(
        "Initializing UPnP Sdk with\n"
        "\tipaddress = %s port = %u\n",
        ip_address, port );

    rc = UpnpInit( ip_address, port );
    if( UPNP_E_SUCCESS != rc ) {
        SampleUtil_Print( "WinCEStart: UpnpInit() Error: %d", rc );
        UpnpFinish();
        return TV_ERROR;
    }

    if( NULL == ip_address ) {
        ip_address = UpnpGetServerIpAddress();
    }
    if( 0 == port ) {
        port = UpnpGetServerPort();
    }

    SampleUtil_Print(
        "UPnP Initialized\n"
	"\tipaddress= %s port = %u\n",
        ip_address, port );

    SampleUtil_Print( "Registering Control Point" );
    rc = UpnpRegisterClient( TvCtrlPointCallbackEventHandler,
                             &ctrlpt_handle, &ctrlpt_handle );
    if( UPNP_E_SUCCESS != rc ) {
        SampleUtil_Print( "Error registering CP: %d", rc );
        UpnpFinish();
        return TV_ERROR;
    }

    SampleUtil_Print( "Control Point Registered" );

    TvCtrlPointRefresh();

    // start a timer thread
    ithread_create( &timer_thread, NULL, TvCtrlPointTimerLoop, NULL );

    return TV_SUCCESS;
}
Ejemplo n.º 2
0
int CtrlPointStart()
{
	//ithread_t timer_thread;
	int rc;
	unsigned short port = 0;
	char *ip_address = NULL;

	ithread_mutex_init(&DeviceListMutex, 0);

        g_print("Initializing UPnP Sdk with\n"
			 "\tipaddress = %s port = %u\n",
			 ip_address ? ip_address : "{NULL}", port);

	rc = UpnpInit(ip_address, port);
	if (rc != UPNP_E_SUCCESS) {
		g_print("WinCEStart: UpnpInit() Error: %d\n", rc);
		UpnpFinish();

		return CP_ERROR;
	}
	if (!ip_address) {
		ip_address = UpnpGetServerIpAddress();
	}
	if (!port) {
		port = UpnpGetServerPort();
	}

        g_print("UPnP Initialized\n"
			 "\tipaddress = %s port = %u\n",
			 ip_address ? ip_address : "{NULL}", port);
        g_print("Registering Control Point\n");
	rc = UpnpRegisterClient(CtrlPointCallbackEventHandler,
				&ctrlpt_handle, &ctrlpt_handle);
	if (rc != UPNP_E_SUCCESS) {
	        g_print("Error registering CP: %d\n", rc);
		UpnpFinish();

		return CP_ERROR;
	}

        g_print("Control Point Registered\n");

	CtrlPointRefresh();

	/* start a timer thread */
	//ithread_create(&timer_thread, NULL, TvCtrlPointTimerLoop, NULL);
	//ithread_detach(timer_thread);

	return CP_SUCCESS;
}
Ejemplo n.º 3
0
/********************************************************************************
 * upnp_igd_destroy
 *
 * Description:
 *       Destroy an existing uPnP IGD context.
 *
 * Parameters:
 *   igd_ctxt -- The upnp igd context
 *
 ********************************************************************************/
void upnp_igd_destroy(upnp_igd_context* igd_ctxt) {
	/* Stop client if started */
	if(igd_ctxt->upnp_handle != -1) {
		upnp_igd_stop(igd_ctxt);
	}

	upnp_context_free_callbacks(igd_ctxt);
	
	UpnpFinish();
	
	ithread_mutex_destroy(&igd_ctxt->devices_mutex);

	ithread_mutex_destroy(&igd_ctxt->callback_mutex);
	
	ithread_cond_destroy(&igd_ctxt->client_cond);
	ithread_mutex_destroy(&igd_ctxt->client_mutex);
	
	ithread_cond_destroy(&igd_ctxt->timer_cond);
	ithread_mutex_destroy(&igd_ctxt->timer_mutex);

	ithread_mutex_destroy(&igd_ctxt->print_mutex);
	
	ithread_mutex_destroy(&igd_ctxt->mutex);
	
	free(igd_ctxt);
}
Ejemplo n.º 4
0
int wscSystemStop(void)
{
    /* Stop the K2U and U2K msg subsystem */
    if (wscU2KMInit && ioctl_sock >= 0)
    {
        // Close the ioctl socket.
        close(ioctl_sock);
        ioctl_sock = -1;
    }
    stopThread = 1;

    if (wscK2UMInit)
    {

    }

    if(wscUPnPDevInit)
        WscUPnPDevStop();
    if(wscUPnPCPInit)
        WscUPnPCPStop();

    if(wscUPnPSDKInit)
        UpnpFinish();

    if( wscMsgQInit)
    {
        wscMsgSubSystemStop();
    }
    exit(0);
}
Ejemplo n.º 5
0
int CtrlPointStop(void)
{
	CtrlPointRemoveAll();
	UpnpUnRegisterClient( ctrlpt_handle );
	UpnpFinish();

	return CP_SUCCESS;
}
Ejemplo n.º 6
0
int TvDeviceStop(void)
{
	UpnpUnRegisterRootDevice(device_handle);
	UpnpFinish();
	SampleUtil_Finish();
	ithread_mutex_destroy(&TVDevMutex);

	return UPNP_E_SUCCESS;
}
Ejemplo n.º 7
0
////////////////////////////////////////
//stop the client
////////////////////////////////////////
int
TvCtrlPointStop( void )
{
    TvCtrlPointRemoveAll(  );
    UpnpUnRegisterClient( ctrlpt_handle );
    UpnpFinish(  );
    SampleUtil_Finish(  );
    return TV_SUCCESS;
}
Ejemplo n.º 8
0
static void Close( vlc_object_t *p_this )
{
    services_discovery_t *p_sd = ( services_discovery_t* )p_this;

    UpnpFinish();
    delete p_sd->p_sys->serverList;
    vlc_mutex_destroy( &p_sd->p_sys->callbackLock );

    free( p_sd->p_sys );
}