This is a "plugin" for the Video Disk Recorder (VDR).

Written by:                  Thomas Keil <tkeil@datacrystal.de>
                             Sascha Volkenandt <sascha@akv-soft.de>

Currently maintained by:     Markus Ehrnsperger ( MarkusE @ https://www.vdr-portal.de)

Previously Maintained by:
                             Dieter Hametner <dh+vdr@gekrumbel.de>
                             Christian Wieninger <cwieninger@gmx.de>
                             Jasmin Jessich <jasmin@anw.at>

Project's homepage:          https://github.com/MarkusEh/vdr-plugin-live
Project's old homepage:      http://live.vdr-developer.org

Latest version available at: https://github.com/MarkusEh/vdr-plugin-live

See the file COPYING for license information.


Description:
============

Live, the "Live Interactive VDR Environment", is a VDR plugin providing
a web interface to VDR and some of it's plugins.

Requirements:
=============

System using an UTF-8 locale
VDR >= 2.4.0
gcc >= v8, must support -std=c++17. -std=c++1z should also work for complilers not yet supporting -std=c++17.
Tntnet >= 2.2.1    - http://www.tntnet.org/download.hms  // https://web.archive.org/web/20160314183814/http://www.tntnet.org/download.html
Cxxtools >= 2.2.1  - http://www.tntnet.org/download.hms  // https://web.archive.org/web/20160314183814/http://www.tntnet.org/download.html

Tntnet provides basic web server functions for live and needs cxxtools.

Optional:
tvscraper >= 1.2.1, for images and other information from [TMDB](https://www.themoviedb.org/) & TheTVDB.com

Installation:
=============

If you compile the plugin outside of the VDR source code you must
copy the resulting binary to the directory where VDR plugins are expected.

You also must copy the subdirectory 'live' from the source distribution
to the directory where the VDR plugins look for their resource files.
The VDR default for this config directory is: /video/plugins, but this
depends also on the parameters -c or -v (see 'vdr --help' for details).

cp -a <live-src-dir>/live <vdr-resource-dir>/plugins

On debian like systems, <vdr-resource-dir> is /usr/share/vdr


======
Setup:
======

Configuration files:
====================

siteprefs.css
- Allows UI adjustments

ffmpeg.conf
- To play live tv / recordings directly in the browser, data must be converted.
  ffmpeg commands used for this are in ffmpeg.conf

On debian like systems:
-  These files are installed in /etc/vdr/plugins/live
-  /var/lib/vdr/plugins/live/ffmpeg.conf is a symbolic link to /etc/vdr/plugins/live/ffmpeg.conf
-  /usr/share/vdr/plugins/live/css/siteprefs.css is a symbolic link to /etc/vdr/plugins/live/siteprefs.css


Command line options:
=====================

The default port is 8008. You can change this via command line:

  -p PORT,  --port=PORT     use PORT to listen for incoming connections
                            (default: 8008)
  -i IP,    --ip=IP         bind server only to specified IP, may appear
                            multiple times
                            (default: 0.0.0.0, ::0)

Additional SSL options are available. See "How to make LIVE listen
for SSL connections" section below on hints how to setup SSL.

To display images or channel logos, you can use:

  -e <...>  --epgimages=/path/to/epgimages              use EPG images created by plugins like tvm2vdr
  --chanlogos=/path/to/channellogos                     use channel logos (PNG only, case sensitive)


Settings in VDR's OSD:
======================

Note: These settings are also available in the web interface.

Live provides a username/password protection. The default username and password are:

  admin/live

The password is stored as a MD5 hash.

"Last Channel" is the last channel in the channels list, that live displays.
This is especially useful if you have VDR's automatic channel update active.
For example, you can add a group separator ":@1000 Found automatically" to
channels.conf and set this parameter to "1000". Thus, everything VDR finds
during scanning (which can after a few months be well more than 3000
channels) won't be displayed.


How to make LIVE listen to SSL connections:
============================================

In order to start the SslListener LIVE requires a SSL certificate. If
no SSL certificate is specified via command-line option, LIVE will try
to use the default certificate location
'$VDRDIR/plugins/live/live.pem'.

If neither the default nor the custom certificate (given by the
command-line option) could be found, LIVE will only start the default
HTTP Listener (default: 8008)

If you want do disable the SslListener for any reason, specify SSL port
number 0 with the command-line option.

SSL Command-line options:
=========================

  -s PORT,  --sslport=PORT     use PORT to listen for incoming SSL connections
                               (default: 8443)
                               use PORT 0 to disable incoming SSL connections
  -c CERT,  --cert=CERT        path to a custom SSL certificate file
                               (default: $CONFIGDIR/live.pem)
  -k KEY,   --cert=CERT        path to a custom SSL certificate key file
                               (default: $CONFIGDIR/live-key.pem)


Creating a self-signed SSL server certificate:
==============================================

To create a self-signed certificate file you'll have to run this command:

  $> cd /put/your/path/here/vdr/plugins/live
  $> openssl req -new -x509 -keyout live-key.pem -out live.pem -days 365 -nodes

While generating the certificate you'll be asked to answer a couple of
questions.  When it prompts to enter the "Common Name" you'll have to
specify the full qualified DNS server name of the machine LIVE is
running on (e.g. vdr.example.com).  If your VDR doesn't have a full
qualified DNS name, you should use the IP Live is listening on.

Note: This is just a quick-and-dirty way to create a SSL self-signed
certificate.  Browsers will complain about it because the certificate
wasn't signed by a known Certificate Authority (CA).


So how does LIVE work?
======================

Basically, Live itself is a Tntnet Web server integrated into the
plugin structure VDR needs.

This Web server, running in VDR's environment, is provided with all
public data structures VDR provides for plugins and thus has very fast
access to information like the EPG, timers or recordings.

Live's "pages" are written in "ecpp", a language integrating C++ and
HTML in one file, very much like e.g. PHP or ASP weave functionality
and "static" content information together.


Contribute!
===========
If you would like to contribute, please read doc/dev-contribute.txt
and doc/TODO.txt.

Security considerations:
========================

Please use live in a controlled environment only, like your home network
or a save VPN of your home network.
You cannot expect sufficient security to expose live to the public internet.

Of course, better security is always appreciated, so please send
patches increasing security.

One possible security issue (there might be others ...):
Live uses the Tntnet MapUrl mechanism to map different request URLs to
Tntnet components. One component 'content.ecpp' delivers files found
in the file system. When given the wrong 'path' it could retrieve any
file from the server where live runs on.  Therefore content.ecpp has
been enhanced to check the paths before returning files.  A second
measure against misuse is to limit the mappings from MapUrl to only
valid files. In the current version this approach has been taken. But
due to the 'difficulty' to fully understand regular expressions, this
might get spoiled again by 'unchecked' code contribution.

Errors
======

If VDR crashes on start with these journal messages:
  loading plugin: /usr/local/lib/vdr/libvdr-live.so.x.x.
  terminate called after throwing an instance of 'std::runtime_error'
    what():  locale::facet::_S_create_c_locale name not valid

Most likely, the locale is not installed correctly. On Debian based systems, use:
  dpkg-reconfigure locales
and restart VDR.
