]> git.sesse.net Git - vlc/blob - modules/stream_out/rtsp.c
Fix a bunch of bugs I added, and simplify some stuff
[vlc] / modules / stream_out / rtsp.c
1 /*****************************************************************************
2  * rtsp.c: RTSP support for RTP stream output module
3  *****************************************************************************
4  * Copyright (C) 2003-2004 the VideoLAN team
5  * Copyright © 2007 Rémi Denis-Courmont
6  *
7  * $Id: rtp.c 21407 2007-08-22 20:10:41Z courmisch $
8  *
9  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include <vlc/vlc.h>
30 #include <vlc_sout.h>
31
32 #include <vlc_httpd.h>
33 #include <vlc_url.h>
34 #include <vlc_network.h>
35 #include <assert.h>
36 #include <errno.h>
37 #include <stdlib.h>
38
39 #include "rtp.h"
40
41 typedef struct rtsp_session_t rtsp_session_t;
42
43 struct rtsp_stream_t
44 {
45     vlc_mutex_t     lock;
46     sout_stream_t  *owner;
47     httpd_host_t   *host;
48     httpd_url_t    *url;
49     char           *psz_control;
50     char           *psz_path;
51
52     int             sessionc;
53     rtsp_session_t **sessionv;
54 };
55
56
57 static int  RtspCallback( httpd_callback_sys_t *p_args,
58                           httpd_client_t *cl, httpd_message_t *answer,
59                           const httpd_message_t *query );
60 static int  RtspCallbackId( httpd_callback_sys_t *p_args,
61                             httpd_client_t *cl, httpd_message_t *answer,
62                             const httpd_message_t *query );
63 static void RtspClientDel( rtsp_stream_t *rtsp, rtsp_session_t *session );
64
65 rtsp_stream_t *RtspSetup( sout_stream_t *p_stream, const vlc_url_t *url )
66 {
67     rtsp_stream_t *rtsp = malloc( sizeof( *rtsp ) );
68
69     if( rtsp == NULL )
70         return NULL;
71
72     rtsp->owner = p_stream;
73     rtsp->sessionc = 0;
74     rtsp->sessionv = NULL;
75     vlc_mutex_init( p_stream, &rtsp->lock );
76
77     msg_Dbg( p_stream, "rtsp setup: %s : %d / %s\n",
78              url->psz_host, url->i_port, url->psz_path );
79
80     rtsp->psz_path = strdup( url->psz_path ? url->psz_path : "/" );
81     if( rtsp->psz_path == NULL )
82         goto error;
83
84     if( asprintf( &rtsp->psz_control, "rtsp://%s:%d%s",
85                   url->psz_host,  url->i_port > 0 ? url->i_port : 554,
86                   rtsp->psz_path ) == -1 )
87     {
88         rtsp->psz_control = NULL;
89         goto error;
90     }
91
92     rtsp->host = httpd_HostNew( VLC_OBJECT(p_stream), url->psz_host,
93                                 url->i_port > 0 ? url->i_port : 554 );
94     if( rtsp->host == NULL )
95         goto error;
96
97     rtsp->url = httpd_UrlNewUnique( rtsp->host, rtsp->psz_path, NULL, NULL,
98                                     NULL );
99     if( rtsp->url == NULL )
100         goto error;
101
102     httpd_UrlCatch( rtsp->url, HTTPD_MSG_DESCRIBE, RtspCallback, (void*)rtsp );
103     httpd_UrlCatch( rtsp->url, HTTPD_MSG_SETUP,    RtspCallback, (void*)rtsp );
104     httpd_UrlCatch( rtsp->url, HTTPD_MSG_PLAY,     RtspCallback, (void*)rtsp );
105     httpd_UrlCatch( rtsp->url, HTTPD_MSG_PAUSE,    RtspCallback, (void*)rtsp );
106     httpd_UrlCatch( rtsp->url, HTTPD_MSG_TEARDOWN, RtspCallback, (void*)rtsp );
107     return rtsp;
108
109 error:
110     RtspUnsetup( rtsp );
111     return NULL;
112 }
113
114
115 void RtspUnsetup( rtsp_stream_t *rtsp )
116 {
117     while( rtsp->sessionc > 0 )
118         RtspClientDel( rtsp, rtsp->sessionv[0] );
119
120     if( rtsp->url )
121         httpd_UrlDelete( rtsp->url );
122
123     if( rtsp->host )
124         httpd_HostDelete( rtsp->host );
125
126     vlc_mutex_destroy( &rtsp->lock );
127 }
128
129
130 struct rtsp_stream_id_t
131 {
132     rtsp_stream_t    *stream;
133     sout_stream_id_t *sout_id;
134     httpd_url_t      *url;
135     const char       *dst;
136     int               ttl;
137     unsigned          loport, hiport;
138 };
139
140
141 typedef struct rtsp_strack_t rtsp_strack_t;
142
143 /* For unicast streaming */
144 struct rtsp_session_t
145 {
146     rtsp_stream_t *stream;
147     uint64_t       id;
148
149     /* output (id-access) */
150     int            trackc;
151     rtsp_strack_t *trackv;
152 };
153
154
155 /* Unicast session track */
156 struct rtsp_strack_t
157 {
158     sout_stream_id_t  *id;
159     sout_access_out_t *access;
160     vlc_bool_t         playing;
161 };
162
163
164 rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
165                              unsigned num,
166                              /* Multicast stuff - TODO: cleanup */
167                              const char *dst, int ttl,
168                              unsigned loport, unsigned hiport )
169 {
170     char urlbuf[strlen( rtsp->psz_control ) + 1 + 10];
171     rtsp_stream_id_t *id = malloc( sizeof( *id ) );
172     httpd_url_t *url;
173
174     if( id == NULL )
175         return NULL;
176
177     id->stream = rtsp;
178     id->sout_id = sid;
179     /* TODO: can we assume that this need not be strdup'd? */
180     id->dst = dst;
181     if( id->dst != NULL )
182     {
183         id->ttl = ttl;
184         id->loport = loport;
185         id->hiport = hiport;
186     }
187
188     sprintf( urlbuf, "%s/trackID=%d", rtsp->psz_path, num );
189     msg_Dbg( rtsp->owner, "RTSP: adding %s\n", urlbuf );
190     url = id->url = httpd_UrlNewUnique( rtsp->host, urlbuf, NULL, NULL, NULL );
191
192     if( url == NULL )
193     {
194         free( id );
195         return NULL;
196     }
197
198     httpd_UrlCatch( url, HTTPD_MSG_DESCRIBE, RtspCallbackId, (void *)id );
199     httpd_UrlCatch( url, HTTPD_MSG_SETUP,    RtspCallbackId, (void *)id );
200     httpd_UrlCatch( url, HTTPD_MSG_PLAY,     RtspCallbackId, (void *)id );
201     httpd_UrlCatch( url, HTTPD_MSG_PAUSE,    RtspCallbackId, (void *)id );
202     httpd_UrlCatch( url, HTTPD_MSG_TEARDOWN, RtspCallbackId, (void *)id );
203
204     return id;
205 }
206
207
208 void RtspDelId( rtsp_stream_t *rtsp, rtsp_stream_id_t *id )
209 {
210     vlc_mutex_lock( &rtsp->lock );
211     for( int i = 0; i < rtsp->sessionc; i++ )
212     {
213         rtsp_session_t *ses = rtsp->sessionv[i];
214
215         for( int j = 0; j < ses->trackc; j++ )
216         {
217             if( ses->trackv[j].id == id->sout_id )
218             {
219                 rtsp_strack_t *tr = ses->trackv + j;
220                 sout_AccessOutDelete( tr->access );
221                 REMOVE_ELEM( ses->trackv, ses->trackc, j );
222                 /* FIXME: are we supposed to notify the client? */
223             }
224         }
225     }
226
227     vlc_mutex_unlock( &rtsp->lock );
228     httpd_UrlDelete( id->url );
229     free( id );
230 }
231
232
233 /** rtsp must be locked */
234 static
235 rtsp_session_t *RtspClientNew( rtsp_stream_t *rtsp )
236 {
237     rtsp_session_t *s = malloc( sizeof( *s ) );
238     if( s == NULL )
239         return NULL;
240
241     s->stream = rtsp;
242     s->id = rand(); /* FIXME: not enough entropy */
243     s->trackc = 0;
244     s->trackv = NULL;
245
246     TAB_APPEND( rtsp->sessionc, rtsp->sessionv, s );
247
248     return s;
249 }
250
251
252 /** rtsp must be locked */
253 static
254 rtsp_session_t *RtspClientGet( rtsp_stream_t *rtsp, const char *name )
255 {
256     char *end;
257     uint64_t id;
258     int i;
259
260     if( name == NULL )
261         return NULL;
262
263     errno = 0;
264     id = strtoull( name, &end, 0x10 );
265     if( errno || *end )
266         return NULL;
267
268     /* FIXME: use a hash/dictionary */
269     for( i = 0; i < rtsp->sessionc; i++ )
270     {
271         if( rtsp->sessionv[i]->id == id )
272             return rtsp->sessionv[i];
273     }
274     return NULL;
275 }
276
277
278 /** rtsp must be locked */
279 static
280 void RtspClientDel( rtsp_stream_t *rtsp, rtsp_session_t *session )
281 {
282     int i;
283     TAB_REMOVE( rtsp->sessionc, rtsp->sessionv, session );
284
285     for( i = 0; i < session->trackc; i++ )
286     {
287         rtp_del_sink( session->trackv[i].id, session->trackv[i].access );
288         sout_AccessOutDelete( session->trackv[i].access );
289     }
290
291     free( session->trackv );
292     free( session );
293 }
294
295
296 /** Aggregate RTSP callback */
297 static int RtspCallback( httpd_callback_sys_t *p_args,
298                          httpd_client_t *cl,
299                          httpd_message_t *answer,
300                          const httpd_message_t *query )
301 {
302     rtsp_stream_t *rtsp = (rtsp_stream_t *)p_args;
303     const char *psz_session = NULL, *psz;
304
305     if( answer == NULL || query == NULL )
306     {
307         return VLC_SUCCESS;
308     }
309     //fprintf( stderr, "RtspCallback query: type=%d\n", query->i_type );
310
311     answer->i_proto = HTTPD_PROTO_RTSP;
312     answer->i_version= query->i_version;
313     answer->i_type   = HTTPD_MSG_ANSWER;
314     answer->i_body = 0;
315     answer->p_body = NULL;
316
317     if( httpd_MsgGet( query, "Require" ) != NULL )
318     {
319         answer->i_status = 551;
320         httpd_MsgAdd( answer, "Unsupported", "%s",
321                       httpd_MsgGet( query, "Require" ) );
322     }
323     else
324     switch( query->i_type )
325     {
326         case HTTPD_MSG_DESCRIBE:
327         {
328             char *psz_sdp = SDPGenerate( rtsp->owner, rtsp->psz_control );
329
330             answer->i_status = 200;
331             httpd_MsgAdd( answer, "Content-Type",  "%s", "application/sdp" );
332             httpd_MsgAdd( answer, "Content-Base",  "%s", rtsp->psz_control );
333             answer->p_body = (uint8_t *)psz_sdp;
334             answer->i_body = strlen( psz_sdp );
335             break;
336         }
337
338         case HTTPD_MSG_SETUP:
339             answer->i_status = 459;
340             break;
341
342         case HTTPD_MSG_PLAY:
343         {
344             rtsp_session_t *ses;
345             answer->i_status = 200;
346
347             psz_session = httpd_MsgGet( query, "Session" );
348             if( httpd_MsgGet( query, "Range" ) != NULL )
349             {
350                 answer->i_status = 456; /* cannot seek */
351                 break;
352             }
353
354             vlc_mutex_lock( &rtsp->lock );
355             ses = RtspClientGet( rtsp, psz_session );
356             if( ses != NULL )
357             {
358                 for( int i = 0; i < ses->trackc; i++ )
359                 {
360                     rtsp_strack_t *tr = ses->trackv + i;
361                     if( !tr->playing )
362                     {
363                         tr->playing = VLC_TRUE;
364                         rtp_add_sink( tr->id, tr->access );
365                     }
366                 }
367             }
368             vlc_mutex_unlock( &rtsp->lock );
369
370             if( httpd_MsgGet( query, "Scale" ) != NULL )
371                 httpd_MsgAdd( answer, "Scale", "1." );
372             break;
373         }
374
375         case HTTPD_MSG_PAUSE:
376             answer->i_status = 405;
377             httpd_MsgAdd( answer, "Allow", "DESCRIBE, PLAY, TEARDOWN" );
378             break;
379
380         case HTTPD_MSG_TEARDOWN:
381         {
382             rtsp_session_t *ses;
383
384             /* for now only multicast so easy again */
385             answer->i_status = 200;
386
387             psz_session = httpd_MsgGet( query, "Session" );
388
389             vlc_mutex_lock( &rtsp->lock );
390             ses = RtspClientGet( rtsp, psz_session );
391             if( ses != NULL )
392                 RtspClientDel( rtsp, ses );
393             vlc_mutex_unlock( &rtsp->lock );
394             break;
395         }
396
397         default:
398             return VLC_EGENERIC;
399     }
400
401     httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
402     httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
403
404     psz = httpd_MsgGet( query, "Cseq" );
405     if( psz != NULL )
406         httpd_MsgAdd( answer, "Cseq", "%s", psz );
407     psz = httpd_MsgGet( query, "Timestamp" );
408     if( psz != NULL )
409         httpd_MsgAdd( answer, "Timestamp", "%s", psz );
410
411     httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
412
413     if( psz_session )
414         httpd_MsgAdd( answer, "Session", "%s;timeout=5", psz_session );
415     return VLC_SUCCESS;
416 }
417
418
419 /** Finds the next transport choice */
420 static inline const char *transport_next( const char *str )
421 {
422     /* Looks for comma */
423     str = strchr( str, ',' );
424     if( str == NULL )
425         return NULL; /* No more transport options */
426
427     str++; /* skips comma */
428     while( strchr( "\r\n\t ", *str ) )
429         str++;
430
431     return (*str) ? str : NULL;
432 }
433
434
435 /** Finds the next transport parameter */
436 static inline const char *parameter_next( const char *str )
437 {
438     while( strchr( ",;", *str ) == NULL )
439         str++;
440
441     return (*str == ';') ? (str + 1) : NULL;
442 }
443
444
445 /** Non-aggregate RTSP callback */
446 static int RtspCallbackId( httpd_callback_sys_t *p_args,
447                            httpd_client_t *cl,
448                            httpd_message_t *answer,
449                            const httpd_message_t *query )
450 {
451     rtsp_stream_id_t *id = (rtsp_stream_id_t *)p_args;
452     rtsp_stream_t    *rtsp = id->stream;
453     sout_stream_t    *p_stream = id->stream->owner;
454     char psz_sesbuf[17];
455     const char *psz_session, *psz;
456
457     if( answer == NULL || query == NULL )
458         return VLC_SUCCESS;
459
460     /* */
461     answer->i_proto = HTTPD_PROTO_RTSP;
462     answer->i_version= query->i_version;
463     answer->i_type   = HTTPD_MSG_ANSWER;
464     answer->i_body = 0;
465     answer->p_body = NULL;
466
467     psz_session = httpd_MsgGet( query, "Session" );
468
469     if( httpd_MsgGet( query, "Require" ) != NULL )
470     {
471         answer->i_status = 551;
472         httpd_MsgAdd( answer, "Unsupported", "%s",
473                       httpd_MsgGet( query, "Require" ) );
474     }
475     else
476     switch( query->i_type )
477     {
478         case HTTPD_MSG_SETUP:
479         {
480             answer->i_status = 461;
481
482             for( const char *tpt = httpd_MsgGet( query, "Transport" );
483                  tpt != NULL;
484                  tpt = transport_next( tpt ) )
485             {
486                 vlc_bool_t b_multicast = VLC_TRUE, b_unsupp = VLC_FALSE;
487                 unsigned loport = 5004, hiport = 5005; /* from RFC3551 */
488
489                 /* Check transport protocol. */
490                 /* Currently, we only support RTP/AVP over UDP */
491                 if( strncmp( tpt, "RTP/AVP", 7 ) )
492                     continue;
493                 tpt += 7;
494                 if( strncmp( tpt, "/UDP", 4 ) == 0 )
495                     tpt += 4;
496                 if( strchr( ";,", *tpt ) == NULL )
497                     continue;
498
499                 /* Parse transport options */
500                 for( const char *opt = parameter_next( tpt );
501                      opt != NULL;
502                      opt = parameter_next( opt ) )
503                 {
504                     if( strncmp( opt, "multicast", 9 ) == 0)
505                         b_multicast = VLC_TRUE;
506                     else
507                     if( strncmp( opt, "unicast", 7 ) == 0 )
508                         b_multicast = VLC_FALSE;
509                     else
510                     if( sscanf( opt, "client_port=%u-%u", &loport, &hiport ) == 2 )
511                         ;
512                     else
513                     if( strncmp( opt, "mode=", 5 ) == 0 )
514                     {
515                         if( strncasecmp( opt + 5, "play", 4 )
516                          && strncasecmp( opt + 5, "\"PLAY\"", 6 ) )
517                         {
518                             /* Not playing?! */
519                             b_unsupp = VLC_TRUE;
520                             break;
521                         }
522                     }
523                     else
524                     if( strncmp( opt,"destination=", 12 ) == 0 )
525                     {
526                         answer->i_status = 403;
527                         b_unsupp = VLC_TRUE;
528                     }
529                     else
530                     {
531                     /*
532                      * Every other option is unsupported:
533                      *
534                      * "source" and "append" are invalid (server-only);
535                      * "ssrc" also (as clarified per RFC2326bis).
536                      *
537                      * For multicast, "port", "layers", "ttl" are set by the
538                      * stream output configuration.
539                      *
540                      * For unicast, we want to decide "server_port" values.
541                      *
542                      * "interleaved" is not implemented.
543                      */
544                         b_unsupp = VLC_TRUE;
545                         break;
546                     }
547                 }
548
549                 if( b_unsupp )
550                     continue;
551
552                 if( b_multicast )
553                 {
554                     const char *dst = id->dst;
555                     if( dst == NULL )
556                         continue;
557
558                     answer->i_status = 200;
559
560                     httpd_MsgAdd( answer, "Transport",
561                                   "RTP/AVP/UDP;destination=%s;port=%u-%u;"
562                                   "ttl=%d;mode=play",
563                                   dst, id->loport, id->hiport,
564                                   ( id->ttl > 0 ) ? id->ttl : 1 );
565                 }
566                 else
567                 {
568                     char ip[NI_MAXNUMERICHOST], url[NI_MAXNUMERICHOST + 8];
569                     static const char access[] = "udp{raw,rtcp}";
570                     rtsp_session_t *ses = NULL;
571                     rtsp_strack_t track = { id->sout_id, NULL, VLC_FALSE };
572
573                     if( httpd_ClientIP( cl, ip ) == NULL )
574                     {
575                         answer->i_status = 500;
576                         continue;
577                     }
578
579                     snprintf( url, sizeof( url ),
580                               ( strchr( ip, ':' ) != NULL ) ? "[%s]:%d" : "%s:%d",
581                               ip, loport );
582
583                     track.access = sout_AccessOutNew( p_stream->p_sout,
584                                                       access, url );
585                     if( track.access == NULL )
586                     {
587                         msg_Err( p_stream,
588                                  "cannot create access output for %s://%s",
589                                  access, url );
590                         answer->i_status = 500;
591                         continue;
592                     }
593
594                     char *src = var_GetNonEmptyString( track.access, "src-addr" );
595                     int sport = var_GetInteger( track.access, "src-port" );
596
597                     vlc_mutex_lock( &rtsp->lock );
598                     if( psz_session == NULL )
599                     {
600                         ses = RtspClientNew( rtsp );
601                         snprintf( psz_sesbuf, sizeof( psz_sesbuf ), I64Fx,
602                                   ses->id );
603                         psz_session = psz_sesbuf;
604                     }
605                     else
606                     {
607                         /* FIXME: we probably need to remove an access out,
608                          * if there is already one for the same ID */
609                         ses = RtspClientGet( rtsp, psz_session );
610                         if( ses == NULL )
611                         {
612                             answer->i_status = 454;
613                             vlc_mutex_unlock( &rtsp->lock );
614                             continue;
615                         }
616                     }
617
618                     INSERT_ELEM( ses->trackv, ses->trackc, ses->trackc, track );
619                     vlc_mutex_unlock( &rtsp->lock );
620
621                     httpd_ServerIP( cl, ip );
622
623                     if( ( src != NULL ) && strcmp( src, ip ) )
624                     {
625                         /* Specify source IP if it is different from the RTSP
626                          * control connection server address */
627                         char *ptr = strchr( src, '%' );
628                         if( ptr != NULL ) *ptr = '\0'; /* remove scope ID */
629
630                         httpd_MsgAdd( answer, "Transport",
631                                       "RTP/AVP/UDP;unicast;source=%s;"
632                                       "client_port=%u-%u;server_port=%u-%u;"
633                                       "mode=play",
634                                       src, loport, loport + 1, sport, sport + 1 );
635                     }
636                     else
637                     {
638                         httpd_MsgAdd( answer, "Transport",
639                                       "RTP/AVP/UDP;unicast;"
640                                       "client_port=%u-%u;server_port=%u-%u;"
641                                       "mode=play",
642                                       loport, loport + 1, sport, sport + 1 );
643                     }
644
645                     answer->i_status = 200;
646                     free( src );
647                 }
648                 break;
649             }
650             break;
651         }
652
653         case HTTPD_MSG_PLAY:
654         {
655             rtsp_session_t *ses;
656             answer->i_status = 200;
657
658             psz_session = httpd_MsgGet( query, "Session" );
659             if( httpd_MsgGet( query, "Range" ) != NULL )
660             {
661                 answer->i_status = 456; /* cannot seek */
662                 break;
663             }
664
665             vlc_mutex_lock( &rtsp->lock );
666             ses = RtspClientGet( rtsp, psz_session );
667             if( ses != NULL )
668             {
669                 for( int i = 0; i < ses->trackc; i++ )
670                 {
671                     rtsp_strack_t *tr = ses->trackv + i;
672                     if( !tr->playing && ( tr->id == id->sout_id ) )
673                     {
674                         tr->playing = VLC_TRUE;
675                         rtp_add_sink( tr->id, tr->access );
676                     }
677                 }
678             }
679             vlc_mutex_unlock( &rtsp->lock );
680
681             if( httpd_MsgGet( query, "Scale" ) != NULL )
682                 httpd_MsgAdd( answer, "Scale", "1." );
683             break;
684         }
685
686         case HTTPD_MSG_PAUSE:
687             answer->i_status = 405;
688             httpd_MsgAdd( answer, "Allow", "SETUP, PLAY, TEARDOWN" );
689             break;
690
691         case HTTPD_MSG_TEARDOWN:
692         {
693             rtsp_session_t *ses;
694
695             answer->i_status = 200;
696
697             psz_session = httpd_MsgGet( query, "Session" );
698
699             vlc_mutex_lock( &rtsp->lock );
700             ses = RtspClientGet( rtsp, psz_session );
701             if( ses != NULL )
702             {
703                 for( int i = 0; i < ses->trackc; i++ )
704                 {
705                     if( ses->trackv[i].id == id->sout_id )
706                     {
707                         rtp_del_sink( id->sout_id, ses->trackv[i].access );
708                         sout_AccessOutDelete( ses->trackv[i].access );
709                         REMOVE_ELEM( ses->trackv, ses->trackc, i );
710                     }
711                 }
712             }
713             vlc_mutex_unlock( &rtsp->lock );
714             break;
715         }
716
717         default:
718             answer->i_status = 460;
719             break;
720     }
721
722     psz = httpd_MsgGet( query, "Cseq" );
723     if( psz != NULL )
724         httpd_MsgAdd( answer, "Cseq", "%s", psz );
725     psz = httpd_MsgGet( query, "Timestamp" );
726     if( psz != NULL )
727         httpd_MsgAdd( answer, "Timestamp", "%s", psz );
728     httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
729     httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
730     httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
731
732     if( psz_session )
733         httpd_MsgAdd( answer, "Session", "%s"/*;timeout=5*/, psz_session );
734     return VLC_SUCCESS;
735 }