Commit 66c6214f authored by Pierre Ynard's avatar Pierre Ynard

rtsp: pass proper PLAY requests to VoD

Half of it is still unimplemented, so it's just sweeping under the
VLM rug
parent 38d2de2c
......@@ -92,10 +92,10 @@ int rtp_get_fmt( vlc_object_t *obj, es_format_t *p_fmt, const char *mux,
int OpenVoD ( vlc_object_t * );
void CloseVoD( vlc_object_t * );
void vod_start(vod_media_t *p_media, const char *psz_session);
int vod_play(vod_media_t *p_media, const char *psz_session,
int64_t start, int64_t end, bool running);
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_seek(vod_media_t *p_media, const char *psz_session, int64_t time);
const char *vod_get_mux(const vod_media_t *p_media);
int vod_init_id(vod_media_t *p_media, const char *psz_session, int es_id,
......
......@@ -1014,23 +1014,20 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
}
if (vod)
{
/* TODO: fix that crap, this is barely RTSP */
/* We want to seek before unpausing, but it won't
* work if the instance is not running yet. */
bool running = (sout_id != NULL);
if (!running)
vod_start(rtsp->vod_media, psz_session);
int64_t start = -1, end = -1;
if (range != NULL)
{
int64_t time = ParseNPT (range + 4);
vod_seek(rtsp->vod_media, psz_session, time);
start = ParseNPT (range + 4);
range = strchr(range, '-');
if (range != NULL && *(range + 1))
end = ParseNPT (range + 1);
}
/* This is the thing to do to unpause... */
if (running)
vod_start(rtsp->vod_media, psz_session);
if (vod_play(rtsp->vod_media, psz_session, start, end,
running) != VLC_SUCCESS)
answer->i_status = 457;
}
}
vlc_mutex_unlock( &rtsp->lock );
......
......@@ -541,11 +541,32 @@ char *SDPGenerateVoD( const vod_media_t *p_media, const char *rtsp_url )
return psz_sdp;
}
void vod_start(vod_media_t *p_media, const char *psz_session)
/* TODO: add support in the VLM for queueing proper PLAY requests with
* start and end times, fetch whether the input is seekable... and then
* clean this up and remove the running argument */
int vod_play(vod_media_t *p_media, const char *psz_session,
int64_t start, int64_t end, bool running)
{
/* We're passing the #vod{} sout chain here */
CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
psz_session, 0, "vod");
if (p_media->i_length > 0 && (start > p_media->i_length
|| end > p_media->i_length))
return VLC_EGENERIC;
/* We want to seek before unpausing, but it won't
* work if the instance is not running yet. */
if (!running)
/* We're passing the #vod{} sout chain here */
CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
psz_session, 0, "vod");
if (start >= 0)
CommandPush(p_media->p_vod, RTSP_CMD_TYPE_SEEK, p_media,
psz_session, start, NULL);
if (running)
/* This is the thing to do to unpause... */
CommandPush(p_media->p_vod, RTSP_CMD_TYPE_PLAY, p_media,
psz_session, 0, "vod");
return VLC_SUCCESS;
}
void vod_pause(vod_media_t *p_media, const char *psz_session)
......@@ -560,12 +581,6 @@ void vod_stop(vod_media_t *p_media, const char *psz_session)
psz_session, 0, NULL);
}
void vod_seek(vod_media_t *p_media, const char *psz_session, int64_t time)
{
CommandPush(p_media->p_vod, RTSP_CMD_TYPE_SEEK, p_media,
psz_session, time, NULL);
}
const char *vod_get_mux(const vod_media_t *p_media)
{
......
......@@ -310,8 +310,8 @@ static const http_status_info http_reason[] =
{ 454, "Session not found" },
{ 455, "Method not valid in this State" },
{ 456, "Header field not valid for resource" },
/*{ 457, "Invalid range" },
{ 458, "Read-only parameter" },*/
{ 457, "Invalid range" },
/*{ 458, "Read-only parameter" },*/
{ 459, "Aggregate operation not allowed" },
{ 460, "Non-aggregate operation not allowed" },
{ 461, "Unsupported transport" },
......
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