CN111193686B - Media stream delivery method and server - Google Patents
Media stream delivery method and server Download PDFInfo
- Publication number
- CN111193686B CN111193686B CN201811353208.6A CN201811353208A CN111193686B CN 111193686 B CN111193686 B CN 111193686B CN 201811353208 A CN201811353208 A CN 201811353208A CN 111193686 B CN111193686 B CN 111193686B
- Authority
- CN
- China
- Prior art keywords
- media
- stream
- time
- type
- sequence number
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/65—Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/61—Network streaming of media packets for supporting one-way streaming services, e.g. Internet radio
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/75—Media network packet handling
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
The invention discloses a media stream delivery method and a server, wherein the method comprises the following steps: receiving a media segment request sent by a client, wherein the media segment request does not carry or carries at least one control parameter, and the control parameter comprises a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted; generating a media segment according to the media segment request, wherein a target media stream to be transmitted is determined according to a first type of parameter, a stream transmission type of the target media stream is determined, candidate media units to be transmitted are determined according to the stream transmission type and a second type of parameter, and the candidate media units to be transmitted are packaged into the media segment; and sending the media segment to the client. The method can realize the segmented media stream delivery according to the requirements of the client, effectively reduce the transmission delay and the cost of the media stream, provide a uniform delivery interface for the live broadcast, the on-demand broadcast and the time shift of the media stream, and simplify the realization of the server and the client.
Description
Technical Field
The present invention relates to the field of digital information transmission technologies, and in particular, to a media stream delivery method and a server.
Background
With the rapid development of the internet, especially the mobile internet, the real-time or non-real-time transmission of multimedia data such as audio, video, and image via the internet becomes a basic requirement for many applications, and to meet this requirement, various streaming media transmission technologies are proposed, and the currently widely used real-time streaming media transmission technologies mainly include three types: Real-Time Transport Protocol (RTP)/RTSP), RTMP (Real-Time Messaging Protocol), and HTTP (HyperText Transfer Protocol) Adaptive Streaming has (HTTP Adaptive Streaming). The HTTP adaptive streaming comprises a plurality of schemes: hls (HTTP Live Streaming) by apple, Smooth Streaming by microsoft, hds (HTTP Dynamic Streaming) by Adobe, DASH (Dynamic Adaptive Streaming over HTTP) by MPEG organization.
The common feature of the HTTP adaptive streaming schemes in the related art is to cut a media stream into media segments of short time (2s to 10s), generate an index file or a manifest file (e.g., m3u8 playlist in HLS and MPD file in DASH) describing the media segments at the same time, store the index file or the manifest file onto each Web server, obtain URL (Uniform Resource Locator) access addresses of the media segments by accessing the playlist or the manifest file by a client, and then download the media segments one by one and play the media segments by using a standard HTTP protocol. In short, the main difference between the above schemes is the packaging format and the manifest file format adopted by the media segments.
Compared with RTP/RTSP and RTMP, HTTP adaptive streaming can make full use of the existing Internet Web caching facilities (such as CDN and various Web caching servers) and can support large-scale user access. Meanwhile, the client can be supported to select the fragments with proper code rates according to network conditions and terminal capability by providing the media fragments with various code rates, so that code rate self-adaption is realized. Therefore, HTTP adaptive streaming has become the mainstream way of real-time streaming media delivery on the internet at present.
However, the HTTP adaptive streaming schemes in the related art all have the following problems:
first, the duration of a media segment cannot adapt to dynamically changing network transmissions. The current HAS schemes all adopt a pre-segmentation mode, that is, a server generates media segments and a manifest file thereof according to a preset time length and submits the media segments and the manifest file to a web server. When the network transmission bandwidth is sufficient and the delay is small, setting a large segment duration means increasing the delay of real-time transmission; when the network transmission bandwidth is insufficient and the delay is large, setting a small segment duration means frequent file requests, and increases the burden of the server and the network transmission overhead. Because the transmission bandwidth and the transmission delay on the internet are dynamically changed, optimal transmission cannot be realized by adopting a pre-segmentation mode with fixed time length.
Second, manifest files add transfer delay and overhead. The client needs to obtain the manifest file first to obtain the URL address of the media segment. However, since the manifest file needs to be transmitted to the client after a period of time, the manifest file obtained by the client cannot reflect the current generation situation of the latest media segments, and in addition, when the manifest file is blocked or transmission errors occur, the fast access of the user to the media segments is blocked, which reduces the transmission performance of the real-time streaming media.
Third, it is not suitable for non-real-time delivery of long-duration media streams. For video-on-demand applications, HTTP adaptive streaming requires pre-splitting a long video file into a large number of short video segments and generating a manifest file of a specific format for the video, which incurs additional processing overhead, storage overhead and transmission overhead.
Fourth, there is no uniform delivery interface for live, time-shifted, and on-demand. Taking live video as an example, in the process of live video, a user wants to see missed playing contents through time shifting, and after the live video is finished, the user wants to review, namely, switching from live video to on-demand video. However, in the existing HTTP adaptive streaming, in order to reduce the overhead caused by frequently updating the manifest file in live broadcasting, the manifest file only indicates a plurality of recently generated media segments, and if a user needs time shifting or on demand, a new manifest file needs to be additionally generated for the user or auxiliary control information needs to be provided, which increases the complexity of server and client implementation and the transmission overhead of the network.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the related art.
Therefore, a first objective of the present invention is to provide a method for delivering a media stream, which can effectively reduce transmission delay and overhead of the media stream, provide a uniform delivery interface for live broadcast, on-demand broadcast, and time-shift broadcast of the media stream, and simplify the implementation of a server and a client.
A second object of the present invention is to propose a delivery server for media streams.
A third object of the invention is to propose a computer device.
A fourth object of the invention is to propose a non-transitory computer-readable storage medium.
A fifth object of the invention is to propose a computer program product.
To achieve the above object, an embodiment of an aspect of the present invention provides a method for delivering a media stream, where the media stream is a sequence of media units, and each media unit is associated with a generation time and/or a sequence number indicating a generation sequence, the method includes: receiving a media segment request sent by a client, wherein the media segment request does not carry or carries at least one control parameter, and the control parameter comprises a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted; generating a media segment according to the media segment request, wherein the target media stream to be transmitted is determined according to the first type of parameter, the stream transmission type of the target media stream is determined, the candidate media unit to be transmitted is determined according to the stream transmission type and the second type of parameter, the candidate media unit to be transmitted is packaged into the media segment, and the stream transmission type is real-time transmission or non-real-time transmission; and sending the media segment to the client.
The media stream delivery method of the embodiment of the invention generates media segments according to the request of the client and returns the media segments to the client to realize the delivery of the media stream segmented according to the requirement of the client, the time length of the media segments can automatically adapt to the change of network transmission bandwidth, the client can control the time length of the media segments through an active request, because each media segment is triggered by the request of the client, a manifest file is not needed any more, and the client does not need to request and analyze the manifest file, on one hand, the client can more quickly obtain the latest media stream, the transmission delay of the real-time media stream is reduced, on the other hand, the transmission overhead and the processing overhead brought by the manifest file are also reduced, and finally, the client can also control the range of the media units packaged in the media segments through the request to provide a uniform delivery interface for the live broadcast, the on-demand and the time-shifting broadcast of the media stream, the implementation of the server and the client is simplified.
In addition, the method for delivering a media stream according to the above embodiment of the present invention may further have the following additional technical features:
wherein, in one embodiment of the present invention, the method of determining the streaming type of the target media stream is specified by default.
Further, in one embodiment of the invention, the first type of parameter comprises a media file identity, and when the target media stream to be transmitted is indicated by the media file identity, the streaming type of the target media stream is specified by default as a non-real-time transmission.
Further, in an embodiment of the present invention, the determining the streaming type of the target media stream includes: if the duration of time that the target media stream no longer generates a new media unit exceeds a preset time value, the streaming type of the target media stream is non-real-time transmission, otherwise, the streaming type of the target media stream is real-time transmission.
Further, in an embodiment of the present invention, the generating a media segment according to the media segment request further includes: if the media segment request does not carry the first type of parameters, the target media stream to be transmitted is a default specified media stream; if the media segment request does not carry the second type of parameter, the candidate media units include a default specified media unit according to a streaming type.
Further, in an embodiment of the present invention, the default specified media unit according to streaming type includes: if the streaming type is real-time transmission, the default specified media unit is a media unit of which the sequence number intervals of all the media units and the latest media unit in the target media stream are smaller than a first preset value, or a media unit of which the generation time intervals of all the media units and the latest media unit in the target media stream are smaller than a second preset value; if the streaming type is non-real-time transmission, the default specified media unit is a media unit of which the sequence number intervals of all the sum stream starting units in the target media stream are smaller than a third preset value, or a media unit of which the generation time intervals of all the sum stream starting units in the target media stream are smaller than a fourth preset value; wherein the stream start unit is the earliest generated media unit in the media stream.
Further, in an embodiment of the present invention, the generating the media segment according to the media segment request further comprises: if the media segment request carries at least one second type parameter, where each second type parameter corresponds to at least one constraint of a candidate media unit under a specified streaming type, the candidate media units to be transmitted include all media units in the target media stream that simultaneously satisfy all constraints corresponding to the second type parameters under the streaming type.
Further, in an embodiment of the present invention, the second type of parameter includes a start sequence number, where when the stream transmission type is real-time transmission, the corresponding constraint condition is: if the starting sequence number is valid, the sequence number of the candidate media unit is after the starting sequence number; when the stream transmission type of the starting sequence number is non-real-time transmission, the corresponding constraint conditions are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is behind the starting sequence number, and the interval between the sequence number of the candidate media unit and the starting sequence number is smaller than a first preset interval value.
Further, in an embodiment of the present invention, the second type of parameter includes a sequence number range, where the sequence number range includes at least one sequence number interval, and the sequence number interval indicates a minimum value and a maximum value of a sequence number, and a constraint condition of the sequence number range corresponding to any stream transmission type is: and if the sequence number range is valid, the sequence number of the candidate media unit is in a sequence number interval included in the sequence number range.
Further, in an embodiment of the present invention, the second type of parameter includes a start time, where when the streaming type is real-time transmission, the corresponding constraint condition is: if the start time is valid, the generation time of the candidate media unit is after the start time; when the stream transmission type is non-real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a second predetermined interval value from the start time.
Further, in an embodiment of the present invention, the second type of parameter includes a generation time range, the generation time range includes at least one generation time interval, the generation time interval indicates a minimum value and a maximum value of the generation time, and the corresponding constraint condition of the generation time range under any streaming transmission type is: if the generation time range is valid, the generation time of the candidate media unit is within the generation time range.
Further, in an embodiment of the present invention, each media unit is associated with an order shift, where the order shift refers to a sequence number interval between the media unit and a stream starting unit, the stream starting unit refers to a media unit generated earliest in a media stream, the second type parameter includes an order shift range, the order shift range includes at least one order shift interval, the order shift interval indicates a minimum value and a maximum value of the order shift, and a corresponding constraint condition of the order shift range in any stream transmission type is: if the shuffle range is valid, the shuffle of the candidate media unit is within the shuffle range.
Further, in an embodiment of the present invention, each media unit is associated with a time shift, where the time shift refers to a generation time interval between the media unit and a stream starting unit, the stream starting unit refers to a media unit generated earliest in a media stream, the second type parameter includes a time shift range, the time shift range includes at least one time shift interval, the time shift interval indicates a minimum value and a maximum value of the time shift, and a constraint condition of the time shift range under any streaming type is: if the time-shift range is valid, the time-shift of the candidate media unit is within the time-shift range.
To achieve the above object, according to another embodiment of the present invention, a server for delivering a media stream, the media stream being a sequence of media units, wherein each media unit is associated with a generation time and/or a sequence number indicating a generation sequence, the server includes: the client interface component is used for receiving a media segment request sent by a client and returning a corresponding media segment, wherein the media segment request does not carry or carry at least one control parameter, and the control parameter comprises a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted; a media segment generating component, configured to generate a media segment according to the media segment request, where the target media stream to be transmitted is determined according to the first type of parameter, a stream transmission type of the target media stream is determined, the candidate media unit to be transmitted is determined according to the stream transmission type and the second type of parameter, the candidate media unit to be transmitted is encapsulated into the media segment, and the media segment is sent to the client through the client interface component, where the stream transmission type is real-time transmission or non-real-time transmission.
The delivery server of the media stream of the embodiment of the invention generates the media segments according to the request of the client and returns the media segments to the client so as to realize the delivery of the segmented media stream according to the requirement of the client, the time length of the media segments can automatically adapt to the change of the network transmission bandwidth, the client can control the time length of the media segments through an active request, because each media segment is triggered by the request of the client, a manifest file is not needed any more, and the client does not need to request and analyze the manifest file, on one hand, the client can more quickly obtain the latest media stream, the transmission delay of the real-time media stream is reduced, on the other hand, the transmission overhead and the processing overhead brought by the manifest file are also reduced, and finally, the client can also control the range of the media units encapsulated in the media segments through the request, and provide a uniform delivery interface for the live broadcast, on demand and time-shift broadcast of the media stream, the implementation of the server and the client is simplified.
In addition, the delivery server of the media stream according to the above embodiment of the present invention may further have the following additional technical features:
wherein, in one embodiment of the present invention, the method of determining the streaming type of the target media stream is specified by default.
Further, in one embodiment of the invention, the first type of parameter comprises a media file identity, and when the target media stream to be transmitted is indicated by the media file identity, the streaming type of the target media stream is specified by default as a non-real-time transmission.
Further, in an embodiment of the present invention, the media segment generating component is further configured to, when a duration that the target media stream no longer generates a new media unit exceeds a preset time value, determine that the streaming type of the target media stream is non-real-time transmission, otherwise, determine that the streaming type of the target media stream is real-time transmission.
Further, in an embodiment of the present invention, the media segment generating component is further configured to, when the media segment request does not carry the first type of parameter, the target media stream to be transmitted is a default specified media stream, and when the media segment request does not carry the second type of parameter, the candidate media units include a default specified media unit according to a streaming type.
Further, in one embodiment of the invention, the media segment generation component is further configured to, when the streaming type is real-time delivery, the default designated media unit is the media unit with the sequence number interval between all the media units and the newest media unit in the target media stream smaller than the first preset value, or for all media units in the target media stream and the media units in which the generation time interval of the latest media unit is smaller than a second preset value, and when the streaming type is non-real-time transmission, the default designated media unit is a media unit in which sequence number intervals of all the target media streams and the stream starting unit are smaller than a third preset value, or all media units in the target media stream, the generation time interval of which is less than a fourth preset value, and the stream starting unit is the earliest generated media unit in the media stream.
Further, in an embodiment of the present invention, the media segment generating component is further configured to, when the media segment request carries at least one parameter of the second type, where each parameter of the second type corresponds to at least one constraint of a candidate media unit under a specified streaming type, the candidate media unit to be transmitted includes all media units in the target media stream that simultaneously satisfy all constraints corresponding to the parameters of the second type under the streaming type.
Further, in an embodiment of the present invention, the second type of parameter includes a start sequence number, where when the stream transmission type is real-time transmission, the corresponding constraint condition is: if the starting sequence number is valid, the sequence number of the candidate media unit is after the starting sequence number; when the stream transmission type of the starting sequence number is non-real-time transmission, the corresponding constraint conditions are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is behind the starting sequence number, and the interval between the sequence number of the candidate media unit and the starting sequence number is smaller than a first preset interval value.
Further, in an embodiment of the present invention, the second type of parameter includes a sequence number range, where the sequence number range includes at least one sequence number interval, and the sequence number interval indicates a minimum value and a maximum value of a sequence number, and a constraint condition of the sequence number range corresponding to any stream transmission type is: and if the sequence number range is valid, the sequence number of the candidate media unit is in a sequence number interval included in the sequence number range.
Further, in an embodiment of the present invention, the second type of parameter includes a start time, where when the streaming type is real-time transmission, the corresponding constraint condition is: if the start time is valid, the generation time of the candidate media unit is after the start time; when the stream transmission type is non-real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a second predetermined interval value from the start time.
Further, in an embodiment of the present invention, the second type of parameter includes a generation time range, the generation time range includes at least one generation time interval, the generation time interval indicates a minimum value and a maximum value of the generation time, and the corresponding constraint condition of the generation time range under any streaming transmission type is: if the generation time range is valid, the generation time of the candidate media unit is within the generation time range.
Further, in an embodiment of the present invention, each media unit is associated with an order shift, where the order shift refers to a sequence number interval between the media unit and a stream starting unit, the stream starting unit refers to a media unit generated earliest in a media stream, the second type parameter includes an order shift range, the order shift range includes at least one order shift interval, the order shift interval indicates a minimum value and a maximum value of the order shift, and a corresponding constraint condition of the order shift range in any stream transmission type is: if the shuffle range is valid, the shuffle of the candidate media unit is within the shuffle range.
Further, in an embodiment of the present invention, each media unit is associated with a time shift, where the time shift refers to a generation time interval between the media unit and a stream starting unit, the stream starting unit refers to a media unit generated earliest in a media stream, the second type parameter includes a time shift range, the time shift range includes at least one time shift interval, the time shift interval indicates a minimum value and a maximum value of the time shift, and a constraint condition of the time shift range under any streaming type is: if the time-shift range is valid, the time-shift of the candidate media unit is within the time-shift range.
To achieve the above object, a third embodiment of the present invention provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the method for delivering a media stream as described in the above embodiment.
To achieve the above object, a fourth aspect of the present invention provides a non-transitory computer readable storage medium, which when executed by a processor, implements the method for delivering a media stream as described in the above embodiments.
To achieve the above object, a fifth aspect of the present invention provides a computer program product, wherein when the instructions in the computer program product are executed by a processor, the method for delivering a media stream as described in the above embodiments is performed.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a flow chart of a method of delivering a media stream according to an embodiment of the invention;
fig. 2 is a schematic diagram of a real-time delivery process (applied to live streaming) for a client to continuously submit media segment requests according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a real-time transmission process (applied to live and time-shifted playing) for a client to continuously submit media segment requests according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a non-real-time delivery process (applied to on-demand and review) in which a client continuously submits requests for media segments according to yet another embodiment of the present invention; and
fig. 5 is a schematic structural diagram of a real-time delivery server of a media stream according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are illustrative and intended to be illustrative of the invention and are not to be construed as limiting the invention.
In the internet, it is often necessary to transmit various real-time generated audio, video or data streams from one network node to another, the network nodes including both various terminals such as PCs, mobile phones, tablets and various application servers such as video servers and audio servers, and the transmitted audio, video or data streams are collectively referred to as media streams. The delivery process of a media stream can be described in a general client-server model: the media stream is delivered by the server to the client. The server and the client refer to logical functional entities, where the server is a functional entity that transmits a media stream, and the client is a functional entity that receives a media stream. The server and client may reside on any network node.
Each transmitted media stream is a sequence of media units. Different media streams, their corresponding media units can be selected by themselves. When the media stream is a byte stream generated in real time, a byte can be selected as a media unit; when the media stream is an audio stream or a video stream obtained through real-time sampling, an original audio frame or a video frame can be selected as a media unit; when the media stream is an audio stream or a video stream which is sampled and encoded in real time, an encoded audio frame, an encoded video frame or an Access Unit (Access Unit) can be selected as a media Unit; when the media stream is an audio stream or a video stream that is sampled, encoded and encapsulated in real time, the encapsulated transport packets (e.g., RTP packets, PES/PS/TS packets, etc.) may be selected as media units; when the media stream is an audio or video stream that is sampled, encoded, encapsulated, and pre-segmented in real-time, a segmented media segment (e.g., a TS format segment used in HLS protocol, fMP4 format segment used in DASH protocol) may be selected as a media unit.
Each media unit may be associated with a generation time, which is typically a timestamp. Each media unit may also be associated with a sequence number that may be used to indicate the order in which the media units were generated. When sequence numbers are used to indicate the order in which the media units are generated, the meaning of the sequence numbers need to be defined in terms of the specific media unit. When the media unit is a byte, the serial number of the media unit is a byte serial number; when the media units are audio frames and video frames, the serial numbers of the media units are frame serial numbers; when the media unit is a transmission packet, the sequence number of the media unit is a packet sequence number; when the media unit is a stream segment, the sequence number of the media unit is the segment sequence number (e.g., MediaSequence of each TS segment in HLS).
For a media stream, a Sequence Number indicating a generation Sequence and a generation time may be associated at the same time, for example, when the media stream is an RTP packet stream, the RTP header has both a packet Sequence Number (Sequence Number) field for indicating the Sequence of the RTP packet and a timestamp field for indicating the generation time of the media data encapsulated in the RTP. In this case, multiple consecutive RTP packets may correspond to the same generation time, but their sequence numbers are unique.
Depending on the temporal relation of the generation and delivery of media units, the delivery of media streams can be divided into two delivery types: real-time delivery and non-real-time delivery. A streaming type of a media stream is a real-time transfer if the media units in the media stream are generated in real-time during the transfer, and a non-real-time transfer if the media stream has been generated before the transfer, e.g. a media file. Real-time delivery and non-real-time delivery are interchangeable, for example, a live media stream is stored for review or on-demand after playback is completed, and the media stream is converted from real-time delivery to non-real-time delivery.
The method of the embodiments of the present invention may be implemented for any media stream. In the following embodiments, the RTP media stream or the MPEG2-TS media stream are respectively selected to illustrate the implementation method of the embodiments of the present invention.
For an RTP media stream, a media unit is an RTP packet, a packet sequence number (sequence number) of the RTP is selected as a sequence number of the media unit, the packet sequence number of the RTP packet is a 16-bit field, the maximum value is 65535, for the RTP packets which are continuously generated, the sequence number is circularly counted, if the current packet sequence number is Seq, the sequence number of the next packet is (Seq + 1)% 65536, therefore, the sequence number is limited by the bit length in realization, the situation that the sequence number size cannot reflect the sequence order can occur, at this time, whether the sequence number circularly counts or not can be judged according to the generation time of the media unit, so as to accurately judge the sequence relation and the interval of the sequence numbers of the two media units.
For MPEG2-TS media stream, PES packets are encapsulated in TS packets, PES packets are selected as media units, and a time stamp PTS in the packet header of each PES packet is used as the generation time of a media unit. For different media streams, the unit of the time stamp PTS is also inconsistent, for example, the time unit of the PTS in the video stream is generally 1/90000 seconds, and the time unit of the PTS in the audio stream is related to the sampling rate.
In a conventional real-time streaming media protocol such as RTP or RTMP, a server push method is adopted: and the server actively sends the new media unit to the client once the new media unit exists. The method of the embodiment of the present invention is similar to various HTTP adaptive streams (such as HLS, smooth stream, MPEG-DASH), and adopts a client pulling method, but the difference is that in the existing various HTTP adaptive streams, the client requests or pulls segmented segments according to a manifest file, each segment may be identified by one URL, whereas in the embodiment of the present invention, a media segment is not pre-segmented, but is generated by the server in real time according to the request of the client, and the client may control the content and duration of the media segment.
The following describes a delivery method of a media stream and a server according to an embodiment of the present invention with reference to the drawings, and first, a delivery method of a media stream according to an embodiment of the present invention will be described with reference to the drawings.
Fig. 1 is a flowchart of a media stream delivery method according to an embodiment of the present invention.
As shown in fig. 1, the method for delivering a media stream, the media stream being a sequence of media units, wherein each media unit is associated with a generation time and/or a sequence number indicating a generation sequence, includes:
in step S101, a media segment request sent by a client is received, where the media segment request does not carry or carries at least one control parameter, and the control parameter includes a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted.
Specifically, the media segment request may not carry any first-class parameter and second-class parameter, and new parameters may be defined according to further implementation needs, for example, the control parameters that may be the first-class parameters include: media stream identification, media stream name, media file identification, media file name, etc.; control parameters that may be of the second type include: start sequence number, start time, sequence number range, generation time range, sequence shift range, time shift range, etc.
The media segment request may be submitted using any protocol, such as the common HTTP protocol, TCP protocol, UDP protocol, and the like. When the media segment request is submitted by adopting an HTTP protocol, an HTTP-GET mode or an HTTP-POST mode can also be adopted.
When the media segment request carries control parameters, the control parameters need to be packaged into a character string or a byte stream in a certain way and sent to the server. For example, when HTTP-GET is used to send media segment requests, the control parameters may be encapsulated as a string into a URL. An example of a media segment request with HTTP-GET is as follows:
media segment request without control parameters:
GET“http://www.xxx-server.com/msreq”[req1]
media segment request carrying a control parameter:
GET“http://www.xxx-server.com/msreqstreamID=601”[req2]
GET“http://www.xxx-server.com/msreqfileID=5100”[req3]
GET“http://www.xxx-server.com/msreqfileName=hello.ts”[req4]
GET“http://www.xxx-server.com/msreqseqBegin=1005”[req5]
GET“http://www.xxx-server.com/msreqtimeBegin=31000”[req6]
GET“http://www.xxx-server.com/msreqseqRange=1010-1015”[req7]
GET“http://www.xxx-server.com/msreqtimeRange=31000-32000”[req8]
GET“http://www.xxx-server.com/msreqSeqShiftRange=0-10”[req9]
GET“http://www.xxx-server.com/msreqtimeShiftRange=0-1000”[req10]
media segment request carrying two control parameters:
GET“http://www.xxx-server.com/msreqstreamID=601&seqBegin=1010”[req11]
GET“http://www.xxx-server.com/msreqfileName=hello.ts&timeBegin=31000”[req12]
GET“http://www.xxx-server.com/msreqstreamID=601&seqShiftRange=0-20”[req13]
GET“http://www.xxx-server.com/msreqfileName=hello.ts&timeShiftRange=0-3000”[req14]
in the URL of the request, the parameter names streamID, fileID, fileName, seqBegin, timebecin, seqRange, timeRange, seqsifrrange, and timeShiftRange respectively represent a media stream identifier, a media file name, a start sequence number, a start time, a sequence number range, a generation time range, a sequence shift range, and a time shift range.
The server may adopt a Web server to receive the media segment request of the client, extract corresponding control parameters from the URL of the request, and classify the control parameters: if the parameter is the media stream identifier, the media file identifier and the media file name, the parameter is a first type parameter; if the parameters are the starting sequence number, the starting time, the sequence number range, the generation time range, the sequence shift range and the time shift range, the parameters are the second type parameters.
In step S102, a media segment is generated according to the media segment request, wherein a target media stream to be transmitted is determined according to the first type of parameter, whether the streaming type of the target media stream is real-time transmission or non-real-time transmission is determined, candidate media units to be transmitted are determined according to the streaming type and the second type of parameter, and the candidate media units to be transmitted are packaged into the media segment.
Specifically, after receiving the media segment request, the server may obtain the control parameters carried in the media segment request, then may determine a target media stream to be transmitted according to a first type of parameters therein, determine whether a streaming type of the target media stream is a real-time type or a non-real-time type, determine candidate media units to be transmitted according to the streaming type and the carried second type of parameters, and finally encapsulate the candidate media units to be transmitted into the media segment. Wherein one or more media units can be encapsulated into media segments using a custom encapsulation protocol, for example, a simple encapsulation protocol is as follows: the media segment is composed of a segment header and a segment payload, the segment payload is formed by cascading a plurality of media units, and the segment header indicates the initial position and the length of each media unit. For the MPEG2-TS stream, the media unit is a PES packet, and each PES packet corresponds to an integer number of TS packets, so in addition to the above simple encapsulation protocol, the MPEG2-TS stream can be directly cut to generate media segments, and the PES packets corresponding to the candidate media units and necessary control information are encapsulated into a TS segment as a media segment.
In step S103, the media segment is sent to the client.
In particular, the server may select an appropriate manner to transmit the media segment to the client according to a protocol used by the media segment request of the client, for example, when the received media segment request adopts an HTTP GET manner, the generated media segment may be transmitted through an HTTP GET response message: the media segment is put into the entity body of the HTTP response message.
For real-time transmission, when the server receives continuous media segment requests from the client, the server will continuously generate new media segments according to the requests of the client, these new media segments encapsulate a plurality of media units that are recently generated, the client analyzes these media segments, and each media unit of the media stream can be recovered, so as to realize the live broadcast of the media stream from the server to the client, and this process is shown in fig. 2.
In the real-time transmission process, the client may also request a media stream in a certain past time period at will, and the server encapsulates the media units in the specified time period into media segments and sends the media segments to the client, so as to implement time-shifting of the media stream, and may freely switch between time-shifting and live broadcasting by requesting, which is shown in fig. 3.
For non-real-time transmission, when the server receives a media segment request from a client, the server generates new media segments according to the client request, the new media segments encapsulate a plurality of media units within a range specified by the client, and the client can recover each media unit of a media stream by analyzing the media segments, so that the on-demand or review of the media stream from the server to the client is realized, which is shown in fig. 4.
Because the mode of instantly generating the media segments is adopted, the method of the embodiment of the invention does not need the list file any more, thereby reducing the transmission delay and saving the expense. In addition, the client can adjust the frequency of sending requests by itself to control the duration of the media segments, so as to better adapt to the change of the network bandwidth. On the other hand, according to the request of the client, the server can package the media units in the designated range into media segments, so that a uniform delivery interface is provided for live broadcast, on-demand broadcast and time-shift broadcast of the media stream, and the realization of the server and the client is simplified.
The above is a detailed explanation of embodiment 1, and embodiment 2 will be described in detail below, and in the following embodiment, a description will be made of how the server determines the streaming type according to the target media stream.
Further, in an embodiment of the present invention, the method for determining the streaming type of the target media stream is specified by default. The server may have a plurality of media streams to be sent at the same time, and the client may indicate the target media stream through a first type of parameter, such as a media stream identifier, a media file identifier, or a media file name, where the media file name may be regarded as a special media file identifier. The streaming type of these target media streams may be specified by the server default, e.g. when the requested media stream is a file (e.g. req3 and req4), which is a non-real-time transfer as it no longer generates new media units.
For a media stream being live, the media units are still being generated continuously, so the streaming type of the media stream is real-time transmission at this time, but when the live process has ended, the user still accessing the media stream is still aiming to review or request, at this time, the server should determine the streaming type of the media stream as non-real-time transmission.
The server may determine whether the live broadcast process is finished in two ways, one is that the media source actively notifies the server, and the other is that the server may time the duration that the target media stream does not generate a new media unit any more, and when the duration exceeds a certain set value, for example, 1 minute, it is determined that the target media stream has stopped updating, and the streaming mode of the media stream is changed to a non-real-time mode. In this way, when the client accesses the media stream at different times through the same interface (e.g., req2), it can smoothly switch between live and on-demand.
Embodiment 3, in the following embodiments, a description will be made of how a server generates a media segment according to a media segment request.
Further, in one embodiment of the present invention, generating the media segment according to the media segment request further comprises: if the media segment request does not carry the first type of parameters, the target media stream to be transmitted is a default specified media stream; if the second type of parameter is not carried in the media segment request, the candidate media units comprise media units specified by default according to the streaming type.
Further, the default specified media unit according to the streaming type includes:
if the streaming type is real-time transmission, the default specified media unit is a media unit of which the sequence number intervals of all the media units and the latest media unit in the target media stream are smaller than a first preset value, or a media unit of which the generation time intervals of all the media units and the latest media unit in the target media stream are smaller than a second preset value;
if the stream transmission type is non-real-time transmission, the default specified media unit is a media unit of which the sequence number intervals of all the sum stream starting units in the target media stream are smaller than a third preset value, or a media unit of which the generation time intervals of all the sum stream starting units in the target media stream are smaller than a fourth preset value; the stream start unit refers to the earliest generated media unit in the media stream.
The real-time transmission of the media stream is described by taking an RTP real-time stream as an example, a media unit is an RTP packet, and each RTP packet carries a packet sequence number. Assuming that the packet sequence number of the newly generated RTP packet is 1020 and the first preset value is 20, when the server receives a media segment request not carrying any parameter, e.g., [ e.g., req1], the server may select one from the existing RTP media streams as a target media stream and determine the streaming type of the target media stream as real-time transmission, since the request does not carry the second type parameter, the candidate media unit to be transmitted includes the most recently generated 20 RTP packets (packet sequence numbers from 1001 to 1020) in the target media stream, and then the server encapsulates the 20 RTP packets into media segments.
Non-real-time transport of a media stream takes the example of an MPEG2-TS stream, where a media unit is a PES packet, and each PES packet is associated with a PTS time stamp, which is the time of generation of the media unit. Assuming that the PTS timestamp of the first PES packet in the TS stream, i.e. the stream start unit, is 30000, and the fourth preset value is 3000 ms, when the server receives a media segment request not carrying the second type of parameters, such as [ req3 or req4], the server determines the target media stream according to the first type of parameters, since the target media stream is a media file, its streaming mode is specified as non-real-time transmission by default, at this time, since the second type of parameters are not carried in the request, the candidate media unit to be transmitted includes all PES packets generated within 3000 ms from the stream start unit in the target media stream, i.e. PES packets with the timestamp PTS within the range (30000< (PTS < (33000), and then encapsulates these PES packets into media segments.
By adopting the above embodiment, for real-time transmission, the server returns a plurality of media units generated recently each time the server receives a media segment request sent by the user. And after the server continuously receives the media segment request, the recently generated media units are continuously delivered to the client. For non-real-time transmission, when a server receives a media segment request which is sent by a user and does not carry any control parameter, a plurality of media units which are originally generated by the media stream are returned to a client, and the client can request subsequent media units by adjusting the control parameter according to the received media unit information.
Embodiment 4, in the following embodiments, a description will be given of how the server determines candidate media units to be transmitted based on the second type of parameters.
Further, in an embodiment of the present invention, if the media segment request carries at least one parameter of the second type, where each parameter of the second type corresponds to at least one constraint of a candidate media unit under a specified streaming type, the candidate media units to be transmitted include all media units in the target media stream that satisfy all constraints of the second type corresponding to the parameter of the second type under the streaming type at the same time.
The following will further give six second-class parameters, and the constraint conditions corresponding to each second-class parameter under the specified streaming type, and in the specific implementation, one or more of them may be used as required, and the other second-class parameters are not limited to be defined by themselves:
1) starting sequence number
The constraint conditions corresponding to the starting sequence number when the streaming transmission type is real-time transmission are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is after the starting sequence number;
the constraint conditions corresponding to the starting sequence number when the streaming transmission type is non-real-time transmission are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is behind the starting sequence number, and the interval between the sequence number of the candidate media unit and the starting sequence number is smaller than a first preset interval value.
2) Range of serial numbers
The sequence number range comprises at least one sequence number interval, the sequence number interval indicates a minimum value and a maximum value of the sequence number, and the corresponding constraint conditions of the sequence number range under any stream transmission type are as follows: and if the sequence number range is valid, the sequence number of the candidate media unit is in a sequence number interval included in the sequence number range.
3) Starting time
The constraint conditions corresponding to the starting time when the stream transmission type is real-time transmission are as follows: if the start time is valid, the generation time of the candidate unit is after the start time;
the start time corresponds to the constraint condition when the stream transmission type is non-real-time transmission: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a second predetermined interval value from the start time.
4) Generating a time horizon
The production time range includes at least one production time interval indicating a minimum value and a maximum value of the production time, and the production time range corresponds to the following constraints under any streaming type: if the generation time range is valid, the generation time of the candidate media unit is within the generation time range.
5) Sequential shift range
The sequence shift refers to the sequence number interval between the media unit and the stream start unit, and the stream start unit refers to the earliest generated media unit in the media stream. The order shift range comprises at least one order shift interval, the order shift interval indicates a minimum value and a maximum value of the order shift, and the corresponding constraint conditions of the order shift range under any stream transmission type are as follows: if the shuffle range is valid, the shuffle of the candidate media unit is within the shuffle range.
6) Range of time shifts
The time shift refers to a generation time interval between a media unit and a stream start unit, the stream start unit refers to a media unit generated earliest in a media stream, the second type of parameter includes a time shift range, the time shift range includes at least one time shift interval, the time shift interval indicates a minimum value and a maximum value of the time shift, and a corresponding constraint condition of the time shift range under any streaming type is: if the time-shift range is valid, the time-shift of the candidate media unit is within the time-shift range.
The second type of validity and invalidity of the parameter refers to whether the value of the parameter is within a specified range. Taking the starting sequence number as an example, for real-time transmission, the value of the starting sequence number cannot exceed the sequence number of the current latest media unit, on the other hand, to ensure real-time performance, the value of the starting sequence number cannot be earlier than the sequence number of a certain existing media unit, and the starting sequence number in the above range is valid; for non-real-time transfers, the starting sequence number cannot exceed the sequence number of the last media unit. If a certain second type parameter is invalid, it is equivalent to not carrying the second type parameter. When all the second-type parameters are invalid, the candidate media unit is the default specified media unit.
It is further noted that all control parameters indicating ranges (e.g. sequence number range, generation time range, sequence shift range, time shift range) may comprise one or more intervals, wherein the representation method of each interval may be self-defined at the time of implementation. One interval is represented by directly indicating the maximum value max and the minimum value min, and the other interval is represented by adopting the minimum value min and the interval length len, wherein the maximum value max can be indirectly indicated: max is min + len-1. When the range is expressed by a character string mode, one implementation method is as follows: intervals can be comma, ' separated, minimum and maximum values can be dashes, ', and minimum and interval lengths can be colon ': ' spaced apart, and if the minimum and maximum values are the same, then the maximum value or interval length may be omitted, so taking the number range as an example, the following two representations correspond to the same number range, both including 17 media units:
A)1200-1205,1208,1211-1220
B)1200:6,1208:1,1211:10
for control parameters that indicate a range, a specific letter such as X may also be added after a particular minimum or maximum value to indicate that the minimum or maximum value is not included. For example, the generation time Tp ranges from 31000X to 32000, indicating a generation time range of 31000< Tp < > 32000.
It should be further noted that in other embodiments, a new second type of parameter may be defined, but if under a certain mapping rule, the parameter a may be mapped to the parameter B, and the constraint condition corresponding to the parameter a may be converted into the constraint condition corresponding to the parameter B, the two parameters are referred to as equivalent parameters. Equivalent parameters should not be regarded as a plurality of second type parameters but should still be regarded as different embodiments of the same parameter. For example, a second type of parameter, a minimum sequence number, may be defined, where the constraint condition for the minimum sequence number is: if the minimum sequence number is valid, the sequence number of the candidate media unit should be greater than or equal to the minimum sequence number, where greater than means that the sequence number is after the minimum sequence number. Comparing the constraint conditions of the minimum sequence number and the initial sequence number, it can be found that if a mapping rule is established: if the minimum sequence number is the start sequence number +1, the constraint conditions corresponding to the start sequence number and the minimum sequence number will contain the same candidate media units. Thus, the minimum sequence number and the start sequence number are actually equivalent parameters, and should be considered as different implementations of the same second type of parameter, and should not be considered as a new second type of parameter.
Real-time transport takes RTP real-time streaming as an example, a media unit is an RTP packet, and each RTP packet carries a packet sequence number. Assuming that the packet sequence number of the first generated RTP packet is 1000 and the packet sequence number of the newly generated RTP packet is 1020, the server receives the following media segment requests:
1)GET“http://www.xxx-server.com/msreqseqBegin=1005”[req5]
the request carries only one parameter of the second type: starting sequence numbers, 15 RTP packets (packet sequence numbers from 1006 to 1020) meeting the constraint condition corresponding to the starting sequence numbers, and the candidate media units to be sent include the 16 RTP packets; the client side can return the recently generated media units to the client side by continuously submitting the requests with the starting serial numbers, so that the live broadcast of the media stream is realized.
2)GET“http://www.xxx-server.com/msreqseqRange=1010-1015”[req7]
The request carries only one parameter of the second type: a sequence number range, which includes only one sequence number interval, the minimum value of the sequence number interval is 1010, and the maximum value is 1015, so that the candidate media units to be sent include all the media units with sequence numbers in this range, i.e. six RTP packets from 1010 to 1015. By submitting a request with a sequence number range, the client can randomly specify the media unit segments in the range to realize time-shifting operation.
3)GET“http://www.xxx-server.com/msreqseqShiftRange=0-10”[req9]
The request carries a second type of parameter: and the sequence shift range of the candidate media units to be sent is 0 to 10. Since the sequence shift is the sequence number interval between the media unit and the stream start unit, and the sequence number of the stream start unit is 1000, the sequence shift range indicates that the sequence number range of the candidate media unit is 1000 to 1010, which includes 11 RTP packets. By submitting the request with the sequential range shifting, the client can acquire the media unit segments in any specified range, and the time-shifting playing of the media stream is realized.
Non-real-time transport takes MPEG2-TS real-time stream as an example, the media units are PES packets, each associated with a PTS time stamp, i.e. the time of generation of the media unit. Assuming that the PTS timestamp of the first PES packet in the TS stream, i.e. the stream start unit, is 30000, when the server receives the following media segment request:
1)GET“http://www.xxx-server.com/msreqtimeBegin=31000”[req6]
the request carries only one parameter of the second type: a start time that conveys a corresponding constraint in non-real time: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a preset value away from the start time. Here, the preset value is assumed to be 5000, i.e., the candidate media unit includes all PES packets having a timestamp PTS within a range (31000< PTS < (36000)). By submitting a request with a start time, the client can obtain a media segment with a fixed duration from the start time, thereby realizing on-demand and time-shift playing.
2)GET“http://www.xxx-server.com/msreqtimeRange=31000-32000”[req8]
The request carries only one parameter of the second type: a time range is generated. The generation time range comprises only one time interval with a maximum value of 32000 and a minimum value of 31000, and thus the candidate media units should comprise all PES packets with all timestamps PTS within the range (31000< ═ Tp < ═ 32000); by submitting a request with a generated time range, the client can request media segments at any position to realize on-demand and time-shift playing.
3)GET“http://www.xxx-server.com/msreqtimeShiftRange=0-1000”[req13]
The request carries a second type of parameter: the range of time shifts. Wherein the time-shift range of the candidate media unit to be transmitted is 0 to 1000. Since time shift is the time interval between a media unit and a stream start unit, and the PTS, which is the generation time of the stream start unit, is 30000, the above time shift range indicates that the candidate media unit includes all PES packets having PTS timestamps within the range (30000< (PTS) > -31000). By submitting a request with a time shift range, the client can request a media segment at any position to realize on-demand and time shift playing.
According to the delivery method of the media stream provided by the embodiment of the invention, the media segment is generated in real time according to the request of the client and is returned to the client, so that the delivery of the segmented media stream according to the requirement of the client is realized, the time length of the media segment automatically adapts to the change of network transmission bandwidth, the time length of the media segment can be controlled by the client through an active request, and when the transmission bandwidth between the client and a server is sufficient and the delay is small, the client can more quickly make the request, so that the media segment with shorter time length is obtained, and the real-time transmission delay is reduced; when the transmission bandwidth between the client and the server is insufficient and the delay is large, the client can prolong the interval of submitting the request, so that a longer media segment is obtained, and the request times are reduced to reduce the transmission overhead; because each media segment is generated by the request trigger of the client, the manifest file is not needed any more, and the client does not need to request and analyze the manifest file either, on one hand, the client can obtain the latest media stream more quickly, the transmission delay of the real-time media stream is reduced, on the other hand, the transmission overhead and the processing overhead brought by the manifest file are also reduced, and finally, the client can also control the range of the media units encapsulated in the media segments through the request, so that a uniform delivery interface is provided for the live broadcast, the on-demand broadcast and the time-shifted broadcast of the media stream, and the realization of the server and the client is simplified.
Next, a real-time delivery server of a media stream proposed according to an embodiment of the present invention is described with reference to the accompanying drawings.
Fig. 5 is a schematic structural diagram of a real-time delivery server of a media stream according to an embodiment of the present invention.
As shown in fig. 5, the real-time delivery server 10 of the media stream includes: a client interface component 100 and a media segment generation component 200.
The client interface component 100 is configured to receive a media segment request sent by a client and return a corresponding media segment, where the media segment request does not carry or carry at least one control parameter, and the control parameter includes a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted. The media segment generation component 200 generates a media segment according to the media segment request, wherein a target media stream to be transmitted is determined according to a first type of parameter, whether the streaming transmission type of the target media stream is real-time transmission or non-real-time transmission is determined, candidate media units to be transmitted are determined according to the streaming transmission type and a second type of parameter, the candidate media units to be transmitted are packaged into the media segment, and the media segment is transmitted to the client through the client interface component 100. The server 10 of the embodiment of the present invention generates media segments in real time according to the request of the client, and returns the media segments to the client, so as to implement the segmented real-time media stream delivery according to the requirements of the client, thereby effectively reducing the media stream transmission delay and overhead, providing a uniform delivery method for live broadcast, on-demand broadcast and time-shift broadcast, and simplifying the implementation of the server and the client.
Specifically, the client interface component 100 is configured to receive a media segment request of a client, and send a generated media segment to the client; the media segment request may carry 0, 1 or more control parameters; the control parameters include the following categories: a first type of parameter and a second type of parameter; the first type of parameter is used for indicating a target media stream to be transmitted; the second type of parameter is used to indicate candidate media units to be transmitted. The client interface component may employ any specified protocol to receive media segment requests, for example, when the HTTP protocol is employed, the client interface component may be a Web server that may receive any media segment requests employing the HTTP protocol and return the media segments via HTTP responses; when using the TCP protocol, the client interface component is a TCP server and provides a fixed service port.
The media segment generation component 200 is configured to generate the required media segments according to the media segment requests of the clients. The method comprises the steps of obtaining a media segment request and control parameters thereof from a client interface component, determining a target media stream to be transmitted according to a first type of parameters, determining whether the stream transmission type of the target media stream is real-time transmission or non-real-time transmission, determining candidate media units to be transmitted according to the stream transmission type and a second type of parameters, extracting the candidate media units to be transmitted from a media stream storage unit, packaging the candidate media units into media segments, and then directly delivering the media segments to the client interface component for transmission.
Wherein, in one embodiment of the invention, the method of determining the streaming type of the target media stream is specified by default.
Further, in one embodiment of the invention, the first type of parameter comprises a media file identity, and when the target media stream to be transmitted is indicated by the media file identity, the streaming type of the target media stream is specified by default as a non-real-time transmission.
Further, in an embodiment of the present invention, the media segment generation component 200 is further configured to determine that the streaming type of the target media stream is non-real-time transmission when the duration that the target media stream no longer generates new media units exceeds a preset time value, and otherwise, determine that the streaming type of the target media stream is real-time transmission.
Further, in an embodiment of the present invention, the media segment generation component 200 is further configured to, when the media segment request does not carry the first type of parameter, the target media stream to be transmitted is a default specified media stream, and when the media segment request does not carry the second type of parameter, the candidate media units include media units that are specified by default according to the streaming type.
Further, in an embodiment of the present invention, the media segment generating component 300 is further configured to, when the streaming type is real-time transmission, default the designated media units to be the media units with the sequence number intervals of all and the latest media units in the target media stream smaller than the first preset value, or to be the media units with the generation time intervals of all and the latest media units in the target media stream smaller than the second preset value, and when the streaming type is non-real-time transmission, default the designated media units to be the media units with the sequence number intervals of all and the stream starting units in the target media stream smaller than the third preset value, or to be the media units with the generation time intervals of all and the stream starting units in the target media stream smaller than the fourth preset value, where the stream starting unit is the earliest generated media unit in the media stream.
Further, in an embodiment of the present invention, the media segment generating component 300 is further configured to, when the media segment request carries at least one second type parameter, where each second type parameter corresponds to at least one constraint of a candidate media unit under a specified streaming type, the candidate media units to be transmitted include all media units in the target media stream that simultaneously satisfy all constraints corresponding to the second type parameter under the streaming type.
Further, in an embodiment of the present invention, the second type of parameter includes a start sequence number, where when the stream transmission type is real-time transmission, the corresponding constraint condition is: if the starting sequence number is valid, the sequence number of the candidate media unit is after the starting sequence number; when the stream transmission type of the start sequence number is non-real-time transmission, the corresponding constraint conditions are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is behind the starting sequence number, and the interval between the sequence number of the candidate media unit and the starting sequence number is less than a first preset interval value.
Further, in an embodiment of the present invention, the second type of parameter includes a sequence number range, where the sequence number range includes at least one sequence number interval, and the sequence number interval indicates a minimum value and a maximum value of a sequence number, and a constraint condition of the sequence number range under any stream transmission type is: if the sequence number range is valid, the sequence number of the candidate media unit is within a sequence number interval included in the sequence number range.
Further, in an embodiment of the present invention, the second type of parameter includes a start time, where when the streaming type is real-time transmission, the corresponding constraint condition is: if the start time is valid, the generation time of the candidate media unit is after the start time; when the stream transmission type is non-real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a second predetermined interval value from the start time.
Further, in an embodiment of the present invention, the second type of parameter includes a generation time range, the generation time range includes at least one generation time interval, the generation time interval indicates a minimum value and a maximum value of the generation time, and the corresponding constraint condition of the generation time range in any streaming type is: if the generation time range is valid, the generation time of the candidate media unit is within the generation time range.
Further, in an embodiment of the present invention, each media unit is associated with an order shift, where the order shift refers to a sequence number interval between the media unit and a stream starting unit, the stream starting unit refers to a media unit generated earliest in a media stream, the second type of parameter includes an order shift range, the order shift range includes at least one order shift interval, the order shift interval indicates a minimum value and a maximum value of the order shift, and a constraint condition of the order shift range under any stream transmission type is: if the shuffle range is valid, the shuffle of the candidate media unit is within the shuffle range.
Further, in an embodiment of the present invention, each media unit is associated with a time shift, where the time shift refers to a generation time interval between the media unit and a stream starting unit, the stream starting unit refers to an earliest generated media unit in the media stream, the second type of parameter includes a time shift range, the time shift range includes at least one time shift interval, the time shift interval indicates a minimum value and a maximum value of the time shift, and a constraint condition of the time shift range in any streaming type is: if the time shift range is valid, the time shift of the candidate media unit is within the time shift range.
According to the delivery server of the media stream provided by the embodiment of the invention, the media segment is generated in real time according to the request of the client and is returned to the client so as to realize the delivery of the segmented media stream according to the requirement of the client, the time length of the media segment automatically adapts to the change of network transmission bandwidth, the client can control the time length of the media segment through an active request, and when the transmission bandwidth between the client and the server is sufficient and the time delay is small, the client can more quickly make the request, so that the media segment with shorter time length is obtained, and the real-time transmission delay is reduced; when the transmission bandwidth between the client and the server is insufficient and the delay is large, the client can prolong the interval of submitting the request, so that a longer media segment is obtained, and the request times are reduced to reduce the transmission overhead; because each media segment is generated by the request trigger of the client, the manifest file is not needed any more, and the client does not need to request and analyze the manifest file either, on one hand, the client can obtain the latest media stream more quickly, the transmission delay of the real-time media stream is reduced, on the other hand, the transmission overhead and the processing overhead brought by the manifest file are also reduced, and finally, the client can also control the range of the media units encapsulated in the media segments through the request, so that a uniform delivery interface is provided for the live broadcast, the on-demand broadcast and the time-shifted broadcast of the media stream, and the realization of the server and the client is simplified.
In order to implement the foregoing embodiments, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the computer device implements the method for delivering a media stream as described in the foregoing embodiments.
In order to implement the foregoing embodiments, the present invention further provides a non-transitory computer readable storage medium, and when executed by a processor, the program implements the method for delivering a media stream as described in the foregoing embodiments.
In order to implement the foregoing embodiments, the present invention further provides a computer program product, and when instructions in the computer program product are executed by a processor, the method for delivering a media stream as described in the foregoing embodiments is performed.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.
Claims (28)
1. A method for delivering a media stream, wherein the media stream is a sequence of media units, and wherein each media unit is associated with a generation time and/or a sequence number indicating a generation order, the method comprising:
receiving a media segment request sent by a client, wherein the media segment request does not carry or carries at least one control parameter, and the control parameter comprises a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted;
generating a media segment according to the media segment request, wherein the target media stream to be transmitted is determined according to the first type of parameter, the stream transmission type of the target media stream is determined, the candidate media unit to be transmitted is determined according to the stream transmission type and the second type of parameter, the candidate media unit to be transmitted is packaged into the media segment, and the stream transmission type is real-time transmission or non-real-time transmission; and
and sending the media segment to the client.
2. The method for delivering a media stream according to claim 1, wherein the method for determining the streaming type of the target media stream is specified by default.
3. The method of delivering a media stream according to claim 2, wherein the first type of parameter comprises a media file identity, and when the target media stream to be delivered is indicated by the media file identity, the streaming type of the target media stream is specified by default as a non-real-time delivery.
4. The method for delivering a media stream according to claim 1, wherein the determining a streaming type of the target media stream comprises:
if the duration of time that the target media stream no longer generates a new media unit exceeds a preset time value, the streaming type of the target media stream is non-real-time transmission, otherwise, the streaming type of the target media stream is real-time transmission.
5. The method for delivering a media stream according to claim 1, wherein the generating a media segment according to the media segment request further comprises:
if the media segment request does not carry the first type of parameters, the target media stream to be transmitted is a default specified media stream;
if the media segment request does not carry the second type of parameter, the candidate media units include a default specified media unit according to a streaming type.
6. The method for delivering a media stream according to claim 5, wherein the default designated media unit according to the streaming type comprises:
if the streaming type is real-time transmission, the default specified media unit is a media unit of which the sequence number intervals of all the media units and the latest media unit in the target media stream are smaller than a first preset value, or a media unit of which the generation time intervals of all the media units and the latest media unit in the target media stream are smaller than a second preset value;
if the streaming type is non-real-time transmission, the default specified media unit is a media unit of which the sequence number intervals of all the sum stream starting units in the target media stream are smaller than a third preset value, or a media unit of which the generation time intervals of all the sum stream starting units in the target media stream are smaller than a fourth preset value; wherein the stream start unit is the earliest generated media unit in the media stream.
7. The method for delivering a media stream according to claim 1, wherein the generating a media segment according to a media segment request further comprises:
if the media segment request carries at least one second type parameter, where each second type parameter corresponds to at least one constraint of a candidate media unit under a specified streaming type, the candidate media units to be transmitted include all media units in the target media stream that simultaneously satisfy all constraints corresponding to the second type parameters under the streaming type.
8. The method of claim 7, wherein the second type of parameter comprises a start sequence number, wherein,
when the stream transmission type of the starting sequence number is real-time transmission, the corresponding constraint conditions are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is after the starting sequence number;
when the stream transmission type of the starting sequence number is non-real-time transmission, the corresponding constraint conditions are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is behind the starting sequence number, and the interval between the sequence number of the candidate media unit and the starting sequence number is smaller than a first preset interval value.
9. The method according to claim 7, wherein the second type of parameter includes a sequence number range, the sequence number range includes at least one sequence number interval, the sequence number interval indicates a minimum value and a maximum value of a sequence number, and the sequence number range corresponds to the following constraints under any streaming type:
and if the sequence number range is valid, the sequence number of the candidate media unit is in a sequence number interval included in the sequence number range.
10. The method of claim 7, wherein the second type of parameter comprises a start time, wherein,
when the stream transmission type is real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time;
when the stream transmission type is non-real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a second predetermined interval value from the start time.
11. The method according to claim 7, wherein the second type of parameter comprises a generation time range, the generation time range comprises at least one generation time interval, the generation time interval indicates a minimum value and a maximum value of a generation time, and the generation time range corresponds to the following constraints under any streaming type:
if the generation time range is valid, the generation time of the candidate media unit is within the generation time range.
12. The method according to claim 7, wherein each media unit is associated with an order shift, the order shift refers to an interval between the media unit and a stream start unit, the stream start unit refers to an earliest generated media unit in the media stream, the second type parameter includes an order shift range, the order shift range includes at least one order shift interval, the order shift interval indicates a minimum value and a maximum value of the order shift, and the corresponding constraint condition of the order shift range in any stream transmission type is:
if the shuffle range is valid, the shuffle of the candidate media unit is within the shuffle range.
13. The method according to claim 7, wherein each media unit is associated with a time shift, the time shift is a generation time interval between the media unit and a stream starting unit, the stream starting unit is an earliest generated media unit in the media stream, the second type parameter includes a time shift range, the time shift range includes at least one time shift interval, the time shift interval indicates a minimum value and a maximum value of the time shift, and the constraint condition of the time shift range in any stream transmission type is:
if the time-shift range is valid, the time-shift of the candidate media unit is within the time-shift range.
14. A delivery server for a media stream, said media stream being a sequence of media units, wherein each media unit is associated with a generation time and/or a sequence number indicating the order of generation, said server comprising:
the client interface component is used for receiving a media segment request sent by a client and returning a corresponding media segment, wherein the media segment request does not carry or carry at least one control parameter, and the control parameter comprises a first type parameter indicating a target media stream to be transmitted and a second type parameter indicating a candidate media unit to be transmitted;
a media segment generating component, configured to generate a media segment according to the media segment request, where the target media stream to be transmitted is determined according to the first type of parameter, a stream transmission type of the target media stream is determined, the candidate media unit to be transmitted is determined according to the stream transmission type and the second type of parameter, the candidate media unit to be transmitted is encapsulated into the media segment, and the media segment is sent to the client through the client interface component, where the stream transmission type is real-time transmission or non-real-time transmission.
15. The media stream delivery server of claim 14, wherein the method of determining the streaming type of the target media stream is specified by default.
16. The media stream delivery server according to claim 15, wherein the first type of parameter comprises a media file identity, and when the target media stream to be transmitted is indicated by the media file identity, the streaming type of the target media stream is specified by default as a non-live transmission.
17. The media stream delivery server of claim 14, wherein the media segment generation component is further configured to determine the streaming type of the target media stream as non-real-time transmission when a duration of time for which the target media stream no longer generates new media units exceeds a preset time value, and otherwise determine the streaming type of the target media stream as real-time transmission.
18. The media stream delivery server of claim 14, wherein the media segment generation component is further configured to, when the media segment request does not carry the first type of parameter, the target media stream to be transmitted is a default specified media stream, and when the second type of parameter is not carried in the media segment request, the candidate media units comprise default specified media units according to streaming type.
19. The delivery server of media streams of claim 18, wherein the media segment generation component is further to, when the streaming type is real-time delivery, the default designated media unit is the media unit with the sequence number interval between all the media units and the newest media unit in the target media stream smaller than the first preset value, or for all media units in the target media stream and the media units in which the generation time interval of the latest media unit is smaller than a second preset value, and when the streaming type is non-real-time transmission, the default designated media unit is a media unit in which sequence number intervals of all the target media streams and the stream starting unit are smaller than a third preset value, or all media units in the target media stream, the generation time interval of which is less than a fourth preset value, and the stream starting unit is the earliest generated media unit in the media stream.
20. The media stream delivery server of claim 14, wherein the media segment generation component is further configured to carry at least one parameter of the second type in the media segment request, wherein when each parameter of the second type corresponds to at least one constraint of a candidate media unit under a specified streaming type, the candidate media unit to be transmitted comprises all media units in the target media stream that satisfy all constraints corresponding to the parameters of the second type under the streaming type at the same time.
21. The media stream delivery server according to claim 20, wherein the second type of parameter comprises a start sequence number, and when the streaming type is real-time transmission, the corresponding constraint conditions are: if the starting sequence number is valid, the sequence number of the candidate media unit is after the starting sequence number; when the stream transmission type of the starting sequence number is non-real-time transmission, the corresponding constraint conditions are as follows: if the starting sequence number is valid, the sequence number of the candidate media unit is behind the starting sequence number, and the interval between the sequence number of the candidate media unit and the starting sequence number is smaller than a first preset interval value.
22. The media stream delivery server according to claim 20, wherein the second type of parameter comprises a sequence number range, the sequence number range comprises at least one sequence number interval, the sequence number interval indicates a minimum value and a maximum value of a sequence number, and the sequence number range corresponds to the following constraints under any streaming type:
and if the sequence number range is valid, the sequence number of the candidate media unit is in a sequence number interval included in the sequence number range.
23. The media stream delivery server of claim 20, wherein the second type of parameter comprises a start time, wherein,
when the stream transmission type is real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time;
when the stream transmission type is non-real-time transmission, the corresponding constraint conditions are as follows: if the start time is valid, the generation time of the candidate media unit is after the start time and is less than a second predetermined interval value from the start time.
24. The media stream delivery server according to claim 20, wherein the second type of parameter comprises a generation time range, the generation time range comprises at least one generation time interval, the generation time interval indicates a minimum value and a maximum value of a generation time, and the generation time range corresponds to the following constraints under any streaming type:
if the generation time range is valid, the generation time of the candidate media unit is within the generation time range.
25. The media stream delivery server according to claim 20, wherein each media unit is associated with an order shift, the order shift is a sequence number interval between the media unit and a stream start unit, the stream start unit is an earliest generated media unit in the media stream, the second type parameter includes an order shift range, the order shift range includes at least one order shift interval, the order shift interval indicates a minimum value and a maximum value of the order shift, and the corresponding constraint condition of the order shift range in any stream transmission type is:
if the shuffle range is valid, the shuffle of the candidate media unit is within the shuffle range.
26. The media stream delivery server according to claim 20, wherein each media unit is associated with a time shift, the time shift is a generation time interval between the media unit and a stream starting unit, the stream starting unit is an earliest generated media unit in the media stream, the second type parameter comprises a time shift range, the time shift range comprises at least one time shift interval, the time shift interval indicates a minimum value and a maximum value of the time shift, and the corresponding constraint condition of the time shift range in any streaming type is:
if the time-shift range is valid, the time-shift of the candidate media unit is within the time-shift range.
27. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program implements the method of any one of claims 1-13.
28. A non-transitory computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method of any one of claims 1-13.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811353208.6A CN111193686B (en) | 2018-11-14 | 2018-11-14 | Media stream delivery method and server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811353208.6A CN111193686B (en) | 2018-11-14 | 2018-11-14 | Media stream delivery method and server |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111193686A CN111193686A (en) | 2020-05-22 |
CN111193686B true CN111193686B (en) | 2021-12-21 |
Family
ID=70710536
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811353208.6A Active CN111193686B (en) | 2018-11-14 | 2018-11-14 | Media stream delivery method and server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111193686B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113873343B (en) * | 2020-06-30 | 2023-02-24 | 北京开广信息技术有限公司 | Self-adaptive real-time delivery method of media stream and server |
CN113596580A (en) * | 2021-07-28 | 2021-11-02 | 伟乐视讯科技股份有限公司 | Streaming media data processing method and device based on SRT protocol and electronic equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102577272A (en) * | 2009-10-06 | 2012-07-11 | 微软公司 | Low latency cacheable media streaming |
CN104937583A (en) * | 2013-01-18 | 2015-09-23 | 华为技术有限公司 | Method and apparatus for performing adaptive streaming on media contents |
WO2016119735A1 (en) * | 2015-01-30 | 2016-08-04 | Mediatek Inc. | Method and device for adaptive video content delivery using http |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104838661B (en) * | 2013-09-13 | 2019-06-07 | 华为技术有限公司 | Flow-medium transmission method and system and user equipment and server |
-
2018
- 2018-11-14 CN CN201811353208.6A patent/CN111193686B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102577272A (en) * | 2009-10-06 | 2012-07-11 | 微软公司 | Low latency cacheable media streaming |
CN104937583A (en) * | 2013-01-18 | 2015-09-23 | 华为技术有限公司 | Method and apparatus for performing adaptive streaming on media contents |
WO2016119735A1 (en) * | 2015-01-30 | 2016-08-04 | Mediatek Inc. | Method and device for adaptive video content delivery using http |
Also Published As
Publication number | Publication date |
---|---|
CN111193686A (en) | 2020-05-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6685989B2 (en) | Extended Block-Request Streaming System with Signaling or Block Generation | |
US11477262B2 (en) | Requesting multiple chunks from a network node on the basis of a single request message | |
US10659502B2 (en) | Multicast streaming | |
EP3496365B1 (en) | System and method for optimized delivery of live adaptive bitrate (abr) media | |
EP3090523B1 (en) | Content delivery | |
US10735823B2 (en) | System and method for optimized delivery of live ABR media | |
US20140032777A1 (en) | Method, apparatus, and system for transmitting and processing media content | |
US20170127147A1 (en) | Multicast streaming | |
CN108370281B (en) | Data rate adaptation for multicast delivery of streaming content | |
EP2391953A1 (en) | Application, usage&radio link aware transport network scheduler | |
EP3391652B1 (en) | Controlling retrieval in adaptive streaming | |
TWI616097B (en) | Streaming apparatus, streaming method, streaming service system using the streaming apparatus and the recording medium | |
CN107920072B (en) | Multimedia sharing method and system based on data characteristics | |
CN111193686B (en) | Media stream delivery method and server | |
CN110086797B (en) | Real-time receiving method of media stream, client, computer device and storage medium | |
CN110072128B (en) | Real-time pushing method of media stream and server | |
CN111193684B (en) | Real-time delivery method and server of media stream | |
CN111654725B (en) | Real-time receiving method and client of media stream | |
CN110881018B (en) | Real-time receiving method and client of media stream | |
Pereira et al. | Dynamic adaptive streaming over http and progressive download: Comparative considerations | |
CN110545492B (en) | Real-time delivery method and server of media stream | |
KR102237900B1 (en) | Method for retrieving, by a client terminal, a content part of a multimedia content | |
WO2020048268A1 (en) | Real-time transmitting method and real-time receiving method for media stream, server, and client |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |