Skip to content

Faceunity/FUTRTCDemoDroid

Repository files navigation

TRTC API-Example

简体中文 | English

Background

This open-source demo shows how to use some APIs of the TRTC SDK to help you better understand the APIs and use them to implement some basic TRTC features.

Contents

This demo covers the following features (click to view the details of a feature):

Note: for clarity purposes, the naming of folders in the project may differ slightly from a standard Android Studio project in terms of letter case.

Environment Requirements

  • Android 4.1 (SDK API level 16) or above; Android 5.0 (SDK API level 21) or above is recommended
  • Android Studio 3.5 or above
  • Devices with Android 5.0 or above

Demo Run Example

Prerequisites

You have signed up for a Tencent Cloud account and completed identity verification.

Obtaining SDKAPPID and SECRETKEY

  1. Log in to the TRTC console and select Application Management > Create application.
  2. Enter an application name such as TestTRTC, and click Next.

 #900px 3. Click Next to view your SDKAppID and Secret key.

Configuring demo project files

  1. Open the demo project TRTC-API-Example with Android Studio (3.5 or above).
  2. Find and open TRTC-API-Example/Debug/src/main/java/com/tencent/trtc/debug/GenerateTestUserSig.java.
  3. Set parameters in GenerateTestUserSig.java as follows:
  • SDKAPPID: PLACEHOLDER by default. Set it to the actual SDKAppID.
  • SECRETKEY: left empty by default. Set it to the actual key.  #900px
  1. Return to the TRTC console and click Next.
  2. Click Return to Overview Page.

!The method for generating UserSig described in this document involves configuring SECRETKEY in client code. In this method, SECRETKEY may be easily decompiled and reversed, and if your key is disclosed, attackers can steal your Tencent Cloud traffic. Therefore, this method is suitable only for the local execution and debugging of the demo. The correct UserSig distribution method is to integrate the calculation code of UserSig into your server and provide an application-oriented API. When UserSig is needed, your application can make a request to the business server for dynamic UserSig. For more information, please see How to Calculate UserSig.

Configuring CDN parameters (optional)

To use CDN services, which are needed for co-anchoring, CDN playback, etc., you need to configure three live streaming parameters.

For detailed instructions, see CDN Relayed Live Streaming.

Integrating the SDK

You can use JCenter for automatic loading or manually download the AAR file and import it to your project. The demo uses the first method by default.

Method 1: automatic loading (AAR)

The TRTC SDK has been released to the JCenter repository. You can use Gradle to download and update it automatically. Use Android Studio to open your project and modify the app/build.gradle file in three simple steps to integrate the SDK into your project, as shown below:

  1. Add the TRTC SDK dependencies to dependencies.
  • Run the following command if you use the 3.x version of com.android.tools.build:gradle.
dependencies {
    implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
}
  • Run the following command if you use the 2.x version of com.android.tools.build:gradle.
dependencies {
    compile 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
}
  1. In defaultConfig, specify the CPU architecture to be used by the application.
defaultConfig {
    ndk {
        abiFilters "armeabi-v7a", "arm64-v8a"
    }
}
  1. Click Sync Now to automatically download and integrate the SDK into your project.

Method 2: manual download (AAR)

If you have difficulty accessing JCenter, you can manually download the SDK and integrate it into your project.

  1. Download the latest version of the TRTC SDK.
  2. Copy the downloaded AAR file to the app/libs directory of your project.
  3. Add flatDir to build.gradle under the project’s root directory and specify a local path for the repository.
...
allprojects {
    repositories {
        flatDir {
            dirs 'libs'
            dirs project(':app').file('libs')
        }
    ...
    }
}
...
  1. Add code in app/build.gradle to import the AAR file.
dependencies {
    ...
    compile(name: 'LiteAVSDK_TRTC_xxx', ext: 'aar') // `xxx` is the version number of the decompressed SDK
    ...
}
  1. In defaultConfig of app/build.gradle, specify the CPU architecture to be used by the application.
defaultConfig {
    ndk {
        abiFilters "armeabi-v7a", "arm64-v8a"
    }
}
  1. Click Sync Now to complete the integration.

Compiling and running the project

Open the project with Android Studio, connect to an Android device, and compile and run the project.

Contact Us

  • If you have questions, see FAQs.

  • To learn about how the TRTC SDK can be used in different scenarios, see Sample Code.

  • For complete API documentation, see SDK API Documentation.

  • Communication & Feedback
    Welcome to join our Telegram Group to communicate with our professional engineers! We are more than happy to hear from you~ Click to join: https://t.me/+EPk6TMZEZMM5OGY1
    Or scan the QR code

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages