real-time delivery method and server of media stream

文档序号:1784966 发布日期:2019-12-06 浏览:19次 中文

阅读说明:本技术 媒体流的实时递送方法及服务器 (real-time delivery method and server of media stream ) 是由 姜红旗 于 2018-09-05 设计创作,主要内容包括:本发明公开了一种媒体流的实时递送方法及服务器,其中,方法包括:接收客户端发送的媒体段请求,其中,媒体段请求不携带或携带至少一个控制参数,且控制参数包括指示待传送的目标媒体流的第一类参数和指示待传送的候选媒体单元的第二类参数;根据媒体段请求生成媒体段,其中,根据第一类参数确定待传送的目标媒体流,根据第二类参数确定待传送的候选媒体单元,并将待传送的候选媒体单元封装成媒体段;发送媒体段至客户端。该方法根据客户端的请求来实时生成媒体段,并返回给客户端,以实现按客户端需求分段的实时媒体流递送,从而有效降低媒体流传输延时和开销,进一步提高实时媒体流的传输性能。(The invention discloses a real-time delivery method of a media stream 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 the first type of parameters, candidate media units to be transmitted are determined according to the second type of parameters, and the candidate media units to be transmitted are packaged into the media segment; and sending the media segment to the client. The method generates the media segments in real time according to the request of the client and returns the media segments to the client so as to realize the delivery of the real-time media stream segmented according to the requirement of the client, thereby effectively reducing the transmission delay and the cost of the media stream and further improving the transmission performance of the real-time media stream.)

1. A method for real-time delivery of a media stream, said media stream being a sequence of media units generated in real-time, wherein each media unit is associated with a generation time and/or a sequence number indicating the generation order, said method comprising the steps of:

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 parameters, the candidate media units to be transmitted are determined according to the second type of parameters, and the candidate media units to be transmitted are packaged into the media segment; and

And sending the media segment to the client.

2. The method for real-time delivery of 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 parameters, the candidate media units include default specified media units, and the default specified media units are media units in which sequence number intervals of all and latest media units in the target media stream are smaller than a first preset value, or media units in which generation time intervals of all and latest media units in the target media stream are smaller than a second preset value.

3. The method for real-time delivery of 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, wherein each second type parameter corresponds to at least one constraint condition of a candidate media unit, the candidate media units to be transmitted include all media units in the target media stream which simultaneously satisfy all constraint conditions corresponding to the second type parameters.

4. the method according to claim 3, wherein the second type of parameter includes a start sequence number, and the constraint condition corresponding to the start sequence number is:

if the start sequence number is valid, the sequence number of the candidate media unit is subsequent to the start sequence number or equal to the start sequence number.

5. the method according to claim 3, wherein the second type of parameter includes a start time, and the constraint condition corresponding to the start time is:

If the start time is valid, the generation time of the candidate unit is after the start time.

6. The method according to claim 3, wherein the second type of parameter includes a unit number, and the constraint condition corresponding to the unit number is:

If the number of units is valid, the number of the candidate media units does not exceed the number of the units;

if the range of the candidate media unit is not limited by other second type parameters carried by the media segment request, the interval between the sequence numbers of the candidate media unit and the latest media unit is less than the number of the units.

7. The method according to claim 3, wherein the second type of parameter includes a segment duration, and the constraint condition corresponding to the segment duration is:

If the segment duration is valid, the generation time interval of the earliest and latest generated units of the candidate media units is less than the segment duration;

If the range of the candidate media unit is not limited by other second type parameters carried by the media segment request, the generation time interval of the candidate media unit and the latest media unit is less than the segment duration.

8. the method of claim 1, wherein the first type of parameter comprises a media stream identifier to specify the target media stream to be transmitted.

9. The method for real-time delivery of a media stream according to claim 8, wherein said encapsulating the candidate media units to be transmitted into the media segment further comprises:

Acquiring media stream index information, and packaging the media stream index information into the media segment, wherein the media stream index information contains a plurality of media stream description information belonging to the same content, and the media stream description information includes a media stream identifier and a media stream bit rate.

10. A server for real-time delivery of a media stream, said media stream being a sequence of media units generated in real-time, 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;

And the media segment generating component generates media segments according to the media segment requests, wherein the target media stream to be transmitted is determined according to the first type of parameters, the candidate media units to be transmitted are determined according to the second type of parameters, the candidate media units to be transmitted are packaged into the media segments, and the media segments are sent to the client through the client interface component.

11. The server according to claim 10, wherein the media segment generation component is further configured to, when the media segment request does not carry the first type of parameter, determine the target media stream to be transmitted as a default specified media stream, and when the media segment request does not carry the second type of parameter, determine the candidate media units to include default specified media units, where the default specified media units are media units whose sequence number intervals between all and the latest media unit in the target media stream are smaller than a first preset value, or media units whose generation time intervals between all and the latest media unit in the target media stream are smaller than a second preset value.

12. The server of claim 10, wherein the media segment generation component is further configured to, when at least one of the second type parameters is carried in the media segment request, wherein each of the second type parameters corresponds to at least one constraint of a candidate media unit, and the candidate media units to be transmitted include all media units in the target media stream that satisfy all constraints corresponding to the second type parameters at the same time.

13. The server according to claim 12, wherein the second type of parameter includes a start sequence number, and the constraint condition corresponding to the start sequence number is: if the start sequence number is valid, the sequence number of the candidate media unit is subsequent to the start sequence number or equal to the start sequence number.

14. The server according to claim 12, wherein the second type of parameter comprises a start time, and the constraint condition of the start time is: if the start time is valid, the generation time of the candidate unit is after the start time.

15. The server according to claim 12, wherein the second type of parameter includes the number of units, and the constraint condition for the number of units is:

If the number of units is valid, the number of the candidate media units does not exceed the number of the units;

If the range of the candidate media unit is not limited by other second type parameters carried by the media segment request, the interval between the sequence numbers of the candidate media unit and the latest media unit is less than the number of the units.

16. The server according to claim 12, wherein the second type of parameter comprises a segment duration, and the constraint condition for the segment duration is:

If the segment duration is valid, the generation time interval of the earliest and latest generated units of the candidate media units is less than the segment duration;

If the range of the candidate media unit is not limited by other second type parameters carried by the media segment request, the generation time interval of the candidate media unit and the latest media unit is less than the segment duration.

17. the server of claim 10, wherein the first type of parameter comprises a media stream identifier to specify the target media stream to be transmitted.

18. The server of claim 17, wherein the media segment generation component is further configured to obtain media stream index information and encapsulate the media stream index information into the media segment, wherein the media stream index information includes a plurality of media stream description information belonging to a same content, and the media stream description information includes a media stream identifier and a media stream bit rate.

19. The real-time delivery server of media streams of claim 10, further comprising:

At least one real-time media stream generation component for self-generating or receiving one or more real-time media streams from other devices.

20. 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-9.

21. 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-9.

22. A computer program product in which instructions, when executed by a processor, perform the method of any one of claims 1-9.

Technical Field

The present invention relates to the field of digital information transmission technologies, and in particular, to a real-time delivery method of a media stream and a server.

Background

With the rapid development of the internet, especially the mobile internet, the real-time transmission of multimedia data such as audio, video, and image through the internet becomes a basic requirement for many applications, and to meet this requirement, various streaming media real-time transmission technologies are proposed, and currently, the streaming media real-time transmission technologies are widely used, and 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 these HTTP adaptive streaming schemes 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 them in each Web server, and obtain URL (Uniform Resource Locator) access addresses of the media segments by accessing the playlist or manifest file, and then download the media segments one by one and play them by using a standard HTTP protocol. The main difference between these schemes is represented by the difference between the encapsulation format and the manifest file format employed 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, these HTTP adaptive streaming schemes described above all have two problems:

Problem 1, 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.

Problem 2, manifest files increase transfer latency 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.

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 real-time delivery of a media stream, which can effectively reduce the transmission delay and overhead of the media stream, and further improve the transmission performance of the real-time media stream.

A second object of the present invention is to propose a real-time delivery server of 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.

In order to achieve the above object, a first embodiment of the present invention provides a method for delivering a media stream in real time, where the media stream is a sequence of media units generated in real time, and each media unit is associated with a generation time and/or a sequence number indicating a generation sequence, the method includes 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 the target media stream to be transmitted is determined according to the first type of parameters, the candidate media units to be transmitted are determined according to the second type of parameters, and the candidate media units to be transmitted are packaged into the media segment; and sending the media segment to the client.

The method for real-time delivery of the media stream generates the media segments in real time according to the request of the client and returns the media segments to the client so as to realize the delivery of the real-time 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 time length of the media segments can be controlled by the client through an active request, and 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, thereby effectively reducing the transmission delay and the overhead of the media stream, and further improving the transmission performance of the real.

In addition, the method for real-time delivery of a media stream according to the above embodiment of the present invention may further have the following additional technical features:

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 parameters, the candidate media units include default specified media units, and the default specified media units are media units in which sequence number intervals of all and latest media units in the target media stream are smaller than a first preset value, or media units in which generation time intervals of all and latest media units in the target media stream are smaller than a second preset value.

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 condition of a candidate media unit, the candidate media unit to be transmitted includes all media units in the target media stream that simultaneously satisfy all constraint conditions corresponding to the parameter of the second type.

Further, in an embodiment of the present invention, the second type of parameter includes a start sequence number, and a constraint condition corresponding to the start sequence number is: if the start sequence number is valid, the sequence number of the candidate media unit is subsequent to the start sequence number or equal to the start sequence number.

Further, in an embodiment of the present invention, the second type of parameter includes a start time, and the constraint condition corresponding to the start time is: if the start time is valid, the generation time of the candidate unit is after the start time.

Further, in an embodiment of the present invention, the second type parameter includes a unit number, and the constraint condition corresponding to the unit number is: if the number of units is valid, the number of the candidate media units does not exceed the number of the units; further, if the range of the candidate media units is not limited by other second type parameters carried by the media segment request, the sequence number interval between the candidate media units and the latest media unit is less than the number of the units.

Further, in an embodiment of the present invention, the second type of parameter includes a segment duration, and the constraint condition corresponding to the segment duration is: if the segment duration is valid, the generation time interval of the earliest and latest generated units of the candidate media units is less than the segment duration; further, if the range of the candidate media unit is not limited by other second type parameters carried by the media segment request, the generation time interval of the candidate media unit and the latest media unit is less than the segment duration.

further, in an embodiment of the present invention, the first type parameter includes a media stream identifier to specify the target media stream to be transmitted.

Further, in an embodiment of the present invention, the encapsulating the candidate media units to be transmitted into the media segment further includes: acquiring media stream index information, and packaging the media stream index information into the media segment, wherein the media stream index information contains a plurality of media stream description information belonging to the same content, and the media stream description information includes a media stream identifier and a media stream bit rate.

To achieve the above object, a second aspect of the present invention provides a server for delivering a media stream in real time, the media stream being a sequence of media units generated in real time, wherein each media unit is associated with a generation time and/or a sequence number indicating a generation sequence, the 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; and the media segment generating component generates media segments according to the media segment requests, wherein the target media stream to be transmitted is determined according to the first type of parameters, the candidate media units to be transmitted are determined according to the second type of parameters, the candidate media units to be transmitted are packaged into the media segments, and the media segments are sent to the client through the client interface component.

The real-time delivery server of the media stream generates the media segments in real time according to the request of the client and returns the media segments to the client so as to realize the delivery of the real-time 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 time length of the media segments can be controlled by the client through an active request, and 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 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, so that the transmission delay and the overhead of the media stream are effectively reduced, and the transmission performance of the real.

in addition, the real-time delivery server of the media stream according to the above embodiment of the present invention may further have the following additional technical features:

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, determine that 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, determine that the candidate media units include default specified media units, where the default specified media units are media units whose sequence number intervals between all of the target media stream and the latest media unit are smaller than a first preset value, or media units whose generation time intervals between all of the target media stream and the latest media unit are smaller than a second preset value.

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 condition of a candidate media unit, the candidate media unit to be transmitted includes all media units in the target media stream that simultaneously satisfy all constraint conditions corresponding to the parameter of the second type.

Further, in an embodiment of the present invention, the second type of parameter includes a start sequence number, and a constraint condition corresponding to the start sequence number is: if the start sequence number is valid, the sequence number of the candidate media unit is subsequent to the start sequence number or equal to the start sequence number.

Further, in an embodiment of the present invention, the second type of parameter includes a start time, and the constraint condition corresponding to the start time is: if the start time is valid, the generation time of the candidate unit is after the start time.

further, in an embodiment of the present invention, the second type parameter includes a unit number, and the constraint condition corresponding to the unit number is: if the number of units is valid, the number of the candidate media units does not exceed the number of the units; further, if the range of the candidate media units is not limited by other second type parameters carried by the media segment request, the sequence number interval between the candidate media units and the latest media unit is less than the number of the units.

Further, in an embodiment of the present invention, the second type of parameter includes a segment duration, and the constraint condition corresponding to the segment duration is: if the segment duration is valid, the generation time interval of the earliest and latest generated units of the candidate media units is less than the segment duration; further, if the range of the candidate media unit is not limited by other second type parameters carried by the media segment request, the generation time interval of the candidate media unit and the latest media unit is less than the segment duration.

further, in an embodiment of the present invention, the first type parameter includes a media stream identifier to specify the target media stream to be transmitted.

Further, in an embodiment of the present invention, the media segment generating component is further configured to acquire media stream index information, and encapsulate the media stream index information into the media segment, where the media stream index information includes multiple pieces of media stream description information belonging to the same content, and the media stream description information includes a media stream identifier and a media stream bit rate.

Further, in an embodiment of the present invention, the method further includes: at least one real-time media stream generation component for self-generating or receiving one or more real-time media streams from other devices.

In order 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 real-time delivery method of the 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 real-time delivery of 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 instructions of the computer program product, when executed by a processor, perform the real-time delivery method of a media stream as described in the above embodiments.

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 diagram of a method for real-time delivery of a media stream according to one embodiment of the invention;

Fig. 2 is a schematic diagram of a real-time delivery process for a client to continuously submit media segment requests according to an embodiment of the present invention;

Fig. 3 is a schematic structural diagram of a real-time delivery server of a media stream according to an embodiment of the present invention;

fig. 4 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 generated in real time 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 generated in real time. 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 a segment Sequence number (e.g., Media Sequence 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 real-time media stream is an RTP packet stream, the RTP header has both a Sequence Number (Sequence Number) field to indicate the Sequence of the RTP packet and a timestamp field to indicate 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.

The method of the embodiments of the present invention may be implemented for any kind of real-time media stream. In the following embodiments, the RTP real-time media stream or the MPEG2-TS real-time media stream is selected to illustrate the implementation method of the embodiments of the present invention. For an RTP real-time 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, the Sequence Number of a continuously generated RTP packet is circularly counted, and if the Sequence Number of the current packet is Seq, the Sequence Number of the next packet is (Seq + 1)% 65536, so that the Sequence Number is limited by the bit length in implementation, the situation that the Sequence Number size cannot reflect the Sequence order of the next packet possibly occurs, at the moment, whether the Sequence Number circularly counts or not can be judged according to the generation time of the media unit, and the Sequence relation and the interval of the Sequence numbers of the two media units can be accurately judged. For MPEG2-TS real-time streams, the TS stream may be divided into TS segments of fixed duration, such as around 1 second, in a manner similar to HLS/DASH, each TS segment may include multiple media frames, and then the segments are sequenced in the generation order as media units, and the timestamp of the first media frame contained in each segment indicates the generation time of the segment.

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 segmented in advance, but is generated by a 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 real-time 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 real-time 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 flow chart of a method for real-time delivery of a media stream according to an embodiment of the present invention.

as shown in fig. 1, the method for real-time delivery of a media stream is a sequence of media units generated in real time, wherein each media unit is associated with a generation time and/or a sequence number indicating a generation sequence, and the method includes the following steps:

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, etc.; control parameters that may be of the second type include: the starting sequence number, the starting time, the number of units, the segment duration and the like.

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/msreq?streamID=601”[req2]

GET“http://www.xxx-server.com/msreq?seqBegin=1005”[req3]

GET“http://www.xxx-server.com/msreq?timeBegin=31000”[req4]

GET“http://www.xxx-server.com/msreq?unitCount=8”[req5]

GET“http://www.xxx-server.com/msreq?segDuration=1000”[req6]

media segment request carrying two control parameters:

GET“http://www.xxx-server.com/msreq?streamID=602&seqBegin=1020” [req7]

GET“http://www.xxx-server.com/msreq?streamID=601&timeBegin=32000” [req8]

GET“http://www.xxx-server.com/msreq?seqBegin=1010&unitCount=5” [req9]

GET“http://www.xxx-server.com/msreq?timeBegin=31000&segDuration= 3000”[req10]

Media segment requests carrying three control parameters:

GET“http://www.xxx-server.com/msreq?streamID=601&seqBegin=1010& unitCount=5”[req11]

GET“http://www.xxx-server.com/msreq?streamID=601&timeBegin=33000& segDuration=3000”[req12]

in the URL of the request, the parameter names streamID, seqBegin, timeBegin, unit count, and segDuration respectively represent the media stream identifier, start sequence number, start time, unit number, and segment duration.

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 parameter is a first type parameter; if the parameters are the starting sequence number, the starting time, the number of units and the segment duration, the parameters are the second type of 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, a candidate media unit to be transmitted is determined according to the second type of parameter, and the candidate media unit to be transmitted is encapsulated 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 the target media stream to be transmitted according to the first type of parameters therein, determine the candidate media units to be transmitted according to the second type of parameters carried, 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.

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.

When the server receives continuous media segment requests from the client, the server continuously generates new media segments according to the requests of the client, the new media segments encapsulate a plurality of recently generated media units, the client analyzes the media segments, and then each media unit of the real-time media stream can be recovered, so that the real-time transmission of the media stream from the server to the client is realized, and the process is shown in fig. 2.

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.

It should be understood that the steps S101 and S104 are provided only for convenience of description, and are not intended to limit the execution order of the method.

The above is a detailed explanation of embodiment 1, and embodiment 2 will be described in detail below, and 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 media segment request does not carry the second type of parameters, the candidate media units include default specified media units, and the default specified media units are media units of which the sequence number intervals of all the latest media units in the target media stream are smaller than a first preset value, or media units of which the generation time intervals of all the latest media units in the target media stream are smaller than a second preset value.

Taking RTP real-time stream as an example, the 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 without any parameters, e.g., [ req1], the server can select one from the existing real-time media streams as the target media stream, and the candidate media units to be transmitted include the most recently generated 20 RTP packets (packet sequence numbers from 1001 to 1020) in the target media stream.

Taking TS real-time stream as an example, the media unit is a TS segment, and each TS segment is associated with a generation time, which is a timestamp of a first media frame in the TS segment. Assuming that the generation time of the newly generated TS segment is 33000 (unit is microsecond), and the second preset value is 3000, when the server receives a media segment request without any parameters, e.g., [ req1], the server can select one from the existing real-time media streams as the target media stream, and the candidate media unit to be sent includes the TS segment generated in the last 3 seconds of the target media stream, i.e., the TS segment whose generation time Tp is within the range (30000< Tp < — 33000).

By adopting the embodiment, each time the media segment request sent by the user returns a plurality of media units which are generated recently. And after the server continuously receives the media segment request, the recently generated media units are continuously delivered to the client.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种软件终端和对讲机进行语音对讲的系统及其方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类