Video distribution method, device, electronic device and storage medium
By pre-constructing the address storage list in the user state and processing video requests and video streams in the kernel state, the problems of video distribution delay and high resource utilization in the prior art are solved, and more efficient video distribution is achieved.
Patent Information
- Application Number
- CN202011009362.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-23
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2040-09-23
AI Technical Summary
The existing video stream distribution technology is implemented in the operating system user mode, resulting in increased video distribution delay and more memory and CPU resources required, which is less time-consuming.
By pre-constructing an address storage list in the user state, storing the source address and target address of the video request, obtaining the source address list and target address list, and transmitting the target address list to the kernel state. Then, the video request is transmitted to the video sender through the kernel state according to the source address list, the video stream is obtained from the video sender, and the video stream is forwarded to the video receiving end in the kernel state.
It reduces the video stream memory copy time, reduces the delay in video distribution, avoids frequent CPU context switching, and reduces CPU resource usage, thereby improving the speed and timeliness of video distribution.
Smart Images

Figure CN112153338B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to data processing technology, and in particular to a video distribution method, device, electronic device and computer-readable storage medium. Background Art
[0002] Video distribution technology is particularly important in the field of video surveillance. Video distribution is the core function of video surveillance platform software. Its purpose is to distribute the video stream from the camera (video transmitter) to multiple different users (video receivers) so that multiple users can preview the same video or different videos. For example, in the field of digital medicine, hospitals can monitor and manage hospital security, personnel flow, and incoming and outgoing patients through remote monitoring. The monitoring and management end usually requires the video surveillance platform software to distribute the video stream of the relevant area to multiple different monitoring and management departments. Because current video surveillance systems usually deploy a large number of cameras, the performance of video distribution determines the cost of the entire video surveillance platform.
[0003] Existing video stream distribution technologies are all implemented in the operating system user state, but implementing video distribution through the operating system user state has the following disadvantages:
[0004] First, the delay of video distribution increases; a large amount of video data is copied back and forth from the operating system kernel state to the user state, which increases the processing time;
[0005] Second, it requires more memory and higher CPU resources. A large amount of video data requires twice as much memory space from the operating system kernel state to the user state. At the same time, the frequent copying of data causes the CPU to frequently switch contexts, which generates more CPU resources and results in slower video distribution.
[0006] In summary, existing video distribution technologies have the problem of low timeliness. Summary of the invention
[0007] The present invention provides a video distribution method, device, electronic device and computer-readable storage medium, the main purpose of which is to improve the timeliness of video distribution.
[0008] To achieve the above object, the present invention provides a video distribution method, comprising:
[0009] Receive a video request from a video receiving end, store a source address and a target address of the video request in an address storage list pre-constructed in a user state, obtain a source address list and a target address list, and transmit the target address list to a kernel state;
[0010] According to the source address list, transmitting the video request to the corresponding video sending end through the kernel state, obtaining the corresponding video stream from the video sending end, and returning the video stream to the kernel state;
[0011] According to the target address list, the video stream is forwarded to the corresponding video receiving end using the kernel state.
[0012] Optionally, storing the source address and the target address of the video request in the address storage list pre-constructed in the user state, and obtaining the source address list and the target address list comprises:
[0013] Obtaining the IP address and port of the video sending end corresponding to the video request, and generating the source address of the video request according to the IP address and port of the video sending end;
[0014] Acquire the IP address and port of the video receiving end corresponding to the video request, and generate the target address of the video request according to the IP address and port of the video receiving end;
[0015] The source address and the target address of the video request are stored in an address storage list pre-constructed in user mode to obtain a source address list and a target address list.
[0016] Optionally, transmitting the video request to a corresponding video sending end in kernel mode according to the source address list, and obtaining a video stream from the video sending end includes:
[0017] According to the source address in the source address list, obtaining the service address of the corresponding video sending end;
[0018] According to the service address, a window connection channel with the video sending end is constructed through kernel mode;
[0019] The video request is transmitted to the video sending end according to the window connection channel, and the video stream sent by the video sending end is received.
[0020] Optionally, the step of constructing a window connection channel with the video sending end in kernel mode according to the service address includes:
[0021] The IP address and port of the service address are obtained, the IP address and port of the service address are configured in the kernel state, and the construction of the window connection channel is executed.
[0022] Optionally, forwarding the video stream to a corresponding video receiving end by using the kernel state according to the target address list includes:
[0023] Capturing the IP data packet of the video stream, and matching the IP data packet with the target address in the target address list;
[0024] If the match fails, recapture the IP data packets of the video stream;
[0025] If the match is successful, the video stream is forwarded to the corresponding video receiving end through the kernel state according to the target address.
[0026] Optionally, capturing an IP data packet of the video stream and matching the IP data packet with a target address in the target address list comprises:
[0027] Determining whether the IP data packet belongs to the User Datagram Protocol according to the header field in the IP data packet;
[0028] If it does not belong to the User Datagram Protocol, continue to capture IP data packets;
[0029] If it belongs to the User Datagram Protocol, parse out the IP address and port of the IP datagram;
[0030] According to the IP address and port of the IP data packet, the IP data packet is matched with the target address in the target address list.
[0031] Optionally, performing matching of the IP data packet with a target address in the target address list according to the IP address and port of the IP data packet includes:
[0032] Obtain the IP address and port of the target address;
[0033] Identify the address match between the IP address of the IP data packet and the IP address of the target address, and identify the port match between the port of the IP data packet and the port of the target address;
[0034] The IP data packet is matched with the target address in the target address list according to the address matching degree and the port matching degree.
[0035] In order to solve the above problem, the present invention further provides a video distribution device, the device comprising:
[0036] A storage module, used for receiving a video request from a video receiving end, storing a source address and a target address of the video request in a user state, obtaining a source address list and a target address list, and transmitting the target address list to a kernel state;
[0037] A transmission module, configured to transmit the video request to a corresponding video sending end through a kernel state according to the source address list, obtain a corresponding video stream from the video sending end, and return the video stream to the kernel state;
[0038] The forwarding module is used to forward the video stream to the corresponding video receiving end through the kernel state.
[0039] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0040] a memory storing at least one instruction; and
[0041] The processor executes the instructions stored in the memory to implement the video distribution method described above.
[0042] In order to solve the above problem, the present invention further provides a computer-readable storage medium, wherein at least one instruction is stored in the computer-readable storage medium, and the at least one instruction is executed by a processor in an electronic device to implement the above-mentioned video distribution method.
[0043] According to the video request, the embodiment of the present invention obtains the corresponding video stream from the video sending end through the kernel state, and searches for the distribution destination address of the video stream from the target address in the kernel state, and further sends the video stream to the video receiving end in the kernel state according to the distribution destination address found. The present invention does not need to copy the video stream from the kernel state to the user state, which reduces the video stream memory copy time, reduces the delay of video distribution, and avoids the frequent context switching of the CPU of the video distribution system, reduces the excessive CPU resources occupied, and thus improves the speed of video distribution. Therefore, a video distribution method, device, electronic device and storage medium proposed by the present invention can improve the timeliness of video distribution. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 A schematic diagram of a flow chart of a video distribution method provided by an embodiment of the present invention;
[0045] Figure 2 In the first embodiment of the present invention Figure 1 A detailed implementation flowchart of one of the steps in the provided video distribution method;
[0046] Figure 3 In the first embodiment of the present invention Figure 1 A detailed implementation flowchart of another step in the provided video distribution method;
[0047] Figure 4 In the first embodiment of the present invention Figure 1A detailed implementation flow diagram of the address matching method in step S3 of the provided video distribution method;
[0048] Figure 5 A schematic diagram of a module of a video distribution device provided by an embodiment of the present invention;
[0049] Figure 6 A schematic diagram of the internal structure of an electronic device for implementing a video distribution method provided by an embodiment of the present invention;
[0050] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0051] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0052] The embodiment of the present application provides a video distribution method, and the execution subject of the video distribution method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the video distribution method can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0053] Reference Figure 1 FIG. 1 is a flow chart of a video distribution method provided by an embodiment of the present invention. In the embodiment of the present invention, the video distribution method includes:
[0054] S1. Receive a video request from a video receiving end, store a source address and a target address of the video request in an address storage list pre-constructed in a user state, obtain a source address list and a target address list, and transmit the target address list to a kernel state.
[0055] In at least one embodiment of the present invention, the video receiving end refers to an electronic device that receives a video stream, such as a mobile phone, a tablet, and a PC. In an embodiment of the present invention, the source address and the target address of the video request are stored in an address storage list pre-constructed in the user state, and the target address list is further transmitted to the kernel state, which reduces the data copy time of the subsequent video stream, thereby improving the distribution speed of the video stream. Wherein, the address storage list refers to a data storage structure table, preferably, it is constructed by SQL statements in the present invention, and is used to store the video addresses of different video receiving ends and video sending ends.
[0056] In a preferred embodiment of the present invention, the video request refers to obtaining the user-required video from the video sending end and transmitting it to the video receiving end, wherein the user-required video can be a surveillance video of a certain road section or a short video, etc.
[0057] For details, see Figure 2 As shown, the source address and the target address of the video request are stored in the address storage list pre-constructed in the user state, and the source address list and the target address list are obtained, including:
[0058] S10, obtaining the IP address and port of the video sending end corresponding to the video request, and generating the source address of the video request according to the IP address and port of the video sending end;
[0059] S11, obtaining the IP address and port of the video receiving end corresponding to the video request, and generating a target address of the video request according to the IP address and port of the video receiving end;
[0060] S12. Storing the source address and the target address of the video request in an address storage list pre-constructed in user mode to obtain a source address list and a target address list.
[0061] Among them, the source address refers to the address of the video sending end of the video request, the target address refers to the address of the video receiving end of the video request, and the source address list and the target address list refer to a list structure for storing corresponding source addresses and target addresses.
[0062] In a preferred embodiment of the present invention, by checking the properties of the video sending end and the video receiving end, the IP address and port of the corresponding video sending end and the IP address and port of the video receiving end are obtained. For example, the video sending end is a PC, and the user clicks on the properties in the PC to obtain the IP address and port of the PC, wherein the IP address of the PC is used to describe its network location, and the port describes the corresponding network service it provides.
[0063] In a preferred embodiment of the present invention, the IP address and port of the video sending end are combined to obtain the source address of the video request, and the IP address and port of the video receiving end are combined to obtain the target address of the video request. For example, the IP address of the video sending end is: 183.168.14.152, and the port of the video sending end is: 80. They are combined to obtain the source address: 183.168.14.152+80.
[0064] Preferably, the embodiment of the present invention copies the target address list to the kernel state through SQL language for subsequent direct transmission of the video stream, avoiding copying the video stream data by querying the corresponding target address through user state, thereby reducing memory and CPU processing time.
[0065] S2. According to the source address list, the video request is transmitted to the corresponding video sending end through the kernel state, a video stream is obtained from the video sending end, and the video stream is returned to the kernel state.
[0066] In at least one embodiment of the present invention, refer to Figure 3 As shown, the video request is transmitted to the corresponding video sending end through the kernel state according to the source address list to obtain the video stream, including:
[0067] S20, acquiring a service address of a corresponding video sending end according to a source address in the source address list;
[0068] S21, constructing a window connection channel with the video sending end through kernel state according to the service address;
[0069] S22. Transmit the video request to the video sending end according to the window connection channel, and receive the video stream sent by the video sending end.
[0070] In an optional embodiment of the present invention, obtaining the service address corresponding to the video sending according to the source address in the source address list includes: obtaining the IP address and port of the corresponding video sending end based on the IP address and port of the source address, and obtaining the service address of the video sending end.
[0071] In an optional embodiment of the present invention, constructing a window connection channel between the kernel state and the video sending end according to the service address includes: obtaining the IP address and port of the service address, configuring the IP address and port of the service address in the kernel state window, and executing the construction of the window connection channel. Preferably, the IP address and port of the service address are configured in the kernel state window using C++ language.
[0072] In an optional embodiment of the present invention, the video request is transmitted to the video sending end, and the video stream sent by the video sending end is received, including: based on the video request, querying the corresponding video data in the video sending end to obtain the video stream, for example, the video stream can be a surveillance product of a hospital waiting area. It is understandable that in other scenarios, the video stream can also be considered as a surveillance video of a traffic accident on a certain road section, a short video of a song MV, or an electronic video of a newlywed wedding highlights.
[0073] Preferably, the embodiment of the present invention returns the video stream to the kernel state according to the window channel.
[0074] It should be emphasized that in order to further ensure the security of the above video stream, the above video stream can be stored in a blockchain node.
[0075] S3. According to the target address list, forward the video stream to the corresponding video receiving end using the kernel state.
[0076] In a preferred embodiment of the present invention, S3 includes: capturing the IP data packet of the video stream, matching the IP data packet with the target address in the target address list; if the match fails, re-capturing the IP data packet of the video stream; if the match succeeds, forwarding the video stream to the corresponding video receiving end through the kernel state according to the target address.
[0077] In an optional implementation, the video stream is forwarded to a video receiving end through a network layer in the kernel state.
[0078] Wherein, the IP data packet refers to a data packet for video stream transmission on the Internet by the TCP / IP protocol. Preferably, the IP data packet of the video stream in the embodiment of the present invention is captured by the hook function (HOOK technology) of the Netfiter framework in the kernel state, and the transmission protocol of the corresponding video stream can be identified in advance, which is conducive to the direct transmission of subsequent IP data packets.
[0079] Further, see Figure 4 As shown, the capturing of the IP data packet of the video stream and matching the IP data packet with the target address in the target address list comprises:
[0080] S30, judging whether the IP data packet belongs to the User Datagram Protocol according to the header field in the IP data packet;
[0081] S31, if it does not belong to the User Datagram Protocol, continue to capture the IP datagram;
[0082] S32. If it belongs to the User Datagram Protocol, the IP address and port of the IP datagram are parsed, and the IP datagram is matched with the target address in the target address list according to the IP address and port of the IP datagram.
[0083] In a preferred embodiment of the present invention, the header field in the IP data packet is a protocol field, and the User Datagram Protocol refers to a connectionless transmission protocol.
[0084] Specifically, performing matching of the IP data packet with the target address in the target address list according to the IP address and port of the IP data packet includes:
[0085] Obtain the IP address and port of the target address, identify the address match between the IP address of the IP data packet and the IP address of the target address, and identify the port match between the port of the IP data packet and the port of the target address, and perform matching between the IP data packet and the target address in the target address list based on the address match and the port match.
[0086] In a preferred embodiment of the present invention, the address matching degree is identified by whether the IP address of the IP data packet is completely consistent with the corresponding numbers in the IP address of the target address. For example, if the IP address of the IP data packet is 192.168.0.01 and the IP address of the target address is 192.168.0.00, the corresponding address matching degree is 0; if the IP address of the IP data packet is 192.168.0.01 and the IP address of the target address is 192.168.0.01, the corresponding address matching degree is 1.
[0087] In a preferred embodiment of the present invention, the port matching degree is identified by whether the port number of the port of the IP data packet is consistent with the port number of the port of the target address. For example, if the port of the IP data packet is 80 and the port of the target address is 120, the corresponding port matching degree is 0; if the port of the IP data packet is 90 and the port of the target address is 90, the corresponding port matching degree is 1.
[0088] Preferably, in the present invention, if the address matching degree and the port matching degree are both 1, then the IP data packet successfully matches the corresponding target address in the target address list, otherwise, the match fails.
[0089] In summary, the embodiment of the present invention obtains the corresponding video stream from the video sending end through the kernel state according to the video request, and searches for the distribution destination address of the video stream from the target address in the kernel state, and further sends the video stream to the video receiving end in the kernel state according to the distribution destination address found. The present invention does not need to copy the video stream from the kernel state to the user state, which reduces the video stream memory copy time, reduces the delay of video distribution, and avoids the frequent context switching of the CPU of the video distribution system, reduces the excessive CPU resources occupied, and thus improves the speed of video distribution. Therefore, a video distribution method proposed by the present invention can improve the timeliness of video distribution. In digital medicine, videos with high timeliness can be distributed to relevant monitoring and management departments, so as to more efficiently perform medical management services according to actual monitoring conditions.
[0090] Through the video distribution method described above in this embodiment, each monitoring management department in the hospital (such as each outpatient department) can obtain the real-time situation of the corresponding waiting area in a timely manner, and then manage the progress of consultations, guide patients, etc. according to the real-time situation of the waiting area.
[0091] like Figure 5 The figure shows a functional module diagram of the video distribution device of the present invention.
[0092] The video distribution device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the video distribution device may include a storage module 101, a transmission module 102, and a forwarding module 103. The module described in the present invention may also be referred to as a unit, which refers to a series of computer program segments that can be executed by a processor of an electronic device and can complete fixed functions, which are stored in the memory of the electronic device.
[0093] In this embodiment, the functions of each module / unit are as follows:
[0094] The storage module 101 is used to receive a video request from a video receiving end, store the source address and the target address of the video request in an address storage list pre-constructed in the user state, obtain a source address list and a target address list, and transmit the target address list to the kernel state.
[0095] In at least one embodiment of the present invention, the video receiving end refers to an electronic device that receives a video stream, such as a mobile phone, a tablet, and a PC. In an embodiment of the present invention, the source address and the target address of the video request are stored in an address storage list pre-constructed in the user state, and the target address list is further transmitted to the kernel state, which reduces the data copy time of the subsequent video stream, thereby improving the distribution speed of the video stream. Wherein, the address storage list refers to a data storage structure table, preferably, it is constructed by SQL statements in the present invention, and is used to store the video addresses of different video receiving ends and video sending ends.
[0096] In a preferred embodiment of the present invention, the video request refers to obtaining the user-required video from the video sending end and transmitting it to the video receiving end, wherein the user-required video can be a surveillance video of a certain road section or a short video, etc.
[0097] Further, the source address and the target address of the video request are stored in the address storage list pre-constructed in the user state. When the source address list and the target address list are obtained, the storage module 101 performs the following operations:
[0098] Step A, obtaining the IP address and port of the video sending end corresponding to the video request, and generating the source address of the video request according to the IP address and port of the video sending end;
[0099] Step B, obtaining the IP address and port of the video receiving end corresponding to the video request, and generating the target address of the video request according to the IP address and port of the video receiving end;
[0100] Step C: storing the source address and the target address of the video request in an address storage list pre-constructed in user mode to obtain a source address list and a target address list.
[0101] Among them, the source address refers to the address of the video sending end of the video request, the target address refers to the address of the video receiving end of the video request, and the source address list and the target address list refer to a list structure for storing corresponding source addresses and target addresses.
[0102] In a preferred embodiment of the present invention, the storage module 101 obtains the IP address and port of the corresponding video sending end and the IP address and port of the video receiving end by checking the properties of the video sending end and the video receiving end. For example, the video sending end is a PC, and the user clicks on the properties in the PC to obtain the IP address and port of the PC, wherein the IP address of the PC is used to describe its network location, and the port describes the corresponding network service it provides.
[0103] In a preferred example of the present invention, the storage module 101 combines the IP address and port of the video sending end to obtain the source address of the video request, and combines the IP address and port of the video receiving end to obtain the target address of the video request. For example, the IP address of the video sending end is: 183.168.14.152, and the port of the video sending end is: 80. They are combined to obtain the source address: 183.168.14.152+80.
[0104] Preferably, the storage module 101 described in the embodiment of the present invention copies the target address list to the kernel state through the SQL language for subsequent direct transmission of the video stream, avoiding the data copying of the video stream by querying the corresponding target address through the user state, thereby reducing the memory and CPU processing time.
[0105] The transmission module 102 is used to transmit the video request to the corresponding video sending end through the kernel state according to the source address list, obtain the video stream from the video sending end, and return the video stream to the kernel state.
[0106] In at least one embodiment of the present invention, when the video request is transmitted to the corresponding video sending end through the kernel state according to the source address list and the video stream is obtained, the transmission module 102 performs the following operations:
[0107] Step I: acquiring the service address of the corresponding video sending end according to the source address in the source address list;
[0108] Step II: constructing a window connection channel with the video sending end through kernel state according to the service address;
[0109] Step III: transmitting the video request to the video sending end according to the window connection channel, and receiving the video stream sent by the video sending end.
[0110] In an optional embodiment of the present invention, the transmission module 102 obtains the service address corresponding to the video sending in the following manner, including: based on the IP address and port of the source address, obtaining the IP address and port of the corresponding video sending end to obtain the service address of the video sending end.
[0111] In an optional embodiment of the present invention, the transmission module 102 constructs a window connection channel between the kernel state and the video sending end according to the service address, including: obtaining the IP address and port of the service address, configuring the IP address and port of the service address in the kernel state window, and executing the construction of the window connection channel. Preferably, the IP address and port of the service address are configured in the kernel state window using C++ language.
[0112] In an optional embodiment of the present invention, the transmission module 102 transmits the video request to the video sending end, and receives the video stream sent by the video sending end, including: based on the video request, querying the corresponding video data in the video sending end to obtain the video stream. For example, the video stream can be: a surveillance video of a traffic accident occurring on a certain road section, a short video of a song MV, or an electronic video of a newlyweds' wedding highlights.
[0113] Preferably, the embodiment of the present invention returns the video stream to the kernel state according to the window channel.
[0114] It should be emphasized that in order to further ensure the security of the above video stream, the above video stream can be stored in a blockchain node.
[0115] The forwarding module 103 is used to forward the video stream to the corresponding video receiving end in the kernel state according to the target address list.
[0116] In a preferred embodiment of the present invention, when forwarding the video stream to the corresponding video receiving end through the kernel state, the forwarding module 103 performs the following operations:
[0117] Capture the IP data packet of the video stream, and match the IP data packet with the target address in the target address list; if the match fails, recapture the IP data packet of the video stream; if the match succeeds, forward the video stream to the corresponding video receiving end through the kernel state according to the target address.
[0118] In an optional implementation, the forwarding module 103 forwards the video stream to the video receiving end through the network layer in the kernel state.
[0119] Wherein, the IP data packet refers to a data packet for video stream transmission on the Internet by the TCP / IP protocol. Preferably, the IP data packet of the video stream in the embodiment of the present invention is captured by the hook function (HOOK technology) of the Netfiter framework in the kernel state, and the transmission protocol of the corresponding video stream can be identified in advance, which is conducive to the direct transmission of subsequent IP data packets.
[0120] Further, when the IP data packet of the video stream is captured and the IP data packet is matched with the target address in the target address list, the forwarding module 103 performs the following operations:
[0121] Determine whether the IP data packet belongs to the User Data Packet Protocol based on the header field in the IP data packet; if it does not belong to the User Data Packet Protocol, continue to capture the IP data packet; if it belongs to the User Data Packet Protocol, parse out the IP address and port of the IP data packet; and match the IP data packet with the target address in the target address list based on the IP address and port of the IP data packet.
[0122] In a preferred embodiment of the present invention, the header field in the IP data packet is a protocol field, and the User Datagram Protocol refers to a connectionless transmission protocol.
[0123] Specifically, when matching the IP data packet with the target address in the target address list according to the IP address and port of the IP data packet, the forwarding module 103 performs the following operations:
[0124] Obtain the IP address and port of the target address, identify the address match between the IP address of the IP data packet and the IP address of the target address, and identify the port match between the port of the IP data packet and the port of the target address, and perform matching between the IP data packet and the target address in the target address list based on the address match and the port match.
[0125] In a preferred embodiment of the present invention, the address matching degree is identified by whether the IP address of the IP data packet is completely consistent with the corresponding numbers in the IP address of the target address. For example, if the IP address of the IP data packet is 192.168.0.01 and the IP address of the target address is 192.168.0.00, the corresponding address matching degree is 0; if the IP address of the IP data packet is 192.168.0.01 and the IP address of the target address is 192.168.0.01, the corresponding address matching degree is 1.
[0126] In a preferred embodiment of the present invention, the port matching degree is identified by whether the port number of the port of the IP data packet is consistent with the port number of the port of the target address. For example, if the port of the IP data packet is 80 and the port of the target address is 120, the corresponding port matching degree is 0; if the port of the IP data packet is 90 and the port of the target address is 90, the corresponding port matching degree is 1.
[0127] Preferably, in the present invention, if the address matching degree and the port matching degree are both 1, then the IP data packet successfully matches the corresponding target address in the target address list, otherwise, the match fails.
[0128] In summary, the embodiment of the present invention obtains the corresponding video stream from the video sending end through the kernel state according to the video request, and searches for the distribution destination address of the video stream from the target address in the kernel state, and further sends the video stream to the video receiving end in the kernel state according to the distribution destination address found. The present invention does not need to copy the video stream from the kernel state to the user state, which reduces the video stream memory copy time, reduces the delay of video distribution, and avoids the frequent context switching of the CPU of the video distribution system, reduces the excessive CPU resources occupied, and thus improves the speed of video distribution. Therefore, a video distribution device proposed by the present invention can improve the timeliness of video distribution.
[0129] like Figure 6 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the video distribution method of the present invention.
[0130] The electronic device 1 may include a processor 10 , a memory 11 , and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a video distribution program 12 .
[0131] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 11 may also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device 1, such as codes for video distribution, etc., but may also be used to temporarily store data that has been output or is to be output.
[0132] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing video distribution, etc.), and calls data stored in the memory 11, so as to execute various functions of the electronic device 1 and process data.
[0133] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0134] Figure 6 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 6 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0135] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0136] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
[0137] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0138] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0139] The video distribution 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions, which, when executed in the processor 10, can achieve:
[0140] Receive a video request from a video receiving end, store a source address and a target address of the video request in an address storage list pre-constructed in a user state, obtain a source address list and a target address list, and transmit the target address list to a kernel state;
[0141] According to the source address list, transmitting the video request to the corresponding video sending end through the kernel state, obtaining the corresponding video stream from the video sending end, and returning the video stream to the kernel state;
[0142] According to the target address list, the video stream is forwarded to the corresponding video receiving end using the kernel state.
[0143] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0144] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0145] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0146] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0147] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0148] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0149] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0150] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0151] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0152] 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, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A video distribution method, characterized in that: The method comprises: Receive a video request from a video receiving end, obtain the IP address and port of a video sending end corresponding to the video request, generate a source address of the video request according to the IP address and port of the video sending end, obtain the IP address and port of the video receiving end corresponding to the video request, generate a target address of the video request according to the IP address and port of the video receiving end, store the source address and target address of the video request in an address storage list pre-constructed in user state, obtain a source address list and a target address list, and transmit the target address list to kernel state; According to the source address list, a window connection channel is constructed between the kernel state and the video sending end, the video request is transmitted to the corresponding video sending end through the window connection channel, a corresponding video stream is obtained from the video sending end, and the video stream is returned to the kernel state; According to the target address list, the video stream is forwarded to the corresponding video receiving end using the kernel state.
2. The video distribution method according to claim 1, characterized in that: The step of constructing a window connection channel between the kernel state and the video sending end according to the source address list, transmitting the video request to the corresponding video sending end through the window connection channel, and obtaining the corresponding video stream from the video sending end includes: According to the source address in the source address list, obtaining the service address of the corresponding video sending end; According to the service address, a window connection channel with the video sending end is constructed through kernel mode; The video request is transmitted to the video sending end according to the window connection channel, and the video stream sent by the video sending end is received.
3. The video distribution method according to claim 2, characterized in that: The step of constructing a window connection channel with the video sending end through kernel state according to the service address includes: The IP address and port of the service address are obtained, the IP address and port of the service address are configured in the kernel state, and the construction of the window connection channel is executed.
4. The video distribution method according to claim 1, characterized in that: The step of forwarding the video stream to a corresponding video receiving end by using the kernel state according to the target address list includes: Capturing the IP data packet of the video stream, and matching the IP data packet with the target address in the target address list; If the match fails, recapture the IP data packets of the video stream; If the match is successful, the video stream is forwarded to the corresponding video receiving end through the kernel state according to the target address.
5. The video distribution method according to claim 4, characterized in that: The capturing of the IP data packet of the video stream and matching the IP data packet with the target address in the target address list comprises: Determining whether the IP data packet belongs to the User Datagram Protocol according to the header field in the IP data packet; If it does not belong to the User Datagram Protocol, continue to capture IP data packets; If it belongs to the User Datagram Protocol, parse out the IP address and port of the IP datagram; According to the IP address and port of the IP data packet, the IP data packet is matched with the target address in the target address list.
6. The video distribution method according to claim 5, characterized in that: The step of matching the IP data packet with the target address in the target address list according to the IP address and port of the IP data packet comprises: Obtain the IP address and port of the target address; Identify the address match between the IP address of the IP data packet and the IP address of the target address, and identify the port match between the port of the IP data packet and the port of the target address; The IP data packet is matched with the target address in the target address list according to the address matching degree and the port matching degree.
7. A video distribution device, characterized in that: The device comprises: A storage module, used for receiving a video request from a video receiving end, obtaining an IP address and a port of a video sending end corresponding to the video request, generating a source address of the video request according to the IP address and the port of the video sending end, obtaining an IP address and a port of a video receiving end corresponding to the video request, generating a target address of the video request according to the IP address and the port of the video receiving end, storing the source address and the target address of the video request in an address storage list pre-constructed in a user state, obtaining a source address list and a target address list, and transmitting the target address list to a kernel state; A transmission module, configured to construct a window connection channel between the kernel state and the video sending end according to the source address list, transmit the video request to the corresponding video sending end through the window connection channel, obtain the corresponding video stream from the video sending end, and return the video stream to the kernel state; The forwarding module is used to forward the video stream to the corresponding video receiving end through the kernel state.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the video distribution method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the video distribution method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Transmission method and apparatus of code stream
CN102695049A
Signal source pushing method and system
CN106791992A
Data transmission method and apparatus
CN107222793A
Multicast traffic forwarding method and device, and server
CN108881069A