Streaming API

The Horn Streaming API deals with audio, video and other real time streams that are part of managing live conversations on the Horn system. It is quite different from the rest of the API and has the following components:

  • Control stream: This manages the asyncronous messaging to manage users in channels and to distribute channel state to the clients.

  • WebRTC: An API to broker the SDP negotiations between the server and the client so they can start a WebRTC session. It also allows some basic management of the underlying media streams.

  • Device management: This concerns the selection and management of the different sources/destinations of audio and video that are available to the client.

The control stream messages as well as WebRTC broker messages are sent over a common websocket using custom messages. For this reason, there is no ReST interface available. We provide a comprehensive TypeScript/JavaScript API to manage this. As only authenticated users may access the streaming API, the user needs to provide a valid authentication token.

JavaScript Library

A streaming session is managed through an HornConnection object from JavaScript API. This section assumes you have Horn’s JavaScript Library available in your project and an authentication token configured.

In order to start new connection, run following code:

import { HornConnection, HornConfiguration } from '@horn/api';

HornConfiguration.configure({
    authToken: 'your-auth-token'
});

const connection = HornConnection.get();
connection.configure('your-channel-uuid')
connection.onConnected(() => {
    console.log('Connected!');
});
connection.onDisconnected((reason) => {
    console.log('Disconnected. Reason: ' + reason);
});
connection.start();

// Disconnect when you want using `stop()` method:
// connection.stop();

Checkout out Horn Examples for more examples on how to start with the JavaScript API.