Skip to content

Commit 3c4a9d0

Browse files
committed
updated jsdoc for handleReceiveCall
1 parent 2c46788 commit 3c4a9d0

File tree

6 files changed

+74
-46
lines changed

6 files changed

+74
-46
lines changed

dist/src/components/VideoCall.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference types="react" />
22
/**
33
* @func VideoCall
4-
* @param {String} props.URL - ws or wss link
4+
* @param {String} props.URL - ws or wss link that establishes a connection between the WebSocket object and the server
55
* @param {object} props.mediaOptions video embed attributes
66
77
* @desc Wrapper component containing the logic necessary for peer connections using WebRTC APIs (RTCPeerConnect API + MediaSession API) and WebSockets.

dist/src/components/VideoCall.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const rtcConfiguration_1 = __importDefault(require("../constants/rtcConfiguratio
4545
const { LOGIN, ICECANDIDATE, OFFER, ANSWER, LEAVE } = actions_1.default;
4646
/**
4747
* @func VideoCall
48-
* @param {String} props.URL - ws or wss link
48+
* @param {String} props.URL - ws or wss link that establishes a connection between the WebSocket object and the server
4949
* @param {object} props.mediaOptions video embed attributes
5050
5151
* @desc Wrapper component containing the logic necessary for peer connections using WebRTC APIs (RTCPeerConnect API + MediaSession API) and WebSockets.
@@ -67,13 +67,14 @@ const VideoCall = ({ URL, mediaOptions }) => {
6767
/**
6868
* @type {mutable ref WebSocket object} ws is the mutable ref object that contains the WebSocket object in its .current property (ws.current). It cannot be null or undefined.
6969
*
70-
* @desc ws.current property contains the WebSocket object, which is created using the useEffect hook and it establishes the WebSocket connection to the server. The useEffect Hook creates the WebSocket object using the URL parameter when the component mounts and the function openUserMedia() is invoked, which makes a permissions request for the client's video and audio.
70+
* @desc ws.current property contains the WebSocket object, which is created using the useEffect hook and it establishes the WebSocket connection to the server. The useEffect Hook creates the WebSocket object using the URL parameter when the component mounts.
7171
*
7272
* ws.current.send enqueues the specified messages that need to be transmitted to the server over the WebSocket connection and this WebSocket connection is connected to the server by using RTConnect's importable SignalingChannel module.
7373
*/
7474
const ws = (0, react_1.useRef)(null);
7575
/**
7676
* @type {mutable ref object} localVideo - video element of the local user. It will not be null or undefined.
77+
* @property {HTMLVideoElement} localVideo.current
7778
*/
7879
const localVideo = (0, react_1.useRef)(null);
7980
/**
@@ -162,19 +163,23 @@ const VideoCall = ({ URL, mediaOptions }) => {
162163
};
163164
/**
164165
* @function getUser
165-
* @desc When data (the list of connected users) is received from the WebSocketServer/backend, getUser function is invoked and it updates the userList state so that the list of currently connected users can be displayed on the frontend.
166-
* @param {Array<string>} parsedData - data (the array of usernames that are connected) that is returned from backend/WebSocketServer.
167-
* @returns Re-renders the page with the new User List
166+
* @desc When data (the list of connected users) is received from the WebSocketServer, getUser is invoked and it creates div tags to render the names of each of the connected users on the front end.
167+
* @param {Object} parsedData - The object (containing the payload with the array of connected usernames) that is returned from backend/WebSocketServer. parsedData.payload contains the array with the strings of connected usernames
168+
* @returns Re-renders the page with the new list of connected users
168169
*/
169170
const getUsers = (parsedData) => {
170171
const userList = parsedData.payload.map((name, idx) => (react_1.default.createElement("div", { key: idx }, name)));
171172
setUsers(userList);
172173
};
173174
/**
174175
* @async
175-
* @function openUserMedia: Invoked in useEffect Hook. openUserMedia uses the constraints provided Requests the clients' browser permissions to open their webcam and microphone.
176+
* @function openUserMedia is invoked in the useEffect Hook after WebSocket connection is established.
177+
* @desc If the localVideo.current property exists, openUserMedia invokes the MediaDevices interface getUserMedia() method to prompt the clients for audio and video permission.
178+
*
179+
* If clients grant permissions, getUserMedia() uses the video and audio constraints to assign the local MediaStream from the clients' cameras/microphones to the local <video> element.
180+
*
176181
* @param {void}
177-
* @desc If the localVideo.current property exists, the MediaStream from the local camera is assigned to the local video element.
182+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
178183
*/
179184
const openUserMedia = () => __awaiter(void 0, void 0, void 0, function* () {
180185
try {
@@ -251,28 +256,34 @@ const VideoCall = ({ URL, mediaOptions }) => {
251256
}
252257
/**
253258
* @namespace handleReceiveCall
254-
* @function handleReceiveCall - When Peer A (caller) calls Peer B (callee), Peer B receives an Offer from the SignalingChannel and this function is invoked. It creates a new RTCPeerConnection with the Peer A's media attached and an Answer is created. The Answer is then sent back to Peer A through the SignalingChannel.
259+
* @function handleReceiveCall
260+
* @desc When Peer A (caller) calls Peer B (callee), Peer B receives an Offer from the SignalingChannel and this function is invoked. It creates a new RTCPeerConnection with the Peer A's media attached and an Answer is created. The Answer is then sent back to Peer A through the SignalingChannel.
255261
* @returns answerPayload object with ANSWER action type and the local description as the payload is sent via WebSocket.
256262
* @param {Object} data payload object
257263
* @property {string} data.sender is the person making the call
258264
* @property { RTCSessionDescriptionInit object } data.payload object providing the session description and it consists of a string containing a SDP message indicating an Offer from Peer A. This value is an empty string ("") by default and may not be null.
259265
*
260-
* @function createPeer - Creates a new RTCPeerConnection object, which represents a WebRTC connection between the local device and a remote peer and adds event listeners to it
266+
* @function createPeer
267+
* @desc Creates a new RTCPeerConnection object, which represents a WebRTC connection between the local device and a remote peer and adds event listeners to it
261268
* @memberof handleReceiveCall
262269
*
263-
* @function RTCSessionDescription - initializes a RTCSessionDescription object, which consists of a description type indicating which part of the offer/answer negotiation process it describes and of the SDP descriptor of the session.
270+
* @function RTCSessionDescription
271+
* @desc initializes a RTCSessionDescription object, which consists of a description type indicating which part of the offer/answer negotiation process it describes and of the SDP descriptor of the session.
264272
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription
265273
* @memberof handleReceiveCall
266274
*
267-
* @function setRemoteDescription - If Peer B wants to accept the offer, setRemoteDescription() is called to set the RTCSessionDescriptionInit object's remote description to the incoming offer from Peer A. The description specifies the properties of the remote end of the connection, including the media format.
275+
* @function setRemoteDescription
276+
* @desc If Peer B wants to accept the offer, setRemoteDescription() is called to set the RTCSessionDescriptionInit object's remote description to the incoming offer from Peer A. The description specifies the properties of the remote end of the connection, including the media format.
268277
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setRemoteDescription
269278
* @memberof handleReceiveCall
270279
*
271-
* @function createAnswer - Creates an Answer to the Offer received from Peer A during the offer/answer negotiation of a WebRTC connection. The Answer contains information about any media already attached to the session, codecs and options supported by the browser, and any ICE candidates already gathered.
280+
* @function createAnswer
281+
* @desc Creates an Answer to the Offer received from Peer A during the offer/answer negotiation of a WebRTC connection. The Answer contains information about any media already attached to the session, codecs and options supported by the browser, and any ICE candidates already gathered.
272282
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createAnswer
273283
* @memberof handleReceiveCall
274284
*
275-
* @function setLocalDescription - WebRTC selects an appropriate local configuration by invoking setLocalDescription(), which automatically generates an appropriate Answer in response to the received Offer from Peer A. Then we send the Answer through the signaling channel back to Peer A.
285+
* @function setLocalDescription
286+
* @desc WebRTC selects an appropriate local configuration by invoking setLocalDescription(), which automatically generates an appropriate Answer in response to the received Offer from Peer A. Then we send the Answer through the signaling channel back to Peer A.
276287
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setLocalDescription
277288
* @memberof handleReceiveCall
278289
*
@@ -284,8 +295,8 @@ const VideoCall = ({ URL, mediaOptions }) => {
284295
peerRef.current = createPeer(data.sender);
285296
/**
286297
* @type {RTCSessionDescriptionInit object} desc - consists of a description type indicating which part of the answer negotiation process it describes and the SDP descriptor of the session.
287-
* @params {string} desc.type - description type with incoming offer
288-
* @params {string} desc.sdp - string containing a SDP message, the format for describing multimedia communication sessions. SDP contains the codec, source address, and timing information of audio and video
298+
* @property {string} desc.type - description type with incoming offer
299+
* @property {string} desc.sdp - string containing a SDP message, the format for describing multimedia communication sessions. SDP contains the codec, source address, and timing information of audio and video
289300
* @see https://developer.mozilla.org/en-US/docs/Glossary/SDP
290301
*/
291302
const desc = new RTCSessionDescription(data.payload);

dist/src/constants/mediaStreamConstraints.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/**
22
*
3-
* @type {Object} A MediaStreamConstraints object is used when calling getUserMedia() to specify what kinds of tracks
3+
* @type {Object} A MediaStreamConstraints object is used when the openUserMedia function is invoked and it calls the WebRTC API method of getUserMedia() to specify what kinds of tracks
44
* should be included in the returned MediaStream and to establish video and audio constraints for
55
* these tracks' settings.
6-
* @property {object} video - The video constraint provides the constraints that must be met by the video track that is
7-
* included in the returned MediaStream (essentially it gives constraints for the quality of the video
8-
* streams returned by the users's webcams).
6+
* @property {object} video - The video constraint provides the constraints that must be met by the video track that is included in the returned MediaStream (essentially it gives constraints for the quality of the video streams returned by the users's webcams).
97
* @property {object} video.width - video width constraint (min:640, ideal:1920, max:1920)
108
* @property {object} video.height - video height constraint (min:480, ideal:1080, max:1080)
119
* @property {boolean} audio - audio constraint that indicates whether or not an audio track is requested.

dist/src/constants/mediaStreamConstraints.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
/**
44
*
5-
* @type {Object} A MediaStreamConstraints object is used when calling getUserMedia() to specify what kinds of tracks
5+
* @type {Object} A MediaStreamConstraints object is used when the openUserMedia function is invoked and it calls the WebRTC API method of getUserMedia() to specify what kinds of tracks
66
* should be included in the returned MediaStream and to establish video and audio constraints for
77
* these tracks' settings.
8-
* @property {object} video - The video constraint provides the constraints that must be met by the video track that is
9-
* included in the returned MediaStream (essentially it gives constraints for the quality of the video
10-
* streams returned by the users's webcams).
8+
* @property {object} video - The video constraint provides the constraints that must be met by the video track that is included in the returned MediaStream (essentially it gives constraints for the quality of the video streams returned by the users's webcams).
119
* @property {object} video.width - video width constraint (min:640, ideal:1920, max:1920)
1210
* @property {object} video.height - video height constraint (min:480, ideal:1080, max:1080)
1311
* @property {boolean} audio - audio constraint that indicates whether or not an audio track is requested.

0 commit comments

Comments
 (0)