Transfer multicast method based on Darwin streaming media server
Technical Field
The invention relates to the field of computer communication, in particular to a transfer multicast method based on a Darwinian streaming media server.
Background
The problems of the existing streaming media server are as follows:
1) the existing streaming media server with relay multicast capability adopts a multicast mode based on client access, that is, a mode of passively receiving RTSP (real time streaming media transport protocol) instructions and actively pushing audio and video data streams. However, in the use of the actual enterprise level, camera resources above ten million levels are often required to be accessed, a large number of code streams are divided and provided for different function servers to perform different function processing, and the method is a mode of actively pushing an RTSP (real time streaming media transport protocol) instruction and actively pushing audio and video data streams in interaction; for example, an RTSP (real time streaming media protocol) instruction is actively pushed to a storage Server, and then, an audio/video code stream is actively pushed to the storage Server for storage, the following processes are the same, such as analyzing the code stream Server, playing the code stream Server in real time, and the like, meanwhile, a machine room is constructed with a required bastion machine with a level of 1, and the backup machine is in a hot-switch backup so as to achieve a fault-free and seamless system level, as described above, a plurality of different processing schemes are often provided for a code stream, a relay Server needs to conduct single-path flow guiding and multi-path forwarding, so that multicast is necessary at this stage, and several open source real time streaming media playing Server programs, darwinstreamstreamstreet, Live555Server and libVLC development libraries do not realize multicast in an Announce instruction mode under the RTSP protocol, which results in that an enterprise level uses a very large number of rack servers and very high bandwidth network cards, various cost resources such as a core switch and the like are arranged, the complexity of machine room construction and comprehensive wiring and the later maintenance cost are increased, and various unpredictable instabilities, packet loss and jitter are generated when the high-flow long-time operation is carried out on the premise of 30-24.
2) The existing switch and router equipment both support IGMP protocol and have multicast function, but the system layout without multicast function wastes a large amount of resources invisibly.
3) In the server distribution mode in the existing unicast (unicast) mode, if there are 1000 system layout requirements to be distributed to 5 functional servers, 1000 × 5 links (i.e. each has 5 links and data packets with the same function) and data traffic are required, and on this premise, the network is full of multiple copies of a large number of the same data packets, and a large amount of redundant data causes heavy network load, long delay, network congestion and even network crash.
4) In the existing Broadcast mode, all hosts in the network need to receive one copy of the same data packet, and a large amount of redundant data also exists, so that the network is quite heavy in burden, delay, congestion and even breakdown.
Disclosure of Invention
The invention aims to provide a transfer multicast method based on a Darwinian streaming media server, which is characterized in that the Darwinian streaming media server is divided into two parts to be deployed, the scheme that the original Darwinian streaming media server only supports unicast transfer is changed, transfer multicast is realized, the quantity statistics with announcing as the transfer destination is carried out in the transfer process, whether a transfer address is a multicast address or not can be judged, whether an audio/video stream transfer address can be stored in the transfer server or not can be judged, one-path code stream multi-path transfer is also realized, the network bandwidth and the network flow are greatly relieved, and the multicast function of network hardware is fully utilized.
In order to achieve the technical purpose, the technical scheme of the invention is as follows:
a transfer multicast method based on a Darwinian streaming media server comprises the following steps:
firstly, deploying the executable file of the Darwinian streaming media server in two parts, if the attribute value of a mark in a configuration file or a database field of the Darwinian streaming media server is true, defining the Darwinian server as a transit server, and if the attribute value of the configuration file or the database field of the Darwinian server is false, defining the Darwinian server as a receiving reflection server; the purpose of the step is to divide the original Darwinian streaming media server into two parts for deployment, wherein a remote camera stream guiding part is defined as a transfer server, and a part for receiving a transfer data stream and reflecting the corresponding data stream to a client is defined as a receiving reflection server;
secondly, initializing a module or a plug-in with transfer and forwarding functions in the starting process of the transfer server;
in the starting process of the Darwinian streaming media server, a module or a plug-in with a transfer and forwarding function is initialized, so that the Darwinian streaming media server defined as the transfer function has the same function;
thirdly, a module with a forwarding function in a transit server firstly reads an IP address and a port number of a target camera and a Uniform Resource Locator (URL) in a real-time streaming media data transmission protocol (RTSP), acquires audio and video code stream data of the target camera after the transit server is linked with the target camera, and acquires a session description file (suffix name. SDP) of the target camera by a Session Description Protocol (SDP) of a load acquired in the real-time streaming media data transmission protocol interaction process;
fourthly, when the transfer server is linked with the target camera, the module with the forwarding function reads the IP address and the port number of the receiving server and the unique identifier in the uniform resource identifier of the ANNOUNCE mode in the real-time streaming media transmission protocol used for forwarding; such as "live 1. sdp". The unique identification suffix name is used uniformly; the ANNOUNCE mode is an extension method of a real-time streaming media transmission protocol, and has unique identification of a uniform resource identifier;
then reading destination end information of ANNOUNCE link needing to be created in the process of transmitting the real-time streaming media transmission protocol; the ANNOUNCE link is established by using a TCP mode; so as to ensure the accurate and reliable delivery and reply of the interactive instruction of the real-time streaming media transmission protocol;
fifthly, the module with the forwarding function reads a destination IP address to be forwarded to the receiving and reflecting server by using a real-time transmission protocol, wherein the destination IP address is a D-type IP address; namely a multicast address;
sixthly, counting the number of transfer targets according to the number of ANNOUNCE forwarding addresses when a module with a forwarding function reads the ANNOUNCE forwarding addresses and the audio and video code stream forwarding addresses in the real-time streaming media transmission protocol;
seventhly, the transfer server takes the real-time streaming media transmission protocol to link the primary target camera for audio and video data flow as a session unit, and then creates a real-time streaming media transmission protocol session for link drainage;
when the interactive instruction of the real-time streaming media transmission protocol of the target camera is successfully linked to Descripte, a transfer session class (RelaySession) is opened up, and a transfer session creating function SetupRelaySession () in a transfer server is called to start creating a transfer session;
after the real-time streaming media transmission protocol interaction instruction link process of the target camera is completely successful, a relay (RelayOutput) is opened, a relay task (RelayAnnouncer) is started to prepare for forwarding an audio and video data stream led from the target camera to a receiving reflection server, the receiving reflection server of the destination performs real-time streaming media transmission protocol interaction, the interaction instruction sequence is Announce- > Setup- > Play- > Teardown, and the sender of the interaction instruction is the relay task RelayAnnouncer;
eighthly, when the transfer task sends an Announce instruction, a loaded CIN IN a session description protocol is that the value of field content is a D-type multicast address, namely a multicast address to be sent later by audio and video data, and when the transfer task (Relay Announce) sends a Setup instruction, the instruction field informs a receiving end that the playing mode is a multicast mode;
and ninthly, when the interactive real-time streaming media transmission protocol between the relay task and the receiving and reflecting server of the relay destination is successfully interacted, judging whether the relay session is available, if so, simultaneously judging whether the relay destination address is a multicast address and judging whether the current session taking the audio-video data stream of the target camera as a session unit is established to be a forwarding multicast session, if so, adding the current relay address into a relay storage structure bucket of the relay server, if not, adopting a unicast mode, completely adding the relay address into the relay storage structure bucket, if not, re-acquiring the next relay address for judgment, and deleting the relay address only under the condition that the relay address is invalid.
Compared with the prior art, the invention has the advantages that:
1. in the prior art, the transfer and reflection processes of a Darwin streaming media server are all executable files, the code stream is sent to the Darwin streaming media server during transfer, and the code stream is reflected to a corresponding client when the client is accessed, so that the limitation is too large in a scene that an enterprise level has thousands of cameras and the code stream needs to be subjected to various processing;
the invention divides the original Darwinian streaming media server into two parts, namely a transfer server and a reflection server, and has flexible deployment mode and strong scene adaptability;
2. in the prior art, the transfer process of the darwinian streaming media server only supports a UDP unicast mode, and in the mode, when N kinds of function processing are required to be carried out on one path of code stream, the same N number of code streams are required to be transferred, so that the pressure on bandwidth and network equipment is huge;
the invention realizes that one path of code stream can be forwarded by N paths by realizing the multicast in the transfer process, greatly reduces the network flow pressure and fully utilizes the multicast capability of hardware in the network;
3. the Dalbergia streaming media server in the prior art takes a field with a destination mark in a configuration file as the quantity statistics of forwarding targets;
the method takes the Announce instruction in the real-time streaming media protocol as the quantity statistics of the forwarding target, and simultaneously judges whether the forwarding address is a multicast address or not and whether the condition that whether the multicast is established or not is satisfied or not by taking one-time target camera flow guiding conversation as a unit so as to determine whether to add the audio and video stream forwarding address into an original transit cache structure barrel (Bucket) of the Darwin streaming media server or not;
4. the Setup instruction of the real-time streaming media protocol (RTSP) process of the darwin streaming media server in the prior art only supports the unicast mode under the UDP transport protocol, and the method of the present invention simultaneously supports the multicast mode under the UDP transport protocol.
Therefore, the Darwin streaming media server is divided into two parts for deployment, so that media data transmission can be more reasonably distributed on different hardware servers and provided for the servers with different functions to be processed, and meanwhile, the switch hardware equipment in the video private network is fully utilized to realize one-path code stream multi-path transfer under the condition of not increasing the uplink and downlink flow of the network card of the server, so that the network bandwidth and the network flow are greatly relieved, the deployment mode is flexible, and the scene adaptability is strong.
The invention is described in further detail below with reference to the figures and specific examples.
Drawings
Fig. 1 is a flowchart of a conventional relay unicast mode;
fig. 2 is a flowchart of a relay multicast method based on a darwinian streaming media server according to the present invention.
Detailed Description
As shown in fig. 2, the relay multicast method based on the darwin streaming media server of the present invention specifically includes the following steps:
firstly, deploying the executable file of the Darwinian streaming media server in two parts, if the attribute value of a mark in a configuration file or a database field of the Darwinian streaming media server is true, defining the Darwinian server as a transit server, and if the attribute value of the configuration file or the database field of the Darwinian server is false, defining the Darwinian server as a receiving reflection server; the purpose of the step is to divide the original Darwinian streaming media server into two parts for deployment, wherein a remote camera stream guiding part is defined as a transfer server, and a part for receiving a transfer data stream and reflecting the corresponding data stream to a client is defined as a receiving reflection server;
secondly, initializing a module or a plug-in with transfer and forwarding functions in the starting process of the transfer server;
in the starting process of the Darwinian streaming media server, a module or a plug-in with a transfer and forwarding function is initialized, so that the Darwinian streaming media server defined as the transfer function has the same function;
thirdly, a module with a forwarding function in a transit server firstly reads an IP address and a port number of a target camera and a Uniform Resource Locator (URL) in a real-time streaming media data transmission protocol (RTSP), acquires audio and video code stream data of the target camera after the transit server is linked with the target camera, and acquires a session description file (suffix name. SDP) of the target camera by a Session Description Protocol (SDP) of a load acquired in the real-time streaming media data transmission protocol interaction process;
fourthly, when the transfer server is linked with the target camera, the module with the forwarding function reads the IP address and the port number of the receiving server and the unique identifier in the uniform resource identifier of the ANNOUNCE mode in the real-time streaming media transmission protocol used for forwarding; such as "live 1. sdp". The unique identification suffix name is used uniformly; the ANNOUNCE mode is an extension method of a real-time streaming media transmission protocol, and has unique identification of a uniform resource identifier;
then reading destination end information of ANNOUNCE link needing to be created in the process of transmitting the real-time streaming media transmission protocol; the ANNOUNCE link is established by using a TCP mode; so as to ensure the accurate and reliable delivery and reply of the interactive instruction of the real-time streaming media transmission protocol;
fifthly, the module with the forwarding function reads a destination IP address to be forwarded to the receiving and reflecting server by using a real-time transmission protocol, wherein the destination IP address is a D-type IP address; namely a multicast address;
sixthly, counting the number of transfer targets according to the number of ANNOUNCE forwarding addresses when a module with a forwarding function reads the ANNOUNCE forwarding addresses and the audio and video code stream forwarding addresses in the real-time streaming media transmission protocol;
seventhly, the transfer server takes the real-time streaming media transmission protocol to link the primary target camera for audio and video data flow as a session unit, and then creates a real-time streaming media transmission protocol session for link drainage;
when the interactive instruction of the real-time streaming media transmission protocol of the target camera is successfully linked to Descripte, a transfer session class (RelaySession) is opened up, and a transfer session creating function SetupRelaySession () in a transfer server is called to start creating a transfer session;
after the real-time streaming media transmission protocol interaction instruction link process of the target camera is completely successful, a relay (RelayOutput) is opened, a relay task (RelayAnnouncer) is started to prepare for forwarding an audio and video data stream led from the target camera to a receiving reflection server, the receiving reflection server of the destination performs real-time streaming media transmission protocol interaction, the interaction instruction sequence is Announce- > Setup- > Play- > Teardown, and the sender of the interaction instruction is the relay task RelayAnnouncer;
eighthly, when the transfer task sends an Announce instruction, a loaded CIN IN a session description protocol is that the value of field content is a D-type multicast address, namely a multicast address to be sent later by audio and video data, and when the transfer task (Relay Announce) sends a Setup instruction, the instruction field informs a receiving end that the playing mode is a multicast mode;
and ninthly, when the interactive real-time streaming media transmission protocol between the relay task and the receiving and reflecting server of the relay destination is successfully interacted, judging whether the relay session is available, if so, simultaneously judging whether the relay destination address is a multicast address and judging whether the current session taking the audio-video data stream of the target camera as a session unit is established to be a forwarding multicast session, if so, adding the current relay address into a relay storage structure bucket of the relay server, if not, adopting a unicast mode, completely adding the relay address into the relay storage structure bucket, if not, re-acquiring the next relay address for judgment, and deleting the relay address only under the condition that the relay address is invalid.
By adopting the transfer multicast method, the following advantages can be obtained:
firstly, one path of drainage is distributed and arranged at the processing stage of the Darwin streaming media server, and multi-path forwarding becomes possible without adding redundant hardware resources.
And secondly, the flow data in the streaming media network is greatly reduced, and one copy of data and multiple copies of data are realized.
Thirdly, the system structure is arranged simply and cleanly, the problem is solved and positioned quickly and is easy to solve.
Fourthly, multicast capability resources of the hardware of the switch and the router are fully utilized.