* Copyright (C) 2003-2004 the VideoLAN team
* Copyright © 2007 Rémi Denis-Courmont
*
- * $Id: rtp.c 21407 2007-08-22 20:10:41Z courmisch $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_sout.h>
#include <vlc_httpd.h>
rtsp->host = NULL;
rtsp->url = NULL;
rtsp->psz_path = NULL;
- vlc_mutex_init( p_stream, &rtsp->lock );
+ vlc_mutex_init( &rtsp->lock );
rtsp->port = (url->i_port > 0) ? url->i_port : 554;
rtsp->psz_path = strdup( ( url->psz_path != NULL ) ? url->psz_path : "/" );
free( rtsp->psz_path );
vlc_mutex_destroy( &rtsp->lock );
+
+ free( rtsp );
}
{
sout_stream_id_t *id;
int fd;
- vlc_bool_t playing;
+ bool playing;
};
const char *psz_session = NULL, *psz;
char control[sizeof("rtsp://[]:12345") + NI_MAXNUMERICHOST
+ strlen( rtsp->psz_path )];
+ time_t now;
+
+ time (&now);
if( answer == NULL || query == NULL || cl == NULL )
return VLC_SUCCESS;
answer->i_body = 0;
answer->p_body = NULL;
+ httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
+
+ /* Date: is always allowed, and sometimes mandatory with RTSP/2.0. */
+ struct tm ut;
+ if (gmtime_r (&now, &ut) != NULL)
+ { /* RFC1123 format, GMT is mandatory */
+ static const char wdays[7][4] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+ static const char mons[12][4] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+ httpd_MsgAdd (answer, "Date", "%s, %02u %s %04u %02u:%02u:%02u GMT",
+ wdays[ut.tm_wday], ut.tm_mday, mons[ut.tm_mon],
+ 1900 + ut.tm_year, ut.tm_hour, ut.tm_min, ut.tm_sec);
+ }
+
if( query->i_proto != HTTPD_PROTO_RTSP )
{
answer->i_status = 505;
tpt != NULL;
tpt = transport_next( tpt ) )
{
- vlc_bool_t b_multicast = VLC_TRUE, b_unsupp = VLC_FALSE;
+ bool b_multicast = true, b_unsupp = false;
unsigned loport = 5004, hiport = 5005; /* from RFC3551 */
/* Check transport protocol. */
opt = parameter_next( opt ) )
{
if( strncmp( opt, "multicast", 9 ) == 0)
- b_multicast = VLC_TRUE;
+ b_multicast = true;
else
if( strncmp( opt, "unicast", 7 ) == 0 )
- b_multicast = VLC_FALSE;
+ b_multicast = false;
else
if( sscanf( opt, "client_port=%u-%u", &loport, &hiport )
== 2 )
&& strncasecmp( opt + 5, "\"PLAY\"", 6 ) )
{
/* Not playing?! */
- b_unsupp = VLC_TRUE;
+ b_unsupp = true;
break;
}
}
if( strncmp( opt,"destination=", 12 ) == 0 )
{
answer->i_status = 403;
- b_unsupp = VLC_TRUE;
+ b_unsupp = true;
}
else
{
*
* "interleaved" is not implemented.
*/
- b_unsupp = VLC_TRUE;
+ b_unsupp = true;
break;
}
}
{
char ip[NI_MAXNUMERICHOST], src[NI_MAXNUMERICHOST];
rtsp_session_t *ses = NULL;
- rtsp_strack_t track = { id->sout_id, -1, VLC_FALSE };
+ rtsp_strack_t track = { id->sout_id, -1, false };
int sport;
if( httpd_ClientIP( cl, ip ) == NULL )
if( psz_session == NULL )
{
ses = RtspClientNew( rtsp );
- snprintf( psz_sesbuf, sizeof( psz_sesbuf ), I64Fx,
+ snprintf( psz_sesbuf, sizeof( psz_sesbuf ), "%"PRIx64,
ses->id );
psz_session = psz_sesbuf;
}
answer->i_status = 200;
psz_session = httpd_MsgGet( query, "Session" );
- if( httpd_MsgGet( query, "Range" ) != NULL )
+ const char *range = httpd_MsgGet (query, "Range");
+ if (range && strncmp (range, "npt=", 4))
{
- answer->i_status = 456; /* cannot seek */
+ answer->i_status = 501;
break;
}
{
if( !tr->playing )
{
- tr->playing = VLC_TRUE;
- rtp_add_sink( tr->id, tr->fd, VLC_FALSE );
+ tr->playing = true;
+ rtp_add_sink( tr->id, tr->fd, false );
}
infolen += sprintf( info + infolen,
"%s/trackID=%u;seq=%u, ", control,
return VLC_EGENERIC;
}
- httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
if( psz_session )
httpd_MsgAdd( answer, "Session", "%s"/*;timeout=5*/, psz_session );