Changeset 494933e13b13f3d2f21f19cf607c4b52074a6db3
- Timestamp:
- 05/12/05 18:30:14
(3 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1133803814 +0000
- git-parent:
[544ad949033fa8e24e7d4c6b1e06b9d3e6267f72]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1133803814 +0000
- Message:
Use net_ConnectUDP
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re6cdbf3 |
r494933e |
|
| 181 | 181 | int i_dst_port; |
|---|
| 182 | 182 | |
|---|
| 183 | | module_t *p_network; |
|---|
| 184 | | network_socket_t socket_desc; |
|---|
| | 183 | int i_handle; |
|---|
| 185 | 184 | |
|---|
| 186 | 185 | vlc_value_t val; |
|---|
| … | … | |
| 250 | 249 | vlc_mutex_init( p_access, &p_sys->p_thread->blocks_lock ); |
|---|
| 251 | 250 | |
|---|
| 252 | | /* FIXME: use net_OpenUDP API */ |
|---|
| 253 | | socket_desc.psz_server_addr = psz_dst_addr; |
|---|
| 254 | | socket_desc.i_server_port = i_dst_port; |
|---|
| 255 | | socket_desc.psz_bind_addr = ""; |
|---|
| 256 | | socket_desc.i_bind_port = 0; |
|---|
| 257 | | socket_desc.i_handle = -1; |
|---|
| 258 | | socket_desc.v6only = 0; |
|---|
| 259 | | |
|---|
| 260 | 251 | var_Get( p_access, SOUT_CFG_PREFIX "ttl", &val ); |
|---|
| 261 | | socket_desc.i_ttl = val.i_int; |
|---|
| 262 | | |
|---|
| 263 | | p_sys->p_thread->p_private = (void*)&socket_desc; |
|---|
| 264 | | p_network = module_Need( p_sys->p_thread, "network", "ipv4", VLC_TRUE ); |
|---|
| 265 | | if( p_network != NULL ) |
|---|
| 266 | | module_Unneed( p_sys->p_thread, p_network ); |
|---|
| 267 | | |
|---|
| 268 | | if( socket_desc.i_handle == -1 ) |
|---|
| 269 | | { |
|---|
| 270 | | p_network = module_Need( p_sys->p_thread, "network", "ipv6", VLC_TRUE ); |
|---|
| 271 | | if( p_network != NULL ) |
|---|
| 272 | | module_Unneed( p_sys->p_thread, p_network ); |
|---|
| 273 | | |
|---|
| 274 | | if( socket_desc.i_handle == -1 ) |
|---|
| 275 | | { |
|---|
| 276 | | msg_Err( p_access, "failed to open a connection (udp)" ); |
|---|
| 277 | | return VLC_EGENERIC; |
|---|
| 278 | | } |
|---|
| 279 | | } |
|---|
| 280 | | |
|---|
| 281 | | p_sys->p_thread->i_handle = socket_desc.i_handle; |
|---|
| 282 | | net_StopRecv( socket_desc.i_handle ); |
|---|
| | 252 | i_handle = net_ConnectUDP( p_this, psz_dst_addr, i_dst_port, val.i_int ); |
|---|
| | 253 | if( i_handle == -1 ) |
|---|
| | 254 | { |
|---|
| | 255 | msg_Err( p_access, "failed to open a connection (udp)" ); |
|---|
| | 256 | return VLC_EGENERIC; |
|---|
| | 257 | } |
|---|
| | 258 | |
|---|
| | 259 | p_sys->p_thread->i_handle = i_handle; |
|---|
| | 260 | net_StopRecv( i_handle ); |
|---|
| 283 | 261 | |
|---|
| 284 | 262 | var_Get( p_access, SOUT_CFG_PREFIX "caching", &val ); |
|---|
| … | … | |
| 288 | 266 | p_sys->p_thread->i_group = val.i_int; |
|---|
| 289 | 267 | |
|---|
| 290 | | p_sys->i_mtu = socket_desc.i_mtu; |
|---|
| | 268 | p_sys->i_mtu = var_CreateGetInteger( p_this, "mtu" ); |
|---|
| 291 | 269 | |
|---|
| 292 | 270 | if( vlc_thread_create( p_sys->p_thread, "sout write thread", ThreadWrite, |
|---|
| r923a185 |
r494933e |
|
| 167 | 167 | if( i_hlim < 1 ) |
|---|
| 168 | 168 | { |
|---|
| 169 | | vlc_value_t val; |
|---|
| 170 | | |
|---|
| 171 | | if( var_Get( p_this, "ttl", &val ) != VLC_SUCCESS ) |
|---|
| 172 | | { |
|---|
| 173 | | var_Create( p_this, "ttl", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); |
|---|
| 174 | | var_Get( p_this, "ttl", &val ); |
|---|
| 175 | | } |
|---|
| 176 | | i_hlim = val.i_int; |
|---|
| 177 | | |
|---|
| 178 | | if( i_hlim < 1 ) i_hlim = 1; |
|---|
| | 169 | i_hlim = var_CreateGetInteger( p_this, "ttl" ); |
|---|
| | 170 | if( i_hlim < 1 ) |
|---|
| | 171 | i_hlim = 1; |
|---|
| 179 | 172 | } |
|---|
| 180 | 173 | |
|---|
| r540f7c1 |
r494933e |
|
| 58 | 58 | char *psz_address; |
|---|
| 59 | 59 | char psz_machine[NI_MAXNUMERICHOST]; |
|---|
| 60 | | int i_port; |
|---|
| 61 | 60 | int i_rfd; /* Read socket */ |
|---|
| 62 | 61 | int i_wfd; /* Write socket */ |
|---|
| … | … | |
| 371 | 370 | } |
|---|
| 372 | 371 | p_address->psz_address = strdup( psz_addr ); |
|---|
| 373 | | p_address->i_port = 9875; |
|---|
| 374 | | p_address->i_wfd = net_OpenUDP( p_sap, "", 0, psz_addr, |
|---|
| 375 | | p_address->i_port ); |
|---|
| | 372 | p_address->i_wfd = net_ConnectUDP( p_sap, psz_addr, SAP_PORT, 0 ); |
|---|
| 376 | 373 | if( p_address->i_wfd != -1 ) |
|---|
| 377 | 374 | { |
|---|
| … | … | |
| 390 | 387 | if( p_sap->b_control == VLC_TRUE ) |
|---|
| 391 | 388 | { |
|---|
| 392 | | p_address->i_rfd = net_OpenUDP( p_sap, psz_addr, |
|---|
| 393 | | p_address->i_port, "", 0 ); |
|---|
| | 389 | p_address->i_rfd = net_OpenUDP( p_sap, psz_addr, SAP_PORT, "", 0 ); |
|---|
| 394 | 390 | if( p_address->i_rfd != -1 ) |
|---|
| 395 | 391 | net_StopSend( p_address->i_rfd ); |
|---|
| … | … | |
| 559 | 555 | p_session->psz_data, |
|---|
| 560 | 556 | p_session->i_length ); |
|---|
| 561 | | if( i_ret != p_session->i_length ) |
|---|
| | 557 | if( i_ret != (int)p_session->i_length ) |
|---|
| 562 | 558 | { |
|---|
| 563 | 559 | msg_Warn( p_sap, "SAP send failed on address %s (%i %i)", |
|---|
| … | … | |
| 629 | 625 | psz_group ? psz_group : "", psz_group ? "\r\n" : "" ) == -1 ) |
|---|
| 630 | 626 | return NULL; |
|---|
| 631 | | |
|---|
| | 627 | |
|---|
| 632 | 628 | msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp), |
|---|
| 633 | 629 | psz_sdp ); |
|---|
| … | … | |
| 680 | 676 | #ifdef EXTRA_DEBUG |
|---|
| 681 | 677 | msg_Dbg( p_sap,"%s:%i : Rate=%i, Interval = %i s", |
|---|
| 682 | | p_address->psz_address,p_address->i_port, |
|---|
| 683 | | i_rate, |
|---|
| 684 | | p_address->i_interval ); |
|---|
| | 678 | p_address->psz_address,SAP_PORT, i_rate, p_address->i_interval ); |
|---|
| 685 | 679 | #endif |
|---|
| 686 | 680 | |
|---|