Skip to content

Commit

Permalink
Merge pull request #7 from DolbyIO/logger
Browse files Browse the repository at this point in the history
Embed js-logger dependency
  • Loading branch information
FabienLavocat committed Mar 26, 2024
2 parents cb38975 + 8981894 commit 87ee697
Show file tree
Hide file tree
Showing 9 changed files with 754 additions and 746 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-package.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

Expand All @@ -25,7 +25,7 @@ jobs:
npm run build
npm pack
- name: Upload artifact 🗄️
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: npm-package
path: ./*.tgz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-package.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

Expand Down
66 changes: 33 additions & 33 deletions README.md
Expand Up @@ -87,28 +87,31 @@ collection.on('error', (error) => {

### Examples

#### Dolby.io Communications APIs
#### Dolby.io Real-time Streaming APIs

Example on how to start a statistics collection from the [Dolby.io Communications APIs](https://docs.dolby.io/communications-apis/docs).
Example on how to start a statistics collection from the [Dolby.io Real-time Streaming APIs](https://docs.dolby.io/streaming-apis/docs).

```js
import WebRTCStats from '@dolbyio/webrtc-stats';
import VoxeetSdk from '@voxeet/voxeet-web-sdk';
import { Director, Publish } from '@millicast/sdk';

const PUBLISHER_TOKEN = '';
const STREAM_NAME = '';

const tokenGenerator = () =>
Director.getPublisher({
token: PUBLISHER_TOKEN,
streamName: STREAM_NAME,
});

const publisher = new Publish(STREAM_NAME, tokenGenerator);

// Publish the stream

const collection = new WebRTCStats({
getStatsInterval: 1000,
getStats: async () => {
// See: https://docs.dolby.io/communications-apis/docs/js-client-sdk-conferenceservice#localstats
const webRTCStats = await VoxeetSDK.conference.localStats();

// Convert the WebRTCStats object to RTCStatsReport
const values = Array.from(webRTCStats.values())[0];
const map = new Map();
for (let i = 0; i < values.length; i++) {
const element = values[i];
map.set(element.id, element);
}
return map;
getStats: () => {
return publisher.webRTCPeer.getRTCPeer().getStats();
},
});

Expand All @@ -122,31 +125,28 @@ collection.on('stats', (event) => {
collection.start();
```

#### Dolby.io Real-time Streaming APIs
#### Dolby.io Communications APIs

Example on how to start a statistics collection from the [Dolby.io Real-time Streaming APIs](https://docs.dolby.io/streaming-apis/docs).
Example on how to start a statistics collection from the [Dolby.io Communications APIs](https://docs.dolby.io/communications-apis/docs).

```js
import WebRTCStats from '@dolbyio/webrtc-stats';
import { Director, Publish } from '@millicast/sdk';

const PUBLISHER_TOKEN = '';
const STREAM_NAME = '';

const tokenGenerator = () =>
Director.getPublisher({
token: PUBLISHER_TOKEN,
streamName: STREAM_NAME,
});

const publisher = new Publish(STREAM_NAME, tokenGenerator);

// Publish the stream
import VoxeetSdk from '@voxeet/voxeet-web-sdk';

const collection = new WebRTCStats({
getStatsInterval: 1000,
getStats: () => {
return publisher.webRTCPeer.getRTCPeer().getStats();
getStats: async () => {
// See: https://docs.dolby.io/communications-apis/docs/js-client-sdk-conferenceservice#localstats
const webRTCStats = await VoxeetSDK.conference.localStats();

// Convert the WebRTCStats object to RTCStatsReport
const values = Array.from(webRTCStats.values())[0];
const map = new Map();
for (let i = 0; i < values.length; i++) {
const element = values[i];
map.set(element.id, element);
}
return map;
},
});

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
@@ -1,4 +1,4 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
collectCoverage: true,
Expand Down

0 comments on commit 87ee697

Please sign in to comment.