@webex/plugin-meetings 3.0.0-beta.21 → 3.0.0-beta.22

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.
@@ -24,6 +24,7 @@ import {
24
24
  } from '@webex/plugin-meetings/src/constants';
25
25
  import {ConnectionState, Event, Errors, ErrorType, RemoteTrackType} from '@webex/internal-media-core';
26
26
  import * as StatsAnalyzerModule from '@webex/plugin-meetings/src/statsAnalyzer';
27
+ import * as MuteStateModule from '@webex/plugin-meetings/src/meeting/muteState';
27
28
  import EventsScope from '@webex/plugin-meetings/src/common/events/events-scope';
28
29
  import Meetings, {CONSTANTS} from '@webex/plugin-meetings';
29
30
  import Meeting from '@webex/plugin-meetings/src/meeting';
@@ -1698,9 +1699,13 @@ describe('plugin-meetings', () => {
1698
1699
 
1699
1700
  it('skips canUpdateMedia() check on contentTracks.onended', () => {
1700
1701
  const {mediaProperties} = meeting;
1702
+ let registeredListener = null;
1701
1703
  const fakeTrack = {
1702
1704
  getSettings: sinon.stub().returns({}),
1703
1705
  onended: sinon.stub(),
1706
+ addEventListener: sinon.stub().callsFake((event, listener) => {
1707
+ registeredListener = listener;
1708
+ }),
1704
1709
  };
1705
1710
 
1706
1711
  sandbox.stub(mediaProperties, 'setLocalShareTrack');
@@ -1709,7 +1714,11 @@ describe('plugin-meetings', () => {
1709
1714
  sandbox.stub(meeting, 'stopShare').resolves(true);
1710
1715
  meeting.setLocalShareTrack(fakeTrack);
1711
1716
 
1712
- fakeTrack.onended();
1717
+ assert.calledOnce(fakeTrack.addEventListener);
1718
+ assert.calledWith(fakeTrack.addEventListener, 'ended', sinon.match.any);
1719
+ assert.isNotNull(registeredListener);
1720
+
1721
+ registeredListener();
1713
1722
 
1714
1723
  assert.calledWith(meeting.stopShare, {skipSignalingCheck: true});
1715
1724
  });
@@ -1743,12 +1752,11 @@ describe('plugin-meetings', () => {
1743
1752
  });
1744
1753
 
1745
1754
  it('handleShareTrackEnded triggers an event', () => {
1746
- const stream = 'stream';
1747
1755
  const {EVENT_TYPES} = CONSTANTS;
1748
1756
 
1749
1757
  sandbox.stub(meeting, 'stopShare').resolves(true);
1750
1758
 
1751
- meeting.handleShareTrackEnded(stream);
1759
+ meeting.handleShareTrackEnded();
1752
1760
 
1753
1761
  assert.calledWith(
1754
1762
  TriggerProxy.trigger,
@@ -1759,7 +1767,6 @@ describe('plugin-meetings', () => {
1759
1767
  },
1760
1768
  EVENT_TRIGGERS.MEETING_STOPPED_SHARING_LOCAL,
1761
1769
  {
1762
- stream,
1763
1770
  type: EVENT_TYPES.LOCAL_SHARE,
1764
1771
  }
1765
1772
  );
@@ -2127,6 +2134,7 @@ describe('plugin-meetings', () => {
2127
2134
  screenshareVideo: {
2128
2135
  id: 'fake share track',
2129
2136
  getSettings: sinon.stub().returns({}),
2137
+ addEventListener: sinon.stub()
2130
2138
  },
2131
2139
  };
2132
2140
 
@@ -2288,6 +2296,7 @@ describe('plugin-meetings', () => {
2288
2296
  screenshareVideo: {
2289
2297
  id: 'fake share track',
2290
2298
  getSettings: sinon.stub().returns({}),
2299
+ addEventListener: sinon.stub(),
2291
2300
  },
2292
2301
  };
2293
2302
 
@@ -3567,6 +3576,172 @@ describe('plugin-meetings', () => {
3567
3576
  }
3568
3577
  });
3569
3578
  });
3579
+ describe('Local tracks publishing', () => {
3580
+ let audioTrack;
3581
+ let videoTrack;
3582
+ let videoShareTrack;
3583
+ let createMuteStateStub;
3584
+
3585
+ beforeEach(() => {
3586
+ audioTrack = {
3587
+ id: 'audio track',
3588
+ getSettings: sinon.stub().returns({}),
3589
+ };
3590
+ videoTrack = {
3591
+ id: 'video track',
3592
+ getSettings: sinon.stub().returns({}),
3593
+ };
3594
+ videoShareTrack = {
3595
+ id: 'share track',
3596
+ addEventListener: sinon.stub(),
3597
+ removeEventListener: sinon.stub(),
3598
+ getSettings: sinon.stub().returns({}),
3599
+ };
3600
+ meeting.requestScreenShareFloor = sinon.stub().resolves({});
3601
+ meeting.releaseScreenShareFloor = sinon.stub().resolves({});
3602
+ meeting.mediaProperties.mediaDirection = {sendAudio: false, sendVideo: false, sendShare: false};
3603
+ meeting.mediaProperties.webrtcMediaConnection = {
3604
+ publishTrack: sinon.stub().resolves({}),
3605
+ unpublishTrack: sinon.stub().resolves({}),
3606
+ };
3607
+
3608
+ createMuteStateStub = sinon.stub(MuteStateModule, 'createMuteState').returns({id: 'fake mute state instance'});
3609
+ })
3610
+ describe('#publishTracks', () => {
3611
+ it('fails if there is no media connection', async () => {
3612
+ meeting.mediaProperties.webrtcMediaConnection = undefined;
3613
+ await assert.isRejected(meeting.publishTracks({audio: {id: 'some audio track'}}));
3614
+ });
3615
+
3616
+ const checkAudioPublished = () => {
3617
+ assert.calledWith(createMuteStateStub, 'audio', meeting, meeting.mediaProperties.mediaDirection);
3618
+ assert.calledWith(meeting.mediaProperties.webrtcMediaConnection.publishTrack, audioTrack, 'main');
3619
+ assert.equal(meeting.mediaProperties.audioTrack, audioTrack);
3620
+ assert.equal(meeting.mediaProperties.mediaDirection.sendAudio, true);
3621
+ }
3622
+
3623
+ const checkVideoPublished = () => {
3624
+ assert.calledWith(createMuteStateStub, 'video', meeting, meeting.mediaProperties.mediaDirection);
3625
+ assert.calledWith(meeting.mediaProperties.webrtcMediaConnection.publishTrack, videoTrack, 'main');
3626
+ assert.equal(meeting.mediaProperties.videoTrack, videoTrack);
3627
+ assert.equal(meeting.mediaProperties.mediaDirection.sendVideo, true);
3628
+ }
3629
+
3630
+ const checkScreenShareVideoPublished = () => {
3631
+ assert.calledOnce(meeting.requestScreenShareFloor);
3632
+ assert.calledWith(meeting.mediaProperties.webrtcMediaConnection.publishTrack, videoShareTrack, 'slides');
3633
+ assert.equal(meeting.mediaProperties.shareTrack, videoShareTrack);
3634
+ assert.equal(meeting.mediaProperties.mediaDirection.sendShare, true);
3635
+ }
3636
+
3637
+ it('requests screen share floor and publishes the screen share video track', async () => {
3638
+ await meeting.publishTracks({screenShare: {video: videoShareTrack}});
3639
+
3640
+ assert.calledOnce(meeting.mediaProperties.webrtcMediaConnection.publishTrack);
3641
+ checkScreenShareVideoPublished();
3642
+ });
3643
+
3644
+ it('creates MuteState instance and publishes the track for main audio', async () => {
3645
+ await meeting.publishTracks({microphone: audioTrack});
3646
+
3647
+ assert.calledOnce(createMuteStateStub);
3648
+ assert.calledOnce(meeting.mediaProperties.webrtcMediaConnection.publishTrack);
3649
+ checkAudioPublished();
3650
+ });
3651
+
3652
+ it('creates MuteState instance and publishes the track for main video', async () => {
3653
+ await meeting.publishTracks({camera: videoTrack});
3654
+
3655
+ assert.calledOnce(createMuteStateStub);
3656
+ assert.calledOnce(meeting.mediaProperties.webrtcMediaConnection.publishTrack);
3657
+ checkVideoPublished();
3658
+ });
3659
+
3660
+ it('publishes audio, video and screen share together', async () => {
3661
+ await meeting.publishTracks({
3662
+ microphone: audioTrack,
3663
+ camera: videoTrack,
3664
+ screenShare: {
3665
+ video: videoShareTrack,
3666
+ }
3667
+ });
3668
+
3669
+ assert.calledTwice(createMuteStateStub);
3670
+ assert.calledThrice(meeting.mediaProperties.webrtcMediaConnection.publishTrack);
3671
+ checkAudioPublished();
3672
+ checkVideoPublished();
3673
+ checkScreenShareVideoPublished();
3674
+ })
3675
+ });
3676
+
3677
+ describe('unpublishTracks', () => {
3678
+ beforeEach(async () => {
3679
+ await meeting.publishTracks({
3680
+ microphone: audioTrack,
3681
+ camera: videoTrack,
3682
+ screenShare: {video: videoShareTrack}
3683
+ });
3684
+ });
3685
+
3686
+ const checkAudioUnpublished = () => {
3687
+ assert.calledWith(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack, audioTrack, 'main');
3688
+
3689
+ assert.equal(meeting.mediaProperties.audioTrack, null);
3690
+ assert.equal(meeting.mediaProperties.mediaDirection.sendAudio, false);
3691
+ };
3692
+
3693
+ const checkVideoUnpublished = () => {
3694
+ assert.calledWith(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack, videoTrack, 'main');
3695
+
3696
+ assert.equal(meeting.mediaProperties.videoTrack, null);
3697
+ assert.equal(meeting.mediaProperties.mediaDirection.sendVideo, false);
3698
+ }
3699
+
3700
+ const checkScreenShareVideoUnpublished = () => {
3701
+ assert.calledWith(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack, videoShareTrack, 'slides');
3702
+
3703
+ assert.calledOnce(meeting.requestScreenShareFloor);
3704
+
3705
+ assert.equal(meeting.mediaProperties.shareTrack, null);
3706
+ assert.equal(meeting.mediaProperties.mediaDirection.sendShare, false);
3707
+ }
3708
+
3709
+ it('fails if there is no media connection', async () => {
3710
+ meeting.mediaProperties.webrtcMediaConnection = undefined;
3711
+ await assert.isRejected(meeting.unpublishTracks([audioTrack, videoTrack, videoShareTrack]));
3712
+ });
3713
+
3714
+ it('un-publishes the tracks correctly (all 3 together)', async () => {
3715
+ await meeting.unpublishTracks([audioTrack, videoTrack, videoShareTrack]);
3716
+
3717
+ assert.calledThrice(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack);
3718
+ checkAudioUnpublished();
3719
+ checkVideoUnpublished();
3720
+ checkScreenShareVideoUnpublished();
3721
+ });
3722
+
3723
+ it('un-publishes the audio track correctly', async () => {
3724
+ await meeting.unpublishTracks([audioTrack]);
3725
+
3726
+ assert.calledOnce(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack);
3727
+ checkAudioUnpublished();
3728
+ });
3729
+
3730
+ it('un-publishes the video track correctly', async () => {
3731
+ await meeting.unpublishTracks([videoTrack]);
3732
+
3733
+ assert.calledOnce(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack);
3734
+ checkVideoUnpublished();
3735
+ })
3736
+
3737
+ it('un-publishes the screen share video track correctly', async () => {
3738
+ await meeting.unpublishTracks([videoShareTrack]);
3739
+
3740
+ assert.calledOnce(meeting.mediaProperties.webrtcMediaConnection.unpublishTrack);
3741
+ checkScreenShareVideoUnpublished();
3742
+ })
3743
+ })
3744
+ });
3570
3745
  });
3571
3746
 
3572
3747
  describe('Public Event Triggers', () => {
@@ -3748,6 +3923,7 @@ describe('plugin-meetings', () => {
3748
3923
  });
3749
3924
  describe('#setLocalShareTrack', () => {
3750
3925
  it('should trigger a media:ready event with local share stream', () => {
3926
+ let registeredListener = null;
3751
3927
  const track = {
3752
3928
  getSettings: sinon.stub().returns({
3753
3929
  aspectRatio: '1.7',
@@ -3757,14 +3933,15 @@ describe('plugin-meetings', () => {
3757
3933
  displaySurface: true,
3758
3934
  cursor: true,
3759
3935
  }),
3936
+ addEventListener: sinon.stub().callsFake((event, listener) => {
3937
+ registeredListener = listener;
3938
+ }),
3760
3939
  };
3761
- const getVideoTracks = sinon.stub().returns([track]);
3762
3940
 
3763
3941
  meeting.mediaProperties.setLocalShareTrack = sinon.stub().returns(true);
3764
- meeting.mediaProperties.shareTrack = {getVideoTracks, getSettings: track.getSettings};
3765
3942
  meeting.stopShare = sinon.stub().resolves(true);
3766
3943
  meeting.mediaProperties.mediaDirection = {};
3767
- meeting.setLocalShareTrack(test1);
3944
+ meeting.setLocalShareTrack(track);
3768
3945
  assert.calledTwice(TriggerProxy.trigger);
3769
3946
  assert.calledWith(
3770
3947
  TriggerProxy.trigger,
@@ -3774,7 +3951,8 @@ describe('plugin-meetings', () => {
3774
3951
  );
3775
3952
  assert.calledOnce(meeting.mediaProperties.setLocalShareTrack);
3776
3953
  assert.equal(meeting.mediaProperties.localStream, undefined);
3777
- meeting.mediaProperties.shareTrack.onended();
3954
+ assert.isNotNull(registeredListener);
3955
+ registeredListener();
3778
3956
  assert.calledOnce(meeting.stopShare);
3779
3957
  });
3780
3958
  });
@@ -1,7 +1,7 @@
1
1
  import sinon from 'sinon';
2
2
  import {assert} from '@webex/test-helper-chai';
3
3
  import MeetingUtil from '@webex/plugin-meetings/src/meeting/util';
4
- import createMuteState from '@webex/plugin-meetings/src/meeting/muteState';
4
+ import {createMuteState} from '@webex/plugin-meetings/src/meeting/muteState';
5
5
  import Media from '@webex/plugin-meetings/src/media/index';
6
6
  import PermissionError from '@webex/plugin-meetings/src/common/errors/permission';
7
7
  import {AUDIO, VIDEO} from '@webex/plugin-meetings/src/constants';
@@ -1,110 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
- var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.MultistreamMedia = void 0;
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
12
- var _constants = require("../constants");
13
- var _muteState = _interopRequireDefault(require("../meeting/muteState"));
14
- /* eslint-disable import/prefer-default-export */
15
- /**
16
- * Class wrapping all the multistream specific APIs that need to be exposed at meeting level.
17
- *
18
- */
19
- var MultistreamMedia = /*#__PURE__*/function () {
20
- /**
21
- * Constructor
22
- * @param {Meeting} meeting
23
- */
24
- function MultistreamMedia(meeting) {
25
- (0, _classCallCheck2.default)(this, MultistreamMedia);
26
- (0, _defineProperty2.default)(this, "meeting", void 0);
27
- this.meeting = meeting;
28
- }
29
-
30
- // eslint-disable-next-line valid-jsdoc
31
- /**
32
- * throws if we don't have a media connection created
33
- */
34
- (0, _createClass2.default)(MultistreamMedia, [{
35
- key: "checkMediaConnection",
36
- value: function checkMediaConnection() {
37
- var _this$meeting, _this$meeting$mediaPr;
38
- if ((_this$meeting = this.meeting) !== null && _this$meeting !== void 0 && (_this$meeting$mediaPr = _this$meeting.mediaProperties) !== null && _this$meeting$mediaPr !== void 0 && _this$meeting$mediaPr.webrtcMediaConnection) {
39
- return;
40
- }
41
- throw new Error('Webrtc media connection is missing');
42
- }
43
-
44
- /**
45
- * Publishes a local track in the meeting
46
- *
47
- * @param {MediaStreamTrack} track
48
- * @returns {Promise}
49
- */
50
- }, {
51
- key: "publishTrack",
52
- value: function publishTrack(track) {
53
- this.checkMediaConnection();
54
-
55
- /* todo: for now we don't support screen share (waiting for server to support bundling, see SPARK-377812)
56
- for sharing:
57
- we have to call meeting.stopFloorRequest() before unpublishing a track
58
- we have to call meeting.share() after publishing a track
59
- */
60
-
61
- // todo: depending on how muting is done with Local tracks, this code here might need to change...
62
-
63
- if (track.kind === 'audio') {
64
- // @ts-ignore
65
- this.meeting.setLocalAudioTrack(track);
66
- this.meeting.mediaProperties.mediaDirection.sendAudio = true;
67
-
68
- // audio state could be undefined if you have not sent audio before
69
- this.meeting.audio = this.meeting.audio || (0, _muteState.default)(_constants.AUDIO, this.meeting, this.meeting.mediaProperties.mediaDirection);
70
- } else if (track.kind === 'video') {
71
- // @ts-ignore
72
- this.meeting.setLocalVideoTrack(track);
73
- this.meeting.mediaProperties.mediaDirection.sendVideo = true;
74
-
75
- // video state could be undefined if you have not sent video before
76
- this.meeting.video = this.meeting.video || (0, _muteState.default)(_constants.VIDEO, this.meeting, this.meeting.mediaProperties.mediaDirection);
77
- }
78
- return this.meeting.mediaProperties.webrtcMediaConnection.publishTrack(track);
79
- }
80
-
81
- /**
82
- * Unpublishes a local track in the meeting
83
- *
84
- * @param {MediaStreamTrack} track
85
- * @returns {Promise}
86
- */
87
- }, {
88
- key: "unpublishTrack",
89
- value: function unpublishTrack(track) {
90
- // todo: see todos in publishTrack() - they all apply here too:
91
- // screen sharing - SPARK-377812
92
- // muting etc
93
-
94
- if (track.kind === 'audio') {
95
- // @ts-ignore
96
- this.meeting.setLocalVideoTrack(null);
97
- this.meeting.mediaProperties.mediaDirection.sendAudio = false;
98
- } else if (track.kind === 'video') {
99
- // @ts-ignore
100
- this.meeting.setLocalAudioTrack(null);
101
- this.meeting.mediaProperties.mediaDirection.sendVideo = false;
102
- }
103
- this.checkMediaConnection();
104
- return this.meeting.mediaProperties.webrtcMediaConnection.unpublishTrack(track);
105
- }
106
- }]);
107
- return MultistreamMedia;
108
- }();
109
- exports.MultistreamMedia = MultistreamMedia;
110
- //# sourceMappingURL=multistreamMedia.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["MultistreamMedia","meeting","mediaProperties","webrtcMediaConnection","Error","track","checkMediaConnection","kind","setLocalAudioTrack","mediaDirection","sendAudio","audio","createMuteState","AUDIO","setLocalVideoTrack","sendVideo","video","VIDEO","publishTrack","unpublishTrack"],"sources":["multistreamMedia.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport {AUDIO, VIDEO} from '../constants';\nimport createMuteState from '../meeting/muteState';\nimport Meeting from '../meeting';\n\n/**\n * Class wrapping all the multistream specific APIs that need to be exposed at meeting level.\n *\n */\nexport class MultistreamMedia {\n private meeting: Meeting;\n\n /**\n * Constructor\n * @param {Meeting} meeting\n */\n constructor(meeting: Meeting) {\n this.meeting = meeting;\n }\n\n // eslint-disable-next-line valid-jsdoc\n /**\n * throws if we don't have a media connection created\n */\n private checkMediaConnection() {\n if (this.meeting?.mediaProperties?.webrtcMediaConnection) {\n return;\n }\n throw new Error('Webrtc media connection is missing');\n }\n\n /**\n * Publishes a local track in the meeting\n *\n * @param {MediaStreamTrack} track\n * @returns {Promise}\n */\n publishTrack(track: MediaStreamTrack): Promise<void> {\n this.checkMediaConnection();\n\n /* todo: for now we don't support screen share (waiting for server to support bundling, see SPARK-377812)\n for sharing:\n we have to call meeting.stopFloorRequest() before unpublishing a track\n we have to call meeting.share() after publishing a track\n */\n\n // todo: depending on how muting is done with Local tracks, this code here might need to change...\n\n if (track.kind === 'audio') {\n // @ts-ignore\n this.meeting.setLocalAudioTrack(track);\n this.meeting.mediaProperties.mediaDirection.sendAudio = true;\n\n // audio state could be undefined if you have not sent audio before\n this.meeting.audio =\n this.meeting.audio ||\n createMuteState(AUDIO, this.meeting, this.meeting.mediaProperties.mediaDirection);\n } else if (track.kind === 'video') {\n // @ts-ignore\n this.meeting.setLocalVideoTrack(track);\n this.meeting.mediaProperties.mediaDirection.sendVideo = true;\n\n // video state could be undefined if you have not sent video before\n this.meeting.video =\n this.meeting.video ||\n createMuteState(VIDEO, this.meeting, this.meeting.mediaProperties.mediaDirection);\n }\n\n return this.meeting.mediaProperties.webrtcMediaConnection.publishTrack(track);\n }\n\n /**\n * Unpublishes a local track in the meeting\n *\n * @param {MediaStreamTrack} track\n * @returns {Promise}\n */\n unpublishTrack(track: MediaStreamTrack): Promise<void> {\n // todo: see todos in publishTrack() - they all apply here too:\n // screen sharing - SPARK-377812\n // muting etc\n\n if (track.kind === 'audio') {\n // @ts-ignore\n this.meeting.setLocalVideoTrack(null);\n this.meeting.mediaProperties.mediaDirection.sendAudio = false;\n } else if (track.kind === 'video') {\n // @ts-ignore\n this.meeting.setLocalAudioTrack(null);\n this.meeting.mediaProperties.mediaDirection.sendVideo = false;\n }\n this.checkMediaConnection();\n\n return this.meeting.mediaProperties.webrtcMediaConnection.unpublishTrack(track);\n }\n}\n"],"mappings":";;;;;;;;;;;AAEA;AACA;AAHA;AAMA;AACA;AACA;AACA;AAHA,IAIaA,gBAAgB;EAG3B;AACF;AACA;AACA;EACE,0BAAYC,OAAgB,EAAE;IAAA;IAAA;IAC5B,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;;EAEA;EACA;AACF;AACA;EAFE;IAAA;IAAA,OAGA,gCAA+B;MAAA;MAC7B,qBAAI,IAAI,CAACA,OAAO,mEAAZ,cAAcC,eAAe,kDAA7B,sBAA+BC,qBAAqB,EAAE;QACxD;MACF;MACA,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;IACvD;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,sBAAaC,KAAuB,EAAiB;MACnD,IAAI,CAACC,oBAAoB,EAAE;;MAE3B;AACJ;AACA;AACA;AACA;;MAEI;;MAEA,IAAID,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B;QACA,IAAI,CAACN,OAAO,CAACO,kBAAkB,CAACH,KAAK,CAAC;QACtC,IAAI,CAACJ,OAAO,CAACC,eAAe,CAACO,cAAc,CAACC,SAAS,GAAG,IAAI;;QAE5D;QACA,IAAI,CAACT,OAAO,CAACU,KAAK,GAChB,IAAI,CAACV,OAAO,CAACU,KAAK,IAClB,IAAAC,kBAAe,EAACC,gBAAK,EAAE,IAAI,CAACZ,OAAO,EAAE,IAAI,CAACA,OAAO,CAACC,eAAe,CAACO,cAAc,CAAC;MACrF,CAAC,MAAM,IAAIJ,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QACjC;QACA,IAAI,CAACN,OAAO,CAACa,kBAAkB,CAACT,KAAK,CAAC;QACtC,IAAI,CAACJ,OAAO,CAACC,eAAe,CAACO,cAAc,CAACM,SAAS,GAAG,IAAI;;QAE5D;QACA,IAAI,CAACd,OAAO,CAACe,KAAK,GAChB,IAAI,CAACf,OAAO,CAACe,KAAK,IAClB,IAAAJ,kBAAe,EAACK,gBAAK,EAAE,IAAI,CAAChB,OAAO,EAAE,IAAI,CAACA,OAAO,CAACC,eAAe,CAACO,cAAc,CAAC;MACrF;MAEA,OAAO,IAAI,CAACR,OAAO,CAACC,eAAe,CAACC,qBAAqB,CAACe,YAAY,CAACb,KAAK,CAAC;IAC/E;;IAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,wBAAeA,KAAuB,EAAiB;MACrD;MACA;MACA;;MAEA,IAAIA,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B;QACA,IAAI,CAACN,OAAO,CAACa,kBAAkB,CAAC,IAAI,CAAC;QACrC,IAAI,CAACb,OAAO,CAACC,eAAe,CAACO,cAAc,CAACC,SAAS,GAAG,KAAK;MAC/D,CAAC,MAAM,IAAIL,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QACjC;QACA,IAAI,CAACN,OAAO,CAACO,kBAAkB,CAAC,IAAI,CAAC;QACrC,IAAI,CAACP,OAAO,CAACC,eAAe,CAACO,cAAc,CAACM,SAAS,GAAG,KAAK;MAC/D;MACA,IAAI,CAACT,oBAAoB,EAAE;MAE3B,OAAO,IAAI,CAACL,OAAO,CAACC,eAAe,CAACC,qBAAqB,CAACgB,cAAc,CAACd,KAAK,CAAC;IACjF;EAAC;EAAA;AAAA;AAAA"}
@@ -1,97 +0,0 @@
1
- /* eslint-disable import/prefer-default-export */
2
-
3
- import {AUDIO, VIDEO} from '../constants';
4
- import createMuteState from '../meeting/muteState';
5
- import Meeting from '../meeting';
6
-
7
- /**
8
- * Class wrapping all the multistream specific APIs that need to be exposed at meeting level.
9
- *
10
- */
11
- export class MultistreamMedia {
12
- private meeting: Meeting;
13
-
14
- /**
15
- * Constructor
16
- * @param {Meeting} meeting
17
- */
18
- constructor(meeting: Meeting) {
19
- this.meeting = meeting;
20
- }
21
-
22
- // eslint-disable-next-line valid-jsdoc
23
- /**
24
- * throws if we don't have a media connection created
25
- */
26
- private checkMediaConnection() {
27
- if (this.meeting?.mediaProperties?.webrtcMediaConnection) {
28
- return;
29
- }
30
- throw new Error('Webrtc media connection is missing');
31
- }
32
-
33
- /**
34
- * Publishes a local track in the meeting
35
- *
36
- * @param {MediaStreamTrack} track
37
- * @returns {Promise}
38
- */
39
- publishTrack(track: MediaStreamTrack): Promise<void> {
40
- this.checkMediaConnection();
41
-
42
- /* todo: for now we don't support screen share (waiting for server to support bundling, see SPARK-377812)
43
- for sharing:
44
- we have to call meeting.stopFloorRequest() before unpublishing a track
45
- we have to call meeting.share() after publishing a track
46
- */
47
-
48
- // todo: depending on how muting is done with Local tracks, this code here might need to change...
49
-
50
- if (track.kind === 'audio') {
51
- // @ts-ignore
52
- this.meeting.setLocalAudioTrack(track);
53
- this.meeting.mediaProperties.mediaDirection.sendAudio = true;
54
-
55
- // audio state could be undefined if you have not sent audio before
56
- this.meeting.audio =
57
- this.meeting.audio ||
58
- createMuteState(AUDIO, this.meeting, this.meeting.mediaProperties.mediaDirection);
59
- } else if (track.kind === 'video') {
60
- // @ts-ignore
61
- this.meeting.setLocalVideoTrack(track);
62
- this.meeting.mediaProperties.mediaDirection.sendVideo = true;
63
-
64
- // video state could be undefined if you have not sent video before
65
- this.meeting.video =
66
- this.meeting.video ||
67
- createMuteState(VIDEO, this.meeting, this.meeting.mediaProperties.mediaDirection);
68
- }
69
-
70
- return this.meeting.mediaProperties.webrtcMediaConnection.publishTrack(track);
71
- }
72
-
73
- /**
74
- * Unpublishes a local track in the meeting
75
- *
76
- * @param {MediaStreamTrack} track
77
- * @returns {Promise}
78
- */
79
- unpublishTrack(track: MediaStreamTrack): Promise<void> {
80
- // todo: see todos in publishTrack() - they all apply here too:
81
- // screen sharing - SPARK-377812
82
- // muting etc
83
-
84
- if (track.kind === 'audio') {
85
- // @ts-ignore
86
- this.meeting.setLocalVideoTrack(null);
87
- this.meeting.mediaProperties.mediaDirection.sendAudio = false;
88
- } else if (track.kind === 'video') {
89
- // @ts-ignore
90
- this.meeting.setLocalAudioTrack(null);
91
- this.meeting.mediaProperties.mediaDirection.sendVideo = false;
92
- }
93
- this.checkMediaConnection();
94
-
95
- return this.meeting.mediaProperties.webrtcMediaConnection.unpublishTrack(track);
96
- }
97
- }