Implementation method and device for converting RTP video stream into low-delay HTTP-PS video stream based on GB28181 protocol

By implementing the low-latency HTTP-PS video stream in the GB28181 protocol based on the HTTP protocol, the lack of video stream format conversion and automatic management functions in the prior art is solved, and low-latency and low-cost video streaming services are realized.

CN119854430AActive Publication Date: 2025-04-18ZHENGZHOU XINDA ADVANCED TECH RES INST

Patent Information

Application Number
CN202411853209.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-04-18
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

The prior art does not support direct output HTTP-PS video streams in the GB28181 protocol, and requires non-essential video stream format conversion, which increases computing overhead and end-to-end delay. It also does not support automatic source video stream management (pull streaming on demand) in the GB28181 protocol scenario.

Method used

By implementing the low-latency HTTP-PS video stream in the GB28181 protocol based on the HTTP protocol, the video stream format conversion is avoided, the calculation overhead and end-to-end delay is reduced, and the stream pull/disconnection is automatically achieved when the video stream is played/stopped, supporting on-demand stream pulling.

Benefits of technology

It realizes the low latency conversion of RTP video streams into HTTP-PS video streams in GB28181 protocol, reducing latency and computing overhead, and provides an out-of-the-box video streaming service through the automatic stream pull/disconnection function, reducing usage costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119854430A_ABST
    Figure CN119854430A_ABST
Patent Text Reader

Abstract

The invention provides an implementation method for converting a GB28181 protocol RTP video stream into a low-delay HTTP-PS video stream, which is applied to an HTTP-PS server and comprises the following steps: step 1, receiving a streaming media playing HTTP connection request of a client; step 2, analyzing a device code DEV1 and a channel code CHANNEL1 of a target video source from the streaming media playing HTTP connection request, and creating an HTTP response object; step 3, randomly acquiring an unused TCP port P1 from the local machine, and starting the Socket service S1 to monitor the port P1; step 4, initiating a stream taking request to the SIP server to request the SIP server to send the RTP video stream of the target video source to the Socket service S1; step 5, after the Socket service S1 receives the RTP data after each PS data packet is subpackaged sent by the target video source, the RTP data is packed in real time to obtain the PS data packet, and the PS data packet is written into the HTTP response object, so that the client obtains the PS packet data from the HTTP response object and displays a frame of live broadcast picture; and step 6, when monitoring that the HTTP connection is disconnected, stopping the Socket service S1.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of video surveillance technology, and in particular to a method and device for implementing GB28181 protocol RTP video stream conversion to low-latency HTTP-PS video stream. Background Art

[0002] In recent years, as public safety has received increasing attention, video surveillance has become increasingly important in maintaining social order. Due to compatibility and interoperability issues between different manufacturers, it is difficult for each system to achieve effective information sharing and interconnection, thus affecting the original value of public safety monitoring.

[0003] The GB28181 protocol was developed to solve this problem. It aims to provide a unified framework and specification to enable video surveillance devices from different manufacturers and platforms to interconnect and share information.

[0004] RTP (Real-time Transport Protocol) plays a vital role in the GB28181 protocol. As a part of the GB28181 protocol, it is mainly responsible for the transmission of real-time audio and video data in PS format. It provides functions such as streaming, timestamps, and sequence numbers to ensure the real-time and reliability of audio and video data. The role of RTP protocol in GB28181 protocol is as follows: Figure 1 shown.

[0005] ZLMediaKit is a streaming media service framework developed based on C++11. It supports multiple streaming protocols and can realize conversion between multiple protocols, such as RTSP, RTMP, HLS, GB28181, etc.; it supports L3 streaming live broadcast, and the end-to-end delay is kept at least within 1 second; it supports on-demand streaming of some protocols; it is widely used in scenarios such as video stream conversion and preview.

[0006] However, it has the following defects in the application of GB28181 protocol: 1. Direct output of HTTP-PS video stream (i.e. PS video stream with HTTP payload) is not supported. PS stream with RTP payload in GB28181 protocol needs to be converted into other formats, which introduces additional computing overhead and network delay. Output formats supported by ZLMediaKit are as follows: Figure 2 As shown; 2. It does not support automatic management of source video streams in GB28181 protocol scenarios (also known as on-demand streaming). After closing the playback, you need to manually cut off the sending of the source video stream; ZLMediaKit supports on-demand streaming of rtsp, rtmp, httpflv, and wsflv, but this feature is not yet supported in GB28181 application scenarios (because GB28181 RTP video streams are obtained in a special passive form and require SIP interaction). Its on-demand streaming is mainly implemented through the / index / api / addStreamProxy interface. This interface currently only supports rtsp / rtmp / hls / http-ts / http-flv format video streams.

[0007] In order to solve the above problems, people have been seeking an ideal technical solution. Summary of the invention

[0008] Based on this, it is necessary to provide a method and device for converting the RTP video stream in the GB28181 protocol into a low-latency HTTP-PS video stream in response to the above-mentioned technical problems, thereby avoiding video stream format conversion, reducing computing overhead and end-to-end delay, and automatically pulling / disconnecting the stream when the video stream is played / stopped to achieve on-demand streaming, providing ready-to-use video streaming services to the outside world, and reducing usage costs.

[0009] In order to achieve the above object, the first aspect of the present invention provides a method for converting a GB28181 protocol RTP video stream to a low-latency HTTP-PS video stream, which is applied to an HTTP-PS server and includes the following steps: Step 1, receiving a streaming media playback HTTP connection request from a client, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address, port number, device code and channel code of the HTTP-PS server; Step 2: parse the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and create an HTTP response object; Step 3, randomly obtain an unused TCP port P1 from the local machine, and start the Socket service S1 to listen to port P1; Step 4: Initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1; Step 5, when the socket service S1 receives the RTP data sent by the target video source after the first PS data packet is packetized, it packets the RTP data in real time to obtain the first PS data packet, and writes it into the HTTP response object, so that the client can obtain the first PS packet data from the HTTP response object and display the first frame of the live screen; Step 5, after receiving the RTP data of each PS data packet sent by the target video source, the socket service S1 packages the RTP data in real time to obtain the PS data packet, and writes it into the HTTP response object, so that the client can obtain the PS packet data from the HTTP response object and display a frame of live screen; Step 6: When the HTTP connection is disconnected, stop the Socket service S1.

[0010] In order to achieve the above-mentioned object, the second aspect of the present invention provides a device for implementing GB28181 protocol RTP video stream to low-latency HTTP-PS video stream, comprising: An HTTP connection request acquisition module is used to receive a streaming media playback HTTP connection request, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address, port number, device code and channel code of the HTTP-PS server; HTTP connection request parsing module, used for parsing the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and creating an HTTP response object; The port activation module is used to randomly obtain an unused TCP port P1 from the local machine and start the Socket service S1 to listen to the port P1; The stream request sending module is used to initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1; The data receiving module receives the RTP data sent by the target video source through the Socket service S1 after the i-th PS data packet is packetized, and the RTP data is packetized in real time to obtain the i-th PS data packet, and write it into the HTTP response object, so that the client can obtain the i-th PS packet data from the HTTP response object and display the corresponding live screen; The connection disconnection module is used to stop the Socket service S1 when it detects that the HTTP connection is disconnected.

[0011] In order to achieve the above object, the third aspect of the present invention provides a conversion system of a GB28181 protocol RTP video stream, comprising: Target video source, used to generate RTP video stream of GB28181 protocol; An HTTP-PS server, the HTTP-PS server being used to perform the steps of the method according to any one of claims 1 to 6; A network switch is used to enable communication between the target video source and the HTTP-PS service.

[0012] In order to achieve the above-mentioned purpose, the fourth aspect of the present invention provides a computer device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; the processor is used to implement the steps of the method described in the first aspect when executing the program stored in the memory.

[0013] In order to achieve the above-mentioned purpose, the fifth aspect of the present invention provides a computer program product, including a computer program, which implements the steps of the method in any one of the above-mentioned embodiments when executed by a processor.

[0014] The beneficial effects of the present invention are: The present invention realizes the conversion of RTP video stream into low-delay HTTP-PS video stream based on HTTP protocol, avoids video stream format conversion, and reduces computing overhead and end-to-end delay.

[0015] The present invention realizes on-demand streaming by automatically pulling / disconnecting the stream when the video stream is played / stopped, can provide a ready-to-use video stream service to the outside, and reduces the use cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a typical communication structure of GB28181 equipment.

[0017] Figure 2 It is the live broadcast format supported by ZLMediaKit.

[0018] Figure 3 It is a typical video key frame PS package structure.

[0019] Figure 4 It is a schematic diagram of the process of the method described in Example 1 of the present invention.

[0020] Figure 5 It is a principle block diagram of a verification embodiment of the present invention.

[0021] Figure 6 It is a rendering of the effect of step 1 of the verification embodiment of the present invention.

[0022] Figure 7 It is a rendering of the effect of step 2 of the verification embodiment of the present invention.

[0023] Figure 8 It is a rendering of step 3 of the verification embodiment of the present invention.

[0024] Fig. 9 It is a schematic diagram of the experimental results of verifying Example 1 of the present invention.

[0025] Fig.10 This is a result diagram of the initial use of the vlc player to directly play the ZlMedia video stream in Verification Example 2 of the present invention.

[0026] Fig.11 This is a result diagram of using a vlc player to play a ZlMedia video stream after manually calling the stream acquisition interface in Verification Example 2 of the present invention.

[0027] Fig.12 It is a result diagram of the VLC player playing the HTTP-PS video stream in Verification Example 2 of the present invention.

[0028] Fig.13 Schematic diagram of the structure of the device described in Example 2 of the present invention.

[0029] Fig.14 It is a flowchart of step 1 of the system described in Example 3 of the present invention.

[0030] Fig.15 It is a flowchart of step 3 of the system described in Example 3 of the present invention.

[0031] Fig.16 It is a flowchart of step 4 of the system described in Example 3 of the present invention.

[0032] Fig.17 It is a flowchart of step 5 of the system described in Example 3 of the present invention.

[0033] Fig.18 It is a flowchart of step 6 of the system described in Example 3 of the present invention.

[0034] Fig.19 It is a flowchart of step 7 of the system described in Example 3 of the present invention.

[0035] Fig. 20 It is a flowchart of step 9 of the system described in Example 3 of the present invention.

[0036] Fig.21 It is a schematic diagram of the structure of the computer device described in Example 4 of the present invention. DETAILED DESCRIPTION

[0037] The technical solution of the present invention is further described in detail below through specific implementation methods.

[0038] For ease of understanding, the interactive parties and / or terms and / or custom words involved in the present invention are first described in conjunction with the technical solution of the present invention: PS is the abbreviation of MPEG-PS, a packaging container for multiplexed digital audio and video, etc. It was originally designed for reliable and stable storage media such as CDs.

[0039] GB28181 protocol uses PS encapsulation of audio and video data based on RTP, which is used to encapsulate audio and video streams into PS packets, and then encapsulate PS packets into RTP packets in the form of payload. When performing PS encapsulation, it encapsulates each video frame into a PS packet, and the PS packet of each key frame contains a system header (System Header) and PSM (Program Stream Map). The system header and PSM are placed after the PS packet header and before the first PES packet. Figure 3 shown.

[0040] There are two technical problems in the existing solutions, as follows: Problem 1: The HTTP-PS format is not supported, resulting in unnecessary video stream format conversion, which increases computing overhead and end-to-end latency.

[0041] Question 2: It does not support automatic management of source video streams in GB28181 protocol scenarios (i.e., pulling streams on demand). Additional maintenance of opening and closing video streams is required, which increases usage costs.

[0042] To this end, the present invention addresses problem 1 by converting RTP video stream to low-latency HTTP-PS video stream based on the HTTP protocol, thereby avoiding video stream format conversion and reducing computing overhead and end-to-end delay.

[0043] In view of problem 2, the present invention realizes on-demand streaming by automatically pulling / disconnecting the stream when the video stream is played / stopped, and can provide a ready-to-use video streaming service to the outside world, thereby reducing the cost of use.

[0044] The technical solution of the present invention is further described in detail below through specific implementation methods.

[0045] Example 1 This embodiment provides a method for implementing a GB28181 protocol RTP video stream to a low-latency HTTP-PS video stream, which is applied to an HTTP-PS server, such as Figure 4 As shown, the following steps are included: Step 1, receiving a streaming media playback HTTP connection request from a client, wherein the streaming media playback HTTP connection request includes at least a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address, port number, device code and channel code of the HTTP-PS server.

[0046] Preferably, the client is usually a web-based streaming media player, a mobile-based streaming media player, a VLC player, an FFMPEG client, etc.

[0047] Step 2: parse the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and create an HTTP response object.

[0048] In some embodiments, parsing the device code DEV1 and the channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request includes: Get the video stream identification URL string from the streaming media playback HTTP connection request; The regular expression matching function is called to match the video stream identifier URL string to obtain the device code DEV1 and channel code CHANNEL1 of the target video source.

[0049] Step 3, randomly obtain an unused TCP port P1 from the local machine, and start the Socket service S1 to listen to port P1.

[0050] The specific steps of step 3 include: Step 3.1, randomly obtain a port p in the local TCP / 20000-30000 port range; Step 3.2, try to bind the port. If the port binding attempt succeeds, it proves that port p is available. Let P1 equal to p and go to step 3.3. If the port binding attempt fails, it proves that port p is unavailable, then return to step 3.1. Step 3.3, start TCP Socket service S1 to listen on port P1.

[0051] Step 4: Initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1.

[0052] The specific steps of step 4 include: Step 4.1, initiating a stream acquisition request to the SIP server according to its own IP, its own port P1, the device code DEV1 of the target video source, and the channel code CHANNEL1, wherein the stream acquisition request at least includes parameters DEV1, CHANNEL1, IP, and P1, so that the SIP server receives the stream acquisition request, determines the target video source according to DEV1 and CHANNEL1, and initiates a stream acquisition operation to the target video source, instructing the target video source to send the video stream to the HTTP-PS server corresponding to (IP, P1) in TCP mode; Step 4.2, receiving the TCP connection request initiated by the target video source, and establishing CONN1 with the target video source, so that the target video source can send PS data packets to the Socket service S1 through CONN1.

[0053] Step 5, after receiving the RTP data after each PS data packet sent by the target video source, Socket service S1 packages the RTP data in real time to obtain the PS data packet and writes it into the HTTP response object so that the client can obtain the PS packet data from the HTTP response object and display a frame of live screen.

[0054] Specifically, the specific steps of step 5 are as follows: Socket service S1 receives RTP data sent by the target video source one by one and caches them, wherein the RTP data includes RTP packets corresponding to the i-th PS data packet: RTP packet 1, RTP packet 2, RTP packet 3...RTP packet m, which are written one by one by the target video source to the CONN1 object, and i is an integer; Each time an RTP packet is received, determine whether its subpacket end flag is 1. If the subpacket end flag is not 1, store the RTP packet in the buffer and continue to receive the next RTP packet. If the subpacket end flag is 1, group all RTP packets in the buffer to obtain the i-th PS data packet. The i-th PS data packet is written into the HTTP response object, so that the client can obtain the corresponding PS packet data from the HTTP response object for screen display.

[0055] Step 6: When the HTTP connection is disconnected, stop the Socket service S1.

[0056] Compared with the existing solutions, the beneficial effects achieved by the present invention are: (1) it realizes the conversion of PS video stream carried by RTP in GB28181 protocol to HTTP-PS video stream, which avoids video format conversion and reduces end-to-end delay compared with the existing solutions.

[0057] (2) It realizes automatic on-demand streaming, reduces complicated interface control and reduces the cost of using GB28181 video streams compared with existing solutions.

[0058] Furthermore, this embodiment provides a verification experiment to prove the beneficial effects achieved in the above two aspects.

[0059] 1. Hardware environment like Figure 5 As shown, the Windows workstation uses an i7-10700 processor, 16G memory, the operating system is Windows 10 Home Edition, the network is a 1000M wired network, and the IP is 192.168.1.164.

[0060] Ubuntu workstation, CPU uses Ryzen7-3700X processor, memory 32G, operating system is Ubuntu24.04Server version, network is 1000M wired network, IP is 192.168.1.122.

[0061] 2. Software Environment Windows workstation, the real-time timestamp program uses TimeSync, the virtual GB28181 program uses the GB28181 Device binary software produced by HappyTimeSoft, VLC uses version 3.0.21, and ffplay uses the official pre-compiled binary version based on ffmpeg7.0.

[0062] Ubuntu workstation, GB28181 signaling service uses wvp-GB28181-pro, ZlMedia streaming media service uses ZlMedia official pre-built Docker image, HTTP-PS service is developed using this embodiment and executed in Docker container mode.

[0063] 3. Experimental environment construction Step 1: Start the GB28181 signaling service, i.e. wvp-GB28181-pro service, on the Ubuntu workstation, start the ZlMedia streaming service, and associate the ZlMedia service with the wvp-GB28181-pro service. Figure 6 shown.

[0064] Start the HTTP-PS service (implementation of this method) and associate the video stream interface of the wvp-GB28181-pro service.

[0065] HTTP-PS uses environment variable configuration to achieve on-demand streaming. When starting the HTTP-PS service, the value of the environment variable INVITE_API is set to: http: / / 192.168.1.122:18080 / api / play / startSVAC. This variable is used to automatically initiate a streaming call to the signaling server when streaming is on demand.

[0066] Step 2: Start the TimeSync window program on the Windows workstation. Figure 7 shown.

[0067] Step 3: Configure the virtual GB28181 device program (GB28181 Device) to capture the window in step 2 as the video source, and register it with the wvp-GB28181-pro service started in step 1.

[0068] After successful registration, the wvp-GB28181-pro service device list is as follows Figure 8 shown.

[0069] Step 4: Get the video stream URLs corresponding to the Zlmedia service and HTTP-PS service, as shown in the following table: Types of streaming services Video stream URL ZlMedia http: / / 192.168.1.122:40080 / rtp / 41000000112008000164_41000000112008000164.live.mp4 HTTP-PS (this embodiment) http: / / 192.168.1.122:8019 / gb28181 / 41000000112008000164 / 41000000112008000164.ps Experiment 1: End-to-end delay experiment The end-to-end delay can be expressed as the difference between the time displayed by the real-time timestamp program TimeSync and the real-time playback image in ffplay's no-buffer mode. Fig. 9 The median end-to-end latency was 341 milliseconds.

[0070] It is understandable that a single measurement of end-to-end delay is unreliable for evaluating streaming services. In order to more accurately represent the end-to-end delay, the following formula is used:

[0071] in Representative The value of the end-to-end delay measured.

[0072] The results of the end-to-end latency experiment using ffplay on a Windows workstation are as follows:

[0073] The data shows that under the current experimental conditions, this solution can reduce the end-to-end average delay of ZlMedia by 22 milliseconds, which is significantly better than the existing solution.

[0074] Experiment 2: Automatic flow acquisition on demand In order to verify the superiority of the method described in this embodiment in automatically obtaining streams on demand, the number of additional interface calls required when playing video streams between ZlMedia and HTTP-PS (based on the implementation of this method) was compared using a VLC player on a Windows workstation.

[0075] Use vlc player to play ZlMedia video stream directly Fig.10 shown.

[0076] After manually calling the stream acquisition interface, use the vlc player to play the ZlMedia video stream as follows Fig.11 As shown, the normal playback of its video stream still relies on additional interface calls.

[0077] Use vlc player to directly play HTTP-PS video stream Fig.12 As shown in the figure, it realizes on-demand flow acquisition and is ready for use.

[0078] The experimental results are summarized as follows: Types of streaming services Player Additional interface calls Automatic flow ZlMedia vlc 1 Not supported HTTP-PS (this solution) vlc 0 support Experimental results show that this method realizes automatic on-demand streaming, reduces complicated interface control compared with existing solutions, supports direct playback without additional interface calls, and reduces the cost of using GB28181 video streams.

[0079] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0080] Example 2 Based on the same inventive concept, the embodiment of the present application also provides a GB28181 protocol RTP video stream to low-latency HTTP-PS video stream implementation device for implementing the above-mentioned GB28181 protocol RTP video stream to low-latency HTTP-PS video stream implementation method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more device embodiments provided below can refer to the limitations of the implementation method for converting GB28181 protocol RTP video stream to low-latency HTTP-PS video stream in Example 1 or Example 2, which will not be repeated here.

[0081] Specifically, Fig.13 As shown, the device for implementing the conversion of the GB28181 protocol RTP video stream to a low-latency HTTP-PS video stream includes: An HTTP connection request acquisition module is used to receive a streaming media playback HTTP connection request, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address, port number, device code and channel code of the HTTP-PS server; HTTP connection request parsing module, used for parsing the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and creating an HTTP response object; The port activation module is used to randomly obtain an unused TCP port P1 from the local machine and start the Socket service S1 to listen to the port P1; The stream request sending module is used to initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1; The data receiving module receives the RTP data sent by the target video source through the Socket service S1 after the i-th PS data packet is packetized, and the RTP data is packetized in real time to obtain the i-th PS data packet, and write it into the HTTP response object, so that the client can obtain the i-th PS packet data from the HTTP response object and display the corresponding live screen; The HTTP connection disconnection module is used to stop the Socket service S1 when the HTTP connection is disconnected.

[0082] Example 3 This embodiment provides a GB28181 protocol RTP video stream conversion system, including: Target video source, used to generate RTP video stream of GB28181 protocol; An HTTP-PS server, the HTTP-PS server being used to perform the steps of the method according to any one of claims 1 to 6; A network switch is used to enable communication between the target video source and the HTTP-PS service.

[0083] like Figure 14-20 As shown, the conversion system is implemented specifically according to the following steps: Step 1: The client constructs a video stream identification URL string according to the device code DEV1 and channel code CHANNEL1 rules of the target video source.

[0084] The specific steps of step 1 are as follows: Step 1.1, the client obtains the IP and port of the HTTP-PS server; Step 1.2, the client obtains the device code DEV1 and channel code CHANNEL1 of the target video source; Step 1.3, the client calls the URL concatenation function to construct a video stream identification URL string using the IP address of the HTTP-PS server, the port number of the HTTP-PS server, the device code and the channel code obtained in step 1.1; The client in step 1 is usually a web-based streaming media player, a mobile streaming media player, a VLC player, an FFMPEG client, etc.

[0085] Step 2: The client initiates a streaming media playback HTTP connection request to the HTTP-PS server, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL character string.

[0086] Step 3, the HTTP-PS server obtains the video stream identification URL string from the HTTP request, parses the target video source device code DEV1 and channel code CHANNEL1 from the video stream identification URL string, and then creates an HTTP response object.

[0087] The specific steps of step 3 are as follows: Step 3.1, the HTTP-PS server obtains the HTTP request initiated by the client; Step 3.2, HTTP-PS obtains the video stream playback URL string from the HTTP request; Step 3.3, the HTTP-PS server calls the regular expression matching function, passes the video stream playback URL string obtained in step 3.2 to the corresponding string matching function, and parses the target video source device code DEV1 and channel code CHANNEL1.

[0088] Step 4: The HTTP-PS server randomly obtains an unused TCP port P1 from the local machine and starts the Socket service S1 to listen to port P1.

[0089] Step 4 is as follows: Step 4.1, the HTTP-PS server randomly obtains a port p in the local TCP / 20000-30000 port range; Step 4.2, try to bind the port. If the port binding attempt succeeds, it proves that port p is available. Let P1 equal to p and go to step 4.3. If the port binding attempt fails, it proves that port p is unavailable, then go to step 4.1. Step 4.3, start TCP Socket service S1 listening on port P1.

[0090] Step 5: The HTTP-PS server initiates a stream request to the SIP server, requesting it to send the RTP video stream of the target video source (device code DEV1 and channel code CHANNEL1) to the Socket service S1. The target video source initiates a TCP connection CONN1 to S1.

[0091] Step 5 specifically includes: Step 5.1, the HTTP-PS server initiates a stream acquisition request to the SIP server according to the target video source device code DEV1, channel code CHANNEL1, IP in step 1, and port P1 in step 4.3 obtained in step 3.2, and passes the following key parameters: DEV1, CHANNEL1, IP, P1; Step 5.2, the SIP server receives the request and extracts the parameters DEV1, CHANNEL1, IP, and P1; Step 5.3, the SIP server initiates a stream acquisition operation to the target video source, instructing it to send the video stream in TCP mode to the following address: (IP, P1); Step 5.4, the target video source initiates a TCP connection request to (IP, P1); Step 5.5: A connection CONN1 is successfully established between the target video source and S1 (established in step 4.3).

[0092] Step 6, the target video source sends the RTP data after the first PS data packet is subdivided to S1 through CONN1. The Socket service S1 in the HTTP-PS server receives the RTP data sent by the target device. The HTTP-PS server assembles the RTP video stream in real time to obtain the first PS data packet, and then immediately writes it into the HTTP response object. The client obtains the first PS packet data from the HTTP response object and displays the first frame of the live broadcast.

[0093] Step 6 is as follows: Step 6.1, the target video source writes the RTP packets corresponding to the first PS data packet into the CONN1 object one by one: RTP packet 1, RTP packet 2, RTP packet 3...RTP packet m; Step 6.2, the Socket service S1 of the HTTP-PS server receives the RTP data sent by the target video source one by one: RTP packet 1, RTP packet 2, RTP packet 3...RTP packet m; Step 6.3, after receiving RTP packet m, the HTTP-PS server finds that its subpacketization end flag is 1, and assembles all RTP packets in the buffer to obtain the first PS data packet; Step 6.4, the HTTP-PS server writes the first PS data packet into the HTTP response object; Step 6.5: The client obtains the first PS packet data from the HTTP response and displays the first live frame.

[0094] Step 7, the target video source sends the RTP data after the next PS data packet is subdivided to S1 through CONN1. The Socket service S1 in the HTTP-PS server receives the new RTP data sent by the target device. The HTTP-PS server assembles the RTP video stream in real time, obtains the next PS data packet, and then immediately writes it into the HTTP response object. The client obtains the next PS packet data from the HTTP response object and displays the next frame of the live screen.

[0095] Step 7 is as follows: Step 7.1, the target video source writes the RTP packets corresponding to the kth PS data packet into the CONN1 object one by one: RTP packet k, RTP packet k+1, RTP packet k+2...RTP packet k+n; Step 7.2, the Socket service S1 of the HTTP-PS server receives the RTP data sent by the target video source one by one: RTP packet k, RTP packet k+1, RTP packet k+2...RTP packet k+n; Step 7.3, after receiving RTP packet k+n, the HTTP-PS server finds that its packet end flag is 1, and assembles all RTP packets in the buffer to obtain the kth PS data packet; Step 7.4, the HTTP-PS server writes the kth PS data packet into the HTTP response object; Step 7.5: The client obtains the kth PS packet data from the HTTP response and displays the kth live frame.

[0096] Step 8: By repeating step 7, the client continues to watch the picture for N seconds.

[0097] Step 9: The client closes the viewing window and disconnects the HTTP connection maintained with the HTTP-PS server, and the HTTP-PS server stops receiving the RTP video stream sent by the target video source.

[0098] Step 9 is as follows: Step 9.1 The client closes the playback window; Step 9.2 The client disconnects the HTTP connection maintained between the client and the HTTP-PS server; Step 9.3 The HTTP-PS server detects that the HTTP connection is disconnected; Step 9.4 The HTTP-PS server stops the TCP Socket service S1 and stops listening on port P1; Step 9.5: The CONN1 connection (established in step 5.5) is disconnected, and the RTP video stream sent by the target video source is stopped.

[0099] Example 4 This embodiment provides a computer device, which may be a terminal, and its internal structure diagram may be as follows: Fig.21 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for implementing a GB28181 protocol RTP video stream to a low-latency HTTP-PS video stream. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0100] Those skilled in the art will understand that Fig.21The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0101] Example 6 On the basis of the above embodiments, this embodiment provides a computer program product, including a computer program, which implements the following steps when executed by a processor: Step 1, receiving a streaming media playback HTTP connection request from a client, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address of the HTTP-PS server, the port number of the HTTP-PS server, the device code, and the channel code; Step 2: parse the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and create an HTTP response object; Step 3, randomly obtain an unused TCP port P1 from the local machine, and start the Socket service S1 to listen to port P1; Step 4: Initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1; Step 5, after receiving the RTP data of each PS data packet sent by the target video source, the socket service S1 packages the RTP data in real time to obtain the PS data packet, and writes it into the HTTP response object, so that the client can obtain the PS packet data from the HTTP response object and display a frame of live screen; Step 6: When the HTTP connection is disconnected, stop the Socket service S1.

[0102] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0103] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0104] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present invention, which should be included in the scope of the technical solution for protection of the present invention.

Claims

1. A method for converting GB28181 protocol RTP video stream to low-latency HTTP-PS video stream, applied to HTTP-PS server, characterized in that: The following steps are involved: Step 1, receiving a streaming media playback HTTP connection request from a client, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address, port number, device code and channel code of the HTTP-PS server; Step 2: parse the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and create an HTTP response object; Step 3, randomly obtain an unused TCP port P1 from the local machine, and start the Socket service S1 to listen to port P1; Step 4: Initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1; Step 5, after receiving the RTP data of each PS data packet sent by the target video source, the socket service S1 packages the RTP data in real time to obtain the PS data packet, and writes it into the HTTP response object, so that the client can obtain the PS packet data from the HTTP response object and display a frame of live screen; Step 6: When the HTTP connection is disconnected, stop the Socket service S1.

2. A method for implementing a GB28181 protocol RTP video stream to a low-delay HTTP-PS video stream according to claim 1, characterized in that: In step 2, the device code DEV1 and channel code CHANNEL1 of the target video source are parsed from the streaming media playback HTTP connection request, including: Get the video stream identification URL string from the streaming media playback HTTP connection request; The regular expression matching function is called to match the video stream identifier URL string to obtain the device code DEV1 and channel code CHANNEL1 of the target video source.

3. A method for implementing a GB28181 protocol RTP video stream to a low-delay HTTP-PS video stream according to claim 1 or 2, characterized in that: The specific steps of step 3 include: Step 3.1, randomly obtain a port p in the local TCP / 20000-30000 port range; Step 3.2, try to bind the port. If the port binding attempt succeeds, it proves that port p is available. Let P1 equal to p and go to step 3.

3. If the port binding attempt fails, it proves that port p is unavailable, then return to step 3.

1. Step 3.3, start TCP Socket service S1 to listen on port P1.

4. A method for implementing a GB28181 protocol RTP video stream to a low-delay HTTP-PS video stream according to claim 3, characterized in that: The specific steps of step 4 include: Step 4.1, initiating a stream acquisition request to the SIP server according to its own IP, its own port P1, the device code DEV1 of the target video source, and the channel code CHANNEL1, wherein the stream acquisition request at least includes parameters DEV1, CHANNEL1, IP, and P1, so that the SIP server receives the stream acquisition request, determines the target video source according to DEV1 and CHANNEL1, and initiates a stream acquisition operation to the target video source, instructing the target video source to send the video stream to the HTTP-PS server corresponding to (IP, P1) in TCP mode; Step 4.2, receiving the TCP connection request initiated by the target video source, and establishing CONN1 with the target video source, so that the target video source can send PS data packets to the Socket service S1 through CONN1.

5. A method for implementing a GB28181 protocol RTP video stream to a low-delay HTTP-PS video stream according to claim 1, characterized in that: In step 5 and step 6, the Socket service S1 receives the RTP data sent by the target video source one by one and caches them, wherein the RTP data includes the RTP packets corresponding to the i-th PS data packet: RTP packet 1, RTP packet 2, RTP packet 3...RTP packet m, which are written one by one by the target video source into the CONN1 object; Each time an RTP packet is received, determine whether its subpacket end flag is 1. If the subpacket end flag is not 1, store the RTP packet in the buffer and continue to receive the next RTP packet. If the subpacket end flag is 1, group all RTP packets in the buffer to obtain the i-th PS data packet. The i-th PS data packet is written into the HTTP response object, so that the client can obtain the corresponding PS packet data from the HTTP response object for screen display.

6. According to the implementation method of a GB28181 protocol RTP video stream to low-delay HTTP-PS video stream according to claim 1, step 7 specifically comprises: Step 7.1, when it is detected that the HTTP connection with the client is disconnected, the TCP Socket service S1 is stopped and the listening port P1 is stopped; wherein the HTTP connection is disconnected by the client after closing the playback window; Step 7.2: disconnect CONN1 and stop receiving the RTP video stream sent by the target video source.

7. A device for implementing GB28181 protocol RTP video stream to low-latency HTTP-PS video stream, characterized in that: include: An HTTP connection request acquisition module is used to receive a streaming media playback HTTP connection request, wherein the streaming media playback HTTP connection request at least includes a video stream identification URL string, and the video stream identification URL string is formed by the client concatenating the IP address, port number, device code and channel code of the HTTP-PS server; HTTP connection request parsing module, used for parsing the device code DEV1 and channel code CHANNEL1 of the target video source from the streaming media playback HTTP connection request, and creating an HTTP response object; The port activation module is used to randomly obtain an unused TCP port P1 from the local machine and start the Socket service S1 to listen to the port P1; The stream request sending module is used to initiate a stream request to the SIP server to request it to send the RTP video stream of the target video source to the Socket service S1; The data receiving module receives the RTP data sent by the target video source through the Socket service S1 after the i-th PS data packet is packetized, and the RTP data is packetized in real time to obtain the i-th PS data packet, and write it into the HTTP response object, so that the client can obtain the i-th PS packet data from the HTTP response object and display the corresponding live screen; The connection disconnection module is used to stop the Socket service S1 when it detects that the HTTP connection is disconnected.

8. A conversion system for GB28181 protocol RTP video stream, characterized in that: include: Target video source, used to generate RTP video stream of GB28181 protocol; An HTTP-PS server, the HTTP-PS server being used to perform the steps of the method according to any one of claims 1 to 6; A network switch is used to enable communication between the target video source and the HTTP-PS service.

9. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, configured to implement the steps of the method according to any one of claims 1 to 6 when executing a program stored in a memory.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method and system for playing video in browser webpage

    CN112422508A

  • Method for equipment supporting GB / T28181 protocol to check in mainstream browser

    CN112866199A

  • Method for optimizing national standard GB28181 real-time video stream on demand

    CN116346790A

  • Implementation method of self-adaptive coding streaming media service for security and protection video monitoring

    CN118353883A

  • Signalling Gateway, Method, Computer Program And Computer Program Product For Communication Between HTTP And SIP

    US20130232217A1

Cited By

  • HTTP3-based GB / T28181 monitoring video stream transmission and decoding method and electronic equipment

    CN121691824A