/// <summary> /// One of the listeners saw a new stream /// </summary> /// This could be invoked on behalf of either the presenter or the conferencing listener. /// <param name="rtpStream"></param> private void OnRtpStreamAdded(object o, RtpEvents.RtpStreamEventArgs ea) { String streamID = makeStreamIdentifier(ea.RtpStream.Properties.CName, ea.RtpStream.Properties.Name); Debug.WriteLine("StreamAdded: " + streamID + " payload:" + ea.RtpStream.PayloadType.ToString()); bool selected = false; if ((confSession != null) && (confSession.Streams.ContainsKey(ea.RtpStream.SSRC))) { if (ea.RtpStream.PayloadType == MSR.LST.Net.Rtp.PayloadType.dynamicAudio) { assrcs.Add(ea.RtpStream.SSRC, streamID); selected = assrcs.IsChecked(streamID); } if (ea.RtpStream.PayloadType == MSR.LST.Net.Rtp.PayloadType.dynamicVideo) { vssrcs.Add(ea.RtpStream.SSRC, streamID); selected = vssrcs.IsChecked(streamID); } if (OnStreamAddRemove != null) { StreamAddRemoveEventArgs area = new StreamAddRemoveEventArgs(true, selected, streamID, ea.RtpStream.PayloadType); OnStreamAddRemove(area); } } if ((presenterSession != null) && (presenterSession.Streams.ContainsKey(ea.RtpStream.SSRC))) { if (ea.RtpStream.PayloadType == MSR.LST.Net.Rtp.PayloadType.dynamicPresentation) { //Note: this is not necessarily an Instructor node, but we need to let the listen threads figure that out. if (OnPresentationStreamAdded != null) { OnPresentationStreamAdded(ea); } } } }
/// <summary> /// Event handler for RTP Stream Removed. Note this is not raised before a listener terminates. /// </summary> /// <param name="o"></param> /// <param name="ea"></param> private void OnRtpStreamRemoved(object o, RtpEvents.RtpStreamEventArgs ea) { String streamID = makeStreamIdentifier(ea.RtpStream.Properties.CName, ea.RtpStream.Properties.Name); Debug.WriteLine("StreamRemoved: " + streamID + " payload:" + ea.RtpStream.PayloadType.ToString()); //PRI2: There is a potential problem here because I have no way to tell which session triggered the event. if (confSession != null) { if (ea.RtpStream.PayloadType == MSR.LST.Net.Rtp.PayloadType.dynamicAudio) { assrcs.Remove(streamID); } if (ea.RtpStream.PayloadType == MSR.LST.Net.Rtp.PayloadType.dynamicVideo) { vssrcs.Remove(streamID); } if (OnStreamAddRemove != null) { StreamAddRemoveEventArgs area = new StreamAddRemoveEventArgs(false, false, streamID, ea.RtpStream.PayloadType); OnStreamAddRemove(area); } } if (presenterSession != null) { if (ea.RtpStream.PayloadType == MSR.LST.Net.Rtp.PayloadType.dynamicPresentation) { if (OnPresentationStreamRemoved != null) { OnPresentationStreamRemoved(ea); } } } }
/// <summary> /// record all the active conference streams in the SSRCManagers /// </summary> /// Note that this would normally happen via StreamAdded event handlers. /// This is a hack to workaround a situation with presenter and conference on /// the same venue. private void AddConferenceStreams() { SSRCToStreamHashtable streams; RtpStream stream; String streamID; bool selected = false; if (confSession != null) { streams = (SSRCToStreamHashtable)confSession.Streams; foreach (object ssrc in streams.Keys) { stream = (RtpStream)streams[(uint)ssrc]; if (stream == null) { continue; } streamID = makeStreamIdentifier(stream.Properties.CName, stream.Properties.Name); if (stream.PayloadType == PayloadType.dynamicAudio) { assrcs.Add((uint)ssrc, streamID); selected = assrcs.IsChecked(streamID); } if (stream.PayloadType == PayloadType.dynamicVideo) { vssrcs.Add((uint)ssrc, streamID); selected = vssrcs.IsChecked(streamID); } if (OnStreamAddRemove != null) { StreamAddRemoveEventArgs area = new StreamAddRemoveEventArgs(true, selected, streamID, stream.PayloadType); OnStreamAddRemove(area); } } } }