Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SAT>IP server: initial code
  • Loading branch information
perexg committed Mar 11, 2015
1 parent 3e33da5 commit ea60066
Show file tree
Hide file tree
Showing 13 changed files with 805 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -159,6 +159,10 @@ SRCS = src/version.c \
SRCS-${CONFIG_UPNP} += \
src/upnp.c

# SATIP Server
SRCS-${CONFIG_SATIP_SERVER} += \
src/satip/server.c

SRCS += \
src/api.c \
src/api/api_status.c \
Expand Down Expand Up @@ -261,7 +265,7 @@ SRCS-${CONFIG_LINUXDVB} += \
src/input/mpegts/linuxdvb/linuxdvb_rotor.c \
src/input/mpegts/linuxdvb/linuxdvb_en50494.c

# SATIP
# SATIP Client
SRCS-${CONFIG_SATIP_CLIENT} += \
src/input/mpegts/satip/satip.c \
src/input/mpegts/satip/satip_frontend.c \
Expand Down
13 changes: 11 additions & 2 deletions configure
Expand Up @@ -21,6 +21,7 @@ OPTIONS=(
"constcw:yes"
"v4l:no"
"linuxdvb:yes"
"satip_server:yes"
"satip_client:yes"
"hdhomerun_client:auto"
"hdhomerun_static:no"
Expand Down Expand Up @@ -257,6 +258,13 @@ if enabled_or_auto zlib; then
fi
fi

#
# SAT>IP server
#
if enabled_or_auto satip_server; then
enable upnp
fi

#
# SAT>IP client
#
Expand Down Expand Up @@ -450,11 +458,12 @@ fi
disable mpegts
disable mpegps
disable mpegts_dvb
if enabled linuxdvb || enabled iptv || enabled tsfile || enabled satip_client || enabled hdhomerun_client;
if enabled linuxdvb || enabled iptv || enabled tsfile || enabled satip_client || \
enabled hdhomerun_client || enabled satip_server;
then
enable mpegts
fi
if enabled linuxdvb || enabled satip_client || enabled hdhomerun_client; then
if enabled linuxdvb || enabled satip_client || enabled hdhomerun_client || enabled satip_server; then
enable mpegts_dvb
fi

Expand Down
40 changes: 40 additions & 0 deletions docs/html/config_misc.html
Expand Up @@ -131,5 +131,45 @@

</dl>

<br><br>
<hr>
<b>SAT>IP Server</b>
<hr>

<dd>SAT>IP Server is something like DVB network tuner. TVHeadend can
forward mpegts input streams including on-the-fly descramling to SAT>IP
clients.</dd>

<dl>

<dt>RTSP Port
<dd>
Select RTSP port (TCP) for realtime commands from SAT>IP clients. Usually
(as defined in the specification) this port is 554. But as extension,
TVHeadend can use any TCP port value (which is default 9983 for non-root
users). But the SAT>IP client must allow to set this value (TVHeadend
client will obtain the RTSP port number automatically using the XML
description). If the RTSP port value is zero, the SAT>IP server
functionality is not enabled.

<dt>Subscription Weight
<dd>
Subscription weight value. Default value is 100 (standard streaming). Note
that the default value for DVR is 300 (normal priority).

<dt>Exported DVB-T Tuners
<dd>
Exported DVB-T tuners - streaming instances.

<dt>Exported DVB-S2 Tuners
<dd>
Exported DVB-S2 tuners - streaming instances.

<dt>Exported DVB-C Tuners
<dd>
Exported DVB-C tuners - streaming instances.

</dl>

</dl>
</div>
5 changes: 5 additions & 0 deletions docs/html/config_networks.html
Expand Up @@ -86,6 +86,11 @@
<p>
<dt><b>Ignore Provider's Channel Numbers</b>
<dd>Do not use the local channel numbers defined by provider.
<p>
<dt><b>SAT>IP Source Number</b>
<dd>For DVB-S SAT>IP source means the LNB selection. 0 = do not use; 1 = AA; 2 = AB; 3 = BA; 4 = BB.
Other values are allowed too (but clients have to support them).
For other network types (DVB-T, DVB-C), use value 1 to enable SAT>IP for this network.
<p>
<dt><b>EIT Local Time</b>
<dd>EPG (EIT) events uses local time instead UTC.
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts.h
Expand Up @@ -293,6 +293,7 @@ struct mpegts_network
* Configuration
*/
uint16_t mn_nid;
uint16_t mn_satip_source;
int mn_autodiscovery;
int mn_skipinitscan;
char *mn_charset;
Expand Down
8 changes: 8 additions & 0 deletions src/input/mpegts/mpegts_network.c
Expand Up @@ -188,6 +188,14 @@ const idclass_t mpegts_network_class =
.off = offsetof(mpegts_network_t, mn_ignore_chnum),
.def.i = 0,
},
#if ENABLE_SATIP_SERVER
{
.type = PT_U16,
.id = "satip_source",
.name = "SAT>IP Source Number",
.off = offsetof(mpegts_network_t, mn_satip_source),
},
#endif
{
.type = PT_STR,
.id = "charset",
Expand Down
3 changes: 2 additions & 1 deletion src/input/mpegts/satip/satip.c
Expand Up @@ -23,6 +23,7 @@
#include "htsmsg_xml.h"
#include "upnp.h"
#include "settings.h"
#include "satip/server.h"
#include "satip_private.h"
#include "dbus.h"

Expand Down Expand Up @@ -882,7 +883,7 @@ satip_discovery_service_received
/* Sanity checks */
if (st == NULL || strcmp(st, "urn:ses-com:device:SatIPServer:1"))
return;
if (uuid == NULL || strlen(uuid) < 16)
if (uuid == NULL || strlen(uuid) < 16 || satip_server_match_uuid(uuid))
return;
if (location == NULL || strncmp(location, "http://", 7))
return;
Expand Down
22 changes: 18 additions & 4 deletions src/main.c
Expand Up @@ -50,6 +50,7 @@
#include "descrambler.h"
#include "dvr/dvr.h"
#include "htsp_server.h"
#include "satip/server.h"
#include "avahi.h"
#include "bonjour.h"
#include "input.h"
Expand Down Expand Up @@ -142,6 +143,9 @@ const tvh_caps_t tvheadend_capabilities[] = {
#if ENABLE_V4L || ENABLE_LINUXDVB || ENABLE_SATIP_CLIENT || ENABLE_HDHOMERUN_CLIENT
{ "tvadapters", NULL },
#endif
#if ENABLE_SATIP_SERVER
{ "satip_server", NULL },
#endif
#if ENABLE_IMAGECACHE
{ "imagecache", (uint32_t*)&imagecache_conf.enabled },
#endif
Expand Down Expand Up @@ -470,6 +474,9 @@ main(int argc, char **argv)
opt_fileline = 0,
opt_threadid = 0,
opt_ipv6 = 0,
#if ENABLE_SATIP_SERVER
opt_satip_rtsp = 0,
#endif
#if ENABLE_TSFILE
opt_tsfile_tuner = 0,
#endif
Expand Down Expand Up @@ -522,6 +529,11 @@ main(int argc, char **argv)
{ 'a', "adapters", "Only use specified DVB adapters (comma separated)",
OPT_STR, &opt_dvb_adapters },
#endif
#if ENABLE_SATIP_SERVER
{ 0, "satip_rtsp", "SAT>IP RTSP port number for server\n"
"(default: -1 = disable, 0 = webconfig, standard port is 554)",
OPT_INT, &opt_satip_rtsp },
#endif
#if ENABLE_SATIP_CLIENT
{ 0, "satip_xml", "URL with the SAT>IP server XML location",
OPT_STR_LIST, &opt_satip_xml },
Expand Down Expand Up @@ -696,9 +708,11 @@ main(int argc, char **argv)
signal(SIGPIPE, handle_sigpipe); // will be redundant later
signal(SIGILL, handle_sigill); // see handler..

uuid_init();
tcp_server_preinit(opt_ipv6);
http_server_init(opt_bindaddr); // bind to ports only
htsp_init(opt_bindaddr); // bind to ports only
http_server_init(opt_bindaddr); // bind to ports only
htsp_init(opt_bindaddr); // bind to ports only
satip_server_init(opt_satip_rtsp); // bind to ports only

if (opt_fork)
pidfile = tvh_fopen(opt_pidpath, "w+");
Expand Down Expand Up @@ -801,7 +815,6 @@ main(int argc, char **argv)
SSL_library_init();

/* Initialise configuration */
uuid_init();
idnode_init();
spawn_init();
config_init(opt_config, opt_nobackup == 0);
Expand Down Expand Up @@ -871,9 +884,9 @@ main(int argc, char **argv)
dbus_server_start();

http_server_register();
satip_server_register();
htsp_register();


if(opt_subscribe != NULL)
subscription_dummy_join(opt_subscribe, 1);

Expand Down Expand Up @@ -914,6 +927,7 @@ main(int argc, char **argv)
#if ENABLE_UPNP
tvhftrace("main", upnp_server_done);
#endif
tvhftrace("main", satip_server_done);
tvhftrace("main", htsp_done);
tvhftrace("main", http_server_done);
tvhftrace("main", webui_done);
Expand Down

0 comments on commit ea60066

Please sign in to comment.