]> git.sesse.net Git - vlc/blob - src/stream_output/sap.c
* src/stream_output/sap.c: net_Write() returns an int, not an unsigned.
[vlc] / src / stream_output / sap.c
1 /*****************************************************************************
2  * sap.c : SAP announce handler
3  *****************************************************************************
4  * Copyright (C) 2002-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Rémi Denis-Courmont <rem # videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <stdlib.h>                                                /* free() */
29 #include <stdio.h>                                              /* sprintf() */
30 #include <string.h>                                            /* strerror() */
31 #include <ctype.h>                                  /* tolower(), isxdigit() */
32
33 #include <vlc/vlc.h>
34 #include <vlc/sout.h>
35
36 #include "network.h"
37 #include "charset.h"
38
39 /* SAP is always on that port */
40 #define SAP_PORT 9875
41
42 #define DEFAULT_PORT "1234"
43
44 #undef EXTRA_DEBUG
45
46 /* SAP Specific structures */
47
48 /* 100ms */
49 #define SAP_IDLE ((mtime_t)(0.100*CLOCK_FREQ))
50 #define SAP_MAX_BUFFER 65534
51 #define MIN_INTERVAL 2
52 #define MAX_INTERVAL 300
53
54 /* A SAP announce address. For each of these, we run the
55  * control flow algorithm */
56 struct sap_address_t
57 {
58     char *psz_address;
59     char psz_machine[NI_MAXNUMERICHOST];
60     int i_port;
61     int i_rfd; /* Read socket */
62     int i_wfd; /* Write socket */
63
64     /* Used for flow control */
65     mtime_t t1;
66     vlc_bool_t b_enabled;
67     vlc_bool_t b_ready;
68     int i_interval;
69     int i_buff;
70     int i_limit;
71 };
72
73 /*****************************************************************************
74  * Local prototypes
75  *****************************************************************************/
76 static void RunThread( vlc_object_t *p_this);
77 static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address );
78 static char *SDPGenerate( sap_handler_t *p_sap,
79                           const session_descriptor_t *p_session,
80                           const sap_address_t *p_addr );
81
82 static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
83                                      sap_session_t *p_session );
84
85
86 static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
87                              session_descriptor_t *p_session );
88
89 static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
90                              session_descriptor_t *p_session );
91
92 #define FREE( p ) if( p ) { free( p ); (p) = NULL; }
93
94
95 /**
96  * Create the SAP handler
97  *
98  * \param p_announce the parent announce_handler
99  * \return the newly created SAP handler or NULL on error
100  */
101 sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
102 {
103     sap_handler_t *p_sap;
104
105     p_sap = vlc_object_create( p_announce, sizeof( sap_handler_t ) );
106
107     if( !p_sap )
108     {
109         msg_Err( p_announce, "out of memory" );
110         return NULL;
111     }
112
113     vlc_mutex_init( p_sap, &p_sap->object_lock );
114
115     p_sap->pf_add = announce_SAPAnnounceAdd;
116     p_sap->pf_del = announce_SAPAnnounceDel;
117
118     p_sap->i_sessions = 0;
119     p_sap->i_addresses = 0;
120     p_sap->i_current_session = 0;
121
122     p_sap->b_control = config_GetInt( p_sap, "sap-flow-control");
123
124     if( vlc_thread_create( p_sap, "sap handler", RunThread,
125                        VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
126     {
127         msg_Dbg( p_announce, "Unable to spawn SAP handler thread");
128         free( p_sap );
129         return NULL;
130     };
131     msg_Dbg( p_announce, "thread created, %i sessions", p_sap->i_sessions);
132     return p_sap;
133 }
134
135 /**
136  *  Destroy the SAP handler
137  *  \param p_this the SAP Handler to destroy
138  *  \return nothing
139  */
140 void announce_SAPHandlerDestroy( sap_handler_t *p_sap )
141 {
142     int i;
143
144     vlc_mutex_destroy( &p_sap->object_lock );
145
146     /* Free the remaining sessions */
147     for( i = 0 ; i< p_sap->i_sessions ; i++)
148     {
149         sap_session_t *p_session = p_sap->pp_sessions[i];
150         FREE( p_session->psz_sdp );
151         FREE( p_session->psz_data );
152         REMOVE_ELEM( p_sap->pp_sessions, p_sap->i_sessions , i );
153         FREE( p_session );
154     }
155
156     /* Free the remaining addresses */
157     for( i = 0 ; i< p_sap->i_addresses ; i++)
158     {
159         sap_address_t *p_address = p_sap->pp_addresses[i];
160         FREE( p_address->psz_address );
161         if( p_address->i_rfd > -1 )
162         {
163             net_Close( p_address->i_rfd );
164         }
165         if( p_address->i_wfd > -1 && p_sap->b_control )
166         {
167             net_Close( p_address->i_wfd );
168         }
169         REMOVE_ELEM( p_sap->pp_addresses, p_sap->i_addresses, i );
170         FREE( p_address );
171     }
172
173     /* Free the structure */
174     vlc_object_destroy( p_sap );
175 }
176
177 /**
178  * main SAP handler thread
179  * \param p_this the SAP Handler object
180  * \return nothing
181  */
182 static void RunThread( vlc_object_t *p_this)
183 {
184     sap_handler_t *p_sap = (sap_handler_t*)p_this;
185     sap_session_t *p_session;
186
187     while( !p_sap->b_die )
188     {
189         int i;
190
191         /* If needed, get the rate info */
192         if( p_sap->b_control == VLC_TRUE )
193         {
194             for( i = 0 ; i< p_sap->i_addresses ; i++)
195             {
196                 if( p_sap->pp_addresses[i]->b_enabled == VLC_TRUE )
197                 {
198                     CalculateRate( p_sap, p_sap->pp_addresses[i] );
199                 }
200             }
201         }
202
203         /* Find the session to announce */
204         vlc_mutex_lock( &p_sap->object_lock );
205         if( p_sap->i_sessions > p_sap->i_current_session + 1)
206         {
207             p_sap->i_current_session++;
208         }
209         else if( p_sap->i_sessions > 0)
210         {
211             p_sap->i_current_session = 0;
212         }
213         else
214         {
215             vlc_mutex_unlock( &p_sap->object_lock );
216             msleep( SAP_IDLE );
217             continue;
218         }
219         p_session = p_sap->pp_sessions[p_sap->i_current_session];
220         vlc_mutex_unlock( &p_sap->object_lock );
221
222         /* And announce it */
223         if( p_session->p_address->b_enabled == VLC_TRUE &&
224             p_session->p_address->b_ready == VLC_TRUE )
225         {
226             announce_SendSAPAnnounce( p_sap, p_session );
227         }
228
229         msleep( SAP_IDLE );
230     }
231 }
232
233 /* Add a SAP announce */
234 static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
235                              session_descriptor_t *p_session )
236 {
237     int i_header_size, i;
238     char *psz_head, psz_addr[NI_MAXNUMERICHOST];
239     vlc_bool_t b_ipv6 = VLC_FALSE;
240     sap_session_t *p_sap_session;
241     mtime_t i_hash;
242     struct addrinfo hints, *res;
243     struct sockaddr_storage addr;
244
245     vlc_mutex_lock( &p_sap->object_lock );
246
247     if( p_session->psz_uri == NULL )
248     {
249         vlc_mutex_unlock( &p_sap->object_lock );
250         msg_Err( p_sap, "*FIXME* Unexpected NULL URI for SAP announce" );
251         msg_Err( p_sap, "This should not happen. VLC needs fixing." );
252         return VLC_EGENERIC;
253     }
254
255     /* Determine SAP multicast address automatically */
256     memset( &hints, 0, sizeof( hints ) );
257     hints.ai_socktype = SOCK_DGRAM;
258     hints.ai_flags = AI_NUMERICHOST;
259
260     i = vlc_getaddrinfo( (vlc_object_t *)p_sap, p_session->psz_uri, 0,
261                          &hints, &res );
262     if( i )
263     {
264         vlc_mutex_unlock( &p_sap->object_lock );
265         msg_Err( p_sap, "Invalid URI for SAP announce: %s: %s",
266                  p_session->psz_uri, vlc_gai_strerror( i ) );
267         return VLC_EGENERIC;
268     }
269
270     if( (unsigned)res->ai_addrlen > sizeof( addr ) )
271     {
272         vlc_mutex_unlock( &p_sap->object_lock );
273         vlc_freeaddrinfo( res );
274         msg_Err( p_sap, "Unsupported address family of size %d > %u",
275                  res->ai_addrlen, sizeof( addr ) );
276         return VLC_EGENERIC;
277     }
278
279     memcpy( &addr, res->ai_addr, res->ai_addrlen );
280
281     switch( addr.ss_family )
282     {
283 #if defined (HAVE_INET_PTON) || defined (WIN32)
284         case AF_INET6:
285         {
286             /* See RFC3513 for list of valid IPv6 scopes */
287             struct in6_addr *a6 = &((struct sockaddr_in6 *)&addr)->sin6_addr;
288
289             memcpy( a6->s6_addr + 2, "\x00\x00\x00\x00\x00\x00"
290                    "\x00\x00\x00\x00\x00\x02\x7f\xfe", 14 );
291             if( IN6_IS_ADDR_MULTICAST( a6 ) )
292                  /* force flags to zero, preserve scope */
293                 a6->s6_addr[1] &= 0xf;
294             else
295                 /* Unicast IPv6 - assume global scope */
296                 memcpy( a6->s6_addr, "\xff\x0e", 2 );
297
298             b_ipv6 = VLC_TRUE;
299             break;
300         }
301 #endif
302
303         case AF_INET:
304         {
305             /* See RFC2365 for IPv4 scopes */
306             uint32_t ipv4;
307
308             ipv4 = ntohl( ((struct sockaddr_in *)&addr)->sin_addr.s_addr );
309             /* 224.0.0.0/24 => 224.0.0.255 */
310             if ((ipv4 & 0xffffff00) == 0xe0000000)
311                 ipv4 =  0xe00000ff;
312             else
313             /* 239.255.0.0/16 => 239.255.255.255 */
314             if ((ipv4 & 0xffff0000) == 0xefff0000)
315                 ipv4 =  0xefffffff;
316             else
317             /* 239.192.0.0/14 => 239.195.255.255 */
318             if ((ipv4 & 0xfffc0000) == 0xefc00000)
319                 ipv4 =  0xefc3ffff;
320             else
321             /* other addresses => 224.2.127.254 */
322                 ipv4 = 0xe0027ffe;
323
324             ((struct sockaddr_in *)&addr)->sin_addr.s_addr = htonl( ipv4 );
325             break;
326         }
327         
328         default:
329             vlc_mutex_unlock( &p_sap->object_lock );
330             vlc_freeaddrinfo( res );
331             msg_Err( p_sap, "Address family %d not supported by SAP",
332                      addr.ss_family );
333             return VLC_EGENERIC;
334     }
335
336     i = vlc_getnameinfo( (struct sockaddr *)&addr, res->ai_addrlen,
337                          psz_addr, sizeof( psz_addr ), NULL, NI_NUMERICHOST );
338     vlc_freeaddrinfo( res );
339
340     if( i )
341     {
342         vlc_mutex_unlock( &p_sap->object_lock );
343         msg_Err( p_sap, "%s", vlc_gai_strerror( i ) );
344         return VLC_EGENERIC;
345     }
346
347     msg_Dbg( p_sap, "using SAP address: %s", psz_addr);
348
349     /* XXX: Check for dupes */
350     p_sap_session = (sap_session_t*)malloc(sizeof(sap_session_t));
351     p_sap_session->p_address = NULL;
352
353     /* Add the address to the buffer */
354     for( i = 0; i < p_sap->i_addresses; i++)
355     {
356         if( !strcmp( psz_addr, p_sap->pp_addresses[i]->psz_address ) )
357         {
358             p_sap_session->p_address = p_sap->pp_addresses[i];
359             break;
360         }
361     }
362
363     if( p_sap_session->p_address == NULL )
364     {
365         sap_address_t *p_address = (sap_address_t *)
366                                     malloc( sizeof(sap_address_t) );
367         if( !p_address )
368         {
369             msg_Err( p_sap, "out of memory" );
370             return VLC_ENOMEM;
371         }
372         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 );
376         if( p_address->i_wfd != -1 )
377         {
378             char *ptr;
379
380             net_StopRecv( p_address->i_wfd );
381             net_GetSockAddress( p_address->i_wfd, p_address->psz_machine,
382                                 NULL );
383
384             /* removes scope if present */
385             ptr = strchr( p_address->psz_machine, '%' );
386             if( ptr != NULL )
387                 *ptr = '\0';
388         }
389
390         if( p_sap->b_control == VLC_TRUE )
391         {
392             p_address->i_rfd = net_OpenUDP( p_sap, psz_addr,
393                                             p_address->i_port, "", 0 );
394             if( p_address->i_rfd != -1 )
395                 net_StopSend( p_address->i_rfd );
396             p_address->i_buff = 0;
397             p_address->b_enabled = VLC_TRUE;
398             p_address->b_ready = VLC_FALSE;
399             p_address->i_limit = 10000; /* 10000 bps */
400             p_address->t1 = 0;
401         }
402         else
403         {
404             p_address->b_enabled = VLC_TRUE;
405             p_address->b_ready = VLC_TRUE;
406             p_address->i_interval = config_GetInt( p_sap,"sap-interval");
407             p_address->i_rfd = -1;
408         }
409
410         if( p_address->i_wfd == -1 || (p_address->i_rfd == -1
411                                         && p_sap->b_control ) )
412         {
413             msg_Warn( p_sap, "disabling address" );
414             p_address->b_enabled = VLC_FALSE;
415         }
416
417         INSERT_ELEM( p_sap->pp_addresses,
418                      p_sap->i_addresses,
419                      p_sap->i_addresses,
420                      p_address );
421         p_sap_session->p_address = p_address;
422     }
423
424
425     /* Build the SAP Headers */
426     i_header_size = ( b_ipv6 ? 16 : 4 ) + 20;
427     psz_head = (char *) malloc( i_header_size * sizeof( char ) );
428     if( psz_head == NULL )
429     {
430         msg_Err( p_sap, "out of memory" );
431         return VLC_ENOMEM;
432     }
433
434     /* SAPv1, not encrypted, not compressed */
435     psz_head[0] = b_ipv6 ? 0x30 : 0x20;
436     psz_head[1] = 0x00; /* No authentification length */
437
438     i_hash = mdate();
439     psz_head[2] = (i_hash & 0xFF00) >> 8; /* Msg id hash */
440     psz_head[3] = (i_hash & 0xFF);        /* Msg id hash 2 */
441
442 #if defined (HAVE_INET_PTON) || defined (WIN32)
443     if( b_ipv6 )
444     {
445         inet_pton( AF_INET6, /* can't fail */
446                    p_sap_session->p_address->psz_machine,
447                    psz_head + 4 );
448     }
449     else
450 #else
451     {
452         inet_pton( AF_INET, /* can't fail */
453                    p_sap_session->p_address->psz_machine,
454                    psz_head + 4 );
455     }
456 #endif
457
458     memcpy( psz_head + (b_ipv6 ? 20 : 8), "application/sdp", 15 );
459
460     /* If needed, build the SDP */
461     if( p_session->psz_sdp == NULL )
462     {
463         p_session->psz_sdp = SDPGenerate( p_sap, p_session,
464                                           p_sap_session->p_address );
465         if( p_session->psz_sdp == NULL )
466         {
467             vlc_mutex_unlock( &p_sap->object_lock );
468             return VLC_ENOMEM;
469         }
470     }
471
472     p_sap_session->psz_sdp = strdup( p_session->psz_sdp );
473     p_sap_session->i_last = 0;
474
475     psz_head[ i_header_size-1 ] = '\0';
476     p_sap_session->i_length = i_header_size + strlen( p_sap_session->psz_sdp);
477
478     p_sap_session->psz_data = (uint8_t *)malloc( sizeof(char)*
479                                                  p_sap_session->i_length );
480
481     /* Build the final message */
482     memcpy( p_sap_session->psz_data, psz_head, i_header_size );
483     memcpy( p_sap_session->psz_data+i_header_size, p_sap_session->psz_sdp,
484             strlen( p_sap_session->psz_sdp) );
485
486     free( psz_head );
487
488     /* Enqueue the announce */
489     INSERT_ELEM( p_sap->pp_sessions,
490                  p_sap->i_sessions,
491                  p_sap->i_sessions,
492                  p_sap_session );
493     msg_Dbg( p_sap,"Addresses: %i  Sessions: %i",
494                    p_sap->i_addresses,p_sap->i_sessions);
495
496     /* Remember the SAP session for later deletion */
497     p_session->p_sap = p_sap_session;
498
499     vlc_mutex_unlock( &p_sap->object_lock );
500
501     return VLC_SUCCESS;
502 }
503
504 /* Remove a SAP Announce */
505 static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
506                              session_descriptor_t *p_session )
507 {
508     int i;
509     vlc_mutex_lock( &p_sap->object_lock );
510
511     msg_Dbg( p_sap,"removing SAP announce %p",p_session->p_sap);
512
513     /* Dequeue the announce */
514     for( i = 0; i< p_sap->i_sessions; i++)
515     {
516         if( p_session->p_sap == p_sap->pp_sessions[i] )
517         {
518             REMOVE_ELEM( p_sap->pp_sessions,
519                          p_sap->i_sessions,
520                          i );
521
522             FREE( p_session->p_sap->psz_sdp );
523             FREE( p_session->p_sap->psz_data );
524             free( p_session->p_sap );
525             break;
526         }
527     }
528
529     /* XXX: Dequeue the address too if it is not used anymore
530      * TODO: - address refcount
531              - send a SAP deletion packet */
532
533     msg_Dbg( p_sap,"%i announces remaining", p_sap->i_sessions );
534
535     vlc_mutex_unlock( &p_sap->object_lock );
536
537     return VLC_SUCCESS;
538 }
539
540 static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
541                                      sap_session_t *p_session )
542 {
543     int i_ret;
544
545     /* This announce has never been sent yet */
546     if( p_session->i_last == 0 )
547     {
548         p_session->i_next = mdate()+ p_session->p_address->i_interval*1000000;
549         p_session->i_last = 1;
550         return VLC_SUCCESS;
551     }
552
553     if( p_session->i_next < mdate() )
554     {
555 #ifdef EXTRA_DEBUG
556         msg_Dbg( p_sap, "Sending announce");
557 #endif
558         i_ret = net_Write( p_sap, p_session->p_address->i_wfd, NULL,
559                            p_session->psz_data,
560                            p_session->i_length );
561         if( i_ret != p_session->i_length )
562         {
563             msg_Warn( p_sap, "SAP send failed on address %s (%i %i)",
564                       p_session->p_address->psz_address,
565                       i_ret, p_session->i_length );
566         }
567         p_session->i_last = p_session->i_next;
568         p_session->i_next = p_session->i_last
569                             + p_session->p_address->i_interval*1000000;
570     }
571     else
572     {
573         return VLC_SUCCESS;
574     }
575     return VLC_SUCCESS;
576 }
577
578 static char *SDPGenerate( sap_handler_t *p_sap,
579                           const session_descriptor_t *p_session,
580                           const sap_address_t *p_addr )
581 {
582     int64_t i_sdp_id = mdate();
583     int     i_sdp_version = 1 + p_sap->i_sessions + (rand()&0xfff);
584     char *psz_group, *psz_name, psz_uribuf[NI_MAXNUMERICHOST], *psz_uri,
585          *psz_sdp;
586     char ipv;
587
588     psz_group = p_session->psz_group;
589     psz_name = p_session->psz_name;
590
591     /* FIXME: really check that psz_uri is a real IP address
592      * FIXME: make a common function to obtain a canonical IP address */
593     ipv = ( strchr( p_session->psz_uri, ':' )  != NULL) ? '6' : '4';
594     if( *p_session->psz_uri == '[' )
595     {
596         char *ptr;
597
598         strncpy( psz_uribuf, p_session->psz_uri + 1, sizeof( psz_uribuf ) );
599         psz_uribuf[sizeof( psz_uribuf ) - 1] = '\0';
600         ptr = strchr( psz_uribuf, '%' );
601         if( ptr != NULL)
602             *ptr = '\0';
603         ptr = strchr( psz_uribuf, ']' );
604         if( ptr != NULL)
605             *ptr = '\0';
606         psz_uri = psz_uribuf;
607     }
608     else
609         psz_uri = p_session->psz_uri;
610
611     /* see the lists in modules/stream_out/rtp.c for compliance stuff */
612     if( asprintf( &psz_sdp,
613                             "v=0\r\n"
614                             "o=- "I64Fd" %d IN IP%c %s\r\n"
615                             "s=%s\r\n"
616                             "t=0 0\r\n"
617                             "c=IN IP%c %s/%d\r\n"
618                             "m=video %d udp %d\r\n"
619                             "a=tool:"PACKAGE_STRING"\r\n"
620                             "a=type:broadcast\r\n"
621                             "%s%s%s",
622                             i_sdp_id, i_sdp_version,
623                             ipv, p_addr->psz_machine,
624                             psz_name, ipv,
625                             psz_uri, p_session->i_ttl,
626                             p_session->i_port, p_session->i_payload,
627                             psz_group ? "a=x-plgroup:" : "",
628                             psz_group ? psz_group : "", psz_group ? "\r\n" : "" ) == -1 )
629         return NULL;
630     
631     msg_Dbg( p_sap, "Generated SDP (%i bytes):\n%s", strlen(psz_sdp),
632              psz_sdp );
633     return psz_sdp;
634 }
635
636 static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
637 {
638     int i_read;
639     uint8_t buffer[SAP_MAX_BUFFER];
640     int i_tot = 0;
641     mtime_t i_temp;
642     int i_rate;
643
644     if( p_address->t1 == 0 )
645     {
646         p_address->t1 = mdate();
647         return VLC_SUCCESS;
648     }
649     do
650     {
651         /* Might be too slow if we have huge data */
652         i_read = net_ReadNonBlock( p_sap, p_address->i_rfd, NULL, buffer,
653                                    SAP_MAX_BUFFER, 0 );
654         i_tot += i_read;
655     } while( i_read > 0 && i_tot < SAP_MAX_BUFFER );
656
657     i_temp = mdate();
658
659     /* We calculate the rate every 5 seconds */
660     if( i_temp - p_address->t1 < 5000000 )
661     {
662         p_address->i_buff += i_tot;
663         return VLC_SUCCESS;
664     }
665
666     /* Bits/second */
667     i_rate = (int)(8*1000000*((mtime_t)p_address->i_buff + (mtime_t)i_tot ) /
668                         (i_temp - p_address->t1 ));
669
670     p_address->i_limit = 10000;
671
672     p_address->i_interval = ((1000*i_rate / p_address->i_limit) *
673                             (MAX_INTERVAL - MIN_INTERVAL))/1000 + MIN_INTERVAL;
674
675     if( p_address->i_interval > MAX_INTERVAL || p_address->i_interval < 0 )
676     {
677         p_address->i_interval = MAX_INTERVAL;
678     }
679 #ifdef EXTRA_DEBUG
680     msg_Dbg( p_sap,"%s:%i : Rate=%i, Interval = %i s",
681                     p_address->psz_address,p_address->i_port,
682                     i_rate,
683                     p_address->i_interval );
684 #endif
685
686     p_address->b_ready = VLC_TRUE;
687
688     p_address->t1 = i_temp;
689     p_address->i_buff = 0;
690
691     return VLC_SUCCESS;
692 }