Data distribution method, device, storage medium and computer program product

By using lock-free queues to acquire data in content distribution, the performance loss and delay problems caused by frequent unlocking operations in the prior art are solved, and the user experience is improved.

CN119052517BActive Publication Date: 2025-06-20GUANGZHOU BAOLUN ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411039086.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2025-06-20
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

Existing content distribution methods require frequent unlocking operations, resulting in increased performance losses, prone to delays, and reduce user experience.

Method used

By receiving the target instruction, if it is a stream pull instruction, the lock-free queue of the target thread is obtained to obtain data, avoiding frequent unlocking operations.

Benefits of technology

It effectively reduces performance losses and delays and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119052517B_ABST
    Figure CN119052517B_ABST
Patent Text Reader

Abstract

The present application provides a data distribution method, device, storage medium and product, relating to the field of streaming media technology. The data distribution method includes receiving a target instruction, where the target instruction includes any one of a push stream instruction and a pull stream instruction; if it is determined that the target instruction is a pull stream instruction, obtaining a target thread corresponding to the target instruction, and obtaining data corresponding to the target instruction based on the lock-free queue of the target thread. Embodiments of the present application ensure mutually exclusive access through a lock-free queue and can avoid frequent execution of lock addition and unlocking operations, effectively reducing performance loss and latency, and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of streaming media technology. Specifically, this application relates to a data distribution method, device, storage medium, and product. Background Art

[0002] With the continuous development of Internet technology, video multimedia services have developed rapidly, such as video live streaming, online course live streaming, etc., including multimedia data such as audio and video streams. The live content of video live streaming is generally realized through CDN (Content Delivery Network) for pushing and pulling streams between the anchor and users. Among them, pushing a stream refers to the process of transmitting the content encapsulated in the acquisition stage to the server; pulling a stream refers to the process of pulling the existing content on the server using a specified address. The video live streaming process is completed through pushing and pulling streams.

[0003] In actual use, the server often faces the situation where multiple stream pullers obtain the same content. To avoid content distribution errors and concurrent processing, it is necessary to allocate corresponding threads for each stream puller and set corresponding threads for the stream pusher, and complete content distribution through these threads. However, the multi-threaded method will cause the threads of the stream pusher to need to deliver content across threads multiple times, and mutual exclusion access is required between threads to avoid interference, resulting in the need to perform locking and unlocking operations each time content is delivered. This method increases the performance loss during content distribution and is prone to content distribution delays due to locking and unlocking operations, resulting in lags on the user side and reducing the user experience. Summary of the Invention

[0004] Embodiments of this application provide a data distribution method, device, storage medium, and product, which can solve the problem that existing content distribution requires frequent locking and unlocking operations, increases performance loss, is prone to delays, and reduces the user experience. To achieve this purpose, the embodiments of this application provide the following several solutions.

[0005] According to one aspect of the embodiments of this application, a data distribution method is provided, including: receiving a target instruction, where the target instruction includes any one of a stream pushing instruction and a stream pulling instruction;

[0006] If it is determined that the target instruction is a stream pulling instruction, obtain the target thread corresponding to the target instruction, and obtain the data corresponding to the target instruction based on the lock-free queue of the target thread.

[0007] In a possible implementation manner, the receiving a target instruction includes:

[0008] Receiving a target instruction, and converting the target instruction into a preset instruction structure, where the preset instruction structure includes a request identifier, a stream name, and an instruction code.

[0009] In a possible implementation, the method further includes:

[0010] If it is determined that the target instruction is a streaming instruction, determine the target thread corresponding to the streaming instruction according to the stream name corresponding to the target instruction and the number of threads, and use the target thread to process the streaming instruction.

[0011] In a possible implementation, the using the target thread to process the streaming instruction includes:

[0012] Establish a streaming connection based on the streaming instruction, and send a streaming notification to other threads based on the streaming connection so that the other threads generate streaming source summary information based on the streaming notification;

[0013] Obtain the pulling connection corresponding to the streaming connection, and distribute the data corresponding to the streaming connection to the threads corresponding to the pulling connection, where the pulling connection is established based on a pulling instruction.

[0014] In a possible implementation, when the target instruction is a pulling instruction, the obtaining the target thread corresponding to the target instruction includes:

[0015] Establish a streaming connection corresponding to the target instruction, and obtain the streaming connection corresponding to the target instruction according to the stream name of the target instruction;

[0016] If it is determined that the streaming connection is bound with a pulling connection, determine the target thread corresponding to the target instruction according to the request identifier of the target instruction.

[0017] In a possible implementation, the obtaining the data corresponding to the target instruction based on the lock-free queue of the target thread includes:

[0018] Establish a lock-free queue for the target thread based on the total number of target threads;

[0019] Determine the source thread corresponding to the pulling connection according to the streaming source summary information, use the target thread to send a registration request to the source thread, and use the lock-free queue to receive the streaming data sent by the source thread based on the registration request, where the streaming data is transmitted by the streaming connection corresponding to the pulling connection to the source thread.

[0020] In a possible implementation, if it is determined that the streaming connection is not bound with a pulling connection, determine the thread corresponding to the streaming connection as the target thread, and establish a binding relationship between the streaming connection and the pulling connection corresponding to the target instruction.

[0021] According to one aspect of the embodiments of the present application, there is provided an electronic device, including a memory, a processor, and a computer program stored on the memory, where the processor executes the computer program to implement the steps of the method as described above.

[0022] According to one aspect of the embodiments of the present application, there is provided a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method as described above are implemented.

[0023] According to one aspect of the embodiments of the present application, there is provided a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the method as described above are implemented.

[0024] The beneficial effects brought by the technical solutions provided by the embodiments of the present application are:

[0025] The data distribution method provided by the present application receives a target instruction; if it is determined that the target instruction is a pull stream instruction, the target thread corresponding to the target instruction is obtained, and the data corresponding to the target instruction is obtained based on the lock-free queue of the target thread. In the embodiments of the present application, the lock-free queue ensures mutually exclusive access and can avoid frequent execution of lock addition and unlocking operations, effectively reducing performance loss and latency, and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description in the embodiments of the present application.

[0027] Figure 1 It is a flowchart of the data distribution method provided by the embodiments of the present application;

[0028] Figure 2 It is a working flowchart of the data distribution method provided by the embodiments of the present application;

[0029] Figure 3 It is a schematic diagram of data transmission in the data distribution method provided by the embodiments of the present application;

[0030] Figure 4 It is a structural diagram of the electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0031] The following describes the embodiments of the present application with reference to the drawings in the present application. It should be understood that the embodiments described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and do not constitute limitations on the technical solutions of the embodiments of the present application.

[0032] Those skilled in the art can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the terms "comprising" and "including" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation of other features, information, data, steps, operations, elements, components and / or their combinations supported by the technical field of the present application, etc. It should be understood that when we say an element is "connected" or "coupled" to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include a wireless connection or a wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" indicates being implemented as "A", or being implemented as "B", or being implemented as "A and B".

[0033] To make the objectives, technical solutions and advantages of the present application clearer, the following will further describe the embodiments of the present application in detail with reference to the accompanying drawings.

[0034] The technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application will be described below by describing several exemplary embodiments. It should be noted that the following embodiments can be referenced, learned from or combined with each other. For the same terms, similar features and similar implementation steps in different embodiments, they will not be described repeatedly.

[0035] The data distribution method, device, storage medium and product provided by the present application are intended to solve at least one technical problem existing in the prior art.

[0036] In an embodiment of the present application, a data distribution method is provided. The object executing the data distribution method can be a server and other devices capable of data distribution.

[0037] Optionally, the device executing the data distribution method may include a signaling processing module, a thread allocation module and a distribution module. The thread allocation module is respectively connected to the signaling processing module and the distribution module. The device realizes the data distribution method through the signaling processing module, the thread allocation module and the distribution module.

[0038] Optionally, as Figures 1-3 shown, the data distribution method includes:

[0039] S101: Receive a target instruction.

[0040] Optionally, the target instruction includes any one of a streaming instruction and a pulling instruction. The target instruction can be an instruction transmitted by the user terminal to the device executing this data distribution method, or an instruction pre-stored in the device executing the data distribution method and triggered based on a preset condition (such as obtaining content that can be streamed).

[0041] Optionally, receiving the target instruction includes: receiving the target instruction and converting it into a preset instruction structure. The preset instruction structure includes a request identifier, a stream name, and an instruction code, and the source of the request is identified through this request identifier.

[0042] Optionally, the request representation can be a user identifier, which is used to indicate which user the target instruction comes from. The stream name is used to implement data distribution, and the instruction code is used to indicate the type of the request.

[0043] Optionally, the request identifier can be represented as uid, the stream name can be indicated by stream_name, and the instruction code can be represented by cmd.

[0044] In one embodiment, the request identifier is a user identifier. The signaling processing module receives an externally input instruction. After receiving the instruction, the signaling processing module converts the instruction into a unified preset instruction structure. The core fields of the preset instruction structure include the user identifier uid, the stream name stream_name, and the instruction code cmd. The instruction converted into the preset instruction structure is sent to the thread allocation module for processing. Among them, uid indicates which user the instruction is a request from. The role of stream_name is to bridge and bind the streaming instruction and the pulling instruction according to the same stream name (that is, forward the source data of the streaming connection to the bound pulling connection through bridging and binding). The role of cmd is to indicate the type of the instruction.

[0045] Optionally, the types of instructions include push and pull. Among them, push indicates that the instruction is a streaming instruction. The user terminal that issues this instruction initiates a request to establish a streaming connection with the server. After establishing the streaming connection, the user terminal will send audio and video data to the server. Pull indicates that the instruction is a pulling instruction. The user initiates a request to establish a pulling connection with the server. The server establishes a pulling connection according to this request and bridges and binds the corresponding streaming connection of the pulling connection through the same stream_name for data forwarding.

[0046] S102: If it is determined that the target instruction is a pulling instruction, obtain the target thread corresponding to the target instruction, and obtain the data corresponding to the target instruction based on the lock-free queue of the target thread.

[0047] Optionally, the device's thread allocation module can allocate threads for the target instruction and use the distribution module to perform data distribution operations. Among them, when the thread allocation module is initialized, multiple threads are established according to the number of cores of the device, and the number of threads is recorded. Thread allocation is performed in combination with the number of threads and the received instruction.

[0048] In one embodiment, the number of threads can be the same as the number of cores of the device. If the device has hyper-threading technology or other technologies that can expand threads, the number of threads can also be greater than the number of cores of the device (for example, the number of threads is twice the number of cores).

[0049] Optionally, the type of the target instruction can be identified according to the instruction code in the target instruction, and the corresponding thread allocation strategy can be used based on this type. Among them, the thread allocation strategies corresponding to the pull stream instruction and the push stream instruction are different.

[0050] Among them, when the object executing the data distribution method is the server and the target instruction is a push stream instruction, a push stream connection is established based on the push stream instruction. This push stream connection is used to connect the server and the client that issues the push stream instruction, and the client sends data to the server through this push stream connection. The target thread corresponding to the push stream instruction is determined according to the stream name corresponding to the target instruction and the number of threads, and the target thread is used to process the push stream instruction.

[0051] Optionally, using the target thread to process the push stream instruction includes: establishing a push stream connection based on the push stream instruction, sending a push stream notification to other threads based on the push stream connection so that other threads generate a push stream source summary information based on the push stream notification; obtaining the pull stream connection corresponding to the push stream connection, and distributing the data corresponding to the push stream connection to the threads corresponding to the pull stream connection. The pull stream connection is established based on the pull stream instruction.

[0052] When the target instruction is a pull stream instruction, obtaining the target thread corresponding to the target instruction includes: obtaining the push stream connection corresponding to the pull stream connection according to the stream name of the target instruction; if it is determined that the push stream connection is bound to a pull stream connection, determining the target thread corresponding to the target instruction according to the request identifier of the target instruction, establishing the pull stream connection corresponding to the target instruction, and the client that sends the instruction obtains data through this pull stream connection. Among them, each push stream connection is bound to a pull stream connection.

[0053] Optionally, the thread with the push stream connection can be the source stream thread. The data corresponding to this push stream connection is the data uploaded by the client to the server through the push stream connection, and this data is distributed by the source stream thread to the lock-free queue of other threads with pull stream connections.

[0054] Optionally, if it is determined that the push stream connection is not bound to a pull stream connection, the thread corresponding to this push stream connection is determined as the target thread, and a binding relationship between the push stream connection and the pull stream connection corresponding to the target instruction is established.

[0055] In one embodiment, the thread allocation module adopts different thread allocation strategies for different types of instructions. Among them, when the thread allocation module is initialized, the same number of threads are created according to the number of cores of the server, and the number of threads is denoted as thread_num. Moreover, after the thread allocation module receives an instruction using a preset instruction structure from the signaling module, the thread allocation module identifies the type of the instruction according to the instruction code in the instruction. When the instruction is a streaming instruction, the thread corresponding to the instruction is calculated based on the formula thread_id = crc32(stream_name) % thread_num, and this thread is used to process the instruction. Here, thread_id represents the allocated thread, and the stream name stream_name is converted into an integer through the crc32 algorithm. thread_id is obtained by taking the modulus of the calculation result.

[0056] When the instruction is a pulling instruction, the stream name of the instruction is obtained, and the corresponding pushing connection for the instruction is obtained according to the stream name (the stream name corresponding to the pushing connection is the same as the stream name of the instruction). It is detected whether the pushing connection is bound with a pulling connection. If not, the thread corresponding to the pushing connection is determined as the target thread (wherein, the same calculation formula as the streaming instruction can be used to allocate threads, so as to ensure that the streaming instruction and the pulling instruction with the same stream name are allocated to the same thread). If the pushing connection is bound with a pulling connection, the thread corresponding to the instruction can be calculated based on the formula thread_id = uid % thread_num, where uid is the request identifier. Through the above allocation method, when both the streaming instruction and the pulling instruction with the same stream name are 1, the streaming instruction and the pulling instruction are allocated to the same thread for distribution, thereby ensuring the reduction of thread usage. When in the scenario of multiple pulling instructions, the above allocation method can allocate the pulling instructions of multiple users to multiple threads, which is convenient for giving play to the advantage of multi-core concurrency.

[0057] Optionally, obtaining the data corresponding to the target instruction based on the lock-free queue of the target thread includes: establishing a lock-free queue for the target thread based on the total number of target threads; determining the source thread corresponding to the pulling connection according to the pushing source summary information, sending a registration request from the target thread to the source thread, and receiving the pushing data sent by the source thread based on the registration request using the lock-free queue corresponding to the pulling connection. The pushing data is transmitted by the pushing connection corresponding to the pulling connection to the source thread.

[0058] Optionally, after the thread corresponding to the push stream connection receives a registration request from another thread, it stores the information of the thread corresponding to the registration request. When receiving data transmitted by the client through the push stream connection, it obtains the pull stream connection bound to the push stream connection, and transmits the data to the client corresponding to the pull stream connection through the pull stream connection, and at the same time sends the data to the thread corresponding to the registration request. Among them, the data is sent to the lock-free queue corresponding to the registration request thread.

[0059] In one embodiment, as Figure 2 shown, when the thread allocation module receives a push stream instruction, it establishes a push stream connection between the server and the client corresponding to the push stream instruction according to the push stream instruction. At this time, the push stream instruction will be assigned to one of the threads. Denote this thread as the source stream thread. At this time, the source stream thread will send a push stream notification to other threads in the system. Use this push stream notification to remind other threads that there will be a new push stream added to this server. Other non-source stream threads will generate source stream summary information based on this push stream notification (the source stream summary information stores the information of the source stream thread and the push stream instruction corresponding to the source stream thread, such as the stream name of the push stream instruction). When the thread allocation module receives a new pull stream instruction, it will establish a pull stream connection according to the pull stream instruction. The pull stream connection is used to connect the server and the client corresponding to the pull stream instruction. At this time, if the pull stream instruction is assigned to a non-source stream thread, this thread can be denoted as the pull stream thread. The pull stream thread will send a registration notification to the source stream thread, and the source stream thread will store the information of the pull stream thread that wants to pull this push stream. When the source stream thread receives data (which can be audio and video data) pushed up by the client, at this time, in addition to sending the data to the client corresponding to the pull stream connection of this thread, it will also send the data to other pull stream threads that send registration requests to this thread.

[0060] Optionally, when data is transmitted across threads, the data is sent by the source stream thread to the lock-free queue of other threads. The thread with the lock-free queue obtains the distributed data through the lock-free queue and sends the data to the client corresponding to the pull stream connection. Among them, if there are n threads in the server, then n - 1 lock-free queues are created in each thread, and each lock-free queue is only used for inter-thread communication between this thread and a corresponding other thread (if the number of cores is 4, then there are 4 threads and each thread has 3 lock-free queues, and one-to-one communication with other threads is carried out through the lock-free queues).

[0061] In one embodiment, as Figure 3As shown in the figure, the number of threads is 3, including Thread 1, Thread 2, and Thread 3. Among them, each thread creates two lock-free queues, and each lock-free queue of a thread corresponds to a thread outside that thread. Specifically, for the lock-free queue 1 of Thread 1, the producer is Thread 2 (i.e., Thread 2 sends data to the lock-free queue 1), and the consumer is Thread 1 (i.e., Thread 1 reads the data in the lock-free queue 1). For the lock-free queue 2 of Thread 1, the producer is Thread 3, and the consumer is Thread 1. User A, User B, and User C send instructions respectively, and the sent instructions are distributed to 3 different threads. Among them, the instruction sent by User A is a streaming push instruction, which pushes the stream to the server. The instructions sent by User B include a streaming push instruction and a streaming pull instruction. It pulls the stream pushed by User A while pushing the stream to the server. User C sends a streaming pull instruction, and this streaming pull instruction only pulls the streams pushed by User A and User B.

[0062] When User B wants to pull the stream pushed by User A, since the threads where User A and User B are located are different, Thread 1 corresponding to User A will deliver the stream to the lock-free queue 1 of Thread 2 corresponding to User B and the lock-free queue 1 of Thread 3 corresponding to User C. User B obtains the data forwarded by Thread 1 through the lock-free queue 1 in Thread 2, and User C obtains the data forwarded by Thread 1 through the lock-free queue 1 in Thread 3.

[0063] In the scenario of multi-channel concurrent stream pulling, one stream push often corresponds to multiple stream pulls. Using multi-threaded distribution can give play to the advantages of multi-core CPUs. At the same time, when using multi-threaded distribution, it is often necessary to copy a piece of data multiple times. The method of using pointers for data distribution enables only pointers to be copied between threads, avoiding a large amount of copying work. At the same time, the design of each thread setting a separate lock-free queue for each other thread can ensure mutually exclusive access to data and avoid frequent locking and unlocking, improving the performance utilization rate of the device and reducing performance loss.

[0064] In an alternative embodiment, an electronic device is provided, as Figure 3 shown. Figure 3 The electronic device 4000 shown in the figure includes: a processor 4001 and a memory 4003. Among them, the processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 can be used for data interaction between this electronic device and other electronic devices, such as data sending and / or data receiving, etc. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of this electronic device 4000 does not constitute a limitation to the embodiments of the present application.

[0065] The processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logical blocks, modules, and circuits described in connection with the disclosure of this application. The processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0066] The bus 4002 may include a path for transmitting information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.

[0067] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or it may also be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, which is not limited here.

[0068] The memory 4003 is used to store the computer program for implementing the embodiments of this application and is controlled by the processor 4001 to execute. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0069] Among them, the electronic device can be any kind of electronic product that can perform human-computer interaction with an object. For example, a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an Internet Protocol Television (IPTV), a smart wearable device, etc.

[0070] The electronic device may further include a network device and / or an object device. Among them, the network device includes, but is not limited to, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing.

[0071] The network where the electronic device is located includes, but is not limited to, the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0072] An embodiment of the present application provides a computer-readable storage medium. The computer-readable storage medium includes a computer program, and when the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiment can be implemented.

[0073] An embodiment of the present application provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiment can be implemented.

[0074] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification, claims and drawings of the present application are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of the present application described here can be implemented in an order other than the illustrated or text description.

[0075] It should be understood that although the flowcharts in the embodiments of the present application indicate various operation steps by arrows, the execution order of these steps is not limited to the order indicated by the arrows. Unless otherwise clearly stated in this article, in some implementation scenarios of the embodiments of the present application, the implementation steps in each flowchart can be executed in other orders according to requirements. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage among these sub-steps or stages can also be executed at different times respectively. In the scenario where the execution times are different, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and the embodiments of the present application do not limit this.

[0076] The above are only optional implementation manners of some implementation scenarios of the present application. It should be noted that for those of ordinary skill in the art, without departing from the technical concept of the solution of the present application, adopting other similar implementation means based on the technical idea of the present application also belongs to the protection scope of the embodiments of the present application.

Claims

1. A data distribution method, characterized in that: include: A target instruction is received, wherein the target instruction includes any one of a push stream instruction and a pull stream instruction; If it is determined that the target instruction is a stream pulling instruction, a target thread corresponding to the target instruction is obtained, and data corresponding to the target instruction is obtained based on a lock-free queue of the target thread; The acquiring data corresponding to the target instruction based on the lock-free queue of the target thread includes: Establishing a lock-free queue of the target threads based on the total number of target threads; Determine the source stream thread corresponding to the pull stream connection according to the push stream source summary information, use the target thread to send a registration request to the source stream thread, use the lock-free queue to receive the push stream data sent by the source stream thread based on the registration request, the push stream data is transmitted to the source stream thread by the push stream connection corresponding to the pull stream connection, the push stream source summary information is generated by other threads based on the push stream notification of the target thread, the pull stream connection is established based on the pull stream instruction, and the push stream connection is established based on the push stream instruction.

2. The data distribution method according to claim 1, characterized in that: The receiving of the target instruction comprises: A target instruction is received and converted into a preset instruction structure, where the preset instruction structure includes a request identifier, a stream name, and an instruction code.

3. The data distribution method according to claim 2, characterized in that: The method further comprises: If it is determined that the target instruction is a streaming instruction, determining a target thread corresponding to the streaming instruction according to the stream name and the number of threads corresponding to the target instruction, and using the target thread to process the streaming instruction; The determining the target thread corresponding to the stream push instruction according to the stream name and the number of threads corresponding to the target instruction includes: The target thread is determined by the calculation formula thread_id=crc32(stream_name)%thread_num, wherein thread_id represents the target thread corresponding to the stream push instruction, crc32 represents the crc32 algorithm, stream_name represents the stream name, thread_num represents the number of threads, and % is a modulo operator.

4. The data distribution method according to claim 3, characterized in that: The using the target thread to process the streaming instruction includes: Establishing a streaming connection based on the streaming instruction, and sending a streaming notification to other threads based on the streaming connection so that the other threads generate streaming source summary information based on the streaming notification; The pull stream connection corresponding to the push stream connection is obtained, and the data corresponding to the push stream connection is distributed to the thread corresponding to the pull stream connection.

5. The data distribution method according to claim 4, characterized in that: The target instruction is a stream pulling instruction, and obtaining a target thread corresponding to the target instruction includes: Establish a push stream connection corresponding to the target instruction, and obtain the push stream connection corresponding to the target instruction according to the stream name of the target instruction; If it is determined that the push stream connection is bound to a pull stream connection, a target thread corresponding to the target instruction is determined according to a request identifier of the target instruction.

6. The data distribution method according to claim 5, characterized in that: include: If it is determined that the push stream connection is not bound to a pull stream connection, the thread corresponding to the push stream connection is determined as the target thread, and a binding relationship between the push stream connection and the pull stream connection corresponding to the target instruction is established.

7. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, 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.

9. 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

  • Media stream forwarding method and forwarding device

    CN116527949A

  • Video data processing method and device, equipment and storage medium

    CN117499687A