The present disclosure generally relates to the field of Internet technology and, more particularly, to alive streaming method, and an apparatus and system thereof.
Streaming media refers to a media format for online playback in a streaming transmission way. Streaming media characterized by simultaneously transmitting and playback allows more real-time and convenient content playback, which has been widely used.
The current streaming media technology is divided into live streaming and on-demand streaming. For the existing live streaming, the complex environment of the Internet may cause many errors in the live streaming transmission, for example, may cause frames to be dropped/lost in live streams, which makes the latency of the source for live streaming getting lower and lower. In the existing technologies, the playback terminal cannot perceive that there are dropped frames in live streams, which causes the playback cache to become smaller and smaller, and the play position to become more and more front. As such, the playback is frequently stopped on the playback terminal, and the user experience is poor.
In order to solve the problem of existing technologies, one aspect of the present disclosure provides a live streaming method. The method is as followings:
initializing a delay window; according to the delay window, requesting a resource slice within a range of the delay window; determining whether a result of a first request for the resource slice within the range of the delay window is successful; and accumulating a number of consecutive failures of the first request for the resource slice within the delay window and, when the number of consecutive failures reaches a preset threshold, sliding the delay window to limit a requesting speed of the playback terminal.
Furthermore, the determining whether the first request for the resource slice within the delay window is successful includes: configuring a counter for accumulating the number of consecutive failures of the first request; obtaining a response status code of the first request for the resource slice within the delay window; and based on the response status code of the first request for the resource slice, identifying whether the request for the resource slice is successful.
Furthermore, the accumulating a number of consecutive failures of the first request for the resource slice within the delay window and, when the number of consecutive failures reach a preset threshold, sliding the delay window to limit a requesting speed of the playback terminal includes: based on the response status code of the first request for the resource slice, identifying whether the first request for the resource slice is successful; when the response status code indicates that the first request is failed, incrementing a value of the counter by one; continuously requesting the resource slice within the range of the delay window to accumulate the number of consecutive failures of the first request for the resource slice within the delay window; when the value of the counter reaches the preset threshold, sliding backward the delay window to limit the requesting speed of the playback terminal; and when the response status code indicates that the first request is successful, setting the value of the counter to zero.
Furthermore, the sliding the delay window to limit the requesting speed of the playback terminal includes: sliding the delay window backward by one unit-of-time; and setting the value of the counter to zero.
Furthermore, before initializing the delay window, the method further includes: slicing a streaming media by a server according to a time interval of one unit-of-time into resource slices; and numbering the resource slices, wherein the resource slices are slices of the streaming media.
Furthermore, the slicing a target streaming media resource and numbering the resource slices further includes: numbering the resource slices according to respective timestamps of the resource slices.
Furthermore, the initializing the delay window includes: obtaining a delay parameter; setting a size of the delay window according to the delay parameter; according to the size of the delay window, obtaining a starting number and a latest number of the target streaming media resource from a server terminal; and periodically maintaining the delay window.
Another aspect of the present disclosure provides a live streaming system. The system includes: a resource request unit is configured to request a resource slice within the delay window according to an initialized delay window; a determination unit is configured to determine whether a result of a first request for a resource slice within the range of the delay window is successful; and a failure number accumulation unit is configured to accumulate a number of consecutive failures of the first request for the resource slice within the delay window and, when the number of failures reaches a preset threshold, to slide the delay window to limit a requesting speed of the playback terminal.
Furthermore, the determination further includes: a counter configured to accumulate the number of consecutive failures of the first request; a status code acquisition module configured to obtain a response status code of the first request for the resource slice of the delay window; and a status code identification and process module configured to, based on the response status code of the first request for the resource slice, identify whether the request for the resource slices is successful, wherein, when the response status code indicates that the request is failed, the value of the counter is incremented by one; continuously requesting the resource slice within the range of the delay window to accumulate the number of consecutive failures of the first request for the resource slice within the delay window; when the value of the counter reaches the preset threshold, sliding backward the delay window to limit the requesting speed of the playback terminal; and when the response status code indicates that the first request is successful, setting the value of the counter to zero.
Furthermore, the live streaming system further includes a delay process unit, the delay process unit configured to, when the value of the counter reaches the preset threshold, slide backward the delay window by one unit-of-time and set the value of the counter to zero.
Furthermore, the live streaming system further includes a slicing unit, the slicing unit being arranged at the server terminal, and configured to slice a streaming media resource according to a time interval of one unit-of-time into resource slices.
Furthermore, the live streaming system further includes a slice numbering unit, the slice numbering unit being arranged at the server terminal, configured to number resource slices according to respective timestamps of the resource slices.
Furthermore, the live streaming system further includes a delay window initialization unit, the delay window initialization unit configured to initialize the delay window; obtain a delay parameter; set a size of the delay window according to the delay parameter; according to the size of the delay window, obtain a starting number and a latest number of the target streaming media resource from the server terminal; and periodically maintain the delay window.
Another aspect of the present disclosure provides a live streaming apparatus, including a resource request unit, a determination unit, and a failure number accumulation unit, wherein, the resource request unit is configured to, according to an initialized delay window, request a resource slice within the delay window; the determination unit is configured to determine whether a result of a first request for the resource slice within the range of the delay window is successful; and the failure number accumulation unit is configured to accumulate a number of consecutive failures of the first request for the resource slice within the delay window and, when the number of consecutive failures reaches a preset threshold, slide the delay window to limit a requesting speed of the playback terminal.
Therefore, the technical solution provided by the present disclosure is as followings. After initializing a delay window, through detecting a response status code of resource slice within the range of the delay window, the response status code is identified, and a number of consecutive failures of the first request for the resource slice within the delay window is accumulated. When the number of consecutive failures reaches a preset threshold, a system identifies a downloading delay of the resource. Thus, the delay window is slid to limit a requesting speed of the playback terminal. As such, the situation that a playback terminal frequently sends request to a server without a successful response, which causes the playback to frequently stop on the playback terminal, can be avoid. The user experience is enhanced.
In order to provide a clear illustration of technical schemes according to various disclosed embodiments, the drawings used in the description of the disclosed embodiments are briefly described below. Obviously, the following drawings are merely some of embodiments of the disclosure. Other drawings may be obtained based on the disclosed drawings by those skilled in the art without creative efforts.
In order to provide a more clear understanding of the objectives, technical aspects, and advantages of the embodiments of the present disclosure, embodiments of the present disclosure are described in detail in connection with the drawings.
The present disclosure provides a method for live streaming as shown in
S101, downloading a target streaming media resource by push streaming or pull streaming by the server terminal.
S103, slicing the target streaming media resource by the server terminal according to a rule to make the streaming media resource exist in the form of resource slices.
Specifically, for example, the slicing may be performed at a time interval of one unit-of-time. The time interval of the unit-of-time refers to a time interval between timestamps of the streaming media resource slices.
S105, numbering each resource slice by the server terminal.
Specifically, an objective of numbering the resource slices is to distinguish and identify the resource slices with different timestamps. Thus, when a system reads a numbered resource slice, in order to identify the timestamp corresponding to the numbered resource slice, the resource slices may be numbered according to the respective timestamps of the resource slices. For example, the number may start from 0 or an initial value, and then increment at the time interval of the unit-of-time as a next resource slice number. As such, the number of the resource slice is just the timestamp of the resource slice. Furthermore, the resource slices may be numbered using a natural number. In order to associate the number of the resource slice with the timestamp of the corresponding resource slice, a mapping table or a mathematical relationship between the number of the resource slice and the timestamp of the corresponding resource slice can be established. The timestamp of the resource slice corresponding to the number of the resource slice can be read by conversion or looking up the mapping table.
S201, initializing a delay window;
Specifically, a player being arranged at a playback terminal may obtain a delay parameter, and sets the size of the delay window according to the delay parameter.
S202, according to the delay window, obtaining from the server a starting number and a latest number within the range of the delay window as defined in S201.
Specifically, when the playback terminal starts, the delay window is initialized according to the delay parameter. That is, the playback terminal obtains the starting number and the latest number of the streaming media resource from the server terminal. Herein, the starting number is the number of the slice in a play starting position of the streaming media resource. The latest number is the number of the resource slice counted from the starting position, for spacing the resource slices of the delay parameter.
S203, periodically maintaining the delay window requested by a same streaming media in the playback terminal.
Specifically, the delay window is used to constrain the range of resource slices that can be obtained from the server terminal by the playback terminal. Thus, as the playback terminal plays the resource slices that have been requested in a chronological order, the playback terminal needs to continually request for the resource slices that have not been played in the delay window, which causes the system to push the delay window to slide forward. That is, the starting number and the latest number are increased synchronously, so that the playback terminal can continuously obtain from the delay window the number of resource that have not been requested. Preferably, the system can set a timer to regularly start increasing the starting number and the latest number simultaneously by a unit-of-time within the range of the delay window.
S204, according to the delay window, requesting the resource slice within the delay window.
Specifically, according to the starting number and the latest number defined by the delay window, the playback terminal may exclude a record of a resource slice that has been successfully requested, and may obtain the number of the next resource slice that has not been successfully requested. The playback terminal may then request the server terminal for the resource slice according to the number of the resource slice that has not been successfully requested.
As shown in
Specifically, determining by the playback terminal whether the result of the first request for the resource slice within the range of the delay window is successful includes the following steps.
S2051, configuring a counter for accumulating the number of consecutive failures of the request on the playback terminal.
S2053, obtaining a response status code of the first request for the resource slice within the delay window.
S2055, based on the response status code of the first request for the resource slice, identifying whether the request for the resource slice is successful.
Specifically, when the response status code of the first request for the resource slice is 200, the first request for the resource slice is considered successful. When the response status code of the first request for the resource slice is 404, the first request for the resource slice is considered to fail. Of course, in addition to the status code 404, there may be other response status codes indicate that the request is failed. For example, when a content attribute of the requested resource cannot satisfy a condition in a request header, consequently the response status code 406 in response to a response entity cannot be generated; or when the server rejects to process a current request, the response status code is 413, and the like.
As shown in
Specifically, accumulating the number of consecutive failures of the first request for the resource slice within the delay window includes the following steps.
S2061, when the response status code indicates that the request is failed, incrementing the value of the counter by one. Specifically, according to the response status code of the first request for the resource slice as described in S2055, identifying whether the request for the resource slice is successful, when the response status code indicates that the request is failed, the value of the counter configured in S2051 is incremented by one.
S2063, the playback terminal continuously requests the resource slice within the range of the delay window to accumulate the number of consecutive failures of the first request for the resource slice within the delay window and, when the value of the counter reaches a preset threshold, sliding backward the delay window to limit the requesting speed from the playback terminal.
Specifically, S2063 includes the following steps.
Step 1, the playback terminal continuously requests the resource slice within the range of the delay window, where the resource slice may be the resource slice for which the first request is failed or the resource slice which has not been requested.
Step 2, when the response status code of the first request for a next resource slice that has not been requested still indicates that the request is failed, incrementing the value of the counter configured in S2051 by one.
Step 3, determining whether the value of the counter configured in S2051 reaches the preset threshold, where the preset threshold is the value of dropped frames which can be tolerated according to a previous playback experience. When the value of the counter configured in S2051 reaches the preset threshold, the playback terminal may consider that a delay phenomenon occurs in the playing environment at this time. That is, the server terminal cannot timely respond to the request from the playback terminal. When the value of the counter configured in S2051 does not reach the preset threshold, steps 1 to 3 are cyclically performed.
S2065, when the response status code indicates that the request is successful, setting the value of the counter configured in S2051 to zero.
S207, sliding the delay window to limit the requesting speed of the playback terminal includes the following steps.
Firstly, sliding the delay window backward by one unit-of-time.
Specifically, at each time when the playback terminal recognizes that the playing environment has the delay phenomenon, the starting number and the latest number in a current delay window are decreased by the unit-of-time at the same time.
Then, setting the value of the counter configured in S2051 to zero.
S208, the playback terminal waits for results from the periodically maintenance and adjustment of the delay window, and continuously requests the server terminal for the resource slice according to the delay window.
The present disclosure also provides a live streaming system as shown in
The live streaming system includes a playback terminal and a server terminal. The living streaming system also includes the following units.
A slicing unit 301 is arranged at the server terminal to slice a streaming media resource according to a time interval of one unit-of-time.
A slice numbering unit 302 is arranged at the server terminal to number resource slices according to timestamps of the resource slices.
Specifically, slice numbering unit 302 numbers the resource slices according to the timestamps of the resource slices. For example, the number may start from 0 or an initial value, and then increment at the time interval of the unit-of-time as a next resource slice number.
As such, the number of the resource slice is just the timestamp of the resource slice. Furthermore, the resource slices may be numbered using a natural number. In order to associate the number of the resource slice with the timestamp of the corresponding resource slice, a mapping table or a mathematical relationship between the number of the resource slice and the timestamp of the corresponding resource slice can be established. The timestamp of the resource slice corresponding to the number of the resource slice can be read by conversion or looking up the mapping table.
A delay window initialization unit 303 is arranged at the playback terminal. The delay window initialization unit 303 obtains a delay parameter according to requirements of the playback business to set the size of the delay window according to the delay parameter. When the playback terminal starts, the delay window is initialized according to the delay parameter. That is, the playback terminal obtains the starting number and the latest number of the streaming media resource from the server terminal. Herein, the starting number is the number of the slice in a play starting position of the streaming media resource. The latest number is the number of the resource slice counted from the starting position for spacing the resource slices of the delay parameter.
A delay window maintenance unit 304 is configured to periodically maintain the delay window requested by a same streaming media in the playback terminal, which thereby causes the system to push the delay window to slide forward. That is, the starting number and the latest number are increased synchronously, so that the playback terminal can continuously obtain from the delay window the number of resource that have not been requested. Preferably, the system can set a timer to regularly start increasing the starting number and the latest number simultaneously by a unit-of-time within the range of the delay window.
A resource request unit 305 is configured to, according to the initialized delay window, request the server terminal for the resource slices within the delay window.
Specifically, according to the starting number and the latest number defined by the delay window, the playback terminal may exclude a record of a resource slice that has been successfully requested, and may obtain the number of the next resource slice that has not been successfully requested. The playback terminal may then request the server terminal for the resource slice according to the number of the resource slice that has not been successfully requested.
A determination unit 306 is configured to determine whether a result of a first request for a resource slice within the range of the delay window is successful.
The determination unit 306 further includes a counter configured to accumulate a number of consecutive failures of the first request; a status code acquisition module configured to obtain a response status code of the first request for the resource slice of the delay window; and a status code identification and process module configured to, based on the response status code of the first request for the resource slice, identify whether the request for the resource slice is successful.
A failure number accumulation unit 307 is configured to accumulate a number of consecutive failures of the first request for the resource slices within the delay window.
Specifically, when the response status code indicates that the request is failed, the value of the counter is incremented by one, and continuously requests the resource slice within the range of the delay window to accumulate the number of consecutive failures of the first request for the resource slice in the delay window.
Furthermore, when the response status code indicates that the request is successful, the value of the counter configured in S2051 is set to zero.
A delay process unit 308 is configured, when the value of the counter reaches a preset threshold, to slide backward the delay window with one unit-of-time and to set the counter to zero.
Specifically, at each time when the playback terminal recognizes that the playing environment has the delay phenomenon, the starting number and the latest number in a current delay window are decreased by the unit-of-time at the same time.
As shown in
The sequence numbers of the disclosed embodiments are merely for the sake of description, and do not represent the advantages and disadvantaged of the embodiments.
Therefore, the technical solution provided by the present disclosure is as followings. After initializing a delay window, through detecting a response status code of resource slice within the range of the delay window, the response status code is identified, and a number of consecutive failures of the first request for the resource slice within the delay window is accumulated. When the number of consecutive failures reaches a preset threshold, a system identifies a downloading delay of the resource. Thus, the delay window is slid backward to limit a requesting speed. As such, the situation that a playback terminal frequently sends request to a server without a successful response, which causes the playback to frequently stop on the playback terminal, can be avoid. Furthermore, the system periodically maintains the delay window to slide forward, which ensures an update speed of the numbering request from the playback terminal. Thus, it can avoid that the playback is frequently stopped on the playback terminal, and the user experience is enhanced.
Each of the embodiments described in the specification is illustrated in a progressive manner, and the same or similar parts between various embodiments can be referenced with each other. Each embodiment is focused on the differences from other embodiments. In particular, for the embodiments of the apparatus, reference can be made to the explanation of the embodiments of the method described above.
The present invention may be described in the general context of computer-executable instructions executed by a computer, for example, program modules. Generally, the program modules include routines, programs, objects, components, and data structures that perform particular tasks or implement particular abstract data types. Aspects of the invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, the program modules may be located in both local and remote computer storage media including memory storage devices.
The foregoing embodiments of the apparatus are merely illustrative, and the units described as separate components may or may not be physically separate, while the components illustrated as units may or may not be physical units, that is, they can be co-located or can be distributed onto a plurality of network elements. A part or all of the modules therein can be selected as required in practice to achieve the objective of the solution of the embodiments. Those ordinarily skilled in the art can appreciate and implement the solution of the embodiments without any inventive effort.
Through the description of the aforementioned embodiments, person in the art may clearly understand that the present disclosure may be realized in the form of software plus the necessary common hardware platform. Based on this understanding, the aforementioned technical solution, in essence, or in the form of a contribution to the prior art, or part of thereof, can be embodied in the form of a software product. The computer software product may be stored on a computer-readable media, such as a ROM/RAM, a magnetic disk, or an optical disk, and the like. The computer software product may include a certain number of computer-executable instructions that make a computer device (such as a personal computer, a server, or a network equipment) to execute the methods described in each embodiment, or certain portions of the embodiments, of the present disclosure.
The embodiments disclosed herein are preferred embodiments and are not intended to limit the present invention. Any alternations, equivalents, modifications, or advantages to the disclosed embodiments within the spirit and principles of the present disclosure are intended to be encompassed within the scope of the present invention.
Number | Date | Country | Kind |
---|---|---|---|
2017104694621 | Jun 2017 | CN | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/CN2017/092834 | 7/13/2017 | WO | 00 |