twilio-video 2.25.0 → 2.26.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +124 -1
  2. package/README.md +1 -1
  3. package/dist/twilio-video.js +1488 -1140
  4. package/dist/twilio-video.min.js +21 -21
  5. package/es5/media/track/localaudiotrack.js +28 -7
  6. package/es5/media/track/localaudiotrack.js.map +1 -1
  7. package/es5/media/track/localmediatrack.js +29 -0
  8. package/es5/media/track/localmediatrack.js.map +1 -1
  9. package/es5/media/track/localvideotrack.js +31 -10
  10. package/es5/media/track/localvideotrack.js.map +1 -1
  11. package/es5/media/track/sender.js +39 -1
  12. package/es5/media/track/sender.js.map +1 -1
  13. package/es5/room.js +50 -1
  14. package/es5/room.js.map +1 -1
  15. package/es5/transceiver.js +3 -3
  16. package/es5/transceiver.js.map +1 -1
  17. package/es5/twilioconnection.js +3 -0
  18. package/es5/twilioconnection.js.map +1 -1
  19. package/es5/webrtc/getstats.js +79 -64
  20. package/es5/webrtc/getstats.js.map +1 -1
  21. package/es5/webrtc/getusermedia.js +1 -1
  22. package/es5/webrtc/getusermedia.js.map +1 -1
  23. package/es5/webrtc/index.js.map +1 -1
  24. package/es5/webrtc/rtcpeerconnection/chrome.js +339 -286
  25. package/es5/webrtc/rtcpeerconnection/chrome.js.map +1 -1
  26. package/es5/webrtc/rtcpeerconnection/firefox.js +225 -179
  27. package/es5/webrtc/rtcpeerconnection/firefox.js.map +1 -1
  28. package/es5/webrtc/rtcpeerconnection/index.js.map +1 -1
  29. package/es5/webrtc/rtcpeerconnection/safari.js +276 -236
  30. package/es5/webrtc/rtcpeerconnection/safari.js.map +1 -1
  31. package/es5/webrtc/rtcrtpsender.js +12 -9
  32. package/es5/webrtc/rtcrtpsender.js.map +1 -1
  33. package/es5/webrtc/rtcsessiondescription/chrome.js +29 -22
  34. package/es5/webrtc/rtcsessiondescription/chrome.js.map +1 -1
  35. package/es5/webrtc/rtcsessiondescription/index.js.map +1 -1
  36. package/es5/webrtc/util/index.js +32 -15
  37. package/es5/webrtc/util/index.js.map +1 -1
  38. package/es5/webrtc/util/latch.js +83 -82
  39. package/es5/webrtc/util/latch.js.map +1 -1
  40. package/es5/webrtc/util/sdp.js +12 -19
  41. package/es5/webrtc/util/sdp.js.map +1 -1
  42. package/lib/media/track/localaudiotrack.js +30 -8
  43. package/lib/media/track/localmediatrack.js +29 -0
  44. package/lib/media/track/localvideotrack.js +33 -10
  45. package/lib/media/track/sender.js +42 -1
  46. package/lib/room.js +41 -1
  47. package/lib/transceiver.js +3 -3
  48. package/lib/twilioconnection.js +4 -0
  49. package/lib/webrtc/getstats.js +157 -175
  50. package/lib/webrtc/getusermedia.js +1 -2
  51. package/lib/webrtc/index.js +1 -1
  52. package/lib/webrtc/rtcpeerconnection/chrome.js +284 -316
  53. package/lib/webrtc/rtcpeerconnection/firefox.js +173 -197
  54. package/lib/webrtc/rtcpeerconnection/index.js +1 -1
  55. package/lib/webrtc/rtcpeerconnection/safari.js +228 -256
  56. package/lib/webrtc/rtcrtpsender.js +10 -8
  57. package/lib/webrtc/rtcsessiondescription/chrome.js +24 -24
  58. package/lib/webrtc/rtcsessiondescription/index.js +1 -1
  59. package/lib/webrtc/util/index.js +26 -33
  60. package/lib/webrtc/util/latch.js +78 -83
  61. package/lib/webrtc/util/sdp.js +32 -41
  62. package/package.json +2 -2
  63. package/tsdef/AudioTrack.d.ts +2 -13
  64. package/tsdef/LocalAudioTrack.d.ts +3 -0
  65. package/tsdef/LocalVideoTrack.d.ts +3 -0
  66. package/tsdef/MediaTrack.d.ts +16 -0
  67. package/tsdef/Room.d.ts +1 -0
  68. package/tsdef/VideoTrack.d.ts +2 -12
  69. package/tsdef/index.d.ts +4 -3
  70. package/tsdef/twilio-video-tests.ts +3 -0
  71. package/es5/webrtc/util/eventtarget.js +0 -34
  72. package/es5/webrtc/util/eventtarget.js.map +0 -1
  73. package/lib/webrtc/util/eventtarget.js +0 -39
package/CHANGELOG.md CHANGED
@@ -2,6 +2,129 @@ The Twilio Programmable Video SDKs use [Semantic Versioning](http://www.semver.o
2
2
 
3
3
  **Version 1.x reached End of Life on September 8th, 2021.** See the changelog entry [here](https://www.twilio.com/changelog/end-of-life-complete-for-unsupported-versions-of-the-programmable-video-sdk). Support for the 1.x version ended on December 4th, 2020.
4
4
 
5
+ 2.26.1 (January 31, 2023)
6
+ =========================
7
+
8
+ Bug Fixes
9
+ ---------
10
+
11
+ - Fixed a bug that manifests on Chrome versions 112+ where `Room.getStats()` rejects the returned Promise due to a
12
+ TypeError caused by trying to read from the now-removed `RTCMediaStreamTrackStats`. Instead, the SDK now reads from
13
+ the `RTCMediaSourceStats`. (VIDEO-12411)
14
+ - Fixed an error in the type definition for the `attach()` method of `AudioTrack` and `VideoTrack`. (VIDEO-12242)
15
+ - Fixed an error in the type definition for `createLocalAudioTrack()`. (VIDEO-12383)
16
+
17
+ 2.26.0 (December 14, 2022)
18
+ ==========================
19
+
20
+ New Features
21
+ ------------
22
+
23
+ - The [`LocalAudioTrack`](https://sdk.twilio.com/js/video/releases/2.26.0/docs/LocalAudioTrack.html) and
24
+ [`LocalVideoTrack`](https://sdk.twilio.com/js/video/releases/2.26.0/docs/LocalVideoTrack.html) classes now provide a
25
+ new boolean property called `isMuted`, which lets you know if the audio or video source is currently providing raw media
26
+ samples. The classes also emit `muted` and `unmuted` events if the value of `isMuted` toggles. The application can use
27
+ these APIs to detect temporary loss of microphone or camera to other applications (ex: an incoming phone call on an iOS device),
28
+ and update the user interface accordingly. (VIDEO-11360)
29
+
30
+ - The `Room` class provides a new method called [refreshInactiveMedia](https://sdk.twilio.com/js/video/releases/2.26.0/docs/Room.html#refreshInactiveMedia),
31
+ which restarts any muted local media Tracks, and plays any inadvertently paused HTMLMediaElements that are attached to
32
+ local and remote media Tracks. This is useful especially on iOS devices, where sometimes your application's media may
33
+ not recover after an incoming phone call. You can use this method in conjunction with the local media Track's `isMuted`
34
+ property described previously to recover local and remote media after an incoming phone call as shown below. (VIDEO-11360)
35
+
36
+ ### Vanilla JS
37
+
38
+ #### html
39
+
40
+ ```html
41
+ <button id="refresh-inactive-media" disabled>Refresh Inactive Media</button>
42
+ ```
43
+
44
+ #### js
45
+
46
+ ```js
47
+ const { connect } = require('twilio-video');
48
+
49
+ const room = await connect('token', { name: 'my-cool-room' });
50
+
51
+ const $refreshInactiveMedia = document.getElementById('refresh-inactive-media');
52
+ $refreshInactiveMedia.onclick = () => room.refreshInactiveMedia();
53
+
54
+ const [{ track: localAudioTrack }] = [...room.localParticipant.audioTracks.values()];
55
+ const [{ track: localVideoTrack }] = [...room.localParticipant.videoTracks.values()];
56
+
57
+ const isLocalAudioOrVideoMuted = () => {
58
+ return localAudioTrack.isMuted || localVideoTrack.isMuted;
59
+ }
60
+
61
+ const onLocalMediaMutedChanged = () => {
62
+ $refreshInactiveMedia.disabled = !isLocalAudioOrVideoMuted();
63
+ };
64
+
65
+ [localAudioTrack, localVideoTrack].forEach(localMediaTrack => {
66
+ ['muted', 'unmuted'].forEach(event => {
67
+ localMediaTrack.on(event, onLocalMediaMutedChanged);
68
+ });
69
+ });
70
+ ```
71
+
72
+ ### React
73
+
74
+ #### src/hooks/useLocalMediaMuted.js
75
+
76
+ ```js
77
+ import { useEffect, useState } from 'react';
78
+
79
+ export default function useLocalMediaMuted(localMediaTrack) {
80
+ const [isMuted, setIsMuted] = useState(localMediaTrack?.isMuted ?? false);
81
+
82
+ useEffect(() => {
83
+ const updateMuted = () => setIsMuted(localMediaTrack?.isMuted ?? false);
84
+ updateMuted();
85
+
86
+ localMediaTrack?.on('muted', updateMuted);
87
+ localMediaTrack?.on('unmuted', updateMuted);
88
+
89
+ return () => {
90
+ localMediaTrack?.off('muted', updateMuted);
91
+ localMediaTrack?.off('unmuted', updateMuted);
92
+ };
93
+ }, [localMediaTrack]);
94
+
95
+ return isMuted;
96
+ }
97
+ ```
98
+
99
+ #### src/components/room.js
100
+
101
+ ```jsx
102
+ import useLocalMediaMuted from '../hooks/useLocalMediaMuted';
103
+
104
+ export default function Room({ room }) {
105
+ const [{ track: localAudioTrack }] = [...room.localParticipant.audioTracks.values()];
106
+ const [{ track: localVideoTrack }] = [...room.localParticipant.videoTracks.values()];
107
+
108
+ const isLocalAudioMuted = useLocalMediaMuted(localAudioTrack);
109
+ const isLocalVideoMuted = useLocalMediaMuted(localVideoTrack);
110
+ const isLocalMediaMuted = isLocalAudioMuted || isLocalVideoMuted;
111
+
112
+ const refreshInactiveMedia = () => {
113
+ room.refreshInactiveMedia();
114
+ };
115
+
116
+ return (
117
+ <>
118
+ ...
119
+ {isLocalMediaMuted && <Button onClick={refreshInactiveMedia}>
120
+ Refresh Inactive Media
121
+ </Button>}
122
+ ...
123
+ </>
124
+ );
125
+ }
126
+ ```
127
+
5
128
  2.25.0 (November 14, 2022)
6
129
  ==========================
7
130
 
@@ -27,7 +150,7 @@ The application can decide to capture audio from a specific audio input device b
27
150
 
28
151
  - using the MediaTrackConstraints `{ audio: { deviceId: 'foo' } }`, and "foo" is available, or
29
152
  - using the MediaTrackConstraints `{ audio: { deviceId: { ideal: 'foo' } } }` and "foo" is available, or
30
- - using the MediaTrackConstraints `{ audio: { deviceId: { exact: 'foo' } } }` and "foo" is available
153
+ - using the MediaTrackConstraints `{ audio: { deviceId: { exact: 'foo' } } }` and "foo" is available
31
154
 
32
155
  In this case, the LocalAudioTrack DOES NOT switch to another audio input device if the current audio input device is no
33
156
  longer available. See below for the behavior of this property based on how the LocalAudioTrack is created. (VIDEO-11701)
package/README.md CHANGED
@@ -74,7 +74,7 @@ Releases of twilio-video.js are hosted on a CDN, and you can include these
74
74
  directly in your web app using a &lt;script&gt; tag.
75
75
 
76
76
  ```html
77
- <script src="//sdk.twilio.com/js/video/releases/2.25.0/twilio-video.min.js"></script>
77
+ <script src="//sdk.twilio.com/js/video/releases/2.26.1/twilio-video.min.js"></script>
78
78
  ```
79
79
 
80
80
  Using this method, twilio-video.js will set a browser global: