Installation guide
Installation
Android support
Code name | Version | API Level |
---|---|---|
Jelly Bean | 4.1+ | API Level 16 |
Importing dependencies into your project
Mobile SDK is built using following frameworks: Retrofit, OkHttp, RxJava/RxAndroid, Gson, and Jetty Server. In order to use CMMobileSDK you should import mentioned frameworks as well:
dependencies {
// Retrofit
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'
implementation 'com.squareup.retrofit2:converter-simplexml:2.5.0'
// OkHttp
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
// Rx
implementation 'io.reactivex.rxjava2:rxandroid:2.2.0'
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
// Gson
implementation 'com.google.code.gson:gson:2.8.2'
// Jetty Server
implementation 'org.eclipse.jetty:jetty-server:8.1.17.v20150415'
implementation 'org.eclipse.jetty:jetty-servlet:8.1.17.v20150415'
implementation 'org.eclipse.jetty:jetty-client:8.1.17.v20150415'
}
Importing CMMobileSDK into your project
- Add CMMobileSDK.aar file to your project (libs directory).
- Add next lines at the build.gradle file where you plan to use it:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation(name:'CMMobileSDK', ext:'aar')
}
Usage examples
The demo app includes implementation of multiview and fullscreen mode as well. Please note that there are a lot of ways to implement this feature. Take you project architecture into consideration while using sample code.
// set access token provider so mobile SDK will be able to retrieve access token when needed.
AccessTokenProvider accessTokenProvider = new AccessTokenProviderImpl();
/* sniffing cameras */
CameraSniffer cameraSniffer = new CameraSniffer(getContext(), new CameraSnifferListenerImpl());
cameraSniffer.setProvider(accessTokenProvider);
cameraSniffer.startSniffing();
/* adding camera */
CameraWizard cameraWizard = new CameraWizard(new CameraWizardListenerImpl());
cameraWizard.setProvider(accessTokenProvider);
cameraWizard.addDevice(someDeviceReturnedBySniffer, "My awesome camera", 1234);
/* streaming live video */
// init live streamer item
long cameraId = 1234;
StreamerItem streamerItem = StreamerItem.createItem(cameraId);
// init recording streamer item
long cameraId = 1234;
long recordingId = 5678;
StreamerItem streamerItem = StreamerItem.createItem(cameraId, recordingId);
// init streamer
CameraStreamer cameraStreamer = new CameraStreamer(getContext(), surface);
cameraStreamer.setCameraStreamerListener(new CameraStreamerListenerImpl());
cameraStreamer.setProvider(accessTokenProvider);
// set streamer item
cameraStreamer.setStreamerItem(streamerItem);
// the streamer will start playing after the streamer item is ready
cameraStreamer.play();
// seek to middle of recording
cameraStreamer.seekTo(streamer.getDuration() / 2 );
Updated almost 2 years ago