# Restrict media zones (/en/realtime-media/broadcast-streaming/build/secure-and-protect-channels/geofencing)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

<_PlatformTabsGroup groupMode="structured" canonicalPlatform="web" platforms="[&#x22;android&#x22;,&#x22;ios&#x22;,&#x22;macos&#x22;,&#x22;windows&#x22;,&#x22;electron&#x22;,&#x22;flutter&#x22;,&#x22;web&#x22;,&#x22;javascript&#x22;,&#x22;react-native&#x22;,&#x22;unity&#x22;,&#x22;unreal&#x22;]" showTabs="true">
  <_PlatformPanel platform="android">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="android" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones]

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

    You specify the access zones by setting the `RtcEngineConfig.mAreaCode` parameter when calling the `create` method to create an `RtcEngine` instance. The available zones are:

    * `AREA_CODE_GLOB`: Global (Default)
    * `AREA_CODE_CN` : Mainland China
    * `AREA_CODE_NA` : North America
    * `AREA_CODE_EU` : Europe
    * `AREA_CODE_AS` : Asia excluding Mainland China
    * `AREA_CODE_JP` : Japan
    * `AREA_CODE_IN` : India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    ### Include a media zone [#include-a-media-zone]

    To limit access to servers in only one zone, such as North America, set `config.mAreaCode = AREA_CODE_NA;` before creating the `RtcEngine` instance:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Initialize the App and join the channel
        private void initializeAndJoinChannel() {
          try {
            RtcEngineConfig config = new RtcEngineConfig();
            config.mAppId = appId;
            config.mContext = mContext;
            config.mEventHandler = mEngineEventHandler.mRtcEventHandler;
            // Restrict access to servers in North America only
            config.mAreaCode = AREA_CODE_NA;
            mRtcEngine = RtcEngine.create(config);
          } catch (Exception e) {
              throw new RuntimeException("Check the error.");
          }
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Initialize the App and join the channel
        private fun initializeAndJoinChannel() {
          try {
            val config = RtcEngineConfig()
            config.mAppId = appId
            config.mContext = mContext
            config.mEventHandler = mEngineEventHandler.mRtcEventHandler
            // Restrict access to servers in North America only
            config.mAreaCode = AREA_CODE_NA
            mRtcEngine = RtcEngine.create(config)
          } catch (e: Exception) {
              throw RuntimeException("Check the error.")
          }
        }
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ### Exclude a media zone [#exclude-a-media-zone]

    To exclude servers in a zone, such as Mainland China, set `config.mAreaCode = AREA_CODE_GLOB ^ AREA_CODE_CN;` before creating the `RtcEngine` instance:

    <CodeBlockTabs defaultValue="java">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="java">
          Java
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="kotlin">
          Kotlin
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="java">
        ```java
        // Initialize the App and join the channel
        private void initializeAndJoinChannel() {
          try {
            RtcEngineConfig config = new RtcEngineConfig();
            config.mAppId = appId;
            config.mContext = mContext;
            config.mEventHandler = mEngineEventHandler.mRtcEventHandler;
            // Exclude Mainland China from access zones
            config.mAreaCode = AREA_CODE_GLOB ^ AREA_CODE_CN;
            mRtcEngine = RtcEngine.create(config);
          } catch (Exception e) {
              throw new RuntimeException("Check the error.");
          }
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="kotlin">
        ```kotlin
        // Initialize the App and join the channel
        private fun initializeAndJoinChannel() {
          try {
            val config = RtcEngineConfig()
            config.mAppId = appId
            config.mContext = mContext
            config.mEventHandler = mEngineEventHandler.mRtcEventHandler
            // Exclude Mainland China from access zones
            config.mAreaCode = AREA_CODE_GLOB xor AREA_CODE_CN
            mRtcEngine = RtcEngine.create(config)
          } catch (e: Exception) {
              throw RuntimeException("Check the error.")
          }
        }
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    ## Reference [#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 [#api-reference]

    * [`create` \[2/2\]](https://api-ref.agora.io/en/video-sdk/android/4.x/API/class_irtcengine.html#api_irtcengine_initialize)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="ios">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="ios" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-1]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-1]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-1]

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

    You specify the access zones by setting the `AgoraRtcEngineConfig.areaCode` parameter when calling the `sharedEngineWithConfig` method to create an instance of `AgoraRtcEngineKit`.

    * `AgoraAreaCodeType.global`: Global (Default)
    * `AgoraAreaCodeType.AS` : Asia except Mainland China
    * `AgoraAreaCodeType.CN` : Mainland China
    * `AgoraAreaCodeType.EUR` : Europe
    * `AgoraAreaCodeType.IN` : India
    * `AgoraAreaCodeType.JP` : Japan
    * `AgoraAreaCodeType.NA` : North America

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    ### Include a media zone [#include-a-media-zone-1]

    To limit access to servers in only one zone, such as North America, set `config.areaCode = .NA` before creating the `AgoraRtcEngineKit` instance.

    ```swift
    // Initialize AgoraEngine
    func initializeAgoraEngine() {
       let config = AgoraRtcEngineConfig()
       // Pass in your App ID
       config.appId = "YourAppId"
       config.channelProfile = .liveBroadcasting
       // Specify access to only servers in North America
       config.areaCode = .NA
       agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
     }
    ```

    ### Exclude a media zone [#exclude-a-media-zone-1]

    To exclude servers in a zone, such as Mainland China, set `config.areaCode = AgoraAreaCodeType(rawValue: AgoraAreaCodeType.global.rawValue ^ AgoraAreaCodeType.CN.rawValue)！` before creating the `AgoraRtcEngineKit` instance.

    ```swift
    // Initialize AgoraEngine
    func initializeAgoraEngine() {
      let config = AgoraRtcEngineConfig()
      // Pass in your App ID
      config.appId = "YourAppId"
      config.channelProfile = .liveBroadcasting
      // Exclude Mainland China from access area
      config.areaCode = AgoraAreaCodeType(rawValue: AgoraAreaCodeType.global.rawValue ^ AgoraAreaCodeType.CN.rawValue)！
      agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
    }
    ```

    ## Reference [#reference-1]

    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 [#api-reference-1]

    * [`areaCode`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agorartcengineconfig/areacode)
    * [`AgoraRtcEngineConfig`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agorartcengineconfig)
    * [`AgoraAreaCodeType`](https://api-ref.agora.io/en/video-sdk/ios/4.x/documentation/agorartckit/agoraareacodetype)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="macos">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="macos" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-2]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-2]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-2]

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

    You specify the access zones by setting the `AgoraRtcEngineConfig.areaCode` parameter when calling the `sharedEngineWithConfig` method to create an instance of `AgoraRtcEngineKit`.

    * `AgoraAreaCodeType.global`: Global (Default)
    * `AgoraAreaCodeType.AS` : Asia except Mainland China
    * `AgoraAreaCodeType.CN` : Mainland China
    * `AgoraAreaCodeType.EUR` : Europe
    * `AgoraAreaCodeType.IN` : India
    * `AgoraAreaCodeType.JP` : Japan
    * `AgoraAreaCodeType.NA` : North America

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    ### Include a media zone [#include-a-media-zone-2]

    To limit access to servers in only one zone, such as North America, set `config.areaCode = .NA` before creating the `AgoraRtcEngineKit` instance.

    ```swift
    // Initialize AgoraEngine
    func initializeAgoraEngine() {
       let config = AgoraRtcEngineConfig()
       // Pass in your App ID
       config.appId = "YourAppId"
       config.channelProfile = .liveBroadcasting
       // Specify access to only servers in North America
       config.areaCode = .NA
       agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
     }
    ```

    ### Exclude a media zone [#exclude-a-media-zone-2]

    To exclude servers in a zone, such as Mainland China, set `config.areaCode = AgoraAreaCodeType(rawValue: AgoraAreaCodeType.global.rawValue ^ AgoraAreaCodeType.CN.rawValue)！` before creating the `AgoraRtcEngineKit` instance.

    ```swift
    // Initialize AgoraEngine
    func initializeAgoraEngine() {
      let config = AgoraRtcEngineConfig()
      // Pass in your App ID
      config.appId = "YourAppId"
      config.channelProfile = .liveBroadcasting
      // Exclude Mainland China from access area
      config.areaCode = AgoraAreaCodeType(rawValue: AgoraAreaCodeType.global.rawValue ^ AgoraAreaCodeType.CN.rawValue)！
      agoraKit = AgoraRtcEngineKit.sharedEngine(with: config, delegate: self)
    }
    ```

    ## Reference [#reference-2]

    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 [#api-reference-2]

    * [`areaCode`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcengineconfig/areacode)
    * [`AgoraRtcEngineConfig`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agorartcengineconfig)
    * [`AgoraAreaCodeType`](https://api-ref.agora.io/en/video-sdk/macos/4.x/documentation/agorartckit/agoraareacodetype)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="windows">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="windows" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-3]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-3]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-3]

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

    You specify the media zone by setting the `context.areaCode` parameter before calling the `initialize` method to create an `IRtcEngine` instance. The available media zones are:

    * `AREA_CODE_GLOB`: Global (Default)
    * `AREA_CODE_CN` : Mainland China
    * `AREA_CODE_NA` : North America
    * `AREA_CODE_EU` : Europe
    * `AREA_CODE_AS` : Asia except Mainland China
    * `AREA_CODE_JP` : Japan
    * `AREA_CODE_IN` : India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    ### Include a media zone [#include-a-media-zone-3]

    To limit access to servers in only one media zone, such as North America, set `context.areaCode = AREA_CODE_NA;` before calling the `initialize` method:

    ```cpp
    // Initialize Agora SDK
    bool CAgoraRegionConnDlg::InitAgora() {
      // Create AgoraRtcEngine instance
      m_rtcEngine = createAgoraRtcEngine();
      if (!m_rtcEngine) {
        m_lstInfo.InsertString(m_lstInfo.GetCount() - 1, _T("createAgoraRtcEngine failed"));
        return false;
      }
      m_eventHandler.SetMsgReceiver(m_hWnd);

      RtcEngineContext context;
      std::string strAppID = GET_APP_ID;
      context.appId = strAppID.c_str();
      CString area_code;
      m_cmbAreaCode.GetWindowText(area_code);

      // Restrict access to servers in North America
      context.areaCode = AREA_CODE_NA;

      // Initialize RtcEngineContext
      int ret = m_rtcEngine->initialize(context);
      if (ret != 0) {
        m_initialize = false;
        CString strInfo;
        strInfo.Format(_T("initialize failed: %d"), ret);
        m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
        return false;
      } else {
        m_initialize = true;
        m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("initialize success"));
      }

      return true;
    }
    ```

    ### Exclude a media zone [#exclude-a-media-zone-3]

    To exclude servers in a region, such as Mainland China, set `context.areaCode = AREA_CODE_GLOB ^ AREA_CODE_CN;` before calling the `initialize` method:

    ```cpp
    // Initialize Agora SDK
    bool CAgoraRegionConnDlg::InitAgora() {
    	// Create AgoraRtcEngine instance
    	m_rtcEngine = createAgoraRtcEngine();
    	if (!m_rtcEngine) {
    		m_lstInfo.InsertString(m_lstInfo.GetCount() - 1,
    		            _T("createAgoraRtcEngine failed"));
    		return false;
    	}
    	m_eventHandler.SetMsgReceiver(m_hWnd);

    	RtcEngineContext context;
    	std::string strAppID = GET_APP_ID;
    	context.appId = strAppID.c_str();
    	CString area_code;
    	m_cmbAreaCode.GetWindowText(area_code);

    	// Exclude Mainland China from access area
      context.areaCode = AREA_CODE_GLOB ^ AREA_CODE_CN;

    	// Initialize RtcEngineContext
    	int ret = m_rtcEngine->initialize(context);
    	if (ret != 0) {
    		m_initialize = false;
    		CString strInfo;
    		strInfo.Format(_T("initialize failed: %d"), ret);
    		m_lstInfo.InsertString(m_lstInfo.GetCount(), strInfo);
    		return false;
    	} else
    		m_initialize = true;
    	m_lstInfo.InsertString(m_lstInfo.GetCount(), _T("initialize success"));
    }
    ```

    ## Reference [#reference-3]

    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 [#api-reference-3]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`RtcEngineContext`](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/class_rtcengineconfig.html)
    * [`AREA_CODE`](https://api-ref.agora.io/en/video-sdk/cpp/4.x/API/enum_areacode.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="electron">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="electron" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-4]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-4]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-4]

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

    By default, the SDK connects to the nearest Agora media zone. Set the `areaCode` parameter when calling the `initialize` method to specify the access zone(s). After you set the access zone, the SDK only connects to Agora servers in the specified zone.

    You can set the `areaCode` to:

    * `AreaCodeGlob`: Global (Default)
    * `AreaCodeCn` : Mainland China
    * `AreaCodeNa` : North America
    * `AreaCodeEu` : Europe
    * `AreaCodeAs` : Asia excluding Mainland China
    * `AreaCodeJp` : Japan
    * `AreaCodeIn` : India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    Refer to the following sample code:

    ```javascript
    // Only connect to the Agora SDRTN® located in North America.
    agoraEngine.initialize(
    {
      appId: appID,
      areaCode: AreaCode.AreaCodeNa
    });
    ```

    ## Reference [#reference-4]

    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 [#api-reference-4]

    * [`RtcEngineContext`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/class_rtcengineconfig.html)
    * [`AreaCode`](https://api-ref.agora.io/en/video-sdk/electron/4.x/API/enum_areacode.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="flutter">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="flutter" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-5]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-5]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-5]

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

    By default, the SDK connects to the nearest Agora server. Set the `areaCode` property of `RtcEngineContext` when calling the `initialize` method to specify the access area. After setting the access zone, the SDK only connects to Agora servers in the specified zone(s).

    You can set the area to:

    * `areaCodeGlob`: Global (Default)
    * `areaCodeCn` : Mainland China
    * `areaCodeNa` : North America
    * `areaCodeEu` : Europe
    * `areaCodeAs` : Asia excluding Mainland China
    * `areaCodeJp` : Japan
    * `areaCodeIn` : India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    Refer to the following sample code:

    ```dart
    // Your app only connects to Agora SDRTN® located in North America.
    await agoraEngine.initialize(RtcEngineContext(
      areaCode: AreaCode.areaCodeNa.value(),
      appId: appId
    ));
    ```

    ## Reference [#reference-5]

    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 [#api-reference-5]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/flutter/6.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`RtcEngineContext`](https://api-ref.agora.io/en/video-sdk/flutter/6.x/API/class_rtcengineconfig.html)
    * [`AreaCode`](https://api-ref.agora.io/en/video-sdk/flutter/6.x/API/enum_areacode.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="web">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="web" />

    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.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-6]

    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 zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-6]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-6]

    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:

    ```javascript
    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`.

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

    ## Reference [#reference-6]

    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 [#api-reference-6]

    * [`setArea`](https://api-ref.agora.io/en/video-sdk/web/4.x/interfaces/iagorartc.html#setarea)
    * [`AREAS`](https://api-ref.agora.io/en/video-sdk/web/4.x/enums/areas.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="javascript">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="javascript" />

    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.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-7]

    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 zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-7]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-7]

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

    By default, the SDK connects to the nearest Agora server. You set the `areaCode` property by calling the `setArea` method to specify the media zone(s). After setting the access zone, the SDK only connects to Agora servers in the specified media zone.

    You can set the area to:

    * `ASIA`: Asia except Mainland China
    * `CHINA`: Mainland China
    * `EUROPE`: European region
    * `GLOBAL`: Global (Default)
    * `INDIA`: India
    * `JAPAN`: Japan
    * `NORTH_AMERICA`: North America

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    Refer to the following sample code:

    ```javascript
    const useMediaZones = () => {
      useEffect(() => {
        AgoraRTC.setArea({
          areaCode: [AREAS.NORTH_AMERICA, AREAS.ASIA],
        });
      }, []);
    };

    function EnableMediaZones() {
      useMediaZones();

      return (
        <div>
          <App />
        </div>
      );
    }
    ```

    ## Reference [#reference-7]

    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 [#api-reference-7]

    * [`setArea`](https://api-ref.agora.io/en/video-sdk/web/4.x/interfaces/iagorartc.html#setarea)
    * [`AREAS`](https://api-ref.agora.io/en/video-sdk/web/4.x/enums/areas.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="react-native">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="react-native" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-8]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-8]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-8]

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

    By default, the SDK connects to the nearest Agora server. Set the `areaCode` property of `RTCEngineContext` before passing it to the `initialize` method. After you set the media zone, the SDK only connects to servers in the specified zone.

    You can set the `areaCode` to:

    * `AreaCodeGlob`: Global (Default)
    * `AreaCodeCn` : Mainland China
    * `AreaCodeNa` : North America
    * `AreaCodeEu` : Europe
    * `AreaCodeAs` : Asia excluding Mainland China
    * `AreaCodeJp` : Japan
    * `AreaCodeIn` : India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    Refer to the following sample code:

    ```javascript
    this._rtcContext.areaCode = AreaCode.AreaCodeNa;
    ```

    ## Reference [#reference-8]

    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 [#api-reference-8]

    * [`RtcEngineContext`](https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/class_rtcengineconfig.html)
    * [`AreaCode`](https://api-ref.agora.io/en/video-sdk/react-native/4.x/API/enum_areacode.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="unity">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="unity" />

    When a user joins a channel, Video SDK automatically connects them to the Agora SDRTN® 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 game by specifying the Agora SDRTN® media zone users connect to.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-9]

    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® from North America and China respectively:

    | Designated access zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-9]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-9]

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

    By default, the SDK connects to the nearest Agora server. Set the `areaCode` property of `RtcEngineContext` when calling the `initialize` method to specify the access zone(s). After setting the access zone, the SDK only connects to Agora servers in the specified zone(s).

    You can set the `areaCode` to:

    * `AREA_CODE_GLOB`: Global (Default)
    * `AREA_CODE_CN` : Mainland China
    * `AREA_CODE_NA` : North America
    * `AREA_CODE_EU` : Europe
    * `AREA_CODE_AS` : Asia except Mainland China
    * `AREA_CODE_JP` : Japan
    * `AREA_CODE_IN` : India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations.
      </CalloutDescription>
    </CalloutContainer>

    ### Include a media zone [#include-a-media-zone-4]

    To limit access to servers in only one media zone, such as North America, set `context.areaCode = AREA_CODE_NA;` before calling the `initialize` method:

    ```csharp
    // Initialize Agora SDK
    RtcEngine = Agora.Rtc.RtcEngine.CreateAgoraRtcEngine();
    RtcEngineContext context = new RtcEngineContext();
    context.appId = _appID;
    context.channelProfile = CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING;
    context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT;
    // Restrict access to servers in North America
    context.areaCode = AREA_CODE.AREA_CODE_NA;
    // Initialize RtcEngineContext
    RtcEngine.Initialize(context);
    ```

    ### Exclude a media zone [#exclude-a-media-zone-4]

    To exclude servers in a region, such as Mainland China, set `context.areaCode = AREA_CODE.AREA_CODE_GLOB ^ AREA_CODE.AREA_CODE_CN;` before calling the `initialize` method:

    ```csharp
    // Initialize Agora SDK
    RtcEngine = Agora.Rtc.RtcEngine.CreateAgoraRtcEngine();
    RtcEngineContext context = new RtcEngineContext();
    context.appId = _appID;
    context.channelProfile = CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING;
    context.audioScenario = AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_DEFAULT;
    // Exclude Mainland China from access area
    context.areaCode = AREA_CODE.AREA_CODE_GLOB ^ AREA_CODE.AREA_CODE_CN;
    // Initialize RtcEngineContext
    RtcEngine.Initialize(context);
    ```

    ## Reference [#reference-9]

    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 [#api-reference-9]

    * [`Initialize`](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`RtcEngineContext`](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_rtcengineconfig.html)
    * [`AreaCode`](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/enum_areacode.html)
    * [`CreateAgoraRtcEngine`](https://api-ref.agora.io/en/video-sdk/unity/4.x/API/class_irtcengine.html#api_createagorartcengine)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>

  <_PlatformPanel platform="unreal">
    <_PlatformProcessedMarker groupMode="structured" canonicalPlatform="web" platform="unreal" />

    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.

    <CalloutContainer type="info">
      <CalloutDescription>
        This is an advanced feature suitable only for use-cases with access security restrictions.
      </CalloutDescription>
    </CalloutContainer>

    ## Understand the tech [#understand-the-tech-10]

    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 zone | User's location | Zone actually accessed by the SDK | User experience         |
    | ---------------------- | --------------- | --------------------------------- | ----------------------- |
    | North America          | North America   | North America                     | Normal                  |
    | North America          | China           | North America                     | Quality may be affected |

    <CalloutContainer type="info">
      <CalloutDescription>
        * 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.
      </CalloutDescription>
    </CalloutContainer>

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

    **Restrict media zones**

    ![Restrict media zones](https://assets-docs.agora.io/images/video-sdk/restrict-media-zones.svg)

    ## Prerequisites [#prerequisites-10]

    Ensure that you have implemented the [SDK quickstart](../../index) in your project.

    ## Implement restricted media zones [#implement-restricted-media-zones-10]

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

    By default, the SDK connects to the nearest Agora server. Set the `areaCode` property of `RtcEngineContext` when calling the `initialize` method to specify the media zones. After setting the media zone(s), the SDK only connects to Agora servers in the specified zone(s).

    You can set the `areaCode` to:

    * `AREA_CODE_GLOB`: Global (Default)
    * `AREA_CODE_CN`: Mainland China
    * `AREA_CODE_NA`: North America
    * `AREA_CODE_EU`: Europe
    * `AREA_CODE_AS`: Asia except Mainland China
    * `AREA_CODE_JP`: Japan
    * `AREA_CODE_IN`: India

    <CalloutContainer type="info">
      <CalloutDescription>
        Media zones support bitwise operations. To include a zone, use the `|` operator, to exclude a zone use `^`.
      </CalloutDescription>
    </CalloutContainer>

    Refer to the following code:

    ```cpp
    void UMyUserWidget::setupVideoSDKEngine()
    {
        // Create an engine instance.
        agoraEngine = agora::rtc::ue::createAgoraRtcEngine();
        // Specify a context for the engine.
        RtcEngineContext context;
        context.appId = appId.c_str();
        context.eventHandler = this;
        // Choose the communication profile for video calling.
        context.channelProfile = CHANNEL_PROFILE_TYPE::CHANNEL_PROFILE_COMMUNICATION;
        // Only connect to Agora SDRTN® located in North America.
        context.areaCode = AREA_CODE::AREA_CODE_NA;
        // Initialize the engine instance with the context.
        agoraEngine->initialize(context);
        // Enable the local audio capture to init the local video stream.
        agoraEngine->enableAudio();
        // Enable the local video capture to init the local video stream.
        agoraEngine->enableVideo();
    }
    ```

    ## Reference [#reference-10]

    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 [#api-reference-10]

    * [`initialize`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_irtcengine.html#api_irtcengine_initialize)
    * [`RtcEngineContext`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/class_rtcengineconfig.html)
    * [`AREA_CODE`](https://api-ref.agora.io/en/video-sdk/unreal-engine/4.x/API/enum_areacode.html)

    <_PlatformProcessedMarker close="true" />
  </_PlatformPanel>
</_PlatformTabsGroup>
