Disclosure of Invention
In view of the foregoing problems, an object of the present invention is to provide a method, an apparatus, a device, and a computer-readable storage medium for video layer update, which avoid that a video receiver frequently requests a video source end for a key frame due to frequent change of a code rate allocated to a window in a short time, and the receiver also frequently updates the window in a short time, thereby increasing decoding decompression pressure.
In a first aspect, an embodiment of the present invention provides a video layer updating method, including the following steps:
when a key frame of a first video stream sent by any first video source end is received, a first video layer corresponding to the key frame is obtained, and a window to be updated to the first video layer is obtained;
comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to determine whether the window meets a first updating condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window;
when the window is determined to meet the first updating condition and the first video layer is larger than the second video layer, judging whether the time period from the last time when the window completes updating the video layer to the current time is larger than a preset time threshold value;
and when the first video layer is larger than the second video layer, if the time period from the last time when the window completes the updating of the video layer to the current time is larger than a preset time threshold, updating the video layer of the window to be the first video layer.
In a first possible implementation manner of the first aspect, the method further includes:
responding to a subscription instruction of a corresponding window sent by any client, and acquiring subscription information corresponding to the subscription instruction;
adding a window of the client subscription to a set of windows to be updated to the first video layer when the subscription information includes a request for the first video stream.
In a second possible implementation manner of the first aspect, the method further includes:
when the distributable code rate updating of the window is detected at any moment, determining whether to update the video layer of the window to the first video layer according to a preset judgment condition;
when the video layer of the window is determined to be updated to the first video layer, adding the window to a window set to be updated to the first video layer.
With reference to the first possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the acquiring a window to be updated to the first video layer further includes:
and traversing the window set to be updated to the first video layer to obtain each window to be updated to the first video layer.
With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the determining whether the window meets the first update condition by comparing the relevant information of the second video stream, the relevant information of the first video stream, and the relevant information of the window, which are forwarded to the window according to the current time, specifically is:
comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window, and judging whether the window meets the condition that a video layer is not updated;
when the window is determined not to accord with the video layer non-updating condition, comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to judge whether the window accords with the video layer updating condition;
when the window is determined to meet the video layer updating condition, determining that the window meets the first updating condition.
With reference to the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, the information related to the window further includes an allocable code rate of the window; the comparing the related information of the second video stream forwarded to the window according to the current moment, the related information of the first video stream and the related information of the window, and determining whether the window meets the video layer non-updating condition includes:
when the first video source end is not matched with the third video source end, determining that the window meets the condition that the video layer is not updated;
when the first video layer is larger than the third video layer, determining that the window meets the condition that the video layer is not updated;
when the first video stream is matched with the second video stream, determining that the window meets the condition that the video layer is not updated;
when the first video layer is larger than the second video layer and the first code rate is lower than the assignable code rate, determining that the window meets the condition that the video layer is not updated;
and when the first video source end is matched with the third video source end, the first video layer is smaller than or equal to the third video layer, the first video stream is not matched with the second video stream, and the first video layer is larger than the second video layer, and the first code rate is lower than the assignable code rate, determining that the window does not conform to the condition that the video layer is not updated.
With reference to the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, the information related to the window further includes a received video stream status of the window; the comparing the relevant information of the second video stream forwarded to the window according to the current moment, the relevant information of the first video stream and the relevant information of the window to judge whether the window meets the video layer updating condition includes:
when the first video layer is larger than the second video layer and the first video layer is matched with the third video layer, determining that the window meets the video layer updating condition;
when the first video layer is larger than the second video layer and the first video layer is not matched with the third video layer, judging whether the first video layer is larger than the third video layer;
when the first video layer is larger than the second video layer and the first video layer is larger than the third video layer, determining that the window meets a video layer updating condition;
when the first video layer is larger than the second video layer and the first video layer is judged to be smaller than or equal to the third video layer, judging whether the current moment of the window is in a state of receiving video streams;
when the current time of the window is in a state of not receiving the video stream, determining that the window meets the video layer updating condition;
when the current time of the window is in a state of receiving video stream, judging whether the second code rate is matched with the assignable code rate;
and when the first video layer is smaller than the second video layer and the second code rate is judged not to be matched with the assignable code rate, determining that the window meets the video layer updating condition.
In a seventh possible implementation manner of the first aspect, the method further includes the steps of:
and when the window is determined to meet the first updating condition and the first video layer is smaller than the second video layer, updating the video layer of the window to be the first video layer.
In a second aspect, the present invention provides a video layer updating apparatus, including:
the system comprises a window acquisition module, a video layer updating module and a video layer updating module, wherein the window acquisition module is used for acquiring a first video layer corresponding to a key frame when the key frame of a first video stream sent by any first video source end is received, and acquiring a window to be updated to the first video layer;
an update condition obtaining module, configured to compare, according to the current time, the relevant information of the second video stream forwarded to the window, the relevant information of the first video stream, and the relevant information of the window, and determine whether the window meets a first update condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window;
the judging module is used for judging whether the time period from the last time when the window finishes the video layer updating to the current time is greater than a preset time threshold value or not when the window is determined to accord with the first updating condition and the first video layer is greater than the second video layer;
and the updating module is used for updating the video layer of the window to be the first video layer when the first video layer is larger than the second video layer and the time period from the last time when the video layer updating of the window is completed to the current time is larger than a preset time threshold.
In a third aspect, an embodiment of the present invention further provides a video layer updating apparatus, which is characterized by including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the video layer updating method as described above is implemented.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, where when the computer program runs, the apparatus where the computer-readable storage medium is located is controlled to perform the video layer updating method as described above.
The embodiment of the invention has the following beneficial effects:
when a key frame of a first video stream sent by any first video source end is received, a first video layer corresponding to the key frame is obtained, and a window to be updated to the first video layer is obtained; comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to determine whether the window meets a first updating condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window; when the window is determined to meet the first updating condition and the first video layer is larger than the second video layer, judging whether the time period from the last time when the window completes updating the video layer to the current time is larger than a preset time threshold value; and when the first video layer is larger than the second video layer, if the time period from the last time when the window completes the updating of the video layer to the current time is larger than a preset time threshold, updating the video layer of the window to be the first video layer. The first update condition is determined by comprehensively considering the information about the second video stream forwarded to the window at the current time, the information about the first video stream, and the information about the window, and the first update condition ensures that the window has the ability to update the video layer and is necessary to update the video layer. And controlling the time period from the last time of finishing the video layer updating to the current time by a preset time threshold, wherein the time period from the last time of finishing the video layer updating to the current time by the window is controlled, and the video receiving end frequently requests a key frame from the video source end due to frequent change of the code rate allocated by the window in a short time, and the receiving end also frequently updates the window in a short time, so that the decoding decompression pressure is increased.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example one
Referring to fig. 1, a schematic diagram of a flow method for updating a video layer according to an embodiment of the present invention is provided;
s11, when a key frame of a first video stream sent by any first video source end is received, acquiring a first video layer corresponding to the key frame and acquiring a window to be updated to the first video layer;
s12, comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to determine whether the window meets a first updating condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window;
s13, when it is determined that the window meets the first updating condition and the first video layer is larger than the second video layer, judging whether the time period from the last time when the window completes the updating of the video layer to the current time is larger than a preset time threshold value;
and S14, when the first video layer is larger than the second video layer, if the time period from the last time when the window completes the video layer update to the current time is larger than a preset time threshold, updating the video layer of the window to be the first video layer.
In the embodiment of the invention, when a video window of a client displays a video, the video window is generally received from a key frame, whether the video layer of the window needs to be updated or not is judged after the key frame is received, when the video layer of the window needs to be updated, the video layer to be updated is obtained, and a server starts to forward a video stream from the key frame corresponding to the video layer to be updated.
In this embodiment of the present invention, the first video source corresponds to a video source corresponding to the currently received key frame, the second video source corresponds to a video source corresponding to a second video stream that is forwarded to the window by the server, the third video source is a video source subscribed by the window and is also a video source expected by the user, and the first video source, the second video source, and the third video source may be the same or different, which is not specifically limited in this invention.
In the embodiment of the present invention, the window is a video window subscribed to the server by the user through the client, and is used for displaying a video, referring to fig. 2, the window has three states including NotForwarding, Pending, Forwarding, when the window changes from the NotForwarding state to the Pending state, the server is searching for a corresponding video layer for the window, and at this time, the window is in a window set added to the corresponding video layer, and waits for a video stream of the corresponding video layer to be forwarded; when the window is changed from the Pending state to the Forwarding state, the server finds a corresponding video layer for the window, receives a key frame of the corresponding video layer, and forwards a video stream of the corresponding video layer; when the window is changed from the Forwarding state to the Notforwarding state, the server does not receive the data of the corresponding video layer sent by the video source end, and the window is changed from the original state of Forwarding the video stream to the state of not Forwarding the video stream; when the window changes from the Forwarding state to the Pending state, the server updates the window with a more suitable video layer, and the window is added to the window set for the more suitable video layer. The window can be in Forwarding state and Pending state at the same time, for example, the window is now Forwarding the video stream of 360P video layer, but the most suitable video layer is selected to be 720P, so the window is added into the window set of 720P video layer, which indicates that the window waits for the video stream of 720P video layer to be forwarded, but still forwards the video stream of 360P video layer, and after receiving the key frame of 720P video layer, if the update condition is satisfied, the window will start to forward the video stream of 720P video layer.
In the prior art, when the first video layer is larger than the second video layer, the window is directly switched upwards, and the video layer of the window is updated to a video layer with higher resolution. In the embodiment of the present invention, when it is determined that the window meets the first update condition and the first video layer is larger than the second video layer, it still needs to be determined whether a time period from a time when the window last completes updating the video layer to a current time is larger than a preset time threshold, and when the time period from the time when the window last completes updating the video layer to the current time is larger than the preset time threshold, the video layer of the window is updated to the first video layer, so as to implement upward switching. The preset time threshold may be set according to actual conditions, and is set to avoid frequent upward switching of the window in a short time.
Specifically, at time T1, the window meets the first update condition, and when the first video layer is greater than the second video layer, whether a time period T from time T0 when the window last completes updating the video layer to current time T1 is greater than a preset time threshold T, if it is detected that T is less than T, the window does not update the video layer, and if it is detected that T is greater than T, the video layer of the window is updated to be the first video layer, so that upward switching of the video layers is realized.
Further, the method further comprises the steps of:
and when the window is determined to meet the first updating condition and the first video layer is smaller than the second video layer, updating the video layer of the window to be the first video layer.
In the embodiment of the present invention, when it is determined that the window meets the first update condition and the first video layer is smaller than the second video layer, the window is switched downward, that is, the video layer of the window is updated to the video layer with the lower resolution. When the window is switched downwards, the video layer can be directly updated when the window meets the first updating condition.
The embodiment of the invention has the following beneficial effects:
when a key frame of a first video stream sent by any first video source end is received, a first video layer corresponding to the key frame is obtained, and a window to be updated to the first video layer is obtained; comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to determine whether the window meets a first updating condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window; when the window is determined to meet the first updating condition and the first video layer is larger than the second video layer, judging whether the time period from the last time when the window completes updating the video layer to the current time is larger than a preset time threshold value; and when the first video layer is larger than the second video layer, if the time period from the last time when the window completes the updating of the video layer to the current time is larger than a preset time threshold, updating the video layer of the window to be the first video layer. The updating condition is determined by comprehensively considering the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window, and the updating condition is ensured to be capable of updating the video layer and necessary to update the video layer. And controlling the time period from the last time of finishing the video layer updating to the current time by a preset time threshold, wherein the time period from the last time of finishing the video layer updating to the current time by the window is controlled, and the video receiving end frequently requests a key frame from the video source end due to frequent change of the code rate allocated by the window in a short time, and the receiving end also frequently updates the window in a short time, so that the decoding decompression pressure is increased.
Example two
On the basis of the first embodiment, the video layer updating method further includes:
responding to a subscription instruction of a corresponding window sent by any client, and acquiring subscription information corresponding to the subscription instruction;
adding a window of the client subscription to a set of windows to be updated to the first video layer when the subscription information includes a request for the first video stream.
Preferably, the acquiring the window to be updated to the first video layer further comprises:
and traversing the window set to be updated to the first video layer to obtain each window to be updated to the first video layer.
In the embodiment of the invention, a server responds to a subscription instruction of a corresponding window sent by any client to acquire subscription information corresponding to the subscription instruction; when the subscription information includes a request about the first video stream and the first video source, adding a window subscribed by the client to a window set to be updated to the first video layer, so that when a key frame of the first video stream sent by any first video source is received, a window to be updated to the first video layer is obtained from the window set to be updated to the first video layer, and then the window to be updated to the first video layer is the window subscribed by the client.
In the embodiment of the present invention, it is assumed that the server selects a 360P video stream of the first video source S1 for a subscribed window, and then it needs to determine whether to subscribe the 360P video stream to the first video source S1 or directly request a key frame of the 360P, where the operation process is as follows: after selecting the 360P video stream of the first video source S1 for the window, judging whether the 360P video stream of the first video source S1 has been forwarded to the subscription window, if so, indicating that the window has received the key frame, and ending; if not, the server determines whether the 360P video stream of the first video source S1 has been received, and if the 360P video stream of the first video source S1 has been received, requests a key frame of 360P from the first video source S1, and then ends. If the video stream of 360P of the first video source S1 is not received, the video stream of 360P is subscribed to the first video source S1.
Specifically, assuming that the client R1 subscribes to the server for the 720P video stream of the first video source S1, and the subscribed window is W1, the server adds the window W1 to the window set to be updated to the first video layer 720P, and at time t0, the server receives the subscription request of the client R1, and since the 720P video stream of the first video source S1 is not forwarded to the window W1, and the server does not receive the 720P video stream of the first video source S1, the server subscribes to the 720P video stream from the first video source S1; at time t1, when the server receives a key frame of a first video stream sent by any first video source, it is detected that the first video source corresponding to the key frame is the subscribed first video source S1, and the first video layer corresponding to the key frame is the subscribed 720P video layer, the window set to be updated to the first video layer 720P is traversed, a window W1 to be updated to the first video layer is obtained, and it is determined that the window W1 satisfies the first update condition and the preset time threshold, so that the window W1 is updated, and the server starts to forward the video stream corresponding to the 720P video layer of the first video source S1 to the window W1.
The embodiment of the invention has the following beneficial effects:
responding to a subscription instruction of a corresponding window sent by any client, and acquiring subscription information corresponding to the subscription instruction; when the subscription information includes a request about the first video stream, adding the window subscribed by the client to the window set to be updated to the first video layer, and acquiring the window needing to update the video layer from the window set of the first video layer.
EXAMPLE III
On the basis of the first embodiment, the video layer updating method further includes:
when the distributable code rate updating of the window is detected at any moment, determining whether to update the video layer of the window to the first video layer according to a preset judgment condition;
when the video layer of the window is determined to be updated to the first video layer, adding the window to a window set to be updated to the first video layer.
Preferably, the acquiring the window to be updated to the first video layer further comprises:
and traversing the window set to be updated to the first video layer to obtain each window to be updated to the first video layer.
In the embodiment of the present invention, each time the window assignable code rate is updated, the code rate of the video stream being received by the window may be greater than the window assignable code rate, so that the window bandwidth is insufficient and the reception fails. Therefore, when the code rate of window allocation is updated, the most suitable video layer needs to be searched again. And the most suitable source needs to satisfy the following condition: receiving a code rate corresponding to a video layer of a key frame, namely a code rate corresponding to the third video layer subscribed by the window; and selecting the video layer with the maximum code rate on the basis of meeting the two conditions.
Specifically, based on the example of the second embodiment, at the time t2, the assignable bitrate of the window W1 is reduced to 650k, and the window W1 needs to be searched for the most suitable video layer again because the assignable bitrate of the window is updated. Since the bitrate of the 720P video layer at the time t1 is 700k, which is greater than the bitrate 650k assignable by the window W1, the 720P video layer is no longer the most suitable video layer, and then the video layer with higher quality is selected from the two video layers 180P and 360P as the most suitable video layer, preferably the video layer with higher quality, the video layer 360P is selected, and the video stream of the video layer 360P is subscribed to the first video source terminal S1. At time t3, the server receives the key frame of the 360P video layer of the first video source S1, and then determines that the window W1 satisfies the first update condition and the preset time threshold, so that the window W1 performs video layer update, and starts to forward the video stream of the 360P video layer of the first video source S1 to the window W1. At time t4, the allocable bitrate of the window W1 increases to 750k, and since the allocable bitrate of the window W1 changes, the window W1 needs to be searched for the most suitable video layer again. Since the bitrate of the 720P video layer is 700k, which is smaller than the bitrate 750k that the window W1 can allocate, the 720P video layer is the most suitable video layer. And subscribing 720P video layer video stream to the first video source terminal S1. At time t5, when the server receives the key frame of the 720P video layer of the first video source S1, it determines that the window W1 satisfies the first update condition and the preset time threshold, so that the window W1 performs video layer update and starts to forward the video stream of the 720P video layer of the first video source S1 to the window W1.
The embodiment of the invention has the following beneficial effects:
when the distributable code rate updating of the window is detected at any moment, determining whether to update the video layer of the window to the first video layer according to a preset judgment condition; when the video layer of the window is determined to be updated to the first video layer, the window is added to a window set to be updated to the first video layer, and whether the code rate of the updated window can support the window to perform video layer updating is judged by detecting the assignable code rate updating of the window, so that failure in receiving video streams due to insufficient bandwidth of the window and assignable code rate updating of the window is avoided.
Example four
On the basis of the first embodiment, the second embodiment and the third embodiment,
the step of comparing the related information of the second video stream forwarded to the window according to the current time, the related information of the first video stream, and the related information of the window to determine whether the window meets a first update condition specifically includes:
comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window, and judging whether the window meets the condition that a video layer is not updated;
when the window is determined not to accord with the video layer non-updating condition, comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to judge whether the window accords with the video layer updating condition;
when the window is determined to meet the video layer updating condition, determining that the window meets the first updating condition.
In the embodiment of the present invention, by comparing the related information of the second video stream forwarded to the window at the current time, the related information of the first video stream, and the related information of the window, it is determined whether the window meets the video layer non-updating condition, and only if the window does not meet the non-updating condition, it is determined that the window is capable of performing video layer updating, that is, the window can receive the video stream occupying a larger bandwidth.
In the embodiment of the present invention, when it is determined that the window does not meet the video layer non-update condition, whether the window meets the video layer update condition is determined by comparing the related information of the second video stream, the related information of the first video stream, and the related information of the window forwarded to the window at the current time, and if the video layer update condition is met, it is determined that the window needs to perform video layer update.
Preferably, the related information of the window further includes an allocable code rate of the window; the comparing the related information of the second video stream forwarded to the window according to the current moment, the related information of the first video stream and the related information of the window, and determining whether the window meets the video layer non-updating condition includes:
when the first video source end is not matched with the third video source end, determining that the window meets the condition that the video layer is not updated;
in the embodiment of the present invention, the update condition is considered only when the non-update condition is not met, so that the first video source end and the third video source end are required to be matched to ensure that the video source ends are unchanged, and the video layer is updated.
When the first video layer is larger than the third video layer, determining that the window meets the condition that the video layer is not updated;
in this embodiment of the present invention, the first video layer is greater than the third video layer, that is, the video layer corresponding to the currently received key frame is greater than the video layer subscribed to by the window, the video layer subscribed to by the window is the video layer with the highest quality that can be received by the window, and when the first video layer is greater than the third video layer, the window has no capability to be updated to the first video layer.
When the first video stream is matched with the second video stream, determining that the window meets the condition that the video layer is not updated;
in the embodiment of the present invention, the first video stream is matched with the second video stream, that is, it indicates that the currently received key frame corresponds to the video stream that the window is forwarding, so that no update is required.
When the first video layer is larger than the second video layer and the first code rate is lower than the assignable code rate, determining that the window meets the condition that the video layer is not updated;
in the embodiment of the present invention, when the first code rate is lower than the assignable code rate, the downlink bandwidth of the window is insufficient, so that the video layer of the window is not updated.
And when the first video source end is matched with the third video source end, the first video layer is smaller than or equal to the third video layer, the first video stream is not matched with the second video stream, and the first video layer is larger than the second video layer, and the first code rate is lower than the assignable code rate, determining that the window does not conform to the condition that the video layer is not updated.
Preferably, the related information of the window further includes a received video stream status of the window; the comparing the relevant information of the second video stream forwarded to the window according to the current moment, the relevant information of the first video stream and the relevant information of the window to judge whether the window meets the video layer updating condition includes:
when the first video layer is larger than the second video layer and the first video layer is matched with the third video layer, determining that the window meets the video layer updating condition;
in this embodiment of the present invention, when the first video layer is larger than the second video layer, and the first video layer is matched with the third video layer, that is, the video layer corresponding to the currently received key frame is the video layer to which the window subscribes, so that the window is updated according to the video layer, and the window is switched upwards.
When the first video layer is larger than the second video layer and the first video layer is not matched with the third video layer, judging whether the first video layer is larger than the third video layer;
when the first video layer is larger than the second video layer and the first video layer is larger than the third video layer, determining that the window meets a video layer updating condition;
when the first video layer is larger than the second video layer and the first video layer is judged to be smaller than or equal to the third video layer, judging whether the current moment of the window is in a state of receiving video streams;
when the current time of the window is in a state of not receiving the video stream, determining that the window meets the video layer updating condition;
when the current time of the window is in a state of receiving video stream, judging whether the second code rate is matched with the assignable code rate;
in the embodiment of the present invention, the window is in a state of not receiving the video stream at the current time, and if a key frame is received and the video stream of the key frame does not satisfy the condition of not updating, the update is performed.
And when the first video layer is smaller than the second video layer and the second code rate is judged not to be matched with the assignable code rate, determining that the window meets the video layer updating condition.
The embodiment of the invention has the following beneficial effects:
the first update condition is determined by comprehensively considering the information about the second video stream forwarded to the window at the current time, the information about the first video stream, and the information about the window, and the first update condition ensures that the window has the ability to update the video layer and is necessary to update the video layer.
EXAMPLE five
Referring to fig. 3, a schematic structural diagram of a video layer update apparatus according to a fifth embodiment of the present invention is provided.
A video layer update apparatus comprising:
awindow obtaining module 21, configured to, when a key frame of a first video stream sent by any one of the first video source terminals is received, obtain a first video layer corresponding to the key frame, and obtain a window to be updated to the first video layer;
an updatecondition obtaining module 22, configured to compare, according to the relevant information of the second video stream forwarded to the window at the current time, the relevant information of the first video stream and the relevant information of the window, determine whether the window meets a first update condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window;
the judgingmodule 23 is configured to, when it is determined that the window meets the first update condition and the first video layer is greater than the second video layer, judge whether a time period from a time when the window completes the video layer update to a current time is greater than a preset time threshold;
and an updatingmodule 24, configured to update the video layer of the window to the first video layer when the first video layer is larger than the second video layer and a time period from a time when the window completes updating the video layer last to a current time is larger than a preset time threshold.
Preferably, the method further comprises the following steps:
responding to a subscription instruction of a corresponding window sent by any client, and acquiring subscription information corresponding to the subscription instruction;
adding a window of the client subscription to a set of windows to be updated to the first video layer when the subscription information includes a request for the first video stream.
Preferably, the method further comprises the following steps:
when the distributable code rate updating of the window is detected at any moment, determining whether to update the video layer of the window to the first video layer according to a preset judgment condition;
when the video layer of the window is determined to be updated to the first video layer, adding the window to a window set to be updated to the first video layer.
Preferably, thewindow obtaining module 21 further includes:
and traversing the window set to be updated to the first video layer to obtain each window to be updated to the first video layer.
Preferably, the updatecondition obtaining module 22 includes:
the non-updating unit is used for comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window and judging whether the window meets the non-updating condition of the video layer or not;
the updating unit is used for comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window when the window is determined not to accord with the video layer non-updating condition, and judging whether the window accords with the video layer updating condition or not;
and the determining unit is used for determining that the window meets the first updating condition when the window is determined to meet the video layer updating condition.
Preferably, the non-updating unit includes:
when the first video source end is not matched with the third video source end, determining that the window meets the condition that the video layer is not updated;
when the first video layer is larger than the third video layer, determining that the window meets the condition that the video layer is not updated;
when the first video stream is matched with the second video stream, determining that the window meets the condition that the video layer is not updated;
when the first video layer is larger than the second video layer and the first code rate is lower than the assignable code rate, determining that the window meets the condition that the video layer is not updated;
and when the first video source end is matched with the third video source end, the first video layer is smaller than or equal to the third video layer, the first video stream is not matched with the second video stream, and the first video layer is larger than the second video layer, and the first code rate is lower than the assignable code rate, determining that the window does not conform to the condition that the video layer is not updated.
Preferably, the updating unit includes:
when the first video layer is larger than the second video layer and the first video layer is matched with the third video layer, determining that the window meets the video layer updating condition;
when the first video layer is larger than the second video layer and the first video layer is not matched with the third video layer, judging whether the first video layer is larger than the third video layer;
when the first video layer is larger than the second video layer and the first video layer is larger than the third video layer, determining that the window meets a video layer updating condition;
when the first video layer is larger than the second video layer and the first video layer is judged to be smaller than or equal to the third video layer, judging whether the current moment of the window is in a state of receiving video streams;
when the current time of the window is in a state of not receiving the video stream, determining that the window meets the video layer updating condition;
when the current time of the window is in a state of receiving video stream, judging whether the second code rate is matched with the assignable code rate;
and when the first video layer is smaller than the second video layer and the second code rate is judged not to be matched with the assignable code rate, determining that the window meets the video layer updating condition.
Preferably, the method further comprises the steps of:
and when the window is determined to meet the first updating condition and the first video layer is smaller than the second video layer, updating the video layer of the window to be the first video layer.
The embodiment has the following beneficial effects:
when a key frame of a first video stream sent by any first video source end is received, a first video layer corresponding to the key frame is obtained, and a window to be updated to the first video layer is obtained; comparing the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window to determine whether the window meets a first updating condition; the related information of the second video stream comprises a second video source end, a second video layer and a second code rate corresponding to the second video stream; the related information of the first video stream comprises the first video source end, a first code rate and a first video layer corresponding to the first video stream; the related information of the window comprises a third video source end and a third video layer subscribed by the window; when the window is determined to meet the first updating condition and the first video layer is larger than the second video layer, judging whether the time period from the last time when the window completes updating the video layer to the current time is larger than a preset time threshold value; and when the first video layer is larger than the second video layer, if the time period from the last time when the window completes the updating of the video layer to the current time is larger than a preset time threshold, updating the video layer of the window to be the first video layer. The updating condition is determined by comprehensively considering the related information of the second video stream forwarded to the window at the current moment, the related information of the first video stream and the related information of the window, and the updating condition is ensured to be capable of updating the video layer and necessary to update the video layer. And controlling the time period from the last time of finishing the video layer updating to the current time by a preset time threshold, wherein the time period from the last time of finishing the video layer updating to the current time by the window is controlled, and the video receiving end frequently requests a key frame from the video source end due to frequent change of the code rate allocated by the window in a short time, and the receiving end also frequently updates the window in a short time, so that the decoding decompression pressure is increased.
EXAMPLE six
Referring to fig. 4, fig. 4 is a schematic diagram of a video layer updating apparatus according to a sixth embodiment of the present invention, configured to execute the video layer updating method according to the sixth embodiment of the present invention, as shown in fig. 4, the video layer updating apparatus includes: at least one processor 11, such as a CPU, at least onenetwork interface 14 orother user interface 13, amemory 15, at least onecommunication bus 12, thecommunication bus 12 being used to enable connectivity communications between these components. Theuser interface 13 may optionally include a USB interface, and other standard interfaces, wired interfaces. Thenetwork interface 14 may optionally include a Wi-Fi interface as well as other wireless interfaces. Thememory 15 may comprise a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Thememory 15 may optionally comprise at least one memory device located remotely from the aforementioned processor 11.
In some embodiments,memory 15 stores the following elements, executable modules or data structures, or a subset thereof, or an expanded set thereof:
anoperating system 151, which contains various system programs for implementing various basic services and for processing hardware-based tasks;
and (5) aprocedure 152.
Specifically, the processor 11 is configured to call theprogram 152 stored in thememory 15 to execute the video layer update method according to the above embodiment.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, said processor being the control center of said video layer update method, various interfaces and lines connecting the various parts of the whole said video layer update method.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the electronic device for video layer update by executing or executing the computer programs and/or modules stored in the memory and calling up the data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, a text conversion function, etc.), and the like; the storage data area may store data (such as audio data, text message data, etc.) created according to the use of the cellular phone, etc. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Wherein the video layer update integrated module, if implemented in the form of a software functional unit and sold or used as a stand-alone product, can be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.
It should be noted that, in the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and in a part that is not described in detail in a certain embodiment, reference may be made to the related descriptions of other embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are preferred and that acts and simulations are necessarily required in accordance with the invention.