@stream-io/video-client 0.1.11 → 0.2.1
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 +18 -0
- package/dist/index.browser.es.js +254 -28
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +254 -28
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +254 -28
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +27 -6
- package/dist/src/events/internal.d.ts +6 -0
- package/dist/src/gen/coordinator/index.d.ts +133 -0
- package/dist/src/gen/video/sfu/event/events.d.ts +31 -1
- package/dist/src/gen/video/sfu/models/models.d.ts +34 -0
- package/dist/src/store/CallState.d.ts +7 -0
- package/dist/src/types.d.ts +16 -2
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/Call.ts +60 -10
- package/src/events/call.ts +1 -0
- package/src/events/callEventHandlers.ts +2 -0
- package/src/events/internal.ts +13 -0
- package/src/gen/coordinator/index.ts +133 -0
- package/src/gen/video/sfu/event/events.ts +131 -0
- package/src/gen/video/sfu/models/models.ts +122 -1
- package/src/rtc/Dispatcher.ts +1 -0
- package/src/rtc/flows/join.ts +2 -8
- package/src/sorting/__tests__/participant-data.ts +4 -1
- package/src/sorting/participants.ts +7 -5
- package/src/store/CallState.ts +43 -2
- package/src/store/__tests__/CallState.test.ts +133 -78
- package/src/types.ts +18 -2
package/dist/index.cjs.js
CHANGED
|
@@ -70,6 +70,7 @@ const OwnCapability = {
|
|
|
70
70
|
JOIN_CALL: 'join-call',
|
|
71
71
|
JOIN_ENDED_CALL: 'join-ended-call',
|
|
72
72
|
MUTE_USERS: 'mute-users',
|
|
73
|
+
PIN_FOR_EVERYONE: 'pin-for-everyone',
|
|
73
74
|
READ_CALL: 'read-call',
|
|
74
75
|
REMOVE_CALL_MEMBER: 'remove-call-member',
|
|
75
76
|
SCREENSHARE: 'screenshare',
|
|
@@ -994,10 +995,17 @@ class CallState$Type extends runtime.MessageType {
|
|
|
994
995
|
kind: 'message',
|
|
995
996
|
T: () => ParticipantCount,
|
|
996
997
|
},
|
|
998
|
+
{
|
|
999
|
+
no: 4,
|
|
1000
|
+
name: 'pins',
|
|
1001
|
+
kind: 'message',
|
|
1002
|
+
repeat: 1 /*RepeatType.PACKED*/,
|
|
1003
|
+
T: () => Pin,
|
|
1004
|
+
},
|
|
997
1005
|
]);
|
|
998
1006
|
}
|
|
999
1007
|
create(value) {
|
|
1000
|
-
const message = { participants: [] };
|
|
1008
|
+
const message = { participants: [], pins: [] };
|
|
1001
1009
|
globalThis.Object.defineProperty(message, runtime.MESSAGE_TYPE, {
|
|
1002
1010
|
enumerable: false,
|
|
1003
1011
|
value: this,
|
|
@@ -1020,6 +1028,9 @@ class CallState$Type extends runtime.MessageType {
|
|
|
1020
1028
|
case /* stream.video.sfu.models.ParticipantCount participant_count */ 3:
|
|
1021
1029
|
message.participantCount = ParticipantCount.internalBinaryRead(reader, reader.uint32(), options, message.participantCount);
|
|
1022
1030
|
break;
|
|
1031
|
+
case /* repeated stream.video.sfu.models.Pin pins */ 4:
|
|
1032
|
+
message.pins.push(Pin.internalBinaryRead(reader, reader.uint32(), options));
|
|
1033
|
+
break;
|
|
1023
1034
|
default:
|
|
1024
1035
|
let u = options.readUnknownField;
|
|
1025
1036
|
if (u === 'throw')
|
|
@@ -1041,6 +1052,9 @@ class CallState$Type extends runtime.MessageType {
|
|
|
1041
1052
|
/* stream.video.sfu.models.ParticipantCount participant_count = 3; */
|
|
1042
1053
|
if (message.participantCount)
|
|
1043
1054
|
ParticipantCount.internalBinaryWrite(message.participantCount, writer.tag(3, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
1055
|
+
/* repeated stream.video.sfu.models.Pin pins = 4; */
|
|
1056
|
+
for (let i = 0; i < message.pins.length; i++)
|
|
1057
|
+
Pin.internalBinaryWrite(message.pins[i], writer.tag(4, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
1044
1058
|
let u = options.writeUnknownFields;
|
|
1045
1059
|
if (u !== false)
|
|
1046
1060
|
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -1109,6 +1123,63 @@ class ParticipantCount$Type extends runtime.MessageType {
|
|
|
1109
1123
|
*/
|
|
1110
1124
|
const ParticipantCount = new ParticipantCount$Type();
|
|
1111
1125
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
1126
|
+
class Pin$Type extends runtime.MessageType {
|
|
1127
|
+
constructor() {
|
|
1128
|
+
super('stream.video.sfu.models.Pin', [
|
|
1129
|
+
{ no: 1, name: 'user_id', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
|
|
1130
|
+
{ no: 2, name: 'session_id', kind: 'scalar', T: 9 /*ScalarType.STRING*/ },
|
|
1131
|
+
]);
|
|
1132
|
+
}
|
|
1133
|
+
create(value) {
|
|
1134
|
+
const message = { userId: '', sessionId: '' };
|
|
1135
|
+
globalThis.Object.defineProperty(message, runtime.MESSAGE_TYPE, {
|
|
1136
|
+
enumerable: false,
|
|
1137
|
+
value: this,
|
|
1138
|
+
});
|
|
1139
|
+
if (value !== undefined)
|
|
1140
|
+
runtime.reflectionMergePartial(this, message, value);
|
|
1141
|
+
return message;
|
|
1142
|
+
}
|
|
1143
|
+
internalBinaryRead(reader, length, options, target) {
|
|
1144
|
+
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
|
1145
|
+
while (reader.pos < end) {
|
|
1146
|
+
let [fieldNo, wireType] = reader.tag();
|
|
1147
|
+
switch (fieldNo) {
|
|
1148
|
+
case /* string user_id */ 1:
|
|
1149
|
+
message.userId = reader.string();
|
|
1150
|
+
break;
|
|
1151
|
+
case /* string session_id */ 2:
|
|
1152
|
+
message.sessionId = reader.string();
|
|
1153
|
+
break;
|
|
1154
|
+
default:
|
|
1155
|
+
let u = options.readUnknownField;
|
|
1156
|
+
if (u === 'throw')
|
|
1157
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
1158
|
+
let d = reader.skip(wireType);
|
|
1159
|
+
if (u !== false)
|
|
1160
|
+
(u === true ? runtime.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return message;
|
|
1164
|
+
}
|
|
1165
|
+
internalBinaryWrite(message, writer, options) {
|
|
1166
|
+
/* string user_id = 1; */
|
|
1167
|
+
if (message.userId !== '')
|
|
1168
|
+
writer.tag(1, runtime.WireType.LengthDelimited).string(message.userId);
|
|
1169
|
+
/* string session_id = 2; */
|
|
1170
|
+
if (message.sessionId !== '')
|
|
1171
|
+
writer.tag(2, runtime.WireType.LengthDelimited).string(message.sessionId);
|
|
1172
|
+
let u = options.writeUnknownFields;
|
|
1173
|
+
if (u !== false)
|
|
1174
|
+
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
1175
|
+
return writer;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* @generated MessageType for protobuf message stream.video.sfu.models.Pin
|
|
1180
|
+
*/
|
|
1181
|
+
const Pin = new Pin$Type();
|
|
1182
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
1112
1183
|
class Participant$Type extends runtime.MessageType {
|
|
1113
1184
|
constructor() {
|
|
1114
1185
|
super('stream.video.sfu.models.Participant', [
|
|
@@ -2423,6 +2494,7 @@ var models = /*#__PURE__*/Object.freeze({
|
|
|
2423
2494
|
Participant: Participant,
|
|
2424
2495
|
ParticipantCount: ParticipantCount,
|
|
2425
2496
|
get PeerType () { return PeerType; },
|
|
2497
|
+
Pin: Pin,
|
|
2426
2498
|
Sdk: Sdk,
|
|
2427
2499
|
get SdkType () { return SdkType; },
|
|
2428
2500
|
StreamQuality: StreamQuality,
|
|
@@ -3514,6 +3586,13 @@ class SfuEvent$Type extends runtime.MessageType {
|
|
|
3514
3586
|
oneof: 'eventPayload',
|
|
3515
3587
|
T: () => ICERestart,
|
|
3516
3588
|
},
|
|
3589
|
+
{
|
|
3590
|
+
no: 22,
|
|
3591
|
+
name: 'pins_updated',
|
|
3592
|
+
kind: 'message',
|
|
3593
|
+
oneof: 'eventPayload',
|
|
3594
|
+
T: () => PinsChanged,
|
|
3595
|
+
},
|
|
3517
3596
|
]);
|
|
3518
3597
|
}
|
|
3519
3598
|
create(value) {
|
|
@@ -3633,6 +3712,12 @@ class SfuEvent$Type extends runtime.MessageType {
|
|
|
3633
3712
|
iceRestart: ICERestart.internalBinaryRead(reader, reader.uint32(), options, message.eventPayload.iceRestart),
|
|
3634
3713
|
};
|
|
3635
3714
|
break;
|
|
3715
|
+
case /* stream.video.sfu.event.PinsChanged pins_updated */ 22:
|
|
3716
|
+
message.eventPayload = {
|
|
3717
|
+
oneofKind: 'pinsUpdated',
|
|
3718
|
+
pinsUpdated: PinsChanged.internalBinaryRead(reader, reader.uint32(), options, message.eventPayload.pinsUpdated),
|
|
3719
|
+
};
|
|
3720
|
+
break;
|
|
3636
3721
|
default:
|
|
3637
3722
|
let u = options.readUnknownField;
|
|
3638
3723
|
if (u === 'throw')
|
|
@@ -3696,6 +3781,9 @@ class SfuEvent$Type extends runtime.MessageType {
|
|
|
3696
3781
|
/* stream.video.sfu.event.ICERestart ice_restart = 21; */
|
|
3697
3782
|
if (message.eventPayload.oneofKind === 'iceRestart')
|
|
3698
3783
|
ICERestart.internalBinaryWrite(message.eventPayload.iceRestart, writer.tag(21, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
3784
|
+
/* stream.video.sfu.event.PinsChanged pins_updated = 22; */
|
|
3785
|
+
if (message.eventPayload.oneofKind === 'pinsUpdated')
|
|
3786
|
+
PinsChanged.internalBinaryWrite(message.eventPayload.pinsUpdated, writer.tag(22, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
3699
3787
|
let u = options.writeUnknownFields;
|
|
3700
3788
|
if (u !== false)
|
|
3701
3789
|
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
@@ -3707,6 +3795,62 @@ class SfuEvent$Type extends runtime.MessageType {
|
|
|
3707
3795
|
*/
|
|
3708
3796
|
const SfuEvent = new SfuEvent$Type();
|
|
3709
3797
|
// @generated message type with reflection information, may provide speed optimized methods
|
|
3798
|
+
class PinsChanged$Type extends runtime.MessageType {
|
|
3799
|
+
constructor() {
|
|
3800
|
+
super('stream.video.sfu.event.PinsChanged', [
|
|
3801
|
+
{
|
|
3802
|
+
no: 1,
|
|
3803
|
+
name: 'pins',
|
|
3804
|
+
kind: 'message',
|
|
3805
|
+
repeat: 1 /*RepeatType.PACKED*/,
|
|
3806
|
+
T: () => Pin,
|
|
3807
|
+
},
|
|
3808
|
+
]);
|
|
3809
|
+
}
|
|
3810
|
+
create(value) {
|
|
3811
|
+
const message = { pins: [] };
|
|
3812
|
+
globalThis.Object.defineProperty(message, runtime.MESSAGE_TYPE, {
|
|
3813
|
+
enumerable: false,
|
|
3814
|
+
value: this,
|
|
3815
|
+
});
|
|
3816
|
+
if (value !== undefined)
|
|
3817
|
+
runtime.reflectionMergePartial(this, message, value);
|
|
3818
|
+
return message;
|
|
3819
|
+
}
|
|
3820
|
+
internalBinaryRead(reader, length, options, target) {
|
|
3821
|
+
let message = target !== null && target !== void 0 ? target : this.create(), end = reader.pos + length;
|
|
3822
|
+
while (reader.pos < end) {
|
|
3823
|
+
let [fieldNo, wireType] = reader.tag();
|
|
3824
|
+
switch (fieldNo) {
|
|
3825
|
+
case /* repeated stream.video.sfu.models.Pin pins */ 1:
|
|
3826
|
+
message.pins.push(Pin.internalBinaryRead(reader, reader.uint32(), options));
|
|
3827
|
+
break;
|
|
3828
|
+
default:
|
|
3829
|
+
let u = options.readUnknownField;
|
|
3830
|
+
if (u === 'throw')
|
|
3831
|
+
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
|
3832
|
+
let d = reader.skip(wireType);
|
|
3833
|
+
if (u !== false)
|
|
3834
|
+
(u === true ? runtime.UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3837
|
+
return message;
|
|
3838
|
+
}
|
|
3839
|
+
internalBinaryWrite(message, writer, options) {
|
|
3840
|
+
/* repeated stream.video.sfu.models.Pin pins = 1; */
|
|
3841
|
+
for (let i = 0; i < message.pins.length; i++)
|
|
3842
|
+
Pin.internalBinaryWrite(message.pins[i], writer.tag(1, runtime.WireType.LengthDelimited).fork(), options).join();
|
|
3843
|
+
let u = options.writeUnknownFields;
|
|
3844
|
+
if (u !== false)
|
|
3845
|
+
(u == true ? runtime.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
|
3846
|
+
return writer;
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
/**
|
|
3850
|
+
* @generated MessageType for protobuf message stream.video.sfu.event.PinsChanged
|
|
3851
|
+
*/
|
|
3852
|
+
const PinsChanged = new PinsChanged$Type();
|
|
3853
|
+
// @generated message type with reflection information, may provide speed optimized methods
|
|
3710
3854
|
class Error$Type extends runtime.MessageType {
|
|
3711
3855
|
constructor() {
|
|
3712
3856
|
super('stream.video.sfu.event.Error', [
|
|
@@ -5569,6 +5713,7 @@ var events = /*#__PURE__*/Object.freeze({
|
|
|
5569
5713
|
Migration: Migration,
|
|
5570
5714
|
ParticipantJoined: ParticipantJoined,
|
|
5571
5715
|
ParticipantLeft: ParticipantLeft,
|
|
5716
|
+
PinsChanged: PinsChanged,
|
|
5572
5717
|
PublisherAnswer: PublisherAnswer,
|
|
5573
5718
|
SfuEvent: SfuEvent,
|
|
5574
5719
|
SfuRequest: SfuRequest,
|
|
@@ -6061,6 +6206,7 @@ const sfuEventKinds = {
|
|
|
6061
6206
|
callGrantsUpdated: undefined,
|
|
6062
6207
|
goAway: undefined,
|
|
6063
6208
|
iceRestart: undefined,
|
|
6209
|
+
pinsUpdated: undefined,
|
|
6064
6210
|
};
|
|
6065
6211
|
const isSfuEvent = (eventName) => {
|
|
6066
6212
|
return Object.prototype.hasOwnProperty.call(sfuEventKinds, eventName);
|
|
@@ -7713,15 +7859,19 @@ const publishingAudio = (a, b) => {
|
|
|
7713
7859
|
* @param b the second participant.
|
|
7714
7860
|
*/
|
|
7715
7861
|
const pinned = (a, b) => {
|
|
7716
|
-
if (a.
|
|
7717
|
-
if (a.
|
|
7862
|
+
if (a.pin && b.pin) {
|
|
7863
|
+
if (!a.pin.isLocalPin && b.pin.isLocalPin)
|
|
7864
|
+
return -1;
|
|
7865
|
+
if (a.pin.isLocalPin && !b.pin.isLocalPin)
|
|
7866
|
+
return 1;
|
|
7867
|
+
if (a.pin.pinnedAt > b.pin.pinnedAt)
|
|
7718
7868
|
return -1;
|
|
7719
|
-
if (a.pinnedAt < b.pinnedAt)
|
|
7869
|
+
if (a.pin.pinnedAt < b.pin.pinnedAt)
|
|
7720
7870
|
return 1;
|
|
7721
7871
|
}
|
|
7722
|
-
if (a.
|
|
7872
|
+
if (a.pin && !b.pin)
|
|
7723
7873
|
return -1;
|
|
7724
|
-
if (!a.
|
|
7874
|
+
if (!a.pin && b.pin)
|
|
7725
7875
|
return 1;
|
|
7726
7876
|
return 0;
|
|
7727
7877
|
};
|
|
@@ -8120,11 +8270,39 @@ class CallState {
|
|
|
8120
8270
|
return p;
|
|
8121
8271
|
}));
|
|
8122
8272
|
};
|
|
8273
|
+
/**
|
|
8274
|
+
* Updates the participant pinned state with server side pinning data.
|
|
8275
|
+
*
|
|
8276
|
+
* @param pins the latest pins from the server.
|
|
8277
|
+
*/
|
|
8278
|
+
this.setServerSidePins = (pins) => {
|
|
8279
|
+
const pinsLookup = pins.reduce((lookup, pin) => {
|
|
8280
|
+
lookup[pin.sessionId] = Date.now();
|
|
8281
|
+
return lookup;
|
|
8282
|
+
}, {});
|
|
8283
|
+
return this.setParticipants((participants) => participants.map((participant) => {
|
|
8284
|
+
const serverSidePinnedAt = pinsLookup[participant.sessionId];
|
|
8285
|
+
// the participant is newly pinned
|
|
8286
|
+
if (serverSidePinnedAt) {
|
|
8287
|
+
return Object.assign(Object.assign({}, participant), { pin: {
|
|
8288
|
+
isLocalPin: false,
|
|
8289
|
+
pinnedAt: serverSidePinnedAt,
|
|
8290
|
+
} });
|
|
8291
|
+
}
|
|
8292
|
+
// the participant is no longer pinned server side
|
|
8293
|
+
// we need to reset the pin
|
|
8294
|
+
if (participant.pin && !participant.pin.isLocalPin) {
|
|
8295
|
+
return Object.assign(Object.assign({}, participant), { pin: undefined });
|
|
8296
|
+
}
|
|
8297
|
+
// no changes to be applied
|
|
8298
|
+
return participant;
|
|
8299
|
+
}));
|
|
8300
|
+
};
|
|
8123
8301
|
this.logger = getLogger(['call-state']);
|
|
8124
8302
|
this.participants$ = this.participantsSubject.pipe(operators.map((ps) => ps.sort(this.sortParticipantsBy)));
|
|
8125
8303
|
this.localParticipant$ = this.participants$.pipe(operators.map((participants) => participants.find(isStreamVideoLocalParticipant)));
|
|
8126
8304
|
this.remoteParticipants$ = this.participants$.pipe(operators.map((participants) => participants.filter((p) => !p.isLocalParticipant)));
|
|
8127
|
-
this.pinnedParticipants$ = this.participants$.pipe(operators.map((participants) => participants.filter((p) => p.
|
|
8305
|
+
this.pinnedParticipants$ = this.participants$.pipe(operators.map((participants) => participants.filter((p) => !!p.pin)));
|
|
8128
8306
|
this.dominantSpeaker$ = this.participants$.pipe(operators.map((participants) => participants.find((p) => p.isDominantSpeaker)));
|
|
8129
8307
|
this.hasOngoingScreenShare$ = this.participants$.pipe(operators.map((participants) => {
|
|
8130
8308
|
return participants.some((p) => p.publishedTracks.includes(TrackType.SCREEN_SHARE));
|
|
@@ -8307,6 +8485,7 @@ const watchCallEnded = (call) => {
|
|
|
8307
8485
|
if (call.state.callingState === exports.CallingState.RINGING ||
|
|
8308
8486
|
call.state.callingState === exports.CallingState.JOINED ||
|
|
8309
8487
|
call.state.callingState === exports.CallingState.JOINING) {
|
|
8488
|
+
call.state.setMetadata(event.call);
|
|
8310
8489
|
yield call.leave();
|
|
8311
8490
|
}
|
|
8312
8491
|
});
|
|
@@ -8437,6 +8616,18 @@ const watchSfuErrorReports = (dispatcher) => {
|
|
|
8437
8616
|
});
|
|
8438
8617
|
});
|
|
8439
8618
|
};
|
|
8619
|
+
/**
|
|
8620
|
+
* Watches for `pinsUpdated` events and updates the pinned state of participants
|
|
8621
|
+
* in the call.
|
|
8622
|
+
*/
|
|
8623
|
+
const watchPinsUpdated = (state) => {
|
|
8624
|
+
return function onPinsUpdated(e) {
|
|
8625
|
+
if (e.eventPayload.oneofKind !== 'pinsUpdated')
|
|
8626
|
+
return;
|
|
8627
|
+
const { pins } = e.eventPayload.pinsUpdated;
|
|
8628
|
+
state.setServerSidePins(pins);
|
|
8629
|
+
};
|
|
8630
|
+
};
|
|
8440
8631
|
|
|
8441
8632
|
/**
|
|
8442
8633
|
* Watches for `call.member_added` events.
|
|
@@ -8815,6 +9006,7 @@ const registerEventHandlers = (call, state, dispatcher) => {
|
|
|
8815
9006
|
watchAudioLevelChanged(dispatcher, state),
|
|
8816
9007
|
watchDominantSpeakerChanged(dispatcher, state),
|
|
8817
9008
|
call.on('callGrantsUpdated', watchCallGrantsUpdated(state)),
|
|
9009
|
+
call.on('pinsUpdated', watchPinsUpdated(state)),
|
|
8818
9010
|
];
|
|
8819
9011
|
Object.keys(coordinatorEvents).forEach((event) => {
|
|
8820
9012
|
const eventName = event;
|
|
@@ -8920,14 +9112,8 @@ const getCascadingModeParams = () => {
|
|
|
8920
9112
|
const reconcileParticipantLocalState = (target, source) => {
|
|
8921
9113
|
if (!source)
|
|
8922
9114
|
return target;
|
|
8923
|
-
|
|
8924
|
-
target
|
|
8925
|
-
target.screenShareStream = source.screenShareStream;
|
|
8926
|
-
target.videoDimension = source.videoDimension;
|
|
8927
|
-
target.screenShareDimension = source.screenShareDimension;
|
|
8928
|
-
target.pinnedAt = source.pinnedAt;
|
|
8929
|
-
target.reaction = source.reaction;
|
|
8930
|
-
target.viewportVisibilityState = source.viewportVisibilityState;
|
|
9115
|
+
// copy everything from source to target
|
|
9116
|
+
Object.assign(target, source);
|
|
8931
9117
|
if (isStreamVideoLocalParticipant(source) &&
|
|
8932
9118
|
isStreamVideoLocalParticipant(target)) {
|
|
8933
9119
|
target.audioDeviceId = source.audioDeviceId;
|
|
@@ -9610,7 +9796,7 @@ class Call {
|
|
|
9610
9796
|
* @returns a promise which resolves once the call join-flow has finished.
|
|
9611
9797
|
*/
|
|
9612
9798
|
this.join = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
9613
|
-
var _e, _f;
|
|
9799
|
+
var _e, _f, _g;
|
|
9614
9800
|
const callingState = this.state.callingState;
|
|
9615
9801
|
if ([exports.CallingState.JOINED, exports.CallingState.JOINING].includes(callingState)) {
|
|
9616
9802
|
this.logger('warn', 'Join method called twice, you should only call this once');
|
|
@@ -9858,6 +10044,7 @@ class Call {
|
|
|
9858
10044
|
const startedAt = (callState === null || callState === void 0 ? void 0 : callState.startedAt)
|
|
9859
10045
|
? Timestamp.toDate(callState.startedAt)
|
|
9860
10046
|
: new Date();
|
|
10047
|
+
const pins = (_g = callState === null || callState === void 0 ? void 0 : callState.pins) !== null && _g !== void 0 ? _g : [];
|
|
9861
10048
|
this.state.setParticipants(() => {
|
|
9862
10049
|
const participantLookup = this.state.getParticipantLookupBySessionId();
|
|
9863
10050
|
return currentParticipants.map((p) => {
|
|
@@ -9865,7 +10052,7 @@ class Call {
|
|
|
9865
10052
|
isLocalParticipant: p.sessionId === sfuClient.sessionId,
|
|
9866
10053
|
viewportVisibilityState: exports.VisibilityState.UNKNOWN,
|
|
9867
10054
|
});
|
|
9868
|
-
// We need to preserve
|
|
10055
|
+
// We need to preserve the local state of the participant
|
|
9869
10056
|
// (e.g. videoDimension, visibilityState, pinnedAt, etc.)
|
|
9870
10057
|
// as it doesn't exist on the server.
|
|
9871
10058
|
const existingParticipant = participantLookup[p.sessionId];
|
|
@@ -9875,6 +10062,7 @@ class Call {
|
|
|
9875
10062
|
this.state.setParticipantCount((participantCount === null || participantCount === void 0 ? void 0 : participantCount.total) || 0);
|
|
9876
10063
|
this.state.setAnonymousParticipantCount((participantCount === null || participantCount === void 0 ? void 0 : participantCount.anonymous) || 0);
|
|
9877
10064
|
this.state.setStartedAt(startedAt);
|
|
10065
|
+
this.state.setServerSidePins(pins);
|
|
9878
10066
|
this.reconnectAttempts = 0; // reset the reconnect attempts counter
|
|
9879
10067
|
this.state.setCallingState(exports.CallingState.JOINED);
|
|
9880
10068
|
// 3. once we have the "joinResponse", and possibly reconciled the local state
|
|
@@ -9999,9 +10187,9 @@ class Call {
|
|
|
9999
10187
|
* @param trackType the track type to stop publishing.
|
|
10000
10188
|
*/
|
|
10001
10189
|
this.stopPublish = (trackType) => __awaiter(this, void 0, void 0, function* () {
|
|
10002
|
-
var
|
|
10190
|
+
var _h;
|
|
10003
10191
|
this.logger('info', `stopPublish ${TrackType[trackType]}`);
|
|
10004
|
-
yield ((
|
|
10192
|
+
yield ((_h = this.publisher) === null || _h === void 0 ? void 0 : _h.unpublishStream(trackType));
|
|
10005
10193
|
});
|
|
10006
10194
|
/**
|
|
10007
10195
|
* Update track subscription configuration for one or more participants.
|
|
@@ -10089,6 +10277,8 @@ class Call {
|
|
|
10089
10277
|
* @param deviceId the selected device, `undefined` means the user wants to use the system's default audio output
|
|
10090
10278
|
*/
|
|
10091
10279
|
this.setAudioOutputDevice = (deviceId) => {
|
|
10280
|
+
if (!this.sfuClient)
|
|
10281
|
+
return;
|
|
10092
10282
|
this.state.updateParticipant(this.sfuClient.sessionId, {
|
|
10093
10283
|
audioOutputDeviceId: deviceId,
|
|
10094
10284
|
});
|
|
@@ -10102,6 +10292,8 @@ class Call {
|
|
|
10102
10292
|
* @param deviceId the selected device, pass `undefined` to clear the device selection
|
|
10103
10293
|
*/
|
|
10104
10294
|
this.setAudioDevice = (deviceId) => {
|
|
10295
|
+
if (!this.sfuClient)
|
|
10296
|
+
return;
|
|
10105
10297
|
this.state.updateParticipant(this.sfuClient.sessionId, {
|
|
10106
10298
|
audioDeviceId: deviceId,
|
|
10107
10299
|
});
|
|
@@ -10114,6 +10306,8 @@ class Call {
|
|
|
10114
10306
|
* @param deviceId the selected device, pass `undefined` to clear the device selection
|
|
10115
10307
|
*/
|
|
10116
10308
|
this.setVideoDevice = (deviceId) => {
|
|
10309
|
+
if (!this.sfuClient)
|
|
10310
|
+
return;
|
|
10117
10311
|
this.state.updateParticipant(this.sfuClient.sessionId, {
|
|
10118
10312
|
videoDeviceId: deviceId,
|
|
10119
10313
|
});
|
|
@@ -10142,8 +10336,8 @@ class Call {
|
|
|
10142
10336
|
* @returns
|
|
10143
10337
|
*/
|
|
10144
10338
|
this.updatePublishQuality = (enabledRids) => __awaiter(this, void 0, void 0, function* () {
|
|
10145
|
-
var
|
|
10146
|
-
return (
|
|
10339
|
+
var _j;
|
|
10340
|
+
return (_j = this.publisher) === null || _j === void 0 ? void 0 : _j.updateVideoPublishQuality(enabledRids);
|
|
10147
10341
|
});
|
|
10148
10342
|
this.assertCallJoined = () => {
|
|
10149
10343
|
return new Promise((resolve) => {
|
|
@@ -10347,16 +10541,48 @@ class Call {
|
|
|
10347
10541
|
return this.streamClient.post(`${this.streamClientBasePath}/mark_ended`);
|
|
10348
10542
|
});
|
|
10349
10543
|
/**
|
|
10350
|
-
*
|
|
10351
|
-
*
|
|
10352
|
-
* @param
|
|
10353
|
-
|
|
10544
|
+
* Pins the given session to the top of the participants list.
|
|
10545
|
+
*
|
|
10546
|
+
* @param sessionId the sessionId to pin.
|
|
10547
|
+
*/
|
|
10548
|
+
this.pin = (sessionId) => {
|
|
10549
|
+
this.state.updateParticipant(sessionId, {
|
|
10550
|
+
pin: {
|
|
10551
|
+
isLocalPin: true,
|
|
10552
|
+
pinnedAt: Date.now(),
|
|
10553
|
+
},
|
|
10554
|
+
});
|
|
10555
|
+
};
|
|
10556
|
+
/**
|
|
10557
|
+
* Unpins the given session from the top of the participants list.
|
|
10558
|
+
*
|
|
10559
|
+
* @param sessionId the sessionId to unpin.
|
|
10354
10560
|
*/
|
|
10355
|
-
this.
|
|
10561
|
+
this.unpin = (sessionId) => {
|
|
10356
10562
|
this.state.updateParticipant(sessionId, {
|
|
10357
|
-
|
|
10563
|
+
pin: undefined,
|
|
10358
10564
|
});
|
|
10359
10565
|
};
|
|
10566
|
+
/**
|
|
10567
|
+
* Pins the given session to the top of the participants list for everyone
|
|
10568
|
+
* in the call.
|
|
10569
|
+
* You can execute this method only if you have the `pin-for-everyone` capability.
|
|
10570
|
+
*
|
|
10571
|
+
* @param request the request object.
|
|
10572
|
+
*/
|
|
10573
|
+
this.pinForEveryone = (request) => __awaiter(this, void 0, void 0, function* () {
|
|
10574
|
+
return this.streamClient.post(`${this.streamClientBasePath}/pin`, request);
|
|
10575
|
+
});
|
|
10576
|
+
/**
|
|
10577
|
+
* Unpins the given session from the top of the participants list for everyone
|
|
10578
|
+
* in the call.
|
|
10579
|
+
* You can execute this method only if you have the `pin-for-everyone` capability.
|
|
10580
|
+
*
|
|
10581
|
+
* @param request the request object.
|
|
10582
|
+
*/
|
|
10583
|
+
this.unpinForEveryone = (request) => __awaiter(this, void 0, void 0, function* () {
|
|
10584
|
+
return this.streamClient.post(`${this.streamClientBasePath}/unpin`, request);
|
|
10585
|
+
});
|
|
10360
10586
|
/**
|
|
10361
10587
|
* Query call members with filter query. The result won't be stored in call state.
|
|
10362
10588
|
* @param request
|
|
@@ -11675,7 +11901,7 @@ class WSConnectionFallback {
|
|
|
11675
11901
|
}
|
|
11676
11902
|
}
|
|
11677
11903
|
|
|
11678
|
-
const version = '0.1
|
|
11904
|
+
const version = '0.2.1';
|
|
11679
11905
|
|
|
11680
11906
|
const logger = getLogger(['location']);
|
|
11681
11907
|
const HINT_URL = `https://hint.stream-io-video.com/`;
|