CN-122002072-A - Multimedia playing window rendering control method based on mutual exclusion switching
Abstract
The invention discloses a multimedia playing window rendering control method based on mutual exclusion switching, which comprises the steps of initializing a window to be in a first rendering state and starting rendering enabling; the method comprises the steps of generating a session identifier in response to a streaming instruction, starting a timer, maintaining first rendering display during the period, receiving a callback, obtaining a synchronous lock, executing session verification and repeated signal filtering, and executing an atomic switching sequence after the verification is passed, wherein after the first rendering is disabled, a second rendering component is activated to take over a window handle to render video. The invention provides a grading overtime judgment, automatically renders waiting or error pictures when blocked, supports a last frame reservation mode, locks the pictures when the stream is interrupted and realizes automatic recovery through heartbeat detection. According to the invention, through atomic time sequence control and session filtering under the synchronous lock, the problems of flicker and black screen in an asynchronous environment are solved, and the display stability, logic robustness and visual consistency are improved.
Inventors
- ZHANG XIAO
- WANG XIAOWEI
- Ding Guangce
- CHEN RUN
- ZHANG XIAOLEI
- Cheng Xiangtong
- LI HAO
- SUN NAN
- ZHENG XIAOBO
Assignees
- 杭州阿启视科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260407
Claims (10)
- 1. A multimedia playing window rendering control method based on mutual exclusion switching is characterized by comprising the following steps: Initializing a rendering state machine of a playing window to be in a first rendering state, and activating a rendering update enabling interface of a first rendering component of the playing window to render a preset picture in the playing window through the first rendering component; Responding to a streaming instruction aiming at a target video stream, generating a session identifier corresponding to a current streaming task, starting a spam detection timer, and calling a rendering start interface of a second rendering component, wherein the rendering state machine is maintained in the first rendering state during the period that the second rendering component is ready to render; responding to the received rendering ready callback signal triggered by the second rendering component, acquiring a rendering synchronization lock corresponding to the rendering state machine, and performing validity check on the rendering ready callback signal based on the session identifier; After the validity check is passed, executing a switching flow, namely executing a rendering mutual exclusion switching sequence based on the rendering synchronization lock, comprising the steps of jumping the state of the rendering state machine to a transition state to execute an atomic switching operation in the transition state, namely disabling a rendering update enabling interface of the first rendering component, and then activating a handle taking over authority of the second rendering component on the playing window so as to render a real-time picture of the target video stream in the playing window by the second rendering component; updating the state of the rendering state machine to a second rendering state, stopping the spam detection timer, and releasing the rendering synchronization lock.
- 2. The method of claim 1, wherein validating the render-ready callback signal based on the session identification comprises: extracting callback session identification carried in the rendering ready callback signal; Judging whether the callback session identifier is matched with the session identifier which is currently active in the system; if so, further checking whether the rendering ready callback signal is a repeated callback signal for the current session; and if the callback signal is not repeated, judging that the rendering ready callback signal is a valid signal.
- 3. The method of claim 2, wherein validating the render-ready callback signal based on the session identification further comprises callback delay checking: Calculating a time difference between the sending time of the streaming instruction and the receiving time of the rendering ready callback signal; and if the time difference value exceeds a preset callback delay threshold value, judging that the rendering ready callback signal is an abnormal callback, and executing an error display flow forcedly.
- 4. The method of claim 1, further comprising determining a flow based on a one-level timeout of the spam detection timer: if the spam detection timer does not receive the valid rendering ready callback signal within a preset first timeout threshold, maintaining the rendering state machine in the first rendering state; and rendering a preset buffer waiting prompt picture in the play window through the first rendering component.
- 5. The method of claim 4, wherein the method further comprises a secondary timeout determination procedure: If the spam detection timer still does not detect the valid rendering ready callback signal within a preset second timeout threshold, judging that the streaming fails; And calling a stop interface of the second rendering component, maintaining the first rendering state and controlling the first rendering component to render a preset error prompt picture.
- 6. The method of claim 1, wherein the performing a render-mutually exclusive switching sequence includes ensuring that a render-update-enabling interface of the first rendering component is fully disabled under protection of the render-synchronization lock, and then triggering a video frame on-screen operation of the second rendering component to implement an atomic yield of the play window takeover rights by the first rendering component and the second rendering component on a time axis.
- 7. The method of claim 1, further comprising a display mode decision process in response to a play anomaly event: identifying a current abnormal display mode in response to a stream disruption event of the target video stream; If the abnormal display mode is an error closing mode, executing a switching-back flow from the second rendering state to the first rendering state; if a preset abnormal display mode configuration instruction is received and the abnormal display mode is the last frame reservation mode, entering a reservation display flow.
- 8. The method of claim 7, wherein entering a reservation display flow comprises: Maintaining the rendering state machine in the second rendering state and maintaining a rendering update enable interface of the first rendering component in a disabled state; And prohibiting calling a stop interface of the second rendering component to control the second rendering component to continuously lock and display the last frame of video picture before the stream interrupt in the play window.
- 9. The method of claim 8, wherein the reservation display flow further comprises automated control logic to resume and exit: Starting a recovery detection mechanism, and continuously sensing the recovery state of the target video stream through a heartbeat detection or state query interface; If the stream recovery is detected within the preset reservation timeout threshold, restarting the stream taking session and executing the switching flow; and if the stream recovery is not detected within the reservation timeout threshold, forcibly calling a stop interface of the second rendering component, and recovering a rendering update enabling interface of the first rendering component to switch back to the first rendering state.
- 10. The method of claim 1, wherein the method further comprises the step of the user actively stopping the process: Responding to a stopping instruction triggered by a user, acquiring the rendering synchronous lock, and calling a stopping interface of the second rendering component to release window taking-over permission; The rendering update enable interface of the first rendering component is re-activated and the rendering state machine is reset to the first rendering state, followed by releasing the rendering synchronization lock.
Description
Multimedia playing window rendering control method based on mutual exclusion switching Technical Field The invention relates to the technical field of multimedia playing and video monitoring, in particular to a rendering control method based on mutual exclusion switching between application frame rendering and decoding library rendering. Background In client applications such as video monitoring and streaming media playing, a playing window is usually required to support multiple-state picture display, including default background when not in streaming, streaming waiting prompt, real-time video pictures in the playing process and error prompt information when playing errors. It is common practice to display default pictures or error cues using a window redrawing mechanism of an application framework (e.g., a generic GUI rendering engine), and take over window areas directly using the rendering interface of the decoding library to display real-time video streams. However, this dual rendering mechanism has the following disadvantages in complex network environments or frequent human-computer interaction scenarios: Rendering switching lacks strict mutual exclusion control, namely, as the UI thread of an application framework and the callback thread of a decoding library are always in an asynchronous state, when rendering authority is switched, if control logic is not strict, the situation that two rendering modes write data into the same window handle at the same time easily occurs, so that obvious flickering or overlapping conflict is generated on a picture. The switching process has a state vacuum period, and if the accurate perception of the actual rendering state of the decoding library is lacking in the process of transition from the application framework rendering to the decoding library rendering, the video stream is not successfully on the screen after the application framework rendering is closed, so that a play window is briefly blacked out, and the user experience is seriously influenced. The consistency check of the streaming session is missing, and when the network fluctuation trigger frequency is heavy, a plurality of decoding callback events triggered asynchronously may have time sequence inversion. If the system cannot recognize the outdated callback instruction, a rendering state machine jump error may be caused, so that the window display is not matched with the actual business logic. The display of pictures in abnormal scenes is inflexible, and when the stream is interrupted or the network shakes, the conventional scheme generally adopts a strategy of 'hard switching back to an error picture'. However, in some security monitoring scenarios, the user is more prone to keep the last frame of effective picture as a reference, and the existing rendering scheduling mechanism cannot consider both flexibility of service and display continuity. In summary, how to achieve accurate mutual exclusion between rendering components, smooth coverage of transition states, and flexible control of abnormal display modes under complex network fluctuation and high-frequency reconnection scenarios, so as to improve stability and visual consistency of multimedia playing, is a technical problem to be solved currently. Disclosure of Invention The invention aims to provide a multimedia playing window rendering control method based on mutual exclusion switching, which aims to overcome the defects of state jump distortion caused by picture overlapping flicker caused by asynchronous conflict, short black screen caused by switching vacuum period, inconsistent picture display strategy under a streaming abnormal scene, inflexibility and the like in the prior art when frame rendering and decoding library rendering are applied, and to realize accurate mutual exclusion and smooth takeover of playing window rendering authority by the frame and decoding library by constructing a rendering state machine with atomic constraint, ensure that a playing window has unique activation rendering sources in each stage of initialization, streaming, playing, abnormal shut-off and the like, introduce session identification verification and multistage bottom scheduling mechanism, realize accurate filtering of asynchronous callback instructions and steady state display control under abnormal state, support various abnormal recovery modes including reservation of the last frame, and finally promote the display stability, logic robustness and visual continuity of the multimedia playing window under complex network fluctuation and high-frequency interaction scene. In order to achieve the above object, the present invention provides a multimedia playing window rendering control method based on mutual exclusion switching, the method comprising: Initializing a rendering state machine of a playing window to be in a first rendering state, and activating a rendering update enabling interface of a first rendering component of the playing window to render