Streaming data transmission control method and device and medium
By encapsulating the Fetch API, dynamically adjusting the block size and transmission interval time, and introducing breakpoint continuous transmission and exception handling mechanisms, the high latency, complex implementation and transmission instability in the existing streaming data transmission methods are solved, and efficient and stable streaming data transmission is achieved.
Patent Information
- Application Number
- CN202411624972.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-25
AI Technical Summary
The existing streaming data transmission methods have problems such as high latency, complex implementation processes, unstable transmission and lack of reconnection mechanisms, especially in scenarios where real-time processing is required.
By encapsulating the Fetch API, dynamically adjusting the chunking size and transmission interval time of streaming data, combining real-time state to realize chunking transmission, and introducing breakpoint continuous transmission and exception handling mechanisms to improve the stability and real-timeness of data transmission.
Real-time and stability of streaming data transmission are improved, development complexity is reduced, and data transmission is ensured in the case of unstable network.
Smart Images

Figure CN119520424A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure at least relates to the field of network technology, and in particular to a stream data transmission control method, a stream data transmission control device, and a computer-readable storage medium. Background Art
[0002] Existing streaming data transmission methods, if they do not use block transmission but rely on the traditional mechanism of single request and response, need to wait for the entire response body to be completed during the data transmission process, resulting in significant delays in processing data, which is inefficient in scenarios that require processing large amounts of real-time data (such as live video and real-time interaction). The implementation of the block transmission solution may have some problems, such as unstable transmission. Summary of the invention
[0003] The technical problem to be solved by the present disclosure is to provide a streaming data transmission control method, a streaming data transmission control device and a computer-readable storage medium in view of the above-mentioned shortcomings, so as to solve the problem of how to optimize streaming data transmission.
[0004] In a first aspect, the present disclosure provides a method for controlling streaming data transmission.
[0005] include:
[0006] Obtaining configuration parameters of the encapsulated first stream data, including: a block size range of the transmission stream data, and a timeout period for receiving the stream data;
[0007] Transmit streaming data in chunks according to real-time status and streaming data configuration parameters, including:
[0008] According to the real-time network status, the block size of the transmission stream data is obtained within the block size range, and the transmission stream data is divided into blocks according to the block size.
[0009] The block interval time of the transmission stream data is obtained within the timeout period according to the real-time status of the cache, and the transmission stream data is divided into blocks according to the block interval time.
[0010] Further, wherein:
[0011] The first stream data configuration parameters also include: breakpoint resume indication;
[0012] Transmitting streaming data in chunks according to real-time status and streaming data configuration parameters also includes:
[0013] According to the real-time status of the transmission stream data interruption and the indication of the breakpoint resuming transmission obtained, the transmission stream data is continued in blocks from the interruption point of the transmission stream data.
[0014] Further, the encapsulated first-stream data configuration parameters are obtained, specifically including:
[0015] In response to the method being applied to a client, a pre-packaged stream data transmission control function is called, a first stream data configuration parameter is input into the stream data transmission control function, the stream data transmission control function adds the first stream data configuration parameter into a Fetch streaming request, and the Fetch streaming request is sent to a server, so that the server obtains the first stream data configuration parameter from the Fetch streaming request;
[0016] In response to the method being applied to the server, a Fetch streaming request from a client is received, and a first stream data configuration parameter is obtained from the Fetch streaming request. The Fetch streaming request is a call by the client to a pre-packaged stream data transmission control function, and the first stream data configuration parameter is input to the stream data transmission control function. The stream data transmission control function adds the first stream data configuration parameter to form a stream data transmission control function.
[0017] Further, wherein:
[0018] The first stream data configuration parameters also include: block transmission specification, stream data format specification, stream data encapsulation method specification, and stream mode specification;
[0019] Transmitting data in blocks also includes: the server transmits stream data in a specified format encapsulated in a specified manner to the client in blocks.
[0020] Furthermore, the method further comprises:
[0021] In response to the method being applied to the client, a second stream data configuration parameter is input into the stream data transmission control function, the stream data transmission control function adds the second stream data configuration parameter to the data block processing function, receives the stream data from the server in blocks, saves the received stream data in a cache area, and the data block processing function processes the stream data in the cache area according to the second stream data configuration parameter.
[0022] Further, wherein:
[0023] The second stream data configuration parameters include a stream data format and a stream data decoding method, and the stream data format includes a text data stream, a video data stream, an audio data stream, and a binary data stream;
[0024] The data block processing function includes: a function for parsing and assembling the block stream data according to the stream data format and the stream data decoding method.
[0025] Further, the streaming data is transmitted in blocks according to the real-time status and the streaming data configuration parameters, specifically including:
[0026] In response to the method being applied to the client, the client sends its own network real-time status, cache real-time status and / or transport stream data interruption real-time status to the server, so that the server obtains the block size, block interval time and / or interruption point of the transport stream data according to the network real-time status, cache real-time status and / or transport stream data interruption real-time status, and blocks the transport stream data according to the block size, block interval time and / or interruption point;
[0027] In response to the method being applied to the server, the real-time network status, the real-time cache status and / or the real-time status of the transmission stream data interruption from the client are received, and the block size, block interval time and / or interruption point of the transmission stream data are obtained according to the real-time network status, the real-time cache status and / or the real-time status of the transmission stream data interruption of the client, and the transmission stream data is divided into blocks according to the block size, the block interval time and / or the interruption point.
[0028] Further, according to the real-time status of the transmission stream data interruption and the indication of the breakpoint resuming transmission obtained, the transmission stream data is continued in blocks from the interruption point of the transmission stream data, specifically including:
[0029] In response to the method being applied to the client, a prompt message is displayed to the user according to the fact that the client has not received the streaming data for a timeout period, the current streaming data transmission is interrupted according to the user's choice and a reconnection request is sent to the server, or a reconnection request is sent to the server after detecting that the connection with the server is disconnected, so that the server obtains the transmission progress recorded according to the obtained breakpoint resume indication when transmitting the streaming data according to the received reconnection request, takes the currently recorded transmission progress as the interruption point of the streaming data transmission, and continues to transmit the streaming data in blocks according to the interruption point;
[0030] In response to the method being applied to a server, when transmitting streaming data, the transmission progress is recorded according to the obtained breakpoint resume indication, and a reconnection request from a client is received. The reconnection request is that the client displays a prompt message to the user based on the fact that it has not received streaming data for a timeout period, interrupts the current streaming data transmission and sends it to the server based on the user's choice, or detects that the connection with the server is disconnected and sends it to the server, obtains the currently recorded transmission progress as the interruption point of the streaming data transmission according to the reconnection request, and continues to transmit the streaming data in blocks according to the interruption point.
[0031] In a second aspect, the present disclosure provides a streaming data transmission control device, the device comprising:
[0032] A configuration parameter module, used to obtain configuration parameters of the encapsulated first stream data, including: a block size range of the transmission stream data, and a timeout period for receiving the stream data;
[0033] The block transmission module is connected to the configuration parameter module and is used to transmit the streaming data in blocks according to the real-time state and the streaming data configuration parameters, including:
[0034] The block size unit is used to obtain the block size of the transmission stream data within the block size range according to the real-time state of the network, and transmit the stream data in blocks according to the block size.
[0035] The interval time unit is used to obtain the block interval time of the transmission stream data within the timeout period according to the real-time status of the cache, and transmit the stream data in blocks according to the block interval time.
[0036] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the streaming data transmission control method as described above is implemented.
[0037] The present disclosure provides a streaming data transmission control method, a streaming data transmission control device and a computer-readable storage medium, which encapsulate and configure streaming data transmission control parameters, dynamically adjust the block transmission of streaming data in combination with real-time status, and improve the stability of streaming data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 is a flow chart of a streaming data transmission control method according to an embodiment of the present disclosure;
[0039] Figure 2 is a structural schematic diagram of a streaming data transmission control device according to an embodiment of the present disclosure;
[0040] Figure 3 is a flow chart of another streaming data transmission control method according to an embodiment of the present disclosure;
[0041] Figure 4 is a flow chart of another streaming data transmission control method according to an embodiment of the present disclosure;
[0042] Figure 5 It is a flowchart of another streaming data transmission control method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.
[0044] It should be understood that the specific embodiments and drawings described herein are only used to explain the present disclosure rather than to limit the present disclosure.
[0045] It can be understood that, in the absence of conflict, the various embodiments of the present disclosure and the various features in the embodiments can be combined with each other.
[0046] It can be understood that, for the convenience of description, the drawings of the present disclosure only show parts related to the present disclosure, while parts irrelevant to the present disclosure are not shown in the drawings.
[0047] It can be understood that each module or unit involved in the embodiments of the present disclosure may correspond to only one entity structure, or may be composed of multiple entity structures, or multiple modules or units may be integrated into one entity structure.
[0048] It will be understood that, in the absence of conflict, the functions and steps marked in the flowcharts and block diagrams of the present disclosure may occur in an order different from that marked in the drawings.
[0049] It is understood that the flowcharts and block diagrams of the present disclosure illustrate the possible architectures, functions, and operations of the systems, devices, equipment, and methods according to the various embodiments of the present disclosure. Each box in the flowchart or block diagram may represent a module, unit, program segment, or code, which contains executable instructions for implementing the specified functions. Moreover, each box or combination of boxes in the block diagram and flowchart may be implemented by a hardware-based device that implements the specified functions, or may be implemented by a combination of hardware and computer instructions.
[0050] It can be understood that the modules and units involved in the embodiments of the present disclosure can be implemented by software or hardware, for example, the modules and units can be located in a processor.
[0051] In order to facilitate understanding of the present disclosure, the main inventive concept involved in the present disclosure is firstly received.
[0052] The present disclosure can specifically provide a streaming data request method based on Fetch encapsulation. Fetch is an API (Application Programming Interface) provided by the Web (network) that can obtain asynchronous resources. As an asynchronous data request tool in Web development, although the Fetch API provides concise syntax and flexible request configuration, its support for streaming data is relatively limited. In the actual application of the existing Fetch-based HTTP (Hypertext Transfer Protocol) request mode, developers need to process the data stream returned by the Fetch API by themselves, including the parsing and assembly of data blocks, which not only increases the complexity of development, but may also cause unstable data processing.
[0053] Specifically, the existing Fetch-based streaming data transmission solution has the following problems:
[0054] 1) High latency: Since the traditional HTTP request mode needs to wait for the entire response body to be completed during the data transmission process, it causes significant delays in data processing, which is especially inefficient in scenarios that require real-time processing. The traditional Fetch API is designed for HTTP requests, and it does not naturally support block reception, parsing, and real-time display. Developers need to manually implement block processing and gradual display of data streams.
[0055] In the present disclosure, by encapsulating Fetch, a gradual reception and display effect similar to a streaming media protocol can be achieved. This method allows users to see the update of video data in real time, and is suitable for scenarios where real-time improvement of streaming data needs to be achieved on standard HTTP.
[0056] 2) Complex implementation process: When using conventional HTTP request methods such as the Fetch API, developers need to parse the original data stream returned from the server and handle the parsing, assembly, and exception handling of the data stream, which increases the complexity of the implementation.
[0057] In the present disclosure, by encapsulating the Fetch API, each "block" of the data stream is automatically read and identified to form complete stream data. For example, the data blocks returned by the server are spliced together in a certain order to ensure that the final generated data stream can be displayed normally on the front end, reducing the development complexity.
[0058] 3) Unstable transmission: When faced with network jitter or instability, the traditional HTTP request model lacks effective dynamic adjustment and error handling mechanisms, resulting in data loss or interruption.
[0059] In the present disclosure, by encapsulating relevant parameters of Fetch and introducing a dynamic adjustment mechanism, these parameters are combined with the real-time status of the network to dynamically adjust the block size and interval time of the transmission process, so as to achieve stable transmission and avoid data loss caused by network problems.
[0060] 4) Lack of reconnection mechanism: In the existing technology, after a network interruption, there is a lack of effective reconnection control mechanism, and it is impossible to decide whether to continue transmitting the data stream from the breakpoint, resulting in difficulty in ensuring the real-time, continuity and integrity of data transmission.
[0061] In the present disclosure, by encapsulating relevant parameters of Fetch and introducing an exception handling mechanism, the control of breakpoint resumption is achieved in the event of network interruption or data transmission failure.
[0062] In response to the problems of high latency, complex development, unstable transmission and lack of reconnection mechanism in the prior art, the present disclosure proposes a streaming request encapsulation method and device based on Fetch API, which can gradually receive, parse and process data streams, while providing dynamic adjustment and exception handling mechanisms, thereby improving the real-time and stability of data transmission.
[0063] Compared with the existing Fetch API solution, the present invention reduces the complexity of developers in processing data streams by encapsulating and optimizing data streams, and introduces a dynamic adjustment mechanism and automatic reconnection function to ensure the continuity and stability of data transmission under unstable network conditions, greatly improving the efficiency of streaming data transmission while simplifying the development process.
[0064] Although Fetch is used as an example to illustrate the main inventive concept of the present disclosure, the present disclosure is not limited thereto and also has the following alternative solutions:
[0065] 1) Streaming data transmission based on WebSockets: Current WebSockets are suitable for continuous, real-time data transmission, and can provide similar low-latency transmission effects in real-time data update application scenarios. However, the existing WebSockets flow control mechanism is not as flexible as the encapsulation mechanism disclosed in this disclosure, and there is a possibility of improvement with reference to the encapsulation mechanism disclosed in this disclosure.
[0066] 2) Server push mechanism based on HTTP / 2: HTTP / 2 server push has similar real-time transmission characteristics to the Fetch streaming request of the present disclosure, and is particularly suitable for high-concurrency data stream transmission scenarios. However, its implementation is relatively complex, and the control of the client lacks the dynamic adjustment mechanism of the present disclosure.
[0067] 3) One-way data flow based on SSE (Server-Sent Events): Server-Sent Events (SSE) is a one-way data flow push technology from server to client based on HTTP. SSE is a lightweight streaming transmission solution. However, the existing SSE only supports one-way data flow and cannot achieve two-way communication. In addition, the flexibility of complex real-time data processing and block transmission is not as good as the encapsulation mechanism disclosed in this disclosure.
[0068] Embodiment 1:
[0069] like Figure 1 As shown, the present disclosure provides a streaming data transmission control method, the method comprising:
[0070] S1. Obtaining configuration parameters of the first encapsulated stream data, including: a block size range of the transmission stream data and a timeout period for receiving the stream data;
[0071] S2, transmitting the streaming data in blocks according to the real-time status and streaming data configuration parameters, including:
[0072] According to the real-time network status, the block size of the transmission stream data is obtained within the block size range, and the transmission stream data is divided into blocks according to the block size.
[0073] The block interval time of the transmission stream data is obtained within the timeout period according to the real-time status of the cache, and the transmission stream data is divided into blocks according to the block interval time.
[0074] In this embodiment, the parameters of the stream data transmission control are configured by encapsulating, and the block transmission of the stream data is dynamically adjusted in combination with the real-time status, thereby improving the stability of the stream data transmission. Among them, the first stream data configuration parameters include: block size range, timeout time; the dynamic adjustment content includes: adjusting the block size, adjusting the transmission interval time. The device corresponding to the method is as follows Figure 2 As shown, it includes a configuration parameter module 1 for implementing step S1 and a block transmission module 2 for implementing step S2.
[0075] Specifically, this embodiment can first solve the problem of unstable block transmission of streaming data. The main solution is to add a dynamic adjustment mechanism on the basis of the encapsulation mechanism to dynamically adjust the block size and transmission interval time to achieve control of stable transmission of streaming data. Encapsulation includes: in response to the method being applied to the client, encapsulating the first stream data configuration parameter and sending it to the server; in response to the method being applied to the server, receiving the first stream data configuration parameter encapsulated from the client. The real-time state is the real-time state of the client.
[0076] More specifically, taking the streaming request encapsulation of the Fetch API as an example, first initialize a streaming request configuration object, in which at least the timeout time and data size control parameters are configured, so that when processing large amounts of data or real-time data, data transmission and processing can be flexibly controlled.
[0077] In order to improve the stability of transmission, a dynamic flow control mechanism is introduced to dynamically adjust the transmission rate of data blocks according to network conditions or system load to ensure that data can be transmitted continuously without loss.
[0078] In the case of poor network conditions, overly large data blocks may cause streaming data transmission failure. This problem can be solved by dynamically adjusting the chunk size chunkSize within the chunk size range. The implementation code example is as follows:
[0079] / / Dynamic adjustment of block size logic
[0080] / / For example: dynamically adjust chunkSize based on network latency or processing time
[0081] if(performance.now()%1000<500){ / / Simulate network status changes
[0082] chunkSize = Math.min(chunkSize + 1024*256, 1024*1024) / / Increase to a maximum of 1MB
[0083] }
[0084] else{
[0085] chunkSize = Math.max(chunkSize-1024*256,1024*128) / / Reduce to a minimum of 128KB
[0086] }
[0087] To prevent the client from buffering and overflowing due to slow data processing, the server can adjust the transmission rhythm according to the client's processing situation. For example, the client will periodically send its own status information to the server, and the server will adjust the frequency and rhythm of data transmission accordingly. The frequency and rhythm of transmission are adjusted within the time limit.
[0088] The above process can be observed from the client side alone, from the server side alone, or from both sides together, that is, the execution subject involved in the method can be the client, the server, or a system composed of the client and the server.
[0089] In one embodiment, wherein:
[0090] The first stream data configuration parameters also include: breakpoint resume indication;
[0091] Transmitting streaming data in chunks according to real-time status and streaming data configuration parameters also includes:
[0092] According to the real-time status of the transmission stream data interruption and the indication of the breakpoint resuming transmission obtained, the transmission stream data is continued in blocks from the interruption point of the transmission stream data.
[0093] In this embodiment, a reconnection control mechanism is also provided, so that the user can set breakpoint resume according to actual needs, and the indication is encapsulated as a parameter for stream data transmission control, for example, encapsulated in a streaming request and sent to the server, so that the server provides the function of recording the progress of data stream transmission.
[0094] More specifically, when initializing a streaming request configuration object, configure the cancellation request (abortController). Users can customize the initialization of an AbortController instance and pass it as a parameter to the encapsulation method. This parameter controls whether the breakpoint resume function needs to be set. The signal attribute in the instance will be assigned to the signal attribute of the Fetch method, and the abort method of the abortController instance can be called externally to cancel the request. In order to achieve seamless reconnection that requires breakpoint resumption, the server needs to record the progress of each transmission (recorded in the backend redis or memory). When the client issues a reconnection request, the server can identify the client's breakpoint and continue to transmit the unfinished data fragments.
[0095] In one implementation, obtaining the encapsulated first-stream data configuration parameters specifically includes:
[0096] In response to the method being applied to a client, a pre-packaged stream data transmission control function is called, a first stream data configuration parameter is input into the stream data transmission control function, the stream data transmission control function adds the first stream data configuration parameter into a Fetch streaming request, and the Fetch streaming request is sent to a server, so that the server obtains the first stream data configuration parameter from the Fetch streaming request;
[0097] In response to the method being applied to the server, a Fetch streaming request from a client is received, and a first stream data configuration parameter is obtained from the Fetch streaming request. The Fetch streaming request is a call by the client to a pre-packaged stream data transmission control function, and the first stream data configuration parameter is input to the stream data transmission control function. The stream data transmission control function adds the first stream data configuration parameter to form a stream data transmission control function.
[0098] In this embodiment, the method can also be as follows Figure 3 and 4 As shown, first the client completes the request initialization and configuration, and sends a streaming request to the server.
[0099] The streaming request is implemented by the client according to the pre-packaged streaming data transmission control function streamFetch. The user (mainly developers here) only needs to call streamFetch to obtain the streaming format and decapsulate the streaming format. The client can flexibly control the reception, parsing and exception handling of the data stream, which is more suitable for data stream applications with high real-time requirements. The traditional Fetch request is used to initiate ordinary HTTP requests and lacks support for processing streaming data. This embodiment needs to add specific parameters on the basis of the existing Fetch request to control the streaming transmission and processing of data. The following is a simple example:
[0100]
[0101]
[0102]
[0103] In one embodiment, wherein:
[0104] The first stream data configuration parameters also include: block transmission specification, stream data format specification, encapsulation method specification, and stream mode specification;
[0105] Transmitting data in blocks also includes: the server transmits the stream data in blocks to the client by encapsulating the specified stream data format in a specified manner.
[0106] In this embodiment, by encapsulating the capabilities of the Fetch API, the gradual reception, parsing, and processing of streaming data are realized, and a dynamic adjustment and exception handling mechanism is provided during the transmission process, thereby improving the stability and efficiency of streaming data transmission. It can support large-scale data transmission and data transmission optimization in real-time interactive scenarios, and is particularly suitable for applications that require streaming processing, such as streaming text, video streams, and audio streams. As an asynchronous network request tool, the Fetch API has concise syntax and flexible request configuration capabilities. However, the Fetch API does not provide a complete flow control mechanism when processing streaming data, resulting in low data processing efficiency.
[0107] In the technical solution of Fetch API streaming request encapsulation, request initialization and configuration are implemented. In the implementation process, the client first initializes a streaming request configuration object. This object not only contains basic HTTP request information (such as request URL (Uniform Resource Locator), transmission mode, streaming data format, timeout, data size, custom processing method, whether it is a streaming mode parameter, etc.), but also introduces configuration parameters for streaming data to ensure that the transmission and processing of data can be flexibly controlled when processing large amounts of data or real-time data.
[0108] Specific parameters include:
[0109] Request address (url): specifies the request address of the linked server (target server).
[0110] Transmission mode (mode): specifies the transmission method of the stream data, such as whether to transmit in chunks and the size of each chunk (chunksize). After specifying the transmission mode and chunk size, the server and client will control the chunking and transmission of the data based on these parameters.
[0111] Stream data format: specifies the format of the data stream (such as text stream, video stream, audio stream, binary stream, etc.) to facilitate subsequent data assembly and parsing.
[0112] Timeout: Set a timeout. If the server does not send data within the specified time, the client will trigger the exception handling mechanism. After requesting the server, if the server does not return data or returns after a timeout, the encapsulated method will automatically trigger the exception mechanism or prompt the user that the server load is too high.
[0113] Data size (chunkSize): Users can set the defined size and its range, the default size is 1024 (1M).
[0114] Custom processing method (onProgress): Users can set custom encapsulation and decoding methods to perform custom processing on stream data.
[0115] Is it stream mode (isStream): Users can set whether to return data in stream mode.
[0116] Cancel request (abortController): Users can customize and initialize an AbortController instance and pass it to the encapsulation method as a parameter. The signal attribute in the instance will be assigned to the signal attribute of the Fetch method. The abort method of the abortController instance can be called externally to cancel the request. The content of the initialized AbortController instance corresponds to the breakpoint resume indication.
[0117] Request body: other request body data submitted by the user to the server.
[0118] In one embodiment, the method further comprises:
[0119] In response to the method being applied to the client, a second stream data configuration parameter is input into the stream data transmission control function, the stream data transmission control function adds the second stream data configuration parameter to the data block processing function, receives the stream data from the server in blocks, saves the received stream data in a cache area, and the data block processing function processes the stream data in the cache area according to the second stream data configuration parameter.
[0120] In this embodiment, the encapsulated method is actively called, and the client uses the Fetch API to send a streaming request to the server through the configured request object. Different from the traditional Fetch request, the streaming request allows the server to send data in blocks (the encapsulated method returns in streaming by default). After the client sends a request through the fetch function, it does not need to wait for the completion of the entire response body, but gradually receives the data stream returned by the server, which greatly improves the real-time performance of data processing. Especially in the face of large-scale data transmission, the client can process the received data immediately, reducing the waiting time.
[0121] like Figure 3 and 4 As shown in the figure, after the request is sent, the server can send data streams in batches, and the client receives data fragments piece by piece through ReadableStream. Whenever a new data fragment is received, when the user configures the onProgress function parameter, the encapsulation method internally determines the incoming onProgress and calls the onProgress function to process the stream data. Each received data is immediately passed to the onProgres function, which can perform custom processing on the stream data, such as custom decoding of the stream data, and the user can see the latest data updates in real time.
[0122] ReadableStream itself is an existing technology provided by the browser. It is part of the Web Streams API and allows developers to process data streams to receive and process data in blocks. This disclosure simplifies the development process by encapsulating this technology. This interface itself has the following functions:
[0123] 1) Receiving data in chunks: ReadableStream supports reading data in chunks, so that the client does not need to wait for the entire data stream to complete when receiving data. It can process streaming data such as video, audio, or large data files.
[0124] 2) Stream control: ReadableStream provides readers (such as ReadableStreamDefaultReader) that can read stream data step by step and supports asynchronous processing, which is very useful for implementing real-time data processing.
[0125] 3) Composability: ReadableStream supports combination with other stream objects, such as TransformStream and WritableStream, for more complex data stream processing.
[0126] When the server pushes a data fragment, the client first stores it in the cache. The cache mechanism adopts a dynamic adjustment strategy. The cache size can be flexibly adjusted according to the network conditions and the client's processing capabilities to prevent cache overflow or data loss caused by network jitter or data backlog.
[0127] ReadableStream and flow control, ReadableStream provides flow control function, allowing developers to implement backpressure management (backpressure). Through the enqueue() method and controller.desiredSize property in ReadableStream, the client can check the current buffer size and decide whether to continue receiving data or temporarily stop reading based on the return value to adjust the buffer size.
[0128] The received data segments are assembled according to the predetermined rules. When processing the data stream, the encapsulated system assembles the encoding format of the data stream according to the incoming stream data format parameters. Through this process, users can see the complete stream data in real time on the front end without waiting for all data segments to be transmitted. Existing live streams, such as flv and hsl, can only be seen after being decoded by the player or the front end. The decoding of basic text streams, video streams, and audio streams is encapsulated here.
[0129] In one embodiment, wherein:
[0130] The second stream data configuration parameters include a stream data format and a stream data decoding method, and the stream data format includes a text data stream, a video data stream, an audio data stream, and a binary data stream;
[0131] The data block processing function includes: a function for parsing and assembling the block stream data according to the stream data format and the stream data decoding method.
[0132] In this embodiment, the assembly and parsing of transmission stream data such as text stream, video stream, audio stream, etc. have been encapsulated internally, and an efficient assembly and parsing module has been implemented on the client to ensure the continuity and real-time performance of the stream data.
[0133] For text streams, the client needs to receive data line by line or segment by segment and decode and display it. When a new text data block is received, the client will temporarily store it in memory and splice it in sequence. Use TextDecoder to decode each data block, such as TextDecoder('utf-8'), to convert the received binary data into a readable text format. The decoded text will be passed to the front-end interface for real-time display or further processing.
[0134] This module assembles and parses video streams. When processing video streams, the client needs to ensure the order and decoding of the data to achieve continuous playback. Use the MediaSource API to assemble data streams on the client. The received video data fragments are spliced by frame or block through the SourceBuffer object. The data will be appended to the SourceBuffer to maintain the time order and continuity of the data. MediaSource will parse the data in real time, decode the assembled data blocks and push them to <video>Tags are used to play. When each video segment is appended to SourceBuffer, the player automatically renders the decoded content.
[0135] This module assembles and parses audio streams. The assembly and parsing of audio stream data is similar to that of video streams, but the audio format and codec need to be adapted. Use the MediaSource API and SourceBuffer objects to receive and assemble audio data. Audio data is spliced into SourceBuffer in chronological order to ensure the continuity of audio playback. Audio data is parsed in real time through MediaSource and SourceBuffer and output to <audio>The audio playback is done synchronously, and the decoder processes the data and outputs it to the audio device.
[0136] More specifically, when transmitting data, the server will include the stream format information in the response header or pass it through a custom request header when the request is initialized, informing the client of the data format, such as video, audio, text, or binary data stream, and the client will adopt different parsing methods accordingly. The encapsulation method will automatically include the default centralized data stream assembly and parsing methods, and the assembly and parsing actions will vary depending on the data type. Figure 5 As shown in the figure, the following scenarios explain how the client performs these actions based on the stream format parameters:
[0137] 1) Text data streams (such as logs, real-time messages)
[0138] Assembly: For text data streams, assembly usually combines the chunked data into complete sentences, lines, or paragraphs line by line or paragraph by paragraph. For example, when log lines are sent in segments, the client can piece together each line as it receives it to form a complete text content.
[0139] Parsing: Parsing a text stream usually involves decoding the received binary data into text format. The client uses TextDecoder (such as TextDecoder('utf-8')) to decode each data block, convert it into a readable text form, and display the text directly on the front-end interface.
[0140] Example: In a log stream, the client receives each line of log data and continuously assembles it into complete log content, and displays it to the user line by line.
[0141] 2) Video or audio streaming
[0142] Assembly: Video or audio streams need to be assembled according to a specific encoding format (such as video / mp4 or audio / mp3). The client will stitch the received segmented video or audio data together in frame or segment order to form a continuous playback stream. This process usually relies on a media decoder or playback buffer to send data fragments to the player in sequence.
[0143] Parsing: Parsing video or audio stream data is usually done through a media decoder, which converts the original binary data into a playable format. For example, using the MediaSource API and SourceBuffer objects, the client can append the received chunks of data to the SourceBuffer so that it can be played back in the future. <video>or <audio>tab for real-time playback.
[0144] Example: In live video streaming, the client receives video frame data transmitted in blocks from the server and assembles each frame into SourceBuffer in sequence to ensure smooth video playback.
[0145] 3) Binary data stream (such as file stream, image stream)
[0146] Assembly: Binary data assembly involves connecting each received data block in sequence into a complete data object. For example, for file transfer, the client will store all received binary blocks in a buffer and stitch them into a complete file after the data is completely received.
[0147] Parsing: Parsing of binary data is usually performed after assembly is completed. For example, for image or file data, the client converts the binary data into a Blob object and uses URL.createObjectURL to generate a directly accessible link or display it in tag.
[0148] Example: During a file download, the client receives and assembles each data block, and after the transfer is complete, provides the complete binary file to the user for download.
[0149] In one implementation, streaming data is transmitted in blocks according to the real-time state and streaming data configuration parameters, specifically including:
[0150] In response to the method being applied to the client, the client sends its own network real-time status, cache real-time status and / or transport stream data interruption real-time status to the server, so that the server obtains the block size, block interval time and / or interruption point of the transport stream data according to the network real-time status, cache real-time status and / or transport stream data interruption real-time status, and blocks the transport stream data according to the block size, block interval time and / or interruption point;
[0151] In response to the method being applied to the server, the real-time network status, the real-time cache status and / or the real-time status of the transmission stream data interruption from the client are received, and the block size, block interval time and / or interruption point of the transmission stream data are obtained according to the real-time network status, the real-time cache status and / or the real-time status of the transmission stream data interruption of the client, and the transmission stream data is divided into blocks according to the block size, the block interval time and / or the interruption point.
[0152] In this embodiment, in order to improve the stability of transmission, a dynamic flow control mechanism is introduced. The client can dynamically adjust the transmission rate of data blocks according to the network conditions or system load to ensure that data can be continuously transmitted without loss. This includes:
[0153] In the case of poor network conditions, overly large data blocks may cause transmission failure. For this purpose, a dynamic adjustment mechanism is designed to allow the server to adjust the size of each data block sent in real time based on the feedback information of the client (the client monitors changes in network conditions, feeds back to the server, and allows the server to dynamically adjust the size of the returned data). When the network delay is high, the server can reduce the amount of data transmitted in a single transmission to avoid transmission interruption; when the network condition is good, the server can increase the size of the data block to improve transmission efficiency. For optimization in case of poor network conditions, the maximum value of dynamic adjustment is the set value, and the minimum is to feed back to the server based on the network status of the client, so that the server can dynamically adjust the transmission size.
[0154] To prevent the client from buffering due to slow data processing, the server can adjust the transmission rhythm according to the client's processing situation. The client will periodically send status information to the server, and the server will adjust the frequency and rhythm of data transmission accordingly. The transmission rhythm is adjusted within the time limit.
[0155] In the specific implementation, the setting of block size and block transmission will affect the data flow management during the transmission process, but also requires specific mechanisms to support dynamic adjustment and processing. The following is a detailed explanation:
[0156] 1) The role and execution mode of the block size parameter. The block size parameter mainly affects the following aspects:
[0157] Server-side chunked response: When a client sends a request, if the request contains a chunk size setting (such as a custom chunk size parameter), the server can split the data into chunks based on this parameter and send them to the client one by one. For example, if the chunk size is set to 1MB, the server will transmit the data stream in chunks of 1MB.
[0158] The client receives and processes each data block by block: When the client receives each data block from the server, it can process it immediately without waiting for the entire response to end. After using the ReadableStream object to receive stream data block by block, the client can process these data blocks in onProgress or similar callback functions to achieve real-time display or step-by-step parsing.
[0159] 2) Flexibility in data flow segmentation: In streaming, the block size can be adjusted dynamically, making data flow segmentation flexible. This flexibility is mainly reflected in the following aspects:
[0160] The server dynamically adjusts the block size: During the transmission process, the server can dynamically adjust the block size based on the client's feedback (such as network speed or latency). When the network condition is good, the block size can be increased to improve the transmission efficiency; when the network is unstable, the block size can be reduced to prevent transmission failure or interruption.
[0161] Client cache management: The client can dynamically manage the cache according to its own processing capabilities and set the cache area to save the received data blocks. When the network is slow or the data block is too large, the cache mechanism can be used to process the data in batches to prevent memory overflow or data loss.
[0162] 3) The ability to arbitrarily divide streaming data into blocks. In theory, streaming data can be divided into blocks arbitrarily, but the implementation is limited by the following factors:
[0163] Transport protocol: HTTP / 1.1's Transfer-Encoding: chunked supports chunked transmission, but the chunk size is fixed before the transmission starts. HTTP / 2 and HTTP / 3 can support streaming transmission more flexibly, but the chunk size is usually determined on the server side and cannot be fully controlled by the client. Therefore, the present disclosure encapsulates the specified controllable range through initialization parameters and makes specific adjustments based on the real-time status.
[0164] Application scenario requirements: Different scenarios have different requirements for block size. For example, live video streaming may require a smaller block size to achieve lower latency, while large file transfers may use a larger block size to improve throughput.
[0165] 4) Implementation mechanism of dynamic chunking. To implement dynamic chunking, the system usually requires a set of feedback and adjustment mechanisms:
[0166] Real-time feedback mechanism: The client can provide feedback to the server, such as the current network status or cache status. The server dynamically adjusts the chunk size based on this feedback. For example, through WebSocket or long polling, the server can obtain feedback from the client about the network status and dynamically change the chunking strategy.
[0167] Adaptive chunking algorithm: The server can adjust the chunk size based on a preset strategy, such as dynamically adjusting it based on network conditions or client receiving speed.
[0168] In short, the setting of block size parameters provides the initial configuration basis for data stream segmentation, while the actual segmentation transmission and dynamic adjustment require the cooperation of the server and the client, based on the real-time feedback mechanism and protocol support.
[0169] In one embodiment, according to the real-time status of the transmission stream data interruption and the breakpoint resume indication obtained, the transmission stream data is continued in blocks from the interruption point of the transmission stream data, specifically including:
[0170] In response to the method being applied to the client, a prompt message is displayed to the user according to the fact that the client has not received the streaming data for a timeout period, the current streaming data transmission is interrupted according to the user's choice and a reconnection request is sent to the server, or a reconnection request is sent to the server after detecting that the connection with the server is disconnected, so that the server obtains the transmission progress recorded according to the obtained breakpoint resume indication when transmitting the streaming data according to the received reconnection request, takes the currently recorded transmission progress as the interruption point of the streaming data transmission, and continues to transmit the streaming data in blocks according to the interruption point;
[0171] In response to the method being applied to a server, when transmitting streaming data, the transmission progress is recorded according to the obtained breakpoint resume indication, and a reconnection request from a client is received. The reconnection request is that the client displays a prompt message to the user based on the fact that it has not received streaming data for a timeout period, interrupts the current streaming data transmission and sends it to the server based on the user's choice, or detects that the connection with the server is disconnected and sends it to the server, obtains the currently recorded transmission progress as the interruption point of the streaming data transmission according to the reconnection request, and continues to transmit the streaming data in blocks according to the interruption point.
[0172] In this embodiment, if Figure 3 and 4 As shown in the figure, various abnormal situations will inevitably occur during network transmission, such as network jitter, connection interruption or data loss. For this reason, a complete exception handling and reconnection mechanism is designed to ensure the continuity and reliability of data transmission. It includes:
[0173] During the data flow transmission process, the client always monitors the transmission status. If data loss or transmission failure is found, the system will immediately trigger the exception handling module and automatically try to resume the transmission. If the problem cannot be solved in a short time, the system will record the log and prompt the user to try to reconnect.
[0174] When the network is briefly interrupted or the server connection is disconnected, the client will automatically trigger the reconnection mechanism, interrupt the current request through AbortController, re-initiate the request and continue to receive data from the interruption point to ensure the continuity of transmission.
[0175] In order to achieve seamless reconnection, the server needs to record the progress of each transmission (recorded in the backend redis or memory). When the client sends a reconnection request, the server can identify the client's breakpoint and continue to transmit the unfinished data fragments.
[0176] In addition, if Figure 3 and 4 As shown, the method of this embodiment also includes ending the transmission and releasing resources. When the server completes the push of all streaming data, the client will receive an end signal, indicating that the data transmission is complete. The client can choose to release the resources related to the data stream and output or store the final processed complete data. This process ensures the rational use of system resources and prevents resource leakage. Related resources include: memory cache: used to store received data blocks, parsed data or other intermediate data; ReadableStream reader: a reader for reading data from a ReadableStream; decoder objects: objects such as TextDecoder or TextEncoder for parsing or encoding data; MediaSource and SourceBuffer: objects used for playing and assembling audio and video streams; event listeners: event listeners for processing data reception, progress updates or end of transmission.
[0177] This embodiment implements the gradual reception, parsing and real-time processing of streaming data by extending and encapsulating the existing Fetch API. This method can significantly improve the efficiency of data transmission, especially in scenarios such as live video and real-time monitoring. The technology of this embodiment can be applied to video cloud platforms, especially in scenarios involving video streaming and concurrent processing of multiple videos. Through the implementation of this technology, it is possible to optimize transmission efficiency, improve the smoothness of video playback, and ensure the stability of the platform under high concurrency. This streaming request encapsulation technology can be incorporated into the internal communication standards of the enterprise to provide technical support for subsequent data transmission interfaces and asynchronous requests.
[0178] Embodiment 2:
[0179] like Figure 2 As shown, the present disclosure provides a streaming data transmission control device, the device comprising:
[0180] Configuration parameter module 1, used to obtain the configuration parameters of the encapsulated first stream data, including: the block size range of the transmission stream data, and the timeout period of the reception stream data;
[0181] The block transmission module 2 is connected to the configuration parameter module 1 and is used to transmit the streaming data in blocks according to the real-time state and the streaming data configuration parameters, including:
[0182] The block size unit is used to obtain the block size of the transmission stream data within the block size range according to the real-time state of the network, and transmit the stream data in blocks according to the block size.
[0183] The interval time unit is used to obtain the block interval time of the transmission stream data within the timeout period according to the real-time status of the cache, and transmit the stream data in blocks according to the block interval time.
[0184] It should be noted that the device may specifically be a client, a server, or a system consisting of a client and a server.
[0185] In one embodiment, wherein:
[0186] The first stream data configuration parameters also include: breakpoint resume indication;
[0187] The block transmission module 2 also includes:
[0188] The breakpoint resume unit is used to continue the transmission stream data in blocks from the interruption point of the transmission stream data according to the real-time status of the transmission stream data interruption and the obtained breakpoint resume instruction.
[0189] In one implementation, the configuration parameter module 1 specifically includes:
[0190] A configuration parameter module 1 located at the client is used to call a pre-packaged stream data transmission control function, input a first stream data configuration parameter to the stream data transmission control function, and the stream data transmission control function adds the first stream data configuration parameter to a Fetch streaming request, and sends the Fetch streaming request to the server, so that the server obtains the first stream data configuration parameter from the Fetch streaming request; and / or,
[0191] The configuration parameter module 1 located on the server is used to receive a Fetch streaming request from a client and obtain a first stream data configuration parameter from the Fetch streaming request. The Fetch streaming request is a call by the client to a pre-packaged stream data transmission control function, and the first stream data configuration parameter is input to the stream data transmission control function. The stream data transmission control function adds the first stream data configuration parameter to form a stream data transmission control function.
[0192] In one embodiment, wherein:
[0193] The first stream data configuration parameters also include: block transmission specification, stream data format specification, encapsulation method specification, and stream mode specification;
[0194] Transmitting data in blocks also includes: the server transmits the stream data in blocks to the client by encapsulating the specified stream data format in a specified manner.
[0195] In one embodiment, the device further comprises:
[0196] The stream data processing module located at the client is connected to the block transmission module 2, and is used to input the second stream data configuration parameters to the stream data transmission control function. The stream data transmission control function adds the second stream data configuration parameters to the data block processing function, receives the stream data from the server in blocks, and saves the received stream data in a cache area. The data block processing function processes the stream data in the cache area according to the second stream data configuration parameters.
[0197] In one embodiment, wherein:
[0198] The second stream data configuration parameters include a stream data format and a stream data decoding method, and the stream data format includes a text data stream, a video data stream, an audio data stream, and a binary data stream;
[0199] The data block processing function includes: a function for parsing and assembling the block stream data according to the stream data format and the stream data decoding method.
[0200] In one implementation, the block transmission module 2 specifically includes:
[0201] The block transmission module 2 located at the client is used to send its own network real-time status, cache real-time status and / or transmission stream data interruption real-time status to the server, so that the server obtains the block size, block interval time and / or interruption point of the transmission stream data according to the network real-time status, cache real-time status and / or transmission stream data interruption real-time status, and blocks the transmission stream data according to the block size, block interval time and / or interruption point; and / or,
[0202] The block transmission module 2 located in the server is used to receive the real-time network status, cache real-time status and / or transmission stream data interruption real-time status from the client, obtain the block size, block interval time and / or interruption point of the transmission stream data according to the real-time network status, cache real-time status and / or transmission stream data interruption real-time status of the client, and block the transmission stream data according to the block size, block interval time and / or interruption point.
[0203] In one implementation, the breakpoint resuming unit specifically includes:
[0204] A breakpoint resume unit located at the client is used to display a prompt message to the user according to the timeout period when the streaming data is not received by the client, interrupt the current streaming data transmission according to the user's choice and send a reconnection request to the server, or detect that the connection with the server is disconnected and send a reconnection request to the server, so that the server obtains the transmission progress recorded according to the obtained breakpoint resume indication when transmitting the streaming data according to the received reconnection request, takes the currently recorded transmission progress as the interruption point of the streaming data transmission, and continues to transmit the streaming data in blocks according to the interruption point; and / or,
[0205] The breakpoint resume unit located on the server is used to record the transmission progress according to the obtained breakpoint resume indication when transmitting streaming data, and receive a reconnection request from the client. The reconnection request is that the client displays a prompt message to the user based on the fact that it has not received streaming data for a timeout period, interrupts the current streaming data transmission and sends it to the server according to the user's choice, or detects that the connection with the server is disconnected and sends it to the server, obtains the currently recorded transmission progress as the interruption point of the transmission streaming data according to the reconnection request, and continues to transmit the streaming data in blocks according to the interruption point.
[0206] Embodiment 3:
[0207] Embodiment 3 of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the streaming data transmission control method as described in Embodiment 1 or the streaming data transmission control device as described in Embodiment 2 is implemented.
[0208] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program elements or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.
[0209] In addition, the present disclosure may also provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the streaming data transmission control method as described in Example 1. The computer device may be the streaming data transmission control device as described in Example 2.
[0210] The memory is connected to the processor, the memory may be a flash memory or a read-only memory or other memory, and the processor may be a central processing unit or a single-chip microcomputer.
[0211] Embodiments 1-3 of the present disclosure provide a stream data transmission control method, a stream data transmission control device, and a computer-readable storage medium, which encapsulate and configure the parameters of the stream data transmission control, dynamically adjust the block transmission of the stream data in combination with the real-time status, and improve the stability of the stream data transmission.
[0212] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present disclosure, but the present disclosure is not limited thereto. For those of ordinary skill in the art, various modifications and improvements can be made without departing from the spirit and substance of the present disclosure, and these modifications and improvements are also considered to be within the scope of protection of the present disclosure.< / audio> < / video> < / audio> < / video>
Claims
1. A streaming data transmission control method, characterized in that: The method comprises: Obtaining configuration parameters of the encapsulated first stream data, including: a block size range of the transmission stream data, and a timeout period for receiving the stream data; Transmit streaming data in chunks according to real-time status and streaming data configuration parameters, including: According to the real-time network status, the block size of the transmission stream data is obtained within the block size range, and the transmission stream data is divided into blocks according to the block size. The block interval time of the transmission stream data is obtained within the timeout period according to the real-time status of the cache, and the transmission stream data is divided into blocks according to the block interval time.
2. The method according to claim 1, characterized in that in: The first stream data configuration parameters also include: breakpoint resume indication; Transmitting streaming data in chunks according to real-time status and streaming data configuration parameters also includes: According to the real-time status of the transmission stream data interruption and the indication of the breakpoint resuming transmission obtained, the transmission stream data is continued in blocks from the interruption point of the transmission stream data.
3. The method according to claim 2, characterized in that Get the encapsulated first-stream data configuration parameters, including: In response to the method being applied to a client, a pre-packaged stream data transmission control function is called, a first stream data configuration parameter is input into the stream data transmission control function, the stream data transmission control function adds the first stream data configuration parameter into a Fetch streaming request, and the Fetch streaming request is sent to a server, so that the server obtains the first stream data configuration parameter from the Fetch streaming request; In response to the method being applied to the server, a Fetch streaming request from a client is received, and a first stream data configuration parameter is obtained from the Fetch streaming request. The Fetch streaming request is a call by the client to a pre-packaged stream data transmission control function, and the first stream data configuration parameter is input to the stream data transmission control function. The stream data transmission control function adds the first stream data configuration parameter to form a stream data transmission control function.
4. The method according to claim 3, characterized in that: in: The first stream data configuration parameters also include: block transmission specification, stream data format specification, stream data encapsulation method specification, and stream mode specification; Transmitting data in blocks also includes: the server transmits stream data in a specified format encapsulated in a specified manner to the client in blocks.
5. The method according to claim 3, characterized in that: The method further comprises: In response to the method being applied to the client, a second stream data configuration parameter is input into the stream data transmission control function, the stream data transmission control function adds the second stream data configuration parameter to the data block processing function, receives the stream data from the server in blocks, saves the received stream data in a cache area, and the data block processing function processes the stream data in the cache area according to the second stream data configuration parameter.
6. The method according to claim 5, characterized in that in: The second stream data configuration parameters include a stream data format and a stream data decoding method, and the stream data format includes a text data stream, a video data stream, an audio data stream, and a binary data stream; The data block processing function includes: a function for parsing and assembling the block stream data according to the stream data format and the stream data decoding method.
7. The method according to any one of claims 2 to 6, characterized in that: Transmit streaming data in blocks according to real-time status and streaming data configuration parameters, including: In response to the method being applied to the client, the client sends its own network real-time status, cache real-time status and / or transport stream data interruption real-time status to the server, so that the server obtains the block size, block interval time and / or interruption point of the transport stream data according to the network real-time status, cache real-time status and / or transport stream data interruption real-time status, and blocks the transport stream data according to the block size, block interval time and / or interruption point; In response to the method being applied to the server, the real-time network status, the real-time cache status and / or the real-time status of the transmission stream data interruption from the client are received, and the block size, block interval time and / or interruption point of the transmission stream data are obtained according to the real-time network status, the real-time cache status and / or the real-time status of the transmission stream data interruption of the client, and the transmission stream data is divided into blocks according to the block size, the block interval time and / or the interruption point.
8. The method according to claim 3, characterized in that According to the real-time status of the transmission stream data interruption and the indication of the breakpoint resuming transmission obtained, the transmission stream data is continued in blocks from the interruption point of the transmission stream data, specifically including: In response to the method being applied to the client, a prompt message is displayed to the user according to the fact that the client has not received the streaming data for a timeout period, the current streaming data transmission is interrupted according to the user's choice and a reconnection request is sent to the server, or a reconnection request is sent to the server after detecting that the connection with the server is disconnected, so that the server obtains the transmission progress recorded according to the obtained breakpoint resume indication when transmitting the streaming data according to the received reconnection request, takes the currently recorded transmission progress as the interruption point of the streaming data transmission, and continues to transmit the streaming data in blocks according to the interruption point; In response to the method being applied to a server, when transmitting streaming data, the transmission progress is recorded according to the obtained breakpoint resume indication, and a reconnection request from a client is received. The reconnection request is that the client displays a prompt message to the user based on the fact that it has not received streaming data for a timeout period, interrupts the current streaming data transmission and sends it to the server based on the user's choice, or detects that the connection with the server is disconnected and sends it to the server, obtains the currently recorded transmission progress as the interruption point of the streaming data transmission according to the reconnection request, and continues to transmit the streaming data in blocks according to the interruption point.
9. A streaming data transmission control device, characterized in that: The device comprises: A configuration parameter module, used to obtain configuration parameters of the encapsulated first stream data, including: a block size range of the transmission stream data, and a timeout period for receiving the stream data; The block transmission module is connected to the configuration parameter module and is used to transmit the streaming data in blocks according to the real-time state and the streaming data configuration parameters, including: The block size unit is used to obtain the block size of the transmission stream data within the block size range according to the real-time state of the network, and transmit the stream data in blocks according to the block size. The interval time unit is used to obtain the block interval time of the transmission stream data within the timeout period according to the real-time status of the cache, and transmit the stream data in blocks according to the block interval time.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the streaming data transmission control method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Large language model streaming response processing method and device, medium, equipment and product
CN121705361A