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