@stream-io/video-client 0.7.7 → 0.7.9
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.
- package/CHANGELOG.md +14 -0
- package/dist/index.browser.es.js +368 -8
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +369 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +368 -8
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +12 -0
- package/dist/src/StreamSfuClient.d.ts +2 -0
- package/dist/src/devices/InputMediaDeviceManager.d.ts +1 -1
- package/dist/src/devices/MicrophoneManager.d.ts +17 -0
- package/dist/src/gen/coordinator/index.d.ts +96 -34
- package/dist/src/gen/video/sfu/signal_rpc/signal.client.d.ts +17 -1
- package/dist/src/gen/video/sfu/signal_rpc/signal.d.ts +76 -0
- package/package.json +6 -5
- package/src/Call.ts +22 -0
- package/src/StreamSfuClient.ts +20 -0
- package/src/devices/InputMediaDeviceManager.ts +2 -1
- package/src/devices/MicrophoneManager.ts +123 -1
- package/src/devices/__tests__/MicrophoneManager.test.ts +121 -4
- package/src/devices/__tests__/MicrophoneManagerRN.test.ts +24 -0
- package/src/devices/__tests__/mocks.ts +17 -1
- package/src/gen/coordinator/index.ts +102 -49
- package/src/gen/google/protobuf/struct.ts +1 -1
- package/src/gen/google/protobuf/timestamp.ts +1 -1
- package/src/gen/video/sfu/event/events.ts +1 -1
- package/src/gen/video/sfu/models/models.ts +1 -1
- package/src/gen/video/sfu/signal_rpc/signal.client.ts +47 -1
- package/src/gen/video/sfu/signal_rpc/signal.ts +369 -1
- package/src/helpers/sound-detector.ts +3 -1
- package/src/store/CallState.ts +10 -4
package/dist/index.cjs.js
CHANGED
|
@@ -54,6 +54,22 @@ const CreateDeviceRequestPushProviderEnum = {
|
|
|
54
54
|
HUAWEI: 'huawei',
|
|
55
55
|
XIAOMI: 'xiaomi',
|
|
56
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* @export
|
|
59
|
+
*/
|
|
60
|
+
const NoiseCancellationSettingsModeEnum = {
|
|
61
|
+
AVAILABLE: 'available',
|
|
62
|
+
DISABLED: 'disabled',
|
|
63
|
+
AUTO_ON: 'auto-on',
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* @export
|
|
67
|
+
*/
|
|
68
|
+
const NoiseCancellationSettingsRequestModeEnum = {
|
|
69
|
+
AVAILABLE: 'available',
|
|
70
|
+
DISABLED: 'disabled',
|
|
71
|
+
AUTO_ON: 'auto-on',
|
|
72
|
+
};
|
|
57
73
|
/**
|
|
58
74
|
* All possibility of string to use
|
|
59
75
|
* @export
|
|
@@ -62,6 +78,7 @@ const OwnCapability = {
|
|
|
62
78
|
BLOCK_USERS: 'block-users',
|
|
63
79
|
CREATE_CALL: 'create-call',
|
|
64
80
|
CREATE_REACTION: 'create-reaction',
|
|
81
|
+
ENABLE_NOISE_CANCELLATION: 'enable-noise-cancellation',
|
|
65
82
|
END_CALL: 'end-call',
|
|
66
83
|
JOIN_BACKSTAGE: 'join-backstage',
|
|
67
84
|
JOIN_CALL: 'join-call',
|
|
@@ -2443,10 +2460,196 @@ var models = /*#__PURE__*/Object.freeze({
|
|
|
2443
2460
|
});
|
|
2444
2461
|
|
|
2445
2462
|
/* eslint-disable */
|
|
2446
|
-
// @generated by protobuf-ts 2.9.
|
|
2463
|
+
// @generated by protobuf-ts 2.9.4 with parameter long_type_string,client_generic,server_none,eslint_disable
|
|
2447
2464
|
// @generated from protobuf file "video/sfu/signal_rpc/signal.proto" (package "stream.video.sfu.signal", syntax proto3)
|
|
2448
2465
|
// tslint:disable
|
|
2449
2466
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
2467
|
+
class StartNoiseCancellationRequest$Type extends runtime.MessageType {
|
|
2468
|
+
constructor() {
|
|
2469
|
+
super('stream.video.sfu.signal.StartNoiseCancellationRequest', [
|
|
2470
|
+
{ no: 1, name: 'session_id', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
|
|
2471
|
+
]);
|
|
2472
|
+
}
|
|
2473
|
+
create(value) {
|
|
2474
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
2475
|
+
message.sessionId = '';
|
|
2476
|
+
if (value !== undefined)
|
|
2477
|
+
runtime.reflectionMergePartial(this, message, value);
|
|
2478
|
+
return message;
|
|
2479
|
+
}
|
|
2480
|
+
internalBinaryRead(reader, length, options, target) {
|
|
2481
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
2482
|
+
while (reader.pos < end) {
|
|
2483
|
+
let [fieldNo, wireType] = reader.tag();
|
|
2484
|
+
switch (fieldNo) {
|
|
2485
|
+
case /* string session_id */ 1:
|
|
2486
|
+
message.sessionId = reader.string();
|
|
2487
|
+
break;
|
|
2488
|
+
default:
|
|
2489
|
+
let u = options.readUnknownField;
|
|
2490
|
+
if (u === 'throw')
|
|
2491
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
2492
|
+
let d = reader.skip(wireType);
|
|
2493
|
+
if (u !== false)
|
|
2494
|
+
(u === true ? runtime.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
return message;
|
|
2498
|
+
}
|
|
2499
|
+
internalBinaryWrite(message, writer, options) {
|
|
2500
|
+
/* string session_id = 1; */
|
|
2501
|
+
if (message.sessionId !== '')
|
|
2502
|
+
writer.tag(1, runtime.WireType.LengthDelimited).string(message.sessionId);
|
|
2503
|
+
let u = options.writeUnknownFields;
|
|
2504
|
+
if (u !== false)
|
|
2505
|
+
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
2506
|
+
return writer;
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* @generated MessageType for protobuf message stream.video.sfu.signal.StartNoiseCancellationRequest
|
|
2511
|
+
*/
|
|
2512
|
+
const StartNoiseCancellationRequest = new StartNoiseCancellationRequest$Type();
|
|
2513
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
2514
|
+
class StartNoiseCancellationResponse$Type extends runtime.MessageType {
|
|
2515
|
+
constructor() {
|
|
2516
|
+
super('stream.video.sfu.signal.StartNoiseCancellationResponse', [
|
|
2517
|
+
{ no: 1, name: 'error', kind: 'message', T: () => Error$2 },
|
|
2518
|
+
]);
|
|
2519
|
+
}
|
|
2520
|
+
create(value) {
|
|
2521
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
2522
|
+
if (value !== undefined)
|
|
2523
|
+
runtime.reflectionMergePartial(this, message, value);
|
|
2524
|
+
return message;
|
|
2525
|
+
}
|
|
2526
|
+
internalBinaryRead(reader, length, options, target) {
|
|
2527
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
2528
|
+
while (reader.pos < end) {
|
|
2529
|
+
let [fieldNo, wireType] = reader.tag();
|
|
2530
|
+
switch (fieldNo) {
|
|
2531
|
+
case /* stream.video.sfu.models.Error error */ 1:
|
|
2532
|
+
message.error = Error$2.internalBinaryRead(reader, reader.uint32(), options, message.error);
|
|
2533
|
+
break;
|
|
2534
|
+
default:
|
|
2535
|
+
let u = options.readUnknownField;
|
|
2536
|
+
if (u === 'throw')
|
|
2537
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
2538
|
+
let d = reader.skip(wireType);
|
|
2539
|
+
if (u !== false)
|
|
2540
|
+
(u === true ? runtime.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
return message;
|
|
2544
|
+
}
|
|
2545
|
+
internalBinaryWrite(message, writer, options) {
|
|
2546
|
+
/* stream.video.sfu.models.Error error = 1; */
|
|
2547
|
+
if (message.error)
|
|
2548
|
+
Error$2.internalBinaryWrite(message.error, writer.tag(1, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
2549
|
+
let u = options.writeUnknownFields;
|
|
2550
|
+
if (u !== false)
|
|
2551
|
+
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
2552
|
+
return writer;
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
/**
|
|
2556
|
+
* @generated MessageType for protobuf message stream.video.sfu.signal.StartNoiseCancellationResponse
|
|
2557
|
+
*/
|
|
2558
|
+
const StartNoiseCancellationResponse = new StartNoiseCancellationResponse$Type();
|
|
2559
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
2560
|
+
class StopNoiseCancellationRequest$Type extends runtime.MessageType {
|
|
2561
|
+
constructor() {
|
|
2562
|
+
super('stream.video.sfu.signal.StopNoiseCancellationRequest', [
|
|
2563
|
+
{ no: 1, name: 'session_id', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
|
|
2564
|
+
]);
|
|
2565
|
+
}
|
|
2566
|
+
create(value) {
|
|
2567
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
2568
|
+
message.sessionId = '';
|
|
2569
|
+
if (value !== undefined)
|
|
2570
|
+
runtime.reflectionMergePartial(this, message, value);
|
|
2571
|
+
return message;
|
|
2572
|
+
}
|
|
2573
|
+
internalBinaryRead(reader, length, options, target) {
|
|
2574
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
2575
|
+
while (reader.pos < end) {
|
|
2576
|
+
let [fieldNo, wireType] = reader.tag();
|
|
2577
|
+
switch (fieldNo) {
|
|
2578
|
+
case /* string session_id */ 1:
|
|
2579
|
+
message.sessionId = reader.string();
|
|
2580
|
+
break;
|
|
2581
|
+
default:
|
|
2582
|
+
let u = options.readUnknownField;
|
|
2583
|
+
if (u === 'throw')
|
|
2584
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
2585
|
+
let d = reader.skip(wireType);
|
|
2586
|
+
if (u !== false)
|
|
2587
|
+
(u === true ? runtime.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
return message;
|
|
2591
|
+
}
|
|
2592
|
+
internalBinaryWrite(message, writer, options) {
|
|
2593
|
+
/* string session_id = 1; */
|
|
2594
|
+
if (message.sessionId !== '')
|
|
2595
|
+
writer.tag(1, runtime.WireType.LengthDelimited).string(message.sessionId);
|
|
2596
|
+
let u = options.writeUnknownFields;
|
|
2597
|
+
if (u !== false)
|
|
2598
|
+
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
2599
|
+
return writer;
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
/**
|
|
2603
|
+
* @generated MessageType for protobuf message stream.video.sfu.signal.StopNoiseCancellationRequest
|
|
2604
|
+
*/
|
|
2605
|
+
const StopNoiseCancellationRequest = new StopNoiseCancellationRequest$Type();
|
|
2606
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
2607
|
+
class StopNoiseCancellationResponse$Type extends runtime.MessageType {
|
|
2608
|
+
constructor() {
|
|
2609
|
+
super('stream.video.sfu.signal.StopNoiseCancellationResponse', [
|
|
2610
|
+
{ no: 1, name: 'error', kind: 'message', T: () => Error$2 },
|
|
2611
|
+
]);
|
|
2612
|
+
}
|
|
2613
|
+
create(value) {
|
|
2614
|
+
const message = globalThis.Object.create(this.messagePrototype);
|
|
2615
|
+
if (value !== undefined)
|
|
2616
|
+
runtime.reflectionMergePartial(this, message, value);
|
|
2617
|
+
return message;
|
|
2618
|
+
}
|
|
2619
|
+
internalBinaryRead(reader, length, options, target) {
|
|
2620
|
+
let message = target ?? this.create(), end = reader.pos + length;
|
|
2621
|
+
while (reader.pos < end) {
|
|
2622
|
+
let [fieldNo, wireType] = reader.tag();
|
|
2623
|
+
switch (fieldNo) {
|
|
2624
|
+
case /* stream.video.sfu.models.Error error */ 1:
|
|
2625
|
+
message.error = Error$2.internalBinaryRead(reader, reader.uint32(), options, message.error);
|
|
2626
|
+
break;
|
|
2627
|
+
default:
|
|
2628
|
+
let u = options.readUnknownField;
|
|
2629
|
+
if (u === 'throw')
|
|
2630
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
2631
|
+
let d = reader.skip(wireType);
|
|
2632
|
+
if (u !== false)
|
|
2633
|
+
(u === true ? runtime.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
return message;
|
|
2637
|
+
}
|
|
2638
|
+
internalBinaryWrite(message, writer, options) {
|
|
2639
|
+
/* stream.video.sfu.models.Error error = 1; */
|
|
2640
|
+
if (message.error)
|
|
2641
|
+
Error$2.internalBinaryWrite(message.error, writer.tag(1, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
2642
|
+
let u = options.writeUnknownFields;
|
|
2643
|
+
if (u !== false)
|
|
2644
|
+
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
2645
|
+
return writer;
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
/**
|
|
2649
|
+
* @generated MessageType for protobuf message stream.video.sfu.signal.StopNoiseCancellationResponse
|
|
2650
|
+
*/
|
|
2651
|
+
const StopNoiseCancellationResponse = new StopNoiseCancellationResponse$Type();
|
|
2652
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
2450
2653
|
class SendStatsRequest$Type extends runtime.MessageType {
|
|
2451
2654
|
constructor() {
|
|
2452
2655
|
super('stream.video.sfu.signal.SendStatsRequest', [
|
|
@@ -3496,6 +3699,18 @@ const SignalServer = new runtimeRpc.ServiceType('stream.video.sfu.signal.SignalS
|
|
|
3496
3699
|
I: SendStatsRequest,
|
|
3497
3700
|
O: SendStatsResponse,
|
|
3498
3701
|
},
|
|
3702
|
+
{
|
|
3703
|
+
name: 'StartNoiseCancellation',
|
|
3704
|
+
options: {},
|
|
3705
|
+
I: StartNoiseCancellationRequest,
|
|
3706
|
+
O: StartNoiseCancellationResponse,
|
|
3707
|
+
},
|
|
3708
|
+
{
|
|
3709
|
+
name: 'StopNoiseCancellation',
|
|
3710
|
+
options: {},
|
|
3711
|
+
I: StopNoiseCancellationRequest,
|
|
3712
|
+
O: StopNoiseCancellationResponse,
|
|
3713
|
+
},
|
|
3499
3714
|
]);
|
|
3500
3715
|
|
|
3501
3716
|
/**
|
|
@@ -5798,6 +6013,20 @@ class SignalServerClient {
|
|
|
5798
6013
|
const method = this.methods[6], opt = this._transport.mergeOptions(options);
|
|
5799
6014
|
return runtimeRpc.stackIntercept('unary', this._transport, method, opt, input);
|
|
5800
6015
|
}
|
|
6016
|
+
/**
|
|
6017
|
+
* @generated from protobuf rpc: StartNoiseCancellation(stream.video.sfu.signal.StartNoiseCancellationRequest) returns (stream.video.sfu.signal.StartNoiseCancellationResponse);
|
|
6018
|
+
*/
|
|
6019
|
+
startNoiseCancellation(input, options) {
|
|
6020
|
+
const method = this.methods[7], opt = this._transport.mergeOptions(options);
|
|
6021
|
+
return runtimeRpc.stackIntercept('unary', this._transport, method, opt, input);
|
|
6022
|
+
}
|
|
6023
|
+
/**
|
|
6024
|
+
* @generated from protobuf rpc: StopNoiseCancellation(stream.video.sfu.signal.StopNoiseCancellationRequest) returns (stream.video.sfu.signal.StopNoiseCancellationResponse);
|
|
6025
|
+
*/
|
|
6026
|
+
stopNoiseCancellation(input, options) {
|
|
6027
|
+
const method = this.methods[8], opt = this._transport.mergeOptions(options);
|
|
6028
|
+
return runtimeRpc.stackIntercept('unary', this._transport, method, opt, input);
|
|
6029
|
+
}
|
|
5801
6030
|
}
|
|
5802
6031
|
|
|
5803
6032
|
const defaultOptions = {
|
|
@@ -7071,13 +7300,11 @@ class CallState {
|
|
|
7071
7300
|
this.eventHandlers = {
|
|
7072
7301
|
// these events are not updating the call state:
|
|
7073
7302
|
'call.closed_caption': undefined,
|
|
7303
|
+
'call.deleted': undefined,
|
|
7074
7304
|
'call.permission_request': undefined,
|
|
7075
7305
|
'call.recording_failed': undefined,
|
|
7076
7306
|
'call.recording_ready': undefined,
|
|
7077
|
-
'call.transcription_started': undefined,
|
|
7078
|
-
'call.transcription_stopped': undefined,
|
|
7079
7307
|
'call.transcription_ready': undefined,
|
|
7080
|
-
'call.transcription_failed': undefined,
|
|
7081
7308
|
'call.user_muted': undefined,
|
|
7082
7309
|
'connection.error': undefined,
|
|
7083
7310
|
'connection.ok': undefined,
|
|
@@ -7113,9 +7340,17 @@ class CallState {
|
|
|
7113
7340
|
'call.session_participant_joined': this.updateFromSessionParticipantJoined,
|
|
7114
7341
|
'call.session_participant_left': this.updateFromSessionParticipantLeft,
|
|
7115
7342
|
'call.session_started': (e) => this.updateFromCallResponse(e.call),
|
|
7343
|
+
'call.transcription_started': () => {
|
|
7344
|
+
this.setCurrentValue(this.transcribingSubject, true);
|
|
7345
|
+
},
|
|
7346
|
+
'call.transcription_stopped': () => {
|
|
7347
|
+
this.setCurrentValue(this.transcribingSubject, false);
|
|
7348
|
+
},
|
|
7349
|
+
'call.transcription_failed': () => {
|
|
7350
|
+
this.setCurrentValue(this.transcribingSubject, false);
|
|
7351
|
+
},
|
|
7116
7352
|
'call.unblocked_user': this.unblockUser,
|
|
7117
7353
|
'call.updated': (e) => this.updateFromCallResponse(e.call),
|
|
7118
|
-
'call.deleted': undefined,
|
|
7119
7354
|
};
|
|
7120
7355
|
}
|
|
7121
7356
|
/**
|
|
@@ -8695,6 +8930,16 @@ class StreamSfuClient {
|
|
|
8695
8930
|
sessionId: this.sessionId,
|
|
8696
8931
|
}), this.logger);
|
|
8697
8932
|
};
|
|
8933
|
+
this.startNoiseCancellation = async () => {
|
|
8934
|
+
return retryable(() => this.rpc.startNoiseCancellation({
|
|
8935
|
+
sessionId: this.sessionId,
|
|
8936
|
+
}), this.logger);
|
|
8937
|
+
};
|
|
8938
|
+
this.stopNoiseCancellation = async () => {
|
|
8939
|
+
return retryable(() => this.rpc.stopNoiseCancellation({
|
|
8940
|
+
sessionId: this.sessionId,
|
|
8941
|
+
}), this.logger);
|
|
8942
|
+
};
|
|
8698
8943
|
this.join = async (data) => {
|
|
8699
8944
|
const joinRequest = JoinRequest.create({
|
|
8700
8945
|
...data,
|
|
@@ -11027,7 +11272,9 @@ const createSoundDetector = (audioStream, onSoundDetectedStateChanged, options =
|
|
|
11027
11272
|
// clean-up the AudioContext elements
|
|
11028
11273
|
microphone.disconnect();
|
|
11029
11274
|
analyser.disconnect();
|
|
11030
|
-
|
|
11275
|
+
if (audioContext.state !== 'closed') {
|
|
11276
|
+
await audioContext.close();
|
|
11277
|
+
}
|
|
11031
11278
|
// stop the stream
|
|
11032
11279
|
if (destroyStreamOnStop) {
|
|
11033
11280
|
audioStream.getTracks().forEach((track) => {
|
|
@@ -11158,6 +11405,99 @@ class MicrophoneManager extends InputMediaDeviceManager {
|
|
|
11158
11405
|
await this.stopSpeakingWhileMutedDetection();
|
|
11159
11406
|
}
|
|
11160
11407
|
});
|
|
11408
|
+
this.subscriptions.push(createSubscription(this.call.state.callingState$, (callingState) => {
|
|
11409
|
+
// do nothing when noise filtering isn't turned on
|
|
11410
|
+
if (!this.noiseCancellationRegistration || !this.noiseCancellation)
|
|
11411
|
+
return;
|
|
11412
|
+
const autoOn = this.call.state.settings?.audio.noise_cancellation?.mode ===
|
|
11413
|
+
NoiseCancellationSettingsModeEnum.AUTO_ON;
|
|
11414
|
+
if (autoOn && callingState === exports.CallingState.JOINED) {
|
|
11415
|
+
this.noiseCancellationRegistration
|
|
11416
|
+
.then(() => this.noiseCancellation?.enable())
|
|
11417
|
+
.catch((err) => {
|
|
11418
|
+
this.logger('warn', `Failed to enable noise cancellation`, err);
|
|
11419
|
+
return this.call.notifyNoiseCancellationStopped();
|
|
11420
|
+
});
|
|
11421
|
+
}
|
|
11422
|
+
else if (callingState === exports.CallingState.LEFT) {
|
|
11423
|
+
this.noiseCancellationRegistration
|
|
11424
|
+
.then(() => this.noiseCancellation?.disable())
|
|
11425
|
+
.catch((err) => {
|
|
11426
|
+
this.logger('warn', `Failed to disable noise cancellation`, err);
|
|
11427
|
+
});
|
|
11428
|
+
}
|
|
11429
|
+
}));
|
|
11430
|
+
}
|
|
11431
|
+
/**
|
|
11432
|
+
* Enables noise cancellation for the microphone.
|
|
11433
|
+
*
|
|
11434
|
+
* Note: not supported in React Native.
|
|
11435
|
+
* @param noiseCancellation - a noise cancellation instance to use.
|
|
11436
|
+
*/
|
|
11437
|
+
async enableNoiseCancellation(noiseCancellation) {
|
|
11438
|
+
if (isReactNative()) {
|
|
11439
|
+
throw new Error('Noise cancellation is not supported in React Native');
|
|
11440
|
+
}
|
|
11441
|
+
const { ownCapabilities, settings } = this.call.state;
|
|
11442
|
+
const hasNoiseCancellationCapability = ownCapabilities.includes(OwnCapability.ENABLE_NOISE_CANCELLATION);
|
|
11443
|
+
if (!hasNoiseCancellationCapability) {
|
|
11444
|
+
throw new Error('Noise cancellation is not available.');
|
|
11445
|
+
}
|
|
11446
|
+
const noiseCancellationSettings = settings?.audio.noise_cancellation;
|
|
11447
|
+
if (!noiseCancellationSettings ||
|
|
11448
|
+
noiseCancellationSettings.mode ===
|
|
11449
|
+
NoiseCancellationSettingsModeEnum.DISABLED) {
|
|
11450
|
+
throw new Error('Noise cancellation is disabled for this call type.');
|
|
11451
|
+
}
|
|
11452
|
+
try {
|
|
11453
|
+
this.noiseCancellation = noiseCancellation;
|
|
11454
|
+
// listen for change events and notify the SFU
|
|
11455
|
+
this.noiseCancellationChangeUnsubscribe = this.noiseCancellation.on('change', (enabled) => {
|
|
11456
|
+
if (enabled) {
|
|
11457
|
+
this.call.notifyNoiseCancellationStarting().catch((err) => {
|
|
11458
|
+
this.logger('warn', `notifyNoiseCancellationStart failed`, err);
|
|
11459
|
+
});
|
|
11460
|
+
}
|
|
11461
|
+
else {
|
|
11462
|
+
this.call.notifyNoiseCancellationStopped().catch((err) => {
|
|
11463
|
+
this.logger('warn', `notifyNoiseCancellationStop failed`, err);
|
|
11464
|
+
});
|
|
11465
|
+
}
|
|
11466
|
+
});
|
|
11467
|
+
this.noiseCancellationRegistration = this.registerFilter(noiseCancellation.toFilter());
|
|
11468
|
+
await this.noiseCancellationRegistration;
|
|
11469
|
+
// handles an edge case where a noise cancellation is enabled after
|
|
11470
|
+
// the participant as joined the call -> we immediately enable NC
|
|
11471
|
+
if (noiseCancellationSettings.mode ===
|
|
11472
|
+
NoiseCancellationSettingsModeEnum.AUTO_ON &&
|
|
11473
|
+
this.call.state.callingState === exports.CallingState.JOINED) {
|
|
11474
|
+
noiseCancellation.enable();
|
|
11475
|
+
}
|
|
11476
|
+
}
|
|
11477
|
+
catch (e) {
|
|
11478
|
+
this.logger('warn', 'Failed to enable noise cancellation', e);
|
|
11479
|
+
await this.disableNoiseCancellation().catch((err) => {
|
|
11480
|
+
this.logger('warn', 'Failed to disable noise cancellation', err);
|
|
11481
|
+
});
|
|
11482
|
+
}
|
|
11483
|
+
}
|
|
11484
|
+
/**
|
|
11485
|
+
* Disables noise cancellation for the microphone.
|
|
11486
|
+
*
|
|
11487
|
+
* Note: not supported in React Native.
|
|
11488
|
+
*/
|
|
11489
|
+
async disableNoiseCancellation() {
|
|
11490
|
+
if (isReactNative()) {
|
|
11491
|
+
throw new Error('Noise cancellation is not supported in React Native');
|
|
11492
|
+
}
|
|
11493
|
+
await this.noiseCancellationRegistration
|
|
11494
|
+
?.then((unregister) => unregister())
|
|
11495
|
+
.then(() => this.noiseCancellation?.disable())
|
|
11496
|
+
.then(() => this.noiseCancellationChangeUnsubscribe?.())
|
|
11497
|
+
.catch((err) => {
|
|
11498
|
+
this.logger('warn', 'Failed to unregister noise cancellation', err);
|
|
11499
|
+
});
|
|
11500
|
+
await this.call.notifyNoiseCancellationStopped();
|
|
11161
11501
|
}
|
|
11162
11502
|
getDevices() {
|
|
11163
11503
|
return getAudioDevices();
|
|
@@ -12184,6 +12524,26 @@ class Call {
|
|
|
12184
12524
|
this.logger('info', `stopPublish ${TrackType[trackType]}, stop tracks: ${stopTrack}`);
|
|
12185
12525
|
await this.publisher?.unpublishStream(trackType, stopTrack);
|
|
12186
12526
|
};
|
|
12527
|
+
/**
|
|
12528
|
+
* Notifies the SFU that a noise cancellation process has started.
|
|
12529
|
+
*
|
|
12530
|
+
* @internal
|
|
12531
|
+
*/
|
|
12532
|
+
this.notifyNoiseCancellationStarting = async () => {
|
|
12533
|
+
return this.sfuClient?.startNoiseCancellation().catch((err) => {
|
|
12534
|
+
this.logger('warn', 'Failed to notify start of noise cancellation', err);
|
|
12535
|
+
});
|
|
12536
|
+
};
|
|
12537
|
+
/**
|
|
12538
|
+
* Notifies the SFU that a noise cancellation process has stopped.
|
|
12539
|
+
*
|
|
12540
|
+
* @internal
|
|
12541
|
+
*/
|
|
12542
|
+
this.notifyNoiseCancellationStopped = async () => {
|
|
12543
|
+
return this.sfuClient?.stopNoiseCancellation().catch((err) => {
|
|
12544
|
+
this.logger('warn', 'Failed to notify stop of noise cancellation', err);
|
|
12545
|
+
});
|
|
12546
|
+
};
|
|
12187
12547
|
/**
|
|
12188
12548
|
* Update track subscription configuration for one or more participants.
|
|
12189
12549
|
* You have to create a subscription for each participant for all the different kinds of tracks you want to receive.
|
|
@@ -14501,7 +14861,7 @@ class StreamClient {
|
|
|
14501
14861
|
});
|
|
14502
14862
|
};
|
|
14503
14863
|
this.getUserAgent = () => {
|
|
14504
|
-
const version = "0.7.
|
|
14864
|
+
const version = "0.7.9" ;
|
|
14505
14865
|
return (this.userAgent ||
|
|
14506
14866
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
14507
14867
|
};
|
|
@@ -14997,6 +15357,8 @@ exports.InputMediaDeviceManager = InputMediaDeviceManager;
|
|
|
14997
15357
|
exports.InputMediaDeviceManagerState = InputMediaDeviceManagerState;
|
|
14998
15358
|
exports.MicrophoneManager = MicrophoneManager;
|
|
14999
15359
|
exports.MicrophoneManagerState = MicrophoneManagerState;
|
|
15360
|
+
exports.NoiseCancellationSettingsModeEnum = NoiseCancellationSettingsModeEnum;
|
|
15361
|
+
exports.NoiseCancellationSettingsRequestModeEnum = NoiseCancellationSettingsRequestModeEnum;
|
|
15000
15362
|
exports.OwnCapability = OwnCapability;
|
|
15001
15363
|
exports.RecordSettingsRequestModeEnum = RecordSettingsRequestModeEnum;
|
|
15002
15364
|
exports.RecordSettingsRequestQualityEnum = RecordSettingsRequestQualityEnum;
|