- sap_address_t *p_address = (sap_address_t *)
- malloc( sizeof(sap_address_t) );
- if( !p_address )
- {
- vlc_mutex_unlock( &p_sap->object_lock );
- return VLC_ENOMEM;
- }
- p_address->psz_address = strdup( psz_addr );
- p_address->i_wfd = net_ConnectUDP( VLC_OBJECT(p_sap), psz_addr, SAP_PORT, 255 );
- if( p_address->i_wfd != -1 )
- {
- shutdown( p_address->i_wfd, SHUT_RD );
- p_address->origlen = sizeof (p_address->orig);
- getsockname (p_address->i_wfd, (struct sockaddr *)&p_address->orig,
- &p_address->origlen);
- }
-
- if( p_sap->b_control == true )
- {
- p_address->i_rfd = net_ListenUDP1( (vlc_object_t*)p_sap, psz_addr, SAP_PORT );
- if( p_address->i_rfd != -1 )
- shutdown( p_address->i_rfd, SHUT_WR );
- p_address->i_buff = 0;
- p_address->b_enabled = true;
- p_address->b_ready = false;
- p_address->i_limit = 10000; /* 10000 bps */
- p_address->t1 = 0;
- }
- else
- {
- p_address->b_enabled = true;
- p_address->b_ready = true;
- p_address->i_interval = config_GetInt( p_sap,"sap-interval");
- p_address->i_rfd = -1;
- }
-
- if( p_address->i_wfd == -1 || (p_address->i_rfd == -1
- && p_sap->b_control ) )