1. Installation

1.1 Installation of TS Engine on Debian
To install TS Engine it's necessary to add Torrent Stream repository to a file /etc/apt/sources.list:
deb http://torrentstream.net/repo ubuntu main

If during package installation you see a message about unknown key, you can add it to the system:
wget -O - http://torrentstream.net/repo/torrentstream.public.key | apt-key add -

After this torrentstream-engine package has to be installed:
apt-get update
apt-get install torrentstream-engine

1.2 Installation of TorrentStream Full package on Ubuntu from deb-package
- download the package by link
http://torrentstream.org/downloads/linux/test/torrentstream_1.0.6-0ubuntu8_amd64.deb
or
http://torrentstream.org/downloads/linux/test/torrentstream_1.0.6-0ubuntu8_i386.deb
(depending on desired architecture)
- install the package via package manager (for example, double click on the downloaded package file)

1.3 Installation of package TorrentStream Full on Ubuntu from repository
Add Torrent Stream repository to the file /etc/apt/sources.list:
deb http://torrentstream.net/repo ubuntu main

If during package installation you see a message about unknown key, you can add it to the system:
wget -q -O - http://torrentstream.net/repo/torrentstream.public.key |
sudo apt-key add -

After this torrentstream-engine package has to be installed:
sudo apt-get update
sudo apt-get install torrentstream-full

2. Launching broadcasting

To launch broadcasting use run "tsengine-stream" from the command line. This program takes the following parameters:

--name
Channel name

--source
Source - URL of a stream, which will be broadcasted. At this moment HTTP streams with MPEG-TS encapsulation are supported.

--destdir
Directory, in which .tslive file for this broadcasting and some service files will be saved.

--bitrate
Stream bitrate in bytes per second. For a correct work of the stream an average bitrate of the stream, which is used as a source, has to be specified.
Info: 1 byte = 8 bits
Example: 800 kilobits = 100 kilobytes = 100000 bytes, 2 megabits = 250 kilobytes = 250000 bytes

--piecesize
Piece size in bytes. The default the value of this parameter is "auto" (piece size is determined automatically).

--duration
Stream duration in format HH:MM:SS. This parameter sets the cache size for the stream. Default value is "01:00:00" (i.e. the system will keep in the cache about one hour of broadcasting).

--host
IP-address or a domain name of a host, from which broadcasting is launched. To enable broadcasting this address must be available for users who will watch broadcasting.

--port
Port on which all incoming connections will be received. By default 7764.

--trackers
List of additional trackers that will be used for exchange of peers. Addresses of trackers must be separated with a comma (example:
--trackers http://192.168.1.100/announce,http://192.168.1.200/announce).
By default additional trackers are not used.

--provider-key
License key for commercial broadcastings. By default it is not used.

--maxclients
Maximum number of clients, who will receive data directly from the broadcasting source. By default 7.

Example:
tsengine-stream --name test --source http://84.22.159.204:8006
--bitrate 350000 --host mysite.com --destdir /tmp/streams

After broadcasting is launched the following files will be created in the directory /tmp/streams:
test - broadcasting cache. Size of this file is approximately equal to stream_duration_in_seconds * bitrate bytes
test.tslive - this file should be distributed to the users who want to connect to broadcasting
test.restart - information for the correct restart of broadcasting is stored here
test.sauth - digital signature key of broadcasting

Also after the start you can go to a web-interface of the internal tracker, which is integrated into TS Engine:
http://mysite.com:7764/

On this page some information about broadcasting is shown, and also here you can download broadcasting file .tslive using a link:
http://mysite.com:7764/file?name=test

3. Watching broadcasting.

There are two ways to watch broadcasting:
1) user downloads file .tslive and plays it with TS Player
2) broadcasting creator makes a web page for watchong broadcasting, users go to that page and watch broadcasting in browser
As a template for such page you can use http://torrentstream.org/stream/test.php. You must only change link to the file .tslive in this line:
this.loadTorrent("http://torrentstream.net/streams/test2.mpegts.tslive");

4. Broadcasting monitoring

"tsengine-stream" program displays all debug information in STDERR. Successful start of broadcasting looks like this:
host:~# tsengine-stream --name test --source http://84.22.159.204:8006
--bitrate 350000 --host mysite.com --destdir /tmp/streams
tracker url: http://mysite.com:7764/announce/
bitrate: 350000
piece size: 262144
dest dir: /tmp/streams
------------------------
createlivestream: open stream: url http://84.22.159.204:8006 reader builtin
2012-07-16 12:56:36 stream: started input thread
2012-07-16 12:56:37 stream: created piece 0 speed 131.12 KiB/s
2012-07-16 12:56:38 stream: created piece 1 speed 183.15 KiB/s
2012-07-16 12:56:39 stream: created piece 2 speed 198.34 KiB/s
2012-07-16 12:56:40 stream: created piece 3 speed 196.96 KiB/s
2012-07-16 12:56:41 stream: created piece 4 speed 199.23 KiB/s
2012-07-16 12:56:43 stream: created piece 5 speed 203.08 KiB/s
2012-07-16 12:56:44 stream: created piece 6 speed 206.37 KiB/s

Such information is displayed: numbers of created pieces and the source speed (the download speed at which data is received from the broadcasting source, which is http://84.22.159.204:8006 is this example).

To stop broadcasting press Ctrl-C.