Migration guide
Android - Migration guide
This page is intended as a guide for the process of migrating from our previous version of SDKs to our newest (CMMobileSDK).
Previously, the sniffer and wizard library were part of one framework (CameraWizard) and the streaming part of a second framework (CameraStreamer). This is not the case anymore, as there's only one framework (CMMobileSDK) which includes all three functionalities as modules. These modules are named as follows: CameraSniffer, CameraWizard and CameraStreamer. All their interfaces can be found here: Public API.
The main big difference between the two SDKs is that the old version needed basic authentication for instantiating objects and used XML API calls for other requests, while the new version requires an access token to be passed with each REST API call.
The steps to install the new mobile SDK can be found here: Android - Installation guide.
Following, we will highlight differences of use for each module.
CameraSniffer + CameraWizard
The first version of the CameraWizard included the sniffer part as well.
The differences are as follows:
/* MobileSDKv1 */
CameraWizard cameraWizard = new CameraWizard(context, new CameraWizardListenerImpl(), userId, sessionId, serverIp, serverHttpsPort);
/* MobileSDKv2/v3 */
// set access token provider so mobile SDK will be able to retrieve access token when needed.
AccessTokenProvider accessTokenProvider = new AccessTokenProviderImpl();
// init sniffer
CameraSniffer cameraSniffer = new CameraSniffer(getContext(), new CameraSnifferListenerImpl());
cameraSniffer.setProvider(accessTokenProvider);
// init wizard
CameraWizard cameraWizard = new CameraWizard(new CameraWizardListenerImpl());
cameraWizard.setProvider(accessTokenProvider);
/* MobileSDKv1 */
cameraWizard.startSniffer();
/* MobileSDKv2/v3 */
cameraSniffer.startSniffing();
/* MobileSDKv1 */
cameraWizard.stopSniffer();
/* MobileSDKv2/v3 */
cameraSniffer.stopSniffing();
/* MobileSDKv1 */
@Override
public void deviceFound(CameraDevice device, CameraWizardError error) {
if (error == CameraWizardError.SUCCESSFUL_TASK) {
// your awesome code here
}
}
/* MobileSDKv2/v3 */
@Override
public void onFound(Device device) {
// your awesome code here
}
@Override
public void onLost(Device device) {
// your awesome code here
}
@Override
public void onError(CMMobileSdkError error) {
// handle error
}
/* MobileSDKv1 */
cameraWizard.addCamera(someDeviceReturnedBySniffer, cameraName, zoneName, cameraUserName, cameraPassword);
/* MobileSDKv2/v3 */
cameraWizard.addDevice(someDeviceReturnedBySniffer, "My awesome camera", 1234);
/* MobileSDKv1 */
@Override
public void wasCameraAdded(CameraDevice device, Integer cameraId, CameraWizardError error) {
if (error == CameraWizardError.SUCCESSFUL_TASK && cameraId != -1) {
// your awesome code here
}
}
/* MobileSDKv2 */
@Override
public void onAdded(Device device, long cameraId) {
// your awesome code here
}
@Override
public void onError(Device device, CMMobileSdkError error) {
// your awesome code here
}
/* MobileSDKv3 */
@Override
public void onAdded(long cameraId) {
// your awesome code here
}
@Override
public void onError(Device device, CMMobileSdkError error) {
// your awesome code here
}
CameraStreamer
The differences for the CameraStreamer in the old and new SDK are highlighted as follows:
/* MobileSDKv1 */
CameraStreamerView cameraStreamerView = new CameraStreamerView(context);
cameraStreamerView.createLiveStreamingPlayer(context, serverIp, httpPort, streamingWithAudio, userId, sessionId, cameraId, isHighBandWidth, cameraStreamerListenerImpl, enableAudio, backgroundColor);
cameraStreamerView.startPlayback();
/* MobileSDKv2 */
// the stream will start playing automatically after creation connection (you'll receive onStarted() callback).
CameraStreamer cameraStreamer = new CameraStreamer(rtspStreamUrl, new CameraStreamerListenerImpl(), surface);
cameraStreamer.setProvider(accessTokenProvider);
cameraStreamer.setRtspUrlString(streamUrl);
/* MobileSDKv3 */
// init streamer item
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);
/* MobileSDKv1 */
cameraStreamerView.startPlayback();
/* MobileSDKv2 */
if (!cameraStreamer.isPlaying()) {
camerasSreamer.play();
}
/* MobileSDKv3 */
// the streamer will start playing after the streamer item is ready
camerasSreamer.play();
/* MobileSDKv1 */
cameraStreamerView.stopPlayback();
/* MobileSDKv2 */
if (camerasSreamer.isPlaying()) {
camerasSreamer.pause();
}
/* MobileSDKv3 */
camerasSreamer.pause();
Notes
The highlighted differences are the most used methods of our SDKs. The methods presented from CMMobileSDK (v2) in this page are enough for basic setup and usage. They should replace (after the SDK installation) the old methods. Also, any other method implementations from the old SDK that were not highlighted here should be removed as well.
Due to the large spectrum of color formats available on Android devices , we dropped support for the raw frame decoding and adopted the use of the Surface for video playback, in order to assure support for a bigger range of devices. Performance wise, the Surface-based implementation is faster than the raw frame one. The usage is straight forward: You have to provide a valid Surface to the CameraStreamer constructor.
public CameraStreamer(Context context, Surface streamSurface);
Updated almost 2 years ago