Ejemplo n.º 1
0
        public static bool Connect(EndPoint endpoint, Variant parameters)
        {
            var chain = ProtocolFactoryManager.ResolveProtocolChain(Defines.CONF_PROTOCOL_OUTBOUND_RTMP);

            TCPConnector <OutboundRTMPProtocol> .Connect(endpoint, chain, parameters);

            return(true);
        }
Ejemplo n.º 2
0
        bool BindAcceptor(Variant node)
        {
            //1. Get the chain
            var chain = ProtocolFactoryManager.ResolveProtocolChain(node[CONF_PROTOCOL]);

            if (chain.Count == 0)
            {
                WARN("Invalid protocol chain: {0}", node[CONF_PROTOCOL]);
            }
            //2. Is it TCP or UDP based?
            if (chain[0] == ProtocolTypes.PT_TCP)
            {
                //3. This is a tcp acceptor. Instantiate it and start accepting connections
                var pAcceptor = new TCPAcceptor(node[CONF_IP], node[CONF_PORT], node, chain);
                if (!pAcceptor.Bind())
                {
                    FATAL("Unable to fire up acceptor from this config node:{0}", node.ToString());
                    return(false);
                }
                acceptors.Add(pAcceptor);
                return(true);
            }
            else if (chain[0] == ProtocolTypes.PT_UDP)
            {
                //4. Ok, this is an UDP acceptor. Because of that, we can instantiate
                //the full stack. Get the stack first
                var pProtocol = ProtocolFactoryManager.CreateProtocolChain(chain, node);
                if (pProtocol == null)
                {
                    FATAL("Unable to instantiate protocol stack {0}", node[CONF_PROTOCOL]);
                    return(false);
                }
                //5. Create the carrier and bind it
                var pUDPCarrier = UDPCarrier.Create(node[CONF_IP], node[CONF_PORT], pProtocol);
                if (pUDPCarrier == null)
                {
                    FATAL("Unable to instantiate UDP carrier on {0}:{1}", node[CONF_IP],
                          node[CONF_PORT]);
                    pProtocol.EnqueueForDelete();
                    return(false);
                }
                pUDPCarrier.Parameters = node;
                acceptors.Add(pUDPCarrier);
                return(true);
            }
            else
            {
                FATAL("Invalid carrier type");
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool ConnectOutboundCluster()
        {
            var uri = new Uri(Configuration["master"]);
            //string localStreamName = streamConfig["localStreamName"] ?? "stream_" + Utils.GenerateRandomString(8);
            var parameters = Variant.Get();

            //parameters["customParameters", "externalStreamConfig"] = streamConfig;
            parameters[Defines.CONF_APPLICATION_NAME] = Application.Name;
            var scheme   = uri.Scheme;
            var endpoint =
                new IPEndPoint(
                    Dns.GetHostAddresses(uri.Host).First(x => x.AddressFamily == AddressFamily.InterNetwork),
                    uri.Port > 0 ? uri.Port : 1935);

            var chain = ProtocolFactoryManager.ResolveProtocolChain(Defines.CONF_PROTOCOL_OUTBOUND_CLUSTER);

            return(TCPConnector <OutboundClusterProtocol> .Connect(endpoint, chain, parameters));
        }