@akkadu/rtc-streamer-base
v4.3.6
Published
To understand the larger context where this module operates, if you are not already familiar, take a look at our Agora RTC documentation [here](https://www.notion.so/akkadu/Agora-RTC-6f6935c5b3be40b08ec33251d8334ca4)
Downloads
392
Readme
RTC Base
To understand the larger context where this module operates, if you are not already familiar, take a look at our Agora RTC documentation here
Purpose of this module
This module is the base of all the RTC modules and provides common functionalities and initialization methods for an Agora client.
The tasks that the base is supposed to accomplish:
- Create a Agora client
- Connect client to a room
- Manage client state (client type, room connection)
- Manage device support outlined in
support.js
- Manage which Agora version we import (AgoraRTS for non-webRTC devices, agora-rtc-sdk for others)
- Maintain and parse streamer information (publishers) requested from the streaming API
Core concepts
Storing publisher information
This module expects a certain type of publisher data to be given when initialized. This data
is based upon a return of the streams api, however
the data is not in a good format, and it is then reformatted in the function parsePublishers
to a format of:
{
'en-US':['stream-1', 'stream-2', 'stream-x']
}
which can then be accessed via this.baseConfig.publishers
in this class and classes extending it.
Using the module
The module is a javascript ESM class and is as of now published as-is. This is so that we can worry about bundling and babelifying the module separately in one place, namely our webapp repository.
This module is not meant to be used directly by itself, but via proxies like rtc-streamer-consumer and producer which extend this base classes functionality.
The main points of using and extending this is to:
- Pass in the correct config, defined in index.d.ts in the class constructor.
validator.js
implements the proper checks and throws an error in the case of invalid config. - Listen to support and error emits which are documented at index.d.ts at method
checkDeviceSupport
- Use this.client that is exposed by the module. If you want to make sure everything is initialized before calling client methods you can
await this.clientInitialized
.
Communication with the module
To simplify usage in the frontend and to make it easier to have consistent behavior with Agora's inconsistent streaming module all communication is done through emits.
This means that when you call a method you should expect a corresponding emit to be fired from the streamer. To see what emits functions are sending see index.d.ts file or use intellisense's documentation user @fires point
Structure
Documentation
- index.d.ts defines the modules interface, this is your main source of method definitions
Implementation
- index.js
Tests
- ./tests/test.js
Commands
Build yarn build
Run Tests yarn test
Development
There are two ways of development, you can either develop inside the repository using the rtc-test-server module or follow the instructions here to export this module outside the repository