Skip to content

Commit f914e53

Browse files
committed
updated jsdoc for handleReceiveCall
1 parent f97447a commit f914e53

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

dist/src/components/VideoCall.js

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,20 @@ const VideoCall = ({ URL, mediaOptions }) => {
181181
}
182182
});
183183
/**
184-
* @desc Constructs a new RTCPeerConnection object that also adds the local client's media tracks to this object.
185-
* @param {string} userID
184+
* @function callUser
185+
* @desc Constructs a new RTCPeerConnection object that also adds the local client's media tracks to this object.
186+
* @param {string} userID
186187
*/
187188
const callUser = (userID) => {
188189
peerRef.current = createPeer(userID);
189190
localStream.current.getTracks().forEach((track) => senders.current.push(peerRef.current.addTrack(track, localStream.current)));
190191
};
191192
/**
192-
* @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
193-
* @param {string} userID
194-
* @returns {RTCPeerConnection} RTCPeerConnection object
195-
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionstatechange_event and other events
193+
* @function createPeer
194+
* @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
195+
* @param {string} userID
196+
* @returns {RTCPeerConnection} RTCPeerConnection object
197+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionstatechange_event and other events
196198
*/
197199
const createPeer = (userID) => {
198200
const peer = new RTCPeerConnection(rtcConfiguration_1.default);
@@ -244,13 +246,44 @@ const VideoCall = ({ URL, mediaOptions }) => {
244246
}).catch(e => console.log(e));
245247
}
246248
/**
247-
* @desc When an offer is received from the SignalingChannel, this function is invoked, creating a new RTCPeerConnection with the local client's media attached and an Answer is created that is then sent back to the original caller through the WebSocket connection.
248-
* @param {RTCSessionDescriptionInit} data
249-
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createAnswer
249+
* @namespace handleReceiveCall
250+
* @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.
251+
* @returns answerPayload object with ANSWER action type and the local description as the payload is sent via WebSocket.
252+
* @param {Object} data payload object
253+
* @property {string} data.sender is the person making the call
254+
* @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.
255+
*
256+
* @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
257+
* @memberof handleReceiveCall
258+
*
259+
* @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.
260+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription
261+
* @memberof handleReceiveCall
262+
*
263+
* @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.
264+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setRemoteDescription
265+
* @memberof handleReceiveCall
266+
*
267+
* @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.
268+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createAnswer
269+
* @memberof handleReceiveCall
270+
*
271+
* @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.
272+
* @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setLocalDescription
273+
* @memberof handleReceiveCall
274+
*
275+
* @returns {Promise} A Promise whose fulfillment handler is called with an RTCSessionDescriptionInit object containing the SDP Answer to be delivered to Peer A.
276+
*
250277
*/
251278
function handleReceiveCall(data) {
252279
otherUser.current = data.sender;
253280
peerRef.current = createPeer(data.sender);
281+
/**
282+
* @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.
283+
* @params {string} desc.type - description type with incoming offer
284+
* @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
285+
* @see https://developer.mozilla.org/en-US/docs/Glossary/SDP
286+
*/
254287
const desc = new RTCSessionDescription(data.payload);
255288
peerRef.current.setRemoteDescription(desc)
256289
.then(() => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "rtc-test-run",
3-
"version": "0.0.59",
2+
"name": "rtconnect",
3+
"version": "0.0.53",
44
"description": "A lightweight React library to set up live streaming and real-time video calls with peers.",
55
"main": "./dist/src/index.js",
66
"types": "./dist/src/index.d.ts",

0 commit comments

Comments
 (0)