Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
If GET_PARAMETER fails use OPTIONS for keep alive loop
  • Loading branch information
spdfrk authored and perexg committed Mar 16, 2016
1 parent e229aed commit 8f86549
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/http.h
Expand Up @@ -345,6 +345,7 @@ struct http_client {
int hc_rtp_timeout;
char *hc_rtsp_user;
char *hc_rtsp_pass;
char hc_rtsp_keep_alive_cmd;

struct http_client_ssl *hc_ssl; /* ssl internals */

Expand Down
24 changes: 18 additions & 6 deletions src/input/mpegts/iptv/iptv_rtsp.c
Expand Up @@ -52,8 +52,12 @@ iptv_rtsp_alive_cb ( void *aux )
{
iptv_mux_t *im = aux;
rtsp_priv_t *rp = im->im_data;

rtsp_get_parameter(rp->hc, "");
if(rp->hc->hc_rtsp_keep_alive_cmd == RTSP_CMD_GET_PARAMETER)
rtsp_get_parameter(rp->hc, "");
else if(rp->hc->hc_rtsp_keep_alive_cmd == RTSP_CMD_OPTIONS)
rtsp_send(rp->hc, RTSP_CMD_OPTIONS, rp->path, rp->query, NULL);
else
return;
mtimer_arm_rel(&rp->alive_timer, iptv_rtsp_alive_cb, im,
sec2mono(MAX(1, (rp->hc->hc_rtp_timeout / 2) - 1)));
}
Expand All @@ -78,6 +82,13 @@ iptv_rtsp_header ( http_client_t *hc )
return 0;
}

if (hc->hc_cmd == RTSP_CMD_GET_PARAMETER && hc->hc_code != HTTP_STATUS_OK) {
tvherror("iptv", "GET_PARAMETER command returned invalid error code %d for '%s', "
"fall back to OPTIONS in keep alive loop.", hc->hc_code, im->mm_iptv_url_raw);
hc->hc_rtsp_keep_alive_cmd = RTSP_CMD_OPTIONS;
return 0;
}

if (hc->hc_code != HTTP_STATUS_OK) {
tvherror("iptv", "invalid error code %d for '%s'", hc->hc_code, im->mm_iptv_url_raw);
return 0;
Expand Down Expand Up @@ -160,10 +171,11 @@ iptv_rtsp_start
return SM_CODE_TUNING_FAILED;
}

hc->hc_hdr_received = iptv_rtsp_header;
hc->hc_data_received = iptv_rtsp_data;
hc->hc_handle_location = 1; /* allow redirects */
http_client_register(hc); /* register to the HTTP thread */
hc->hc_hdr_received = iptv_rtsp_header;
hc->hc_data_received = iptv_rtsp_data;
hc->hc_handle_location = 1; /* allow redirects */
hc->hc_rtsp_keep_alive_cmd = RTSP_CMD_GET_PARAMETER; /* start keep alive loop with GET_PARAMETER */
http_client_register(hc); /* register to the HTTP thread */
r = rtsp_setup(hc, u->path, u->query, NULL,
ntohs(IP_PORT(rtp->ip)),
ntohs(IP_PORT(rtcp->ip)));
Expand Down

0 comments on commit 8f86549

Please sign in to comment.