Skip to content

Bluetooth Audio Plugin

Version: 1.0

Status: ⚫⚪⚪

BluetoothAudio plugin for Thunder framework.

Table of Contents

Introduction

Scope

This document describes purpose and functionality of the BluetoothAudio plugin. It includes detailed specification about its configuration, methods and properties as well as sent notifications.

Case Sensitivity

All identifiers of the interfaces described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.

Acronyms, Abbreviations and Terms

The table below provides and overview of acronyms used in this document and their definitions.

Acronym Description
API Application Programming Interface
BR/EDR Basic Rate/Enhanced Data Rate
HTTP Hypertext Transfer Protocol
JSON JavaScript Object Notation; a data interchange format
JSON-RPC A remote procedure call protocol encoded in JSON
LC-SBC Low-Complexity SubBand Coding

The table below provides and overview of terms and abbreviations used in this document and their definitions.

Term Description
bitpool A parameter to the LC-SBC codec that changes the encoding bitrate; the higher it is the higher the bitrate and thus the audio quality
callsign The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique.

References

Ref ID Description
HTTP HTTP specification
JSON-RPC JSON-RPC 2.0 specification
JSON JSON specification
Thunder Thunder API Reference

Description

The Bluetooth Audio Sink plugin enables audio streaming to Bluetooth audio sink devices. The plugin is sink a from the host device stack perspective; in Bluetooth topology the host device becomes in fact an audio source. The plugin requires a Bluetooth controller service that will provide Bluetooth BR/EDR scanning, pairing and connection functionality; typically this is fulfiled by the BluetoothControl plugin.

The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].

Configuration

The table below lists configuration options of the plugin.

Name Type M/O Description
callsign string mandatory Plugin instance name (default: BluetoothAudio)
classname string mandatory Class name: BluetoothAudio
locator string mandatory Library name: libThunderBluetoothAudio.so
startmode string mandatory Determines in which state the plugin should be moved to at startup of the framework
controller string optional Callsign of the Bluetooth controller service (typically BluetoothControl)
server object optional BluetoothAudio server configuration
server?.interface integer optional Bluetooth interface to listen to for incomming connections
server?.inactivitytimeout integer optional Timeout to drop inactive connections (in ms)
server?.psm integer optional Port to listen to for incomming conections (typically 25)
sink object optional BluetoothAudio sink configuration
sink.codecs object mandatory Codec settings
sink.codecs.LC-SBC object mandatory Settings for the LC-SBC codec
sink.codecs.LC-SBC?.preset string optional Predefined audio quality setting (must be one of the following: Compatible, HQ, LQ, MQ, XQ)
sink.codecs.LC-SBC?.bitpool integer optional Custom audio quality based on bitpool value (used when preset is not specified)
sink.codecs.LC-SBC?.channelmode string optional Channel mode for custom audio quality (used when preset is not specified) (must be one of the following: DualChannel, JointStereo, Mono, Stereo)
source object optional BluetoothAudio source configuration
source.codecs object mandatory Codec settings
source.codecs?.LC-SBC object optional Settings for the LC-SBC codec
source.codecs?.LC-SBC.maxbitpool integer mandatory Maximum accepted bitpool value

Interfaces

This plugin implements the following interfaces:

  • IBluetoothAudio::ISink (IBluetoothAudio.h) (version 1.0.0) (compliant format)

    This interface uses legacy lowercase naming convention. With the next major release the naming convention will change to camelCase.

  • IBluetoothAudio::ISource (IBluetoothAudio.h) (version 1.0.0) (compliant format)

    This interface uses legacy lowercase naming convention. With the next major release the naming convention will change to camelCase.

Methods

The following methods are provided by the BluetoothAudio plugin:

BluetoothAudio Sink interface methods:

Method Description
sink::assign Assigns a Bluetooth sink device for audio playback
sink::revoke Revokes a Bluetooth sink device from audio playback

sink::assign method

Assigns a Bluetooth sink device for audio playback.

Parameters

Name Type M/O Description
params object mandatory ...
params.address string mandatory Address of the bluetooth device to assign

Result

Name Type M/O Description
result null mandatory Always null

Errors

Message Description
ERROR_BAD_REQUEST Device address value is invalid
ERROR_ALREADY_CONNECTED A sink device is already assigned

Example

Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::assign",
  "params": {
    "address": "..."
  }
}

Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": null
}

sink::revoke method

Revokes a Bluetooth sink device from audio playback.

Parameters

This method takes no parameters.

Result

Name Type M/O Description
result null mandatory Always null

Errors

Message Description
ERROR_ALREADY_RELEASED No device is currently assigned as sink

Example

Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::revoke"
}

Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": null
}

Properties

The following properties are provided by the BluetoothAudio plugin:

BluetoothAudio Sink interface properties:

Property R/W Description
sink::state read-only Current state o the audio sink device
sink::device read-only Bluetooth address of the audio sink device
sink::type read-only Type of the audio sink device
sink::latency read/write Latency of the audio sink device
sink::supportedcodecs read-only Audio codecs supported by the audio sink device
sink::supporteddrms read-only DRM schemes supported by the audio sink device
sink::codec read-only Properites of the currently used audio codec
sink::drm read-only Properites of the currently used DRM scheme
sink::stream read-only Properties of the currently transmitted audio stream

BluetoothAudio Source interface properties:

Property R/W Description
source::state read-only Current state of the source device
source::device read-only Bluetooth address of the source device
source::type read-only Type of the audio source device
source::codec read-only Properites of the currently used codec
source::drm read-only Properties of the currently used DRM scheme
source::stream read-only Properites of the currently transmitted audio stream

sink::state property

Provides access to the current state o the audio sink device.

This property is read-only.

Value

Name Type M/O Description
(property) string mandatory Current state o the audio sink device (must be one of the following: Connected, ConnectedBad, ConnectedRestricted, Connecting, Disconnected, Ready, Streaming, Unassigned)

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::state"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "Disconnected"
}

sink::device property

Provides access to the bluetooth address of the audio sink device.

This property is read-only.

Value

Name Type M/O Description
(property) string mandatory Bluetooth address of the audio sink device

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not assigned

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::device"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "..."
}

sink::type property

Provides access to the type of the audio sink device.

This property is read-only.

Value

Name Type M/O Description
(property) string mandatory Type of the audio sink device (must be one of the following: Amplifier, Headphone, Recorder, Speaker, Unknown)

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not connected

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::type"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "Headphone"
}

sink::latency property

Provides access to the latency of the audio sink device.

Value

Name Type M/O Description
(property) object mandatory Latency of the audio sink device
(property).value integer mandatory Audio latency in milliseconds
Name Type M/O Description
(property) integer mandatory Latency of the audio sink device

Errors

Message Description
ERROR_BAD_REQUEST Latency value is invalid

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::latency"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": 0
}

Set Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::latency",
  "params": {
    "value": 20
  }
}

Set Response

{
    "jsonrpc": "2.0",
    "id": 42,
    "result": "null"
}

sink::supportedcodecs property

Provides access to the audio codecs supported by the audio sink device.

This property is read-only.

Value

Name Type M/O Description
(property) array mandatory Audio codecs supported by the audio sink device
(property)[#] string mandatory ... (must be one of the following: LC-SBC)

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not connected

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::supportedcodecs"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": [
    "LC-SBC"
  ]
}

sink::supporteddrms property

Provides access to the DRM schemes supported by the audio sink device.

This property is read-only.

Value

Name Type M/O Description
(property) array mandatory DRM schemes supported by the audio sink device
(property)[#] string mandatory ... (must be one of the following: DTCP, SCMS-T)

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not connected

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::supporteddrms"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": [
    "SCMS-T"
  ]
}

sink::codec property

Provides access to the properites of the currently used audio codec.

This property is read-only.

Value

Name Type M/O Description
(property) object mandatory Properites of the currently used audio codec
(property).codec string mandatory Audio codec used (must be one of the following: LC-SBC)
(property).settings opaque object mandatory Codec-specific audio quality preset, compression profile, etc

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not configured

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::codec"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "codec": "LC-SBC",
    "settings": {}
  }
}

sink::drm property

Provides access to the properites of the currently used DRM scheme.

This property is read-only.

Value

Name Type M/O Description
(property) object mandatory Properites of the currently used DRM scheme
(property).drm string mandatory Content protection scheme used (must be one of the following: DTCP, SCMS-T)
(property).settings opaque object mandatory DRM-specific content protection level, encoding rules, etc

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not connected or not yet configured

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::drm"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "drm": "SCMS-T",
    "settings": {}
  }
}

sink::stream property

Provides access to the properties of the currently transmitted audio stream.

This property is read-only.

Value

Name Type M/O Description
(property) object mandatory Properties of the currently transmitted audio stream
(property).samplerate integer mandatory Sample rate in Hz
(property).bitrate integer mandatory Target bitrate in bits per second (eg. 320000)
(property).channels integer mandatory Number of audio channels
(property).resolution integer mandatory Sampling resolution in bits per sample
(property).isresampled boolean mandatory Indicates if the source stream is being resampled by the stack to match sink capabilities

Errors

Message Description
ERROR_ILLEGAL_STATE The sink device currently is not connected or not yet configured

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.sink::stream"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "samplerate": 44100,
    "bitrate": 0,
    "channels": 2,
    "resolution": 16,
    "isresampled": false
  }
}

source::state property

Provides access to the current state of the source device.

This property is read-only.

Value

Name Type M/O Description
(property) string mandatory Current state of the source device (must be one of the following: Connected, ConnectedBad, ConnectedRestricted, Connecting, Disconnected, Ready, Streaming, Unassigned)

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.source::state"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "Disconnected"
}

source::device property

Provides access to the bluetooth address of the source device.

This property is read-only.

Value

Name Type M/O Description
(property) string mandatory Bluetooth address of the source device

Errors

Message Description
ERROR_ILLEGAL_STATE No source device is currently connected

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.source::device"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "..."
}

source::type property

Provides access to the type of the audio source device.

This property is read-only.

Value

Name Type M/O Description
(property) string mandatory Type of the audio source device (must be one of the following: Microphone, Mixer, Player, Tuner, Unknown)

Errors

Message Description
ERROR_ILLEGAL_STATE No source device is currently connected

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.source::type"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": "Player"
}

source::codec property

Provides access to the properites of the currently used codec.

This property is read-only.

Value

Name Type M/O Description
(property) object mandatory Properites of the currently used codec
(property).codec string mandatory Audio codec used (must be one of the following: LC-SBC)
(property).settings opaque object mandatory Codec-specific audio quality preset, compression profile, etc

Errors

Message Description
ERROR_ILLEGAL_STATE No source device is not connected or sink is not yet configured

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.source::codec"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "codec": "LC-SBC",
    "settings": {}
  }
}

source::drm property

Provides access to the properties of the currently used DRM scheme.

This property is read-only.

Value

Name Type M/O Description
(property) object mandatory Properties of the currently used DRM scheme
(property).drm string mandatory Content protection scheme used (must be one of the following: DTCP, SCMS-T)
(property).settings opaque object mandatory DRM-specific content protection level, encoding rules, etc

Errors

Message Description
ERROR_ILLEGAL_STATE No source device is connected or sink is not yet configured

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.source::drm"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "drm": "SCMS-T",
    "settings": {}
  }
}

source::stream property

Provides access to the properites of the currently transmitted audio stream.

This property is read-only.

Value

Name Type M/O Description
(property) object mandatory Properites of the currently transmitted audio stream
(property).samplerate integer mandatory Sample rate in Hz
(property).bitrate integer mandatory Target bitrate in bits per second (eg. 320000)
(property).channels integer mandatory Number of audio channels
(property).resolution integer mandatory Sampling resolution in bits per sample
(property).isresampled boolean mandatory Indicates if the source stream is being resampled by the stack to match sink capabilities

Errors

Message Description
ERROR_ILLEGAL_STATE No source device is connected or sink is not yet configured

Example

Get Request

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.source::stream"
}

Get Response

{
  "jsonrpc": "2.0",
  "id": 42,
  "result": {
    "samplerate": 44100,
    "bitrate": 0,
    "channels": 2,
    "resolution": 16,
    "isresampled": false
  }
}

Notifications

Notifications are autonomous events triggered by the internals of the implementation and broadcasted via JSON-RPC to all registered observers. Refer to [Thunder] for information on how to register for a notification.

The following events are provided by the BluetoothAudio plugin:

BluetoothAudio Sink interface events:

Notification Description
sink::statechanged Signals audio sink state change

BluetoothAudio Source interface events:

Notification Description
source::statechanged Signals audio source state change

sink::statechanged notification

Signals audio sink state change.

Notification Parameters

Name Type M/O Description
params object mandatory ...
params.state string mandatory Changed BluetoothAudio State (must be one of the following: Connected, ConnectedBad, ConnectedRestricted, Connecting, Disconnected, Ready, Streaming, Unassigned)

Example

Registration

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.register",
  "params": {
    "event": "sink::statechanged",
    "id": "myid"
  }
}

Notification

{
  "jsonrpc": "2.0",
  "method": "myid.sink::statechanged",
  "params": {
    "state": "Disconnected"
  }
}

The client ID parameter is passed within the notification designator, i.e. <client-id>.sink::statechanged.

source::statechanged notification

Signals audio source state change.

Notification Parameters

Name Type M/O Description
params object mandatory ...
params.state string mandatory Changed BluetoothAudio State (must be one of the following: Connected, ConnectedBad, ConnectedRestricted, Connecting, Disconnected, Ready, Streaming, Unassigned)

Example

Registration

{
  "jsonrpc": "2.0",
  "id": 42,
  "method": "BluetoothAudio.1.register",
  "params": {
    "event": "source::statechanged",
    "id": "myid"
  }
}

Notification

{
  "jsonrpc": "2.0",
  "method": "myid.source::statechanged",
  "params": {
    "state": "Disconnected"
  }
}

The client ID parameter is passed within the notification designator, i.e. <client-id>.source::statechanged.