Skip to content

Instantly share code, notes, and snippets.

@bilus
Created March 29, 2024 16:10
Show Gist options
  • Save bilus/6343130db51c9b86770076618556c524 to your computer and use it in GitHub Desktop.
Save bilus/6343130db51c9b86770076618556c524 to your computer and use it in GitHub Desktop.

AutoStage Broadcasts Server

Overview

This document describes AutoStage Broadcasts Server version 1.0.0 providing information about radio stations, providing API identical to AutoStage Delivery API.

Supported endpoints:

  • /v1/broadcasts
  • /v1/config
  • /v1/genres

Quick start

The embedded server exposes Broadcasts API via HTTP on a given port. You can access the API using the AutoStage SDK.

Example code for starting the server:

ServerConfig config = new ServerConfig(
        "localhost", // domain to bind to
        8000,        // port to bind to
        false);      // production mode

String filesPath = this.getFilesDir().getAbsolutePath();
server = new Server(filesPath, config);
config.setReadOnly(true);
server.start();

Note: The application will need Internet access for the server to run, so make sure the following has been added to AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

We recommend using setReadOnly to ensure that the database storing Broadcast data is open in read-only mode:

config.setReadOnly(true);

Read-write access is unnecessary, given the application will be installed along with its database files and station logos.

Data storage

All application data is stored inside the directory passed as the first argument to the Server constructor. For example:

String filesPath = this.getFilesDir().getAbsolutePath();
server = new Server(filesPath, config);

There are two sub-directories inside the filesPath directory:

  • data/ containing database files,
  • logos/ with cached station logos.

Logging

Logs generated by the embedded server are prefixed with [DTS-ASE]. Here is an example of output you can expect:

[DTS-ASE] Starting AutoStage Broadcasts Server 1.0.0 LEVEL=info
[DTS-ASE] Opening storage at data/user/0/com.dts.autostage/files/assets/data in read-only mode LEVEL=info
[DTS-ASE] All 2 tables opened in 3ms LEVEL=info
[DTS-ASE] Discard stats nextEmptySlot: 0 LEVEL=info
[DTS-ASE] Set nextTxnTs to 1934 LEVEL=info
[DTS-ASE] Successfully loaded 8 locales of genres LEVEL=info
[DTS-ASE] Starting web server at localhost:8000 LEVEL=info
[DTS-ASE] Last cursor: 0, next cursor: 0 LEVEL=info
[DTS-ASE] Broadcast records after reload: 1932 LEVEL=info
[DTS-ASE] Loaded 1932 broadcast records LEVEL=info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment