@defcomm/meetingsdk 0.3.0 → 0.3.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/dist/index.mjs CHANGED
@@ -1431,16 +1431,9 @@ 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;
1435
- const existingTrack = this.screenSender.track;
1436
- if (existing || existingTrack && existingTrack.readyState === "live") {
1437
- return existing;
1438
- }
1439
- try {
1440
- await this.screenSender.replaceTrack(null);
1441
- } catch {
1434
+ if (this.screenStream) {
1435
+ return this.screenStream;
1442
1436
  }
1443
- this.screenTransceiver.direction = "inactive";
1444
1437
  const screenStream = await navigator.mediaDevices.getDisplayMedia({
1445
1438
  video: true,
1446
1439
  audio: false
@@ -1450,33 +1443,29 @@ var SFUClient = class {
1450
1443
  screenStream.getTracks().forEach((track) => track.stop());
1451
1444
  throw new Error("Screen share returned no video track");
1452
1445
  }
1453
- const generation = ++this.screenShareGeneration;
1454
1446
  this.screenStream = screenStream;
1455
1447
  try {
1456
1448
  await this.screenSender.replaceTrack(screenTrack);
1457
1449
  this.screenTransceiver.direction = "sendonly";
1458
- this.send({
1459
- type: "start_screen_share"
1460
- });
1461
1450
  const offer = await this.publisher.createOffer();
1462
1451
  await this.publisher.setLocalDescription(offer);
1463
- const localDescription = this.publisher.localDescription;
1464
- if (!localDescription?.sdp) {
1465
- throw new Error("Publisher did not produce a valid screen-share SDP");
1466
- }
1467
1452
  this.send({
1468
1453
  type: "publish_offer",
1469
1454
  payload: {
1470
1455
  revision: ++this.publisherRevision,
1471
- sdp: localDescription.sdp
1456
+ sdp: offer.sdp
1472
1457
  }
1473
1458
  });
1459
+ this.send({ type: "start_screen_share" });
1474
1460
  screenTrack.onended = () => {
1475
- if (generation !== this.screenShareGeneration) {
1476
- return;
1477
- }
1478
1461
  void this.stopScreenShare();
1479
1462
  };
1463
+ console.info("[publisher] Screen track attached", {
1464
+ screenTrackId: screenTrack.id,
1465
+ cameraTrackId: this.videoSender?.track?.id,
1466
+ screenMid: this.screenTransceiver.mid,
1467
+ cameraMid: this.cameraTransceiver?.mid
1468
+ });
1480
1469
  return this.screenStream;
1481
1470
  } catch (error) {
1482
1471
  try {
@@ -1484,33 +1473,19 @@ var SFUClient = class {
1484
1473
  } catch {
1485
1474
  }
1486
1475
  this.screenTransceiver.direction = "inactive";
1487
- screenTrack.onended = null;
1488
- screenStream.getTracks().forEach((track) => {
1489
- try {
1490
- track.stop();
1491
- } catch {
1492
- }
1493
- });
1476
+ screenStream.getTracks().forEach((track) => track.stop());
1494
1477
  this.screenStream = null;
1495
1478
  try {
1496
- this.send({
1497
- type: "stop_screen_share"
1498
- });
1479
+ this.send({ type: "stop_screen_share" });
1499
1480
  } catch {
1500
1481
  }
1501
1482
  throw error;
1502
1483
  }
1503
1484
  }
1504
1485
  async stopScreenShare() {
1505
- const stream = this.screenStream;
1506
- const senderTrack = this.screenSender?.track || null;
1507
- if (!stream && !senderTrack) {
1508
- return;
1509
- }
1510
- ++this.screenShareGeneration;
1511
- if (senderTrack) {
1512
- senderTrack.onended = null;
1513
- }
1486
+ if (!this.screenStream && !this.screenSender?.track) return;
1487
+ const screenTrack = this.screenSender?.track || null;
1488
+ if (screenTrack) screenTrack.onended = null;
1514
1489
  try {
1515
1490
  await this.screenSender?.replaceTrack(null);
1516
1491
  } catch (error) {
@@ -1519,33 +1494,23 @@ var SFUClient = class {
1519
1494
  if (this.screenTransceiver) {
1520
1495
  this.screenTransceiver.direction = "inactive";
1521
1496
  }
1497
+ this.send({ type: "stop_screen_share" });
1522
1498
  try {
1523
- if (this.publisher) {
1524
- const offer = await this.publisher.createOffer();
1499
+ const offer = await this.publisher?.createOffer();
1500
+ if (offer && this.publisher) {
1525
1501
  await this.publisher.setLocalDescription(offer);
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
- }
1502
+ this.send({
1503
+ type: "publish_offer",
1504
+ payload: {
1505
+ revision: ++this.publisherRevision,
1506
+ sdp: offer.sdp
1507
+ }
1508
+ });
1536
1509
  }
1537
1510
  } catch (error) {
1538
1511
  this.onError(error);
1539
1512
  }
1540
- this.send({
1541
- type: "stop_screen_share"
1542
- });
1543
- stream?.getTracks().forEach((track) => {
1544
- try {
1545
- track.stop();
1546
- } catch {
1547
- }
1548
- });
1513
+ this.screenStream?.getTracks().forEach((track) => track.stop());
1549
1514
  this.screenStream = null;
1550
1515
  if (this.currentParticipantId) {
1551
1516
  this.onScreenShareStopped(this.currentParticipantId);
@@ -2374,7 +2339,9 @@ var VideoSDKCore = class {
2374
2339
  client.setLocalStream(this.localStream);
2375
2340
  await client.getToken(roomId, {
2376
2341
  displayName: name,
2377
- participantId: this.myId
2342
+ participantId: this.myId,
2343
+ audioMuted: this.state.localParticipant?.media?.micEnabled,
2344
+ videoMuted: this.state.localParticipant?.media?.camEnabled
2378
2345
  });
2379
2346
  }
2380
2347
  // SFU STATE