National standard GB28181 protocol client development (1) overall process and technology selection

National standard GB28181 protocol client development (1) overall process and technology selection

This series of articles will introduce the development process of the device side of the national standard GB28181 protocol. This article aims to discuss overall design and technology selection considerations to provide guidance and reference for developers. The article will discuss the overall architecture of device-side development, signaling interaction process and key technology selection, etc., to help readers in need understand and grasp the key points of GB28181 protocol device-side development, and master the technologies required to develop the GB28181 protocol device-side. and knowledge to lay the foundation for the development of actual projects.

1. Introduction to GB28181 protocol

The full name of GB28181 is "Technical Requirements for Information Transmission, Exchange and Control of Public Safety Video Surveillance Networking Systems". It defines the network communication protocol between video surveillance equipment and aims to achieve interconnection and unified management of video surveillance systems. In recent years, with the rapid development of video surveillance systems, GB28181 has become the de facto standard protocol for various surveillance equipment such as IPC network cameras and NVR network hard disk recorders.

  1. Basic architecture:

    The basic architecture of the GB28181 protocol includes the device side and the platform side. The device side includes video surveillance equipment, such as cameras, video recorders, etc.; the platform side is the management platform of the video surveillance system, responsible for equipment management, video stream reception and storage, and other functions.

  2. Signaling interaction:

    The GB28181 protocol uses a SIP-based signaling interaction mechanism (extended). Devices send SIP signaling to establish communication sessions and transmit control information. Commonly used SIP messages include registration, heartbeat, device search, device status query, device control, etc.

  3. data transmission:

    The GB28181 protocol uses RTP to transmit audio and video streams. Video surveillance equipment encapsulates real-time audio and video data into data packets through the RTP protocol and transmits them to the receiving end through the network.

From the above points, it can be seen that GB28181 is very similar to the SIP protocol, but the two focus on different fields. The GB28181 protocol is customized and expanded on the basis of the SIP protocol for the video surveillance field to meet the requirements of video surveillance. Network communication needs between monitoring devices. Compared with the SIP protocol, the GB28181 protocol is more focused on the needs of video surveillance systems and provides specific functions and interfaces. The main functions included in the protocol are as follows:

  • Device registration management
  • Equipment information query, directory query, status query
  • Live preview
  • Video query, playback and download
  • Equipment control (PTZ control, arm/disarm, auxiliary switch, etc.)
  • Voice broadcast and voice intercom
  • Alarm event notification and distribution
  • school hours
  • Subscriptions and notifications

2. Overall architecture of GB28181 device side

Insert image description here

  • Network layer: Responsible for the network connection and communication of the device.

  • Management control layer: handles device control instructions, management requests, video storage and retrieval.

  • Media layer: Responsible for audio and video encoding and decoding and analysis of media files.

3. Operation process of GB28181 device

Insert image description here

  1. Start the device: After the device is started, connect to the network and initialize each module.

  2. Establish RTP/RTCP network: The device needs to initialize the RTP/RTCP network after startup to establish a media channel with the platform for audio and video stream transmission.

  3. Registration platform: The device sends a Register registration request to the designated platform, including SIP device ID, IP address, SIP port and other key information. There will be a two-time registration process for password verification on the GB28181 platform, which will be discussed later.

  4. Heartbeat keep-alive: The device regularly sends heartbeat messages to the platform to maintain the connection with the platform.

  5. Respond to platform management requests: The device receives management requests from the platform, such as device directory query, status, information and other operations, and then responds accordingly according to the request.

  6. Real-time preview: The device receives the real-time preview request from the GB28181 platform, combines the real-time audio and video streams into an RTP message, and sends it to the requester.

  7. Video storage, query and playback: The device stores video and divides and stores the video data according to time periods. When the GB28181 platform sends a video playback request, the device combines the video data of the corresponding time period into an RTP message according to the request, and sends it to the requesting party for playback.

  8. Alarm processing: The device receives the alarm trigger signal and sends an alarm notification to the GB28181 platform. When receiving an alarm processing request, the device can perform related processing, such as triggering alarm audio, video push, etc.

  9. Network connection maintenance: The device needs to maintain a stable network connection with the GB28181 platform and handle abnormal situations such as network disconnection and reconnection.

  10. Shut down the device: When the device receives a shutdown command or actively disconnects, it needs to send a corresponding SIP bye message to the ongoing RTP data link and release related resources.

Among them, the key steps are registration, heartbeat, device directory query, real-time preview and network connection maintenance. Only by achieving these points can it be regarded as a basic GB28181 device.

4. Technology Selection

Choosing the right technology is crucial for the development of the device side of the GB28181 protocol. The following are some selection suggestions for key technologies:

  • Development languages ​​and frameworks: Project development usually involves selecting appropriate development languages ​​and frameworks based on project requirements and the technical background of the development team. According to the requirements of this project, I used C++ to implement the underlying process and QT for interface design.

  • SIP protocol library: Choose a stable and mature SIP protocol library to handle signaling interactions. Common choices include PJSIP, JAIN-SIP, oSIP, eXosip, etc. Considering the maturity of online information, eXosip was chosen as the SIP basic library. Of course, since SIP signaling is a text protocol similar to HTTP, you can also consider implementing it yourself. Or use Node.js directly to do it. Since I implemented the entire project in C++, I chose eXosip.

  • RTP protocol library: In order to realize the transmission of audio and video streams, there are many underlying libraries that support the RTP/RTCP protocol, such as JRTP, ortp, and live555. Considering that RTP itself is not complicated and can be implemented by yourself, I used the latter here. .

  • Media library: Since the GB28181 device needs to provide video/audio streams, involving video file reading, decoding, encoding and other functions, using ffmpeg is the most appropriate solution.


[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-WpzYXRQP-1686798286928) (img/logo.jpg)]

Please add the author hbstream ( http://haibindev.cnblogs.com ) for cooperation. Please indicate the author and source when reprinting.

Guess you like

Origin blog.csdn.net/haibindev/article/details/131223819