Fast Integration with IPC SDK for Android

Last Updated on : 2023-03-29 02:40:43download

IPC SDK for Android helps you implement IP camera (IPC) functionalities on top of the modules provided by Smart Life App SDK, such as user management, device pairing, home management, and device management.

Before you start

The IPC SDK is developed based on the Smart Life App SDK. Before integration with the IPC SDK, perform the steps described in Fast Integration with Smart Life App SDK for Android.

Fast integration

Configure build.gradle

  • Configure the file build.gradle in the root directory of your project.

    allprojects {
        repositories {
            ...
            maven {
                url "https://maven-other.tuya.com/repository/maven-releases/"
            }
    	...
        }
    }
    
  • Configure build.gradle in the app directory.

    defaultConfig {
    	ndk {
    	   abiFilters "armeabi-v7a","arm64-v8a"
    	}
    }
    packagingOptions {
            pickFirst 'lib/*/libc++_shared.so'
            pickFirst 'lib/*/libyuv.so'
            pickFirst 'lib/*/libopenh264.so'
    }
    dependencies {
    	...
    	implementation 'com.tuya.smart:tuyasmart-ipcsdk:4.0.0-4'
    	...
    }
    
    • The IPC SDK supports armeabi-v7a and arm64-v8a by default.
    • The IPC SDK does not support P2P 1.0 devices by default. In this case, the value of p2pType for this type of device is 1. To support this type of device, add the dependency implementation 'com.tuya.smart:tuyasmart-ipc-camera-v1:3.20.0'.

Configure AndroidManifest.xml

Set permissions in AndroidManifest.xml.

<!-- sdcard -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Network -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

Obfuscate the code

Configure obfuscation in proguard-rules.pro.

-keep class com.tuyasmart.**{*;}
-dontwarn com.tuyasmart.**

For P2P 1.0 devices (p2pType is 1), add the following obfuscation rules:

 -keep class com.tutk.**{*;}
 -dontwarn com.tutk.**

Demo app

Based on the features of the Smart Life App SDK demo app, the IPC SDK demo app is added with the control panel module for IPCs to implement the following pages:

  • Live streaming: P2P connections of IPCs, live video playing, video recording, screenshots, video talk, and more.
  • Playback: retrieval and playback of video footage from an SD card, and use of timeline components.
  • Cloud Storage for Videos: service subscription, status query, and retrieval and playback of cloud-stored videos and cloud storage events.
  • Messages: retrieval and display of alerts.
  • Settings: use of standard data points for IPCs.