This is the player and user interface application as part of the BATC ryde project. It allows the control of Longmynd compatible tuners using an IR remote control handset and on screen display on a Raspberry Pi 4.
The software is designed and tested on a Raspberry Pi 4 although it will likely run on older hardware this is unsupported. Primary target tuner hardware is the BATC MiniTiouner V2 although it should work with any Longmynd compatible hardware although some features may not be supported.
Install packaged dependencies:
sudo apt-get install python3-pygame python3-vlc python3-yaml python3-evdev python3-pil vlc-plugin-base python3-librtmp
Install pyDispmanx driver from https://github.com/eclispe/pyDispmanx and ensure the .so file is in your PYTHONPATH
Install Longmynd. Currently recommending that the BATC fork is used: https://github.com/BritishAmateurTelevisionClub/longmynd
Install CombiTunerExpress. CombiTunerExpress is proprietary and only available as a binary.
A complete sample YAML config file is provided as config.sample.yaml, this contains all currently configurable options. If some options are omitted from the config file then internal defaults will be used.
-
configRevThe config format revision of this file, if present but wrong the file will not load, if missing file will load with warning. Current revision is 3 -
playerIDThis is an ID string for this player, if no ID is specified a unique one is generated based on the hardware serial number. It is recommended to put quotes around the ID. -
sourcesThis section contains the source specific confgsLONGMYNDThis section defines the paths and other settings for your Longmynd installationbinpathpath to the Longmynd binary.mediapathpath to Longmynd's media FIFO, this will be auto-created if it doesn't exist.statuspathpath to Longmynd's status FIFO, this will be auto-created if it doesn't exist.tstimeoutTS timeout in ms, passed to longmynd with-r, see longmynd manual for more details.
COMBITUNERThis section defines the paths and other settings for your CombiTuner installationbinpathpath to the CombiTuner binary.mediapathpath to CombiTuner's media FIFO, this will be auto-created if it doesn't exist.
-
bands- Name of the band, you may have to put it in double quotes
"if you want to use names with various caracters such as:in it. It is recommended that you add an anchor if you need to reference the band later, e.g."LNB Low": &bandlnblowsourceThe name of the signal source type, the other options in the band only apply for certain sources, see options below for details. Currently supportsLONGMYND,COMBITUNERorRTMPSTREAMlofreqLO frequency value in kHz. Currently supportsLONGMYNDorCOMBITUNERlosideSelect eitherHIGHorLOWwhen using the difference mixing product where the LO is above or below the RF frequency respectively orSUMif using the sum mixing product. Currently supportsLONGMYNDorCOMBITUNERpolBand polarity, selects bias voltage. Choose fromNONE,HORIZONTALorVERTICAL. Supported sources:LONGMYNDportBand input port. Choose fromTOPorBOTTOM. Supported sources:LONGMYNDdomainBand RTMP server domain e.g.rtmp.batc.org.uk. Supported sources:RTMPSTREAMrtmpappBand RTMP server app name, often the directory from the URL, e.g.live. Supported sources:RTMPSTREAMnetworkTimeoutBand RTMP network timeout in seconds. Supported sources:RTMPSTREAMnetworkTimeoutInitBand RTMP network initialisation timeout in seconds, likely needs to be larger thannetworkTimeout. Supported sources:RTMPSTREAMgpioidBand GPIO ID, valid values are 0-7.
- Name of the band, you may have to put it in double quotes
-
presets- Name of the preset, following the same naming rules as for bands above. supported options vary depending on the source specified in the band, see indigidual options for details. It is also recommended you add an anchor to a preset to use as the default also similar to bands above, e.g.
"QO-100 Beacon": &presetdefaultbandPreset band, its recommended to use an alias to a band in the band library, e.g.band: *bandlnblowfreqPreset frequency to tune, this can either be a single frequency or if using sourceLONGMYNDa list of frequencies to enable frequency scanning. Supported sources:LONGMYNDorCOMBITUNERsrPreset symbol rate in kSps, this can either be a single symbol rate or a list of symbol rates to enable symbol rate scanning. Supported sources:LONGMYNDbwPreset bandwidth in kHz. Supported sources:COMBITUNERstreamnamePreset RTMP stream name e.g.oscar100net. Supported sources:RTMPSTREAM
- Name of the preset, following the same naming rules as for bands above. supported options vary depending on the source specified in the band, see indigidual options for details. It is also recommended you add an anchor to a preset to use as the default also similar to bands above, e.g.
-
default- Initial settings, its recommended to use an alias to a preset in the preset library, e.g.
default: *presetdefault
- Initial settings, its recommended to use an alias to a preset in the preset library, e.g.
-
irThis section defines the IR handset behaviour.repeatFirstThe time to wait before beginning to repeat an IR events in ms.repeatDelayThe time between repeats once repeating has begun in ms.repeatResetHow long to wait with no IR signals before requiring repeatFirst again in ms.libraryPathPath to the directory containing the handset library files, see the Handset Configuration sestion for the library formathandsetsA list of handset names to load from the library
-
gpioThis section defines the pins and other options for interacting with the Raspberry Pi GPIO.repeatFirstThe time to wait before beginning to repeat an GPIO button press event in ms.repeatDelayThe time between repeats once repeating has begun in ms.rxGoodThe BCM pin number to output the reciver locked indication to. For example to output the signal on pin 7 set this to 4.buttonsA map of button names to BCM pin numbers.switchesContainer for switch event to BCM pin number mappings.highgoingA map of high going events to BCM pin numbers.lowgoingA map of low going events to BCM pin numbers.
bandA list of BCM pin numbers to use to output band ID, starting with LSB
-
osdThis section contains the configuration for the on screen display-
timersContains deactiate timers for various triggers in seconds,0disables the initial event,nulldisables the auto deactivateUSERTRIGGERActivate triggered by user pressing select buttonPROGRAMTRIGGERActivated when a new or different signal is received
-
activeContains a list of modules and their configurations for when the OSD is active. Include any modules from the list below that should be displayed in this mode.MUTEDisplays a mute icon when the player is muted. Set value tonullfor default size and location, use all sub elements to set size and location.datumWhere to measure the new location relative to. Options:TLTop Left,TCTop Centre,TRTop Right,CRCentre Right,CCCentre both,CLCentre Left,BLBottom Left,BCBottom Centre orBRBottom Right.xThe fraction of the display height the left/right (depending on datum) of the module is from the left/right of the display, valid values 0-1 for edges or -0.5 to 0.5 for centres.ySame as forxbut what fraction of the display height is the top/bottom (depending on datum).wThe width of the module as a fraction of the display height, valid values 0-1.xSame as forwbut for module height.
VOLUMEDisplays the currently set output volume.SIGLEVELVaries depending on source. ForLONGMYNDdisplays the MER of the current received signal. ForCOMBITUNERdisplays the SNR of the current received signal in dB. Size/location configuration the same as forMUTE.REPORTVaries depending on source. ForLONGMYNDdisplays the difference between the MER and the minimal viable MER for the current modulation and FEC. ForCOMBITUNERdisplays the SQI as a percentage. Size/location configuration the same as forMUTE.POWERLEVELOnly works withLONGMYND. It displays an approximate imput signal strength in dBm. Indicated power should be between -70 and -65dBm with no advantage seen for higer power. Size/location configuration the same as forMUTE.PROGRAMDisplays the service, provider, preset name, modulation type and transport stream PID details for the current signal, size/location configuration the same as forMUTE.FREQVaries slightly depending on source. ForLONGMYNDdisplays the actual frequency that is being received. ForCOMBITUNERdisplays the requested freqency only as reported by combituner.BWVaries slightly depending on source. ForLONGMYNDdisplays the actual symbol rate that is being received in kSps. ForCOMBITUNERdisplays the requested bandwidth only as reported by combituner.PLAYERIDDisplays the current player ID.
-
inactiveThe same as the active list but for when the OSD is inactive.
-
-
networkThis section contains the network control configurationbindaddrThe address of the local network interface use or '' to use all interfacesportThe TCP port number to use
-
watchdogThis section contains the source watchdog configuration, it can be populated as below or set tonullto disable the watchdog.minRestartTimeInitial time to wait after source unload before retrying, must be greater than 0 and not more thanmaxRestartTime.maxRestartTimeMaximum time to wait after source unload before retrying, must be not less thanminRestartTime.startupDelayTime to wait before the first restart after watchdog startup, prevents false restarts during player startup.backoffRateHow much to multiply the wait time by for each failed restart, must be at least.
-
watchdogServiceThis section contains the watchdog servicing configuration, it can be populated as below or set tonullto disable servicing the watchdog- ```serviceInterval`` Time to wait between touching the watchdog PID file, must be greater than 0.
pidPathThe path of the watchdog file or directory. If a directory is provided a default filename will be used. The file will be auto-created if it doesn't exist.
-
shutdownBehaviorThe default shutdown option when the power button is double pressed. Choose fromAPPSTOPorAPPRESTto stop the player or restart the player respectively. -
audioThis section contains audio configuration optionsmuteOnStartupSet the default mute status to use when starting the playervolumeOnStartupSet the default volume level to use when starting the player in %volumeStepSet the step size to use when adjusting the volume level in %enableMenuEnable a menu item to adjust mute and volume, designed for when dedicated buttons are unavailable.
-
debugDebug options, for advanced users, do not rely on these, they may go away without noticeenableMenuEnable the debug menu entryautoplayAuto play the stream on lock, should be set to True.disableHardwareCodecDisable hardware decoder in VLC, recommend setting to True, uses more CPU but is more reliable at decoding.useFTfontUse freetype font rendering adapter, supports emoji better but may cause memory leak so not recommended.
To configure a handset you need to add the handset configuration file to the handset library directory and add the filename (without the .yaml extension) to the main config file. Currently you also need to activate the driver listed in the handset file manually using the instructions in the Manual driver activation section.
A complete example handset file is available as handset.sample.yaml
nameThe name of the new handset, this should be meaningful and uniquedriverThe name of the driver used by this handsetbuttonsA map of button names to scan codes
If you know which driver you need it can be enabled with sudo ir-keytable -p <driver name>. Common values include rc-5, rc-6 and nec, a full list can be seen by running ir-keytable. If you are unsure you can enable all drivers with sudo ir-keytable -p all although this is not recommended as a permanent solution due to the risk of code conflicts.
Once you have the correct driver setup you should be able to see the IR codes when you run ir-keytable -t and press buttons on the handset you should see something like this:
54132.040051: lirc protocol(nec): scancode = 0x40
54132.040074: event type EV_MSC(0x04): scancode = 0x40
54132.040074: event type EV_SYN(0x00).
Now press each button you wish to map on the handset and add the scancode to the new handset file. To access the core functionality you need to add at least the core 5 codes, UP or DOWN, LEFT or RIGHT, SELECT, BACK and MENU for each remote. The full list of supported codes is available in the sample handset file, it is recommended that you map all codes that are supported by your handset.
The interface uses TCP sockets with JSON payloads, all requests and responses consist of a JSON object. All requests must contain a minimum of a request attribute string. All responses will contain a minimum of a success attribute boolean, if there is an error an error attribute string will be present.
The network interface is disabled by default and is only enabled if a bind address is specified in the config file. A very basic sample client is provided in networktest.py.
The getBands request returns a bands attribute object containing the bands in the band library using the same format as the config file.
The setTune request accepts a tune attribute object containing a preset in the same format as the config file. The band attribute of the preset is in the same format as returned by the getBands request.
The setMute request accepts a mute attribute boolean for the new mute state.
The sendEvent request accepts an event attribute string containing the button event to trigger.
The debugFire request accepts a function attribute string containing the name of the debug function, these are shown in the UI debug menu.
With both pyDispmanx and rydeplayer in the current directory or your PYTHONPATH and optionally a config.yaml in the current directory run:
python3 -m rydeplayer
You can also specify a config file path at the commandline:
python3 -m rydeplayer ~/myconfig.yaml
Ryde Player provides a on screen interface and video player for Longmynd compatible tuners.
Copyright (C) 2020 Tim Clark
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.