From 39307445f95e92f4ea35b58719de2a504994fa6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Tue, 27 Nov 2007 17:22:54 +0000 Subject: [PATCH] add RTSP URL in HTML interface --- channels.c | 20 +++++++++++++++++++- htmlui.c | 10 +++++++++- http.c | 3 +++ http.h | 2 ++ main.c | 3 +++ rtsp.c | 10 ++++++---- tvhead.h | 2 ++ 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/channels.c b/channels.c index 9dec4023..9d573dd4 100644 --- a/channels.c +++ b/channels.c @@ -22,7 +22,7 @@ #include #include #include - +#include #include #include #include @@ -47,7 +47,10 @@ void scanner_init(void); th_channel_t * channel_find(const char *name, int create) { + const char *n2; th_channel_t *ch; + int l, i; + char *cp, c; TAILQ_FOREACH(ch, &channels, ch_global_link) if(!strcasecmp(name, ch->ch_name)) @@ -58,6 +61,21 @@ channel_find(const char *name, int create) ch = calloc(1, sizeof(th_channel_t)); ch->ch_name = strdup(name); + + l = strlen(name); + ch->ch_sname = cp = malloc(l + 1); + + n2 = utf8toprintable(name); + + for(i = 0; i < strlen(n2); i++) { + c = tolower(n2[i]); + if(isalnum(c)) + *cp++ = c; + else + *cp++ = '-'; + } + *cp = 0; + ch->ch_index = nchannels; TAILQ_INIT(&ch->ch_epg_events); diff --git a/htmlui.c b/htmlui.c index 6a7d4262..eca54a37 100644 --- a/htmlui.c +++ b/htmlui.c @@ -435,9 +435,17 @@ page_root(http_connection_t *hc, const char *remain, void *opaque) } tcp_qprintf(&tq, "
"); - tcp_qprintf(&tq, "%s
", + tcp_qprintf(&tq, + "" + "%s", ch->ch_tag, ch->ch_name); + if(tvheadend_streaming_host != NULL) { + tcp_qprintf(&tq, "Watch live
", + tvheadend_streaming_host, http_port, ch->ch_sname); + } + e = epg_event_find_current_or_upcoming(ch); for(i = 0; i < 3 && e != NULL; i++) { diff --git a/http.c b/http.c index 5f1b2c2c..125edbb6 100644 --- a/http.c +++ b/http.c @@ -44,6 +44,8 @@ #include "http.h" #include "rtsp.h" +int http_port; + static LIST_HEAD(, http_path) http_paths; static struct strtab HTTP_cmdtab[] = { @@ -442,6 +444,7 @@ http_tcp_callback(tcpevent_t event, void *tcpsession) void http_start(int port) { + http_port = port; tcp_create_server(port, sizeof(http_connection_t), "http", http_tcp_callback); } diff --git a/http.h b/http.h index a865b4dc..f6ddb178 100644 --- a/http.h +++ b/http.h @@ -19,6 +19,8 @@ #ifndef HTTP_H_ #define HTTP_H_ +extern int http_port; + #include "tcp.h" #define HTTP_STATUS_OK 200 diff --git a/main.c b/main.c index 4306bece..9e4b2c1f 100644 --- a/main.c +++ b/main.c @@ -58,6 +58,7 @@ int running; int xmltvreload; int startupcounter; +const char *tvheadend_streaming_host; static pthread_mutex_t tag_mutex = PTHREAD_MUTEX_INITIALIZER; static uint32_t tag_tally; @@ -189,6 +190,8 @@ main(int argc, char **argv) subscriptions_init(); + tvheadend_streaming_host = config_get_str("streaming-host", NULL); + htmlui_start(); avgen_init(); diff --git a/rtsp.c b/rtsp.c index 1d5cc126..ee35a361 100644 --- a/rtsp.c +++ b/rtsp.c @@ -90,8 +90,8 @@ typedef struct rtsp_session { static th_channel_t * rtsp_channel_by_url(char *url) { + th_channel_t *ch; char *c; - int chid; c = strrchr(url, '/'); if(c != NULL && c[1] == 0) { @@ -104,9 +104,11 @@ rtsp_channel_by_url(char *url) return NULL; c++; - if(sscanf(c, "chid-%d", &chid) != 1) - return NULL; - return channel_by_index(chid); + TAILQ_FOREACH(ch, &channels, ch_global_link) + if(!strcasecmp(ch->ch_sname, c)) + return ch; + + return NULL; } /* diff --git a/tvhead.h b/tvhead.h index 216b2761..b777cc4a 100644 --- a/tvhead.h +++ b/tvhead.h @@ -599,6 +599,7 @@ typedef struct th_channel { int ch_index; const char *ch_name; + const char *ch_sname; struct pvr_rec *ch_rec; @@ -695,5 +696,6 @@ char *utf8toprintable(const char *in); char *utf8tofilename(const char *in); const char *htstvstreamtype2txt(tv_streamtype_t s); uint32_t tag_get(void); +extern const char *tvheadend_streaming_host; #endif /* TV_HEAD_H */