@tellescope/video-chat 0.0.15 → 0.0.16

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 (58) hide show
  1. package/lib/cjs/controls.d.ts +3 -0
  2. package/lib/cjs/controls.d.ts.map +1 -0
  3. package/lib/cjs/controls.js +23 -0
  4. package/lib/cjs/controls.js.map +1 -0
  5. package/lib/cjs/index.d.ts +1 -0
  6. package/lib/cjs/index.d.ts.map +1 -1
  7. package/lib/cjs/index.js +1 -0
  8. package/lib/cjs/index.js.map +1 -1
  9. package/lib/cjs/index.native.d.ts +1 -0
  10. package/lib/cjs/index.native.d.ts.map +1 -1
  11. package/lib/cjs/index.native.js +1 -0
  12. package/lib/cjs/index.native.js.map +1 -1
  13. package/lib/cjs/native/RNVideoRenderView.d.ts +1 -1
  14. package/lib/cjs/native/RNVideoRenderView.d.ts.map +1 -1
  15. package/lib/cjs/native/RNVideoRenderView.js.map +1 -1
  16. package/lib/cjs/video.d.ts +10 -2
  17. package/lib/cjs/video.d.ts.map +1 -1
  18. package/lib/cjs/video.js +31 -3
  19. package/lib/cjs/video.js.map +1 -1
  20. package/lib/cjs/video.native.d.ts +6 -1
  21. package/lib/cjs/video.native.d.ts.map +1 -1
  22. package/lib/cjs/video.native.js +50 -10
  23. package/lib/cjs/video.native.js.map +1 -1
  24. package/lib/esm/components.d.ts +1 -0
  25. package/lib/esm/components.d.ts.map +1 -0
  26. package/lib/esm/components.js +3 -0
  27. package/lib/esm/components.js.map +1 -0
  28. package/lib/esm/controls.d.ts +3 -0
  29. package/lib/esm/controls.d.ts.map +1 -0
  30. package/lib/esm/controls.js +15 -0
  31. package/lib/esm/controls.js.map +1 -0
  32. package/lib/esm/index.d.ts +1 -0
  33. package/lib/esm/index.d.ts.map +1 -1
  34. package/lib/esm/index.js +1 -0
  35. package/lib/esm/index.js.map +1 -1
  36. package/lib/esm/index.native.d.ts +1 -0
  37. package/lib/esm/index.native.d.ts.map +1 -1
  38. package/lib/esm/index.native.js +1 -0
  39. package/lib/esm/index.native.js.map +1 -1
  40. package/lib/esm/native/RNVideoRenderView.d.ts +1 -1
  41. package/lib/esm/native/RNVideoRenderView.d.ts.map +1 -1
  42. package/lib/esm/native/RNVideoRenderView.js.map +1 -1
  43. package/lib/esm/video.d.ts +10 -2
  44. package/lib/esm/video.d.ts.map +1 -1
  45. package/lib/esm/video.js +33 -3
  46. package/lib/esm/video.js.map +1 -1
  47. package/lib/esm/video.native.d.ts +6 -1
  48. package/lib/esm/video.native.d.ts.map +1 -1
  49. package/lib/esm/video.native.js +47 -9
  50. package/lib/esm/video.native.js.map +1 -1
  51. package/lib/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +10 -10
  53. package/src/controls.tsx +33 -0
  54. package/src/index.native.ts +2 -1
  55. package/src/index.ts +2 -1
  56. package/src/native/RNVideoRenderView.tsx +1 -1
  57. package/src/video.native.tsx +56 -6
  58. package/src/video.tsx +37 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/video-chat",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -33,17 +33,17 @@
33
33
  "@fontsource/roboto": "^4.5.1",
34
34
  "@mui/icons-material": "^5.0.1",
35
35
  "@mui/material": "^5.0.2",
36
- "@tellescope/constants": "^0.0.15",
37
- "@tellescope/react-components": "^0.0.15",
38
- "@tellescope/sdk": "^0.0.15",
39
- "@tellescope/types-client": "^0.0.15",
40
- "@tellescope/types-models": "^0.0.15",
41
- "@tellescope/types-utilities": "^0.0.15",
42
- "@tellescope/utilities": "^0.0.15",
36
+ "@tellescope/constants": "^0.0.16",
37
+ "@tellescope/react-components": "^0.0.16",
38
+ "@tellescope/sdk": "^0.0.16",
39
+ "@tellescope/types-client": "^0.0.16",
40
+ "@tellescope/types-models": "^0.0.16",
41
+ "@tellescope/types-utilities": "^0.0.16",
42
+ "@tellescope/utilities": "^0.0.16",
43
43
  "@typescript-eslint/eslint-plugin": "^4.33.0",
44
44
  "@typescript-eslint/parser": "^4.33.0",
45
45
  "amazon-chime-sdk-component-library-react": "^2.12.0",
46
- "amazon-chime-sdk-js": "^2.23.0",
46
+ "amazon-chime-sdk-js": "^2.24.0",
47
47
  "eslint": "^7.32.0",
48
48
  "eslint-plugin-react": "^7.26.1",
49
49
  "nodemon": "^2.0.13",
@@ -54,7 +54,7 @@
54
54
  "react": "^17.0.2",
55
55
  "react-dom": "^17.0.2"
56
56
  },
57
- "gitHead": "bafbe70fd6546fdbc894fd408ae071709d3c5b80",
57
+ "gitHead": "06e581f4d3a6c5b57fd0cfcc22103b94125f9da4",
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  }
@@ -0,0 +1,33 @@
1
+ // components that work with web or native
2
+ import React from "react"
3
+
4
+ import {
5
+ VideoIcon,
6
+ VideoOffIcon,
7
+ MicrophoneIcon,
8
+ MicrophoneOffIcon,
9
+ } from "@tellescope/react-components/lib/esm/mui"
10
+ import { LabeledIconButton } from "@tellescope/react-components/lib/esm/controls"
11
+ import {
12
+ CurrentCallContext,
13
+ } from "./video"
14
+
15
+ export const VideoToggle = () => {
16
+ const { toggleVideo, videoIsEnabled } = React.useContext(CurrentCallContext)
17
+
18
+ return (
19
+ <LabeledIconButton Icon={videoIsEnabled ? VideoIcon : VideoOffIcon} onClick={toggleVideo}
20
+ label={videoIsEnabled ? "Turn Camera Off" : "Turn Camera On"}
21
+ />
22
+ )
23
+ }
24
+
25
+ export const MicrophoneToggle = () => {
26
+ const { microphoneIsEnabled, toggleMicrophone } = React.useContext(CurrentCallContext)
27
+
28
+ return (
29
+ <LabeledIconButton Icon={microphoneIsEnabled ? MicrophoneIcon : MicrophoneOffIcon} onClick={toggleMicrophone}
30
+ label={microphoneIsEnabled ? "Turn Microphone Off" : "Turn Microphone On"}
31
+ />
32
+ )
33
+ }
@@ -1 +1,2 @@
1
- export * from "./video"
1
+ export * from "./video"
2
+ export * from "./controls"
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
- export * from "./video";
1
+ export * from "./video";
2
+ export * from "./controls"
@@ -8,7 +8,7 @@ import React from 'react';
8
8
  import { requireNativeComponent, findNodeHandle, ViewStyle } from 'react-native';
9
9
  import { NativeFunction } from './bridge';
10
10
 
11
- export class RNVideoView extends React.Component<{ tileId: string | number, style?: ViewStyle }> {
11
+ export class RNVideoView extends React.Component<{ tileId: number, style?: ViewStyle }> {
12
12
  componentDidMount() {
13
13
  // we need to delay the bind video
14
14
  // Because "componentDidMount" will be called "immediately after the initial rendering occurs"
@@ -17,14 +17,24 @@ import {
17
17
  } from '@tellescope/types-utilities'
18
18
  import { useSession } from "@tellescope/react-components/lib/esm/authentication"
19
19
  import { Flex } from "@tellescope/react-components/lib/esm/layout"
20
- import { Button, Typography } from "@tellescope/react-components/lib/esm/mui"
20
+ import {
21
+ Button,
22
+ Typography,
23
+ convert_CSS_to_RNStyles,
24
+
25
+ VideoIcon,
26
+ VideoOffIcon,
27
+ MicrophoneIcon,
28
+ MicrophoneOffIcon,
29
+ } from "@tellescope/react-components/lib/esm/mui.native"
21
30
 
22
31
  import {
23
32
  CurrentCallContext,
24
33
  JoinVideoCallReturnType,
25
34
  StartVideoCallReturnType,
26
35
  VideoProps,
27
- AttendeeDisplayInfo
36
+ AttendeeDisplayInfo,
37
+ VideoViewProps,
28
38
  } from "./video.js"
29
39
 
30
40
  import {
@@ -40,20 +50,26 @@ interface TileState {
40
50
  tileId: number,
41
51
  }
42
52
 
43
- export const WithVideo = ({ children } : VideoProps ) => {
53
+ export const WithVideo = ({ children } : VideoProps) => {
44
54
  const [meeting, setMeeting] = useState(undefined as MeetingInfo | undefined)
45
55
 
46
56
  const [inMeeting, setInMeeting] = useState(false)
47
57
  const [isLoading, setIsLoading] = useState(false)
58
+ const [muted, setMuted] = useState(false)
48
59
  const [videoIsEnabled, setVideoIsEnabled] = useState(false)
49
60
  const [videoTiles, setVideoTiles] = useState([] as number[])
61
+ const [localTileId, setLocalTileId] = useState(null as number | null)
50
62
  const [screenShareTile, setScreenShareTile] = useState(null as number | null)
51
63
  const [attendees, setAttendees] = useState ([] as AttendeeDisplayInfo[])
52
64
 
53
65
  const toggleVideo = async () => {
54
- console.log('toggling', NativeFunction.setCameraOn(!videoIsEnabled))
66
+ NativeFunction.setCameraOn(!videoIsEnabled)
55
67
  setVideoIsEnabled(v => !v)
56
68
  }
69
+ const toggleMic = async () => {
70
+ NativeFunction.setMute(!muted)
71
+ setMuted(m => !m)
72
+ }
57
73
  const emitter = getSDKEventEmitter()
58
74
 
59
75
  useEffect(() => {
@@ -98,6 +114,9 @@ export const WithVideo = ({ children } : VideoProps ) => {
98
114
  setScreenShareTile(tileState.tileId)
99
115
  return
100
116
  }
117
+ if (tileState.isLocal) {
118
+ setLocalTileId(tileState.tileId)
119
+ }
101
120
  setVideoTiles(v => [...v, tileState.tileId])
102
121
  setVideoIsEnabled(v => tileState.isLocal ? true : v)
103
122
  });
@@ -127,18 +146,40 @@ export const WithVideo = ({ children } : VideoProps ) => {
127
146
  return (
128
147
  <CurrentCallContext.Provider value={{
129
148
  attendees,
149
+ localTileId,
130
150
  videoTiles,
131
151
  meeting,
132
152
  shareScreenId: screenShareTile,
133
153
  setMeeting,
134
154
  videoIsEnabled,
135
- toggleVideo
155
+ toggleVideo,
156
+ microphoneIsEnabled: !muted,
157
+ toggleMicrophone: toggleMic,
136
158
  }}>
137
159
  {children}
138
160
  </CurrentCallContext.Provider>
139
161
  )
140
162
  }
141
163
 
164
+
165
+ export const useRemoteViews = ({ style } : { style: React.CSSProperties }) => {
166
+ const { localTileId, videoTiles } = React.useContext(CurrentCallContext)
167
+ const nonLocal = videoTiles.filter(v => v !== localTileId)
168
+
169
+ return nonLocal.map(tileId =>
170
+ <RNVideoView style={convert_CSS_to_RNStyles(style) ?? styles.video} tileId={tileId} />
171
+ )
172
+ }
173
+
174
+ export const SelfView = ({ style } : VideoViewProps) => {
175
+ const { localTileId } = React.useContext(CurrentCallContext)
176
+ if (!localTileId) return null
177
+
178
+ return (
179
+ <RNVideoView style={convert_CSS_to_RNStyles(style) ?? styles.video} tileId={localTileId}/>
180
+ )
181
+ }
182
+
142
183
  export const useStartVideoCall = (): StartVideoCallReturnType => {
143
184
  const session = useSession()
144
185
  const { meeting, setMeeting, videoIsEnabled, toggleVideo } = React.useContext(CurrentCallContext)
@@ -182,7 +223,16 @@ export const useStartVideoCall = (): StartVideoCallReturnType => {
182
223
  setMeeting(undefined)
183
224
  }
184
225
 
185
- return { meeting, videoIsEnabled, starting, ending, toggleVideo, createAndStartMeeting, addAttendees, endMeeting }
226
+ return {
227
+ meeting,
228
+ videoIsEnabled,
229
+ starting,
230
+ ending,
231
+ toggleVideo,
232
+ createAndStartMeeting,
233
+ addAttendees,
234
+ endMeeting,
235
+ }
186
236
  }
187
237
 
188
238
  export const useJoinVideoCall = (): JoinVideoCallReturnType => {
package/src/video.tsx CHANGED
@@ -12,14 +12,6 @@ import {
12
12
  MeetingInfo,
13
13
  } from '@tellescope/types-models'
14
14
 
15
- import {
16
- user_display_name,
17
- } from "@tellescope/utilities"
18
-
19
- import {
20
- Session,
21
- EnduserSession,
22
- } from "@tellescope/sdk"
23
15
 
24
16
  import { ThemeProvider } from 'styled-components';
25
17
  import {
@@ -31,12 +23,15 @@ import {
31
23
  // VideoGrid,
32
24
  // VideoTile,
33
25
  // PreviewVideo,
34
- // RemoteVideo,
26
+ RemoteVideo,
35
27
  useAttendeeAudioStatus,
28
+ LocalVideo,
36
29
  useLocalVideo,
37
30
  useMeetingManager,
38
31
  useRosterState,
39
- useRemoteVideoTileState
32
+ useRemoteVideoTileState,
33
+ VideoTile,
34
+ useToggleLocalMute,
40
35
  // useRemoteVideoTileState,
41
36
  // useContentShareControls, // screen sharing
42
37
  } from 'amazon-chime-sdk-component-library-react';
@@ -47,8 +42,10 @@ export type AttendeeDisplayInfo = { attendeeId: string, externalUserId: string
47
42
  export const CurrentCallContext = React.createContext({} as {
48
43
  meeting: MeetingInfo | undefined, setMeeting: (m: MeetingInfo | undefined) => void,
49
44
  videoIsEnabled: boolean, toggleVideo: () => Promise<void>,
45
+ microphoneIsEnabled: boolean, toggleMicrophone: () => Promise<void>,
50
46
  attendees: AttendeeDisplayInfo[], shareScreenId: number | null,
51
- videoTiles: (number | string)[],
47
+ localTileId: number | null,
48
+ videoTiles: (number)[],
52
49
  })
53
50
  export interface VideoProps {
54
51
  children?: React.ReactNode,
@@ -56,10 +53,11 @@ export interface VideoProps {
56
53
  }
57
54
  const WithContext = ({ children } : { children: React.ReactNode }) => {
58
55
  const [meeting, setMeeting] = useState(undefined as MeetingInfo | undefined)
59
- const { toggleVideo, isVideoEnabled: videoIsEnabled } = useLocalVideo();
56
+ const { toggleVideo, isVideoEnabled: videoIsEnabled, tileId: localTileId } = useLocalVideo();
60
57
  const { roster } = useRosterState()
61
58
  const { tileId } = useContentShareState()
62
59
  const { tiles } = useRemoteVideoTileState()
60
+ const { muted, toggleMute } = useToggleLocalMute()
63
61
 
64
62
  const attendees = [] as AttendeeDisplayInfo[]
65
63
  for (const attendeeId in roster) {
@@ -68,7 +66,18 @@ const WithContext = ({ children } : { children: React.ReactNode }) => {
68
66
  }
69
67
 
70
68
  return (
71
- <CurrentCallContext.Provider value={{ attendees, videoTiles: tiles, shareScreenId: tileId, meeting, setMeeting, videoIsEnabled, toggleVideo }}>
69
+ <CurrentCallContext.Provider value={{
70
+ attendees,
71
+ localTileId,
72
+ videoTiles: tiles,
73
+ shareScreenId: tileId,
74
+ meeting,
75
+ setMeeting,
76
+ videoIsEnabled,
77
+ toggleVideo,
78
+ microphoneIsEnabled: !muted,
79
+ toggleMicrophone: async () => toggleMute(),
80
+ }}>
72
81
  {children}
73
82
  </CurrentCallContext.Provider>
74
83
  )
@@ -148,4 +157,19 @@ export const useJoinVideoCall = () => {
148
157
  }
149
158
  export type JoinVideoCallReturnType = ReturnType<typeof useJoinVideoCall>
150
159
 
160
+ export interface VideoViewProps {
161
+ style?: CSSProperties,
162
+ }
163
+ export const SelfView = ({ style }: VideoViewProps) => <div style={style}><LocalVideo/></div>
164
+
165
+ export const useRemoteViews = ({ style } : VideoViewProps) => {
166
+ const { localTileId, videoTiles } = React.useContext(CurrentCallContext)
167
+ const nonLocal = videoTiles.filter(v => v !== localTileId)
168
+
169
+ return nonLocal.map(tileId =>
170
+ <RemoteVideo style={style} tileId={tileId} />
171
+ )
172
+ }
173
+
174
+
151
175
  export { VideoTileGrid }