Construction of Haikang Ehome protocol server

Posted by programming_passion on Sat, 29 Jan 2022 20:13:42 +0100

I Haikang EHome agreement preview process

1.0 introduction

EHOME protocol is a push mode protocol for communication between equipment and server. It is applicable to network camera, network ball machine, DVR, NVR, on-board DVR, on-board forensics system, individual soldier, alarm host and other equipment supporting EHOME protocol.
Haikang devices can actively register the cloud based on the ehome protocol, which is different from the restriction that onvif can only be used in the LAN.
This service software is based on the Haikang private agreement EHOME v2 X version, and strive to build an open source security basic product.

1.1. flow chart

1.2. Access steps of EHOME protocol

The EIKON protocol is used to register the EIKON device with the private address, which is more applicable to the EIKON protocol than the EIKON protocol. The EIKON protocol is used to register the EIKON device with the private address.

Integrating the home SDK to complete the video preview function requires the use of the central management service CMS component and the streaming media service SMS component.

In combination with the above figure, the basic steps to complete the preview playback of home protocol device access are as follows:

1> Call NET_ECMS_XMLConfig and GetDevAbility command obtain the device capability and judge whether preview is supported.
The device capability is returned by pOutBuf.
·If supported, the node will be returned, and you can continue with the following steps.
·Otherwise, end the task.

2> Call NET_ESTREAM_StartListenPreview starts the SMS listening service and receives the connection request from the device.

3> Call NET_ESTREAM_SetExceptionCallBack registers an exception callback function for SMS.

4> The exception information will be called back to the registered callback function. Please handle the exception in time to avoid blocking.

5> Call NET_ECMS_StartGetRealStreamV11 sends the preview start request from CMS to the device.

6> Send the address and port number of SMS to the device, and automatically assign a session ID to CMS.

7> Call NET_ESTREAM_SetPreviewDataCB registers a callback function for SMS to receive real-time streams from devices.

8> Call NET_ECMS_StartPushRealStream sends the real-time streaming request from CMS to the device.

9> The device automatically connects to SMS and starts sending real-time stream to SMS.

II Device registration message

2.2. After the device to platform is registered, the Haikang device will actively connect to the configured ehome platform

Send message as follows

<?xml version="1.0" encoding="GB2312"?>
	<!--ehome Protocol version-->
   	<!--Signaling interaction serial number-->
	<!--Indicates that the request was sent-->
	<!--Device registration command-->	
        <!--Equipment serial number: unique-->
        <!--Device firmware version-->
        <FirmwareVersion>V5.4.5 build 170302</FirmwareVersion>
        <!--Device native IP-->
        <!--Device native port-->
        <!--Equipment type: see special documents-->
        <!--Equipment manufacturer-->

2.3. After receiving the equipment registration instruction, the EHOME platform

The returned message is as follows

<?xml version="1.0" encoding="GB2312" ?>
	<!--The platform version number may not be consistent with the equipment-->
    <!--Signaling interaction serial number-->	
    <!--Indicates that a reply is sent-->
    <!--Indicates that the reply is registration signaling-->
    <!--Registration status code-->
    <!--Status code description-->
    	<!--Keep alive interval in seconds-->
        <!--Platform alarm service information-->
        <!--Time synchronization configuration information-->
        <!--Picture service information-->
        <!--Basically meaningless-->

III Preview request message

3.1. Platfrom = > > device, ehome platform launch Preview

Request message

<?xml version="1.0" encoding="GB2312" ?>
    	<!-- Request device channel number-->
        <!-- Request device bitstream type: MAIN:Main code stream, SUB: Sub code stream, THIRD: Three bit stream-->

3.2. Device = > > platform, the device returns to the platform request stream

Return message

<?xml version="1.0" encoding="GB2312"?>
    <!-- Status code after the current request flow, 200 indicates success, see error code for others-->
        <!-- Current request flow location indicator, similar to ssrc-->

3.3. Platfrom = > > device, stop VOD

Request message

<?xml version="1.0" encoding="GB2312" ?>
    	<!--With the start of on-demand Session agreement -->

3.4. Device = > > platfrom, the device returns the stop status to the platform

Return as follows

<?xml version="1.0" encoding="GB2312"?>
    	<!--With the start of on-demand Session agreement -->

Hello! This is the first time you have used the welcome page displayed by the Markdown editor. If you want to learn how to use the Markdown editor, you can read this article carefully to understand the basic grammar of Markdown.

IV Video stream

4.1. Haikang's camera is on demand through TCP through Haikang ehome protocol. The stream pushed by the camera is not a standard PS stream

The stream format is as follows


It can be seen that 000001ba is the header of PS stream and PS is loaded in RTP package. Let's analyze the bytes in front of PS header:

24 00 01 39 80 60 00 00 00 00 00 00 0a 68 9e bc 0d

The first two bytes of 24 00 are '$', which is a bit like the rtsp protocol of tcp transmission;
01 39 is the length of RTP package, here 313;
80 60 00 00 00 00 0a 68 9e bc is the standard 12 bit RTP header, in which the 3rd and 4th bytes are the sequence number, here is 00 00, 0a 68 9e bc is ssrc;
0d, which is considered as the separator between RTP header and PS package.

V Build home server

5.1. Open source project link.

5.2. Download and compile the complete program

5.3. Modify CMS configuration

Enter the freeehomecms = > conf folder
According to app The notes in the conf file are modified according to the actual situation, as follows:

#ehomeCMS service address
udpAddr = ""
#Streaming media SMS address
streamStartIP = ""
streamStartPort = 10000
#Live broadcast waiting timeout, 3 seconds by default
waitStreamSessionTime = 3
#The timeout for closing the live broadcast is 3 seconds by default
waitHookSessionTime = 3

#The streaming media distribution service configuration must be in English; Split
streamIP = ";"
#hls port
hlsPort = "10080;10080"
#rtmp port
rtmpPort = "1935;1935"
#rtsp port
rtspPort = "10554;10554"

PS. the IP and ports mentioned above shall be modified according to the actual configuration and SMS

5.1 modify SMS configuration

Enter FreeEhomeSMS folder
Found config INI file, which can be modified optionally. The streaming media distribution port must be consistent with the configuration in CMS.
[hook] if CMS and SMS are on the same machine, you don't need to repair it. Otherwise, it is modified to the actual address of CMS here
[rtp_proxy] part of the configuration is the collection address of Haikang ehome protocol, which should be consistent with CMS


5.2 operation

At present, the release version only supports Windows platform

1. Run in terminal mode: double click freeehome exe MediaServer. Exe

2. Run in service mode: double click to execute install Bat can be installed as system service; uninstall.bat serves for unloading the system; MediaServer does not support Windows system services.

5.3 operation cms

5.4 running SMS

5.5 access project

admin 123456

5.6 equipment query and Preview

5.7 front end project compilation and operation

1. Development tool VScode
2. Development environment vue (online reference)
3. Download items link.
4. Import projectadd folder to workspace Add Folder to Workspace
5. Download cnpm component compilation environment
6. Change the project configuration api interface platform address

7. Compile the project

# install dependencies
set-ExecutionPolicy RemoteSigned
Set-ExecutionPolicy RemoteSigned -Scope Process
cnpm install

8. Operation project

# serve with hot reload at localhost:8080
cnpm run dev

9. Browser access

http://localhost:8081/     admin  123456

Thanks to the blogger: the open source project provided by tsingeye
The above summary is all personal and online experience summary. If there are similarities, please understand. Welcome to discuss technology, pay attention and continue to update later

Topics: Java Linux network Vue.js RESTful