twilio-video 2.24.3 → 2.26.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +1 -2
  3. package/dist/twilio-video.js +1651 -1174
  4. package/dist/twilio-video.min.js +21 -21
  5. package/es5/createlocaltrack.js +10 -2
  6. package/es5/createlocaltrack.js.map +1 -1
  7. package/es5/createlocaltracks.js +20 -8
  8. package/es5/createlocaltracks.js.map +1 -1
  9. package/es5/media/track/localaudiotrack.js +140 -7
  10. package/es5/media/track/localaudiotrack.js.map +1 -1
  11. package/es5/media/track/localmediatrack.js +32 -6
  12. package/es5/media/track/localmediatrack.js.map +1 -1
  13. package/es5/media/track/localvideotrack.js +33 -12
  14. package/es5/media/track/localvideotrack.js.map +1 -1
  15. package/es5/media/track/mediatrack.js +3 -3
  16. package/es5/media/track/mediatrack.js.map +1 -1
  17. package/es5/media/track/remotemediatrack.js +2 -2
  18. package/es5/media/track/remotemediatrack.js.map +1 -1
  19. package/es5/media/track/sender.js +39 -1
  20. package/es5/media/track/sender.js.map +1 -1
  21. package/es5/room.js +50 -1
  22. package/es5/room.js.map +1 -1
  23. package/es5/transceiver.js +3 -3
  24. package/es5/transceiver.js.map +1 -1
  25. package/es5/util/browserdetection.js +16 -15
  26. package/es5/util/browserdetection.js.map +1 -1
  27. package/es5/webrtc/getstats.js +75 -58
  28. package/es5/webrtc/getstats.js.map +1 -1
  29. package/es5/webrtc/getusermedia.js +1 -1
  30. package/es5/webrtc/getusermedia.js.map +1 -1
  31. package/es5/webrtc/index.js.map +1 -1
  32. package/es5/webrtc/rtcpeerconnection/chrome.js +339 -286
  33. package/es5/webrtc/rtcpeerconnection/chrome.js.map +1 -1
  34. package/es5/webrtc/rtcpeerconnection/firefox.js +225 -179
  35. package/es5/webrtc/rtcpeerconnection/firefox.js.map +1 -1
  36. package/es5/webrtc/rtcpeerconnection/index.js.map +1 -1
  37. package/es5/webrtc/rtcpeerconnection/safari.js +276 -236
  38. package/es5/webrtc/rtcpeerconnection/safari.js.map +1 -1
  39. package/es5/webrtc/rtcrtpsender.js +12 -9
  40. package/es5/webrtc/rtcrtpsender.js.map +1 -1
  41. package/es5/webrtc/rtcsessiondescription/chrome.js +29 -22
  42. package/es5/webrtc/rtcsessiondescription/chrome.js.map +1 -1
  43. package/es5/webrtc/rtcsessiondescription/index.js.map +1 -1
  44. package/es5/webrtc/util/index.js +32 -15
  45. package/es5/webrtc/util/index.js.map +1 -1
  46. package/es5/webrtc/util/latch.js +83 -82
  47. package/es5/webrtc/util/latch.js.map +1 -1
  48. package/es5/webrtc/util/sdp.js +12 -19
  49. package/es5/webrtc/util/sdp.js.map +1 -1
  50. package/lib/createlocaltrack.js +10 -2
  51. package/lib/createlocaltracks.ts +32 -11
  52. package/lib/media/track/localaudiotrack.js +142 -8
  53. package/lib/media/track/localmediatrack.js +31 -5
  54. package/lib/media/track/localvideotrack.js +35 -13
  55. package/lib/media/track/mediatrack.js +2 -2
  56. package/lib/media/track/remotemediatrack.js +2 -2
  57. package/lib/media/track/sender.js +42 -1
  58. package/lib/room.js +41 -1
  59. package/lib/transceiver.js +3 -3
  60. package/lib/util/browserdetection.js +16 -15
  61. package/lib/webrtc/getstats.js +155 -171
  62. package/lib/webrtc/getusermedia.js +1 -2
  63. package/lib/webrtc/index.js +1 -1
  64. package/lib/webrtc/rtcpeerconnection/chrome.js +284 -316
  65. package/lib/webrtc/rtcpeerconnection/firefox.js +173 -197
  66. package/lib/webrtc/rtcpeerconnection/index.js +1 -1
  67. package/lib/webrtc/rtcpeerconnection/safari.js +228 -256
  68. package/lib/webrtc/rtcrtpsender.js +10 -8
  69. package/lib/webrtc/rtcsessiondescription/chrome.js +24 -24
  70. package/lib/webrtc/rtcsessiondescription/index.js +1 -1
  71. package/lib/webrtc/util/index.js +26 -33
  72. package/lib/webrtc/util/latch.js +78 -83
  73. package/lib/webrtc/util/sdp.js +32 -41
  74. package/package.json +3 -3
  75. package/tsdef/LocalAudioTrack.d.ts +3 -0
  76. package/tsdef/LocalVideoTrack.d.ts +3 -0
  77. package/tsdef/Room.d.ts +1 -0
  78. package/tsdef/index.d.ts +1 -0
  79. package/tsdef/types.d.ts +2 -0
  80. package/es5/webrtc/util/eventtarget.js +0 -34
  81. package/es5/webrtc/util/eventtarget.js.map +0 -1
  82. package/lib/webrtc/util/eventtarget.js +0 -39
package/CHANGELOG.md CHANGED
@@ -2,6 +2,178 @@ 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.0 (December 14, 2022)
6
+ ==========================
7
+
8
+ New Features
9
+ ------------
10
+
11
+ - The [`LocalAudioTrack`](https://sdk.twilio.com/js/video/releases/2.26.0/docs/LocalAudioTrack.html) and
12
+ [`LocalVideoTrack`](https://sdk.twilio.com/js/video/releases/2.26.0/docs/LocalVideoTrack.html) classes now provide a
13
+ new boolean property called `isMuted`, which lets you know if the audio or video source is currently providing raw media
14
+ samples. The classes also emit `muted` and `unmuted` events if the value of `isMuted` toggles. The application can use
15
+ these APIs to detect temporary loss of microphone or camera to other applications (ex: an incoming phone call on an iOS device),
16
+ and update the user interface accordingly. (VIDEO-11360)
17
+
18
+ - The `Room` class provides a new method called [refreshInactiveMedia](https://sdk.twilio.com/js/video/releases/2.26.0/docs/Room.html#refreshInactiveMedia),
19
+ which restarts any muted local media Tracks, and plays any inadvertently paused HTMLMediaElements that are attached to
20
+ local and remote media Tracks. This is useful especially on iOS devices, where sometimes your application's media may
21
+ not recover after an incoming phone call. You can use this method in conjunction with the local media Track's `isMuted`
22
+ property described previously to recover local and remote media after an incoming phone call as shown below. (VIDEO-11360)
23
+
24
+ ### Vanilla JS
25
+
26
+ #### html
27
+
28
+ ```html
29
+ <button id="refresh-inactive-media" disabled>Refresh Inactive Media</button>
30
+ ```
31
+
32
+ #### js
33
+
34
+ ```js
35
+ const { connect } = require('twilio-video');
36
+
37
+ const room = await connect('token', { name: 'my-cool-room' });
38
+
39
+ const $refreshInactiveMedia = document.getElementById('refresh-inactive-media');
40
+ $refreshInactiveMedia.onclick = () => room.refreshInactiveMedia();
41
+
42
+ const [{ track: localAudioTrack }] = [...room.localParticipant.audioTracks.values()];
43
+ const [{ track: localVideoTrack }] = [...room.localParticipant.videoTracks.values()];
44
+
45
+ const isLocalAudioOrVideoMuted = () => {
46
+ return localAudioTrack.isMuted || localVideoTrack.isMuted;
47
+ }
48
+
49
+ const onLocalMediaMutedChanged = () => {
50
+ $refreshInactiveMedia.disabled = !isLocalAudioOrVideoMuted();
51
+ };
52
+
53
+ [localAudioTrack, localVideoTrack].forEach(localMediaTrack => {
54
+ ['muted', 'unmuted'].forEach(event => {
55
+ localMediaTrack.on(event, onLocalMediaMutedChanged);
56
+ });
57
+ });
58
+ ```
59
+
60
+ ### React
61
+
62
+ #### src/hooks/useLocalMediaMuted.js
63
+
64
+ ```js
65
+ import { useEffect, useState } from 'react';
66
+
67
+ export default function useLocalMediaMuted(localMediaTrack) {
68
+ const [isMuted, setIsMuted] = useState(localMediaTrack?.isMuted ?? false);
69
+
70
+ useEffect(() => {
71
+ const updateMuted = () => setIsMuted(localMediaTrack?.isMuted ?? false);
72
+ updateMuted();
73
+
74
+ localMediaTrack?.on('muted', updateMuted);
75
+ localMediaTrack?.on('unmuted', updateMuted);
76
+
77
+ return () => {
78
+ localMediaTrack?.off('muted', updateMuted);
79
+ localMediaTrack?.off('unmuted', updateMuted);
80
+ };
81
+ }, [localMediaTrack]);
82
+
83
+ return isMuted;
84
+ }
85
+ ```
86
+
87
+ #### src/components/room.js
88
+
89
+ ```jsx
90
+ import useLocalMediaMuted from '../hooks/useLocalMediaMuted';
91
+
92
+ export default function Room({ room }) {
93
+ const [{ track: localAudioTrack }] = [...room.localParticipant.audioTracks.values()];
94
+ const [{ track: localVideoTrack }] = [...room.localParticipant.videoTracks.values()];
95
+
96
+ const isLocalAudioMuted = useLocalMediaMuted(localAudioTrack);
97
+ const isLocalVideoMuted = useLocalMediaMuted(localVideoTrack);
98
+ const isLocalMediaMuted = isLocalAudioMuted || isLocalVideoMuted;
99
+
100
+ const refreshInactiveMedia = () => {
101
+ room.refreshInactiveMedia();
102
+ };
103
+
104
+ return (
105
+ <>
106
+ ...
107
+ {isLocalMediaMuted && <Button onClick={refreshInactiveMedia}>
108
+ Refresh Inactive Media
109
+ </Button>}
110
+ ...
111
+ </>
112
+ );
113
+ }
114
+ ```
115
+
116
+ 2.25.0 (November 14, 2022)
117
+ ==========================
118
+
119
+ New Features
120
+ ------------
121
+
122
+ ### Auto-switch default audio input devices
123
+
124
+ This release adds a new feature that preserves audio continuity in situations where end-users change the default audio input device.
125
+ A LocalAudioTrack is said to be capturing audio from the default audio input device if:
126
+
127
+ - it was created using the MediaTrackConstraints `{ audio: true }`, or
128
+ - it was created using the MediaTrackConstraints `{ audio: { deviceId: 'foo' } }`, and "foo" is not available, or
129
+ - it was created using the MediaTrackConstraints `{ audio: { deviceId: { ideal: 'foo' } } }` and "foo" is not available
130
+
131
+ In previous versions of the SDK, if the default device changed (ex: a bluetooth headset is connected to a mac or windows laptop),
132
+ the LocalAudioTrack continued to capture audio from the old default device (ex: the laptop microphone). Now, a LocalAudioTrack
133
+ will switch automatically from the old default audio input device to the new default audio input device (ex: from the laptop microphone to the headset microphone).
134
+ This feature is controlled by a new [CreateLocalAudioTrackOptions](https://sdk.twilio.com/js/video/releases/2.25.0/docs/global.html#CreateLocalAudioTrackOptions)
135
+ property `defaultDeviceCaptureMode`, which defaults to `auto` (new behavior) or can be set to `manual` (old behavior).
136
+
137
+ The application can decide to capture audio from a specific audio input device by creating a LocalAudioTrack:
138
+
139
+ - using the MediaTrackConstraints `{ audio: { deviceId: 'foo' } }`, and "foo" is available, or
140
+ - using the MediaTrackConstraints `{ audio: { deviceId: { ideal: 'foo' } } }` and "foo" is available, or
141
+ - using the MediaTrackConstraints `{ audio: { deviceId: { exact: 'foo' } } }` and "foo" is available
142
+
143
+ In this case, the LocalAudioTrack DOES NOT switch to another audio input device if the current audio input device is no
144
+ longer available. See below for the behavior of this property based on how the LocalAudioTrack is created. (VIDEO-11701)
145
+
146
+ ```js
147
+ const { connect, createLocalAudioTrack, createLocalTracks } = require('twilio-video');
148
+
149
+ // Auto-switch default audio input devices: option 1
150
+ const audioTrack = await createLocalAudioTrack();
151
+
152
+ // Auto-switch default audio input devices: option 2
153
+ const audioTrack1 = await createLocalAudioTrack({ defaultDeviceCaptureMode: 'auto' });
154
+
155
+ // Auto-switch default audio input devices: option 3
156
+ const [audioTrack3] = await createLocalTracks({ audio: true });
157
+
158
+ // Auto-switch default audio input devices: option 4
159
+ const [audioTrack4] = await createLocalTracks({ audio: { defaultDeviceCaptureMode: 'auto' } });
160
+
161
+ // Auto-switch default audio input devices: option 5
162
+ const room1 = await connect({ audio: true });
163
+
164
+ // Auto-switch default audio input devices: option 6
165
+ const room2 = await connect({ audio: { defaultDeviceCaptureMode: 'auto' } });
166
+
167
+ // Disable auto-switch default audio input devices
168
+ const room = await createLocalAudioTrack({ defaultDeviceCaptureMode: 'manual' });
169
+ ```
170
+
171
+ **Limitations**
172
+
173
+ - This feature is not enabled on iOS as it is natively supported.
174
+ - Due to this [WebKit bug](https://bugs.webkit.org/show_bug.cgi?id=232835), MacOS Safari Participants may lose their local audio after switching between default audio input devices two-three times.
175
+ - This feature is not supported on Android Chrome, as it does not support the [MediaDevices.ondevicechange](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/devicechange_event#browser_compatibility) event.
176
+
5
177
  2.24.3 (October 10, 2022)
6
178
  =========================
7
179
 
package/README.md CHANGED
@@ -74,8 +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.24.3/twilio-video.min.js"></script>
78
-
77
+ <script src="//sdk.twilio.com/js/video/releases/2.26.0/twilio-video.min.js"></script>
79
78
  ```
80
79
 
81
80
  Using this method, twilio-video.js will set a browser global: