Saturday, March 31, 2018

Audio Sound Over TCP IP


Download jessie raspberry:
https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-07-05/2017-07-05-raspbian-jessie-lite.zip

install package di masing masing mesin TX maupun RX
apt-get update
apt-get dist-upgrade
apt-get install git python-gst0.10 python-redis \
gstreamer0.10-plugins-base gstreamer0.10-plugins-bad \
gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly \
gstreamer0.10-tools python-gobject python-gobject-2 gstreamer0.10-alsa python-setuptools lsof -y

# optional
apt-get install pulseaudio alsa-base

apt-get install redis-server
sed -i.bak 's/bind 127.*/bind 0.0.0.0/' /etc/redis/redis.conf

/etc/init.d/redis-server restart
test antar mesin dengan cara :
redis-cli -h [iplawan] ping
jika reply = PONG berarti redis-server sukses!
kemudian :
easy_install OpenOB

untuk transmitter :
- HARUS ADA USB SOUNDCARD sebagai input audio
nano /usr/share/alsa/alsa.conf
ubah nilai 0 menjadi 1

defaults.ctl.card 1
defaults.pcm.card 1

kemudian start sisi TRANSMIT
/usr/local/bin/openob 192.168.127.2 ngadirojo test-link tx 192.168.127.2
#### START SCRIPT
port=3000
server=10.10.1.66
while ! lsof -i @"$port"
do
        echo -e "\e[38;5;198mPORT : $port is down,    - start STL\e[0m"
        /usr/local/bin/openob "$server" rahox test-link tx "$server"
done
#### END SCRIPT


sisi RECEIVE
/usr/local/bin/openob [ip-receiver] test-rx-node test-link rx
#### START SCRIPT
port=3000
server=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}')
while ! lsof -i:"$port"
do
        echo -e "\e[38;5;198mPORT : $port is down,    - start STL\e[0m"
        /usr/local/bin/openob "$server" test-rx-node test-link rx
done
#### END SCRIPT

trobelshoot :
lsof|grep "\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}" | grep openob
usage: openob config_host node_name link_name tx [-h] [-a {auto,alsa,jack}]
                                                 [-d ALSA_DEVICE]
                                                 [-jn JACK_NAME] [-aj]
                                                 [-r SAMPLERATE]
                                                 [-e {pcm,opus}] [-p PORT]
                                                 [-m] [--no-multicast]
                                                 [-j JITTER_BUFFER]
                                                 [-b {16,24,32,48,64,96,128,192,256,384}]
                                                 [-l LOSS] [--dtx] [--no-dtx]
                                                 [--fec] [--no-fec]
                                                 [--complexity {0,1,2,3,4,5,6,7,8,9}]
                                                 [--framesize {2,5,10,20,40,60}]
                                                 receiver_host

positional arguments:
  receiver_host         The receiver for this transmitter. The machine at this
                        address must be running an rx-mode Manager for this
                        link name

optional arguments:
  -h, --help            show this help message and exit
  -a {auto,alsa,jack}, --audio_input {auto,alsa,jack}
                        The audio source type for this end of the link
                        (default: auto)
  -r SAMPLERATE, --samplerate SAMPLERATE
                        Set the sample rate to request from the input (Hz)
                        (default: 0)
  -e {pcm,opus}, --encoding {pcm,opus}
                        The audio encoding type for this link; PCM for linear
                        audio (16-bit), or Opus for encoded audio (default:
                        opus)
  -p PORT, --port PORT  The base port to use for audio transport. This port
                        must be accessible on the receiving host (default:
                        3000)
  -m, --multicast       Start this transmitter in multicast mode, enabling
                        multiple clients to connect at once using the address
                        specified in reciever_host (default: False)
  --no-multicast        Start this transmitter in unicast mode (default)
                        (default: False)
  -j JITTER_BUFFER, --jitter_buffer JITTER_BUFFER
                        The size of the jitter buffer in milliseconds. Affects
                        latency; may be reduced to 5-10ms on fast reliable
                        networks, or increased for poor networks like 3G
                        (default: 40)

alsa:
  Options when using ALSA source type

  -d ALSA_DEVICE, --alsa_device ALSA_DEVICE
                        The ALSA device to connect to for input (default:
                        hw:0)

jack:
  Options when using JACK source type

  -jn JACK_NAME, --jack_name JACK_NAME
                        JACK port name root (default: openob)
  -aj, --jack_auto      Disable auto connection for JACK inputs (default:
                        True)

opus:
  Opus encoder options

  -b {16,24,32,48,64,96,128,192,256,384}, --bitrate {16,24,32,48,64,96,128,192,256,384}
                        Bitrate if using CELT/Opus (in kbit/s) (default: 128)
  -l LOSS, --loss LOSS  Expected packet loss percentage for Opus, between 0
                        and 100 (default: 0)
  --dtx                 Enable Opus Discontinuous Transmission support
                        (default: False)
  --no-dtx              Disable Opus Discontinuous Transmission support
                        (default) (default: False)
  --fec                 Enable Opus Inband Forward Error Correction support
                        (default) (default: True)
  --no-fec              Disable Opus Inband Forward Error Correction support
                        (default: True)
  --complexity {0,1,2,3,4,5,6,7,8,9}
                        Opus Computational Complexity, between 0 and 10 -
                        reduce on CPU-constrained devices (default: 9)
  --framesize {2,5,10,20,40,60}
                        Opus frame size (ms) (default: 20)


No comments:

Post a Comment