protected virtual void ProcessInputData(object obj)
        {
            HttpListenerContext ctx = obj as HttpListenerContext;

            if (ctx == null)
            {
                return;
            }

            IMediaHandler       handler  = null;
            List <MediaChannel> channels = new List <MediaChannel>();

            var urlSegments = ctx.Request.Url.Segments;

            string channelNames = "";

            if (urlSegments.Length > 1)
            {
                channelNames = urlSegments[1].Replace("/", "");
            }

            if (channelNames.Length > 0)
            {
                var names = channelNames.Split(',');
                foreach (var channelName in names)
                {
                    var channel = GetChannel(channelName.Trim());
                    if (channel != null && channel.IsWorking() == false)
                    {
                        channel.Start();
                    }
                    if (channel != null)
                    {
                        channels.Add(channel);
                    }
                }
            }

            if (channels.Count > 0)
            {
                string typeinfo = "";
                if (urlSegments.Length > 2)
                {
                    typeinfo = urlSegments[2].Replace("/", "");
                }
                if (typeinfo.Length > 0)
                {
                    handler = m_ResourceManager.GetHandler(typeinfo);
                }
            }

            if (channels.Count > 0 && handler != null)
            {
                string mediainfo = "";
                if (urlSegments.Length > 3)
                {
                    mediainfo = urlSegments[3].Replace("/", "");
                }
                if (mediainfo.Length > 0)
                {
                    mediainfo = handler.GetMediaType() + "(" + mediainfo + ")";
                }
                else
                {
                    mediainfo = handler.GetMediaType();
                }

                foreach (var channel in channels)
                {
                    MediaChannelState state = new MediaChannelState();
                    state.ChannelName = channel.ChannelName;
                    state.AddressInfo = ctx.Request.RemoteEndPoint.ToString();
                    state.MediaInfo   = mediainfo;
                    state.ClientCount = 0;

                    UpdateState(channel.ChannelName, state);
                }

                handler.HandleInput(this, channels, ctx.Request.InputStream, mediainfo);

                foreach (var channel in channels)
                {
                    //channel.SetWelcomeText("");
                    channel.RemoveWelcomeText(mediainfo);
                    channel.SetWelcomeData(new byte[0]);
                    RemoveState(channel.ChannelName);
                }
            }

            try
            {
                ctx.Response.Abort(); // make sure the connection is closed
            }
            catch (Exception ex)
            {
                Logger.Error("HTTP context error: " + ex.Message);
            }
        }
        protected virtual void ProcessInputData(object obj)
        {
            HttpListenerContext ctx = obj as HttpListenerContext;

            if (ctx == null)
            {
                return;
            }

            string remoteIp  = "";
            string sourceUrl = "";

            try
            {
                remoteIp  = ctx.Request.RemoteEndPoint.Address.ToString();
                sourceUrl = "[" + remoteIp + "] - " + ctx.Request.Url.ToString();
            }
            catch (Exception ex)
            {
                Logger.Error("HTTP context error: " + ex.Message);
            }

            IMediaHandler       handler  = null;
            List <MediaChannel> channels = new List <MediaChannel>();

            var urlSegments = ctx.Request.Url.Segments;

            string channelNames = "";

            if (urlSegments.Length > 1)
            {
                channelNames = urlSegments[1].Replace("/", "");
            }

            if (channelNames.Length > 0)
            {
                var names = channelNames.Split(',');
                foreach (var channelName in names)
                {
                    var channel = GetChannel(channelName.Trim());

                    if (channel != null)
                    {
                        channel.AddInputUrl(sourceUrl);
                    }
                    if (channel != null)
                    {
                        var srcUrls = channel.GetInputUrls();
                        Logger.Info("Channel #" + channelName + "# input source updated >> ");
                        foreach (var srcUrl in srcUrls)
                        {
                            Logger.Info("#" + channelName + "# - " + srcUrl);
                        }
                    }

                    if (channel != null && channel.IsWorking() == false)
                    {
                        channel.Start();
                    }
                    if (channel != null)
                    {
                        channels.Add(channel);
                    }

                    Thread.Sleep(50);
                }
            }

            if (channels.Count > 0)
            {
                string typeinfo = "";
                if (urlSegments.Length > 2)
                {
                    typeinfo = urlSegments[2].Replace("/", "");
                }
                if (typeinfo.Length > 0)
                {
                    handler = m_ResourceManager.GetHandler(typeinfo);
                }
            }

            if (channels.Count > 0 && handler != null)
            {
                string mediainfo = "";
                if (urlSegments.Length > 3)
                {
                    mediainfo = urlSegments[3].Replace("/", "");
                }
                if (mediainfo.Length > 0)
                {
                    mediainfo = handler.GetMediaType() + "(" + mediainfo + ")";
                }
                else
                {
                    mediainfo = handler.GetMediaType();
                }

                foreach (var channel in channels)
                {
                    MediaChannelState state = new MediaChannelState();
                    state.ChannelName = channel.ChannelName;
                    state.AddressInfo = ctx.Request.RemoteEndPoint.ToString();
                    state.MediaInfo   = mediainfo;
                    state.ClientCount = 0;

                    UpdateState(channel.ChannelName, state);
                }

                // should ensure there is at least a try-catch block inside the process function
                handler.HandleInput(this, channels, ctx.Request.InputStream, mediainfo);

                foreach (var channel in channels)
                {
                    //channel.SetWelcomeText("");
                    channel.RemoveWelcomeText(mediainfo);
                    channel.SetWelcomeData(new byte[0]);

                    channel.RemoveInputUrl(sourceUrl);
                    if (channel != null)
                    {
                        var srcUrls = channel.GetInputUrls();
                        if (srcUrls.Count > 0)
                        {
                            Logger.Info("Channel #" + channel.ChannelName + "# input source updated >> ");
                            foreach (var srcUrl in srcUrls)
                            {
                                Logger.Info("#" + channel.ChannelName + "# - " + srcUrl);
                            }
                        }
                        else
                        {
                            Logger.Info("Channel #" + channel.ChannelName + "# input source dropped.");
                        }
                    }

                    RemoveState(channel.ChannelName);

                    Thread.Sleep(50);
                }
            }

            try
            {
                ctx.Response.Abort(); // make sure the connection is closed
            }
            catch (Exception ex)
            {
                Logger.Error("HTTP context error: " + ex.Message);
            }
        }