//------------------------------------------------------------------------------------------------------------------------ public VideoFeed CreateVideoFeed(string videoFeedName) { VideoFeed vf; lock (videofeeds) if (videofeeds.TryGetValue(videoFeedName, out vf) == false) { vf = new VideoFeed(this, videoFeedName); videofeeds.Add(videoFeedName, vf); } return(vf); }
//------------------------------------------------------------------------------------------------------------------------ private void ClientThread(object client) { //get client socket var socket = (Socket)client; DebugEx.TraceLog(string.Format("New client from " + socket.RemoteEndPoint.ToString())); //get feed name request string feedName = string.Empty; using (var netStream = new NetworkStream(socket, false)) using (var reader = new StreamReader(netStream)) { var req = reader.ReadLine(); try { if (req != null) { feedName = req.Split(new[] { ' ' })[1]; if (feedName[0] == '/') { feedName = feedName.Substring(1); } } } catch (Exception ex) { DebugEx.TraceError(ex.Message); } } //find feed VideoFeed feed = null; lock (videofeeds) if (!string.IsNullOrEmpty(feedName)) { feed = videofeeds.TryGetOrDefault(feedName); } //give client to feed if (feed != null) { feed.AddClient(socket); } else { DebugEx.TraceLog("Client requested feed not found"); } }
//------------------------------------------------------------------------------------------------------------------------ public void DestroyVideoFeed(string videoFeedName) { //find feed VideoFeed vf = null; lock (videofeeds) if (videofeeds.TryGetValue(videoFeedName, out vf)) { videofeeds.Remove(videoFeedName); } //remove //stop if (vf != null) { vf._InternalStop(); vf.Dispose(); } }
//------------------------------------------------------------------------------------------------------------------------ public void DestroyVideoFeed(VideoFeed videofeed) { DestroyVideoFeed(videofeed.Name); }
//------------------------------------------------------------------------------------------------------------------------ public VideoFeed CreateVideoFeed(string videoFeedName) { VideoFeed vf; lock (videofeeds) if (videofeeds.TryGetValue(videoFeedName, out vf) == false) { vf = new VideoFeed(this, videoFeedName); videofeeds.Add(videoFeedName, vf); } return vf; }