Video stream sending method, device, equipment and medium based on RTP (real-time transport protocol)

文档序号:1046930 发布日期:2020-10-09 浏览:23次 中文

阅读说明:本技术 基于rtp协议的视频流发送方法、装置、设备和介质 (Video stream sending method, device, equipment and medium based on RTP (real-time transport protocol) ) 是由 叶力 于 2020-06-30 设计创作,主要内容包括:本申请属于研发管理技术领域,公开了一种基于RTP协议的视频流发送方法、装置、计算机设备及可读存储介质。所述方法包括根据视频流的时间戳以及系统时间,计算所述视频流中当前关键帧周期的时隙号;获取当前时隙号对应的当前时隙的已发送带宽,其中,所述已发送带宽为当前时隙已发送的数据包的数据量;判断所述已发送带宽是否小于目标数据量;并根据判断结果发送所述当前数据包。其中,所述视频流可存储于区块链中。采用本方法解决了现有技术中由于关键帧与非关键帧在数据体量上的巨大差异,导致发送带宽不平滑,不利于估算整个网络的带宽需求的技术问题。(The application belongs to the technical field of research and development management and discloses a video stream sending method and device based on an RTP (real-time transport protocol), computer equipment and a readable storage medium. The method comprises the steps of calculating the time slot number of a current key frame period in a video stream according to the time stamp and the system time of the video stream; acquiring a sent bandwidth of a current time slot corresponding to a current time slot number, wherein the sent bandwidth is the data volume of a data packet sent by the current time slot; judging whether the sent bandwidth is smaller than a target data volume; and sending the current data packet according to the judgment result. Wherein the video stream may be stored in a block chain. The method solves the technical problems that in the prior art, due to the huge difference of the key frames and the non-key frames in the data volume, the sending bandwidth is not smooth, and the estimation of the bandwidth requirement of the whole network is not facilitated.)

1. A method for transmitting a video stream based on an RTP protocol, the method comprising:

calculating the time slot number of the current key frame period in the video stream according to the timestamp and the system time of the video stream;

acquiring a sent bandwidth of a current time slot corresponding to a time slot number of a current key frame period, wherein the sent bandwidth is the data volume of a data packet sent by the current time slot;

judging whether the sent bandwidth is smaller than a target data volume; and are

And sending the current data packet according to the judgment result.

2. The method according to claim 1, wherein said calculating the time slot number of the current key frame period in the video stream according to the timestamp and the system time of the video stream comprises:

acquiring a preset time slot;

and calculating the time slot number of the current key frame period according to the system time, the timestamp and the preset time slot.

3. The method of claim 1, wherein the obtaining the sent bandwidth of the current timeslot corresponding to the timeslot number of the current key frame period comprises:

detecting whether the current time slot is a new time slot or not according to the counter;

if so, clearing the sent bandwidth;

and if the time slot is not the new time slot, acquiring the sent bandwidth.

4. The method of claim 1, prior to said determining whether said transmitted bandwidth is less than a target amount of data, further comprising:

determining the time slot number of the current key frame period according to the time slot number and the time stamp;

acquiring the actual bandwidth of the last key frame period;

acquiring the sending bandwidth of the current key frame period according to the actual bandwidth;

and distributing the sending bandwidth to each time slot evenly according to the number of the time slots to obtain the target data volume of each time slot.

5. The method of claim 4, wherein the obtaining the transmission bandwidth of the current key frame period according to the actual bandwidth comprises:

according to the formula:

TBW=(LBW×0.75+TBW×0.25)×GAIN×Max(1.0,logBL)

and calculating to obtain the sending bandwidth of the current key frame period, wherein the TBW on the right side of the equation equal sign is the sending bandwidth of the previous key frame period, the TBW on the right side of the equation equal sign is the sending bandwidth of the current key frame period, the LBW is the actual bandwidth, the GAIN is the sending bandwidth GAIN, and the BL is the sending buffer queuing time.

6. The method of claim 1, wherein the sending the current data packet according to the determination result comprises:

when the judgment result is that the sent bandwidth is not larger than the target data volume, sending the current data packet of the current key frame period in the current time slot; and are

Updating the data volume of the current data packet into the sent bandwidth, repeatedly judging whether the sent bandwidth is smaller than the target data volume, and sending the next data packet;

when the judgment result shows that the sent bandwidth is larger than the target data volume, stopping sending the data packet until the system time reaches the next time slot number; then

And taking the time slot corresponding to the next time slot number as the current time slot, and repeating the operations of acquiring the sent bandwidth, judging whether the sent bandwidth is smaller than the target data volume and sending the current data packet until all the data packets in the current key frame period are sent in sequence.

7. The method of any of claims 1-6, wherein the video stream is stored in a blockchain.

8. An apparatus for transmitting a video stream based on an RTP protocol, comprising:

the time slot module is used for calculating the time slot number and the time slot number of the current key frame period in the video stream according to the time stamp and the system time of the video stream;

the bandwidth module is used for acquiring a sent bandwidth of a current time slot corresponding to the current time slot number, wherein the sent bandwidth is the data volume of a data packet sent by the current time slot;

the judging module is used for judging whether the sent bandwidth is smaller than the target data volume SBW; and are

And the sending module is used for sending the current data packet according to the judgment result.

9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.

Technical Field

The present application relates to the field of research and development management technologies, and in particular, to a video stream transmission method and apparatus based on an RTP protocol, a computer device, and a storage medium.

Background

In a video stream, the intervals of frames are generally the same, but the amount of data after encoding is very different. For example, in h.264 coding, key frames (IDR, large data amount) may be several times, even hundreds of times different from Non-key frames (Non-IDR, small data amount). When a sending end strictly matches a timestamp (the timestamp in an RTP packet header indicates the time when a video frame with load data belongs to which the video frame is expected to be played back) for sending, an obvious peak-valley effect exists on a sending bandwidth, so that network load imbalance is caused, and meanwhile, due to the characteristic of unreliable UDP protocol, a large number of burst key frame data packets easily cause buffer overflow of a receiving end and packet loss. In a single key frame period, due to the huge difference of the key frame and the non-key frame in the data volume, the sending bandwidth is not smooth, the bandwidth requirement of the whole network is not favorably estimated, the wave crest overlapping of a plurality of data volumes is increased, and the actual utilization rate of the bandwidth of the whole network is reduced.

Disclosure of Invention

Based on this, the application provides a video stream sending method, device, computer equipment and storage medium based on an RTP protocol, so as to solve the technical problems that in the prior art, due to the huge difference of the key frames and the non-key frames in the data volume, the sending bandwidth is not smooth, and the estimation of the bandwidth requirement of the whole network is not facilitated.

A method for transmitting a video stream based on an RTP protocol, the method comprising:

calculating the time slot number of the current key frame period in the video stream according to the timestamp and the system time of the video stream;

acquiring a sent bandwidth of a current time slot corresponding to a current time slot number, wherein the sent bandwidth is the data volume of a data packet sent by the current time slot;

judging whether the sent bandwidth is smaller than a target data volume SBW; and are

And sending the current data packet according to the judgment result.

An apparatus for transmitting a video stream based on an RTP protocol, the apparatus comprising:

the time slot module is used for calculating the time slot number and the time slot number of the current key frame period in the video stream according to the time stamp and the system time of the video stream;

the bandwidth module is used for acquiring a sent bandwidth of a current time slot corresponding to the current time slot number, wherein the sent bandwidth is the data volume of a data packet sent by the current time slot;

the judging module is used for judging whether the sent bandwidth is smaller than the target data volume SBW; and are

And the sending module is used for sending the current data packet according to the judgment result.

A computer device comprising a memory and a processor, and a computer program stored in said memory and executable on said processor, said processor implementing the steps of the above-mentioned video streaming method based on the RTP protocol when executing said computer program.

A computer-readable storage medium, which stores a computer program that, when executed by a processor, implements the steps of the above-described video streaming method based on the RTP protocol.

According to the video stream transmitting method, the device, the computer equipment and the storage medium based on the RTP protocol, the transmitting bandwidth of each time slot is controlled in the next key frame period through dynamic calculation at the receiving node according to the real-time bandwidth and the average bandwidth, so that data packets of all key frames including the current key frame are transmitted in a smooth mode, the peak valley effect of the transmitting bandwidth is eliminated, even if the key frame and the non-key frame have great difference in the amount of data, the transmitting bandwidth can be guaranteed to be smooth, and the bandwidth requirement of the whole network can be estimated.

Drawings

In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.

Fig. 1 is a schematic application environment diagram of a video streaming method based on an RTP protocol according to an embodiment of the present application;

fig. 2 is a schematic flowchart of a video stream transmission method based on an RTP protocol according to an embodiment of the present application;

FIG. 3 is a logic flow diagram of FIG. 2;

FIG. 4 is a graph of bandwidth after transmission;

fig. 5 is a schematic flowchart of another embodiment of a video stream sending method based on an RTP protocol according to an embodiment of the present application;

fig. 6 is a schematic diagram of a video streaming apparatus based on an RTP protocol according to an embodiment of the present application;

FIG. 7 is a diagram of a computer device in one embodiment.

Detailed Description

Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.

Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.

In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The video stream transmission method based on the RTP protocol provided by the embodiment of the invention can be applied to the application environment shown in fig. 1. The application environment may include a terminal 102, a network for providing a communication link medium between the terminal 102 and the server 104, and a server 104, wherein the network may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.

A user may use the terminal 102 to interact with the server 104 over a network to receive or send messages, etc. The terminal 102 may have installed thereon various communication client applications, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.

The terminal 102 may be various electronic devices having a display screen and supporting web browsing, including but not limited to a smart phone, a tablet computer, an e-book reader, an MP3 player (Moving Picture Experts Group audio Layer III, mpeg compression standard audio Layer 3), an MP4 player (Moving Picture Experts Group audio Layer IV, mpeg compression standard audio Layer 4), a laptop portable computer, a desktop computer, and the like.

The server 104 may be a server that provides various services, such as a background server that provides support for pages displayed on the terminal 102.

It should be noted that the video stream transmission method based on the RTP protocol provided in the embodiment of the present application is generally executed by a server/terminal, and accordingly, the video stream transmission apparatus based on the RTP protocol is generally disposed in a server/terminal device. The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices

It should be understood that the number of terminals, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.

Wherein, the terminal 102 communicates with the server 104 through the network. The server 104 calculates a time slot number of a current key frame period in the video stream according to a timestamp of the video stream and the system time, acquires a sent bandwidth corresponding to the time slot, judges the sent bandwidth and a target data volume, and sends a current data packet according to a judgment result, wherein the current data packet can be sent to the terminal 102 or other storage nodes on the server. The terminal 102 and the server 104 are connected through a network, the network may be a wired network or a wireless network, the terminal 102 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.

In an embodiment, as shown in fig. 2, a video streaming sending method based on an RTP protocol is provided, which is described by taking the method as an example of being applied to a server in fig. 1, and includes the following steps:

step 202, calculating the time slot number of the current key frame period in the video stream according to the time stamp of the video stream and the system time.

Key frame period: the timestamp difference of two adjacent key frames.

Key frame cycle Bandwidth (BW): the total amount of data of all frames in the key frame period/key frame period;

specifically, the calculation method of the slot number is as follows:

acquiring a preset time slot; and calculating the time slot number SegId of the current key frame period according to the system time, the timestamp and the preset time slot.

For example, when the preset time slot is set to 10ms, the system time can be taken, and modulo calculation is performed on the preset time slot of 10ms, that is, the length of one time slot is set to 10ms, and after the length is determined, how many time slots are included in one key frame period can be calculated according to the time stamp on the video stream, and the time slot number corresponding to each time slot on the system. For example, in a typical high definition H264 stream, the bandwidth is generally several hundred KB, several KB needs to be transmitted every 10ms on average, and a full RTP packet is 1.5KB, so that several to more than ten packets per slot easily exhibit the control effect.

If a fixed time interval is set as a statistical period unit for controlling the amount of transmitted data, for example, 10ms, the purpose of this embodiment is to control the average number of packets per slot to be about 10 (5 to 15) and to be both too large and too small, which affects the effect, compared with dividing 1 second into 100 control units.

It is emphasized that, to further ensure the privacy and security of the video stream information, the video stream information may also be stored in a node of a block chain.

Step 204, acquiring a sent bandwidth of the current time slot corresponding to the time slot number of the current key frame period, wherein the sent bandwidth is a data volume of a data packet sent by the current time slot.

Detecting whether the current time slot is a new time slot or not according to the counter; if so, clearing the sent bandwidth; and if the time slot is not the new time slot, acquiring the sent bandwidth. A counter can be used to detect whether the current time slot is a new time slot; the counter is used for recording the time slot number of the current time slot, and every time a new time slot is entered, the counter is added with a number. In this embodiment, each time a new time slot is entered, the sent bandwidth is cleared to 0, and then each time a data packet is sent, the size of one data packet is added, and the bandwidth that has been sent is cleared after entering the next time slot. In this way, the transmitted bandwidth of the current slot is obtained.

In step 206, it is determined whether the transmitted bandwidth is less than the target data amount.

The target amount of data SBW is the size of the bandwidth that the current slot is expected to transmit.

If the sent bandwidth is smaller than the target data amount SBW, the current data packet is sent with the residual bandwidth. For example, if 1500 data packets are to be transmitted, 7500< SBW 8000, a data packet with size 1500 is transmitted in the current time slot, and although the transmitted bandwidth of the final current time slot is larger than the target data amount, a new data packet is directly transmitted through a new time slot at the next judgment, so as to prevent the situation that the data packets are all transmitted in the same time slot to cause a peak.

Wherein, each specific time point in the system time axis has a determined gap number, which is called SegId; the whole working process takes the starting point of the algorithm as the origin, and the actual time lapse process of the whole working process forms a time axis. The target bandwidth, i.e. the key frame period bandwidth BW, is evenly distributed to each gap, and the gap target data amount is called SBW.

And step 208, sending the current data packet according to the judgment result.

And if the judgment result is less than the target data volume SBW, sending the current data packet in the current time slot, updating the data volume of the current data packet into the sent bandwidth of the current time slot, and repeatedly judging whether the sent bandwidth is less than the target data volume SBW or not to send the next data packet.

After the current data packet is sent, the next data packet is processed, so that the judgment process needs to be repeated to send other data packets in the key frame period. Since all the data packets to be sent are in one queue, the embodiment processes the data packets one by one.

And if so, suspending the sending of the data packets until the current time slot is finished, taking the next time slot as the current time slot, repeatedly acquiring the sent bandwidth of the current time slot, judging whether the sent bandwidth of the current time slot is smaller than the target data volume SBW, and sending the current data packets until all the data packets of the current key frame period are sent in sequence.

The algorithm of this embodiment is to run a video stream processing node of a server to process and control a video stream that is continuously sent from a sending end, where the sending end is suspended to send the video stream to a receiving end during processing and control of this node, and during a waiting period, this node does not send data outward, but the sending end is free to send, so this node is still receiving data, and preprocesses the received data, and puts the data that needs to be forwarded into a packet queue to be sent). Waiting for the transmission equivalent to a forced pause occurs to indicate that too many packets are expected to be transmitted in the time slot, which would result in a peak in the transmitted data if the transmission is not paused. After the pause, the data is suspended to be sent out in the subsequent time slot (or a plurality of time slots), so that the trough of the subsequent time slot is filled, but the total amount of the data sent in each key frame period is kept unchanged.

Fig. 3 is a flow chart of data packet transmission:

wherein LEN is the size of a data packet and is expressed in bytes;

CurSegID is the slot number of the current slot, and CalcSegID () is a function of the current slot number.

Used is the amount of data that has been transmitted in the current slot, and SBW is the amount of data that can be transmitted in the current slot, referred to as the target amount of data.

Sleep is a process that needs to wait when waiting for the next time slot when the current time slot cannot send the current data packet.

As shown in fig. 3, the flow in the drawing is explained by a specific example:

if, the parameter values at the beginning are:

SegId=158048364783

SBW 8000 byte

Used 6000 (this slot has sent 6000 bytes);

1) bag 1 (cycle 1)

Let LEN 1500 bytes; current time 1580483647833(ms), currsegid 158048364783, currsegid SegId (also in the same slot);

checking the usage amount, namely the sent bandwidth of the current time slot;

if Used (6000) < SBW (8000), indicating that the current timeslot can be transmitted, updating the size of the data packet to be transmitted into the transmitted bandwidth, where Used is Used + LEN, i.e. Used is 6000+1500 is 7500;

and sending the data packet.

2) Bag 2 (cycle 2)

Let LEN 1300 bytes;

current time 1580483647835(ms), currsegid 158048364783 is calculated;

currsegid ═ SegId (also in the same slot);

checking the usage amount, using (7500) < SBW (8000), and sending, namely using ═ Used + LEN, namely using ═ 7500+1300 ═ 8800;

and sending the data packet.

2) Packet 3 (cycle 3);

assuming LEN 1300 bytes, current time 1580483647837(ms), currsegid 158048364783 is calculated

Currsegid ═ SegId (also in the same slot); checking the usage amount, Used (8800) > -SBW (8000);

has exceeded, waits until the next Seg (1580483647840 milliseconds, 3ms away) begins;

namely Sleep (3 ms);

after Sleep is finished (4 th cycle), current time 1580483647840(ms), currsegid is calculated to be 158048364784;

CurSegId < > SegId (has entered another slot), update SegId ═ CurSegId (158048364784)

Updating Used LEN (1300);

and sending the data packet.

Wherein, in fig. 3: when the currsegid is set to SegID, No, it means that a new slot is now entered.

Two operations are performed:

SegId ═ CurSegId; updating the time slot number to the current actual time slot;

Used=LEN;

having decided to send this packet, the Used (i.e., counter) is set to the size of the current packet (the zero clearing is omitted from the figure).

The bandwidth curve after the video stream is transmitted in the above manner is shown in fig. 4.

In the video stream transmission method based on the RTP protocol, the receiving node dynamically calculates according to the real-time bandwidth, and controls the transmission bandwidth of each time slot in the next key frame period according to the average bandwidth, so that data packets of all key frames including the current key frame are transmitted in a smooth mode, and the peak-valley effect of the transmission bandwidth is eliminated.

In one embodiment, as shown in fig. 5, before step 206, the method further includes:

step 502, determining the number of time slots of the current key frame period according to the time slot number and the time stamp.

Step 504, obtain the actual bandwidth of the last key frame period.

Step 506, obtaining the transmission bandwidth of the current key frame period according to the actual bandwidth.

Further, the following may be obtained according to equation (1):

TBW=(LBW×0.75+TBW×0.25)×GAIN×Max(1.0,log BL) (1)

and calculating to obtain the sending bandwidth of the current key frame period, wherein the TBW on the right side of the equal sign of the formula (1) is the sending bandwidth of the previous key frame period, the TBW on the left side of the equal sign of the formula (1) is the sending bandwidth of the current key frame period, the LBW is the actual bandwidth, the GAIN is the sending bandwidth GAIN, and the BL is the sending buffer queuing time.

Specifically, GAIN of the GAIN for the transmission bandwidth, 1.0, is slightly higher than the transmission bandwidth for transmission, so as to avoid data backlog, because fluctuation of the actual bandwidth is not controlled by the node, and in order to avoid backlog as much as possible, the GAIN greater than 1.0 is introduced, and the control value is moderately increased. In equation (1), when the first time the packet is sent, an initial TBW needs to be set, such as 300KB/s, which is also generally obtained empirically.

When calculating the sending bandwidth TBW of the current key frame period, adding a GAIN, which is moderately increased and is used for adjusting the bandwidth stabilizing strength of the algorithm, wherein the larger value tends to weaken the effect of the algorithm and reduce the time delay caused by the algorithm. Since TBW is calculated from past statistics, its reaction is always delayed for the case where the amount of data will likely increase, so it is adjusted up moderately in the calculation to mitigate this effect.

And sending a buffer queue length (BL), wherein BL is the number of video frames in the buffer. The node is used as a forwarding node of the video stream and always receives data sent from the upstream, so that the data need to be buffered to a sending queue before being sent to the downstream. The actual process may include data collection, data parsing, processing, packing before transmission, enqueuing for transmission, and scheduling a time point for transmission by an algorithm.

Specifically, the weights of LBW and TBW are actual test empirical values, and increasing the weight of TBW can reduce the bandwidth variation of adjacent control periods.

Since the video stream will actually change in bandwidth due to changes in image content, which often represents a temporal continuity, LBW (i.e., the last key frame period actual value) is assigned a greater weight (0.75) to more quickly track the matching change trend. The last period of the calculated TBW, which is a history, is recalculated after the start of the period. When recalculating, the historical value is kept according to a certain weight (0.25) to avoid fluctuation caused by overlarge. Considering more last cycle statistics (LBW), there is often continuity in considering bandwidth changes, which allows faster tracking of changes.

Step 508, evenly distributing the transmission bandwidth to each time slot according to the number of the time slots to obtain the target data volume of each time slot.

After the sending bandwidth is obtained through calculation, the sending bandwidth can be evenly distributed to each time slot according to the number of the time slots, and the target data volume of each practice is obtained.

Specifically, each specific time point in the time axis has a certain gap number, called SegId; the whole working process takes the starting point of the algorithm as the origin, and the actual time lapse process of the whole working process forms a time axis. The target bandwidth, i.e. the current key frame period Bandwidth (BW), is evenly distributed to each gap, and the gap target data amount is called SBW.

In this embodiment, the target data amount of each time slot of the current key frame period is calculated according to the transmission bandwidth and the actual transmission bandwidth of the previous key frame, and the current data packet is transmitted, so that the receiving end can receive the data packet transmitted by the node in a smooth manner, thereby stabilizing load fluctuation, preventing overflow of the receiving buffer caused by burst traffic, and reducing the probability of packet loss. This effect will be more pronounced for low processing power devices. Meanwhile, smooth bandwidth occupation also has obvious benefits on each intermediate forwarding node of the whole network, is beneficial to more accurately estimating bandwidth requirements, reduces QoS degradation caused by the overlapping of wave crests of a plurality of concurrent data streams, and finally achieves higher actual utilization rate of the bandwidth of the whole network.

It should be understood that, although the steps in the flowcharts of fig. 2 and 5 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2 and 5 may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or stages is not necessarily sequential, but may be performed alternately or alternately with other steps or at least some of the sub-steps or stages of other steps.

In one embodiment, as shown in fig. 6, a video streaming transmission apparatus based on an RTP protocol is provided, where the video streaming transmission apparatus based on the RTP protocol corresponds to the video streaming transmission method based on the RTP protocol in the foregoing embodiments one to one, and includes:

the time slot module 602 is configured to calculate a time slot number and a time slot number of a current key frame period in the video stream according to the timestamp of the video stream and the system time.

The bandwidth module 604 is configured to obtain a sent bandwidth of a current time slot corresponding to a time slot number of a current key frame period, where the sent bandwidth is a data amount of a data packet sent by the current time slot.

A determining module 606, configured to determine whether the sent bandwidth is smaller than the target data amount SBW; and

a sending module 608, configured to send the current data packet according to the determination result.

It is emphasized that, to further ensure the privacy and security of the video stream information, the video stream information may also be stored in a node of a block chain.

Further, the timeslot module 602 includes:

and the time slot submodule is used for acquiring a preset time slot.

And the sequence number submodule is used for calculating the time slot number of the current key frame period according to the system time and the preset time slot.

Further, a bandwidth module 604, comprising;

the detection submodule is used for detecting whether the current time slot is a new time slot or not;

an emptying submodule, configured to empty the sent bandwidth if the time slot is a new time slot;

and the acquisition submodule is used for acquiring the sent bandwidth if the time slot is not the new time slot.

Further, before the determining module, the apparatus for transmitting a video stream based on an RTP protocol further includes:

the quantity module is used for determining the time slot quantity of the current key frame period according to the time slot number and the time stamp;

the bandwidth module is used for acquiring the actual bandwidth of the previous key frame period;

the calculation module is used for acquiring the sending bandwidth of the current key frame period according to the actual bandwidth;

and the target module is used for evenly distributing the sending bandwidth to each time slot according to the number of the time slots to obtain the target data volume of each time slot.

Further, the sending module 608 includes:

the first judgment submodule is used for sending the current data packet of the current key frame period in the current time slot when the judgment result shows that the sent bandwidth is not larger than the target data amount; and

the first sending submodule is used for updating the data volume of the current data packet into the sent bandwidth, repeatedly judging whether the sent bandwidth is smaller than the target data volume or not and sending the next data packet;

the second judgment submodule is used for suspending sending the data packet until the system time reaches the next time slot number when the judgment result is that the sent bandwidth is larger than the target data amount; then

And the second sending submodule is used for taking the time slot corresponding to the next time slot number as the current time slot, and repeating the operations of acquiring the sent bandwidth, judging whether the sent bandwidth is smaller than the target data volume and sending the current data packet until all the data packets in the current key frame period are sent in sequence.

According to the video stream transmitting device based on the RTP protocol, the transmitting bandwidth of each time slot is controlled in the next key frame period according to the average bandwidth through dynamic calculation at the receiving node according to the real-time bandwidth, so that data packets of all key frames including the current key frame are transmitted in a smooth mode, and the peak-valley effect of the transmitting bandwidth is eliminated.

In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing the video stream. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to realize a video stream transmitting method based on an RTP protocol, and the transmitting bandwidth of each time slot is controlled in the next key frame period according to the real-time bandwidth dynamic calculation at a receiving node and the average bandwidth, so that the data packets of all key frames including the current key frame are transmitted in a smooth mode, and the peak-valley effect of the transmitting bandwidth is eliminated.

As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.

In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and the computer program when executed by a processor implements the steps of the video stream transmission method based on the RTP protocol in the above-described embodiment, for example, the steps 202 to 208 shown in fig. 2, or the processor implements the functions of the modules/units of the video stream transmission apparatus based on the RTP protocol in the above-described embodiment, for example, the functions of the modules 502 to 508 shown in fig. 5. In order to avoid repetition, the sending bandwidth of each time slot is controlled in the next key frame period by dynamically calculating the receiving node according to the real-time bandwidth and according to the average bandwidth, so that the data packets of all the key frames including the current key frame are sent in a smooth mode, and the peak-valley effect of the sending bandwidth is eliminated.

It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.

It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.

The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.

The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for those skilled in the art, without departing from the spirit and scope of the present invention, several changes, modifications and equivalent substitutions of some technical features may be made, and these changes or substitutions do not make the essence of the same technical solution depart from the spirit and scope of the technical solution of the embodiments of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:多媒体内容投射方法、装置、电子设备

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!

技术分类