twilio-video 2.25.0 → 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 (65) hide show
  1. package/CHANGELOG.md +112 -1
  2. package/README.md +1 -1
  3. package/dist/twilio-video.js +1481 -1134
  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/webrtc/getstats.js +75 -58
  18. package/es5/webrtc/getstats.js.map +1 -1
  19. package/es5/webrtc/getusermedia.js +1 -1
  20. package/es5/webrtc/getusermedia.js.map +1 -1
  21. package/es5/webrtc/index.js.map +1 -1
  22. package/es5/webrtc/rtcpeerconnection/chrome.js +339 -286
  23. package/es5/webrtc/rtcpeerconnection/chrome.js.map +1 -1
  24. package/es5/webrtc/rtcpeerconnection/firefox.js +225 -179
  25. package/es5/webrtc/rtcpeerconnection/firefox.js.map +1 -1
  26. package/es5/webrtc/rtcpeerconnection/index.js.map +1 -1
  27. package/es5/webrtc/rtcpeerconnection/safari.js +276 -236
  28. package/es5/webrtc/rtcpeerconnection/safari.js.map +1 -1
  29. package/es5/webrtc/rtcrtpsender.js +12 -9
  30. package/es5/webrtc/rtcrtpsender.js.map +1 -1
  31. package/es5/webrtc/rtcsessiondescription/chrome.js +29 -22
  32. package/es5/webrtc/rtcsessiondescription/chrome.js.map +1 -1
  33. package/es5/webrtc/rtcsessiondescription/index.js.map +1 -1
  34. package/es5/webrtc/util/index.js +32 -15
  35. package/es5/webrtc/util/index.js.map +1 -1
  36. package/es5/webrtc/util/latch.js +83 -82
  37. package/es5/webrtc/util/latch.js.map +1 -1
  38. package/es5/webrtc/util/sdp.js +12 -19
  39. package/es5/webrtc/util/sdp.js.map +1 -1
  40. package/lib/media/track/localaudiotrack.js +30 -8
  41. package/lib/media/track/localmediatrack.js +29 -0
  42. package/lib/media/track/localvideotrack.js +33 -10
  43. package/lib/media/track/sender.js +42 -1
  44. package/lib/room.js +41 -1
  45. package/lib/transceiver.js +3 -3
  46. package/lib/webrtc/getstats.js +155 -171
  47. package/lib/webrtc/getusermedia.js +1 -2
  48. package/lib/webrtc/index.js +1 -1
  49. package/lib/webrtc/rtcpeerconnection/chrome.js +284 -316
  50. package/lib/webrtc/rtcpeerconnection/firefox.js +173 -197
  51. package/lib/webrtc/rtcpeerconnection/index.js +1 -1
  52. package/lib/webrtc/rtcpeerconnection/safari.js +228 -256
  53. package/lib/webrtc/rtcrtpsender.js +10 -8
  54. package/lib/webrtc/rtcsessiondescription/chrome.js +24 -24
  55. package/lib/webrtc/rtcsessiondescription/index.js +1 -1
  56. package/lib/webrtc/util/index.js +26 -33
  57. package/lib/webrtc/util/latch.js +78 -83
  58. package/lib/webrtc/util/sdp.js +32 -41
  59. package/package.json +2 -2
  60. package/tsdef/LocalAudioTrack.d.ts +3 -0
  61. package/tsdef/LocalVideoTrack.d.ts +3 -0
  62. package/tsdef/Room.d.ts +1 -0
  63. package/es5/webrtc/util/eventtarget.js +0 -34
  64. package/es5/webrtc/util/eventtarget.js.map +0 -1
  65. package/lib/webrtc/util/eventtarget.js +0 -39
package/CHANGELOG.md CHANGED
@@ -2,6 +2,117 @@ 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
+
5
116
  2.25.0 (November 14, 2022)
6
117
  ==========================
7
118
 
@@ -27,7 +138,7 @@ The application can decide to capture audio from a specific audio input device b
27
138
 
28
139
  - using the MediaTrackConstraints `{ audio: { deviceId: 'foo' } }`, and "foo" is available, or
29
140
  - using the MediaTrackConstraints `{ audio: { deviceId: { ideal: 'foo' } } }` and "foo" is available, or
30
- - using the MediaTrackConstraints `{ audio: { deviceId: { exact: 'foo' } } }` and "foo" is available
141
+ - using the MediaTrackConstraints `{ audio: { deviceId: { exact: 'foo' } } }` and "foo" is available
31
142
 
32
143
  In this case, the LocalAudioTrack DOES NOT switch to another audio input device if the current audio input device is no
33
144
  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.0/twilio-video.min.js"></script>
78
78
  ```
79
79
 
80
80
  Using this method, twilio-video.js will set a browser global: