CloudHub Docs
Download Documents

RTS


Quick start RTS SDK

This page describes how to set up the environment and integrate the CloudHubRTSSDK on windows and MAC platforms.

Prepare the environment

Download the latest CloudHubRTSSDK package.

The windows package is as follows:

FileDescription
CloudHubBase.hStructs and Enums
CloudHubBaseInternal.hThe definition of a dependent structure
CloudhubRts.hThe main interface file for CloudHubRTSSDK
rtssdk.dllWindows RTS, divided into x86 and x64
rtssdk.dll.libThe windows version of RTS function calls the library file, including x86 and x64

The Mac package is as follows:

FileDescription
CloudHubBase.hStructs and Enums
CloudHubBaseInternal.hThe definition of a dependent structure
CloudhubRts.hThe main interface file for CloudHubRTSSDK
rtssdk.dylibMAC RTS

Integrate the CloudHub SDK——IUpStream

1. Create IUpStream

Before you can call another API, you need to create and initialize the IUpStream object.

First, an APPID is required , See Gets an AppId

A callback event processor is required to initialize IUpStream. See Overview

class UpStreamEventHandler: public IUpStreamEventHandler {
 public:
  virtual void onError(cloudhub::IUpStream* stream, int code, const char* msg) {
    printf("\n UpStream onError(%d) \n", code);
  }
  
  virtual void onCaptureFirstAudioFrame(cloudhub::IUpStream* stream) {
    printf("\n UpStream onCaptureFirstAudioFrame \n");
  }

  virtual void onCaptureFirstVideoFrame(cloudhub::IUpStream* stream,
                                        int width,
                                        int height,
                                        const char* sourceID="") {
    printf("\n UpStream onCaptureFirstVideoFrame(%d, %d, %s) \n", width, height, sourceID);
  }

  virtual void onPushStatusUpdate(cloudhub::IUpStream* stream,
                                  CONNECTION_STATE_TYPE type) {
    printf("\n UpStream onPushStatusUpdate(%d) \n", (int)type);
  }

  virtual void onLocalVideoStateChanged(
      cloudhub::IUpStream* stream,
      cloudhub::LOCAL_VIDEO_STREAM_STATE localVideoState,
      cloudhub::LOCAL_VIDEO_STREAM_ERROR error){
    printf("\n UpStream onLocalVideoStateChanged(%d, %d) \n", (int)localVideoState, (int)error);
  }

  virtual void onLocalAudioStateChanged(
      cloudhub::IUpStream* stream,
      cloudhub::LOCAL_AUDIO_STREAM_STATE state,
      cloudhub::LOCAL_AUDIO_STREAM_ERROR error) {
    printf("\n UpStream onLocalVideoStateChanged(%d, %d) \n", (int)localVideoState, (int)error);
  }

  virtual void onStatisticsUpdate(cloudhub::IUpStream* stream,
                                  cloudhub::RtcStats& stats) {

  }

  virtual void onAudioVolumeIndication(cloudhub::IUpStream* stream,
                                       int volume) {

  }

  virtual void onVideoDeviceStateChanged(
      const char* deviceId,
      cloudhub::MEDIA_DEVICE_STATE_TYPE deviceState) {
    printf("\n UpStream onVideoDeviceStateChanged(%s, %d) \n", deviceId, (int)deviceState);
  }

  virtual void onAudioDeviceStateChanged(
      const char* deviceId,
      cloudhub::MEDIA_DEVICE_TYPE deviceType,
      cloudhub::MEDIA_DEVICE_STATE_TYPE deviceState) {
    printf("\n UpStream onAudioDeviceStateChanged(%s, %d, %d) \n", deviceId, (int)deviceType, (int)deviceState);
  }

  virtual ~UpStreamEventHandler() {}
};
const char* const appId = ""; /* using your appId */
UpStreamEventHandler handler;

cloudhub::IUpStream* const upStream = createUpStream(appId, &handler);
if (upStream == NULL)
{
    printf(" Error! Create UpStream failed. \n");
    return;
}

2. Start the audio and video

upStream->startCamera();
upStream->startMicrophone();

3. Preview

Watch your own video:

engine->setRenderView(hwnd);

4. Start pushing

const char* url = ""; /* using your url */
const int ret = upStream->startPush(url);
if (ret != ERR_OK)
{
    printf(" Error! startPush() failed. ret = %d \n", ret);
}

5. Stop pushing

Call ‘stopPush’ to stop the push stream and then release the upstream.

upStream->stopPush();
deleteUpStream(upStream);

Integrate the CloudHub SDK——IDownStream

1. Create IDownStream

Before you can call another API, you need to create and initialize the IDownStream object.

First, an APPID is required , See Gets an AppId

A callback event processor is required to initialize IDownStream. See Overview

class DownStreamEventHandler: public IDownStreamEventHandler {
 public:
  virtual void onError(cloudhub::IDownStream* stream,
                       int code,
                       const char* msg) {
    printf("\n DownStream onError(%d) \n", code);
  }
  
  virtual void onFirstRemoteAudioFrame(cloudhub::IDownStream* stream) {
    printf("\n DownStream onFirstRemoteAudioFrame \n");
  }

  virtual void onFirstRemoteVideoFrame(cloudhub::IDownStream* stream,
                                       int width,
                                       int height){
    printf("\n DownStream onFirstRemoteVideoFrame(%d, %d) \n", width, height);
  }

  virtual void onRemoteVideoSizeChange(cloudhub::IDownStream* stream,int width,int height) {
    printf("\n DownStream onRemoteVideoSizeChange(%d, %d) \n", width, height);
  }

  virtual void onPullStatusUpdate(cloudhub::IDownStream* stream,
                                  CONNECTION_STATE_TYPE type) {
    printf("\n DownStream onPullStatusUpdate(%d) \n",(int)type);
  }

  virtual void onRemoteVideoStateChanged(cloudhub::IDownStream* stream,
                                         RTS_VIDEO_STATE state) {
    printf("\n DownStream onRemoteVideoStateChanged(%d) \n",(int)state);
  }

  virtual void onRemoteAudioStateChanged(cloudhub::IDownStream* stream,
                                         RTS_AUDIO_STATE state) {
    printf("\n DownStream onRemoteAudioStateChanged(%d) \n",(int)state);
  }

  virtual void onStatisticsUpdate(cloudhub::IDownStream* stream,
                                  cloudhub::RtcStats& stats) {

  }

  virtual void onAudioVolumeIndication(cloudhub::IDownStream* stream,
                                       int volume) {

  }

  virtual ~DownStreamEventHandler() {}
};
const char* const appId = ""; /* using your appId */
DownStreamEventHandler handler;

cloudhub::IDownStream* const downStream = createDownStream(appId, &handler);
if (downStream == NULL)
{
    printf(" Error! Create downStream failed. \n");
    return;
}

2. Video playback

Watch your own video:

downStream->setRenderView(hwnd);

3. Start pulling

const char* url = ""; /* using your url */
const int ret = downStream->startPull(url);
if (ret != ERR_OK)
{
    printf(" Error! startPull() failed. ret = %d \n", ret);
}

4. Stop pulling

Call ‘stopPull’ to stop the pull stream and then release the downstream.

downStream->stopPull();
deleteDownStream(upStream);