From 26988b456e97bb24c6b22ccfdd8e4c5f81dd8890 Mon Sep 17 00:00:00 2001 From: Henry Smith <36210679+hensmi-amazon@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:44:53 -0700 Subject: [PATCH] Updated guides and doc-strings to recommend `VideoPriorityBasedPolicy` over `VideoAdaptiveProbePolicy` (#2959) --- CHANGELOG.md | 2 + docs/classes/videoadaptiveprobepolicy.html | 22 +++-- docs/modules/gettingstarted.html | 4 +- .../prioritybased_downlink_policy.html | 54 ++++-------- .../qualitybandwidth_connectivity.html | 12 +-- docs/modules/simulcast.html | 24 +----- guides/01_Getting_Started.md | 2 +- guides/04_Quality_Bandwidth_Connectivity.md | 12 +-- guides/05_Simulcast.md | 29 +------ guides/11_Priority_Based_Downlink_Policy.md | 82 ++++++------------- .../VideoAdaptiveProbePolicy.ts | 19 ++++- 11 files changed, 94 insertions(+), 168 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb1e5943f..78a0b387a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Updated guides and doc-strings to recommend `VideoPriorityBasedPolicy` over `VideoAdaptiveProbePolicy`. + ### Fixed ## [3.24.0] - 2024-07-11 diff --git a/docs/classes/videoadaptiveprobepolicy.html b/docs/classes/videoadaptiveprobepolicy.html index cec35ddc7..f4b97fbb6 100644 --- a/docs/classes/videoadaptiveprobepolicy.html +++ b/docs/classes/videoadaptiveprobepolicy.html @@ -69,8 +69,20 @@

Class VideoAdaptiveProbePolicy

VideoAdaptiveProbePolicy wraps VideoPriorityBasedPolicy with customized behavior to automatically - assign a high preference to content share.

+ assign a high preference to content share. This is a legacy policy used by default when simulcast is enabled, but + all customers should be using VideoPriorityBasedPolicy instead, since this policy does not work with + server side network adaptation.

+

You can imitate this classes behavior using the VideoPriorityBasedPolicy with the following snippet

+
  remoteVideoSourcesDidChange(videoSources: VideoSource[]) {
+    const videoPreferences = VideoPreferences.prepare();
+    for(const source of videoSources) {
+       const isContent = source.attendee.attendeeId.endsWith(ContentShareConstants.Modality);
+       videoPreferences.add(new VideoPreference(source.attendee.attendeeId, isContent ? 2: 1, TargetDisplaySize.High));
+    }
+    this.priorityBasedDownlinkPolicy.chooseRemoteVideoSources(videoPreferences.build());
+  }
+
@@ -150,7 +162,7 @@

constructor

Parameters

@@ -362,7 +374,7 @@

chooseRemoteVideoSources

@@ -563,7 +575,7 @@

reset

@@ -707,7 +719,7 @@

updateIndex

diff --git a/docs/modules/gettingstarted.html b/docs/modules/gettingstarted.html index b2ac93756..d9fe2e2c1 100644 --- a/docs/modules/gettingstarted.html +++ b/docs/modules/gettingstarted.html @@ -72,8 +72,8 @@

Namespace GettingStarted

Getting Started

-

For guidance and examples on how to use the Amazon Chime SDK for JavaScript in your application, see API overview for more information. - Give feedback on this guide

+

For guidance and examples on how to use the Amazon Chime SDK for JavaScript in your application, see API overview for more information.

+

Give feedback on this guide

diff --git a/docs/modules/prioritybased_downlink_policy.html b/docs/modules/prioritybased_downlink_policy.html index 51bca060c..10f38d967 100644 --- a/docs/modules/prioritybased_downlink_policy.html +++ b/docs/modules/prioritybased_downlink_policy.html @@ -81,7 +81,6 @@

User Guide for Priority-based Downlink Policy

  • Priority and max size for each remote stream
  • Configuring the receipt and priority of remote video sources
  • Receiving notifications that a remote video was paused due to bandwidth constraint
  • -
  • Enabling Server Side Network Adaption Features
  • Builder Code Sample
  • @@ -91,15 +90,14 @@

    User Guide for Priority-based Downlink Policy

    Introduction

    -

    Amazon Chime SDK for JavaScript allows builders to choose a downlink policy on each device when joining a meeting. Downlink policies control the way how a recipient subscribes to the remote video sources. This document explains how to use the VideoPriorityBasedPolicy introduced in version 2.8, how it differs from the existing policies and how builders can take advantage of it to meet their use cases.

    -

    Amazon Chime SDK for JavaScript defines VideoPriorityBasedPolicy as the central class providing the ability to request remote video sources to receive and set their respective priorities. The policy ensures bandwidth is reserved for video sources with higher priorities. This policy can be used in conjunction with clients sending simulcast renditions of sources, as well as single stream or mixed environments.

    -

    All new users should enable server side network adaptation features for vastly improved behavior. When server side network adapatation is used, all browsers are supported. Otherwise since previously the policy uses WebRTC's available downlink bandwidth estimation, which is not supported Firefox, it should not be used there.

    -

    The existing AllHighestVideoBandwidthPolicy and AdaptiveProbePolicy both subscribe to a fixed number of available remote video sources. Builders listen to videoTileDidUpdate when a new remote video source becomes available and call pauseVideoTile if they don’t want it to be seen, otherwise video sources will be consumed automatically. VideoPriorityBasedPolicy relies on builders subscribing to AudioVideoObserver.remoteVideoSourcesDidChange to receive updates on available remote sources, and then calling chooseRemoteVideoSources to set which video sources to receive and their related preferences. Note that when using VideoPriorityBasePolicy, if builders do not call chooseRemoteVideoSources, no videos will be subscribed to. videoTileDidUpdate will then be called if we are able to successfully subscribe to the stream.

    -

    Under constrained networks where simulcast is in use, VideoPriorityBasedPolicy may lower the resolution of remote video sources, starting with the lowest priority sources. All video sources are separeted into multiple groups by different priorities. If all video sources within same priority group are at the lowest resolution possible, or simulcast is not being used, the policy may further pause video tiles until the network has recovered. Same operations will be repeated group by group, from priority lowest to highest.

    +

    Amazon Chime SDK for JavaScript allows builders to choose a downlink policy on each device when joining a meeting. Downlink policies control the way how a recipient subscribes to the remote video sources. This document explains how to use the VideoPriorityBasedPolicy introduced in version 2.8, how it differs from the default behavior, and how builders can take advantage of it to meet their use cases.

    +

    Amazon Chime SDK for JavaScript defines VideoPriorityBasedPolicy as the central class providing the ability to request remote video sources to receive and set their respective priorities. The policy ensures bandwidth is reserved for video sources with higher priorities. This policy can be used in conjunction with clients sending simulcast renditions of sources, as well as single stream or mixed environments. All browsers are supported.

    +

    The existing AllHighestVideoBandwidthPolicy automatically subscribes to a fixed number of available remote video sources. VideoPriorityBasedPolicy relies on builders subscribing to AudioVideoObserver.remoteVideoSourcesDidChange to receive updates on available remote sources, and then calling chooseRemoteVideoSources to set which video sources to receive and their related preferences. Note that when using VideoPriorityBasePolicy, if builders do not call chooseRemoteVideoSources, no videos will be subscribed to. videoTileDidUpdate will then be called if we are able to successfully subscribe to the stream.

    +

    It is recommended to enable simulcast or SVC to fully take advantage of the network adaptation capabilities, and to avoid the need to fully pause videos unless under extreme network conditions. When simulcast is in use, VideoPriorityBasedPolicy may lower the resolution of remote video sources in response to network constraints, starting with the lowest priority sources. All video sources are separated into multiple groups by different priorities. If all video sources within same priority group are at the lowest resolution possible, or simulcast is not being used, the policy may further pause video tiles until the network has recovered. Same operations will be repeated group by group, from priority lowest to highest.

    If you want to keep the last frame of the video stream when paused due to insufficient bandwidth, please set MeetingSessionConfiguration.keepLastFrameWhenPaused to true.

    A typical workflow to use this policy would be:

      -
    1. When creating meetingSession.configuration, construct and set a VideoPriorityBasedPolicy object as the videoDownlinkBandwidthPolicy
    2. +
    3. When creating meetingSession.configuration, construct and set a VideoPriorityBasedPolicy object as thevideoDownlinkBandwidthPolicy
    4. Monitor callbacks on AudioVideoObserver.remoteVideoSourcesDidChange to receive updates on available sources.
    5. Update VideoPreference for each video stream and then call chooseRemoteVideoSources
    6. Repeat step 2 as needed to update the desired receiving set of remote sources and their priorities, either due to changes indicated by AudioVideoObserver.remoteVideoSourcesDidChange or other application events (like switching the current page of videos).
    7. @@ -125,64 +123,40 @@

      Priority and max size for each remote stream

    8. priority: Provides relative priority of this attendee from 1 to x, where 1 is the highest priority. Remote videos are allowed to have the same priority signifying equal priority between them.
    9. targetSize: Optional parameter to control maximum simulcast layer to receive.
    10. -

      The default preference set the same priority 1 for all attendees. The target size will be:

      - +

      The default preference set the same priority 1 for all attendees.

      Configuring the receipt and priority of remote video sources

      The main API being used is:

      -
      chooseRemoteVideoSources(sources: VideoPreference[]): void
      +					
      chooseRemoteVideoSources(sources: VideoPreference[]): void
       
      -

      An array of VideoPreference is passed in to specify preference for each remote video. - Be aware of the following when calling this function:

      +

      An array of VideoPreference is passed in to specify preference for each remote video. When calling this function:

      • You must pass a complete array of VideoPreference objects each time you call chooseRemoteVideoSources. Each call overrides the behavior defined by any previous call. The AudioVideoController will unsubscribe from any existing video streams associated with attendee IDs that are not present in the new array. Do not modify the provided array after calling this function; for efficiency, the policy object does not clone the array.
      • Including a remote video stream in this list does not guarantee that the video will be received. If there is insufficient bandwidth then the lowest priority video(s) will be paused and the client will be notified.
      • -
      • A video tile will be created for all requested video streams. If there is insufficient bandwidth to receive the video then the policy will pause it and provide notification with a reason. This is a difference in behavior from the current AdaptiveProbePolicy which removes the tile for this condition.
      • +
      • A video tile will be created for all requested video streams. If there is insufficient bandwidth to receive the video then the policy will pause it and provide notification with a reason.
      • Content share is treated as another video stream**:** Builders will need to specify content video and its priority as well. It will not be auto subscribed to anymore when using priority based downlink policy.
      • Any newly added remote videos (e.g. a new VideoPreference was added to the list) to the list will result in a videoTileDidUpdate event, and any removed remote videos (e.g. a VideoPreference was removed from the list, or an attendee left the meeting) will trigger a videoTileWasRemoved event.
      • Any preferences entries associated with attendee IDs that are paused by the application or no longer available in the call will be ignored until unpaused.
      • The policy may limit how often it updates the list of actual streams it subscribes to.
      -

      (Note that the exact internal behavior of this policy may slightly change in future releases)

      Receiving notifications that a remote video was paused due to bandwidth constraint

      If a remote video source is paused due to insufficient bandwidth, then the application will be notified through tileWillBePausedByDownlinkPolicy by VideoDownlinkObserver and the VideoTileState will be set to paused.

      - -

      Enabling Server Side Network Adaption Features

      -
      -

      VideoPriorityBasedPolicy has support for enabling additional features on the backend related to network adaptation. These features lead to the following improvements relative to the default policy:

      -
        -
      • Faster network constraint response time, e.g. compared to default it will downgrade and pause videos faster to prioritize audio.
      • -
      • Avoidance of video upgrades that cause network overuse. The server side adaptation uses pacing and probing to determine headroom before upgrading videos.
      • -
      • Stable video quality selections under constraint due to a backend calculated bandwidth estimation utilizing transport wide congestion control.
      • -
      • Faster recovery time due to use of pacing and probing on backend.
      • -
      -

      These features are currently opt-in but may become defaults in the future. To enable these features, set the following on VideoPriorityBasedPolicyConfig before injecting:

      -
      const config = new VideoPriorityBasedPolicyConfig;
      -config.serverSideNetworkAdaption = 
      -    ServerSideNetworkAdaption.BandwidthProbingAndRemoteVideoQualityAdaption;
      -let priorityBasedDownlinkPolicy = 
      -    new VideoPriorityBasedPolicy(this.meetingLogger, config);
      -

      Builder Code Sample

      Below, we are going to show one potential use case, “featured video”, that can be built on top of this policy. A video tile can be featured by clicking a “Pin” button on it and its priority will be set to 1 whereas the rest unpinned tiles are set to 2 by default. The pinned tile will be displayed in a larger size and will not be paused/downgraded (if simulcast uplink policy being enabled on the remote side) until all of the rest are when encountering network constraint.

      First create an instance of VideoPriorityBasedPolicy that you will share with the meeting session. Then create a meeting session configuration and set videoDownlinkBandwidthPolicy to that created policy.

      -
      // `meetingLogger: Logger` created elsewhere
      +					
      // `meetingLogger: Logger` created elsewhere
       const priorityBasedDownlinkPolicy = new VideoPriorityBasedPolicy(meetingLogger);
       // `configuration: MeetingSessionConfiguration` created elsewhere
       configuration.videoDownlinkBandwidthPolicy = priorityBasedDownlinkPolicy;
       

      Once connected to the meeting, we can an observer on remoteVideoSourcesDidChange and keep track of if which clients in the roster list are publishing video.

      -
        // Assumes we are storing roster in a member variable like `roster: any = {};`
      +					
        // Assumes we are storing roster in a member variable like `roster: any = {};`
         remoteVideoSourcesDidChange(videoSources: VideoSource[]) {
           // Reset current hasVideo flag in roster list
           for (const attendeeId in this.roster) {
      @@ -200,7 +174,7 @@ 

      Builder Code Sample

      }

      We can then add a pin button to our application, and wire it up to change the priority of the respective video. Update the tile button click callback to set or unset the pin status.

      -
          pinButtonElement.addEventListener('click', () => {
      +					
          pinButtonElement.addEventListener('click', () => {
             // Get the attendeeID associated with this tile
             const attendeeId = tileState.boundAttendeeId;
             // Change pin state
      @@ -213,8 +187,8 @@ 

      Builder Code Sample

      });

      We can then write updateDownlinkPreference which is shared by the above two snippets. This logic simply sets featured tiles to priority 1 and all others to priority 2. This will ensure featured tiles are requested first at the highest resolution allowed by bandwidth and other participants are requested as bandwidth allows. To store the VideoPreference objects we use VideoPreferences, a set like data structure that allows efficient modification of an existing list while only copying when necessary.

      -
        updateDownlinkPreference(): void {
      -    const videoPreferences: MutableVideoPreferences = VideoPreferences.prepare();
      +					
        updateDownlinkPreference(): void {
      +    const videoPreferences = VideoPreferences.prepare();
           for (const attendeeId in this.roster) {
             if (this.roster[attendeeId].hasVideo) {
               // Make pinned videos of equal high importance and the rest as secondary
      diff --git a/docs/modules/qualitybandwidth_connectivity.html b/docs/modules/qualitybandwidth_connectivity.html
      index 84a53cdd7..992ecc00d 100644
      --- a/docs/modules/qualitybandwidth_connectivity.html
      +++ b/docs/modules/qualitybandwidth_connectivity.html
      @@ -96,7 +96,6 @@ 

      Quality, Bandwidth, and Connectivity

    11. Adjust local video quality
    12. Turning off local video
    13. Configure a video uplink policy
    14. -
    15. Pause remote attendee video
    16. Use active speaker detection
    17. Configure a video downlink policy
    18. @@ -305,10 +304,6 @@

      Turning off local video

      Configure a video uplink policy

      The SDK by default uses the NScaleVideoUplinkBandwidthPolicy which monitors number of participants in the meeting and automatically scales down the maxBandwidthKbps as the number of remote video tiles increases. This can be customized by implementing a VideoUplinkBandwidth Policy and setting it in the MeetingSessionConfiguration class.

      - -

      Pause remote attendee video

      -
      -

      When more video is being received than available estimated downlink bandwidth can support, the event videoNotReceivingEnoughData can is triggered with a list of attendee IDs and the bandwidth being consumed due to them. You can use this information to selectively pause attendees that are sending the highest bitrate video streams using pauseVideoTile. When a video tile is paused, the action only affects your client. It does not pause the video for other attendees.

      Use active speaker detection

      @@ -316,14 +311,13 @@

      Use active speaker detection

      Configure a video downlink policy

      -

      By default the SDK uses the AllHighestVideoBandwidthPolicy, but VideoAdaptiveProbePolicy is used if simulcast is enabled. AllHighestVideoBandwidthPolicy subscribes to the highest quality video of all participants and VideoAdaptiveProbePolicy tries to subscribe to videos based on the browser downlink estimate, dropping videos in case of not enough bandwidth.

      +

      By default the SDK uses the AllHighestVideoBandwidthPolicy which will not adapt to local receive network conditions and always subscribes to the highest quality video of all participant, but VideoPriorityBasedPolicy will downgrade or pause videos in response to network constraints. Additional configuration of that policy is required to select which remote videos to subscribe to, see the guide for more information. Downgrades are only possible if simulcast or SVC is enabled.

      You can customize the default downlink policy by setting the VideoDownlinkBandwidthPolicy in MeetingSessionConfiguration class.

      -

      Browser clients currently only send one stream resolution. You would only need to use this function if you were also using the Amazon Chime SDK for iOS or the Amazon Chime SDK for Android.

      Use video simulcast

      -

      Simulcast is a standardized technique in WebRTC to enhance video quality in a multi-party call. Amazon Chime SDK for JavaScript provides a video simulcast solution for Chromium-based browsers. To use simulcast, please refer to the documentation here. - Give feedback on this guide

      +

      Simulcast is a standardized technique in WebRTC to enhance video quality in a multi-party call. Amazon Chime SDK for JavaScript provides a video simulcast solution for Chromium-based browsers. To use simulcast, please refer to the documentation here.

      +

      Give feedback on this guide

      diff --git a/docs/modules/simulcast.html b/docs/modules/simulcast.html index 3487434f1..484a17a0e 100644 --- a/docs/modules/simulcast.html +++ b/docs/modules/simulcast.html @@ -75,8 +75,7 @@

      Video Simulcast

      In multi-party video calls, attendees can enable the simulcast feature to enhance the overall video quality. Simulcast is a standardized technique where the video publishers create multiple renditions, or layers, of the same video source and video subscribers have the flexibility to choose the rendition that best fits their needs based on such factors as available bandwidth, compute and screen size. The uplink policy controls the configuration of the renditions through camera capture and encoding parameters. The simulcast-enabled uplink policy is SimulcastUplinkPolicy.

      Simulcast is currently disabled by default. To enable it MeetingSessionConfiguration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers must be set. Currently, only Chrome 76 and above is supported.

      -

      The VideoAdaptiveProbePolicy downlink policy adaptively subscribes to the best simulcast layer and is automatically selected if [MeetingSessionConfiguration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers is set to true.

      -

      If you want more fine-grained control of which simulcast layer to subscribe, please use VideoPriorityBasedPolicy. More details about priority-based downlink policy can be +

      When enabling simulcast, you should use VideoPriorityBasedPolicy to allow switching between layers in response to application use-cases or network adaptation. More details about priority-based downlink policy can be found here.

      • Video Simulcast
          @@ -162,21 +161,6 @@

          Simulcast resolutions and behavior

          The table entries represent the maximum configuration. When CPU and bandwidth consumption is overused, WebRTC will dynamically adjust bitrate, disable a layer or scale down resolution. The SimulcastUplinkPolicy has a monitoring mechanism which tracks the sending status and automatically adjusts without need for application intervention.

          Note that simulcast is disabled when there are only 2 or fewer attendees. This is because WebRTC has additional functionality to request lower bitrates from the remote end, and we will forward these requests if there are no competing receivers (i.e. if the receiving estimates it has 200kbps downlink bandwidth available, this will be sent and relayed in a message to the sending client). Therefore there is no need for simulcast based adaption.

          - -

          Downlink Bandwidth Policy

          -
          -

          The VideoAdaptiveProbePolicy adds functionality to take advantage of video simulcast. The goal of this policy is to leave the complexity of managing the downlink bandwidth and decision of which streams to request inside the SDK and remove that burden from the application. The policy monitors numerous pieces of information and uses that to determine which streams to subscribe to. The data considered are:

          -
            -
          1. Message from infrastructure enumerating video streams from each remote client
          2. -
          3. Estimated downlink bandwidth from WebRTC library
          4. -
          5. Media metrics such as packet loss and used bandwidth
          6. -
          7. Stream type - Screen share or camera device
          8. -
          -

          The policy works by listening to any changes in the information listed above. Anytime there is a change it re-evaluates the best mix of remote videos to fit within the target downlink bandwidth. The policy is currently configured to try to request as many remote clients as possible, then increase resolution where possible. It prioritizes screen share video above people video. If there is insufficient bandwidth to request all far participants then only a certain number will be seen.

          -

          Applications will receive notifications of remote video being added or removed through the videoTileDidUpdate and videoTileWasRemoved callbacks. You can use encodingSimulcastLayersDidChange to know when the selected upstream simulcast resolutions change.

          -

          If the application pauses a remote video by calling pauseVideoTile, then this policy will not include that remote video in the list of available streams and therefore will not automatically subscribe or unsubscribe from it while it is in the paused state.

          -

          When using the policy it is recommended that applications do not take action on the downlink monitoring metrics from metricsDidReceive since it may conflict with decisions being made within the policy.

          -

          The VideoAdaptiveProbePolicy can be used with or without simulcast. To enable it without simulcast set the MeetingSessionConfiguration.videoDownlinkBandwidthPolicy to VideoAdaptiveProbePolicy. If simulcast is not active, then the policy will only be able to add or remove remote videos.

          Creating a simulcast enabled meeting

          @@ -203,8 +187,8 @@

          Creating a simulcast enabled meeting

          in the created MeetingSessionConfiguration.

          configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers = true;
           
          -//Specify the apdative probe downlink policy
          -configuration.videoDownlinkBandwidthPolicy = new VideoAdaptiveProbePolicy(logger);
          +// Specify the apdative probe downlink policy
          +configuration.videoDownlinkBandwidthPolicy = new VideoPriorityBasedPolicy(logger);
           

          Now create a meeting session with the simulcast enabled meeting session configuration.

          // In the examples below, you will use this meetingSession object.
          @@ -214,7 +198,7 @@ 

          Creating a simulcast enabled meeting

          deviceController );
          -

          This meetingSession is now simulcast enabled and will have the videoUplinkBandwidthPolicy set to DefaultSimulcastUplinkPolicy and videoDownlinkBandwidthPolicy set to VideoAdaptiveProbePolicy. Due to these policies, the local and remote video resolutions may change. The video resolution depends on the available simulcast streams. The available simlucast streams are dependent on the number of attendees and the current bandwidth estimations. Check "Simulcast resolutions and behavior" section in this guide for more information.

          +

          This meetingSession is now simulcast enabled and will have the videoUplinkBandwidthPolicy set to DefaultSimulcastUplinkPolicy. Due to these policies, the local and remote video resolutions may change. The video resolution depends on the available simulcast streams. The available simlucast streams are dependent on the number of attendees and the current bandwidth estimations. Check "Simulcast resolutions and behavior" section in this guide for more information.

          Receive upstream simulcast layer change notification

          diff --git a/guides/01_Getting_Started.md b/guides/01_Getting_Started.md index 88806fd40..ca1a3300c 100644 --- a/guides/01_Getting_Started.md +++ b/guides/01_Getting_Started.md @@ -1,3 +1,3 @@ # Getting Started -For guidance and examples on how to use the Amazon Chime SDK for JavaScript in your application, see [API overview](https://aws.github.io/amazon-chime-sdk-js/modules/apioverview.html) for more information. \ No newline at end of file +For guidance and examples on how to use the Amazon Chime SDK for JavaScript in your application, see [API overview](https://aws.github.io/amazon-chime-sdk-js/modules/apioverview.html) for more information. diff --git a/guides/04_Quality_Bandwidth_Connectivity.md b/guides/04_Quality_Bandwidth_Connectivity.md index e9e0c9e31..3233ed592 100644 --- a/guides/04_Quality_Bandwidth_Connectivity.md +++ b/guides/04_Quality_Bandwidth_Connectivity.md @@ -20,7 +20,6 @@ The Amazon Chime SDK for JavaScript, in conjunction with WebRTC, allows you to c - [Adjust local video quality](#adjust-local-video-quality) - [Turning off local video](#turning-off-local-video) - [Configure a video uplink policy](#configure-a-video-uplink-policy) - - [Pause remote attendee video](#pause-remote-attendee-video) - [Use active speaker detection](#use-active-speaker-detection) - [Configure a video downlink policy](#configure-a-video-downlink-policy) - [Use video simulcast](#use-video-simulcast) @@ -119,6 +118,7 @@ In the absence of packet loss, keep in mind that the sender uplink and receiver You can choose a video quality of up to 1280x720 (720p) at 30 fps using [chooseVideoInputQuality(width, height, frameRate)](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideofacade.html#choosevideoinputquality) and [setVideoMaxBandwidthKbps(maxBandwidthKbps)](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideofacade.html#setvideomaxbandwidthkbps) APIs before the meeting session begins. However, in some cases it is not necessary to send the highest quality and you can use a lower values. For example, if the size of the video tile is small then the highest quality may not be worth the additional bandwidth and CPU overhead. Example: + ```js // 360p meetingSession.audioVideo.chooseVideoInputQuality(640, 360, 15); @@ -157,22 +157,16 @@ You can also observe the [connectionDidSuggestStopVideo](https://aws.github.io/a The SDK by default uses the [NScaleVideoUplinkBandwidthPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/nscalevideouplinkbandwidthpolicy.html) which monitors number of participants in the meeting and automatically scales down the maxBandwidthKbps as the number of remote video tiles increases. This can be customized by implementing a [VideoUplinkBandwidth Policy](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#videouplinkbandwidthpolicy) and setting it in the [MeetingSessionConfiguration](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#videouplinkbandwidthpolicy) class. -#### Pause remote attendee video - -When more video is being received than available estimated downlink bandwidth can support, the event [videoNotReceivingEnoughData](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideoobserver.html#videonotreceivingenoughdata) can is triggered with a list of attendee IDs and the bandwidth being consumed due to them. You can use this information to selectively pause attendees that are sending the highest bitrate video streams using [pauseVideoTile](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideofacade.html#pausevideotile). When a video tile is paused, the action only affects your client. It does not pause the video for other attendees. - #### Use active speaker detection You can use the [active speaker detector](https://aws.github.io/amazon-chime-sdk-js/modules/apioverview.html#5d-subscribe-to-an-active-speaker-detector-optional) to show only the video of the active speakers and pause other videos. #### Configure a video downlink policy -By default the SDK uses the [AllHighestVideoBandwidthPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/allhighestvideobandwidthpolicy.html), but [VideoAdaptiveProbePolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoadaptiveprobepolicy.html) is used if simulcast is enabled. [AllHighestVideoBandwidthPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/allhighestvideobandwidthpolicy.html) subscribes to the highest quality video of all participants and [VideoAdaptiveProbePolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoadaptiveprobepolicy.html) tries to subscribe to videos based on the browser downlink estimate, dropping videos in case of not enough bandwidth. +By default the SDK uses the [AllHighestVideoBandwidthPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/allhighestvideobandwidthpolicy.html) which will not adapt to local receive network conditions and always subscribes to the highest quality video of all participant, but [VideoPriorityBasedPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoprioritybasedpolicy.html) will downgrade or pause videos in response to network constraints. Additional configuration of that policy is required to select which remote videos to subscribe to, see [the guide](https://aws.github.io/amazon-chime-sdk-js/modules/prioritybased_downlink_policy.html) for more information. Downgrades are only possible if [simulcast or SVC is enabled](https://aws.github.io/amazon-chime-sdk-js/modules/simulcast.html#). You can customize the default downlink policy by setting the [VideoDownlinkBandwidthPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#videodownlinkbandwidthpolicy) in [MeetingSessionConfiguration](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#videodownlinkbandwidthpolicy) class. -*Browser clients currently only send one stream resolution. You would only need to use this function if you were also using the Amazon Chime SDK for iOS or the Amazon Chime SDK for Android.* - ### Use video simulcast -Simulcast is a standardized technique in WebRTC to enhance video quality in a multi-party call. Amazon Chime SDK for JavaScript provides a video simulcast solution for Chromium-based browsers. To use simulcast, please refer to the documentation [here](https://aws.github.io/amazon-chime-sdk-js/modules/simulcast.html#). \ No newline at end of file +Simulcast is a standardized technique in WebRTC to enhance video quality in a multi-party call. Amazon Chime SDK for JavaScript provides a video simulcast solution for Chromium-based browsers. To use simulcast, please refer to the documentation [here](https://aws.github.io/amazon-chime-sdk-js/modules/simulcast.html#). diff --git a/guides/05_Simulcast.md b/guides/05_Simulcast.md index 7a701ad5b..f5ce3bcd4 100644 --- a/guides/05_Simulcast.md +++ b/guides/05_Simulcast.md @@ -5,9 +5,7 @@ The uplink policy controls the configuration of the renditions through camera ca Simulcast is currently disabled by default. To enable it [MeetingSessionConfiguration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#enablesimulcastforunifiedplanchromiumbasedbrowsers) must be set. Currently, only Chrome 76 and above is supported. -The [VideoAdaptiveProbePolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoadaptiveprobepolicy.html) downlink policy adaptively subscribes to the best simulcast layer and is automatically selected if [[MeetingSessionConfiguration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#enablesimulcastforunifiedplanchromiumbasedbrowsers) is set to true. - -If you want more fine-grained control of which simulcast layer to subscribe, please use [VideoPriorityBasedPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoprioritybasedpolicy). More details about priority-based downlink policy can be +When enabling simulcast, you should use [VideoPriorityBasedPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoprioritybasedpolicy) to allow switching between layers in response to application use-cases or network adaptation. More details about priority-based downlink policy can be found [here](https://aws.github.io/amazon-chime-sdk-js/modules/prioritybased_downlink_policy.html). - [Video Simulcast](#video-simulcast) @@ -52,25 +50,6 @@ The table entries represent the maximum configuration. When CPU and bandwidth c Note that simulcast is disabled when there are only 2 or fewer attendees. This is because WebRTC has additional functionality to request lower bitrates from the remote end, and we will forward these requests if there are no competing receivers (i.e. if the receiving estimates it has 200kbps downlink bandwidth available, this will be sent and relayed in a message to the sending client). Therefore there is no need for simulcast based adaption. -### Downlink Bandwidth Policy - -The [VideoAdaptiveProbePolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoadaptiveprobepolicy.html) adds functionality to take advantage of video simulcast. The goal of this policy is to leave the complexity of managing the downlink bandwidth and decision of which streams to request inside the SDK and remove that burden from the application. The policy monitors numerous pieces of information and uses that to determine which streams to subscribe to. The data considered are: - -1. Message from infrastructure enumerating video streams from each remote client -2. Estimated downlink bandwidth from WebRTC library -3. Media metrics such as packet loss and used bandwidth -4. Stream type - Screen share or camera device - -The policy works by listening to any changes in the information listed above. Anytime there is a change it re-evaluates the best mix of remote videos to fit within the target downlink bandwidth. The policy is currently configured to try to request as many remote clients as possible, then increase resolution where possible. It prioritizes screen share video above people video. If there is insufficient bandwidth to request all far participants then only a certain number will be seen. - -Applications will receive notifications of remote video being added or removed through the [videoTileDidUpdate](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideoobserver.html#videotiledidupdate) and [videoTileWasRemoved](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideoobserver.html#videotilewasremoved) callbacks. You can use [encodingSimulcastLayersDidChange](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideoobserver.html#encodingSimulcastLayersDidChange) to know when the selected upstream simulcast resolutions change. - -If the application pauses a remote video by calling [pauseVideoTile](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideofacade.html#pausevideotile), then this policy will not include that remote video in the list of available streams and therefore will not automatically subscribe or unsubscribe from it while it is in the paused state. - -When using the policy it is recommended that applications do not take action on the downlink monitoring metrics from [metricsDidReceive](https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideoobserver.html#metricsdidreceive) since it may conflict with decisions being made within the policy. - -The VideoAdaptiveProbePolicy can be used with or without simulcast. To enable it without simulcast set the [MeetingSessionConfiguration.videoDownlinkBandwidthPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/meetingsessionconfiguration.html#videodownlinkbandwidthpolicy) to [VideoAdaptiveProbePolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoadaptiveprobepolicy.html). If simulcast is not active, then the policy will only be able to add or remove remote videos. - ### Creating a simulcast enabled meeting First, create a meeting session configuration. @@ -101,8 +80,8 @@ in the created [MeetingSessionConfiguration](https://aws.github.io/amazon-chime- ```javascript configuration.enableSimulcastForUnifiedPlanChromiumBasedBrowsers = true; -//Specify the apdative probe downlink policy -configuration.videoDownlinkBandwidthPolicy = new VideoAdaptiveProbePolicy(logger); +// Specify the apdative probe downlink policy +configuration.videoDownlinkBandwidthPolicy = new VideoPriorityBasedPolicy(logger); ``` Now create a meeting session with the simulcast enabled meeting session configuration. @@ -116,7 +95,7 @@ const meetingSession = new DefaultMeetingSession( ); ``` -This `meetingSession` is now simulcast enabled and will have the `videoUplinkBandwidthPolicy` set to [DefaultSimulcastUplinkPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/defaultsimulcastuplinkPolicy.html) and `videoDownlinkBandwidthPolicy` set to [VideoAdaptiveProbePolicy](https://aws.github.io/amazon-chime-sdk-js/classes/videoadaptiveprobepolicy.html). Due to these policies, the local and remote video resolutions may change. The video resolution depends on the available simulcast streams. The available simlucast streams are dependent on the number of attendees and the current bandwidth estimations. Check "Simulcast resolutions and behavior" section in this guide for more information. +This `meetingSession` is now simulcast enabled and will have the `videoUplinkBandwidthPolicy` set to [DefaultSimulcastUplinkPolicy](https://aws.github.io/amazon-chime-sdk-js/classes/defaultsimulcastuplinkPolicy.html). Due to these policies, the local and remote video resolutions may change. The video resolution depends on the available simulcast streams. The available simlucast streams are dependent on the number of attendees and the current bandwidth estimations. Check "Simulcast resolutions and behavior" section in this guide for more information. ### Receive upstream simulcast layer change notification diff --git a/guides/11_Priority_Based_Downlink_Policy.md b/guides/11_Priority_Based_Downlink_Policy.md index 1c5d46d97..a68098495 100644 --- a/guides/11_Priority_Based_Downlink_Policy.md +++ b/guides/11_Priority_Based_Downlink_Policy.md @@ -8,99 +8,71 @@ - [Priority and max size for each remote stream](#priority-and-max-size-for-each-remote-stream) - [Configuring the receipt and priority of remote video sources](#configuring-the-receipt-and-priority-of-remote-video-sources) - [Receiving notifications that a remote video was paused due to bandwidth constraint](#receiving-notifications-that-a-remote-video-was-paused-due-to-bandwidth-constraint) - - [Enabling Server Side Network Adaption Features ](#enabling-server-side-network-adaption-features-) - [Builder Code Sample](#builder-code-sample) - ## Introduction -Amazon Chime SDK for JavaScript allows builders to choose a downlink policy on each device when joining a meeting. Downlink policies control the way how a recipient subscribes to the remote video sources. This document explains how to use the `VideoPriorityBasedPolicy` introduced in version 2.8, how it differs from the existing policies and how builders can take advantage of it to meet their use cases. - -Amazon Chime SDK for JavaScript defines `VideoPriorityBasedPolicy` as the central class providing the ability to request remote video sources to receive and set their respective priorities. The policy ensures bandwidth is reserved for video sources with higher priorities. This policy can be used in conjunction with clients sending simulcast renditions of sources, as well as single stream or mixed environments. +Amazon Chime SDK for JavaScript allows builders to choose a downlink policy on each device when joining a meeting. Downlink policies control the way how a recipient subscribes to the remote video sources. This document explains how to use the `VideoPriorityBasedPolicy` introduced in version 2.8, how it differs from the default behavior, and how builders can take advantage of it to meet their use cases. -All new users should enable [server side network adaptation features](#server-side-network-adaption) for vastly improved behavior. When server side network adapatation is used, all browsers are supported. Otherwise since previously the policy uses WebRTC's available downlink bandwidth estimation, which is not supported Firefox, it should not be used there. +Amazon Chime SDK for JavaScript defines `VideoPriorityBasedPolicy` as the central class providing the ability to request remote video sources to receive and set their respective priorities. The policy ensures bandwidth is reserved for video sources with higher priorities. This policy can be used in conjunction with clients sending simulcast renditions of sources, as well as single stream or mixed environments. All browsers are supported. -The existing `AllHighestVideoBandwidthPolicy` and `AdaptiveProbePolicy` both subscribe to a fixed number of available remote video sources. Builders listen to `videoTileDidUpdate` when a new remote video source becomes available and call `pauseVideoTile` if they don’t want it to be seen, otherwise video sources will be consumed automatically. `VideoPriorityBasedPolicy` relies on builders subscribing to `AudioVideoObserver.remoteVideoSourcesDidChange` to receive updates on available remote sources, and then calling `chooseRemoteVideoSources` to set which video sources to receive and their related preferences. Note that when using `VideoPriorityBasePolicy`, if builders do not call `chooseRemoteVideoSources`, no videos will be subscribed to. `videoTileDidUpdate` will then be called if we are able to successfully subscribe to the stream. +The existing `AllHighestVideoBandwidthPolicy` automatically subscribes to a fixed number of available remote video sources. `VideoPriorityBasedPolicy` relies on builders subscribing to `AudioVideoObserver.remoteVideoSourcesDidChange` to receive updates on available remote sources, and then calling `chooseRemoteVideoSources` to set which video sources to receive and their related preferences. Note that when using `VideoPriorityBasePolicy`, if builders do not call `chooseRemoteVideoSources`, no videos will be subscribed to. `videoTileDidUpdate` will then be called if we are able to successfully subscribe to the stream. -Under constrained networks where simulcast is in use, `VideoPriorityBasedPolicy` may lower the resolution of remote video sources, starting with the lowest priority sources. All video sources are separeted into multiple groups by different priorities. If all video sources within same priority group are at the lowest resolution possible, or simulcast is not being used, the policy may further pause video tiles until the network has recovered. Same operations will be repeated group by group, from priority lowest to highest. +It is recommended to enable simulcast or SVC to fully take advantage of the network adaptation capabilities, and to avoid the need to fully pause videos unless under extreme network conditions. When simulcast is in use, `VideoPriorityBasedPolicy` may lower the resolution of remote video sources in response to network constraints, starting with the lowest priority sources. All video sources are separated into multiple groups by different priorities. If all video sources within same priority group are at the lowest resolution possible, or simulcast is not being used, the policy may further pause video tiles until the network has recovered. Same operations will be repeated group by group, from priority lowest to highest. If you want to keep the last frame of the video stream when paused due to insufficient bandwidth, please set `MeetingSessionConfiguration.keepLastFrameWhenPaused` to true. A typical workflow to use this policy would be: -1. When creating `meetingSession.configuration`, construct and set a `VideoPriorityBasedPolicy` object as the` videoDownlinkBandwidthPolicy` +1. When creating `meetingSession.configuration`, construct and set a `VideoPriorityBasedPolicy` object as the`videoDownlinkBandwidthPolicy` 2. Monitor callbacks on `AudioVideoObserver.remoteVideoSourcesDidChange` to receive updates on available sources. 3. Update `VideoPreference` for each video stream and then call `chooseRemoteVideoSources` 4. Repeat step 2 as needed to update the desired receiving set of remote sources and their priorities, either due to changes indicated by `AudioVideoObserver.remoteVideoSourcesDidChange` or other application events (like switching the current page of videos). - Note that applications still need to handle `videoTileDidUpdate` just as done without the policy. Detailed usage and explanation can be found below. ## APIs and Usage ### MeetingSessionConfiguration -When initializing the meeting, builders can specify the usage of the `VideoPriorityBasedPolicy` by allocating the policy in the application and passing it in through the `MeetingSessionConfiguration` when the meeting session is started. + +When initializing the meeting, builders can specify the usage of the `VideoPriorityBasedPolicy` by allocating the policy in the application and passing it in through the `MeetingSessionConfiguration` when the meeting session is started. ### Notification of current available remote sources + Once you are connected to the meeting, builders will be notified of available remote video sources via the existing `remoteVideoSourcesDidChange` callback. ### Priority and max size for each remote stream + `VideoPreference` is used to contain the priority and size of remote video sources and content share to be received. There are three fields inside the `VideoPreference,` you could find more info for each field below. -* _*attendeeId:*_ The attendee ID this video tile belongs to. Note that screen share video will have a suffix of #content -* _*priority:*_ Provides relative priority of this attendee from 1 to x, where 1 is the highest priority. Remote videos are allowed to have the same priority signifying equal priority between them. -* *_targetSize:_* Optional parameter to control maximum simulcast layer to receive. +- _*attendeeId:*_ The attendee ID this video tile belongs to. Note that screen share video will have a suffix of #content +- _*priority:*_ Provides relative priority of this attendee from 1 to x, where 1 is the highest priority. Remote videos are allowed to have the same priority signifying equal priority between them. +- _*targetSize:*_ Optional parameter to control maximum simulcast layer to receive. -The default preference set the same priority 1 for all attendees. The target size will be: -- High if there are 1-4 videos. -- Medium if there are 5-8 videos. -- Low otherwise. +The default preference set the same priority 1 for all attendees. ### Configuring the receipt and priority of remote video sources The main API being used is: -``` +```typescript chooseRemoteVideoSources(sources: VideoPreference[]): void ``` -An array of `VideoPreference` is passed in to specify preference for each remote video. -Be aware of the following when calling this function: - -* You must pass a complete array of VideoPreference objects each time you call chooseRemoteVideoSources. Each call overrides the behavior defined by any previous call. The AudioVideoController will unsubscribe from any existing video streams associated with attendee IDs that are not present in the new array. Do not modify the provided array after calling this function; for efficiency, the policy object does not clone the array. -* Including a remote video stream in this list does not guarantee that the video will be received. If there is insufficient bandwidth then the lowest priority video(s) will be paused and the client will be notified. -* A video tile will be created for all requested video streams. If there is insufficient bandwidth to receive the video then the policy will pause it and provide notification with a reason. *This is a difference in behavior from the current `AdaptiveProbePolicy` which removes the tile for this condition.* -* Content share is treated as another video stream**:** Builders will need to specify content video and its priority as well. It will not be auto subscribed to anymore when using priority based downlink policy. -* Any newly added remote videos (e.g. a new `VideoPreference` was added to the list) to the list will result in a `videoTileDidUpdate` event, and any removed remote videos (e.g. a `VideoPreference` was removed from the list, or an attendee left the meeting) will trigger a `videoTileWasRemoved` event. -* Any preferences entries associated with attendee IDs that are paused by the application or no longer available in the call will be ignored until unpaused. -* The policy may limit how often it updates the list of actual streams it subscribes to. - -*(Note that the exact internal behavior of this policy may slightly change in future releases)* +An array of `VideoPreference` is passed in to specify preference for each remote video. When calling this function: +- You must pass a complete array of VideoPreference objects each time you call chooseRemoteVideoSources. Each call overrides the behavior defined by any previous call. The AudioVideoController will unsubscribe from any existing video streams associated with attendee IDs that are not present in the new array. Do not modify the provided array after calling this function; for efficiency, the policy object does not clone the array. +- Including a remote video stream in this list does not guarantee that the video will be received. If there is insufficient bandwidth then the lowest priority video(s) will be paused and the client will be notified. +- A video tile will be created for all requested video streams. If there is insufficient bandwidth to receive the video then the policy will pause it and provide notification with a reason. +- Content share is treated as another video stream**:** Builders will need to specify content video and its priority as well. It will not be auto subscribed to anymore when using priority based downlink policy. +- Any newly added remote videos (e.g. a new `VideoPreference` was added to the list) to the list will result in a `videoTileDidUpdate` event, and any removed remote videos (e.g. a `VideoPreference` was removed from the list, or an attendee left the meeting) will trigger a `videoTileWasRemoved` event. +- Any preferences entries associated with attendee IDs that are paused by the application or no longer available in the call will be ignored until unpaused. +- The policy may limit how often it updates the list of actual streams it subscribes to. ### Receiving notifications that a remote video was paused due to bandwidth constraint If a remote video source is paused due to insufficient bandwidth, then the application will be notified through `tileWillBePausedByDownlinkPolicy` by `VideoDownlinkObserver` and the `VideoTileState` will be set to `paused`. -### Enabling Server Side Network Adaption Features - -`VideoPriorityBasedPolicy` has support for enabling additional features on the backend related to network adaptation. These features lead to the following improvements relative to the default policy: - -* Faster network constraint response time, e.g. compared to default it will downgrade and pause videos faster to prioritize audio. -* Avoidance of video upgrades that cause network overuse. The server side adaptation uses pacing and probing to determine headroom before upgrading videos. -* Stable video quality selections under constraint due to a backend calculated bandwidth estimation utilizing transport wide congestion control. -* Faster recovery time due to use of pacing and probing on backend. - -These features are currently opt-in but may become defaults in the future. To enable these features, set the following on `VideoPriorityBasedPolicyConfig` before injecting: - -```ts -const config = new VideoPriorityBasedPolicyConfig; -config.serverSideNetworkAdaption = - ServerSideNetworkAdaption.BandwidthProbingAndRemoteVideoQualityAdaption; -let priorityBasedDownlinkPolicy = - new VideoPriorityBasedPolicy(this.meetingLogger, config); -``` - ## Builder Code Sample Below, we are going to show one potential use case, “featured video”, that can be built on top of this policy. @@ -108,7 +80,7 @@ A video tile can be featured by clicking a “Pin” button on it and its priori First create an instance of `VideoPriorityBasedPolicy` that you will share with the meeting session. Then create a meeting session configuration and set `videoDownlinkBandwidthPolicy` to that created policy. -``` +```js // `meetingLogger: Logger` created elsewhere const priorityBasedDownlinkPolicy = new VideoPriorityBasedPolicy(meetingLogger); // `configuration: MeetingSessionConfiguration` created elsewhere @@ -117,7 +89,7 @@ configuration.videoDownlinkBandwidthPolicy = priorityBasedDownlinkPolicy; Once connected to the meeting, we can an observer on `remoteVideoSourcesDidChange` and keep track of if which clients in the roster list are publishing video. -``` +```js // Assumes we are storing roster in a member variable like `roster: any = {};` remoteVideoSourcesDidChange(videoSources: VideoSource[]) { // Reset current hasVideo flag in roster list @@ -138,7 +110,7 @@ Once connected to the meeting, we can an observer on `remoteVideoSourcesDidChang We can then add a pin button to our application, and wire it up to change the priority of the respective video. Update the tile button `click` callback to set or unset the pin status. -``` +```js pinButtonElement.addEventListener('click', () => { // Get the attendeeID associated with this tile const attendeeId = tileState.boundAttendeeId; @@ -154,9 +126,9 @@ We can then add a pin button to our application, and wire it up to change the pr We can then write `updateDownlinkPreference` which is shared by the above two snippets. This logic simply sets featured tiles to priority `1` and all others to priority `2`. This will ensure featured tiles are requested first at the highest resolution allowed by bandwidth and other participants are requested as bandwidth allows. To store the `VideoPreference` objects we use `VideoPreferences`, a set like data structure that allows efficient modification of an existing list while only copying when necessary. -``` +```js updateDownlinkPreference(): void { - const videoPreferences: MutableVideoPreferences = VideoPreferences.prepare(); + const videoPreferences = VideoPreferences.prepare(); for (const attendeeId in this.roster) { if (this.roster[attendeeId].hasVideo) { // Make pinned videos of equal high importance and the rest as secondary diff --git a/src/videodownlinkbandwidthpolicy/VideoAdaptiveProbePolicy.ts b/src/videodownlinkbandwidthpolicy/VideoAdaptiveProbePolicy.ts index 8c9034766..0fe27c13d 100644 --- a/src/videodownlinkbandwidthpolicy/VideoAdaptiveProbePolicy.ts +++ b/src/videodownlinkbandwidthpolicy/VideoAdaptiveProbePolicy.ts @@ -11,8 +11,23 @@ import { VideoPreferences } from './VideoPreferences'; import VideoPriorityBasedPolicy from './VideoPriorityBasedPolicy'; import VideoPriorityBasedPolicyConfig from './VideoPriorityBasedPolicyConfig'; -/** [[VideoAdaptiveProbePolicy]] wraps [[VideoPriorityBasedPolicy]] with customized behavior to automatically - * assign a high preference to content share. +/** + * [[VideoAdaptiveProbePolicy]] wraps [[VideoPriorityBasedPolicy]] with customized behavior to automatically + * assign a high preference to content share. This is a legacy policy used by default when simulcast is enabled, but + * all customers should be using `VideoPriorityBasedPolicy` instead, since this policy does not work with + * server side network adaptation. + * + * You can imitate this classes behavior using the `VideoPriorityBasedPolicy` with the following snippet + * ``` + * remoteVideoSourcesDidChange(videoSources: VideoSource[]) { + * const videoPreferences = VideoPreferences.prepare(); + * for(const source of videoSources) { + * const isContent = source.attendee.attendeeId.endsWith(ContentShareConstants.Modality); + * videoPreferences.add(new VideoPreference(source.attendee.attendeeId, isContent ? 2: 1, TargetDisplaySize.High)); + * } + * this.priorityBasedDownlinkPolicy.chooseRemoteVideoSources(videoPreferences.build()); + * } + * ``` */ export default class VideoAdaptiveProbePolicy extends VideoPriorityBasedPolicy { private static createConfig(): VideoPriorityBasedPolicyConfig {