Stream Receiver

From BATC Wiki
Jump to navigation Jump to search

Introduction

Software Version 201807290 introduced the capability to receive an incoming stream and trigger a repeater to relay it when the stream is active.

The concept of operation is that a special "repeater input" streaming channel is set up on the BATC Streaming Server for any repeaters who wish to implement the facility.

This stream will not be listed on the normal BATC live stream pages as it will only be viewed by the Portsdown stream receiver at the repeater site.

A dedicated Portsdown Stream Receiver is then installed at each repeater site, connected to the internet, and set up to listen or monitor the "repeater input" streaming channel only.

The Stream Receiver's video and audio output is fed into the repeater video input matrix, and the "stream active" signal is used to switch the repeater logic to show the incoming stream as if it was a normal RF input channel.

Trusted members of the repeater group are then given access to be able to stream in to the BATC server on this account and will then be able to access and send signals to the repeater using Adobe Media encoder, Vmix or a Portsdown in streaming mode.

Preparation

You will need a Raspberry Pi 3B or Raspberry Pi 3B+ and a good power supply. This should be connected to the internet at the repeater site, and the video and audio outputs from the 3.5mm jack (connection details here) connected to your repeater input matrix. GPIO pin 7 on the Raspberry Pi should be connected to a suitable interface to switch the input into use when it goes high (3.3v). A suitable memory card with Raspbian Stretch software and Portsdown Software Version 201807290 or later should be fitted. No touchscreen, video dongle or audio dongle is required.

The next requirement is to have a "Repeater Input" stream account set up on the BATC Streaming Server; send a request to admin@batc.tv.

Once the account is set up, you will be sent the account details including the stream RTMP input URL and key and the stream output URL.

The stream rtmp input URL and key should be given to your trusted users to configure their streaming software.

The output stream URL should not be passed to anyone and is only used to set up the repeater site stream Receiver as described below.

Setting up the Raspberry Pi

Change the default password

Connect to the Raspberry Pi through the console as described in the Console Guide. The first step is to change the default Raspberry Pi password as it will be constantly connected to the Internet. You should not run a Portsdown-configured Raspberry Pi constantly connected to the internet without changing the default password. From the console, select Shutdown and Reboot options. Then select Option 3, "Exit to Linux". At the command prompt type passwd and press enter. It will ask you for the current password (raspberry), but will not echo anything to the screen as you type it in. It should then ask you for the new password (twice). Again it will not show anything on the screen. When complete, type

sudo reboot now

and press enter to return to reboot; you may need to disconnect and reconnect the power. Don't forget to write the password down (yes!) and put it out of view, but attached to your receiver hardware (on the underside of the box?). If a hacker has physical access to your hardware, you have bigger problems than the hacker simply knowing the password.

Setting up the stream receiver

When the Raspberry Pi reboots, log in with you new password and the console should be displayed.

Console 1.jpg

From the console select option 4, Receive. The select option 4 on the Receive Menu.

Receive Menu.jpg


Next, the software will request the stream output URL. This is the stream output URL for your special repeater input channel (NOT your normal repeater output stream) and will be in the form of:

rtmp://rtmp.batc.org.uk/live/gb3xxinput

Press enter and it will start the stream receiver FOR TESTING. You can now check that the stream is displayed and that your switching circuitry works.

The final, ESSENTIAL, step is to set up the system to boot straight into the receiver. From the Console Main Menu select option 5, System.

System.jpg

Next select option 1, Autostart, and move the red box to the "StreamRX_boot" line and select it with the space bar. The press enter to select it.

Autostart.jpg

The stream receiver will now start at every reboot.

The last thing to do is to reboot the RPi and check that the stream receiver does restart and work.

Operation

The stream receiver is designed to be run unattended for long periods. This is how it operates.

With no incoming stream there is a continuous loop that starts the stream player (omxplayer) every 10 seconds. If there is no stream, the player times out after about 6 seconds and sits idle until it is restarted 4 seconds later.

If the player finds a stream and starts, it sends a status message. The status message is checked by the software, and if the first line starts with "Video" this is taken as an indication that the stream is valid, and the GPIO pin to trigger the repeater switching is set high. Sometimes the player does not start properly and only finds the audio part of the stream. In this case the player is stopped and restarted at the beginning of the next 10 second cycle.

When the stream finishes, the player times out and the GPIO pin is set low. The 10 second cycle starts again.

There is an occasional lock-up condition where the player seems to detect a valid stream, but does not display any video. This triggers the GPIO switch, but leaves the system locked up showing the "Valid Stream Detected" message. To overcome this without requiring repeater keeper intervention, the player is stopped (whatever is happening) once an hour, normally within 10 seconds of the top of the hour.

During normal running, the stream receiver does not write to the SD Card, so it is unlikely to get corrupted in the event of a power failure.