Git Product home page Git Product logo

rocd's Introduction

PROJECT IS WORK IN PROGRESS!

rocd: audio streaming daemon

Build Matrix chat

About project

rocd is a real-time audio streaming daemon with REST API.

With it, you can:

  • inspect and control audio devices
  • initiate audio streaming between local devices and remote peers
  • create virtual devices that automatically stream all sound to/from remote peers

The key idea is to isolate application code from complexities of network streaming and audio I/O.

Applications can be written in any language (e.g. node.js or python) and don't have any special requirements. Real-time path, sensitive to latency and performance, is fully enclosed inside rocd.

Features

Internally, rocd is based on Roc Toolkit, which gives you:

  • streaming high-quality audio with guaranteed latency
  • robust work on unreliable networks like Wi-Fi, due to use of Forward Erasure Correction codes
  • multiple profiles for different CPU and latency requirements
  • portability and low requirements to hardware

With rocd, these benefits are combined with a high-level, language-independent, and easy to use HTTP API. Basically you just say "stream from here to there" and it works.

Use cases

TBD

Technology

rocd is built on top of several big lower-level technologies:

  • For streaming:

    • roc-toolkit - real-time streaming library that combines high quality, guaranteed latency, and loss repair
    • roc-go - golang bindings to Roc Toolkit
  • For virtual devices:

    • roc-sink and roc-source PipeWire modules - virtual devices for Linux with PipeWire
    • roc-pulse - virtual devices for Linux with PulseAudio
    • roc-vad - virtual devices for macOS CoreAudio

Compatibility

Since rocd is based on Roc Toolkit, it is automatically interoperable with all other software based on it.

Remote peer can be:

Third-party RTP peers are also supported, given that they implement all necessary extensions.

Platforms

Currently supported platforms:

  • Linux / PipeWire
  • Linux / PulseAudio
  • Linux / ALSA
  • macOS / CoreAudio
  • Windows / WASAPI

Releases

TBD

Installation

TBD

Usage

There are two ways to use rocd:

  • via REST API
  • via web interface

In addition, rocd can be configured via command-line flags and configuration file.

For further details, see USAGE.md.

Hacking

Contributions in any form are always welcome! You can find issues needing help using help wanted and good first issue labels.

If you would like to dig into the project internals, have a look at HACKING.md.

Authors

See here.

License

Contents of the repository is licensed under MPL-2.0.

For details on Roc Toolkit licensing, see here.

rocd's People

Contributors

gavv avatar adrianopol avatar

Watchers

Mikhail Baranov avatar  avatar  avatar

Forkers

gavv adrianopol

rocd's Issues

Add /about endpoint

Return json with:

  • rocd version
  • rocd git commit
  • go version
  • os
  • arch
  • device backend (pulseaudio, pipewire)
  • device backend version

Also show this info in /admin.

Translate errors to HTTP

  1. Declare common error types in models package (e.g. NotFound, ServiceUnavailable).
  2. Use them when reporting errors in device manager, stream manager, etc.
  3. Translate them to HTTP responses in server.go

Add "make gen" and "make fmt" to CI

Check that code generation works. Check that after generation and formatting there are no changed files, i.e. committed files are uptodate.

Add user config

Add yaml config that allows user to configure stream devices and streams statically, without need to use http.

On start, rocd should read stream devices and streams from config and create or update actual devices & streams to match them.

Such devices & streams should be readonly, and it shouldn't be possible to modify or delete them via http.

(We can also add readonly: true/false to json)

We also need /reload endpoint to re-read config.

Implement streams

We need to implement StreamManager. See USAGE#streams for more details.

Stream:

  • Is a virtual object that maps connects some Device (by UID) -- reader -- to a list of peers -- writers (each peer has 1 to 3 interfaces). On diagram below, it is a sender-to-recerver part of the pipeline.
  • In MVP Stream may be implemented as a goroutine that manages a number of subprocesses: roc-send, roc-recv.
  • Should be stored persistently and restored on daemon start.
  • Should be able to be updated through API. The payload accepts a subset of parameters that are being updated.
  • StreamManager should handle situations when subprocesses are crashed. (This should be analyzed.)
  • There are 2 Stream types:
    • sending Stream: is has from_device and to_address paarameters
    • receiving Stream: is has from_address and to_device paarameters
  • Initially there are no Streams.
graph LR
  microphone --> input
  subgraph roc_sender
    input --> sender1
    input --> sender2
  end
  sender1 -- AU_SRC --> receiver1
  sender1 -- AU_RPR --> receiver1
  sender1 <-- AU_CTL --> receiver1

  sender2 -- AU_SRC --> receiver2
  sender2 -- AU_RPR --> receiver2
  sender2 <-- AU_CTL --> receiver2

  subgraph roc_receiver1
    receiver1 --> output1
  end
  subgraph roc_receiver2
    receiver2 --> output2
  end

  output1 --> speaker1
  output2 --> speaker2
Loading

Steps

  • Implement StreamManager methods.
  • ...

Out of scope

  • Choose storage format for Streams.

Docs

Add CLI options

Options:

  • path to state file
  • path to config file
  • ip
  • port
  • force specific device backend

Also add --help and --version.

Rework persistent storage

Use some simple key-value db instead of yaml file, to avoid scaling problems when number of streams is high.

Ideally choose pure go implementation to avoid cgo dependencies.

To serialize structs into kv db we could use msgpack.

Add discovery API

  • GET /beacons
  • POST /beacons
  • GET /beacons/uid
  • PUT /beacons/uid
  • DELETE /beacons/uid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.