add RTSP URL in HTML interface
This commit is contained in:
parent
3ace21bc5f
commit
39307445f9
7 changed files with 44 additions and 6 deletions
20
channels.c
20
channels.c
|
@ -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);
|
||||
|
||||
|
|
10
htmlui.c
10
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++) {
|
||||
|
|
3
http.c
3
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);
|
||||
}
|
||||
|
|
2
http.h
2
http.h
|
@ -19,6 +19,8 @@
|
|||
#ifndef HTTP_H_
|
||||
#define HTTP_H_
|
||||
|
||||
extern int http_port;
|
||||
|
||||
#include "tcp.h"
|
||||
|
||||
#define HTTP_STATUS_OK 200
|
||||
|
|
3
main.c
3
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();
|
||||
|
|
10
rtsp.c
10
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
2
tvhead.h
2
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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue