Skip to content

Commit 655d8a2

Browse files
author
Kevin Le Goff
committed
Rewamp the isReceiving section
1 parent 775affb commit 655d8a2

File tree

1 file changed

+68
-26
lines changed

1 file changed

+68
-26
lines changed

articles/communication-services/how-tos/calling-sdk/includes/manage-video/manage-video-web.md

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ console.log(result.video);
165165
166166
To place a video call, you have to enumerate local cameras by using the `getCameras()` method in `deviceManager`.
167167

168-
After you select a camera, use it to construct a `LocalVideoStream` instance. Pass it within `videoOptions` as an item within the `localVideoStream` array to the `startCall` method.
168+
After you select a camera, use it to construct a `LocalVideoStream` instance.
169+
Pass it within `videoOptions` as an item within the `localVideoStream` array to the `CallAgent` `startCall` method.
169170

170171
```js
171172
const deviceManager = await callClient.getDeviceManager();
@@ -181,7 +182,11 @@ const call = callAgent.startCall([userCallee], placeCallOptions);
181182

182183
## Start and stop sending local video while on a call
183184

184-
To start a video while on a call, you have to enumerate cameras using the `getCameras` method on the `deviceManager` object. Then create a new instance of `LocalVideoStream` with the desired camera and then pass the `LocalVideoStream` object into the `startVideo` method of an existing call object:
185+
186+
### Start video
187+
To start a video while on a call, you have to enumerate cameras using the `getCameras` method on the `deviceManager` object.
188+
Then create a new instance of `LocalVideoStream` with the desired camera and then pass the `LocalVideoStream`
189+
object into the `startVideo` method of an existing call object:
185190

186191
```js
187192
const deviceManager = await callClient.getDeviceManager();
@@ -191,19 +196,25 @@ const localVideoStream = new LocalVideoStream(camera);
191196
await call.startVideo(localVideoStream);
192197
```
193198

194-
After you successfully start sending video, a `LocalVideoStream` instance of type `Video` is added to the `localVideoStreams` collection on a call instance.
195199

200+
### Stop Video
201+
202+
After you successfully start sending video, a `LocalVideoStream` instance of type `Video` is added to the `localVideoStreams`
203+
collection on a call instance.
204+
205+
**Find the video stream in the Call object**
196206
```js
197207
const localVideoStream = call.localVideoStreams.find( (stream) => { return stream.mediaStreamType === 'Video'} );
198208
```
199209

200-
To stop local video while on a call, pass the `localVideoStream` instance that's being used for video:
210+
**Stop the local video**
211+
To stop local video while on a call, pass the `localVideoStream` instance that's being used for video to the stopVideo method of the `Call`:
201212

202213
```js
203214
await call.stopVideo(localVideoStream);
204215
```
205216

206-
You can switch to a different camera device while a video is sending by invoking `switchSource` on a `localVideoStream` instance:
217+
You can switch to a different camera device while having an active LocalVideoStream by invoking `switchSource` on that `LocalVideoStream` instance:
207218

208219
```js
209220
const cameras = await callClient.getDeviceManager().getCameras();
@@ -212,11 +223,11 @@ localVideoStream.switchSource(camera);
212223
```
213224

214225
If the specified video device is being used by another process, or if it is not enabled in the system:
215-
- While in a call, if your video is off and you start video using `call.startVideo()`, this method throws a `SourceUnavailableError` and `cameraStartFiled` user facing diagnostic is set to true.
226+
- While in a call, if your video is off and you start video using `call.startVideo()`, this method throws a `SourceUnavailableError` and `cameraStartFailed` user facing diagnostic is set to true.
216227
- A call to the `localVideoStream.switchSource()` method causes `cameraStartFailed` to be set to true.
217228
Our Call Diagnostics guide provides additional information on how to diagnose call related issues.
218229

219-
To verify if the local video is on or off you can use isLocalVideoStarted API, which returns true or false:
230+
To verify if the local video is on or off you can use the `Call` method `isLocalVideoStarted`, which returns true or false:
220231
```js
221232
// Check if local video is on or off
222233
call.isLocalVideoStarted;
@@ -234,26 +245,29 @@ call.off('isLocalVideoStartedChanged', () => {
234245
});
235246
```
236247

237-
238-
239248
## Start and stop screen sharing while on a call
240-
To start screen sharing while on a call, you can use asynchronous API startScreenSharing:
249+
To start screen sharing while on a call, you can use the asynchronous method `startScreenSharing()` on a `Call` object:
250+
251+
### Start screen sharing
241252
```js
242253
// Start screen sharing
243254
await call.startScreenSharing();
244255
```
245256

257+
### Find the screen sharing in the collection of LocalVideoStream
246258
After you successfully start sending screen sharing, a `LocalVideoStream` instance of type `ScreenSharing`, is added to the `localVideoStreams` collection on the call instance.
247259
```js
248260
const localVideoStream = call.localVideoStreams.find( (stream) => { return stream.mediaStreamType === 'ScreenSharing'} );
249261
```
250262

263+
### Stop screen sharing
251264
To stop screen sharing while on a call, you can use asynchronous API stoptScreenSharing:
252265
```js
253266
// Stop screen sharing
254267
await call.stopScreenSharing();
255268
```
256269

270+
### Check the screen sharing status
257271
To verify if screen sharing is on or off, you can use isScreenSharingOn API, which returns true or false:
258272
```js
259273
// Check if screen sharing is on or off
@@ -274,8 +288,11 @@ call.off('isScreenSharingOnChanged', () => {
274288

275289
[!INCLUDE [Public Preview Disclaimer](../../../../includes/public-preview-include.md)]
276290
Local screen share preview is in public preview and available as part of version 1.15.1-beta.1+.
291+
277292
### Local screen share preview
278-
You can use `VideoStreamRenderer` to begin rendering streams from your local screen share so you can see what you are sending as a screen sharing stream.
293+
294+
You can use a `VideoStreamRenderer` to begin rendering streams from your local screen share so you can see
295+
what you are sending as a screen sharing stream.
279296
```js
280297
// To start viewing local screen share preview
281298
await call.startScreenSharing();
@@ -303,23 +320,32 @@ call.on('isScreenSharingOnChanged', () => {
303320

304321
## Render remote participant video/screensharing streams
305322

306-
To list the video streams and screen sharing streams of remote participants, inspect the `videoStreams` collections:
323+
<!-- To list the video streams and screen sharing streams of remote participants, inspect the `videoStreams` collections:
324+
-->
325+
The to render a remote participant video or screensharing, the first step is to get a reference on the RemoteVideoStream you want to render.
326+
This can be done by going through the array or video stream (`videoStreams`) of the `RemoteParticipant`. The remote particpant collection
327+
is accessed via the `Call` object.
307328

308329
```js
309330
const remoteVideoStream: RemoteVideoStream = call.remoteParticipants[0].videoStreams[0];
310331
const streamType: MediaStreamType = remoteVideoStream.mediaStreamType;
311332
```
312333

313-
To render `RemoteVideoStream`, you have to subscribe to its `isAvailableChanged` event. If the `isAvailable` property changes to `true`, a remote participant is sending a stream. After that happens, create a new instance of `VideoStreamRenderer`, and then create a new `VideoStreamRendererView` instance by using the asynchronous `createView` method. You can then attach `view.target` to any UI element.
334+
To render `RemoteVideoStream`, you have to subscribe to its `isAvailableChanged` event. If the `isAvailable` property changes to `true`,
335+
a remote participant is sending a video stream.
336+
After that happens, create a new instance of `VideoStreamRenderer`, and then create a new `VideoStreamRendererView`
337+
instance by using the asynchronous `createView` method.
338+
You can then attach `view.target` to any UI element.
314339

315-
Whenever availability of a remote stream changes, you can destroy the whole `VideoStreamRenderer` or a specific `VideoStreamRendererView`. If you do decided to keep them, then the view displays a blank video frame.
340+
Whenever the availability of a remote stream changes, you can destroy the whole `VideoStreamRenderer` or
341+
a specific `VideoStreamRendererView`. If you do decided to keep them, then the view displays a blank video frame.
316342

317343
```js
318344
// Reference to the html's div where we would display a grid of all remote video stream from all participants.
319345
let remoteVideosGallery = document.getElementById('remoteVideosGallery');
320346

321347
subscribeToRemoteVideoStream = async (remoteVideoStream) => {
322-
let renderer = new VideoStreamRenderer(remoteVideoStream);
348+
let renderer = new VideoStreamRenderer(remoteVideoStream);
323349
let view;
324350
let remoteVideoContainer = document.createElement('div');
325351
remoteVideoContainer.className = 'remote-video-container';
@@ -415,10 +441,17 @@ CSS for styling the loading spinner over the remote video stream.
415441

416442
### Remote video quality
417443

418-
The Azure Communication Services WebJS SDK, starting in version [1.15.1](https://github.com/Azure/Communication/blob/master/releasenotes/acs-javascript-calling-library-release-notes.md#1153-stable-2023-08-18), provides a feature called Optimal Video Count (OVC). This feature can be used to inform applications at run-time how many incoming videos from different participants can be optimally rendered at a given moment in a group call (2+ participants). This feature exposes a property `optimalVideoCount` that is dynamically changing during the call based on the network and hardware capabilities of a local endpoint. The value of `optimalVideoCount` details how many videos from different participants application should render at a given moment. Applications should handle these changes and update number of rendered videoes accordingly to the recommendation. There's a cooldown period (around 10 s), between updates that to avoid too frequent of changes.
444+
The Azure Communication Services WebJS SDK, provides a feature called Optimal Video Count (OVC), starting in version [1.15.1](https://github.com/Azure/Communication/blob/master/releasenotes/acs-javascript-calling-library-release-notes.md#1153-stable-2023-08-18).
445+
This feature can be used to inform applications at run-time about how many incoming videos from different participants can be optimally rendered at a given moment in a group call (2+ participants).
446+
This feature exposes a property `optimalVideoCount` that is dynamically changing during the call based on the network and
447+
hardware capabilities of a local endpoint. The value of `optimalVideoCount` details how many videos from different participant
448+
application should render at a given moment. Applications should handle these changes and update number of rendered videos
449+
accordingly to the recommendation. There's a debounce period (around 10 s) between each update.
419450

420451
**Usage**
421452
The `optimalVideoCount` feature is a call feature
453+
454+
<!-- TODO KLG convert this to Javascript -->
422455
```typescript
423456
interface OptimalVideoCountCallFeature extends CallFeature {
424457
off(event: 'optimalVideoCountChanged', listener: PropertyChangedEvent): void;
@@ -432,9 +465,8 @@ optimalVideoCountFeature.on('optimalVideoCountChanged', () => {
432465
})
433466
```
434467

435-
Example usage: Application should subscribe to changes of OVC and handle it in group calls by either creating new renderer (`createView` method) or dispose views (`dispose`)
436-
and update layout accordingly either by removing participants from the main call screen area (often called stage or roster ) or replacing their video elements with an avatar and a name of the user.
437-
468+
Example usage: Application should subscribe to changes of Optimal Video Count in group calls. A change in the optimal video count can be handled
469+
by either creating new renderer (`createView` method) or dispose views (`dispose`) and update the application layout accordingly.
438470

439471
### Remote video stream properties
440472

@@ -459,13 +491,23 @@ const isAvailable: boolean = remoteVideoStream.isAvailable;
459491
```
460492

461493
- `isReceiving`:
462-
- Informs the application if remote video stream data is being received or not. Such scenarios are:
463-
- I'm viewing the video of a remote participant who is on mobile browser. The remote participant brings the mobile browser app to the background. I now see the RemoteVideoStream.isReceiving flag goes to false and I see their video with black frames / frozen. When the remote participant brings the mobile browser back to the foreground, I now see the RemoteVideoStream.isReceiving flag to back to true, and I see their video playing normally.
464-
- I'm viewing the video of a remote participant who is on whatever platforms. There are network issues from either side, their video start to have bad quality, probably because of network issues, so I see the RemoteVideoStream.isReceiving flag goes to false.
465-
- I'm viewing the video of a Remote participant who is On macOS/iOS Safari, and from their address bar, they click on "Pause" / "Resume" camera. I see a black/frozen video since they paused their camera and I see the RemoteVideoStream.isReceiving flag goes to false. Once they resume playing the camera, then I see the RemoteVideoStream.isReceiving flag goes to true.
466-
- I'm viewing the video of a remote participant who is on any platform and their network disconnects. The remote participant will stay in the call for about two minutes and I see their video frozen/black frame. The RemoteVideoStream.isReceiving flag goes to false. The remote participant can get network back and reconnect and their audio/video should start flowing normally and I see the RemoteVideoStream.isReceiving flag to true.
467-
- I'm viewing the video of a remote participant who is on mobile browser. The remote participant terminates/kills the mobile browser. Since that remote participant was on mobile, this will actually leave the participant in the call for about two minutes. I will still see them on the call and their video will be frozen. The RemoteVideoStream.isReceiving flag goes to false. At some point, service will kick participant out of the call and I would just see that the participant disconnected from the call.
468-
- I'm viewing the video of a remote participant who is on mobile browser and they lock the device. I see the RemoteVideoStream.isReceiving flag goes to false. Once the remote participant unlocks the device and navigates to the Azure Communication Services call, then I'll see the flag go back to true. Same behavior when remote participant is on desktop and the desktop locks/sleeps
494+
- Informs the application if remote video stream data is being received or not. All scenarios listed assumes the remote partipant is
495+
sharing its video
496+
497+
- The flag moves to `false` in the following scenarios:
498+
- A remote participant who is on mobile browser brings the browser app to the background.
499+
- A remote participant or the user receiving the video has network issue that affects video quality drastically.
500+
- A remote participant who is On macOS/iOS Safari clicks on "Pause" from their address bar.
501+
- A remote participant has a network disconnection.
502+
- A remote particpant on mobile kills or terminate the browser.
503+
- A remote particpant on mobile or desktop locks his device. This scenario applies also if the remote particpant is on a desktop computer and it goes to sleep.
504+
505+
- The flag moves to `true` in the following scenarios:
506+
- A remote participant whos is on mobile browser and has his browser backgrounded brings it back to foreground.
507+
- A remote participant who is On macOS/iOS Safari clicks on "Resume" from their address bar after having paused its video.
508+
- A remote participant has a reconnects to the network after a temporary disconnection.
509+
- A remote participant on mobile unlock his device and return to the call on his mobile browser.
510+
469511
- This feature improves the user experience for rendering remote video streams.
470512
- You can display a loading spinner over the remote video stream when isReceiving flag changes to false. You don't have to do a loading spinner, you can do anything you desire, but a loading spinner is the most common usage for better user experience.
471513
```js

0 commit comments

Comments
 (0)