Skip to content

Commit

Permalink
Add observer
Browse files Browse the repository at this point in the history
  • Loading branch information
havfo committed Mar 22, 2024
1 parent dc0cbc4 commit 3a229fc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@mui/icons-material": "^5.14.16",
"@mui/material": "^5.14.16",
"@observertc/client-monitor-js": "^3.5.0",
"@observertc/samples-encoder": "^2.2.12",
"@reduxjs/toolkit": "^1.9.7",
"awaitqueue": "^3.0.2",
"bowser": "^2.11.0",
Expand Down
13 changes: 10 additions & 3 deletions src/services/mediaService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,18 @@ export class MediaService extends EventEmitter {

public monitor: Promise<ClientMonitor> = (async () => {
const { createClientMonitor } = await import('@observertc/client-monitor-js');
const { ClientSampleEncoder, schemaVersion } = await import('@observertc/samples-encoder');

const sampleEncoder = new ClientSampleEncoder();
const monitor = createClientMonitor({ collectingPeriodInMs: 5000 });

monitor.on('stats-collected', (stats) => {
logger.debug('stats-collected [stats:%o]', stats);
monitor.on('sample-created', ({ clientSample }) => {
const encodedSample = sampleEncoder.encodeToBase64(clientSample);

this.signalingService.notify('clientSample', {
schemaVersion,
encodedSample,
});
});

return monitor;
Expand Down Expand Up @@ -588,7 +595,7 @@ export class MediaService extends EventEmitter {
return;
}

throw new Error('consumer not found');
return;
}

this.changeConsumer(consumerId, changeEvent[notification.method] as MediaChange, false);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mediaSender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class MediaSender extends EventEmitter {
if (this.p2pProduce) {
promises.push(...this.peerIds.map((peerId) => this.peerProduce(peerId)));
}

const [ sfuResult ] = await Promise.allSettled(promises);

if (sfuResult.status === 'rejected') {
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"

"@bufbuild/protobuf@^1.2.0":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@bufbuild/protobuf/-/protobuf-1.8.0.tgz#1c8651ea34adb8019b483e09de02aeeb1cd57d79"
integrity sha512-qR9FwI8QKIveDnUYutvfzbC21UZJJryYrLuZGjeZ/VGz+vXelUkK+xgkOHsvPEdYEdxtgUUq4313N8QtOehJ1Q==

"@emotion/babel-plugin@^11.11.0":
version "11.11.0"
resolved "https://registry.yarnpkg.com/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz#c2d872b6a7767a9d176d007f5b31f7d504bb5d6c"
Expand Down Expand Up @@ -837,6 +842,13 @@
events "^3.3.0"
uuid "^8.3.2"

"@observertc/samples-encoder@^2.2.12":
version "2.2.12"
resolved "https://registry.yarnpkg.com/@observertc/samples-encoder/-/samples-encoder-2.2.12.tgz#85345d1ba386cf300b1ba766f201dbab6a878670"
integrity sha512-m0L+MZKSTzFT0+nfgro3mAwzioBw+4rDFyZgsRVWZ8MD9jInnXVneRegUlUQCrYIw0O0lWsLR7/UGo9Fj/GJaw==
dependencies:
"@bufbuild/protobuf" "^1.2.0"

"@popperjs/core@^2.11.8":
version "2.11.8"
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
Expand Down

0 comments on commit 3a229fc

Please sign in to comment.