Multi-Lens IPC

Last Updated on : 2024-06-17 07:58:20download

The IPC SDK allows for displaying video from multiple cameras on a single screen by using a video splitting protocol for rendering, which relies on device support.

Check video splitting support

API description

Check if the device supports video splitting and return a Boolean value.

boolean isSupportVideoSegmentation();

Example

IThingIPCCore cameraInstance = ThingIPCSdk.getCameraInstance();
if (cameraInstance != null) {
    ICameraConfigInfo cameraConfig = cameraInstance.getCameraConfig(deviceId);
    return cameraConfig != null && cameraConfig.isSupportVideoSegmentation();
}

Get video splitting protocol

API description

Get the video splitting protocol and return the model ThingVideoSplitInfo.

ThingVideoSplitInfo getCameraVideoSegmentationModel();

ThingVideoSplitInfo

Parameter Description
total_split_num The number of channels to split.
split_info An array of information about video splitting.
split_info.index The camera ID.
split_info.type The type of the video stream.
  • -1: Single channel stream.
  • 0: All channels.
  • 1: PTZ camera.
  • 2: Bullet camera.
split_info.res_pos The coordinates.
align_info (Optional) Video window alignment and localizer position.
align_info.align_type Video window alignment. Valid values:
  • 20: Arrange two windows up and down for dual-lens IPCs.
  • 21: Arrange two windows side by side for dual-lens IPCs.
  • 30: Arrange three windows up and down for three-lens IPCs. This value is currently not supported because such devices do not exist.
  • 31: Arrange one window at the top and two windows side by side below for three-lens IPCs.
  • 32: Arrange two windows side by side at the top and one window below for three-lens IPCs.
align_info.align_group The order of cameras. Use the camera ID from split_info.index to specify the order. A non-array element indicates one camera in a row, while nested arrays indicate multiple cameras arranged side by side in a row.
align_info.localizer_group The position with specific localizers split_info.index. Cross-column arrangement is not supported.

Example

IThingIPCCore cameraInstance = ThingIPCSdk.getCameraInstance();
if (cameraInstance != null) {
    ICameraConfigInfo cameraConfig = cameraInstance.getCameraConfig(deviceId);
    if(cameraConfig != null && cameraConfig.isSupportVideoSegmentation()){
        ThingVideoSplitInfo videoSplitInfo = cameraConfig.getCameraVideoSegmentationModel();
    }
}

Bind rendering view with type

Specify the type of rendering view, which can be PTZ camera, bullet camera, or non-split view.

Invoke setType after ThingCameraView.createVideoView.

void setType(int type);

Request parameters

Parameter Description
type The type corresponds to the split_info.type in the video splitting protocol.
  • 0: All screens before splitting.
  • 1: PTZ camera.
  • 2: Bullet camera.

Example

ThingVideoSplitInfo.SplitInfo splitInfo = mThingVideoSplitInfo.getSplit_info();
ThingCameraView mVideoView = findViewById(R.id.camera_video_view);

...

mVideoView.setType(splitInfo.getType());

Bind rendering view with camera ID

API description

Bind the rendering view with a camera ID to specify the IPC to render.

Invoke setIndex after ThingCameraView.createVideoView.

void setIndex(int index);

Request parameters

Parameter Description
index The camera ID, corresponding to the split_info.index in the video splitting protocol.

Example

ThingVideoSplitInfo.SplitInfo splitInfo = mThingVideoSplitInfo.getSplit_info();
ThingCameraView mVideoView = findViewById(R.id.camera_video_view);

...

mVideoView.setIndex(splitInfo.getIndex());

Multi-lens view rendering container ThingMultiCameraView

The ThingCameraView-based multi-lens player supports four types of video window alignment. For dual-lens IPCs, you can arrange the double windows up and down or side by side. For three-lens IPCs, you can have one window at the top and two windows side by side below or two windows side by side at the top and one window below.

Example

IThingSmartCameraP2P mCameraP2P = null;
IThingIPCCore cameraInstance = ThingIPCSdk.getCameraInstance();
if (cameraInstance != null) {
    mCameraP2P = cameraInstance.createCameraP2P(devId));
}
// Imported through the layout.
ThingMultiCameraView thingCameraView = new ThingMultiCameraView(context);
// Set the video splitting protocol.
thingCameraView.setThingVideoSplitInfo(videoSplitInfo);
// Set the width of the player.
thingCameraView.setCameraViewWidth(widthPixels);

thingCameraView.setViewCallback(new AbsVideoViewCallback() {
    @Override
    public void onCreated(Object view) {
        super.onCreated(view);
        // When the rendering view is created, bind IThingSmartCameraP2P with the rendering view.
        if (null != mCameraP2P){
            mCameraP2P.generateCameraView(view);
        }
    }
});
thingCameraView.createVideoView(devId);

Example protocol

The protocol defines conventions between the mobile app and the IPC. When developing with the SDK, contact your project manager for a suitable solution.

The example protocol below is intended for three-lens IPCs.

{
  "total_split_num":3,
  "split_info":[
    {
      "index":1,
      "type":1,
      "res_pos":[[0,0,640,720],[0,0,960,1080]]
    },
    {
      "index":2,
      "type":2,
      "res_pos":[[0,720,640,720],[0,1080,960,1080]]
    },
    {
      "index":3,
      "type":2,
      "res_pos":[[0,720,1280,720],[0,1080,1920,1080]]
    }
  ],
  "align_info":{
    "align_type":32,
    "align_group":[[1, 3],[2]],
    "localizer_group":[1,3]
  }
}