3xcellent / intercom

GRPC Stream Spike

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Intercom

Golang GRPC stream server and client for sending audio and video.

This is a demonstration of a bi-directional GRPC stream, while also being somewhat interesting in that it is streaming audio and images with the connected microphone and webcam. I have so far only tested on a Macbook Pro. While the following installation instructions are for OSX as well, there is no reason this wouldn't work on other OS's with the proper gocv and portaudio installations.

I would eventually like to target running on a Raspberry Pi with an attached display, webcam, and microphone. Otherwise, I hope to learn a bit about:

  • GRPC Streams
  • Golang Threading
  • Audio/Video

Dev Workstation Setup

  1. Install Opencv

    brew install opencv
    

    Install pk-config if not already installed

    brew install pkg-config
    

    be sure to have pkg-config var set correctly

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
    

    Opencv comes with it's own .pc, move it or simlink it to the PKG_CONFIG_PATH

    ln -s /usr/local/opt/opencv@4/lib/pkgconfig/opencv4.pc $PKG_CONFIG_PATH
    

    Add these lines to your environment .bash_profile or similiar

    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
    alias opencvflags="pkg-config --cflags --libs opencv"
    
  2. Install PortAudio

    brew install portaudio
    

GRPC

Using protobuf and protoc for code-generation of go files (i.e. intercom.pb.go)

To generate updated proto files, run:

cd _proto
protoc \
  -I ./ \
  --go_out=plugins=grpc:../proto \
  intercom.proto

Running

  1. Start Server

    cd cmd/server
    go run main.go
    
  2. Start Client

    cd cmd/client
    go run main.go 0 [path to background image, hopefully a kitten]
    

    Press [Spacebar] to broadcast

    Press [Esc] to exit

    Note that feedback can occur. Once multiple clients are supported this can be addressed.

About

GRPC Stream Spike


Languages

Language:Go 100.0%