1. Vonage Learn
  2. Blog
  3. 2021
  4. 05
  5. 24
  6. Best Practices to Get Started With the Vonage Video Api
Best Practices to Get Started With Vonage Video

< Inspiration />

Best Practices to Get Started With Vonage Video

This document describes some of the best practices we recommend for consideration, before you start building your feature-rich video application powered by Vonage Video API. 

Visit our website to set up your new account; it’s free and your account will automatically be credited ten US dollars ($10).

Where to get more help?

Very detailed developer documentation on the Vonage Video API is publicly available on our Video API Developer Site - here you will find all the details you need for basically any question you might have, sample codes, release notes. There is also a great section called “Get answers to your Video API questions”.

To help us better assist you, please send us your feedback via email at: support@tokbox.com

Video Platform

Vonage video uses webRTC for audio-video communications and consists of client libraries for web, IOS and Android, as well as server SDKs and REST API. More information can be found here https://tokbox.com/developer/guides/basics/#opentok-platform.

Key Terms:

  • Session: a logical group of connections and streams. Connections within the same session can exchange messages. Think of a session as the “room” where participants can interact with each other.
  • Connection: an endpoint that participates in a session and is capable of sending and receiving messages. A connection has a presence, it is either connected and can receive messages, or it’s disconnected. 
  • Stream: media stream between two connections. This means that actual bytes containing media are being exchanged. 
  • Publisher: clients publishing stream.
  • Subscriber: clients receiving stream.

Environment

When designing a video application, consider having two environments; one for testing and one for production. To test simple items, you can also use our playground or you can use the OpenTok command-line interface.

For Enterprise server customers, it is important to note that newly added API keys will be using the Standard environment by default. If you need to switch an API key’s environment from Standard to Enterprise, you can do so on our account portal. 

The Enterprise JS SDK is available at https://enterprise.opentok.com/v2/js/opentok.min.js. For more info, visit https://tokbox.com/developer/enterprise/content/enterprise-overview.html.

API key/secret, Tokens and Session IDs

  • API Key and secret

    • Keep secret/key private by NOT exposing them to public repositories.
    • Do NOT save secret/key in client libraries/compiled mobile SDKs.
    • Use HTTPS only to make REST calls.
  • Session ID

    • Always generate a new sessionId for every new session created.  
    • Sessions’ quality scores and data are indexed by sessionId. If there are multiple conversations per sessionId, it will be difficult to debug using Vonage’s inspector tool as reused sessionIds tend to report lower aggregate quality scores than the actual call quality experienced by end-users.
  • Tokens

    • Server that generates tokens must be placed behind a secured/authenticated endpoint
    • Always generate new tokens for each participant
    • Do not store or reuse tokens. 
    • By default, tokens expire after 24 hours, this is checked at connection time. Adjust the expiration as needed, depending on your use case and application. 
    • Add additional information to tokens (using the data parameter) such as usernames or other information that can identify participants, but NEVER use personal information. This will help in troubleshooting.
    • Set roles when applicable such as moderator, publisher and subscriber.
    • More information about tokens can be found at https://tokbox.com/developer/guides/create-token/.

Media Modes

  • Relayed - this media mode does not use Vonage media servers. Before deciding whether to use relayed mode or not, be sure to check the following:

    • That recording is not needed
    • One-to-one session ONLY
    • End-to-end media encryption is required

Note that media quality will not be managed on relayed mode since media is exchanged between clients. Therefore, setting the subscriber's frame rate and/or resolution will not work. See https://tokbox.com/developer/guides/scalable-video/ for more information.

  • Routed - this media mode uses Vonage media servers. Before deciding whether to use routed mode or not, be sure to check the following:

    • Three or more participants
    • May have a need to archive
    • Needs media quality control (audio fallback and video recovery)
    • May have a need to use SIP interconnect
    • May have a need to use interactive or live streaming broadcast

More information about media modes can be found at: https://tokbox.com/developer/guides/create-session/.

Broadcast

  • Interactive - this type of broadcast allows clients to interact with each other by subscribing to each other's stream. Important to note that this type of broadcast can only support up to 3,000 subscribers; anything above that will generate an error message. Below are things to consider when using this broadcast:

    • Contact support and have them enable simulcast. Visit https://support.tokbox.com/hc/en-us/articles/360029733831-TokBox-Scalable-Video-Simulcast-FAQ to learn more about Simulcast. By default Simulcast is set to heuristic in all API keys, this means that Simulcast will only kick in after the third connection joins the call (this is done to avoid Simulcast in one-to-one calls). Important to note that the first two connections won’t use Simulcast if it is set to the heuristic.
    • Allow no more than five publishers. Keep in mind that the maximum number of subscribers will be impacted when streams increase. To get the max subscribers based on the number of publishers, divide the max participants (3,000) by the number of publishers. For example: two publishers can have 1,500 subscribers (3,000 divided by 2).
    • Suppress connection events. 
    • See https://tokbox.com/developer/guides/broadcast/live-interactive-video/for more information
  • Live Streaming - this type of broadcast allows for more than 3,000 subscribers to subscribe to streams. There are two types of protocols available to broadcast video, RTMP (Real Time Messaging Protocol) and HLS (HTTP Live Streaming). Regardless of which one you choose, limit the number of publishers to five for a better experience.

HLS vs RTMP

  • HLS supports an unlimited number of subscribers where RTMP is limited by the RTMP delivery platform
  • HLS is delayed by 15-20 seconds where RTMP, from Vonage’s platform, is delayed by five seconds; this does not include the delay from the RTMP delivery platform however as they too will induce delay based on how they process video.
  • HLS playback is not supported on all browsers but there are plugins that you can use such as flowplayer. Playback allows users to go back, video scrubbing (rewind/fast forward) if you will, from the beginning of the livestream then back to the current live stream.
  • HLS/RTMP has a max duration of two hours. If the broadcast needs to go longer, change the max duration property (max is 10 hours).
  • HLS/RTMP stream automatically stops sixty seconds after the last client disconnects from the session

To learn more about live streaming such as layouts, max duration and how to start/stop the live stream, visit https://tokbox.com/developer/guides/broadcast/live-streaming/.

User Interface/Experience

  • Pre-call Test - add a pre-call test where users’ device and connection will be subject to network and hardware test prior to joining a session. Remember to generate new sessionIDs for every test and let the test run for at least 30 seconds for more accurate results.

  • Audio Fallback - our media server constantly checks network conditions and if it detects an issue with end users’ connection, it will automatically drop the video and continue with audio-only, if packet loss is greater than 15%; and, an event gets sent when this happens. It is recommended that such an event is displayed on the UI alerting impacted users that the quality of their connection dropped, switching to audio-only. The threshold to switch to audio-only is not configurable, more information can be found here. “audioFallbackEnabled (Boolean) — Whether the stream will use the audio-fallback feature (true) or not (false). The audio-fallback feature is available in sessions that use the OpenTok Media Router. With the audio-fallback feature enabled (the default), when the server determines that a stream's quality has degraded significantly for a specific subscriber, it disables the video in that subscriber in order to preserve audio quality. “ --https://tokbox.com/developer/sdks/js/reference/OT.html

  • Reconnecting to session - when a participant suddenly drops from a session due to network-related issues, it will attempt to reconnect back to the session. For a better user’s experience, it is recommended that such events are captured and properly displayed to the UI letting the user know that it is attempting to reconnect back to the session. More information can be found here.

  • Active speaker - for audio-only session, try adding an audio level meter so that participants can have a visual of who the current active speaker/s is/are. For video, try changing the layout where the active speaker gets more screen real estate. You can use the audioLevelUpdated event that gets sent periodically to make UI adjustments, more information can be found here.

  • Loudness detector - It is good practice to implement a loudness detector to identify when a given user who is muted is trying to speak. In this case, the audioLevelUpdated event will fire with audioLevel set to 0. Therefore, it’s necessary to use an AudioContext to avoid this situation.For reference, follow this blog post.

  • Report Issue API - https://tokbox.com/developer/guides/debugging/js/#report-issue. This allows the end consumer of the application to trigger a unique issue ID from the client-side. Our customer can store this issue ID and that can be used when raising a ticket with support. The issue Id will help to identify the unique connection ID that reported the problem and focus the investigation from support.

Features

  • Chat (text messaging) - you can send messages using Vonage’s signaling https://tokbox.com/developer/sdks/js/reference/Session.html#signal, but note that messages are not persistent on Vonage’s video platform. When adding text messaging functionality, keep in mind that some users may arrive/join a session after text messages were sent; latecomers will be unable to view messages that were sent. Additionally, should you decide to record a session, text messages will not be saved. To solve this problem, we recommend using the Nexmo Client SDK (see the sample code, Nexmo in-app messaging, at the end of this document).

  • Archiving - there are two types of offerings when it comes to recording, composed and individual stream. Below talks about the difference between the two and things to consider

    • Composed

    • Individual Stream

      • Can record up to 50 streams
      • Multiple individual streams/files saved in a zip folder
      • Intended for use with a post-processing tool to produce customized content
      • Cannot be started automatically
  • Screen-share - hide the publisher that sharing its screen to avoid the hallway-mirror effect.

    • ContentHint: motion, detail, etc: This flag can and should be set after 2.20.

Storing archives

Vonage will keep copies of archives for 72 hours if uploading fails, if cloud storage has not been configured or if the disable option for storage fallback is not selected. Keep in mind that should you decide to not enable upload fallback and uploading fails for whatever reason, that archives will be not recoverable.

Archiving FAQs:

Important note on Safari browser when using archive - To include video from streams published from Safari clients, you must use a Safari OpenTok project. Otherwise, streams published from Safari show up as audio-only

Quality, Performance and Compatibility

  • Devices - for multi party sessions, try to limit the number of participants as more participants require more processing power. \ See below the number of participants that we recommend:

    • Mobile = 4 (Engineering official statement supported up to 8 MAX)
    • Laptop = 10
    • Desktop = 15
  • For bandwidth requirements please see: What is the minimum bandwidth requirement to use OpenTok?

  • Proxy - if users can only access the internet through a proxy, make sure that it is a “transparent” proxy or it must be configured in the browser for HTTPS connection as webRTC does not work well on proxies requiring authentication. Check out our network check flow.

  • Firewall - at minimum, below are the ports and domains that need to be included on firewalls’ rules:

    • TCP 443
    • FQDN: tokbox.com
    • FQDN: opentok.com
    • STUN/TURN: 3478

If allowed, try opening the following range: UDP 1025 - 65535. This range covers port ranges that will provide users the best experience possible. This will also eliminate the need for TURN; not relaying media through such network elements decreases latency.

  • Codec - link to codec compatibility https://tokbox.com/developer/guides/codecs/. Vonage supports VP9, VP8 and H.264 codecs; however, VP9 is only available on relayed media mode on sessions where ALL participants are using Chrome.\ Difference between VP8 and H.264:

    • VP8 is a software codec, more mature and can handle lower bitrates. Additionally, it supports scalable/simulcast video.
    • H.264 is available as a software or hardware depending on the device. It does not support scalable video or simulcast.

By default, codec is set to VP8. If you need to change the assigned codec for a particular project key, login to your portal to make the change.

Session Monitoring

Addons

It is possible now for Enterprise customers to purchase (or remove) add-ons with a single click. Refer to this presentation slide for the list of add-ons that can be configured via the self-service tool.

Security and Privacy

Vonage Video API can be customized to meet the highest security standards. Our platform is GDPR compliant and we are HIPAA compliant. For European customers, we are offering extended addons that make it possible to comply with additional local certifications and standards, such as KBV certification (Germany) or other privacy laws that aim for better data ownership & protection (Europe-wide).

You can find more about GDPR here: https://www.vonage.com/communications-apis/platform/gdpr/

The Vonage Privacy Policy can be found here: https://www.vonage.com/legal/privacy-policy/

We are also listing all our sub processors here: https://www.vonage.com/communications-apis/platform/gdpr/sub-processors/

In addition, a Data Processing Addendum (DPA) can be found and self-signed on the GDPR page.

On request and under NDA, we can provide further reports such as SOC2 and External Pen Tests that prove the high-security standards of our Video platform.

Calculating monthly usage / Video API tiered pricing

Comments currently disabled.