public bool IsChecked(String cname) { if (RunningSet.ContainsKey(cname)) { return(true); } return(false); }
/// <summary> /// Add a source to hashtables, and possibly raise a SourceRestored event /// </summary> /// <param name="ssrc"></param> /// <param name="cname"></param> public void Add(uint ssrc, string cname) { String cnamekey = cname; // + " " + name; lock (this) { if (!AddedFlags.ContainsKey(ssrc)) { AddedFlags.Add(ssrc, "true"); } if (ActiveStreams.ContainsKey(cnamekey)) { ActiveStreams[cnamekey] = ssrc; } else { ActiveStreams.Add(cnamekey, ssrc); } DateTime previousAddForCname = DateTime.Now; if (RestartTimes.ContainsKey(cnamekey)) { Debug.WriteLine("found previous restart time"); previousAddForCname = (DateTime)RestartTimes[cnamekey]; RestartTimes.Remove(cnamekey); } RestartTimes.Add(cnamekey, DateTime.Now); //Debug.WriteLine("SSRCManager.Add: " + cname +" "+Convert.ToString(ssrc)); //if it was in our running set, update the RtpStream and raise event. if (RunningSet.ContainsKey(cnamekey)) { Debug.WriteLine("found item in running set:" + cnamekey); uint old_ssrc = Convert.ToUInt32(RunningSet[cnamekey]); RunningSet[cnamekey] = ssrc; //Don't raise source restored if the last add came less then 3 seconds ago. if (DateTime.Now - previousAddForCname > new TimeSpan(0, 0, 0, 3, 0)) { //Debug.WriteLine("time qualifies stream for source restored:" + cname); if ((raiseSourceRestored) && (OnSourceRestored != null)) { //Debug.WriteLine("Ready to enqueue sourceRestored"); SourceData sd = new SourceData(); sd.old_ssrc = old_ssrc; sd.new_ssrc = ssrc; sd.cname = cnamekey; ThreadPool.QueueUserWorkItem(new WaitCallback(queueSourceRestored), sd); } } } } }
/// <summary> /// Remove cname from running set. To support change to audio source while encoding. /// </summary> /// <param name="cname"></param> /// <returns></returns> public bool RemoveFromSnapshot(string cname) { lock (this) { if (RunningSet.ContainsKey(cname)) { RunningSet.Remove(cname); } else { return(false); } } return(true); }