A method and system for media streaming transmission in a large concurrent scenario
By grouping downstream platform equipment and sending streaming instructions asynchronously, combining Redis operations and accurately calculating the number of media streams, the problem of instability of media stream transmission in large concurrent scenarios is solved, and stable transmission and efficient resource utilization are achieved.
Patent Information
- Application Number
- CN202510704949.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-05-29
AI Technical Summary
In large concurrency scenarios, media streaming is unstable in the prior art, and the underlying platform cannot support concurrency, resulting in crashes, affecting the data reading progress and user experience.
The lower platform equipment is grouped through the management platform, and the stream fetching instructions are sent asynchronously within the preset time interval, the time interval is dynamically adjusted to be compatible with platforms that do not support true concurrency, combined with Redis atomic operation and accurate calculation of the number of media streams, control the amount of concurrent requests, and achieve stable transmission.
It improves the fault tolerance and stability of the system, is compatible with platforms that do not support true concurrency, ensures the stable transmission of media streams, and improves resource utilization and transmission efficiency.
Smart Images

Figure CN120223967B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of media streaming transmission, and in particular to a method and system for media streaming transmission in a large concurrent scenario. Background Art
[0002] The technical foundation of current video platforms, live streaming services, and online conferencing systems lies in concurrent streaming technology. The devices or systems involved are divided into upper-level platforms, management platforms, and lower-level platforms based on the direction of media streaming transmission. Lower-level platforms have a high degree of autonomy during development, leading to many uncontrollable factors in the media streaming process. This can cause lower-level platforms, which are supposed to support concurrent operations, to fail to do so. Consequently, media streaming can easily crash in high-concurrency scenarios.
[0003] Therefore, the existing technology has the problem of unstable media stream transmission under high concurrency conditions. Summary of the Invention
[0004] The embodiments of the present application provide a method and system for transmitting media streams in a large-concurrency scenario, so as to at least solve the problem of unstable media stream transmission in a large-concurrency scenario in the related art.
[0005] In a first aspect, an embodiment of the present application provides a method for transmitting media streams in a large concurrent scenario. The method is applied to a management platform, and the management platform is used to receive media streams pushed by a lower-level platform. The method includes:
[0006] Grouping the devices of the lower-level platform according to the first maximum concurrency of the management platform, and traversing each group to obtain traffic, wherein the number of devices in each group is less than or equal to the first maximum concurrency;
[0007] Traversing the devices in the current group, asynchronously sending stream acquisition instructions to the lower-level platform devices in sequence according to preset time intervals, and acquiring the media streams returned by the lower-level platforms in response to the stream acquisition instructions;
[0008] In response to the completion of traversal of devices in the current group, traversal of devices in the next group is performed until traversal of all groups is completed.
[0009] In one embodiment, after the previous group traversal is completed and before the current group traversal begins, the method further includes:
[0010] The asynchronous flow acquisition success rate is determined based on the return results of all flow acquisition instructions in the previous group, and the preset time interval is updated based on the success rate and a preset coefficient.
[0011] In one embodiment, updating the preset time interval based on the success rate and a preset coefficient includes:
[0012] In response to the success rate being less than a preset minimum threshold, updating the preset time interval based on a magnification factor;
[0013] In response to the success rate being greater than a preset maximum threshold, the preset time interval is updated based on a reduction factor.
[0014] In one embodiment, the management platform is further configured to push the media stream to the upper-level platform, and the method further includes:
[0015] Obtain the second maximum concurrency of the target upper-level platform and the number of media streams that the management platform has pushed to the target upper-level platform;
[0016] A maximum new concurrent volume is determined based on the number of media streams and the second maximum concurrent volume.
[0017] In one embodiment, determining the number of media streams that the management platform has pushed to the target upper-level platform includes:
[0018] Traversing the playback sessions of the management platform, and in response to a session flow existing in the playback session and the session flow belonging to the target upper-level platform, taking the playback session as a valid session and calculating the number of valid sessions;
[0019] The number of media streams that the management platform has pushed to the target upper-level platform is determined based on the number of valid sessions.
[0020] In one embodiment, the method further comprises:
[0021] Receiving a flow acquisition instruction from a target upper-level platform, and obtaining a concurrent request amount based on the flow acquisition instruction;
[0022] In response to the concurrent request amount being greater than the maximum newly added concurrent amount, returning and sending path number abnormality information to the target upper-level platform;
[0023] In response to the concurrent request amount being less than or equal to the maximum newly added concurrent amount, a media stream is generated, the media stream is pushed to the target upper-level platform, and the request is ended.
[0024] In one embodiment, the method further comprises:
[0025] In response to the stream fetch instruction request failing or timing out, ending the request;
[0026] In response to the request being completed, the concurrent request amount is updated through Redis.
[0027] In a second aspect, an embodiment of the present application provides a media stream transmission system in a large concurrent scenario, the system being applied to a management platform, the management platform being configured to receive media streams pushed by a lower-level platform, the system comprising:
[0028] An acquisition module is configured to group devices of the lower-level platform according to the first maximum concurrency of the management platform, and traverse each group to obtain traffic, wherein the number of devices in each group is less than or equal to the first maximum concurrency;
[0029] The stream acquisition module is used to traverse the devices in the current group, asynchronously send stream acquisition instructions to the lower-level platform devices in sequence according to preset time intervals, and obtain the media streams returned by the lower-level platforms in response to the stream acquisition instructions;
[0030] Traversal module: used to traverse the devices in the next group in response to the completion of traversal of the devices in the current group, until the traversal of all groups is completed.
[0031] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method for transmitting media streams in a highly concurrent scenario as described in the first aspect above is implemented.
[0032] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the method for transmitting media streams in a large concurrent scenario as described in the first aspect above is implemented.
[0033] The embodiments of the present application provide a method and system for transmitting media streams in a large concurrent scenario, which have at least the following technical effects.
[0034] This application performs asynchronous streaming at preset time intervals to provide a certain buffer time for concurrent tasks, so as to be compatible with some platforms that do not support true concurrency, improve the fault tolerance and stability of the system, and thus achieve stable transmission of media streams between the lower-level platform and the management platform.
[0035] The details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0037] Figure 1 is a schematic diagram of an application scenario according to an exemplary embodiment;
[0038] Figure 2 This is a flowchart of a method for transmitting media streams in a large concurrent scenario according to an embodiment of the present application;
[0039] Figure 3 This is a flow chart showing a method of obtaining a stream from a lower-level platform according to an exemplary embodiment;
[0040] Figure 4 is a flow chart of a method for adjusting a time interval according to an exemplary embodiment;
[0041] Figure 5 is a flow chart showing a method for processing upper-level flow acquisition according to an exemplary embodiment;
[0042] Figure 6 is a timing diagram showing a flow acquisition process of an upper-level platform according to an exemplary embodiment;
[0043] Figure 7 This is a structural block diagram of a media streaming transmission system in a large concurrent scenario according to an embodiment of the present application;
[0044] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is described and illustrated below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely used to explain this application and are not intended to limit this application. Based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without making any creative efforts are within the scope of protection of this application.
[0046] Obviously, the drawings described below are merely examples or embodiments of the present application. Those skilled in the art can, without inventive effort, apply the present application to other similar scenarios based on these drawings. Furthermore, it is also understood that, although the effort involved in such a development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, changes in design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as an insufficiency of the content disclosed in this application.
[0047] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments unless there is a conflict.
[0048] Unless otherwise defined, technical or scientific terms used herein shall have the ordinary meaning as understood by persons of ordinary skill in the art to which this application belongs. The terms "a," "an," "an," "the," and similar expressions used herein do not denote quantitative limitations and may refer to either the singular or the plural. The terms "comprise," "include," "have," and any variations thereof, used herein, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or modules (units) is not limited to the listed steps or units but may also include steps or units not listed, or may include other steps or units inherent to the process, method, product, or apparatus. The terms "connected," "connected," "coupled," and similar expressions used herein are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. As used herein, "plurality" means two or more. "And / or" describes an association between associated objects, indicating that three possible relationships exist. For example, "A and / or B" may mean: A exists alone; A and B exist simultaneously; or B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.
[0049] Figure 1 is a schematic diagram of an application scenario according to an exemplary embodiment. Figure 1 As shown, the devices or systems involved are divided into upper-level platforms, management platforms, and lower-level platforms according to the direction of media stream transmission. During the actual research and development process, the inventors of this application found that the lower-level platform was unable to support true concurrency. At this time, media stream transmission is prone to crash in a large concurrency scenario, affecting data reading progress and user experience. The inventors speculate that the possible reasons for this problem include: (1) The lower-level platform may not use locks and atomic operations when processing INVITE signaling, resulting in a race condition when multiple threads modify data. (2) Deadlocks are caused by unreasonable lock granularity, incorrect sequence, or abnormal congestion designed by the lower-level platform, leading to system crashes.
[0050] Based on the above situation, the embodiments of the present application provide a method and system for media stream transmission in a large concurrency scenario.
[0051] In a first aspect, an embodiment of the present application provides a method for transmitting media streams in a large concurrent scenario. The method is applied to a management platform, and the management platform is used to receive media streams pushed by a lower-level platform.
[0052] Figure 2This is a flow chart of a method for transmitting media streams in a large concurrent scenario according to an embodiment of the present application. Figure 2 As shown, the method includes:
[0053] Step S101: Group the devices of the lower-level platform according to the first maximum concurrency of the management platform, and traverse each group to obtain traffic, wherein the number of devices in each group is less than or equal to the first maximum concurrency.
[0054] Optionally, the lower-level platform determines the maximum concurrency of the management platform based on resources such as device performance, network bandwidth, and the priority of the management platform in the target lower-level platform, and sends the maximum concurrency to the management platform, and the management platform receives the maximum flow concurrency sent by the lower-level platform. Among them, the number of lower-level platforms is greater than or equal to 1. When the number of lower-level platforms is more than one, the priority of the management platform is different. The priority of the management platform is relative to the target lower-level platform, and the management platform priorities corresponding to different target lower-level platforms are different. The lower-level platform determines the priority based on parameters such as the recharge status of the management platform in the target lower-level platform and the historical maximum concurrency.
[0055] In step S101, the management platform groups devices in the lower-level platform based on their maximum concurrency. For example, the image acquisition devices in the lower-level platform are divided into n groups, with A representing the number of devices in each group, where n and A are both positive integers, and A represents the maximum concurrency of the lower-level platform. This ensures that the concurrency of asynchronous stream acquisition does not exceed the maximum concurrency of the management platform, which helps ensure the stability of media streaming transmission.
[0056] Step S102 , traverse the devices in the current group, asynchronously send stream acquisition instructions to the lower-level platform devices in sequence according to a preset time interval, and acquire the media stream returned by the lower-level platform in response to the stream acquisition instruction.
[0057] Optionally, traverse each device in the current group, start the asynchronous flow acquisition task of the first device at time T1, start the asynchronous flow acquisition task of the second device at time T2, and c Always start the asynchronous streaming task of the Ath device, and the time difference between the current device and the next device is the preset time interval. In this application, the initial preset time interval is set to 100ms according to the test situation. The initial time interval can also be set to 150ms, 200ms, etc. The initial time interval can be set according to the specific actual application situation and is not limited to the examples listed in this application. In addition, this application extracts the key frames in the media stream data after the stream is taken, ends the stream taking task after extracting the key frames, and processes the callback of the asynchronous stream taking task.
[0058] In this way, when the lower-level platform is configured to support asynchronous tasks but cannot truly implement concurrent functions, a certain time interval is set to ensure that the lower-level platform stably executes asynchronous stream acquisition tasks, thereby achieving stable transmission of media streams between the lower-level platform and the management platform.
[0059] Step S103: In response to the completion of traversal of the devices in the current group, traverse the devices in the next group until all groups are traversed. Optionally, traverse each group in turn, mark all asynchronous tasks as completed after the current group is traversed, and continue traversing the next group.
[0060] Figure 3 This is a flow chart showing a method of obtaining a stream from a lower-level platform according to an exemplary embodiment. Figure 3 As shown in the figure, the process of fetching streams from the lower-level platform specifically includes: dividing the lower-level platform devices into n groups, with each group size equal to the first maximum concurrency of the current platform, A. Then, traversing the n groups to fetch streams, setting a counter count = A during each traversal to control the number of traversals within the group, and creating a Promise instance to enter the async executor to traverse A devices to fetch streams.
[0061] When traversing devices within a group to retrieve streams, asynchronous stream retrieval is performed at regular intervals, with a certain interval between the current and previous stream retrieval tasks. After the stream retrieval is completed, keyframes are extracted from the resulting media stream, the retrieval task is terminated, and the asynchronous task callback is processed. Each time a stream retrieval is completed, the corresponding counter is decremented by 1 until the counter reaches 0, indicating that all devices in the current group have been traversed, and the Promise is resolved. The stream retrieval process then continues with the devices in the next group until all groups have been traversed, ending the loop.
[0062] In one example, after the previous group traversal is completed and before the current group traversal begins, the method further includes:
[0063] Step S201: Determine the asynchronous stream acquisition success rate based on the return results of all stream acquisition instructions in the previous group.
[0064] Step S202: updating the preset time interval based on the success rate and the preset coefficient.
[0065] Optionally, the initial preset time interval is determined based on experimental conditions, but the time interval during asynchronous stream retrieval can be adjusted based on application conditions. Specifically, after the previous group traversal is completed, the ratio of the tasks that successfully retrieved streams from the previous group to the total number of tasks is calculated as the success rate. The preset time interval is updated based on the success rate, and the updated preset time interval is applied to the current group.
[0066] In one example, step S202 includes:
[0067] Step S2021 : in response to the success rate being less than a preset minimum threshold, updating the preset time interval based on the amplification factor.
[0068] Step S2022: In response to the success rate being greater than the preset maximum threshold, the preset time interval is updated based on the reduction coefficient.
[0069] Optionally, when the success rate is less than the preset minimum threshold, it indicates that the current preset time interval is too small and is not sufficient to stably implement the asynchronous task, and the time interval needs to be increased; when the success rate is greater than the preset maximum threshold, it indicates that the current success rate is high and the current time interval is sufficient to stably implement the asynchronous task. In order to further improve the transmission efficiency while ensuring the success rate of the asynchronous task, it is necessary to reduce the time interval to further traverse and adjust the preset time interval.
[0070] As an example, the specific process of adjusting the time interval includes: setting the initial time interval timeInterval, the minimum time interval minInterval, the maximum time interval maxInterval, the minimum threshold for the success rate, and the maximum threshold for the success rate. In this application, considering the need to ensure the stability of media stream transmission while minimizing the compensation time to ensure data transmission efficiency, the time interval is set between 50ms and 1000ms. Then, the maximum concurrency A of the upper-level platform is set, and the lower-level platform devices are grouped according to the maximum concurrency, with the number of groups n = number of devices / A.
[0071] It should be noted that the above-mentioned time interval setting parameters, success rate threshold parameters, concurrent number and other parameters can be set according to the actual application scenario and are not limited to the examples listed in this application.
[0072] After setting the above parameters, the time interval is dynamically adjusted. Figure 4 FIG. 1 is a flow chart showing a method for adjusting a time interval according to an exemplary embodiment. Figure 4 As shown in the figure, after setting the parameters, each group is iterated. During the iteration of each group, A concurrent tasks are controlled at an initial time interval using Promise and a counter. The failure or success result of each concurrent task in the current group is recorded. The success rate of the current group is calculated based on the number of successful tasks and the total number of tasks.
[0073] Determine whether the success rate of the current group is less than the minimum success rate threshold. If so, the current preset interval is too short to stably implement the asynchronous task. Increase the interval using the amplification factor. The amplification factor can be set based on the actual application scenario. If the amplified interval is greater than the maximum interval, the maximum interval is used as the updated interval.
[0074] If the success rate of the current packet is not less than the minimum success rate threshold, the system determines whether the success rate is greater than the maximum success rate threshold. If so, the current success rate is high and the current time interval is sufficient to stably implement asynchronous tasks. To further improve transmission efficiency while ensuring the success rate of asynchronous tasks, the time interval is reduced by a reduction factor. The reduction factor can be set based on the actual application scenario. If the reduced time interval is less than the minimum time interval, the minimum time interval is used as the updated time interval.
[0075] The next group is traversed at the updated time interval until all groups are traversed and the final optimal time interval is obtained.
[0076] In this way, the time interval of the asynchronous flow acquisition task is dynamically updated according to the flow acquisition success rate of each group to determine the optimal time interval, thereby ensuring the transmission efficiency while ensuring the success rate of the asynchronous task.
[0077] Refer again Figure 1 In one example, the management platform is further configured to push the media stream to the upper-level platform. In this case, the method further includes:
[0078] Step S104: Acquire the second maximum concurrency of the target upper-level platform and the number of media streams that the management platform has pushed to the target upper-level platform.
[0079] Optionally, the management platform determines the maximum concurrent flow rate for the target upper-level platform based on resources such as performance, network bandwidth, and the target upper-level platform's priority within the management platform. The number of upper-level platforms is greater than or equal to one, and the priority of an upper-level platform is relative to the management platform. Different upper-level platforms have different priorities. The management platform determines the priority based on parameters such as the target upper-level platform's top-up status within the management platform and its historical maximum concurrent flow rate.
[0080] In one example, determining the number of media streams that the management platform has pushed to the target upper-level platform in step S104 includes:
[0081] Traverse the playback sessions of the management platform. If a session stream exists in the playback session and the session stream belongs to the target upper-level platform, treat the playback session as a valid session and calculate the number of valid sessions. Based on the number of valid sessions, determine the number of media streams that the management platform has pushed to the target upper-level platform.
[0082] Optionally, the number of valid sessions is used as the number of media streams that have been pushed to the target upper-level platform. In the platform cascade scenario, audio and video playback involves multi-level platform signaling interaction, media stream transmission and dynamic resource allocation. Existing technologies generally rely on SIP signaling session management (such as INVITE / BYE signaling counting). In the event of network anomalies, equipment failures or process link interruptions, the signaling session may become invalid. However, since the session end signaling is not received, the invalid session will still be treated as a valid session, resulting in an inaccurate number of valid sessions. This example determines the number of media streams that have been pushed to the target upper-level platform by the number of session streams, can accurately calculate the number of valid sessions, avoid the problem of concurrency exceeding the maximum concurrency due to inaccurate session counting, and improve the stability of media stream transmission.
[0083] Step S105: Determine the maximum new concurrent volume based on the number of media streams and the second maximum concurrent volume.
[0084] Optionally, the maximum new concurrency is determined based on the difference between the second maximum concurrency of the target upper platform and the number of media streams pushed to the target upper platform. By accurately calculating the maximum new concurrency, the concurrency process is effectively controlled and the stability of media stream transmission is improved.
[0085] Figure 5 This is a flowchart of a method for processing upper-level flow according to an exemplary embodiment. Figure 5 Steps S502 through S509 determine the number of media streams between the current platform and the superior platform. The specific process includes: determining whether a session stream exists in the playback session. If not, the session is deemed invalid. If a session stream exists, determining whether the session stream belongs to the target superior platform. If so, the session stream is deemed valid, deleting the invalid session, and determining the current number of media streams between the management platform and the superior platform based on the number of valid sessions. The maximum new concurrent capacity is determined based on the number of media streams and the maximum concurrent capacity of the target superior platform. The maximum new concurrent capacity is expressed as newCount = C – currentCount, where currentCount represents the number of media streams already pushed to the target superior platform and C represents the second maximum concurrent capacity.
[0086] In one example, the method further includes:
[0087] Step S106: Receive a flow acquisition instruction from the target upper-level platform, and obtain the concurrent request quantity based on the flow acquisition instruction.
[0088] Step S107: In response to the concurrent request amount being greater than the maximum newly added concurrent amount, a return is made to the target upper-level platform and a path number abnormality information is sent.
[0089] Step S108 : In response to the concurrent request amount being less than or equal to the maximum newly added concurrent amount, a media stream is generated, the media stream is pushed to the target upper-level platform, and the request is ended.
[0090] Optionally, parse the flow instructions sent by the upper platform and determine the number of concurrent requests based on all flow instructions. Figure 5 For details, see steps S510 to S514. Redis atomic operations are used to count concurrent requests. If the number of concurrent requests exceeds the maximum number of concurrent requests, an error message such as "Concurrency Limit Exceeded" or "Concurrent Path Abnormal" is immediately displayed. If the number of concurrent requests is less than or equal to the maximum number of concurrent requests, a media stream is generated and pushed to the target upper-level platform. The request is terminated, and the number of concurrent requests is updated through Redis.
[0091] This approach ensures that the sum of the maximum number of concurrent connections and the number of media streams currently allowed does not exceed the maximum number of concurrent connections. Furthermore, Redis atomicity ensures accurate responses to newly added concurrent requests, preventing transmission crashes and improving the stability of media stream transmission.
[0092] In one example, the method further includes: in response to a failure or timeout of the fetch stream instruction request, ending the request. In response to the request ending, updating the concurrent request quantity via Redis.
[0093] Optionally, when a request completes, regardless of success or failure, the number of concurrent requests is decremented to ensure resource release and improve resource utilization.
[0094] This application divides the upper-level platform's streaming process into two phases through steps S104 to S108: Phase 1 (request-response phase): receiving a playback request and allocating temporary resources; Phase 2 (media streaming phase): establishing a media transmission channel and consuming actual resources. Figure 6 This is a timing diagram of a flow acquisition process of an upper-level platform according to an exemplary embodiment. Figure 6As shown, the streaming media server is queried in real time to obtain the currentCount number of media streams currently being transmitted in phase 2. Based on the number of media streams, the maximum number of concurrent requests allowed in phase 1 is determined: maxRequestCount = C – currentCount. Redis atomic operations (INCR / DECR) are used to count the number of concurrent requests in phase 1: requestCount. Upon receiving a request, if requestCount > maxRequestCount, an exception message such as "Concurrency Limit Exceeded" or "Concurrent Path Count Abnormal" is immediately displayed. If the number of concurrent requests is less than or equal to the maximum number of concurrent requests, a media stream is generated, pushed to the target upstream platform, and the request is terminated. Upon completion of the request, regardless of success or failure, the number of concurrent requests, requestCount, is decremented to ensure resource release and improve resource utilization.
[0095] In this way, steps S104-S108 accurately determine the number of streaming media, avoiding resource leaks caused by signaling anomalies. The maximum number of new concurrent requests is dynamically adjusted based on the actual state of the media streams, improving resource utilization. Global control is achieved through Redis counts and parent platform status, reducing system complexity. Redis can also respond to network fluctuations and device status changes in real time. For example, in the event of a camera failure, request failure, or network outage, the concurrent request count is automatically released, improving resource utilization.
[0096] In summary, the present application sets the time interval to start the asynchronous task through steps S101~S103, is compatible with some platforms that do not support true concurrency, and improves the fault tolerance and stability of the system at the cost of a small time delay, thereby achieving stable transmission of media streams between the lower-level platform and the management platform. Through steps S104~S108, the number of valid session streams belonging to the target upper-level platform is judged to accurately determine the number of streaming media, avoiding resource leakage due to signaling anomalies, thereby dynamically adjusting the maximum new concurrency according to the actual status of the media stream, and improving resource utilization. The atomicity of Redis ensures accurate response to new concurrent requests, avoids transmission crashes, and improves the stability of media stream transmission. Global control is achieved through Redis counting and the status of the upper-level platform, reducing system complexity, and Redis can respond to network fluctuations and device status changes in real time. For example, when the camera fails, the request fails, or the network is interrupted, the concurrent request count is automatically released to improve resource utilization.
[0097] In a second aspect, an embodiment of the present application provides a media stream transmission system in a large concurrent scenario. The system is applied to a management platform, and the management platform is used to receive media streams pushed by lower-level platforms. Figure 7 This is a structural block diagram of a media streaming system in a large concurrent scenario according to an embodiment of the present application. Figure 7As shown, the system includes:
[0098] The acquisition module 100 is used to group the devices of the lower-level platform according to the first maximum concurrency of the management platform, and traverse each group to obtain the flow, wherein the number of devices in each group is less than or equal to the first maximum concurrency.
[0099] The stream acquisition module 200 is used to traverse the devices in the current group, asynchronously send stream acquisition instructions to the lower-level platform devices in sequence according to preset time intervals, and acquire the media stream returned by the lower-level platform in response to the stream acquisition instruction.
[0100] The traversal module 300 is configured to traverse the devices in the next group in response to the completion of the traversal of the devices in the current group, until the traversal of all groups is completed.
[0101] In one example, after the previous group traversal is completed and before the current group traversal begins, the system further includes:
[0102] It is used to determine the success rate of asynchronous flow acquisition based on the return results of all flow acquisition instructions in the previous group, and update the preset time interval based on the success rate and the preset coefficient.
[0103] In one example, updating the preset time interval based on the success rate and the preset coefficient includes:
[0104] In response to the success rate being less than a preset minimum threshold, the preset time interval is updated based on the amplification factor.
[0105] In response to the success rate being greater than a preset maximum threshold, the preset time interval is updated based on the reduction factor.
[0106] In one example, the management platform is further configured to push the media stream to the upper-level platform. The system further includes:
[0107] Acquisition module: used to obtain the second maximum concurrency of the target upper-level platform and the number of media streams that the management platform has pushed to the target upper-level platform.
[0108] Determination module: used to determine the maximum new concurrent volume based on the number of media streams and the second maximum concurrent volume.
[0109] In one example, the acquisition module includes:
[0110] It is used to traverse the playback sessions of the management platform, and in response to the existence of a session flow in the playback session and the session flow belonging to the target upper-level platform, the playback session is regarded as a valid session and the number of valid sessions is calculated.
[0111] Used to determine the number of media streams that the management platform has pushed to the target upper-level platform based on the number of valid sessions.
[0112] In one example, the system further includes:
[0113] Used to receive flow instructions from the target upper-level platform and obtain the concurrent request volume based on the flow instructions.
[0114] In response to the concurrent request amount being greater than the maximum newly added concurrent amount, a path number abnormality message is returned to the target superior platform and sent.
[0115] In response to the concurrent request amount being less than or equal to the maximum newly added concurrent amount, a media stream is generated, the media stream is pushed to the target upper-level platform, and the request is ended.
[0116] In one example, the system further includes: terminating the request in response to a failure or timeout of the fetch stream instruction request, and updating the concurrent request amount through Redis in response to the request being terminated.
[0117] In summary, this application starts asynchronous tasks by setting time intervals, is compatible with some platforms that do not support true concurrency, and improves the fault tolerance and stability of the system at the cost of a small time delay, thereby achieving stable transmission of media streams between the lower-level platform and the management platform. The number of streaming media is accurately determined by the number of session streams belonging to the target upper-level platform to avoid resource leakage due to signaling anomalies, thereby dynamically adjusting the maximum new concurrency according to the actual status of the media stream to improve resource utilization. The atomicity of Redis ensures accurate response to new concurrent requests, avoids transmission crashes, and improves the stability of media stream transmission. Global control is achieved through Redis counts and upper-level platform status, reducing system complexity, and Redis can respond to network fluctuations and device status changes in real time. For example, when a camera fails, a request fails, or the network is interrupted, the concurrent request count is automatically released to improve resource utilization.
[0118] In a third aspect, an embodiment of the present application provides an electronic device, Figure 8 This is a structural diagram of an electronic device provided in an embodiment of the present application. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, a method for transmitting media streams in a large concurrent scenario provided in the first aspect is implemented. Figure 8 The electronic device 60 shown is only an example and should not limit the functions and scope of use of the embodiments of the present application.
[0119] The electronic device 60 may be a general-purpose computing device, such as a server device. Components of the electronic device 60 may include, but are not limited to, the at least one processor 61, the at least one memory 62, and a bus 63 connecting different system components (including the memory 62 and the processor 61).
[0120] The bus 63 includes a data bus, an address bus, and a control bus.
[0121] The memory 62 may include a volatile memory, such as a random access memory (RAM) 621 and / or a cache memory 622 , and may further include a read-only memory (ROM) 623 .
[0122] The memory 62 may also include a program / utility 625 having a set (at least one) of program modules 624, such program modules 624 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0123] The processor 61 executes various functional applications and data processing by running the computer program stored in the memory 62, such as a media streaming transmission method in a large concurrent scenario provided in the first aspect of the present application.
[0124] The electronic device 60 can also communicate with one or more external devices 64 (e.g., keyboard, pointing device, etc.). Such communication can be performed through an input / output (I / O) interface 65. In addition, the electronic device 60 can also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 66. Figure 8 As shown, the network adapter 66 communicates with other modules of the electronic device 60 via the bus 63. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 60, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (RAID) systems, tape drives, and data backup storage systems.
[0125] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the present invention, the features and functions of two or more units / modules described above may be embodied in a single unit / module. Conversely, the features and functions of a single unit / module described above may be further divided and embodied by multiple units / modules.
[0126] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a program stored thereon. When the program is executed by a processor, the method for transmitting media streams in a large concurrent scenario provided in the first aspect is implemented.
[0127] Specifically, the readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0128] In a possible implementation, the present invention can also be implemented in the form of a program product, which includes program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of a media streaming transmission method in a large concurrent scenario provided by the first aspect.
[0129] The program code for executing the present invention may be written in any combination of one or more programming languages, and may be executed entirely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or entirely on the remote device.
[0130] The technical features of the above-mentioned embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above-mentioned embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0131] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for transmitting media streams in a large concurrent scenario, characterized in that: The method is applied to a management platform, which is used to receive media streams pushed by a lower-level platform. The method includes: Grouping the devices of the lower-level platform according to the first maximum concurrency of the management platform, and traversing each group to obtain traffic, wherein the number of devices in each group is less than or equal to the first maximum concurrency; Traverse the devices in the current group, asynchronously send stream fetching instructions to the lower-level platform devices in sequence at preset time intervals, and obtain the media stream returned by the lower-level platform in response to the fetching instruction. After the stream fetching is completed, perform key frame extraction on the obtained media stream, then end the stream fetching task and process the callback of the asynchronous task; In response to the completion of the traversal of the devices in the current group, the devices in the next group are traversed until all groups are traversed. After the traversal of the previous group is completed and before the traversal of the current group begins, the method further includes: determining the asynchronous flow acquisition success rate based on the return results of all flow acquisition instructions in the previous group, and updating the preset time interval based on the success rate and a preset coefficient. Wherein, updating the preset time interval based on the success rate and the preset coefficient includes: in response to the success rate being less than a preset minimum threshold, updating the preset time interval based on the magnification coefficient; in response to the success rate being greater than a preset maximum threshold, updating the preset time interval based on the reduction coefficient.
2. The method for transmitting media streams in a large concurrent scenario according to claim 1, wherein: The management platform is further configured to push the media stream to the upper-level platform. The method further includes: Obtain the second maximum concurrency of the target upper-level platform and the number of media streams that the management platform has pushed to the target upper-level platform; A maximum new concurrent volume is determined based on the number of media streams and the second maximum concurrent volume.
3. The method for transmitting media streams in a large concurrent scenario according to claim 2, wherein: Determine the number of media streams that the management platform has pushed to the target upper-level platform, including: Traversing the playback sessions of the management platform, and in response to a session flow existing in the playback session and the session flow belonging to the target upper-level platform, taking the playback session as a valid session and calculating the number of valid sessions; The number of media streams that the management platform has pushed to the target upper-level platform is determined based on the number of valid sessions.
4. The method for transmitting media streams in a large concurrent scenario according to claim 2, wherein: The method further comprises: Receiving a flow acquisition instruction from a target upper-level platform, and obtaining a concurrent request amount based on the flow acquisition instruction; In response to the concurrent request amount being greater than the maximum newly added concurrent amount, returning and sending path number abnormality information to the target upper-level platform; In response to the concurrent request amount being less than or equal to the maximum newly added concurrent amount, a media stream is generated, the media stream is pushed to the target upper-level platform, and the request is ended.
5. The method for transmitting media streams in a large concurrent scenario according to claim 4, wherein: The method further comprises: In response to the stream fetch instruction request failing or timing out, ending the request; In response to the request being completed, the concurrent request amount is updated through Redis.
6. A media streaming transmission system in a large concurrent scenario, characterized in that: The system is applied to a management platform, which is used to receive media streams pushed by a lower-level platform. The system includes: An acquisition module is configured to acquire a first maximum concurrency of the management platform and a device group of a subordinate platform, and traverse each group, wherein the number of devices in each group is less than or equal to the first maximum concurrency; The stream acquisition module is used to traverse the devices in the current group, asynchronously send stream acquisition instructions to the lower-level platform devices in sequence according to preset time intervals, and obtain the media stream returned by the lower-level platform in response to the stream acquisition instruction. After the stream acquisition is completed, the key frame is extracted from the obtained media stream, and then the stream acquisition task is terminated and the callback of the asynchronous task is processed; A traversal module is configured to, in response to the completion of the traversal of the devices in the current group, traverse the devices in the next group until all groups are traversed. After the traversal of the previous group is completed and before the traversal of the current group begins, the method further includes: determining the asynchronous flow acquisition success rate based on the return results of all flow acquisition instructions in the previous group, and updating the preset time interval based on the success rate and the preset coefficient. Wherein, updating the preset time interval based on the success rate and the preset coefficient includes: in response to the success rate being less than a preset minimum threshold, updating the preset time interval based on the magnification coefficient; in response to the success rate being greater than a preset maximum threshold, updating the preset time interval based on the reduction coefficient.
7. An electronic device, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for transmitting media streams in a large concurrent scenario according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a media streaming transmission method in a large concurrent scenario is implemented as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Data downloading method and device, computer equipment and storage medium
CN112954406A
Media stream sending method and system, processing equipment and storage medium
CN113630628A