@defcomm/meetingsdk 0.2.8 → 0.3.0
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/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +71 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1431,26 +1431,15 @@ var SFUClient = class {
|
|
|
1431
1431
|
if (!this.screenTransceiver || !this.screenSender) {
|
|
1432
1432
|
throw new Error("Screen transceiver is not initialized");
|
|
1433
1433
|
}
|
|
1434
|
+
const existing = this.screenStream;
|
|
1434
1435
|
const existingTrack = this.screenSender.track;
|
|
1435
|
-
if (
|
|
1436
|
-
return
|
|
1436
|
+
if (existing || existingTrack && existingTrack.readyState === "live") {
|
|
1437
|
+
return existing;
|
|
1437
1438
|
}
|
|
1438
|
-
const generation = ++this.screenShareGeneration;
|
|
1439
1439
|
try {
|
|
1440
1440
|
await this.screenSender.replaceTrack(null);
|
|
1441
|
-
} catch
|
|
1442
|
-
console.warn("[SFU] Failed to clear previous screen track", err);
|
|
1443
|
-
}
|
|
1444
|
-
if (this.screenStream) {
|
|
1445
|
-
for (const track of this.screenStream.getTracks()) {
|
|
1446
|
-
try {
|
|
1447
|
-
track.onended = null;
|
|
1448
|
-
track.stop();
|
|
1449
|
-
} catch {
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1441
|
+
} catch {
|
|
1452
1442
|
}
|
|
1453
|
-
this.screenStream = null;
|
|
1454
1443
|
this.screenTransceiver.direction = "inactive";
|
|
1455
1444
|
const screenStream = await navigator.mediaDevices.getDisplayMedia({
|
|
1456
1445
|
video: true,
|
|
@@ -1461,6 +1450,7 @@ var SFUClient = class {
|
|
|
1461
1450
|
screenStream.getTracks().forEach((track) => track.stop());
|
|
1462
1451
|
throw new Error("Screen share returned no video track");
|
|
1463
1452
|
}
|
|
1453
|
+
const generation = ++this.screenShareGeneration;
|
|
1464
1454
|
this.screenStream = screenStream;
|
|
1465
1455
|
try {
|
|
1466
1456
|
await this.screenSender.replaceTrack(screenTrack);
|
|
@@ -1468,20 +1458,16 @@ var SFUClient = class {
|
|
|
1468
1458
|
this.send({
|
|
1469
1459
|
type: "start_screen_share"
|
|
1470
1460
|
});
|
|
1471
|
-
await new Promise((resolve) => {
|
|
1472
|
-
queueMicrotask(resolve);
|
|
1473
|
-
});
|
|
1474
1461
|
const offer = await this.publisher.createOffer();
|
|
1475
1462
|
await this.publisher.setLocalDescription(offer);
|
|
1476
1463
|
const localDescription = this.publisher.localDescription;
|
|
1477
1464
|
if (!localDescription?.sdp) {
|
|
1478
1465
|
throw new Error("Publisher did not produce a valid screen-share SDP");
|
|
1479
1466
|
}
|
|
1480
|
-
const revision = ++this.publisherRevision;
|
|
1481
1467
|
this.send({
|
|
1482
1468
|
type: "publish_offer",
|
|
1483
1469
|
payload: {
|
|
1484
|
-
revision,
|
|
1470
|
+
revision: ++this.publisherRevision,
|
|
1485
1471
|
sdp: localDescription.sdp
|
|
1486
1472
|
}
|
|
1487
1473
|
});
|
|
@@ -1491,28 +1477,26 @@ var SFUClient = class {
|
|
|
1491
1477
|
}
|
|
1492
1478
|
void this.stopScreenShare();
|
|
1493
1479
|
};
|
|
1494
|
-
return screenStream;
|
|
1480
|
+
return this.screenStream;
|
|
1495
1481
|
} catch (error) {
|
|
1496
|
-
|
|
1482
|
+
try {
|
|
1483
|
+
await this.screenSender.replaceTrack(null);
|
|
1484
|
+
} catch {
|
|
1485
|
+
}
|
|
1486
|
+
this.screenTransceiver.direction = "inactive";
|
|
1487
|
+
screenTrack.onended = null;
|
|
1488
|
+
screenStream.getTracks().forEach((track) => {
|
|
1497
1489
|
try {
|
|
1498
|
-
|
|
1490
|
+
track.stop();
|
|
1499
1491
|
} catch {
|
|
1500
1492
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
} catch {
|
|
1507
|
-
}
|
|
1493
|
+
});
|
|
1494
|
+
this.screenStream = null;
|
|
1495
|
+
try {
|
|
1496
|
+
this.send({
|
|
1497
|
+
type: "stop_screen_share"
|
|
1508
1498
|
});
|
|
1509
|
-
|
|
1510
|
-
try {
|
|
1511
|
-
this.send({
|
|
1512
|
-
type: "stop_screen_share"
|
|
1513
|
-
});
|
|
1514
|
-
} catch {
|
|
1515
|
-
}
|
|
1499
|
+
} catch {
|
|
1516
1500
|
}
|
|
1517
1501
|
throw error;
|
|
1518
1502
|
}
|
|
@@ -1520,32 +1504,52 @@ var SFUClient = class {
|
|
|
1520
1504
|
async stopScreenShare() {
|
|
1521
1505
|
const stream = this.screenStream;
|
|
1522
1506
|
const senderTrack = this.screenSender?.track || null;
|
|
1523
|
-
if (!stream && !senderTrack)
|
|
1507
|
+
if (!stream && !senderTrack) {
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1524
1510
|
++this.screenShareGeneration;
|
|
1525
|
-
if (senderTrack)
|
|
1511
|
+
if (senderTrack) {
|
|
1512
|
+
senderTrack.onended = null;
|
|
1513
|
+
}
|
|
1526
1514
|
try {
|
|
1527
1515
|
await this.screenSender?.replaceTrack(null);
|
|
1528
1516
|
} catch (error) {
|
|
1529
1517
|
this.onError(error);
|
|
1530
1518
|
}
|
|
1531
|
-
if (this.screenTransceiver)
|
|
1519
|
+
if (this.screenTransceiver) {
|
|
1520
|
+
this.screenTransceiver.direction = "inactive";
|
|
1521
|
+
}
|
|
1532
1522
|
try {
|
|
1533
|
-
|
|
1534
|
-
|
|
1523
|
+
if (this.publisher) {
|
|
1524
|
+
const offer = await this.publisher.createOffer();
|
|
1535
1525
|
await this.publisher.setLocalDescription(offer);
|
|
1536
|
-
this.
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1526
|
+
const localDescription = this.publisher.localDescription;
|
|
1527
|
+
if (localDescription?.sdp) {
|
|
1528
|
+
this.send({
|
|
1529
|
+
type: "publish_offer",
|
|
1530
|
+
payload: {
|
|
1531
|
+
revision: ++this.publisherRevision,
|
|
1532
|
+
sdp: localDescription.sdp
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1540
1536
|
}
|
|
1541
1537
|
} catch (error) {
|
|
1542
1538
|
this.onError(error);
|
|
1543
1539
|
}
|
|
1544
|
-
this.send({
|
|
1545
|
-
|
|
1540
|
+
this.send({
|
|
1541
|
+
type: "stop_screen_share"
|
|
1542
|
+
});
|
|
1543
|
+
stream?.getTracks().forEach((track) => {
|
|
1544
|
+
try {
|
|
1545
|
+
track.stop();
|
|
1546
|
+
} catch {
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1546
1549
|
this.screenStream = null;
|
|
1547
|
-
if (this.currentParticipantId)
|
|
1550
|
+
if (this.currentParticipantId) {
|
|
1548
1551
|
this.onScreenShareStopped(this.currentParticipantId);
|
|
1552
|
+
}
|
|
1549
1553
|
}
|
|
1550
1554
|
muteAudio(muted) {
|
|
1551
1555
|
this.desiredAudioMuted = muted;
|
|
@@ -1651,7 +1655,9 @@ var SFUClient = class {
|
|
|
1651
1655
|
sendReaction(reaction) {
|
|
1652
1656
|
this.send({
|
|
1653
1657
|
type: "send_reaction",
|
|
1654
|
-
|
|
1658
|
+
payload: {
|
|
1659
|
+
emoji: reaction
|
|
1660
|
+
}
|
|
1655
1661
|
});
|
|
1656
1662
|
}
|
|
1657
1663
|
removeRemoteParticipant(participantId) {
|
|
@@ -2545,21 +2551,23 @@ var VideoSDKCore = class {
|
|
|
2545
2551
|
throw err;
|
|
2546
2552
|
}
|
|
2547
2553
|
}
|
|
2548
|
-
stopScreenShare() {
|
|
2549
|
-
if (!this.
|
|
2554
|
+
async stopScreenShare() {
|
|
2555
|
+
if (!this.sfuClient) {
|
|
2550
2556
|
return;
|
|
2551
2557
|
}
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2558
|
+
try {
|
|
2559
|
+
await this.sfuClient.stopScreenShare();
|
|
2560
|
+
} finally {
|
|
2561
|
+
this.screenStream = null;
|
|
2562
|
+
this.isScreenSharing = false;
|
|
2563
|
+
this.state.updateLocalParticipant({
|
|
2564
|
+
media: {
|
|
2565
|
+
isScreenSharing: false,
|
|
2566
|
+
screenStream: null,
|
|
2567
|
+
screenTrack: void 0
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2563
2571
|
}
|
|
2564
2572
|
// RECORDING
|
|
2565
2573
|
async startRecording() {
|