Android camera

❗️

-------- THIS FEATURE IS IN ACTIVE DEVELOPMENT AND NOT FINISHED. PLEASE CONTACT [email protected] IF YOU WANT TO USE THIS ---------

Installation guide

==================

Importing dependencies into your project


Mobile SDK is built using the following frameworks: Retrofit, OkHttp, RxJava/RxAndroid, and Gson. In order to use SmartphoneCameraStreamerSDK you should import the following frameworks as well:

Importing SmartphoneCameraStreamerSDK into your project


1. Add smartphonecamerastreamer.aar file to your project (libs directory).

2. Add the next lines at the build.gradle file where you plan to use it:

dependencies {
 
/* HTTP */
implementation "com.squareup.okhttp3:okhttp:3.12.0"
implementation "com.squareup.okhttp3:okhttp-urlconnection:3.10.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.4.1"
 
/* REST API */
implementation "com.squareup.retrofit2:retrofit:2.5.0"
implementation "com.squareup.retrofit2:adapter-rxjava2:2.2.0"
implementation "com.squareup.retrofit2:converter-gson:2.2.0"
implementation "com.squareup.retrofit2:converter-scalars:2.5.0"
 
/* JSON parser */
implementation "com.google.code.gson:gson:2.8.5"
 
// RxAndroid
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
}
 
//---------------------------
 
repositories {
    flatDir {
        dirs 'libs'
    }
}
 
//---------------------------
 
 
dependencies {
    //add smartphonecamerastreamer library
    implementation(name:'smartphonecamerastreamer', ext:'aar')
}

3. Add request for following app permissions:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

Process overview


To start streaming, the following actions need to be taken:

  • The user installs the app containing the SDK on their phone
  • The app gets the camera credentials and sends this to the partner’s backend.
  • Partner’s backend registers camera with Cameramanager backend
  • Partner’s backend reports back to app that camera has registered
  • App starts streaming
  • App stops streaming

Below, are a few more details on some of these steps:

Getting the credentials to register the camera with the CameraManager backend


SmartphoneCameraStreamer streamer = new SmartphoneCameraStreamer(getApplication());
String hardwareID = streamer.getHardwareId()
String cameraUsername = streamer.getUsername();
String cameraPassword = streamer.getPassword()

Registering a camera with the CameraManager backend


This also adds it to a defined zone, so if there is no zone yet in the account, it needs to be created beforehand using the TODO: INSERT LINK TO ZONE API HERE API.
Add a camera to your zone in backend using the zone ID, hardware ID, username and password using the TODO: INSERT LINK TO CAMERA API HERE API. The "deviceTypeId" field should be set to “10031”.

Keep the following in mind:

  • Keep information about user and hardware ID in the backend
  • A Hardware ID can be added only to one account
  • If the user changes the hardware ID (for example: uninstall and install the app) you need to remove the camera in the backend too. 

Start stream in app


Example code:

// init params
String apiUrl = "https://rest.cameramanager.com"
SmartphoneCameraStreamerParams params = new SmartphoneCameraStreamerParams(apiUrl)
 
// init cameraSmartphoneCameraStreamer 
smartCamera = new SmartphoneCameraStreamer( activity, applicationContext, surface, params)
 
// add listener
smartCamera.setStreamingListener(streamingListener)
 
// camera will start streaming after connection will be set up
smartCamera.connect()
 
//stop streaming
smartCamera.disconnect()
 
//release SmartphoneCameraStreamer
smartCamera.release()

Downloads

=========

SmartphoneCameraStreamer SDK


VersionDownloadRelease notesDescription
1.0.1sdk-v1.0.1.zipInitial release of SmartphoneCameraStreamer SDKThe archive contains the AAR file that should be imported into the Application project

Demo application


VersionDownloadRelease NotesDescription
1.0.1sample-app-v1.0.1.zipInitial release containing SmartphoneCameraStreamer SDKSmartphoneCameraStreamer SDK The archive contains the Demo App project with SDK files