@stream-io/video-client 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ import {
26
26
  watchChangePublishQuality,
27
27
  watchConnectionQualityChanged,
28
28
  watchDominantSpeakerChanged,
29
+ watchLiveEnded,
29
30
  watchNewReactions,
30
31
  watchParticipantCountChanged,
31
32
  watchParticipantJoined,
@@ -92,6 +93,7 @@ export const registerEventHandlers = (
92
93
  'call.user_muted': () => console.log('call.user_muted received'),
93
94
  };
94
95
  const eventHandlers = [
96
+ watchLiveEnded(dispatcher, call),
95
97
  watchSfuErrorReports(dispatcher),
96
98
  watchChangePublishQuality(dispatcher, call),
97
99
  watchConnectionQualityChanged(dispatcher, state),
@@ -4,6 +4,7 @@ import { CallState } from '../store';
4
4
  import { StreamVideoParticipantPatches } from '../types';
5
5
  import { getLogger } from '../logger';
6
6
  import { ErrorCode } from '../gen/video/sfu/models/models';
7
+ import { OwnCapability } from '../gen/coordinator';
7
8
 
8
9
  const logger = getLogger(['events']);
9
10
 
@@ -68,6 +69,20 @@ export const watchParticipantCountChanged = (
68
69
  });
69
70
  };
70
71
 
72
+ export const watchLiveEnded = (dispatcher: Dispatcher, call: Call) => {
73
+ return dispatcher.on('error', (e) => {
74
+ if (
75
+ e.eventPayload.oneofKind !== 'error' ||
76
+ !e.eventPayload.error.error ||
77
+ e.eventPayload.error.error.code !== ErrorCode.LIVE_ENDED
78
+ )
79
+ return;
80
+
81
+ if (!call.permissionsContext.hasPermission(OwnCapability.JOIN_BACKSTAGE))
82
+ call.leave();
83
+ });
84
+ };
85
+
71
86
  /**
72
87
  * Watches and logs the errors reported by the currently connected SFU.
73
88
  */
@@ -412,7 +412,7 @@ export class Publisher {
412
412
  private onIceCandidate = async (e: RTCPeerConnectionIceEvent) => {
413
413
  const { candidate } = e;
414
414
  if (!candidate) {
415
- this.logger('warn', 'null ice candidate');
415
+ this.logger('debug', 'null ice candidate');
416
416
  return;
417
417
  }
418
418
  await this.sfuClient.iceTrickle({
@@ -615,14 +615,14 @@ export class Publisher {
615
615
 
616
616
  private onIceConnectionStateChange = () => {
617
617
  this.logger(
618
- 'error',
618
+ 'debug',
619
619
  `ICE Connection state changed`,
620
620
  this.pc.iceConnectionState,
621
621
  );
622
622
  };
623
623
 
624
624
  private onIceGatheringStateChange = () => {
625
- this.logger('error', `ICE Gathering State`, this.pc.iceGatheringState);
625
+ this.logger('debug', `ICE Gathering State`, this.pc.iceGatheringState);
626
626
  };
627
627
 
628
628
  private onSignalingStateChange = () => {
@@ -248,7 +248,7 @@ export class Subscriber {
248
248
  private onIceCandidate = async (e: RTCPeerConnectionIceEvent) => {
249
249
  const { candidate } = e;
250
250
  if (!candidate) {
251
- logger('warn', 'null ice candidate');
251
+ logger('debug', 'null ice candidate');
252
252
  return;
253
253
  }
254
254
 
@@ -188,7 +188,7 @@ export const createStatsReporter = ({
188
188
  if (pollingIntervalInMs > 0) {
189
189
  const loop = async () => {
190
190
  await run().catch((e) => {
191
- logger('warn', 'Failed to collect stats', e);
191
+ logger('debug', 'Failed to collect stats', e);
192
192
  });
193
193
  timeoutId = setTimeout(loop, pollingIntervalInMs);
194
194
  };