Stream sharing among multiple FMS servers

Source: Internet
Author: User

A very important feature of the system is that the stream can be shared among multiple servers.

With this function, we can distribute the streams on the source server to other servers. These servers that obtain the streams can also be used as new source servers. This function is a bit like an FMS cluster.

We all know that using the WMP plug-in can obtain the streaming media address on the Internet to create a network TV station. In fact, using flash and FMS can also be achieved.

Collect TV signals on a server, and then pub the collected stream to an app with an IP address of 127.0.0.1 (Suppose it is a tvset). Assume that the stream is named "cctv1 ",

In this way, the FP Client Connected to the server can easily obtain the stream. However, if the number of connections is large, the server may be overloaded and traffic distribution needs to be considered.

There are at least two kinds of shunting solutions. One is to use the proxy server, and the other is to share the stream among multiple servers.

So how can we distribute the stream?

This first source server does not need to do anything. It is only responsible for receiving and pub TV signals. We need to find another server, which is used in the FMS.ProgramIn Main. ASC, write the followingCode:

// Executed when the program starts
Application. onappstart = function (){
This. mync = new netconnection ();
This. mync. onstatus = nc_onstatus;
This. mync. Connect ("rtmp: // address of the first source server/tvset ");
};

Function nc_onstatus (Info ){
Switch (info. Code ){
Case "netconnection. Connect. Success ":
Application. mystream = stream. Get ("cctv1 ");
Application. mystream. onstatus = ns_onstatus;
If (application. mystream ){
Application. mystream. Play ("cctv1",-2,-1, false, application. mync );
}
Trace ("connection successful! ");
Break;
Case "netconnection. Connect. Failed ":
Trace ("connection failed! ");
Break;
Case "netconnection. Connect. Rejected ":
Trace ("connection failed! ");
Break;
}
}
Function ns_onstatus (Info ){
Trace (info. Code );
}

In this way, the new server obtains the same stream as the first source server.

When the client is connected again, it does not have to connect to the first source server and connect to the new source server. The new source server can be one or multiple, in this way, the burden on the first source server will be minimized.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.