Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
balazskreith committed Jan 15, 2025
1 parent 35f4992 commit 5a1f203
Show file tree
Hide file tree
Showing 85 changed files with 2,270 additions and 3,471 deletions.
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
Table of Contents:

- [Quick Start](#quick-start)
- [Integrations](#integrations)
- [Mediasoup](#mediasoup)
- [Configuration](#configurations)
- [Developer Manual](#developer-manual)
- [User Manual](#developer-manual)
- [API Manual](#api-manual)
<!--
- [Collected Metrics](#collected-metrics)
Expand Down Expand Up @@ -54,21 +51,26 @@ Add `@observertc/client-monitor-js` to your WebRTC app.
```javascript
import { createClientMonitor } from "@observertc/client-monitor-js";
const monitor = createClientMonitor();
const collector = monitor.sources.addRTCPeerConnection(peerConnection);
monitor.sources.addRTCPeerConnection(peerConnection);

monitor.on("stats-collected", () => {
console.log(`Sending audio bitrate: ${monitor.sendingAudioBitrate}`);
console.log(`Sending video bitrate: ${monitor.sendingVideoBitrate}`);
console.log(`Receiving audio bitrate: ${monitor.receivingAudioBitrate}`);
console.log(`Receiving video bitrate: ${monitor.receivingVideoBitrate}`);
});

monitor.on('freezed-video-track', (trackMonitor) => {

});
```

The above example do as follows:

1. Create a client monitor, which collect stats every (by default in every 5s)
2. Setup a collector collect stats from a peer connection
3. Register an event called after stats are collected
1. Create a client monitor, which collect stats every (by default in every 2s)
2. Setup a source collect stats from a peer connection
3. Register an event handler called after stats are collected and metrics are updated
4. Register an event handler called if a receiving video track has freezed

**NOTE**: `createClientMonitor()` method creates a monitor instance with default configurations.
You can pass a configuration object to the `createClientMonitor(config: ClientMonitorConfig)` method to customize the monitor instance.
Expand All @@ -84,22 +86,23 @@ import mediasoup from "mediaousp-client";

const mediasoupDevice = new mediasoup.Device();
const monitor = createClientMonitor();
const collector = monitor.collectors.addMediasoupDevice(mediasoupDevice);

monitor.on("stats-collected", () => {
console.log(`Sending audio bitrate: ${monitor.sendingAudioBitrate}`);
console.log(`Sending video bitrate: ${monitor.sendingVideoBitrate}`);
console.log(`Receiving audio bitrate: ${monitor.receivingAudioBitrate}`);
console.log(`Receiving video bitrate: ${monitor.receivingVideoBitrate}`);
});
const collector = monitor.sources.addMediasoupDevice(mediasoupDevice);
```

**Important Note**: The created collector is hooked to the device's 'newtransport' event and can automatically detect transports created **after** the device has been added. If you create transports before adding the device to the monitor, those previously created transports will not be monitored automatically. You will need to manually add them to the stats collector like this:

```javascript
const myTransport = collector.addTransport(myTransport); // your transport created before the device is added to the monitor
const myTransport = monitor.sources.addMediasoupTransport(myTransport); // your transport created before the device is added to the monitor
```

## User Manual

For detailed description of configuration and client monitor usage check out the user manual.





## Collected Metrics

Collecting WebRTC Metrics is either done periodically according to the `collectingPeriodInMs` configuration or manually by calling the `monitor.collect()` method. The collected metrics are stored in the `ClientMonitor` instance and assigned to Entries.
Expand Down
1 change: 0 additions & 1 deletion docs/.nojekyll

This file was deleted.

92 changes: 0 additions & 92 deletions docs/assets/highlight.css

This file was deleted.

Loading

0 comments on commit 5a1f203

Please sign in to comment.