Skip to content

Commit

Permalink
sync last commits from original minisatip - f16c69b.
Browse files Browse the repository at this point in the history
  • Loading branch information
McMCCRU committed Apr 21, 2020
1 parent a200e1e commit 0d8852b
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ config.status
Makefile
src/Makefile
tests/Makefile
src/confdefs.h
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#
# export PATH=/opt/gxtools/csky-linux-tools-uclibc-20170724/bin:$PATH

export LANG=C
export PATH=/opt/goxceed/csky-linux-tools-i386-uclibc-20170724/bin:/opt/gxtools/csky-linux-tools-uclibc-20170724/bin:$PATH

cd ./libdvbcsa
Expand Down
23 changes: 20 additions & 3 deletions html/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
color: #eee !important;
}

.version {
font-family: Tahoma, Geneva, sans-serif;
font-size: 0.7em;
list-style-type: none;
}

table#myTable thead th {
background-color: #aaa;
}
Expand Down Expand Up @@ -270,9 +276,11 @@
// Create VLC stream URL
// Example: rtsp://@satip/?src=1&freq=12382&pol=H&msys=DVBS2&sr=27500&pids=0,5375,5378,116,5375,32
var hostArray = window.location.host.split(':');
myTable += "<small>rtsp://@" + hostArray[0] + "/?src=" + state['ad_pos'][i] + "&freq=" + state['ad_freq'][i]
+ "&pol=" + pol[state['ad_pol'][i]].replace('(', '').replace(')', '') + "&msys=" + sys[state['ad_sys'][i]].toUpperCase() + "&sr=" + state['ad_sr'][i] + "&pids=" + st_p + "</small><br />";

myTable += "<small><a href=" + '"' + "rtsp://@" + state['rtsp_host'] + "/?src=" + state['ad_pos'][i] + "&freq=" + state['ad_freq'][i]
+ "&pol=" + pol[state['ad_pol'][i]].replace('(', '').replace(')', '') + "&msys=" + sys[state['ad_sys'][i]].toUpperCase() + "&sr=" + state['ad_sr'][i] + "&pids=" + st_p + '"' + ">RTSP Link</a></small><br />";
myTable += "<small><a href=" + '"' + "http://" + hostArray[0] + ":" + hostArray[1] + "/?src=" + state['ad_pos'][i] + "&freq=" + state['ad_freq'][i]
+ "&pol=" + pol[state['ad_pol'][i]].replace('(', '').replace(')', '') + "&msys=" + sys[state['ad_sys'][i]].toUpperCase() + "&sr=" + state['ad_sr'][i] + "&pids=" + st_p + '"' + ">HTTP Link</a></small><br />";

if (state['st_overflow'][j] > 0)
myTable += "<small>Dropped: " + (state['st_overflow'][j]/1048576.0).toFixed(2) + " MB</small><br />";
if (state['st_buffered'][j] > 0)
Expand All @@ -296,6 +304,15 @@
}

myTable += "</tbody></table>";

// SYSTEM STATUS
myTable += "<div align='center'><ul class='version'>"
myTable += "<li><B>Minisatip Version:</B> " + state['version'] + " -- <B>Build date/time:</B> " + state['datetime_compile'] + "</li>"
myTable += "<li><B>Current Time:</B> " + state['datetime_current'] + " -- <B>Start Time:</B> " + state['datetime_start'] + " -- <B>Running Time:</B> " + state['time_running'] + "</span></li>"
myTable += "<li><B>RTSP address:</B> " + state['rtsp_host'] + " -- <B>UUID:</B> " + state['uuid'] + "</li>"
myTable += "<li><B>Process ID:</B> " + state['run_pid'] + " -- <B>Run as ID:</B> " + state['run_user'] + "</span></li>"
myTable += "</ul></div>"

return myTable;
}

Expand Down
2 changes: 2 additions & 0 deletions src/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ void close_adapter_for_stream(int sid, int aid)
ad->master_sid = -1;
mark_pids_deleted(aid, -1, NULL);
init_dvb_parameters(&ad->tp);
if (ad->standby)
ad->standby(ad);
#ifdef AXE
free_axe_input(ad);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ typedef int (*Adapter_commit)(void *ad);
typedef int (*Open_device)(void *ad);
typedef int (*Device_signal)(void *ad);
typedef int (*Device_wakeup)(void *ad, int fd, int voltage);
typedef int (*Device_standby)(void *ad);
typedef int (*Tune)(int aid, transponder *tp);
typedef uint8_t (*Dvb_delsys)(int aid, int fd,
uint8_t *sys);
Expand Down Expand Up @@ -124,6 +125,7 @@ typedef struct struct_adapter
Dvb_delsys delsys;
Device_signal get_signal;
Device_wakeup wakeup;
Device_standby standby;
Adapter_commit post_init, close;
} adapter;

Expand Down
1 change: 0 additions & 1 deletion src/confdefs.h

This file was deleted.

52 changes: 50 additions & 2 deletions src/minisatip.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ void print_version(int use_log)
char buf[200];
int i;
memset(buf, 0, sizeof(buf));
sprintf(buf, "%s version %s, compiled with %s version: %04X",
app_name, version, USE_API, LOGDVBAPIVERSION);
sprintf(buf, "%s version %s, compiled in %s %s, with %s version: %04X",
app_name, version, __DATE__, __TIME__, USE_API, LOGDVBAPIVERSION);
if (!use_log)
puts(buf);
else
Expand Down Expand Up @@ -1106,6 +1106,29 @@ void set_options(int argc, char *argv[])
opts.http_host = (char *)malloc1(MAX_HOST);
sprintf(opts.http_host, "%s:%u", lip, opts.http_port);
}

opts.rtsp_host = (char *)malloc1(MAX_HOST);
sprintf(opts.rtsp_host, "%s:%u", lip, opts.rtsp_port);

opts.datetime_compile = (char *)malloc1(64);
sprintf(opts.datetime_compile, "%s | %s", __DATE__, __TIME__);

time(&opts.start_time);
struct tm *info;
info = localtime(&opts.start_time);
opts.datetime_start = (char *)malloc1(32);
sprintf(opts.datetime_start, "%s ", asctime(info));
opts.datetime_start[24]=' ';
opts.datetime_start[25]='\0';

opts.datetime_current = (char *)malloc1(32);
sprintf(opts.datetime_current, "%s", " ");
opts.time_running = (char *)malloc1(32);
sprintf(opts.time_running, "%s", "0");

opts.run_user = (int)getuid();
opts.run_pid = (int)getpid();

if (!is_log)
opts.log = 0;

Expand Down Expand Up @@ -1451,6 +1474,24 @@ int read_http(sockets *s)
}
s->rlen = 0;

time_t now;
struct tm *info;
time(&now);
info = localtime(&now);
sprintf(opts.datetime_current, "%s ", asctime(info));
opts.datetime_current[24]=' ';
opts.datetime_current[25]='\0';

double seconds = difftime(now, opts.start_time);
int days = seconds/60/60/24;
seconds -= days*24*60*60;
int hours = seconds/60/60;
seconds -= hours*60*60;
int mins = seconds/60;
seconds -= mins*60;
int secs = seconds;
sprintf(opts.time_running, "%.0d%s%02d:%02d:%02d", days, days > 0 ? "d " : "", hours, mins, secs);

LOG("Read HTTP (handle %d) [%s:%d] sid %d, sock %d", s->sid,
get_sockaddr_host(s->sa, ra, sizeof(ra)), get_sockaddr_port(s->sa),
s->sid, s->sock);
Expand Down Expand Up @@ -2016,5 +2057,12 @@ _symbols minisatip_sym[] =
{"http_host", VAR_PSTRING, &opts.http_host, 0, 0, 0},
{"uuid", VAR_STRING, uuid, 0, 0, 0},
{"http_port", VAR_INT, &opts.http_port, 1, 0, 0},
{"rtsp_host", VAR_PSTRING, &opts.rtsp_host, 0, 0, 0},
{"datetime_compile", VAR_PSTRING, &opts.datetime_compile, 0, 0, 0},
{"datetime_start", VAR_PSTRING, &opts.datetime_start, 0, 0, 0},
{"datetime_current", VAR_PSTRING, &opts.datetime_current, 0, 0, 0},
{"time_running", VAR_PSTRING, &opts.time_running, 0, 0, 0},
{"run_user", VAR_INT, &opts.run_user, 1, 0, 0},
{"run_pid", VAR_INT, &opts.run_pid, 1, 0, 0},
{"version", VAR_STRING, &version, 1, 0, 0},
{NULL, 0, NULL, 0, 0, 0}};
8 changes: 8 additions & 0 deletions src/minisatip.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ struct struct_opts
{
char *rrtp;
char *http_host; //http-server host
char *rtsp_host; //rtsp-server host
char *datetime_compile;
time_t start_time;
char *datetime_start;
char *datetime_current;
char *time_running;
int run_user;
int run_pid;
char *disc_host; //discover host
char mac[13];
unsigned int log, debug, slog, start_rtp, http_port;
Expand Down
1 change: 0 additions & 1 deletion src/pmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#define FILTER_CRC 16
#define FILTER_EMM 32

#define PID_FROM_TS(b) (((b)[1] & 0x1F) * 256 + (b)[2])
#define MAX_PI_LEN 1500

typedef struct struct_batch // same as struct dvbcsa_bs_batch_s
Expand Down
44 changes: 40 additions & 4 deletions src/satipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef struct struct_satipc
int sport;
char session[18];
int stream_id;
int sleep;
int listen_rtp;
int rtcp, rtcp_sock, cseq;
int wp, qp; // written packet, queued packet
Expand Down Expand Up @@ -463,7 +464,7 @@ int satipc_open_device(adapter *ad)
sip->expect_reply = 0;
sip->last_connect = 0;
sip->sent_transport = 0;
sip->session[0] = 0;
sip->sleep = 0;
sip->stream_id = -1;
sip->wp = sip->qp = sip->want_commit = 0;
sip->rcvp = sip->repno = 0;
Expand Down Expand Up @@ -495,8 +496,15 @@ void satip_close_device(adapter *ad)
satipc *sip = get_satip(ad->id);
if (!sip)
return;

LOG("satip device %s:%d is closing", sip->sip, sip->sport);
http_request(ad, NULL, "TEARDOWN");
if (sip->sleep)
{
LOGM("satip device %s:%d sleeping, so not sending the TEARDOWN message", sip->sip, sip->sport);
}
else
http_request(ad, NULL, "TEARDOWN");
sip->sleep = 0;
sip->session[0] = 0;
sip->sent_transport = 0;
if (ad->fe_sock > 0)
Expand All @@ -508,6 +516,27 @@ void satip_close_device(adapter *ad)
sip->enabled = 0;
}

void satip_standby_device(adapter *ad)
{
satipc *sip;
if (!ad)
return;

sip = get_satip(ad->id);
if (!sip)
return;

LOG("satip device %s:%d going to standby sleep", sip->sip, sip->sport);
if (sip->sleep)
{
LOGM("satip device %s:%d already sleeping in standby", sip->sip, sip->sport);
}
else
http_request(ad, NULL, "TEARDOWN");
sip->sleep = 1;
sip->session[0] = 0;
}

int satipc_read(int socket, void *buf, int len, sockets *ss, int *rb)
{
unsigned char buf1[20];
Expand Down Expand Up @@ -1011,6 +1040,11 @@ int http_request(adapter *ad, char *url, char *method)

if (sip->stream_id != -1)
sprintf(sid, "stream=%d", sip->stream_id);
else if (!strcmp(method, "TEARDOWN"))
{
LOG("satipc_http_request (adapter %d): impossible to send TEARDOWN without specific stream!", ad->id);
return 0;
}

lb = snprintf(buf, sizeof(buf), format, method, sip->sip, sip->sport, sid,
qm, url, sip->cseq++, session);
Expand Down Expand Up @@ -1071,8 +1105,8 @@ void satipc_commit(adapter *ad)

url[0] = 0;
LOG(
"satipc: commit for adapter %d pids to add %d, pids to delete %d, expect_reply %d, force_commit %d want_tune %d do_tune %d, force_pids %d, sent_transport %d",
ad->id, sip->lap, sip->ldp, sip->expect_reply, sip->force_commit, sip->want_tune, ad->do_tune, sip->force_pids, sip->sent_transport);
"satipc: commit for adapter %d pids to add %d, pids to delete %d, expect_reply %d, force_commit %d want_tune %d do_tune %d, force_pids %d, sent_transport %d, sleep %d",
ad->id, sip->lap, sip->ldp, sip->expect_reply, sip->force_commit, sip->want_tune, ad->do_tune, sip->force_pids, sip->sent_transport, sip->sleep);

if (ad->do_tune && !sip->want_tune)
{
Expand Down Expand Up @@ -1230,6 +1264,7 @@ void satipc_commit(adapter *ad)
sip->force_commit = 0;
}

sip->sleep = 0;
http_request(ad, url, NULL);

return;
Expand Down Expand Up @@ -1321,6 +1356,7 @@ int add_satip_server(char *host, int port, int fe, char delsys, char *source_ip,
ad->tune = (Tune)satipc_tune;
ad->delsys = (Dvb_delsys)satipc_delsys;
ad->post_init = (Adapter_commit)satip_post_init;
ad->standby = (Device_standby)satip_standby_device;
ad->close = (Adapter_commit)satip_close_device;
ad->type = ADAPTER_SATIP;

Expand Down
1 change: 1 addition & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ static inline int get_index_hash(void *p, int max, int struct_size, uint32_t key
typedef ssize_t (*mywritev)(int fd, const struct iovec *io, int len);

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define PID_FROM_TS(b) (((b)[1] & 0x1F) * 256 + (b)[2])

#ifdef TESTING

Expand Down

0 comments on commit 0d8852b

Please sign in to comment.