WO2020192152A1 - 视频传输的方法、根节点、子节点、p2p服务器和系统 - Google Patents

视频传输的方法、根节点、子节点、p2p服务器和系统 Download PDF

Info

Publication number
WO2020192152A1
WO2020192152A1 PCT/CN2019/120024 CN2019120024W WO2020192152A1 WO 2020192152 A1 WO2020192152 A1 WO 2020192152A1 CN 2019120024 W CN2019120024 W CN 2019120024W WO 2020192152 A1 WO2020192152 A1 WO 2020192152A1
Authority
WO
WIPO (PCT)
Prior art keywords
video
node
sub
frame
stream
Prior art date
Application number
PCT/CN2019/120024
Other languages
English (en)
French (fr)
Inventor
戴满佐
Original Assignee
广州华多网络科技有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 广州华多网络科技有限公司 filed Critical 广州华多网络科技有限公司
Publication of WO2020192152A1 publication Critical patent/WO2020192152A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications

Definitions

  • the video package corresponding to each substream subscription request is determined among the multiple video packages.
  • the method also includes:
  • a video transmission method includes:
  • a video packet determined by the node according to the sub-stream subscription request where the video packet is obtained by splitting a video frame by the node according to a preset length, and the video frame is received by the node from the content distribution Network CDN server;
  • the video packet also carries the first time stamp of the video frame to which the video packet belongs, the packet sequence number within the frame of the video packet, and the previous frame of the video frame to which the video packet belongs.
  • the method further includes:
  • the method further includes:
  • the child node can determine the node to which the sub-stream subscription request is sent.
  • the total number of sub-streams of the subscription request is used by the node to determine the video packet to be sent to the child node.
  • the video packet is obtained by splitting the video frame by the node according to a preset length, and the video frame is obtained by the node Received from the CDN server of the content distribution network.
  • a root node switching notification is sent to the target child node.
  • the method further includes:
  • the root node and child nodes can be dynamically adjusted.
  • a root node for video transmission includes:
  • the receiving module is used to receive the streaming media FLV rectification sent by the CDN server of the content distribution network;
  • each video frame in the FLV rectification is divided into a plurality of video packets according to a preset length
  • the plurality of divided video packets are sequentially numbered, and whenever the divided video frame is an I frame, the divided I frame is obtained Renumber the video package;
  • the determining module is used to:
  • the receiving module is further used for:
  • the sending module is also used for:
  • a retransmission request is sent to the node sending the first video packet and/or the node sending the first video frame.
  • the first deleting module is configured to: if the difference between the time stamp of the second video packet currently received and the third time stamp is greater than the first preset threshold, or the time stamp of the second video packet currently received is greater than the fourth If the time stamp difference is greater than the first preset threshold, the second video packet is deleted, where the third time stamp is the time stamp of the video packet received within the first preset time period before the current time point.
  • the fourth time stamp is the maximum value of the time stamps of the video packets received within the first preset time period before the current time point.
  • the receiving module is also used to obtain streaming media FLV rectification from the CDN server.
  • the receiving module is further used for:
  • a P2P server for video transmission includes:
  • Fig. 1 is a system diagram of a video transmission provided by an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of a video transmission method provided by an embodiment of the present disclosure.
  • FIG. 7 is a schematic diagram of a node conversion provided by an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of a root node for video transmission provided by an embodiment of the present disclosure.
  • FIG. 9 is a schematic structural diagram of a child node of video transmission provided by an embodiment of the present disclosure.
  • FIG. 13 is a schematic structural diagram of a node provided by an embodiment of the present disclosure.
  • the current state is the FLV node
  • the connection can be established with the P2P server by logging in to the P2P server.
  • the P2P server can subsequently determine the root node, the child nodes, and provide a node list for the child nodes (described later).
  • Figure 2 above is a simplified diagram of an embodiment of the present disclosure.
  • an overall scheme diagram is also provided:
  • the retransmission server can establish a connection with the child node to retransmit audio and video packets (including audio and video packets) for the child node.
  • the SM server can establish a connection with the AP server, and is used to issue the URL (Uniform Resource Locator) of the CDN server's line.
  • the VC server can establish a connection with the AP server to provide nodes with P2P server information.
  • AP The server can be connected to the node to provide a bridge between the node and the P2P server.
  • the current state is the FLV node
  • the URL of the CDN server can be obtained through the AP server, and then the FLV rectification is obtained based on the URL, and the VC server requests to connect to the P2P server.
  • the node receives the address of the P2P server, it can log in to the P2P server through the AP server.
  • the P2P server can subsequently determine the root node, the child nodes, and provide a node list for the child nodes (described later).
  • the embodiments of the present disclosure may be applicable to the process of multiple nodes requesting video frames.
  • the host terminal the terminal used by the host
  • the CDN server can send FLV rectification to the connected root node (the terminal used by the user in the live room), and the root node can send the video packet in the video frame to the child node that subscribes to the sub-stream, the child node It is also possible to send the video packet in the video frame to the child node that subscribes to the substream.
  • Step 501 The sub-node sends a sub-stream subscription request to the node, where the sub-stream subscription request carries the sub-stream number and the total number of sub-streams.
  • the child node When the child node receives the feedback information, it can record the receiving time point, then calculate the difference between the receiving time point and the sending time point, and obtain the total number of substreams, and select the total number of substreams with the smallest difference from the nodes in the node list A node is determined as the node to which the sub-stream subscription request is sent. In this way, the node to which the sub-stream subscription request is sent can be determined, that is, the node that subscribes to the sub-stream can be determined.
  • the root node when it does not receive certain audio frames and video frames in the FLV rectification, it can send a retransmission request to the CDN server to request retransmission of the unreceived audio frames and video frames.
  • the CDN server may establish a TCP connection with the root node through a three-way handshake, and send FLV rectification to the root node through TCP.
  • Step 503 The root node divides each video frame in the FLV rectification into multiple video packets according to a preset length.
  • multiple divided video packets may be sequentially numbered, and whenever the divided video frame is an I frame, the numbering of the divided video packets must be restarted.
  • video frame 1 there are 4 consecutive video frames
  • video frame 2 video frame 3, and video frame 4.
  • Video frame 3 is I frame
  • Video packets the number of video packets in video frame 1 are 0, 2, 4, 6, and the number of video packets in video frame 2 are 8, 10, 12, and 14, and video frame 3 is an I frame, which needs to be renumbered.
  • the video packets in frame 3 are numbered 0, 2, 4, and 6, and the video packets in video frame 4 are numbered 8, 10, 12, and 14.
  • each GOP is renumbered, that is, the I frame is renumbered.
  • the root node when the root node splits the video frame, it will also determine whether a sub-stream subscription request is received. If a sub-stream subscription request is received, the video frame will be split according to the processing in step 503 , If the sub-stream subscription request is not received, the split video frame will not be processed.
  • the root node may receive the sub-stream subscription request sent by the sub-node, and then based on the sub-stream subscription request, determine the video package corresponding to each received sub-stream subscription request among multiple video packages.
  • the root node may determine the video package corresponding to each sub-stream subscription request among multiple video packages according to the received sub-stream subscription request and the number of the video package.
  • the first time stamp of the video frame is DTS (Decoding Time Stamp).
  • DTS Decoding Time Stamp
  • the significance of this time stamp is to tell the player when to decode this frame of data.
  • the second time stamp of the previous video frame is also DTS.
  • the number of video packets with the first time stamp can be determined, and since the number of video packets contained in the video frame is carried, the number of video packets with the first time stamp can be determined Compare with the number of video packets carried. If the number of video packets with the first time stamp is less than the number of video packets carried, it means that there is a video packet loss. If the number of video packets with the first time stamp is equal to the number of videos carried The number of packets indicates that the video packets in the video frame are received completely. In addition, since the second time stamp of the previous video frame is carried, the adjacent relationship between the video frames on the time stamp can be established, and the missing video frame can be determined.
  • Step 507 The child node composes a video stream according to the received video packet, and plays the video stream.
  • the child node after receiving the video packet, can compose the video packet into a video frame, compose the video frame into a video stream, and play the video stream.
  • the root node can determine the sub-stream number in the received sub-stream subscription request (which can be pre-configured). If the sub-stream number in the first sub-stream subscription request is the sub-stream number for sending audio frames, it can send an audio frame to the first sub-stream.
  • the node to which the stream subscription request belongs sends the audio frame in the FLV rectification.
  • the number of substreams for sending audio frames can be two (that is, two-way push audio frames). For example, when the total number of substreams is 15, the substream number for sending audio frames is 13 and 14, when the child node receives an audio frame with the same time stamp, one of them can be deleted.
  • the embodiment of the present disclosure also provides processing of receiving audio frames by the child node and processing of how to play the audio frames.
  • the corresponding processing may be as follows:
  • the child node can receive audio frames. Since each audio frame carries the timestamp of the current audio frame and the timestamp of the previous audio frame, a continuous relationship between the timestamps of the audio frame can be established. Then first arrange the video packets with the same time stamp in the order of the packet sequence number in the video packet from small to large to form a video frame, and then according to the time stamp of the video frame carried by the video packet and the time stamp of the previous video frame , To establish a continuous relationship between video frames. Then, according to the continuous relationship of the time stamp of the video frame and the continuous relationship of the time stamp of the audio frame, the audio and video stream composed of the video frame and the audio frame is played back.
  • the above is the processing of the root node when the root node receives the sub-stream subscription request. If the sub-node receives the sub-stream subscription request sent by other sub-nodes, the processing process of the sub-stream subscription request received by the root node is completely the same. It is the same and will not be repeated here.
  • the received The I frame with the smallest timestamp in the video frame is composed of the video packet of the I frame and the video packet of the video frame after the I frame, and the video stream is played.
  • processing for retransmission of video packets is also provided, and the corresponding processing may be as follows:
  • the retransmission process can be performed.
  • two maps can be used to record and maintain the continuous relationship of timestamps and the relationship of request timestamps:
  • the retransmission server when using the retransmission server for retransmission, it is also possible to first determine whether the node retransmission is started, and the corresponding processing can be as follows:
  • the node retransmission when the retransmission interval is reached, if the node retransmission starts, it indicates that the video packet can be retransmitted from the node, and a retransmission request can be sent to the node that sent the first video packet, so that the node can send the video packet again. It is also possible to send a retransmission request to the node that sent the first video frame.
  • the first preset duration can be preset, stored in the live broadcast application, and installed on the node along with the live broadcast application.
  • the first preset threshold may also be preset, and stored in the live broadcast application, and installed on the node along with the live broadcast application.
  • the absolute value of the difference between the time stamp of the currently received second video packet and the third time stamp can be determined, and the relationship between the absolute value of the difference and the first preset threshold can be determined, and if the difference is greater than the first preset By setting the threshold, it can be determined that the second video packet is an illegal video packet, and the second video packet can be deleted.
  • the absolute value of the difference between the time stamp of the second video packet and the fourth time stamp may be determined, and the relationship between the absolute value of the difference and the first preset threshold may be determined, and if the absolute value of the difference is greater than the first preset By setting the threshold, it can be determined that the second video packet is an illegal video packet, and the second video packet can be deleted. In this way, since the time stamp difference of the video packets received in a short time is not particularly large, if it is particularly large, it means that it is an illegal video packet.
  • the absolute value of the difference between the time stamp of the currently received second audio frame and the fifth time stamp can be determined, and the relationship between the absolute value of the difference and the fourth preset threshold can be determined, and if the difference is greater than the fourth preset
  • the second audio frame can be determined to be an illegal audio frame, and the second audio frame can be deleted.
  • the absolute value of the difference between the time stamp of the second audio frame and the fourth time stamp may be determined, and the relationship between the absolute value of the difference and the first preset threshold may be determined, and if the absolute value of the difference is greater than the fourth preset
  • the second audio frame can be determined to be an illegal audio frame, and the second audio frame can be deleted. In this way, since the time stamps of the audio frames received in a short period of time are not particularly different, if they are particularly large, it means that they are illegal audio frames.
  • the preset number can be preset and stored in the root node.
  • the maximum value of the preset number can be 20, the minimum value can be 0, and generally 5 can be taken.
  • the child node can send a retransmission request of the audio frame to the retransmission server, which carries the timestamp of the audio frame and the URL of the CDN server.
  • the retransmission server After the retransmission server receives it, it can find the audio frame based on the URL of the CDN server, then determine the audio frame with the timestamp in the audio frame, and send it to the child node.
  • the child node can send a retransmission request of the audio frame to the node that sent the audio frame, which carries the timestamp of the audio frame and the URL of the CDN server. After the node receives it, it can find the audio frame based on the URL of the CDN server, then determine the audio frame with the timestamp in the audio frame, and send it to the child node.
  • the embodiment of the present disclosure also provides a child node switching process, and the corresponding process may be as follows:
  • the P2P server determines the amount of data sent by each node within the fourth preset period of time before the current time point; if the amount of data corresponding to the target root node is less than the preset value, it sends a child node switching notification to the target root node.
  • the root node receives the child node switching notification, and if the child node switching condition is met, it subscribes to the substream from other nodes and disconnects from the CDN server.
  • the child node switching conditions can be preset and stored in the root node, usually installed on the node along with the live broadcast application.
  • the node switching conditions when judging whether the node switching conditions are met, it can also be judged whether it can be connected to the retransmission server. If the retransmission function of the current node is not enabled and cannot be connected to the retransmission server, the child node switching conditions are not met, then no Perform sub-node switching processing (that is, do not subscribe to other nodes to sub-streams, nor disconnect the connection with the CDN server). If the retransmission function of the current node is enabled, no matter whether the retransmission server can be connected or not, the child node switching process can be performed (subscribing to the substream from other nodes and disconnecting from the CDN server).
  • a processing procedure of root node switching is also provided, and the corresponding processing may be as follows:
  • the child node receives the root node switching notification, sends a sub-stream unsubscribe request to the root node subscribed to the sub-stream, establishes a connection with the CDN server of the content distribution network, and obtains the streaming media FLV rectification from the CDN server.
  • the preset value can be preset and installed on the node along with the live broadcast application.
  • the P2P server can periodically determine the amount of data sent by each node within the third preset period of time before the current time point. If a certain child node (which may be referred to as a target child node) sends data If the amount is greater than or equal to the preset value, the root node switching notification can be sent to the target child node. After receiving the root node switching notification, the target child node can send a sub-stream unsubscribe request to the root node subscribing to the sub-stream, establish a connection with the CDN server, and obtain streaming media FLV rectification from the CDN server. After the target child node becomes the root node, it can report to the P2P server that it has switched to the root node.
  • a certain child node which may be referred to as a target child node
  • a processing method for audio frame skipping is also provided, and the corresponding processing may be as follows:
  • the difference between the current time point and the time point of the last played audio frame reaches the sixth preset threshold, and the number of received and unplayed audio frames exceeds the seventh preset threshold, determine the timestamp in the received audio frame The minimum audio frame, the determined audio frame is played.
  • the P2P server can control the child node to switch to the FLV node, establish a connection with the CDN server, and start from the CDN The server gets the FLV rectification.
  • Step 601 The P2P server obtains the code rate within the target preset duration of the child node.
  • Step 603 The P2P server sends the total number of sub-streams to the sub-node.
  • the above description only takes the root node to push audio frames and video frames to the child nodes as an example.
  • the child nodes can also send video to other child nodes.
  • the processing process of the video packet and audio frame in the frame is the same as the processing process of the root node push, and will not be repeated here.
  • the determining module 830 is configured to determine a video package corresponding to each sub-stream subscription request among the multiple video packages according to the received sub-stream subscription request;
  • the sending module 840 is configured to, for each sub-stream subscription request, send the video package corresponding to the sub-stream subscription request to the sub-node to which the sub-stream subscription request belongs.
  • each video frame in the FLV rectification is divided into a plurality of video packets according to a preset length
  • the plurality of divided video packets are sequentially numbered, and whenever the divided video frame is an I frame, the divided I frame is obtained Renumber the video package;
  • the determining module 830 is configured to:
  • a video package corresponding to each sub-stream subscription request is determined among the multiple video packages.
  • the determining module 830 is configured to:
  • the video packet also carries the first time stamp of the video frame to which the video packet belongs, the packet sequence number within the frame of the video packet, and the previous frame of the video frame to which the video packet belongs.
  • the sending module 840 is also used for:
  • the sending module 910 is configured to send a sub-stream subscription request to a node, where the sub-stream subscription request carries a sub-stream number and a total number of sub-streams;
  • the receiving module 920 is configured to receive a video packet determined by the node according to the sub-stream subscription request, where the video packet is obtained by splitting a video frame by the node according to a preset length, and the video frame is obtained by the node
  • the node is received from the CDN server of the content distribution network;
  • the retransmission server sends a retransmission request, where if the first video frame is not received, the retransmission request carries the first time stamp of the first video frame, and if the first video frame is not received Packet, the retransmission request carries the first time stamp of the video frame to which the first video packet belongs and the intra-packet sequence number of the first video packet, if the first video frame and the The first video packet, the retransmission request carries the first time stamp of the first video frame, the first time stamp of the video frame to which the first video packet belongs, and the intra-frame packet of the first video packet Serial number.
  • the sending module 910 is further configured to:
  • the first deleting module 940 is configured to: if the difference between the time stamp of the currently received second video packet and the third time stamp is greater than the first preset threshold, or the time stamp of the currently received second video packet and the first The difference between the four timestamps is greater than the first preset threshold, the second video packet is deleted, where the third timestamp is the time of the video packet received within the first preset time period before the current time point The minimum value of the timestamp, and the fourth timestamp is the maximum value of the timestamps of the video packets received within the first preset time period before the current time point.
  • the received The I frame with the smallest time stamp in the video frame If the difference between the current point in time and the point in time when the video frame in the video stream was last played reaches the second preset threshold, and the number of received video frames that have not been sent for playback exceeds the third preset threshold, the received The I frame with the smallest time stamp in the video frame;
  • the video packets of the I frame and the video packets of the video frames after the I frame form a video stream, and play the video stream.
  • the receiving module 920 is further configured to:
  • the video packet is formed into a video frame
  • the time stamp of the video frame and the time stamp of the audio frame composing the video frame and the audio frame into an audio and video stream
  • the child node further includes:
  • the sending module 910 is further configured to send a sub-stream unsubscribe request to the root node subscribing to the sub-stream, and establish a connection with the CDN server of the content delivery network;
  • the receiving module 920 is further configured to:
  • the root node when the video frame is pushed, can receive the streaming media FLV rectification sent by the CDN server, and each video frame in the FLV rectification is divided into multiple video packets according to a preset length, and the child nodes can send to the root node Sending a sub-stream subscription request, the root node determines the video package corresponding to each sub-stream subscription request among multiple video packages according to the received sub-stream subscription request, and then for each sub-stream subscription request, the sub-stream subscription request belongs to the sub-stream The node sends the video packet corresponding to the sub-stream subscription request. In this way, since only the root node obtains video frames from the CDN server, and the child nodes obtain video frames from the root node, instead of all video frames being sent from the CDN server, the data traffic cost of the CDN server can be saved.
  • the determining module 1220 is further configured to determine the amount of data sent by each node within a third preset time period adjacent to the current time point;
  • the sending module 1230 is further configured to send a root node switching notification to the target child node if the amount of data corresponding to the target child node is greater than or equal to a preset value.
  • the determining module 1220 is further configured to determine the amount of data sent by each node within a fourth preset period of time before the current time point;
  • the sending module 1230 is further configured to send a child node switching notification to the target root node if the amount of data corresponding to the target root node is less than a preset value.
  • the root node when the video frame is pushed, can receive the streaming media FLV rectification sent by the CDN server, and each video frame in the FLV rectification is divided into multiple video packets according to a preset length, and the child nodes can send to the root node Sending a sub-stream subscription request, the root node determines the video package corresponding to each sub-stream subscription request among multiple video packages according to the received sub-stream subscription request, and then for each sub-stream subscription request, the sub-stream subscription request belongs to the sub-stream The node sends the video packet corresponding to the sub-stream subscription request. In this way, since only the root node obtains video frames from the CDN server, and the child nodes obtain video frames from the root node, instead of all video frames being sent from the CDN server, the data traffic cost of the CDN server can be saved.
  • the root node, sub-nodes, and P2P server provided in the above embodiments are only used as an example to illustrate the division of the above functional modules during video transmission. In actual applications, the above functions can be assigned to different functions as required.
  • the function module is completed, that is, the internal structure of the root node, sub-nodes, and P2P server is divided into different function modules to complete all or part of the functions described above.
  • the root node, sub-nodes, and P2P server provided in the foregoing embodiment belong to the same concept as the video transmission method embodiment. For the specific implementation process, refer to the method embodiment, and will not be repeated here.
  • FIG. 13 shows a structural block diagram of a terminal 1300 provided by an exemplary embodiment of the present invention.
  • the terminal 1300 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, moving picture expert compression standard audio layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, moving picture expert compressing standard audio Level 4) Player, laptop or desktop computer.
  • the terminal 1300 may also be called user equipment, portable terminal, desktop terminal and other names.
  • the terminal 1300 includes a processor 1301 and a memory 1302.
  • the processor 1301 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on.
  • the processor 1301 may adopt at least one hardware form among DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array, Programmable Logic Array). achieve.
  • the peripheral device includes: at least one of a radio frequency circuit 1304, a touch display screen 1305, a camera 1306, an audio circuit 1307, a positioning component 1308, and a power supply 1309.
  • the terminal 1300 further includes one or more sensors 1310.
  • the one or more sensors 1310 include, but are not limited to, an acceleration sensor 1311, a gyroscope sensor 1312, a pressure sensor 1313, a fingerprint sensor 1314, an optical sensor 1315, and a proximity sensor 1316.
  • FIG. 14 is a schematic structural diagram of a P2P server provided by an embodiment of the present invention.
  • the P2P server 1400 may have relatively large differences due to different configurations or performance, and may include one or more processors (central processing units, CPU) 1401 And one or more memories 1402, wherein at least one instruction is stored in the memory 1402, and the at least one instruction is loaded and executed by the processor 1401 to implement the above-mentioned video transmission method steps.
  • processors central processing units, CPU
  • memories 1402 wherein at least one instruction is stored in the memory 1402, and the at least one instruction is loaded and executed by the processor 1401 to implement the above-mentioned video transmission method steps.
  • an embodiment of the present disclosure also provides a video transmission system, the system includes a root node, a child node, and a peer-to-peer P2P server, wherein: the root node is used to implement the steps of the video transmission method, the The child node is used to implement the above method steps of video transmission, and the P2P server is used to implement the above method steps of video transmission.
  • an embodiment of the present disclosure further provides a node, the node includes a processor and a memory, and at least one instruction is stored in the memory, and the instruction is loaded and executed by the processor to realize the above-mentioned video transmission.
  • Method steps the node includes a processor and a memory, and at least one instruction is stored in the memory, and the instruction is loaded and executed by the processor to realize the above-mentioned video transmission.
  • an embodiment of the present disclosure also provides a peer-to-peer P2P server, the P2P server includes a processor and a memory, and at least one instruction is stored in the memory, and the instruction is loaded and executed by the processor to implement The above video transmission method.
  • the embodiment of the present disclosure further provides a computer-readable storage medium, and at least one instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement the above-mentioned video transmission method steps.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

本公开提供了一种视频传输的方法、根节点、子节点、P2P服务器和系统,属于音视频技术领域。所述方法包括:在推送视频帧时,根节点可以接收CDN服务器发送的流媒体FLV整流,将FLV整流中每个视频帧按照预设长度分为多个视频包,子节点可以向根节点发送子流订阅请求,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包,然后对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。采用本公开,可以节约CDN服务器的数据流量花销。

Description

视频传输的方法、根节点、子节点、P2P服务器和系统
本申请要求于2019年03月26日提交的申请号为201910234475.X、发明名称为“视频传输的方法、根节点、子节点、P2P服务器和系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本公开涉及音视频技术领域,特别涉及一种视频传输的方法、根节点、子节点、P2P服务器和系统。
背景技术
随着计算机技术和网络技术的发展,越来越多的直播应用程序出现,用户在直播应用程序中观看直播。
相关技术中,主播的音视频流的传输方式可以为:主播终端将音视频流拆分成连续音视频数据包,使用TCP(Transmission Control Protocol,传输控制协议)发送至CDN(Content Delivery Network,内容分发网络)服务器。CDN服务器可以将音视频数据包发送至观众终端,观众终端可以基于接收到的音视频数据包组成音视频流,进行播放。
由于均是从CDN服务器拉取音视频流,所以会导致CDN服务器的数据流量花销比较高。
发明内容
为了解决现有技术的问题,本公开实施例提供了一种视频传输的方法、根节点、子节点、P2P服务器和系统。所述技术方案如下:
第一方面,提供了一种视频传输的方法,所述方法包括:
接收内容分发网络CDN服务器发送的流媒体FLV整流;
将所述FLV整流中每个视频帧按照预设长度分为多个视频包;
根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包;
对于每个子流订阅请求,向所述子流订阅请求所属的子节点发送所述子流订阅请求对应的视频包。
可选的,所述将所述FLV整流中每个视频帧按照预设长度分为多个视频包之后,还包括:
对划分得到的多个视频包依次进行编号且每当划分的视频帧为I帧时,对划分I帧得到的视频包重新进行编号;
所述根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包,包括:
根据接收到的子流订阅请求和视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
可选的,所述子流订阅请求中携带有子流编号和总子流数;
所述根据接收到的子流订阅请和视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包,包括:
根据接收到的子流订阅请求中的子流编号、总子流数以及视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
这样,可以使子节点更快速的恢复出视频帧。
可选的,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目。
可选的,所述子流订阅请求中携带有子流编号;
所述方法还包括:
根据接收到的子流订阅请求中的子流编号,如果确定第一子流订阅请求中子流编号是发送音频帧的子流编号,则向所述第一子流订阅请求所属的子节点发送所述FLV整流中的音频帧。
可选的,所述音频帧中还携带有所述音频帧的时间戳、所述音频帧的前一个音频帧的时间戳、音频帧的序号以及所述前一个音频帧之前相邻的连续的预设数目个音频帧的时间戳。
这样,可以更快速的确定出需要重传的音频帧。
可选的,所述方法还包括:
接收子节点切换通知;
如果满足子节点切换条件,则向其它节点订阅子流,并且断开与CDN服务器的连接。
这样,可以动态调整根节点和子节点。
第二方面,提供了一种视频传输的方法,所述方法包括:
向节点发送子流订阅请求,其中,所述子流订阅请求中携带有子流编号和总子流数;
接收所述节点根据所述子流订阅请求确定出的视频包,其中,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器;
根据接收到的视频包,组成视频流,播放所述视频流。
可选的,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目;
所述方法还包括:
根据接收到的视频包中携带的所述第一时间戳和所述第二时间戳,如果存在未接收到的第一视频帧和/或第一视频包,则当达到重传间隔时,向重传服务器发送重传请求,其中,如果未接收到所述第一视频帧,则所述重传请求中携带所述第一视频帧的第一时间戳,如果未接收到所述第一视频包,则所述重传请求中携带所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号,如果未接收到所述第一视频帧和所述第一视频包,则所述重传请求中携带所述第一视频帧的第一时间戳、所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号。
这样,可以实现重传。
可选的,所述当达到重传间隔时,向重传服务器发送重传请求,包括:
当达到重传间隔时,如果节点重传未启动,则向重传服务器发送重传请求。
这样,可以实现重传。
可选的,所述方法还包括:
如果节点重传启动,则向发送所述第一视频包的节点和/或发送所述第一视频帧的节点发 送重传请求。
这样,可以实现重传。
可选的,所述方法还包括:
如果当前接收到的第二视频包的时间戳与第三时间戳的差值大于第一预设阈值,或者,当前接收到的第二视频包的时间戳与第四时间戳的差值大于第一预设阈值,则将所述第二视频包删除,其中,所述第三时间戳是当前时间点之前的第一预设时长内接收到的视频包的时间戳的最小值,所述第四时间戳是当前时间点之前的所述第一预设时长内接收到的视频包的时间戳的最大值。
这样,可以删除非法的视频包。
可选的,所述根据接收到的视频包,组成视频流,播放所述视频流,包括:
如果当前时间点与最后一次播放播放视频流中的视频帧的时间点之差达到第二预设阈值,且接收到未送去播放的视频帧的数目超过第三预设阈值,则确定接收到的视频帧中时间戳最小的I帧;
根据所述I帧的视频包及所述I帧之后的视频帧的视频包,组成视频流,播放所述视频流。
这样,可以使播放连续。
可选的,所述方法还包括:
接收音频帧;
所述根据接收到的视频包,组成视频流,播放所述视频流,包括:
根据接收到的视频包的帧内包序号和时间戳,将视频包组成视频帧;
根据所述视频帧的时间戳和所述音频帧的时间戳,将所述视频帧和音频帧组成音视频流;
播放所述音视频流。
这样,可以使用户看到视频。
可选的,所述方法还包括:
如果当前接收到的第一音频帧的时间戳与第五时间戳的差值大于第四预设阈值,或者,当前接收到的第二音频帧的时间戳与第六时间戳的差值大于第四预设阈值,则将所述第二音频帧删除,其中,所述第五时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最小值,所述第六时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最大值。
这样,可以删除非法的音频帧。
可选的,所述方法还包括:
接收根节点切换通知;
向订阅子流的根节点发送子流退订请求,并且与内容分发网络CDN服务器建立连接;
从所述CDN服务器获取流媒体FLV整流。
这样,可以动态的调整根节点和子节点。
可选的,所述方法还包括:
接收点对点P2P服务器发送的节点列表;
根据与所述节点列表中的节点进行通信,确定所述子流订阅请求发往的节点。
这样,可以使子节点确定出子流订阅请求发往的节点。
第三方面,提供了一种视频传输的方法,所述方法包括:
获取子节点目标预设时长之内的码率;
根据码率范围与总子流数的对应关系,确定所述码率所属的码率范围对应的总子流数;
向所述子节点发送所述总子流数,其中,所述总子流数在所述子节点向节点发送子流订阅请求时,被携带在子流订阅请求中,携带在所述子流订阅请求的总子流数用于所述节点确定发送往所述子节点的视频包,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器。
可选的,所述方法还包括:
在与本设备建立连接的终端中随机确定预设数目个根节点;
向确定出为根节点的FLV节点发送根节点切换通知,并向除所述确定为根节点FLV节点之外的其它节点发送子节点切换通知。
可选的,所述方法还包括:
确定在当前时间点之前相邻的第三预设时长内各节点发送数据的数据量;
如果目标子节点对应的数据量大于或等于预设数值,则向所述目标子节点发送根节点切换通知。
这样,可以动态调整根节点和子节点。
可选的,所述方法还包括:
确定在当前时间点之前相邻的第四预设时长内各节点发送数据的数据量;
如果目标根节点对应的数据量小于预设数值,则向所述目标根节点发送子节点切换通知。
这样,可以动态调整根节点和子节点。
第四方面,提供了一种视频传输的根节点,所述根节点包括:
接收模块,用于接收内容分发网络CDN服务器发送的流媒体FLV整流;
拆分模块,用于将所述FLV整流中每个视频帧按照预设长度分为多个视频包;
确定模块,用于根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包;
发送模块,用于对于每个子流订阅请求,向所述子流订阅请求所属的子节点发送所述子流订阅请求对应的视频包。
可选的,所述拆分模块,还用于:
将所述FLV整流中每个视频帧按照预设长度分为多个视频包之后,对划分得到的多个视频包依次进行编号且每当划分的视频帧为I帧时,对划分I帧得到的视频包重新进行编号;
所述确定模块,用于:
根据接收到的子流订阅请求和视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
可选的,所述子流订阅请求中携带有子流编号和总子流数;
所述确定模块,用于:
根据接收到的子流订阅请求中的子流编号、总子流数以及视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
可选的,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的可选的,所述子流订阅请求中携带有子流编号;
所述发送模块,还用于:
根据接收到的子流订阅请求中的子流编号,如果确定第一子流订阅请求中子流编号是发送音频帧的子流编号,则向所述第一子流订阅请求所属的子节点发送所述FLV整流中的音频帧。
可选的,所述音频帧中还携带有所述音频帧的时间戳、所述音频帧的前一个音频帧的时间戳、音频帧的序号以及所述前一个音频帧之前相邻的连续的预设数目个音频帧的时间戳。
可选的,所述接收模块,还用于:
接收子节点切换通知;
所述发送模块,还用于:
如果满足子节点切换条件,则向其它节点订阅子流,并且断开与CDN服务器的连接。
第五方面,提供了一种视频传输的子节点,所述子节点包括:
发送模块,用于向节点发送子流订阅请求,其中,所述子流订阅请求中携带有子流编号和总子流数;
接收模块,用于接收所述节点根据所述子流订阅请求确定出的视频包,其中,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器;
播放模块,用于根据接收到的视频包,组成视频流,播放所述视频流。
可选的,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目;
所述发送模块,还用于:
根据接收到的视频包中携带的所述第一时间戳和所述第二时间戳,如果存在未接收到的第一视频帧和/或第一视频包,则当达到重传间隔时,向重传服务器发送重传请求,其中,如果未接收到所述第一视频帧,则所述重传请求中携带所述第一视频帧的第一时间戳,如果未接收到所述第一视频包,则所述重传请求中携带所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号,如果未接收到所述第一视频帧和所述第一视频包,则所述重传请求中携带所述第一视频帧的第一时间戳、所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号。
可选的,所述发送模块,还用于:
当达到重传间隔时,如果节点重传未启动,则向重传服务器发送重传请求。
可选的,所述发送模块,还用于:
如果节点重传启动,则向发送所述第一视频包的节点和/或发送所述第一视频帧的节点发送重传请求。
可选的,所述子节点还包括:
第一删除模块,用于如果当前接收到的第二视频包的时间戳与第三时间戳的差值大于第一预设阈值,或者,当前接收到的第二视频包的时间戳与第四时间戳的差值大于第一预设阈值,则将所述第二视频包删除,其中,所述第三时间戳是当前时间点之前的第一预设时长内接收到的视频包的时间戳的最小值,所述第四时间戳是当前时间点之前的所述第一预设时长内接收到的视频包的时间戳的最大值。
可选的,所述播放模块,用于:
如果当前时间点与最后一次播放视频流中的视频帧的时间点之差达到第二预设阈值,且 接收到未送去播放的视频帧的数目超过第三预设阈值,则确定接收到的视频帧中时间戳最小的I帧;
根据所述I帧的视频包及所述I帧之后的视频帧的视频包,组成视频流,播放所述视频流。
可选的,所述接收模块,还用于:
接收音频帧;
所述播放模块,用于:
根据接收到的视频包的帧内包序号和时间戳,将视频包组成视频帧;
根据所述视频帧的时间戳和所述音频帧的时间戳,将所述视频帧和音频帧组成音视频流;
播放所述音视频流。
可选的,所述子节点还包括:
第二删除模块,用于:
如果当前接收到的第一音频帧的时间戳与第五时间戳的差值大于第四预设阈值,或者,当前接收到的第二音频帧的时间戳与第六时间戳的差值大于第四预设阈值,则将所述第二音频帧删除,其中,所述第五时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最小值,所述第六时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最大值。
可选的,所述接收模块,还用于接收根节点切换通知;
所述发送模块,还用于向订阅子流的根节点发送子流退订请求,并且与内容分发网络CDN服务器建立连接;
所述接收模块,还用于从所述CDN服务器获取流媒体FLV整流。
可选的,所述接收模块,还用于:
接收点对点P2P服务器发送的节点列表;
根据与所述节点列表中的节点进行通信,确定所述子流订阅请求发往的节点。
第六方面,提供了一种视频传输的P2P服务器,所述P2P服务器包括:
获取模块,用于获取子节点目标预设时长之内的码率;
确定模块,用于根据码率范围与总子流数的对应关系,确定所述码率所属的码率范围对应的总子流数;
发送模块,用于向所述子节点发送所述总子流数,其中,所述总子流数在所述子节点向节点发送子流订阅请求时,被携带在子流订阅请求中,携带在所述子流订阅请求的总子流数用于所述节点确定发送往所述子节点的视频包,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器。
可选的,所述确定模块,还用于在与本设备建立连接的终端中随机确定预设数目个根节点;
所述发送模块,还用于向确定出为根节点的FLV节点发送根节点切换通知,并向除所述确定为根节点FLV节点之外的其它节点发送子节点切换通知。
可选的,所述确定模块,还用于确定在当前时间点之前相邻的第三预设时长内各节点发送数据的数据量;
所述发送模块,还用于如果目标子节点对应的数据量大于或等于预设数值,则向所述目标子节点发送根节点切换通知。
可选的,所述确定模块,还用于确定在当前时间点之前相邻的第四预设时长内各节点发送数据的数据量;
所述发送模块,还用于如果目标根节点对应的数据量小于预设数值,则向所述目标根节点发送子节点切换通知。
第七方面,提供了一种视频传输的系统,所述系统包括根节点、子节点和点对点P2P服务器,其中:
所述根节点,如上述第四方面所述的根节点,所述子节点,如上述第五方面所述的子节点,所述P2P服务器,如上述第六方面所述的P2P服务器。
第八方面,提供了一种节点,所述节点包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现上述第一方面和第二方面的视频传输的方法。
第九方面,提供了一种点对点P2P服务器,所述P2P服务器包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现上述第三方面的视频传输的方法。
第十方面,提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现上述第一方面、第二方面和第三方面的视频传输的方法。
本公开实施例提供的技术方案带来的有益效果至少包括:
本公开实施例中,在推送视频帧时,根节点可以接收CDN服务器发送的流媒体FLV整流,将FLV整流中每个视频帧按照预设长度分为多个视频包,子节点可以向根节点发送子流订阅请求,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包,然后对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。这样,由于仅有根节点从CDN服务器获取视频帧,子节点是从根节点获取视频帧,而不是所有的视频帧均是从CDN服务器进行发送,所以可以节约CDN服务器的数据流量花销。
附图说明
图1是本公开实施例提供的一种视频传输的系统图;
图2是本公开实施例提供的一种视频传输的系统图;
图3是本公开实施例提供的一种视频传输的系统图;
图4是本公开实施例提供的一种视频传输的方法的流程示意图;
图5是本公开实施例提供的一种视频传输的方法的流程示意图;
图6是本公开实施例提供的一种获取总子流数的示意图;
图7是本公开实施例提供的一种节点转换的示意图;
图8是本公开实施例提供的一种视频传输的根节点的结构示意图;
图9是本公开实施例提供的一种视频传输的子节点的结构示意图;
图10是本公开实施例提供的一种视频传输的子节点的结构示意图;
图11是本公开实施例提供的一种视频传输的子节点的结构示意图;
图12是本公开实施例提供的一种视频传输的P2P服务器的结构示意图;
图13是本公开实施例提供的一种节点的结构示意图;
图14是本公开实施例提供的一种P2P服务器的结构示意图。
具体实施方式
为使本公开的目的、技术方案和优点更加清楚,下面将结合附图对本公开实施方式作进一步地详细描述。
本公开实施例提供了一种视频传输的方法,如图1所示,该方法的执行主体可以是节点和P2P(peer-to-peer,点对点)服务器。其中,节点可以是安装有视频播放应用程序的终端,节点可以包括FLV(Flash Video,流媒体)节点、根节点和子节点,FLV节点可以与CDN服务器建立连接,从CDN服务器获取FLV整流,根节点可以与CDN服务器建立连接,从CDN服务器获取FLV整流,子节点可以从根节点或者子节点获取视频包。
其中,P2P服务器中可以设置有处理器、存储器和收发器,处理器可以用于视频传输的过程的处理,存储器可以用于存储视频传输过程中需要的数据以及产生的数据,收发器可以用于接收以及发送数据。
节点中可以设置有处理器、存储器和收发器,处理器可以用于视频传输的过程的处理,存储器可以用于存储视频传输过程中需要的数据以及产生的数据,收发器可以用于接收以及发送数据。节点中还可以设置有屏幕、麦克风等输入输出部件,屏幕可以用于显示视频画面,屏幕可以是触摸屏。
在进行实施前,首先介绍一下本公开实施例涉及的视频传输的系统、应用场景以及所涉及到的名词概念:
如图2所示,视频传输的系统中包括CDN服务器、根节点、子节点、P2P服务器和重传服务器,根节点与CDN服务器建立连接,从CDN服务器获取FLV整流。子节点可以从子节点获取视频包,也可以是从根节点获取视频包。P2P服务器可以与子节点、根节点建立连接,通知节点是根节点还是子节点。重传服务器可以与子节点建立连接,用于为子节点重传音视频包(包括音频包和视频包)。
在图2所示的方案图下,在节点进入CDN线路时,当前状态为FLV节点,可以通过登录P2P服务器,与P2P服务器建立连接。P2P服务器后续可以确定根节点、子节点以及为子节点提供节点列表(在后面进行说明)。
需要说明的是,CDN服务器与根节点之间通过TCP传输FLV整流,根节点与子节点、子节点与子节点之间通过UDP(User Datagram Protocol,用户数据报协议)传输音视频包(包括音频帧(也可以称为是音频包)和视频包),P2P服务器与根节点、子节点之间通过TCP传输数据,重传服务器与子节点之间通过TCP或UDP传输数据。
另外,上述图2是本公开实施例的简图,本公开实施例中,还提供了整体的方案图:
如图3所示,视频传输的系统包括CDN服务器、根节点、子节点、P2P服务器、重传服务器、SM(subscribe manager,订阅管理者)服务器、VC(video Center,视频分配节点)服务器、AP(access prefer,接入代理节点)服务器,根节点与CDN服务器建立连接,从CDN服务器获取FLV整流。子节点可以从子节点获取视频包,也可以是从根节点获取视频包。P2P服务器可以与子节点、根节点建立连接,通知节点是根节点还是子节点。重传服务器可以与子节点建立连接,用于为子节点重传音视频包(包括音频包和视频包)。SM服务器可以与AP服务器建立连接,用于下发CDN服务器的线路的URL(Uniform Resource Locator,统一资源定位符),VC服务器可以与AP服务器建立连接,用于为节点提供P2P服务器的信息, AP服务器可以与节点连接,为节点提供与P2P服务器连接的桥梁。
在图3所示的方案图下,在节点进入CDN线路时,当前状态为FLV节点,可以通过AP服务器获取CDN服务器的URL,然后基于URL获取FLV整流,并且通过VC服务器请求连接P2P服务器,该节点接收到P2P服务器的地址时,可以通过AP服务器登录P2P服务器。P2P服务器后续可以确定根节点、子节点以及为子节点提供节点列表(在后面进行说明)。
本公开实施例可以适用于多个节点请求视频帧的过程,例如,在一个直播间中,主播在直播过程中,主播终端(主播使用的终端)录制主播直播的视频,向CDN服务器发送录制的视频帧,CDN服务器接收到后,可以向连接的根节点(直播间中的用户使用的终端)发送FLV整流,根节点可以向进行子流订阅的子节点发送视频帧中的视频包,子节点也可以向进行子流订阅的子节点发送视频帧中的视频包。
根节点,是节点的一种状态,是相对于子节点而言,根节点是与CDN服务器建立连接的节点,从CDN服务器获取FLV整流,并为子节点提供子流订阅服务。
子节点,是节点的一种状态,是相对于根节点而言,子节点不与CDN服务器建立连接,不从CDN服务器获取FLV整流,而是从根节点或者子节点获取视频帧。
FLV节点,是节点的一种状态,在节点连接到P2P服务器上,还未被分为子节点或者根节点时的一种状态,从CDN服务器获取FLV整流。
总子流数,进行P2P的子流的数目,一份视频流可以分为N份发送,那么N就是总子流数。
子流订阅,节点A需要P2P订阅时,需要找多个发布视频流的节点,发送子流订阅通知,请求发送子流。
本公开实施例提供了一种视频传输的方法,如图4所示,根节点的处理流程可以如下:
步骤401,根节点接收内容分发网络CDN服务器发送的流媒体FLV整流。
步骤402,根节点将FLV整流中每个视频帧按照预设长度分为多个视频包。
步骤403,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包。
步骤404,根节点对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。
本公开实施例提供了一种视频传输的方法,并且以图2为方案图,直播过程中的视频帧分发、子节点向根节点获取视频帧为例进行本公开的说明,如图5所示,该方法的执行流程可以如下:
步骤501,子节点向节点发送子流订阅请求,其中,子流订阅请求中携带有子流编号和总子流数。
在实施中,主播在直播过程中,用户想要进入直播间观看主播的直播,可以在终端(节点)中安装直播应用程序(即视频播放应用程序),然后使用申请的账户和密码登录直播应用程序,操作进入主播所在的直播间。这时节点与P2P服务器建立连接,此时节点为FLV节点,P2P服务器会向节点提供CDN服务器的URL,节点可以使用该URL从CDN服务器获取FLV整流。这时,P2P如果确定该节点为子节点,可以通知给该节点。这样,子节点后续会向节点(子节点和/或根节点)发送子流订阅请求,在子流订阅请求中会携带子流编号和总子流数。子流编号用于指示请求的子流的编号,总子流数为请求的子流的数目。后续可以断开与CDN服务器的连接,不再从CDN服务器获取FLV整流。
需要说明的是,一个子流订阅请求中一般携带一个子流编号,但是也可以携带多个子流编号,本公开实施例不做限定。
还需要说明的是,以上仅是以一个子节点为例进行说明,所有子节点均会进行上述处理,只不过子流订阅请求的接收方有可能不相同。
可选的,本公开实施例中,还提供了子节点选取发送子流订阅请求的节点的处理过程,处理可以如下:
子节点接收点对点P2P服务器发送的节点列表,根据与节点列表中的节点进行通信,确定子流订阅请求发往的节点。
在实施中,P2P服务器可以确定直播间中的所有用户的账户的登录终端(即节点),将这些登录终端组成节点列表,向各个子节点发送节点列表。子节点接收到节点列表之后,可以向节点列表中的各节点发送质量查询信息,并记录发送信息的发送时间点,各节点接收到质量查询信息后,可以反馈信息。子节点接收到反馈的信息时,可以记录接收时间点,然后计算接收时间点与发送时间点的差值,并获取总子流数,在节点列表的节点中选取差值最小的总子流数个节点,确定为子流订阅请求发往的节点。这样,可以确定出子流订阅请求发往的节点,也即确定出订阅子流的节点。
步骤502,根节点接收CDN服务器发送的FLV整流。
在实施中,在直播过程中,主播直播的视频流通过主播终端发送至CDN服务器,CDN服务器可以确定直播间中与CDN服务器建立连接的终端(即根节点),然后可以向根节点发送FLV整流(FLV整流中包括直播的视频帧和音频帧)。这样,根节点可以接收到CDN服务器发送的FLV整流。根节点接收到FLV整流后,可以进行播放,这样,根节点的用户可以观看主播的直播。
另外,在根节点未接收到FLV整流中的某些音频帧和视频帧时,可以向CDN服务器发送重传请求,请求重传未接收到的音频帧和视频帧。
可选的,本公开实施例中还提供了确定根节点和子节点的方法,相应的处理为:
在与本设备建立连接的终端中随机确定目标预设数目个根节点,向确定出为根节点的FLV节点发送根节点切换通知,并向除确定为根节点FLV节点之外的其它节点发送子节点切换通知。
在实施中,终端在刚进入直播间时,是FLV节点,CDN服务器可以在当前直播间中的终端中随机指定目标预设数目(如可以为50等)个节点为根节点,并通知给根节点,其余终端为子节点,后续根节点可以被动态调整为FLV节点和子节点,使音频帧和视频帧的分发更为流畅。
可选的,CDN服务器可以与根节点通过三次握手建立TCP连接,通过TCP向根节点发送FLV整流。
步骤503,根节点将FLV整流中每个视频帧按照预设长度分为多个视频包。
其中,预设长度可以预设,并且随着直播应用程序存储至根节点中,如1200字节等。
在实施中,根节点接收到FLV整流后,可以将FLV整流中的每个视频帧,按照预设长度进行分包处理,得到多个视频包。
可选的,可以在每个GOP(Group of Pictures,画面组)中按照视频帧进行依次编号,相应的处理可以如下:
根节点对划分得到的多个视频包依次进行编号且每当划分的视频帧为I帧时,对划分I 帧得到的视频包重新进行编号。
其中,I帧(I frame)又称为intra picture(内部画面),I帧通常是每个GOP的第一个帧,经过适度地压缩,作为随机访问的参考点,可以当成图像。
在实施中,在对视频帧进行分包时,可以对划分得到的多个视频包依次进行编号,并且每当划分的视频帧为I帧时,对划分得到的视频包要重新开始编号。例如,有连续4个视频帧,视频帧1、视频帧2、视频帧3和视频帧4,视频帧3是I帧,视频帧1、视频帧2、视频帧3和视频帧4分别有4个视频包,视频帧1中视频包的编号为0、2、4、6,视频帧2中视频包的编号为8、10、12、14,视频帧3为I帧,要重新编号,视频帧3中视频包的编号为0、2、4、6,视频帧4中视频包的编号为8、10、12、14。
由于GOP的第一个帧是I帧,所以每个GOP重新编号,即为遇到I帧重新进行编号。
可选的,为了节约根节点的处理资源,根节点在拆分视频帧时,还会判断是否接收到子流订阅请求,如果接收到子流订阅请求,则按照步骤503的处理拆分视频帧,如果未接收到子流订阅请求,则不进行拆分视频帧的处理。
步骤504,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包。
在实施中,根节点可以接收子节点发送的子流订阅请求,然后基于子流订阅请求,在多个视频包中,确定接收到的每个子流订阅请求所对应的视频包。
可选的,在步骤503中拆分视频包时,每个视频包还有编号,相应的步骤504的处理可以如下:根据接收到的子流订阅请求和视频包的编号,在多个视频包中确定每个子流订阅请求对应的视频包。
在实施中,根节点可以根据接收到的子流订阅请求和视频包的编号,在多个视频包中确定每个子流订阅请求所对应的视频包。
可选的,子流订阅请求中可以携带有子流编号和子流总数,相应的步骤504的处理可以如下:
根据接收到的子流订阅请求中的子流编号、总子流数以及视频包的编号,在多个视频包中确定每个子流订阅请求对应的视频包。
在实施中,根节点可以获取计算每个子流订阅请求对应的视频包的公式:子流编号=(视频包的编号/2)mod总子流数,mod表示取余,然后,将总子流数和子流编号代入该公式,即可确定出子流编号对应的视频包,将子流编号所对应的视频包,确定为子流编号所属的子流订阅请求对应的视频包。这样,就可以确定出每个子流订阅请求对应的视频包。例如,子流订阅请求中的子流编号为0,总子流数为15,则子流编号为0的子流订阅请求对应的视频包的编号为0、30、60、、等。
步骤505,对于每个子流订阅请求,根节点向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。
在实施中,根节点确定出每个子流订阅请求所对应的视频包后,可以向发送该子流订阅请求的子节点发送该子流订阅请求对应的视频包。
可选的,为了使视频帧中的视频包能够重传,对于每个视频包,视频包还携带有视频包所属的视频帧的第一时间戳、视频包的帧内包序号、所属的视频帧的前一帧视频帧的第二时间戳、视频包所属的视频帧包含的视频包的数目。
在实施中,对于某个视频包的帧内包序号是指该视频包在所属视频帧中的排序。例如, 某个视频包的帧内包序号为10,说明该视频包是所属视频帧中的第10个视频包。
视频帧的第一时间戳是DTS(Decoding Time Stamp,解码时间戳)。这个时间戳的意义在于告知播放器在什么时候解码这一帧的数据。同样,前一帧视频帧的第二时间戳也是DTS。
由于携带了视频帧的第一时间戳,所以可以确定出第一时间戳的视频包的数目,并且由于携带了视频帧包含的视频包的数目,所以可以将第一时间戳的视频包的数目与携带的视频包的数目进行比较,如果第一时间戳的视频包的数目小于携带的视频包的数目,则说明有视频包丢包,如果第一时间戳的视频包的数目等于携带的视频包的数目,则说明视频帧中的视频包接收完整。另外,由于携带了前一帧视频帧的第二时间戳,所以可以建立起视频帧在时间戳上的相邻关系,进而可以确定出丢失的视频帧。
另外,每个视频包中还可以携带有该视频包所属的视频帧的前一个视频帧包含的视频包的数目,这是为了使所有的视频帧均可以重传。例如,接收到一个视频帧B的一个包,前一个视频帧为视频帧A,除了将视频帧B的所有包的序号添加重传,还可以检查视频帧A是否也需要添加重传。这样,即使视频帧A的视频包全部丢失,也可以进行重传。
另外,还可以携带有按照GOP进行编号的视频包的编号,以及是否为重传的视频包的指示信息、进行P2P的URL的MD5串、视频数据等。
需要说明的是,上述第一时间戳与第二时间戳实际上均是时间戳,只不过第一时间戳是每个视频帧的时间戳,第二时间戳时该视频帧的前一个视频帧的时间戳。对于首个音频帧,前一个音频帧的第二时间戳为0。
步骤506,子节点接收节点根据子流订阅请求确定出的视频包。
在实施中,子节点接收到的视频包是节点将视频帧按照预设长度拆分得到,视频帧由节点接收自CDN服务器。
步骤507,子节点根据接收到的视频包,组成视频流,播放视频流。
在实施中,子节点接收到视频包后,可以将视频包组成视频帧,将视频帧组成视频流,播放视频流。
可选的,一般视频会包括视频帧和音频帧,它们一般是单独进行发送,本公开实施例中还提供了音频帧的发送处理,相应的处理可以如下:
子流订阅请求中携带有子流编号;根据接收到的子流订阅请求中的子流编号,如果确定第一子流订阅请求中子流编号是发送音频帧的子流编号,则向第一子流订阅请求所属的子节点发送FLV整流中的音频帧。
在实施中,由于单个音频帧的数据量比较小,所以不适宜再拆分,也即每次发送时,都是以音频帧为单位进行发送,即一个音频帧为一个音频包。在发送音频帧时,一般是接收到固定的子流编号的根节点进行发送。
根节点可以确定接收到的子流订阅请求中的子流编号(可以是预先配置),如果第一子流订阅请求中的子流编号是发送音频帧的子流编号,则可以向第一子流订阅请求所属的节点发送FLV整流中的音频帧。
例如,总子流数是15,子流编号为0~14,子流编号为14的子流订阅请求用于指示发送音频帧。
需要说明的是,子流编号为14的子流订阅请求除了用于指示发送音频帧,还可以用于指示发送视频包,二者没有冲突。
可选的,为了使音频帧的发送更灵活,本公开实施例中,还确定了发送音频帧的子流编 号的确定方法:
音频帧中对应有GOP序列号,根据GOP序列号,确定发送音频帧的子流编号。
在实施中,音频帧对应有GOP序列号(每个音频帧的GOP序列号都是相等的),根节点可以获取音频帧中携带的GOP序列号,并且可以获取发送音频帧的子流编号的公式,将GOP序列号代入该公式中,即可确定出发送音频帧的子流编号。例如,在总子流数为15时,子流编号为0~14,GOP序列号为26,使用(GOP序列号/2)mod2,即可确定出发送音频帧的子流编号为13。
另外,为了减少音频帧的重传,可以使发送音频帧的子流编号有两个(即双路推送音频帧),例如,在总子流数为15时,发送音频帧的子流编号为13和14,在子节点接收到相同时间戳的音频帧时,可以删除其中一个。
另外,GOP序列号还可以用于子节点确定接收到的包是音频帧还是视频包,如果是音频帧,其中会有GOP序列号,如果是视频包,则没有。
可选的,本公开实施例中还提供了子节点接收音频帧的处理,以及如何播放音频帧的处理,相应的处理可以如下:
接收音频帧,根据接收到的视频包的帧内包序号和时间戳,将视频包组成视频帧,根据视频帧的时间戳和音频帧的时间戳,将视频帧和音频帧组成音视频流,播放音视频流。
在实施中,子节点可以接收音频帧,由于每个音频帧携带有当前音频帧的时间戳以及前一个音频帧的时间戳,所以可以建立起音频帧的时间戳的前后连续关系。然后首先将相同时间戳的视频包,按照视频包的帧内包序号的从小到大的顺序进行排列,组成视频帧,然后按照视频包携带的所属视频帧的时间戳与前一个视频帧的时间戳,建立起视频帧的前后连续关系。然后按照视频帧的时间戳的前后连续关系、音频帧的时间戳的前后连续关系,将视频帧和音频帧组成的音视频流,播放音视频流。
需要说明的是,上述是根节点接收到子流订阅请求时,根节点的处理,如果子节点接收到其它子节点发送的子流订阅请求,与根节点接收到子流订阅请求的处理过程完全相同,此处不再赘述。
另外,在本公开实施例中,如果根节点有子流订阅请求数目的限制,则对于超过子流订阅请求数目后接收到的子流订阅请求,会向子节点发送子流退订消息,以使子节点从其它子节点或者根节点获取子流。
可选的,子节点在未接收到视频包时,为了使直播视频可以继续播放,可以进行跳帧播放处理,相应的处理可以如下:
如果当前时间点与最后一次播放视频流中的视频帧的时间点之差达到第二预设阈值,且接收到未送去播放的视频帧的数目超过第三预设阈值,则确定接收到的视频帧中时间戳最小的I帧,根据I帧的视频包及I帧之后的视频帧的视频包,组成视频流,播放视频流。
其中,I帧(I frame)又称为intra picture(内部画面),I帧通常是每个GOP的第一个帧,经过适度地压缩,作为随机访问的参考点,可以当成图像,在播放时不需要参考其它视频帧即可进行解码。第二预设阈值可以预设,并且随着视频应用程序,一起安装在节点上。第三预设阈值也可以预设,并且随着视频应用程序,一起安装在节点上。
在实施中,子节点可以确定当前时间点距离最后一次播放视频流中的视频帧的时间点的差值,如果该差值达到第二预设阈值,则可以确定接收到且未进行播放的视频帧的数目是否超过第三预设阈值,如果超过第三预设阈值,则可以确定接收到的视频帧中的I帧,在这些I 帧中确定时间戳最小的I帧,根据I帧的视频包及I帧之后的视频帧的视频包,组成视频流,播放视频流。这样,在丢帧后也可以继续播放视频流,用户可以继续观看主播的直播视频。
另外,跳帧处理可以通过代码执行。
可选的,本公开实施例中,还提供了进行视频包重传的处理,相应的处理可以如下:
根据接收到的视频包中携带的第一时间戳和第二时间戳,如果存在未接收到的第一视频帧和/或第一视频包,则当达到重传间隔时,向重传服务器发送重传请求,其中,如果未接收到第一视频帧,则重传请求中携带第一视频帧的第一时间戳,如果未接收到第一视频包,则重传请求中携带第一视频包所属的视频帧的第一时间戳和第一视频包的帧内包序号,如果未接收到第一视频帧和第一视频包,则重传请求中携带第一视频帧的第一时间戳、第一视频包所属的视频帧的第一时间戳和第一视频包的帧内包序号。
其中,对于某个视频包的帧内包序号是指该视频包在所属视频帧中的排序。例如,某个视频包的帧内包序号为10,说明该视频包是所属视频帧中的第10个视频包。
在实施中,子节点上维护有两个映射表,分别用于维护时间戳的连续关系和请求时间戳关系,时间戳的连续关系可以使用video Dts Relation表示,video Dts Relation用于记录接收到的视频帧的时间戳,请求时间戳关系可以使用video Dts Ack Map表示,用于记录未接收到视频包所属的视频帧后续的视频帧的时间戳。
子节点接收到任意一个视频包后,可以从该视频包解析到第一时间戳和第二时间戳,如果第二时间戳和第一时间戳在video Dts Relation中均存在,则不更改video Dts Relation,如果第一时间戳在video Dts Relation中不存在,则在video Dts Relation中的第二时间戳之后添加第一时间戳。这样,可以建立起视频帧的时间戳的前后连续关系。并且判断第一时间戳在video Dts Relation中是否存在或者是否为0,如果不存在或者为0,则将该第一时间戳添加到video Dts Ack Map中,如果存在,则不进行处理。
例如,A、B、C、D、E、F、G分别是连续的视频帧,其对应的时间戳如下,其中,第一时间戳使用Dts表示,第二时间戳使用lastDts表示:
A:Dts:5,lastDts:0;
B:Dts:8,lastDts:5;
C:Dts:13,lastDts:8;
D:Dts:17,lastDts:13;
E:Dts:22,lastDts:17;
F:Dts:26,lastDts:22;
G:Dts:29,lastDts:26
假设video Dts Ack Map中开始记录有0,比如接收到A、B、G、F、D,而未接收到C、E,接收A,则从video Dts Ack Map中删除时间戳0,并记录时间戳5,此时video Dts Ack Map大小为1。接收到B,则从video Dts Ack Map删除时间戳5,并记录时间戳8,此时videoDtsAckMap大小为1。接收到G,则从video Dts Ack Map删除时间戳26,并记录时间戳29,此时video Dts Ack Map大小为2。接收到F,则从video Dts Ack Map删除时间戳22,因时间戳26已被记录后续关系,所以不需要video Dts Ack Map记录数据,此时videoDtsAckMap大小为2。接收到D,则从video Dts Ack Map删除时间戳13,并记录时间戳17,此时videoDtsAckMap大小为3。执行到这里video Dts Ack Map中记录的值是8,17,29,即B、D、G后续的视频帧未接收到。
并且video Dts Relation记录的时间戳的前后连续关系为0-5-8-13-17-22-26-29。
这样,可以定时检查video Dts Ack Map,如果其中存在未接收到的视频帧,且达到重传间隔时,则可以向重传服务器发送时间戳的连续关系的获取请求,在其中携带CDN服务器的URL、以及视频帧的时间戳开始不连续的时间戳和时间戳结束不连续的时间戳(例如,时间戳依次为0-5-8-13-、、、-22-、、、-29,13至22时间戳不连续,22至29时间戳不连续,时间戳开始不连续的时间戳为13,时间戳结束不连续的时间戳为29)。重传服务器接收到时间戳的连续关系的获取请求之后,可以确定CDN服务器的URL对应的时间戳的连续关系,从中确定出接收到的两个时间戳之间的时间戳的连续关系,向子节点发送该时间戳的连续关系。子节点接收到后,可以使用video Dts Ack Map中记录的值,在连续关系中查找确定出丢失的视频帧的时间戳,然后可以向重传服务器发送重传请求,重传请求中携带所述第一视频帧(丢失的视频帧)的第一时间戳。
而且由于有的视频帧仅是丢失了某些视频包,所以可以仅重传丢失的这些视频包,而不需要重传整个视频帧,所以可以向重传服务器发送重传请求,该重传请求中携带有第一视频包(丢失的视频包)所属的视频帧的第一时间戳和所述第一视频包的帧内包序号。
另外,如果既丢失了视频帧,也丢失了视频包,则该重传请求中会携带第一视频帧的第一时间戳、第一视频包所属的视频帧的第一时间戳和第一视频包的帧内包序号。
另外,确定重传间隔的方式可以如下:
对于某个视频帧或者某个视频包,与重传服务器之间的第一次重传的重传间隔,可以首先预计每个视频包的到达时间,对于每个视频帧第一次接收的视频包,记录接收时间点,将接收时间点与该视频包所属的视频帧的时间戳相减,得到一个差值,然后将多个视频帧的差值求平均值,得到一个抖动平均值,即为第一次重传的时间间隔。对于该视频帧或者该视频包,与重传服务器之间的后续重传的重传间隔,子节点可以向重传服务器发送ping包,记录发送时间点,重传服务器会返回对ping包的回复信息,记录接收时间点,将接收时间点与发送时间点相减,得到RTT(round-trip time,回环时间),然后确定当前的抖动平均值(计算方式与计算第一次重传的重传间隔中的抖动平均值相同),并且可以获取抖动对应的权值、RTT对应的权值。将抖动平均值与抖动对应的权值相乘,得到第一乘积,并将RTT与RTT对应的权值相乘,得到第二乘积,将第一乘积与第二乘积相加,即得到重传间隔。
在得到重传间隔后,每次达到重传间隔,还未接收到视频帧和/或者视频包,可以进行重传处理。
每次达到重传间隔是指:将视频帧的时间戳的添加到video Dts Ack Map中后的时长等于重传间隔时,则进行重传该视频帧之后的视频帧。或者某个视频包的相邻视频包已经接收到的时长达到重传间隔时,则进行重传。另外,对于向重传服务器请求二次或者多次重传的视频帧或者视频包,则是发出重传请求之后的时长达到重传间隔时,还未接收到请求重新发送的视频帧或者视频包,则说明达到重传间隔。
另外,为了方便记录视频包的重传或者视频帧的重传,本公开实施例中,还提供了video Frame Dts队列和video Resend Map队列,video Frame Dts队列记录的是接收到的视频帧中还未播放的视频帧的时间戳,video Resend Map队列记录的是需要进行重传的视频包。每当接收到一个视频帧的某个视频包,将该视频包所属的视频帧的时间戳和包括的视频包的序号添加到video Resend Map队列中。并且判断video Frame Dts队列中是否存在该视频包所属的视频帧的时间戳,如果存在,则不进行处理,如果不存在,则将该时间戳添加至video Frame Dts 队列中。另外,还可以判断是否大于当前播放的视频帧的时间戳,如果大于则将接收到的视频包删除。在将某个视频帧送去播放后,可以将video Frame Dts队列中的该视频帧的时间戳删除。另外,如果接收到某个视频包,则可以按照视频包的帧内包序号,将视频包的重传记录从video Resend Map队列中删除。
可选的,可以使用两个map记录并维护时间戳的连续关系及请求时间戳的关系:
std::map<uint32_t,uint64_t>m_videoDtsRelation;
//时间戳的连续关系:lastDts->(dts<<32|frameNum)
std::map<uint32_t,FlvAckDtsInfo>m_videoDtsAckMap;
//请求时间戳的关系。
可选的,可以使用以下结构体维护接收到的视频包的信息:
std::set<FlvP2pVideoDtsCmp>m_videoDtsList
Flv P2P Dts Status m_dtsStatus。
可选的,在使用重传服务器进行重传时,还可以首先判断节点重传是否启动,相应的处理可以如下:
当达到重传间隔时,如果节点重传未启动,则向重传服务器发送重传请求。
在实施中,子节点可以配置有节点重传功能,如果节点重传功能开启,则说明节点重传启动,如果节点重传功能未开启,则说明节点重传未启动。
在达到重传间隔时,如果节点重传未启动,说明不能从节点重传视频包,则可以向重传服务器发送重传请求,以使重传服务器再次发送视频帧和/或视频包。
另外,在节点重传启动时,处理可以如下:
如果节点重传启动,则向发送第一视频包的节点和/或发送第一视频帧的节点发送重传请求。
在实施中,在达到重传间隔时,如果节点重传启动,说明可以从节点重传视频包,可以向发送第一视频包的节点发送重传请求,以使该节点再次发送视频包。还可以向发送第一视频帧的节点发送重传请求。
另外,本公开实施例中,还提供了判断非法视频包的处理,相应的处理可以如下:
如果当前接收到的第二视频包的时间戳与第三时间戳的差值的绝对值大于第一预设阈值,或者,当前接收到的第二视频包的时间戳与第四时间戳的差值的绝对值大于第一预设阈值,则将第二视频包删除,其中,第三时间戳是当前时间点之前的第一预设时长内接收到的视频包的时间戳的最小值,第四时间戳是当前时间点之前的第一预设时长内接收到的视频包的时间戳的最大值。
其中,第一预设时长可以预设,并且存储至直播应用程序中,随直播应用程序一起安装在节点上。第一预设阈值也可以预设,并且存储至直播应用程序中,随直播应用程序一起安装在节点上。
在实施中,子节点在接收到任一视频包(后续可以称为是第二视频包)时,或者每隔一定时长,可以获取当前时间点之前的第一预设时长内接收到的视频包的时间戳,然后确定时间戳中的最小值(即第三时间戳),并且可以确定时间戳中的最大值(即第四时间戳)。
然后可以确定当前接收到的第二视频包的时间戳与第三时间戳的差值的绝对值,判断该差值的绝对值与第一预设阈值的关系,如果该差值大于第一预设阈值,可以确定第二视频包为非法视频包,可以将第二视频包删除。或者,可以确定第二视频包的时间戳与第四时间戳 的差值的绝对值,判断该差值的绝对值与第一预设阈值的关系,如果该差值的绝对值大于第一预设阈值,可以确定第二视频包为非法视频包,可以将第二视频包删除。这样,由于短时间内接收到的视频包的时间戳相差不会特别大,如果特别大,说明是非法视频包。
可选的,本公开实施例还提供了判断音频帧是非法音频帧的处理,相应的处理可以如下:
如果当前接收到的第一音频帧的时间戳与第五时间戳的差值大于第四预设阈值,或者,当前接收到的第二音频帧的时间戳与第六时间戳的差值大于第四预设阈值,则将第二音频帧删除,其中,第五时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最小值,第六时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最大值。
其中,第二预设时长可以预设,并且存储至视频应用程序中,随应用程序一起安装在节点上。第四预设阈值也可以预设,并且存储至视频应用程序中,随应用程序一起安装在节点上。
在实施中,子节点在接收到任一音频帧(后续可以称为是第二音频帧)时或者每隔一定时长,可以获取当前时间点之前的第二预设时长内接收到的音频帧的时间戳,然后确定时间戳中的最小值(即第五时间戳),并且可以确定时间戳中的最大值(即第六时间戳)。
然后可以确定当前接收到的第二音频帧的时间戳与第五时间戳的差值的绝对值,判断该差值的绝对值与第四预设阈值的关系,如果该差值大于第四预设阈值,可以确定第二音频帧为非法音频帧,可以将第二音频帧删除。或者,可以确定第二音频帧的时间戳与第四时间戳的差值的绝对值,判断该差值的绝对值与第一预设阈值的关系,如果该差值的绝对值大于第四预设阈值,可以确定第二音频帧为非法音频帧,可以将第二音频帧删除。这样,由于短时间内接收到的音频帧的时间戳相差不会特别大,如果特别大,说明是非法音频帧。
可选的,在音频帧丢失后,为了音频帧还可以进行重传,音频帧中还携带有音频帧的时间戳、音频帧的前一个音频帧的时间戳、音频帧的序号以及前一个音频帧之前相邻的连续的预设数目个音频帧的时间戳。
其中,预设数目可以预设,并且存储至根节点中,预设数目取值的最大值可以为20,最小值可以为0,一般可以取5。
在实施中,对于任一音频帧,该音频帧中携带有音频帧的时间戳、该音频帧的前一个音频帧的时间戳、前一个音频帧之前相邻的连续预设数目个音频帧的时间戳、该音频帧的序号(即前面提到的GOP序号)。该音频帧的序号主要用于音频帧的分发。每个音频帧的序号都是一样的,只要接收到该序号的数据,说明是音频帧。
这样,由于音频帧中携带有前一个音频帧的时间戳,所以在该音频帧之前接收到的音频帧的时间戳不是该音频帧中前一个音频帧的时间戳,说明音频帧有丢失,而且基于前一个音频帧之前的预设数目个音频帧的时间戳,可以确定出那些音频帧丢失。例如,预设数目为5,对于某个音频帧a,其中携带的前一个音频帧的时间戳为10秒,已经接收到的音频帧b的时间戳为8秒,说明8秒至10秒之间的音频帧丢失,然后可以基于前一个音频帧之前的预设数目个音频帧的时间戳为9秒30、9秒10、8秒55、8秒25、8秒,所以丢失的音频帧的时间戳为9秒30、9秒10、8秒55、8秒25。
这样,确定出音频帧丢失时,如果节点重传功能未开启,则子节点可以向重传服务器发送音频帧的重传请求,其中,携带有音频帧的时间戳和CDN服务器的URL。重传服务器接收到后,可以基于CDN服务器的URL,找到音频帧,然后在音频帧中确定出该时间戳的音频帧,发送给子节点。
另外,如果节点重传功能开启,则子节点可以向发送该音频帧的节点发送音频帧的重传请求,其中,携带有音频帧的时间戳和CDN服务器的URL。该节点接收到后,可以基于CDN服务器的URL,找到音频帧,然后在音频帧中确定出该时间戳的音频帧,发送给子节点。
可选的,本公开实施例中还提供了子节点切换处理的过程,相应的处理可以如下:
P2P服务器确定在当前时间点之前相邻的第四预设时长内各节点发送数据的数据量;如果目标根节点对应的数据量小于预设数值,则向目标根节点发送子节点切换通知。根节点接收子节点切换通知,如果满足子节点切换条件,则向其它节点订阅子流,并且断开与CDN服务器的连接。
其中,子节点切换条件可以预设,并且存储至根节点中,一般是随着直播应用程序安装在节点上。
在实施中,P2P服务器可以周期性确定在当前时间点之前相邻的第四预设时长内各节点发送数据的数据量,如果某个根节点发送数据的数据量小于预设数值,则可以向该根节点发送子节点切换通知。该根节点可以接收子节点切换通知,然后判断是否满足子节点切换条件,即判断是否可以连接到其它节点,如果可以连接到其它节点,则可以确定满足节点切换条件,可以向其它节点订阅子流,并且可以断开与CDN服务器的连接,即后续不会从CDN服务器获取FLV-整流。然后子节点可以向P2P服务器上报自己切换为子节点的通知。
另外,在判断是否满足节点切换条件时,还可以判断是否可以连接到重传服务器,如果当前节点的重传功能未开启,且不能连接到重传服务器,则不满足子节点切换条件,则不进行子节点切换处理(即不向其它节点订阅子流,也不断开与CDN服务器的连接)。如果当前节点的重传功能开启,则不管是否能够连接到重传服务器,均可以进行子节点切换处理(向其它节点订阅子流,并且断开与CDN服务器的连接)。
可选的,本公开实施例中,还提供了根节点切换的处理过程,相应的处理可以如下:
确定在当前时间点之前相邻的第三预设时长内各节点发送数据的数据量,如果目标子节点对应的数据量大于或等于预设数值,则向目标子节点发送根节点切换通知。子节点接收根节点切换通知,向订阅子流的根节点发送子流退订请求,并且与内容分发网络CDN服务器建立连接,从CDN服务器获取流媒体FLV整流。
其中,预设数值可以预设,并且随直播应用程序一起安装在节点上。
在实施中,P2P服务器可以周期性确定在当前时间点之前相邻的第三预设时长内各节点发送数据的数据量,如果某个子节点(后续可以称为是目标子节点)发送数据的数据量大于或等于预设数值,则可以向目标子节点发送根节点切换通知。目标子节点接收到根节点切换通知之后,可以向订阅子流的根节点发送子流退订请求,并且与CDN服务器建立连接,从CDN服务器获取流媒体FLV整流。目标子节点变为根节点后,可以向P2P服务器上报自己切换为根节点的通知。
另外,本公开实施例中,还提供了音频跳帧的处理方法,相应的处理可以如下:
如果当前时间点距离最后一次播放音频帧的时间点之差达到第六预设阈值,且接收到且未播放的音频帧的数目超过第七预设阈值,则确定接收到的音频帧中时间戳最小音频帧,播放确定出的音频帧。
在实施中,子节点可以确定当前时间点距离最后一次播放音频帧的时间点的差值,如果该差值达到第六预设阈值,则可以确定接收到且未进行播放的音频帧的数目是否超过第七预设阈值,如果超过第七预设阈值,则可以确定接收到的音频帧中时间戳最小的音频帧,播放 该时间戳最小的音频帧。这样,在丢帧后也可以继续进行播放音频帧,用户可以继续观看主播的直播视频。
可选的,本公开实施例中,在子节点无法连接到重传服务器,且无法为其他子节点提供子流时,P2P服务器可以控制子节点切换为FLV节点,与CDN服务器建立连接,从CDN服务器获取FLV整流。
可选的,本公开实施例中,如图6所示,还提供了P2P服务器确定总子流数的方法,相应的处理可以如下:
步骤601,P2P服务器获取子节点目标预设时长之内的码率。
在实施中,每次用户使用账户在登录终端(子节点)进行登录,进入直播间后,会与P2P服务器进行连接,P2P服务器可以获取子节点在目标预设时长内的码率。
步骤602,P2P服务器根据码率范围与总子流数的对应关系,确定码率所属的码率范围对应的总子流数。
在实施中,在P2P服务器上预设有码率范围与总子流数的对应关系,P2P服务器确定子节点在预设时长内的码率之后,可以获取预设的码率范围与总子流数的对应关系,然后在该对应关系中,确定码率所属的码率范围对应的总子流数,这样,就可以确定该子节点对应的总子流数。
步骤603,P2P服务器向子节点发送总子流数。
在实施中,P2P服务器确定出某个子节点的总子流数之后,可以向该子节点发送该总子流数。
子节点可以接收总子流数,然后确定总子流数个订阅的节点,向这些节点订阅子流,在子流订阅请求中携带总子流数。
另外,本公开实施例中,如图7所示,还提供了FLV节点、根节点和子节点的转换示意图。终端在刚进入直播间时,为FLV节点,P2P服务器将FLV节点指定为子节点或者根节点,服务器在确定子节点切换为根节点时,指定子节点切换为根节点,服务器在确定根节点切换为子节点时,指定根节点切换为子节点,服务器在确定子节点不满足子节点条件时,指定子节点切换为FLV节点。
需要说明的是,上述仅以根节点向子节点推送音频帧和视频帧为例进行说明,实际上子节点在接收到根节点发送的音频帧和视频帧后,也可以向其它子节点发送视频帧中的视频包和音频帧,处理过程和根节点推送的处理过程相同,此处不再赘述。
另外,时间戳和帧内包序号可以一起使用计算机的移位进行表示,将时间戳向左移动32位,即对应64位数据,高32位为时间戳,低32位为帧内包序号。
还需要说明的是,上述仅是以直播间中的音视频流分发为例进行说明,凡是音视频流的分发想使用P2P服务器,均可以使用本公开实施例的处理方式。
本公开实施例中,在推送视频帧时,根节点可以接收CDN服务器发送的流媒体FLV整流,将FLV整流中每个视频帧按照预设长度分为多个视频包,子节点可以向根节点发送子流订阅请求,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包,然后对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。这样,由于仅有根节点从CDN服务器获取视频帧,子节点是从根节点获取视频帧,而不是所有的视频帧均是从CDN服务器进行发送,所以可以节约CDN服务器的数据流量花销。
基于相同的技术构思,本公开实施例还提供了一种根节点,如图8所示,该根节点包括:
接收模块810,用于接收内容分发网络CDN服务器发送的流媒体FLV整流;
拆分模块820,用于将所述FLV整流中每个视频帧按照预设长度分为多个视频包;
确定模块830,用于根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包;
发送模块840,用于对于每个子流订阅请求,向所述子流订阅请求所属的子节点发送所述子流订阅请求对应的视频包。
可选的,所述拆分模块820,还用于:
将所述FLV整流中每个视频帧按照预设长度分为多个视频包之后,对划分得到的多个视频包依次进行编号且每当划分的视频帧为I帧时,对划分I帧得到的视频包重新进行编号;
所述确定模块830,用于:
根据接收到的子流订阅请求和视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
可选的,所述子流订阅请求中携带有子流编号和总子流数;
所述确定模块830,用于:
根据接收到的子流订阅请求中的子流编号、总子流数以及视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
可选的,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目。
可选的,所述子流订阅请求中携带有子流编号;
所述发送模块840,还用于:
根据接收到的子流订阅请求中的子流编号,如果确定第一子流订阅请求中子流编号是发送音频帧的子流编号,则向所述第一子流订阅请求所属的子节点发送所述FLV整流中的音频帧。
可选的,所述音频帧中还携带有所述音频帧的时间戳、所述音频帧的前一个音频帧的时间戳、音频帧的序号以及所述前一个音频帧之前相邻的连续的预设数目个音频帧的时间戳。
可选的,所述接收模块810,还用于:
接收子节点切换通知;
所述发送模块840,还用于:
如果满足子节点切换条件,则向其它节点订阅子流,并且断开与CDN服务器的连接。
本公开实施例中,在推送视频帧时,根节点可以接收CDN服务器发送的流媒体FLV整流,将FLV整流中每个视频帧按照预设长度分为多个视频包,子节点可以向根节点发送子流订阅请求,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包,然后对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。这样,由于仅有根节点从CDN服务器获取视频帧,子节点是从根节点获取视频帧,而不是所有的视频帧均是从CDN服务器进行发送,所以可以节约CDN服务器的数据流量花销。
基于相同的技术构思,本公开实施例还提供了一种子节点,如图9所示,该子节点包括:
发送模块910,用于向节点发送子流订阅请求,其中,所述子流订阅请求中携带有子流编号和总子流数;
接收模块920,用于接收所述节点根据所述子流订阅请求确定出的视频包,其中,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器;
播放模块930,用于根据接收到的视频包,组成视频流,播放所述视频流。
可选的,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目;
所述发送模块910,还用于:
根据接收到的视频包中携带的所述第一时间戳和所述第二时间戳,如果存在未接收到的第一视频帧和/或第一视频包,则当达到重传间隔时,向重传服务器发送重传请求,其中,如果未接收到所述第一视频帧,则所述重传请求中携带所述第一视频帧的第一时间戳,如果未接收到所述第一视频包,则所述重传请求中携带所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号,如果未接收到所述第一视频帧和所述第一视频包,则所述重传请求中携带所述第一视频帧的第一时间戳、所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号。
可选的,所述发送模块910,还用于:
当达到重传间隔时,如果节点重传未启动,则向重传服务器发送重传请求。
可选的,所述发送模块910,还用于:
如果节点重传启动,则向发送所述第一视频包的节点和/或发送所述第一视频帧的节点发送重传请求。
可选的,如图10所示,所述子节点还包括:
第一删除模块940,用于如果当前接收到的第二视频包的时间戳与第三时间戳的差值大于第一预设阈值,或者,当前接收到的第二视频包的时间戳与第四时间戳的差值大于第一预设阈值,则将所述第二视频包删除,其中,所述第三时间戳是当前时间点之前的第一预设时长内接收到的视频包的时间戳的最小值,所述第四时间戳是当前时间点之前的所述第一预设时长内接收到的视频包的时间戳的最大值。
可选的,所述播放模块930,用于:
如果当前时间点与最后一次播放视频流中的视频帧的时间点之差达到第二预设阈值,且接收到未送去播放的视频帧的数目超过第三预设阈值,则确定接收到的视频帧中时间戳最小的I帧;
根据所述I帧的视频包及所述I帧之后的视频帧的视频包,组成视频流,播放所述视频流。
可选的,所述接收模块920,还用于:
接收音频帧;
所述播放模块930,用于:
根据接收到的视频包的帧内包序号和时间戳,将视频包组成视频帧;
根据所述视频帧的时间戳和所述音频帧的时间戳,将所述视频帧和音频帧组成音视频流;
播放所述音视频流。
可选的,如图11所示,所述子节点还包括:
第二删除模块950,用于:
如果当前接收到的第一音频帧的时间戳与第五时间戳的差值大于第四预设阈值,或者,当前接收到的第二音频帧的时间戳与第六时间戳的差值大于第四预设阈值,则将所述第二音频帧删除,其中,所述第五时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最小值,所述第六时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最大值。
可选的,所述接收模块920,还用于接收根节点切换通知;
所述发送模块910,还用于向订阅子流的根节点发送子流退订请求,并且与内容分发网络CDN服务器建立连接;
所述接收模块920,还用于从所述CDN服务器获取流媒体FLV整流。
可选的,所述接收模块920,还用于:
接收点对点P2P服务器发送的节点列表;
根据与所述节点列表中的节点进行通信,确定所述子流订阅请求发往的节点。
本公开实施例中,在推送视频帧时,根节点可以接收CDN服务器发送的流媒体FLV整流,将FLV整流中每个视频帧按照预设长度分为多个视频包,子节点可以向根节点发送子流订阅请求,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包,然后对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。这样,由于仅有根节点从CDN服务器获取视频帧,子节点是从根节点获取视频帧,而不是所有的视频帧均是从CDN服务器进行发送,所以可以节约CDN服务器的数据流量花销。
基于相同的技术构思,本公开实施例还提供了一种P2P服务器,如图12所示,该P2P服务器包括:
获取模块1210,用于获取子节点目标预设时长之内的码率;
确定模块1220,用于根据码率范围与总子流数的对应关系,确定所述码率所属的码率范围对应的总子流数;
发送模块1230,用于向所述子节点发送所述总子流数,其中,所述总子流数在所述子节点向节点发送子流订阅请求时,被携带在子流订阅请求中,携带在所述子流订阅请求的总子流数用于所述节点确定发送往所述子节点的视频包,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器。
可选的,所述确定模块1220,还用于在与本设备建立连接的终端中随机确定预设数目个根节点;
所述发送模块1230,还用于向确定出为根节点的FLV节点发送根节点切换通知,并向除所述确定为根节点FLV节点之外的其它节点发送子节点切换通知。
可选的,所述确定模块1220,还用于确定在当前时间点之前相邻的第三预设时长内各节点发送数据的数据量;
所述发送模块1230,还用于如果目标子节点对应的数据量大于或等于预设数值,则向所述目标子节点发送根节点切换通知。
可选的,所述确定模块1220,还用于确定在当前时间点之前相邻的第四预设时长内各节点发送数据的数据量;
所述发送模块1230,还用于如果目标根节点对应的数据量小于预设数值,则向所述目标根节点发送子节点切换通知。
本公开实施例中,在推送视频帧时,根节点可以接收CDN服务器发送的流媒体FLV整流,将FLV整流中每个视频帧按照预设长度分为多个视频包,子节点可以向根节点发送子流订阅请求,根节点根据接收到的子流订阅请求,在多个视频包中确定每个子流订阅请求对应的视频包,然后对于每个子流订阅请求,向子流订阅请求所属的子节点发送子流订阅请求对应的视频包。这样,由于仅有根节点从CDN服务器获取视频帧,子节点是从根节点获取视频帧,而不是所有的视频帧均是从CDN服务器进行发送,所以可以节约CDN服务器的数据流量花销。
需要说明的是:上述实施例提供的根节点、子节点和P2P服务器在视频传输时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将根节点、子节点和P2P服务器的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的根节点、子节点和P2P服务器与视频传输的方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
图13示出了本发明一个示例性实施例提供的终端1300的结构框图。该终端1300可以是:智能手机、平板电脑、MP3播放器(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面4)播放器、笔记本电脑或台式电脑。终端1300还可能被称为用户设备、便携式终端、台式终端等其他名称。通常,终端1300包括有:处理器1301和存储器1302。
处理器1301可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器1301可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。
存储器1302可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器1302还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,终端1300还可选包括有:外围设备接口1303和至少一个外围设备。处理器1301、存储器1302和外围设备接口1303之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口1303相连。具体地,外围设备包括:射频电路1304、触摸显示屏1305、摄像头1306、音频电路1307、定位组件1308和电源1309中的至少一种。在一些实施例中,终端1300还包括有一个或多个传感器1310。该一个或多个传感器1310包括但不限于:加速度传感器1311、陀螺仪传感器1312、压力传感器1313、指纹传感器1314、光学传感器1315以及接近传感器1316。
本领域技术人员可以理解,图13中示出的结构并不构成对终端1300的限定,可以包括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。实际图13所示的终端是上述提到的节点,包括根节点、子节点和FLV节点。
图14是本发明实施例提供的一种P2P服务器的结构示意图,该P2P服务器1400可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上处理器(central processing units, CPU)1401和一个或一个以上的存储器1402,其中,所述存储器1402中存储有至少一条指令,所述至少一条指令由所述处理器1401加载并执行以实现上述视频传输的方法步骤。
可选的,本公开实施例还提供了一种视频传输的系统,所述系统包括根节点、子节点和点对点P2P服务器,其中:所述根节点用于实现上述视频传输的方法步骤,所述子节点用于实现上述视频传输的方法步骤,所述P2P服务器用于实现上述视频传输的方法步骤。
可选的,本公开实施例还提供了一种节点,所述节点包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现上述视频传输的方法步骤。
可选的,本公开实施例还提供了一种点对点P2P服务器,所述P2P服务器包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现上述视频传输的方法。
可选的,本公开实施例还提供了一种计算机可读存储介质,所述存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现上述的视频传输的方法步骤。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本公开的较佳实施例,并不用以限制本公开,凡在本公开的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本公开的保护范围之内。

Claims (28)

  1. 一种视频传输的方法,其特征在于,所述方法包括:
    接收内容分发网络CDN服务器发送的流媒体FLV整流;
    将所述FLV整流中每个视频帧按照预设长度分为多个视频包;
    根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包;
    对于每个子流订阅请求,向所述子流订阅请求所属的子节点发送所述子流订阅请求对应的视频包。
  2. 根据权利要求1所述的方法,其特征在于,所述将所述FLV整流中每个视频帧按照预设长度分为多个视频包之后,还包括:
    对划分得到的多个视频包依次进行编号且每当划分的视频帧为I帧时,对划分I帧得到的视频包重新进行编号;
    所述根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包,包括:
    根据接收到的子流订阅请求和视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
  3. 根据权利要求2所述的方法,其特征在于,所述子流订阅请求中携带有子流编号和总子流数;
    所述根据接收到的子流订阅请和视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包,包括:
    根据接收到的子流订阅请求中的子流编号、总子流数以及视频包的编号,在所述多个视频包中确定每个子流订阅请求对应的视频包。
  4. 根据权利要求1至3任一所述的方法,其特征在于,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目。
  5. 根据权利要求1或2所述的方法,其特征在于,所述子流订阅请求中携带有子流编号;
    所述方法还包括:
    根据接收到的子流订阅请求中的子流编号,如果确定第一子流订阅请求中子流编号是发送音频帧的子流编号,则向所述第一子流订阅请求所属的子节点发送所述FLV整流中的音频帧。
  6. 根据权利要求5所述的方法,其特征在于,所述音频帧中还携带有所述音频帧的时间戳、所述音频帧的前一个音频帧的时间戳、音频帧的序号以及所述前一个音频帧之前相邻的连续的预设数目个音频帧的时间戳。
  7. 根据权利要求2所述的方法,其特征在于,所述方法还包括:
    接收子节点切换通知;
    如果满足子节点切换条件,则向其它节点订阅子流,并且断开与CDN服务器的连接。
  8. 一种视频传输的方法,其特征在于,所述方法包括:
    向节点发送子流订阅请求,其中,所述子流订阅请求中携带有子流编号和总子流数;
    接收所述节点根据所述子流订阅请求确定出的视频包,其中,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器;
    根据接收到的视频包,组成视频流,播放所述视频流。
  9. 根据权利要求8所述的方法,其特征在于,对于每个视频包,所述视频包还携带有所述视频包所属的视频帧的第一时间戳、所述视频包的帧内包序号、所述所属的视频帧的前一帧视频帧的第二时间戳、所述视频包所属的视频帧包含的视频包的数目;
    所述方法还包括:
    根据接收到的视频包中携带的所述第一时间戳和所述第二时间戳,如果存在未接收到的第一视频帧和/或第一视频包,则当达到重传间隔时,向重传服务器发送重传请求,其中,如果未接收到所述第一视频帧,则所述重传请求中携带所述第一视频帧的第一时间戳,如果未接收到所述第一视频包,则所述重传请求中携带所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号,如果未接收到所述第一视频帧和所述第一视频包,则所述重传请求中携带所述第一视频帧的第一时间戳、所述第一视频包所属的视频帧的第一时间戳和所述第一视频包的帧内包序号。
  10. 根据权利要求9所述的方法,其特征在于,所述当达到重传间隔时,向重传服务器发送重传请求,包括:
    当达到重传间隔时,如果节点重传未启动,则向重传服务器发送重传请求。
  11. 根据权利要求10所述的方法,其特征在于,所述方法还包括:
    如果节点重传启动,则向发送所述第一视频包的节点和/或发送所述第一视频帧的节点发送重传请求。
  12. 根据权利要求8所述的方法,其特征在于,所述方法还包括:
    如果当前接收到的第二视频包的时间戳与第三时间戳的差值大于第一预设阈值,或者,当前接收到的第二视频包的时间戳与第四时间戳的差值大于第一预设阈值,则将所述第二视频包删除,其中,所述第三时间戳是当前时间点之前的第一预设时长内接收到的视频包的时间戳的最小值,所述第四时间戳是当前时间点之前的所述第一预设时长内接收到的视频包的时间戳的最大值。
  13. 根据权利要求8所述的方法,其特征在于,所述根据接收到的视频包,组成视频流,播放所述视频流,包括:
    如果当前时间点与最后一次播放视频流中的视频帧的时间点之差达到第二预设阈值,且接收到未送去播放的视频帧的数目超过第三预设阈值,则确定接收到的视频帧中时间戳最小的I帧;
    根据所述I帧的视频包及所述I帧之后的视频帧的视频包,组成视频流,播放所述视频流。
  14. 根据权利要求8所述的方法,其特征在于,所述方法还包括:
    接收音频帧;
    所述根据接收到的视频包,组成视频流,播放所述视频流,包括:
    根据接收到的视频包的帧内包序号和时间戳,将视频包组成视频帧;
    根据所述视频帧的时间戳和所述音频帧的时间戳,将所述视频帧和音频帧组成音视频流;
    播放所述音视频流。
  15. 根据权利要求8所述的方法,其特征在于,所述方法还包括:
    如果当前接收到的第一音频帧的时间戳与第五时间戳的差值大于第四预设阈值,或者,当前接收到的第二音频帧的时间戳与第六时间戳的差值大于第四预设阈值,则将所述第二音频帧删除,其中,所述第五时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最小值,所述第六时间戳是当前时间点之前的第二预设时长内接收到的音频帧的时间戳的最大值。
  16. 根据权利要求8所述的方法,其特征在于,所述方法还包括:
    接收根节点切换通知;
    向订阅子流的根节点发送子流退订请求,并且与内容分发网络CDN服务器建立连接;
    从所述CDN服务器获取流媒体FLV整流。
  17. 根据权利要求8所述的方法,其特征在于,所述方法还包括:
    接收点对点P2P服务器发送的节点列表;
    根据与所述节点列表中的节点进行通信,确定所述子流订阅请求发往的节点。
  18. 一种视频传输的方法,其特征在于,所述方法包括:
    获取子节点目标预设时长之内的码率;
    根据码率范围与总子流数的对应关系,确定所述码率所属的码率范围对应的总子流数;
    向所述子节点发送所述总子流数,其中,所述总子流数在所述子节点向节点发送子流订阅请求时,被携带在子流订阅请求中,携带在所述子流订阅请求的总子流数用于所述节点确定发送往所述子节点的视频包,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器。
  19. 根据权利要求18所述的方法,其特征在于,所述方法还包括:
    在与本设备建立连接的终端中随机确定预设数目个根节点;
    向确定出为根节点的FLV节点发送根节点切换通知,并向除所述确定为根节点FLV节点之外的其它节点发送子节点切换通知。
  20. 根据权利要求19所述的方法,其特征在于,所述方法还包括:
    确定在当前时间点之前相邻的第三预设时长内各节点发送数据的数据量;
    如果目标子节点对应的数据量大于或等于预设数值,则向所述目标子节点发送根节点切换通知。
  21. 根据权利要求19或20所述的方法,其特征在于,所述方法还包括:
    确定在当前时间点之前相邻的第四预设时长内各节点发送数据的数据量;
    如果目标根节点对应的数据量小于预设数值,则向所述目标根节点发送子节点切换通知。
  22. 一种视频传输的根节点,其特征在于,所述根节点包括:
    接收模块,用于接收内容分发网络CDN服务器发送的流媒体FLV整流;
    拆分模块,用于将所述FLV整流中每个视频帧按照预设长度分为多个视频包;
    确定模块,用于根据接收到的子流订阅请求,在所述多个视频包中确定每个子流订阅请求对应的视频包;
    发送模块,用于对于每个子流订阅请求,向所述子流订阅请求所属的子节点发送所述子 流订阅请求对应的视频包。
  23. 一种视频传输的子节点,其特征在于,所述子节点包括:
    发送模块,用于向节点发送子流订阅请求,其中,所述子流订阅请求中携带有子流编号和总子流数;
    接收模块,用于接收所述节点根据所述子流订阅请求确定出的视频包,其中,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器;
    播放模块,用于根据接收到的视频包,组成视频流,播放所述视频流。
  24. 一种视频传输的点对点P2P服务器,其特征在于,所述P2P服务器包括:
    获取模块,用于获取子节点目标预设时长之内的码率;
    确定模块,用于根据码率范围与总子流数的对应关系,确定所述码率所属的码率范围对应的总子流数;
    发送模块,用于向所述子节点发送所述总子流数,其中,所述总子流数在所述子节点向节点发送子流订阅请求时,被携带在子流订阅请求中,携带在所述子流订阅请求的总子流数用于所述节点确定发送往所述子节点的视频包,所述视频包是所述节点将视频帧按照预设长度拆分得到,所述视频帧由所述节点接收自内容分发网络CDN服务器。
  25. 一种视频传输的系统,其特征在于,所述系统包括根节点、子节点和点对点P2P服务器,其中:
    所述根节点,如上述权利要求22所述的根节点;
    所述子节点,如上述权利要求23所述的子节点;
    所述P2P服务器,如上述权利要求24所述的P2P服务器。
  26. 一种节点,其特征在于,所述节点包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如权利要求1至17任一所述的视频传输的方法。
  27. 一种点对点P2P服务器,其特征在于,所述P2P服务器包括处理器和存储器,所述存储器中存储有至少一条指令,所述指令由所述处理器加载并执行以实现如权利要求18至21任一所述的视频传输的方法。
  28. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现如权利要求1至21任一所述的视频传输的方法。
PCT/CN2019/120024 2019-03-26 2019-11-21 视频传输的方法、根节点、子节点、p2p服务器和系统 WO2020192152A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910234475.X 2019-03-26
CN201910234475.XA CN109889543B (zh) 2019-03-26 2019-03-26 视频传输的方法、根节点、子节点、p2p服务器和系统

Publications (1)

Publication Number Publication Date
WO2020192152A1 true WO2020192152A1 (zh) 2020-10-01

Family

ID=66934576

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/120024 WO2020192152A1 (zh) 2019-03-26 2019-11-21 视频传输的方法、根节点、子节点、p2p服务器和系统

Country Status (2)

Country Link
CN (1) CN109889543B (zh)
WO (1) WO2020192152A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112437346A (zh) * 2020-11-04 2021-03-02 央视国际网络无锡有限公司 一种判断视频文件是否完整的方法
CN112770122A (zh) * 2020-12-31 2021-05-07 上海网达软件股份有限公司 一种在云导播台视频同步的方法及系统
CN112967142A (zh) * 2021-03-31 2021-06-15 上海英方软件股份有限公司 一种行情信息流的转发方法及装置
CN114499777A (zh) * 2022-04-15 2022-05-13 四川腾盾科技有限公司 一种集群无人系统数据传输方法
CN114567638A (zh) * 2022-02-14 2022-05-31 珠海迈科智能科技股份有限公司 一种根据节点实际网络动态调整分享策略的方法
CN114697610A (zh) * 2020-12-30 2022-07-01 成都鼎桥通信技术有限公司 视频传输方法及电子设备

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109889543B (zh) * 2019-03-26 2020-11-13 广州华多网络科技有限公司 视频传输的方法、根节点、子节点、p2p服务器和系统
CN110493327B (zh) * 2019-08-05 2022-06-10 网宿科技股份有限公司 一种数据传输方法及装置
EP3809668A1 (en) * 2019-10-14 2021-04-21 Sandvine Corporation System and method for monitoring and managing video stream content
CN111343475B (zh) * 2020-03-04 2022-04-15 广州虎牙科技有限公司 数据处理方法和装置、直播服务器及存储介质
CN111669610B (zh) * 2020-05-27 2022-08-05 北京奇艺世纪科技有限公司 直播视频的传输方法、系统、装置、服务器、电子设备及存储介质
CN111988674A (zh) * 2020-08-18 2020-11-24 广州极飞科技有限公司 一种多媒体数据传输方法、装置、设备及存储介质
CN112261418B (zh) * 2020-09-18 2022-09-30 网宿科技股份有限公司 一种传输直播视频数据的方法和直播加速系统
CN113242113A (zh) * 2021-04-30 2021-08-10 北京汇钧科技有限公司 数据传输控制方法、装置、电子设备及存储介质
CN114821936A (zh) * 2022-03-21 2022-07-29 慧之安信息技术股份有限公司 基于边缘计算的违法犯罪行为检测方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150100665A1 (en) * 2013-10-07 2015-04-09 Electronics And Telecommunications Research Institute Digital display terminal, contents server, and method of transmitting and receiving content
CN104735044A (zh) * 2014-11-18 2015-06-24 深圳市同洲电子股份有限公司 一种流媒体直播方法及系统
CN109348257A (zh) * 2018-11-14 2019-02-15 广州虎牙信息科技有限公司 拉流控制方法、装置及直播系统
CN109474684A (zh) * 2018-11-14 2019-03-15 广州虎牙信息科技有限公司 一种获取直播视频流的方法、装置、终端设备及存储介质
CN109889543A (zh) * 2019-03-26 2019-06-14 广州华多网络科技有限公司 视频传输的方法、根节点、子节点、p2p服务器和系统

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8051161B2 (en) * 2008-12-08 2011-11-01 Microsoft Corporation Peer-to-peer (P2P) streaming overlay construction and optimization
CN101959054B (zh) * 2009-07-14 2013-04-10 中国电信股份有限公司 集中式对等点播系统和伙伴节点选择方法
CN105338421A (zh) * 2014-08-05 2016-02-17 深圳国微技术有限公司 一种hls流媒体传输方法及装置
CN105792021A (zh) * 2014-12-26 2016-07-20 乐视网信息技术(北京)股份有限公司 一种视频流的传输方法及装置
CN104967866B (zh) * 2015-05-13 2018-04-06 浙江树人大学 一种动态自适应的p2p直播流媒体子流调度方法
CN106649855B (zh) * 2016-12-30 2019-06-21 中广热点云科技有限公司 一种视频标签的添加方法和添加系统
CN108696773B (zh) * 2017-04-11 2021-03-09 苏州谦问万答吧教育科技有限公司 一种实时视频的传输方法及装置
CN107426629B (zh) * 2017-06-19 2020-06-23 网宿科技股份有限公司 一种流媒体文件处理方法及直播系统
CN109510868B (zh) * 2018-11-14 2021-01-22 广州虎牙信息科技有限公司 一种建立p2p网络的方法、装置、终端设备及存储介质
CN109348243B (zh) * 2018-11-14 2021-01-22 广州虎牙信息科技有限公司 订阅处理方法、装置、直播系统、存储介质及计算机设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150100665A1 (en) * 2013-10-07 2015-04-09 Electronics And Telecommunications Research Institute Digital display terminal, contents server, and method of transmitting and receiving content
CN104735044A (zh) * 2014-11-18 2015-06-24 深圳市同洲电子股份有限公司 一种流媒体直播方法及系统
CN109348257A (zh) * 2018-11-14 2019-02-15 广州虎牙信息科技有限公司 拉流控制方法、装置及直播系统
CN109474684A (zh) * 2018-11-14 2019-03-15 广州虎牙信息科技有限公司 一种获取直播视频流的方法、装置、终端设备及存储介质
CN109889543A (zh) * 2019-03-26 2019-06-14 广州华多网络科技有限公司 视频传输的方法、根节点、子节点、p2p服务器和系统

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112437346A (zh) * 2020-11-04 2021-03-02 央视国际网络无锡有限公司 一种判断视频文件是否完整的方法
CN114697610A (zh) * 2020-12-30 2022-07-01 成都鼎桥通信技术有限公司 视频传输方法及电子设备
CN114697610B (zh) * 2020-12-30 2023-08-18 成都鼎桥通信技术有限公司 视频传输方法及电子设备
CN112770122A (zh) * 2020-12-31 2021-05-07 上海网达软件股份有限公司 一种在云导播台视频同步的方法及系统
CN112770122B (zh) * 2020-12-31 2022-10-14 上海网达软件股份有限公司 一种在云导播台视频同步的方法及系统
CN112967142A (zh) * 2021-03-31 2021-06-15 上海英方软件股份有限公司 一种行情信息流的转发方法及装置
CN114567638A (zh) * 2022-02-14 2022-05-31 珠海迈科智能科技股份有限公司 一种根据节点实际网络动态调整分享策略的方法
CN114567638B (zh) * 2022-02-14 2023-09-01 珠海迈科智能科技股份有限公司 一种根据节点实际网络动态调整分享策略的方法
CN114499777A (zh) * 2022-04-15 2022-05-13 四川腾盾科技有限公司 一种集群无人系统数据传输方法
CN114499777B (zh) * 2022-04-15 2022-07-22 四川腾盾科技有限公司 一种集群无人系统数据传输方法

Also Published As

Publication number Publication date
CN109889543A (zh) 2019-06-14
CN109889543B (zh) 2020-11-13

Similar Documents

Publication Publication Date Title
WO2020192152A1 (zh) 视频传输的方法、根节点、子节点、p2p服务器和系统
KR102387161B1 (ko) 비디오 스크린 프로젝션 방법과 장치, 컴퓨터 장비, 및 저장 매체
CN107135417B (zh) 一种hls协议的投屏方法及系统
JP5588517B2 (ja) データセグメントのオプションのブロードキャスト配信によるストリーミング
US11178200B2 (en) Systems and methods for playing adaptive bitrate streaming content by multicast
US7587507B2 (en) Media recording functions in a streaming media server
WO2016049987A1 (zh) 一种数据处理方法、装置及相关服务器
CN109474684B (zh) 一种获取直播视频流的方法、装置、终端设备及存储介质
CN107819809B (zh) 对内容进行同步操作的方法及装置
JP5257367B2 (ja) 映像配信装置、映像配信システム及び映像配信方法
CN109560901A (zh) 一种数据重传方法、装置、终端设备及存储介质
KR20100050516A (ko) 네트워크에서의 데이터 콘텐츠 스트리밍
EP1806870B1 (en) Method for providing data and data transmission system
KR20080075095A (ko) 비디오 네트워크를 관리하는 방법 및 시스템
US20120233346A1 (en) Method, apparatus and system for rapid acquisition of multicast realtime transport protcol sessions
CN110445723B (zh) 一种网络数据调度方法及边缘节点
KR20120011969A (ko) Rtsp 세션에 기초해 스트리밍 데이터를 송수신하는 방법 및 장치
US20150188963A1 (en) Systems and Methods for Distributing Adaptive Bitrate Streaming Content by Multicast
KR20190018142A (ko) Mmt 전송 패킷의 설정 방법 및 전송 방법
CN114245153B (zh) 切片方法、装置、设备及可读存储介质
JP7259056B2 (ja) メディアストリーム送信方法、装置、システム、およびデバイス
JP2004135239A (ja) データ配信装置、受信装置、データ配信方法、データ配信プログラム、および該プログラムを記録した記録媒体
JP2015501018A (ja) コンテンツをサーバおよび対応する装置上のファイルに保存する方法
CN113726817B (zh) 一种流媒体数据的传输方法、装置及介质
US10523409B2 (en) Method of synchronization during the processing, by a multimedia player, of an item of multimedia content transmitted by an MBMS service

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19921154

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19921154

Country of ref document: EP

Kind code of ref document: A1