Golang streamer for sdr_fm/sdr_rtl devices

spsobole 6575b91b2e Merge changes from contrib 3 years ago
api 6575b91b2e Merge changes from contrib 3 years ago
cmd 6575b91b2e Merge changes from contrib 3 years ago
config 6575b91b2e Merge changes from contrib 3 years ago
plex 6575b91b2e Merge changes from contrib 3 years ago
streamer 6575b91b2e Merge changes from contrib 3 years ago
README.md be5533d341 Add a bit of documentation 3 years ago
build.yaml 6575b91b2e Merge changes from contrib 3 years ago
file.go 6575b91b2e Merge changes from contrib 3 years ago
go.mod 6575b91b2e Merge changes from contrib 3 years ago
radio.go 6575b91b2e Merge changes from contrib 3 years ago
rtlfm.go 6575b91b2e Merge changes from contrib 3 years ago
rxfm.go 6575b91b2e Merge changes from contrib 3 years ago
wav.go 1dd7daae3a Inital bare bones stremer using sdr_fm 3 years ago

README.md

go-sdr-stream

Tool to stream sdr_fm audio over HTTP written in golang.

Prerequisite

You need a to install a copy of sdr_fm

sudo apt-get install rtl-sdr

You may need to unload kernel modules and black list the modules:


#lists modules using the rtl driver
lsmod |grep rtl 

#remove them
rmmod dvb_usb_rtl28xxu
rmmod videodev
rmmod rtl2832_sdr

#optionally black list for the next reboot
echo "blacklist dvb_usb_rtl28xxu" >> /etc/modprobe.d/blacklist.conf

Build the service binary

go build git.thirdmartini.com/pub/go-sdr-stream/cmd/service

if you want to crosscompile for Raspberry Pi

GOOS=linux GOARCH=arm go build git.thirdmartini.com/pub/go-sdr-stream/cmd/service 

Use:
GOARCH=arm64 for RPI4 when running a 64bit os

Create your config

See config/config.yaml for an example

Services:
  - Name: "Stream 0"                
    Description: "FM Radio Stream" 
    MaxClients: 16                   <-- Max Clients you want to allow to stream at the same time 
    ClientTimeoutSec: 30             <-- Timeout when a client goes idel
    AllowTune: true                  <-- allow tuning interface
    Tuner:                           <-- Tuner driver config
      Type: sdr-fm                   <-- sdr-fm (uses rtl_fm )
      Id: 0                          <-- device id.. if you have multiple devices
      SampleRate: 192000             <-- radio sampling rate
      DownSampleRate: 48000          <-- output rate
      Gain: 50                       <-- sdr gain
      Oversample: 1                  <-- rtl oversampling
    Presets:                         <--Preset channels  (Supports any number of cahnnels)
      - Name: 93.3 KTCL                     <-- Chanel name dfor display
        Description: Alternative Rock       <-- short channel description
        Channel: 93.3 FM                    <-- the channel frequency
      - Name: 95.5 KTLA                     
        Description: Classical;
        Channel: 95.6 FM

Run

./service --config=<myconfig.yml>

Connect

You can now go to the ip address of where tou are running service with a web browser:

http://<myip>:9090/

You will have a stream for every service available at:

http://<myip>:9090/<service>/stream 

IE:
http://<myip>:9090/0/stream