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