Restrict media zones

Updated

Control and customize video SDK data routing in your app

When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN(R) media zone that is geographically closest to the user. However, to meet the laws and regulations of the user's country, you may need to specify, or filter out connections to a specific geographical zone. Agora enables you to control and customize data routing in your app by specifying the Agora SDRTN(R) media zone users connect to.

This is an advanced feature suitable only for use-cases with access security restrictions.

Understand the tech

After you turn on the restricted media zones feature, the SDK only accesses the Agora server in the specified zone(s), irrespective of the geographical location of the user. As an example, the following table shows the outcome if you specify North America as the access zone, and users connect to Agora SDRTN(R) from North America and China respectively:

Designated access zoneUser's locationZone actually accessed by the SDKUser experience
North AmericaNorth AmericaNorth AmericaNormal
North AmericaChinaNorth AmericaQuality may be affected
  • If a server in the specified zone is not available, the SDK reports an error.
  • Due to cross-regional public internet between the designated zone and the geographical location where the app user is located, the audio and video experience may be affected.

The following figure shows the workflow you implement to restrict access to media zones:

Restrict media zones

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Implement restricted media zones

This section shows you how to restrict access to media zones in your app.

You call the AgoraRTC.setArea method to specify the media zone. By default, the SDK selects the nearest Agora server region to connect to. After you set the media zone, the SDK only connects to Agora servers in the specified zone.

Use one of the following values for areaCode and excludedArea:

  • ASIA: Asia except Mainland China
  • CHINA: Mainland China
  • EUROPE: Europe
  • GLOBAL: Global (Default)
  • INDIA: India
  • JAPAN: Japan
  • NORTH_AMERICA: North America

Refer to the following sample code:

AgoraRTC.setArea('ASIA');

Use the excludedArea parameter to specify a smaller zone to be excluded from a larger zone. Currently, you can only set the larger zone to GLOBAL.

// Exclude Mainland China from media zones
AgoraRTC.setArea({
  areaCode: 'GLOBAL',
  excludedArea: 'CHINA',
});

Reference

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

API reference