]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
add RTSP URL in HTML interface
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 27 Nov 2007 17:22:54 +0000 (17:22 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 27 Nov 2007 17:22:54 +0000 (17:22 +0000)
channels.c
htmlui.c
http.c
http.h
main.c
rtsp.c
tvhead.h

index 9dec4023fde16c79ac986011a3101736ff4b73d3..9d573dd4715be15ce7f1b061da5bb7952f292874 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
-
+#include <ctype.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -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);
 
index 6a7d4262eb7d71678f6300c29d362bb244d9440d..eca54a37ee95e18b6103bc88764e68d04988a318 100644 (file)
--- a/htmlui.c
+++ b/htmlui.c
@@ -435,9 +435,17 @@ page_root(http_connection_t *hc, const char *remain, void *opaque)
     }
 
     tcp_qprintf(&tq, "<div class=\"over\">");
-    tcp_qprintf(&tq, "<strong><a href=\"channel/%d\">%s</a></strong><br>",
+    tcp_qprintf(&tq, 
+               "<span style=\"overflow: hidden; height: 15px; "
+               "width: 300px; float: left; font-weight:bold\">"
+               "<a href=\"channel/%d\">%s</a></span>",
                ch->ch_tag, ch->ch_name);
 
+    if(tvheadend_streaming_host != NULL) {
+      tcp_qprintf(&tq, "<i><a href=\"rtsp://%s:%d/%s\">Watch live</a></i><br>",
+                 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 5f1b2c2c1d925835f587e73d0ace0b07580b986f..125edbb6dac64549577fe05ec89421f17c2ea408 100644 (file)
--- 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 a865b4dcdb11f7a2a4e1334679d475d46659c386..f6ddb1785cff3e06921fe1a18d247e97ce88a9bd 100644 (file)
--- 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 4306bece7099a1ca6809110d49480770b16aead0..9e4b2c1f2b965b06a16eddd52dc96c3891effd31 100644 (file)
--- 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 1d5cc126da62c833b7cb555d61711e480bf5dc24..ee35a36151bf6bf9cdf9d57369ba55c6edc05250 100644 (file)
--- 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;
 }
 
 /*
index 216b276139059aa80e26713c7b22953fcd0403a2..b777cc4a4761d51e715b8e7e3ae5f846ce8f9d21 100644 (file)
--- 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 */