This topic describes how to integrate Native RTS SDK for iOS with ApsaraVideo Player SDK to use the Real-Time Streaming (RTS) feature in ApsaraVideo Live.


CocoaPods is installed in your environment.


  1. Add the dependencies of ApsaraVideo Player SDK and Native RTS SDK in pod mode.
    1. Open a CLI on a terminal
    2. Go to the directory of your project and run the following command to create a Podfile file:

      pop init

    3. Modify the Podfile file by adding dependencies for the latest SDK versions.
       pod 'RtsSDK'
       pod 'AliPlayerSDK_iOS'
       pod 'AliPlayerSDK_iOS_ARTC'
      • After you add the AliPlayerSDK_iOS_ARTC and RtsSDK dependencies, ApsaraVideo Player SDK automatically loads Native RTS SDK as a plug-in.
      • If you need to add a dependency of a specified version, specify the version number in the code. Example: pod 'RtsSDK','2.1.0'. For more information about the latest versions of ApsaraVideo Player SDKs, see Release notes of ApsaraVideo Player SDK for iOS. For more information about the latest versions of RTS SDKs, see Download SDKs.
      • Make sure that the requirements are met when you integrate Native RTS SDK with ApsaraVideo Player SDK. For more information, see Release notes.
    4. Run the pod install command to integrate ApsaraVideo Player SDK with Native RTS SDK. After you the command, a *.xcworkspace file is generated, which indicates that the SDKs are integrated.

      pod install

  2. Call an API operation of ApsaraVideo Player SDK to use the RTS feature.
    • Initialize AliPlayer
      - (AliPlayer *)aliPlayer{
          if (!_aliPlayer) {
              _aliPlayer = [[AliPlayer alloc] init];
              _aliPlayer.scalingMode =  AVP_SCALINGMODE_SCALEASPECTFIT;
              _aliPlayer.rate = 1;
          // To use AVPDelegate, add the following line of code:
              _aliPlayer.delegate = self;
          // Set the user interface (UI) view and apply the UI view to AliPlayer.
              _aliPlayer.playerView = self.basePlayerView.playerView;
              _aliPlayer.autoPlay = YES;
          return _aliPlayer;
    • Configure streaming URLs
      AVPUrlSource *source = [[AVPUrlSource alloc] urlWithString:_url];
      [self.aliPlayer setUrlSource:source];
    • Set playback parameters

      You can set playback parameters to improve the RTS effect. You must set player parameters before you call the prepare method.

      AVPConfig *config = self.aliPlayer.getConfig;
      // The maximum latency of live streaming.
      [config setMaxDelayTime:1000];
      // The buffer period.
      [config setHighBufferDuration:10];
      // The maximum startup loading duration.
      [config setStartBufferDuration:10];
      // The number of retries.
      [config setNetworkRetryCount:2];
      // The retry interval.  
      [config setNetworkTimeout:15000];
       [_aliPlayer setConfig:config];
      // By default, hardware decoding is enabled. If hardware decoding fails during the preparation of the player, hardware decoding is switched to software decoding.
       _aliPlayer.enableHardwareDecoder = YES;
    • Enable logging
      [AliPlayer setEnableLog:YES];
      [AliPlayer setLogCallbackInfo:LOG_LEVEL_DEBUG callbackBlock:nil];
    • Set playback control
      [self.aliPlayer prepare];
      [self.aliPlayer stop];
      [self.aliPlayer destroy];
      [self.aliPlayer reload];

    For more information about the features of ApsaraVideo Player SDK, see Implementation and API reference.