How to configure SPI (Service and Programme Information) for ODR-DabMux

From Opendigitalradio
Revision as of 17:11, 14 July 2020 by Nickpiggott (Talk | contribs)

Jump to: navigation, search

Howto by Ulrik Brinck on odr-radioepg-bridge installation on Debian Jessie

Contents

Introduction

This tool (or rather series of tools) will pick up your SPI (Service and Programme Information) from the internet via RadioDNS and generate a DAB EPG from it. It was written by Ben Poor and Nick Piggott. In this HowTo, I will describe how it can be installed on Debian Jessie. Some details might be slightly different on other Debian generations.

  • In this context, EPG and SPI is basically the same thing. While EPG (Electronic Programme Guide) is an old, but commonly well-known term, SPI (Service and Programme Information) is now the official name of this feature.

Notes

This tool uses RadioDNS to locate and acquire Service Information (SI.xml), Programme Information (PI.xml) and Logos. Each station you want to add to the EPG must be registered in RadioDNS using the correct information (Ensemble ID, Service ID, Service Component ID), and have correctly formatted SI, PI and logo files in PNG format. Find out more at https://radiodns.org/technical/documentation/#howto

I have assumed that you are logged in to your Linux system as a standard user and have sudo installed on your system. If sudo is not installed, you can see here, how to install it on Debian Jessie: https://www.geek17.com/en/content/debian-8-jessie-install-and-configure-sudo-25

Installation

Step 0: Update your system

Begin with "sudo apt-get update" to make sure that you can install all that you need.

Step 1: Miscellaneous dependencies

First there are some dependencies to install with apt-get:

sudo apt-get install python-crcmod
sudo apt-get install python-bitarray
sudo apt-get install python-isodate

Next there are some dependencies and subcomponents which must be downloaded from github and installed:

Step 2: python-dabmot

Download from here https://github.com/GlobalRadio/python-dabmot and unpack to a folder, e.g. /home/user/python-dabmot-master

Then navigate to the folder and run:

sudo python setup.py install

Step 3: python-mot-epg

Download from here https://github.com/GlobalRadio/python-mot-epg and unpack to a folder, e.g. /home/user/python-mot-epg-master

Then navigate to the folder and run:

sudo python setup.py install

Step 4: python-msc

Download from here https://github.com/nickpiggott/python-dabmsc and unpack to a folder, e.g. /home/user/python-dabmsc-master

Important: It MUST be this commit, NOT the original one from GlobalRadio from 2017 (thanks to Nick Piggott for help figuring out this).

Then navigate to the folder and run:

sudo apt-get install python-dateutil
sudo python setup.py install

Step 5: odr-radiodns-bridge

Download from here https://github.com/nickpiggott/odr-radiodns-bridge and unpack to a folder, e.g. /home/user/odr-radiodns-bridge-master

Then navigate to the folder and run:

sudo apt-get install python-pip
sudo pip install hybridspi
sudo pip install pyradiodns
sudo python setup.py install

Step 6: python-hybridspi

Download from here https://github.com/magicbadger/python-hybridspi and unpack to a folder, e.g. /home/user/python-hybridspi-master

Then navigate to the folder and run:

sudo python setup.py install

Step 7: odr-radioepg-bridge

And now for the RadioEPG-bridge itself.

Download from here https://github.com/nickpiggott/odr-radioepg-bridge and unpack to a folder, e.g. /home/user/odr-radioepg-bridge-master

Then run:

sudo ln -s /home/user/odr-radioepg-bridge-master/generate-epg /usr/local/bin/generate-epg

(If your folder is not /home/user/odr-radioepg-bridge-master, use your_path/generate-epg in the last command line above).

That's it. You should now be able to run this command and see a help text:

generate-epg -h

Generating and broadcasting your EPG

Generating your EPG

Odr-radioepg-bridge is a command-line tool, which will:

  • First read your mux.conf (from your ODR-DabMux configuration) to get information about your services.
  • Then try to fetch SPI data for your services from the internet using RadioDNS.
  • And lastly generate an output file containing a complete EPG.

If you type "generate-epg -h" you will get a list of available command-line arguments:

usage: generate-epg [-h] [-o OUTPUT] [-X] [-d DAYS] [-p PACKET_SIZE]
                    [-a PACKET_ADDRESS]
                    f

Encodes an EPG bitstream for services in a multiplex configuration file

positional arguments:
  f                  multiplex configuration file

optional arguments:
  -h, --help         show this help message and exit
  -o OUTPUT          output bitstream file
  -X                 turn debug on
  -d DAYS            number of days ahead to encode schedule files
  -p PACKET_SIZE     Packet size in bytes
  -a PACKET_ADDRESS  Packet address

The positional argument tells the tool where to find your mux.conf. The other arguments are optional, and some default values will be used if you don't set them:

  • -o can be used to set filename and path to your output file (your EPG). Default is output.dat, placed in the folder from where you run the tool.
  • -d is the number of days of programme schedule you want in you EPG. From 1 til 4 days, default is 2.
  • -p is packet size. Available values are 24, 48, 72 and 96. Default is 96. Which value you should use, depends on the bitrate in which you are broadcasting your EPG (see below).
  • -a is the packet address for your EPG. Default is 1, which will normally be fine. Important is, that you must set the same address in your mux.conf (see below).


Example: If your mux.conf is placed in /home/user/odr/config/mux.conf, and you want 4 days in your EPG (today and the next 3 days) and you want to broadcast it in 16 kbit/s, your command line could look like this:

generate-epg -d 4 -p 48 /home/user/odr/config/mux.conf

This will generate a file named output.dat containing your EPG. In this example, I have set the packet size to 48, which is suitable for 16 kbit/s. I have not set the packet address, which means that the default value of 1 will be used.

Packet sizes and bitrates

The packet size, which you set when you generate your EPG, should match the bitrate in which you intend to broadcast it. If the packet size is too large, your EPG will not be broadcasted. If the packet size is too small, your EPG will (probably) be broadcasted, but it will be slower than necessary, because more space will be used for packet headers and maybe partly empty data packets. I will recommend these values:

Bitrate Packet size
8 24
16 48
24 72
32 96
48 72
64 96

Broadcasting your EPG

To broadcast your EPG using ODR-DabMux, create a packet data service in your mux.conf like in this example:

In the services section:

srv-epg {
label "EPG"
shortlabel "EPG"
; the service-ID consists of 8 hex digits for packet data services. Usually the first two digits will
; be the same as your ECC, and the third digit will be the same as the first digit in your Ensemble Id.
id 0xe1912345
}

In the subchannels section:

sub-epg {
; type packet or enhancedpacket can be used for EPG.
type enhancedpacket
; if you change the bitrate, remember to also change the packet size accordingly (see above) and generate your EPG again.
bitrate 16
protection-profile EEP_A
protection 3
; inputuri is the path and filename for your output file from generate-epg
inputuri "/home/user/odr-radioepg-bridge-master/output.dat"
inputproto file
} 

And in the components section:

comp-epg {
type 60
service srv-epg
subchannel sub-epg
figtype 0x7
; The address must be the same as your packet address set when you generate the EPG (default value is 1).
address 0x1
datagroup true
}

That's it. Now (re)start your ODR-DabMux, and your EPG should be broadcasted.

Updating your EPG automatically every day

To be written....

Some problems and solutions

Local variable 'ecc' referenced before assignment

For some domains, lookup will cause the script to fail with error message "local variable 'ecc' referenced before assignment" if the domain has no _radiotag._tcp SRV record.

You can get around this by opening this file in a text editor:

/usr/local/lib/python2.7/dist-packages/pyradiodns/rdns.py

and remove or comment out line 13 "('radiotag', 'TCP'),".

If the domain is not using RadioVIS, you might also have to remove line 14 "('radiovis', 'TCP'),", but I haven't experienced this myself.

Note: When you modify this file, you might have to remove rdns.pyc in the same folder to make sure that your changes are being used.

Radio programmes listed on a wrong date

I have observed that radio programmes beginning before noon (or all programmes on some receivers) were listed on a wrong date, one day before the correct date. My solution was to modify line 428 in this file:

/usr/local/lib/python2.7/dist-packages/spi/binary/__init__py

Here, "(timepoint.hour - 12)" should be changed to "timepoint.hour", so that line 428 will be:

jd = jdn + timepoint.hour / 24 + timepoint.minute / 1440 + timepoint.second / 86400

This should fix the daystamp issue.

Note: When you modify this file, you might have to remove __init__.pyc in the same folder to make sure that your changes are being used.

Radio programmes listed with wrong timestamps if your time zone is not UTC

I have observed that if the time zone is not UTC, all radio programmes were listed with wrong times. My solution was to make some modifications to this file:

/usr/local/lib/python2.7/dist-packages/spi/binary/__init__py

After line 419 ("bits.setall(False)") I have added the following two lines:

offset = (timepoint.utcoffset().days * 86400 + timepoint.utcoffset().seconds) + (timepoint.dst().days * 86400 + timepoint.dst().days)
timepoint=timepoint - timedelta(seconds=offset)

(The first line is taken from line 457, from where it can then be removed)

And after line 28 ("import sys"), I have added this line:

from datetime import timedelta

This should fix the timestamp issue.

Note: When you modify this file, you might have to remove __init__.pyc in the same folder to make sure that your changes are being used.

Other observations

  • According to specs, logo slides in DAB EPG must be PNG. Although JPG is allowed in hybrid radio SPI, JPG logos will not be added to your DAB EPG. Be sure that your logos (up to 320x240) are PNG.
  • Programme descriptions (shortDescription) seem to be processed but not shown. Perhaps we will have to look a little further into this.
Personal tools