This project is built with Lerna and contains the following packages:
millicast-sdk
: The SDK itself.millicast-publisher-demo
: Publisher demo page using SDK. You can try this demo here.millicast-viewer-demo
: Viewer demo page using SDK.millicast-chromecast-receiver
: Example of Google Cast receiver for demo.
Asumming that you have Node 12.10.x or newer and npm
installed, install the required dependencies running:
npm ci
Whenever you are working on a new feature, fix or change, make sure you create a changeset with a description of the change. Follow this guide for further understanding.
As the project is built using Lerna, we can rely on it to manage our packages dependencies, so you just need to run at project's root directory
npm run prepare
You will need to add a .env
file in all demo packages (packages/millicast-publisher-demo
, packages/millicast-viewer-demo
, packages/millicast-chromecast-receiver
, packages/millicast-multiview-demo
& packages/millicast-webaudio-delay-demo
). You can simply copy the .env.sample
to get started:
note : The
.env
is typically not added to git. When you clone the repo, you will not find this file and will have to create one yourself. The.env.example
app can be used as a template with basic keys. Rename the file to.env
and insert your tokens to get the file up and running.
# Make a .env file with the following vars
MILLICAST_STREAM_NAME=test
MILLICAST_ACCOUNT_ID=test
MILLICAST_PUBLISH_TOKEN=test
These tokens can be found in your Dolby.io dashboard.
Then, build all packages:
npm run build
Optionally you can run other Lerna commands using $ npx lerna [command]
.
If you want to add, fix or edit features in the SDK or just try our demo pages, run the following command:
npm run start-all
Please note that before you run
npm run start-all
, you need to have built the solution first usingnpm run build
It opens all the demo apps in your browser and keeps watching for changes in all the packages. You only need to refresh both pages if you modify the code.
If you want to add, fix or edit features in the SDK or just try our specific demo pages, run the following command:
npm run start
Please note that before you run
npm run start
, you need to have built the solution first usingnpm run build
This command opens the following demo apps in your browser:
- millicast-publisher-demo
- millicast-viewer-demo
- millicast-sdk
It keeps watching for changes in these packages. You only need to refresh both pages if you modify the code.
If you want to run all tests, run:
npm run test
Note: There are some requirements to take into account before running E2E tests. Make sure to take a look at those.
If you want to run only unit tests, navigate to the millicast-sdk
package.
cd packages/millicast-sdk
npm run test-unit
The first step before running E2E tests is setting some environment variables and adjusting the director URL desired.
- You have to set three variables in the environment based on the token environment you are.
- In MacOS/Linux:
export PUBLISH_TOKEN=<your_publish_token>
export ACCOUNT_ID=<your_account_id>
export STREAM_NAME=<your_stream_name>
- In Windows (Powershell):
$env:PUBLISH_TOKEN="<your_publish_token>"
$env:ACCOUNT_ID="<your_account_id>"
$env:STREAM_NAME="<your_stream_name>"
- In Windows (CMD):
set PUBLISH_TOKEN=<your_publish_token>
set ACCOUNT_ID=<your_account_id>
set STREAM_NAME=<your_stream_name>
If you only want to run E2E tests, in the command line run:
npm run test-e2e
The SDK documentation is written with JSDcos. To build the HTML documentation, run:
npx lerna run build-docs
Or if you want to navigate to the docs on your local machine, run:
npx lerna run start-docs --stream
In the logs you find the link where you can access to docs. By default, the logs run on http://localhost:5000.
classDiagram
class EventEmitter {
+emit(eventName: string | symbol, ...args: any[]) boolean
+on(eventName: string | symbol, listener: (...args: any[]) => void) EventEmitter
}
class BaseWebRTC {
<<Abstract>>
+string streamName
#PeerConnection webRTCPeer
#Signaling signaling
#tokenGeneratorCallback tokenGenerator
+isActive() bool
+stop()
+async reconnect(data)
+getRTCPeerConnection() RTCPeerConnection
}
class PeerConnection{
$getCapabilities() MillicastCapability
+async addRemoteTrack(media, streams) RTCRtpTransceiver
+async createRTCPeer(config)
+async closeRTCPeer()
+initStats()
+stopStats()
+async getRTCLocalSDP(options) string
+async setRTCRemoteSDP(sdp)
+updateBandwidthRestriction(sdp, bitrate) string
+async updateBitrate(bitrate)
}
class Signaling {
+async connect() WebSocket
+close()
+async cmd(command, data?) Object
+async publish(sdp, options) string
+async subscribe(sdp, options) string
}
class Publish {
+async connect(options)
+async record()
+async unrecord()
}
class View {
+async connect(options)
+async select(layer)
+async addRemoteTrack(media, streams)
+async project(sourceId, mapping)
+async unproject(mediaIds)
}
class Director {
<<Singleton>>
+getPublisher(publishToken, streamName, streamType?)
+getSubscriber(streamName, streamAccountId, subscribeToken?)
}
class SdpParser {
<<Singleton>>
+setStereo(sdp) string
+setDTX(sdp) string
+setVideoBitrate(sdp, bitrate) string
+setSimulcast(sdp, codec) string
}
class Logger {
<<Singleton>>
+get() Logger
+getLevel() LogLevel
+setLevel()
+debug(string)
+info(string)
+warn(string)
+error(string)
+time(string)
}
EventEmitter <|-- BaseWebRTC
EventEmitter <|-- PeerConnection
EventEmitter <|-- Signaling
BaseWebRTC <|-- Publish
BaseWebRTC <|-- View
BaseWebRTC *-- PeerConnection
BaseWebRTC *-- Signaling
Signaling <-- SdpParser
PeerConnection <-- SdpParser
Publish <-- Director : getPublisher
View <-- Director: getSubscriber
BaseWebRTC <-- Logger
Director <-- Logger
Signaling <-- Logger
PeerConnection <-- Logger
Publish <-- Logger
View <-- Logger
SdpParser <-- Logger