Commit 6ef65eaf authored by Pierre Ynard's avatar Pierre Ynard

rtsp: check Range validity before starting to process the request

parent c200ffa3
...@@ -92,7 +92,9 @@ int rtp_get_fmt( vlc_object_t *obj, es_format_t *p_fmt, const char *mux, ...@@ -92,7 +92,9 @@ int rtp_get_fmt( vlc_object_t *obj, es_format_t *p_fmt, const char *mux,
int OpenVoD ( vlc_object_t * ); int OpenVoD ( vlc_object_t * );
void CloseVoD( vlc_object_t * ); void CloseVoD( vlc_object_t * );
int vod_play(vod_media_t *p_media, const char *psz_session, int vod_check_range(vod_media_t *p_media, const char *psz_session,
int64_t start, int64_t end);
void vod_play(vod_media_t *p_media, const char *psz_session,
int64_t start, int64_t end, bool running); int64_t start, int64_t end, bool running);
void vod_pause(vod_media_t *p_media, const char *psz_session); void vod_pause(vod_media_t *p_media, const char *psz_session);
void vod_stop(vod_media_t *p_media, const char *psz_session); void vod_stop(vod_media_t *p_media, const char *psz_session);
......
...@@ -954,15 +954,24 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id, ...@@ -954,15 +954,24 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
answer->i_status = 457; answer->i_status = 457;
break; break;
} }
if (vod)
{
if (vod_check_range(rtsp->vod_media, psz_session,
start, end) != VLC_SUCCESS)
{
answer->i_status = 457;
break;
}
} }
/* We accept start times of 0 even for broadcast streams /* We accept start times of 0 even for broadcast streams
* that already started */ * that already started */
if (!vod && (start > 0 || end >= 0)) else if (start > 0 || end >= 0)
{ {
answer->i_status = 456; answer->i_status = 456;
break; break;
} }
}
vlc_mutex_lock( &rtsp->lock ); vlc_mutex_lock( &rtsp->lock );
ses = RtspClientGet( rtsp, psz_session ); ses = RtspClientGet( rtsp, psz_session );
if( ses != NULL ) if( ses != NULL )
...@@ -1037,9 +1046,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id, ...@@ -1037,9 +1046,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
if (vod) if (vod)
{ {
bool running = (sout_id != NULL); bool running = (sout_id != NULL);
if (vod_play(rtsp->vod_media, psz_session, start, end, vod_play(rtsp->vod_media, psz_session, start, end, running);
running) != VLC_SUCCESS)
answer->i_status = 457;
} }
} }
vlc_mutex_unlock( &rtsp->lock ); vlc_mutex_unlock( &rtsp->lock );
......
...@@ -541,15 +541,26 @@ char *SDPGenerateVoD( const vod_media_t *p_media, const char *rtsp_url ) ...@@ -541,15 +541,26 @@ char *SDPGenerateVoD( const vod_media_t *p_media, const char *rtsp_url )
return psz_sdp; return psz_sdp;
} }
int vod_check_range(vod_media_t *p_media, const char *psz_session,
int64_t start, int64_t end)
{
(void) psz_session;
if (p_media->i_length > 0 && (start > p_media->i_length
|| end > p_media->i_length))
return VLC_EGENERIC;
return VLC_SUCCESS;
}
/* TODO: add support in the VLM for queueing proper PLAY requests with /* TODO: add support in the VLM for queueing proper PLAY requests with
* start and end times, fetch whether the input is seekable... and then * start and end times, fetch whether the input is seekable... and then
* clean this up and remove the running argument */ * clean this up and remove the running argument */
int vod_play(vod_media_t *p_media, const char *psz_session, void vod_play(vod_media_t *p_media, const char *psz_session,
int64_t start, int64_t end, bool running) int64_t start, int64_t end, bool running)
{ {
if (p_media->i_length > 0 && (start > p_media->i_length if (vod_check_range(p_media, psz_session, start, end) != VLC_SUCCESS)
|| end > p_media->i_length)) return;
return VLC_EGENERIC;
/* We want to seek before unpausing, but it won't /* We want to seek before unpausing, but it won't
* work if the instance is not running yet. */ * work if the instance is not running yet. */
...@@ -565,8 +576,6 @@ int vod_play(vod_media_t *p_media, const char *psz_session, ...@@ -565,8 +576,6 @@ int vod_play(vod_media_t *p_media, const char *psz_session,
/* This is the thing to do to unpause... */ /* This is the thing to do to unpause... */
CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media, CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
psz_session, 0, "vod"); psz_session, 0, "vod");
return VLC_SUCCESS;
} }
void vod_pause(vod_media_t *p_media, const char *psz_session) void vod_pause(vod_media_t *p_media, const char *psz_session)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment