Skip to content

Commit fd79fb8

Browse files
authored
Merge pull request #47 from oslabs-beta/doc
Doc
2 parents 461d12a + cef718c commit fd79fb8

File tree

9 files changed

+233
-113
lines changed

9 files changed

+233
-113
lines changed

dist/src/components/VideoCall.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/// <reference types="react" />
22
/**
3+
* @func VideoCall
4+
* @param {String} props.URL - ws or wss link that establishes a connection between the WebSocket object and the server
5+
* @param {object} props.mediaOptions video embed attributes
6+
37
* @desc Wrapper component containing the logic necessary for peer connections using WebRTC APIs (RTCPeerConnect API + MediaSession API) and WebSockets.
48
*
59
* ws, localVideo, remoteVideo, peerRef, localStream, otherUser, senders are all mutable ref objects that are created using the useRef hook. The useRef hook allows you to persist values between renders and it is used to store a mutable value that does NOT cause a re-render when updated.
@@ -11,9 +15,6 @@
1115
* @type {state} username - username state stores the name the client enters. All users (see getUsers) will be able to see an updated list of all other users whenever a new user logs in or leaves.
1216
* @type {state} users - users state is the list of connected users that is rendered on the frontend.
1317
*
14-
* @param {Object} props
15-
* @param {String} props.URL - ws or wss link
16-
* @param {object} props.mediaOptions video embed attributes
1718
* @returns A component that renders two VideoComponents,
1819
*/
1920
declare const VideoCall: ({ URL, mediaOptions }: {

dist/src/components/VideoCall.js

Lines changed: 73 additions & 48 deletions
Large diffs are not rendered by default.

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.

dist/src/utils/Livestream.d.ts

Whitespace-only changes.

dist/src/utils/Livestream.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"use strict";
2+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject
3+
/*
4+
const openUserMedia = async (): Promise<void> => {
5+
try {
6+
if (localVideo.current){
7+
localStream.current = localVideo.current.srcObject = await navigator.mediaDevices.getUserMedia(constraints);
8+
}
9+
} catch (error) {
10+
console.log('Error in openUserMedia: ', error);
11+
}
12+
};
13+
14+
15+
// In this example, a MediaStream from a camera is assigned to a newly-created <video> element.
16+
const mediaStream = await navigator.mediaDevices.getUserMedia({video: true});
17+
const video = document.createElement('video');
18+
video.srcObject = mediaStream;
19+
20+
21+
// In this example, a new MediaSource is assigned to a newly-created <video> element.
22+
const mediaSource = new MediaSource();
23+
const video = document.createElement('video');
24+
video.srcObject = mediaSource;
25+
26+
// First, a MediaStream from a camera is assigned to a newly-created <video> element, with fallback for older browsers.
27+
const mediaStream = await navigator.mediaDevices.getUserMedia({video: true});
28+
const video = document.createElement('video');
29+
if ('srcObject' in video) {
30+
video.srcObject = mediaStream;
31+
} else {
32+
// Avoid using this in new browsers, as it is going away.
33+
video.src = URL.createObjectURL(mediaStream);
34+
}
35+
*/

0 commit comments

Comments
 (0)