Example #1
0
 // constructor:
 public SSRCManager(MSR.LST.Net.Rtp.PayloadType payload)
 {
     eventLog            = new EventLog("WMG", ".", "WMGCore");
     raiseSourceRestored = false;
     ActiveStreams       = new Hashtable();      //All Cnames currently active with latest ssrc. key: cname, value: SSRC
     //This is used to validate stream and obtain SSRC when running set snapshot occurs.
     RunningSet = new Hashtable();               //The set of Cnames/SSRCs currently encoding.
     //Note these may not be in ActiveStreams in the case where the stream was lost after encoding started.
     //Also used to support various public methods which return data about encoding streams.
     RestartTimes = new Hashtable();             //Time of last start/restart for each cname. Cname/datetime. This is used
     //to help determine when to try restarting (maintenance thread) to clear a stuck stream.
     AddedFlags = new Hashtable();               //SSRC/bool: Flag to indicate a stream was added after an event such as listener restart.
     //Used to verify streams right before start encoding.
     this.payload = payload;                     //The payload type for this instance
 }
Example #2
0
        /// <summary>
        /// Add CapabilityViewer Icons to a Participant Icon to graphically show an end user what CapabilityViewers are available for a Participant
        /// (AKA are they sending video? sending audio? sharing a whiteboard? sharing a PowerPoint?
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        internal static Bitmap CreateDecoratedParticipantImage(Participant p)
        {
            Bitmap   partBit = new Bitmap(p.Icon);
            Graphics g       = Graphics.FromImage(partBit);

            // Indicate which stream's are available for the participant
            bool sendingAudio = false;
            bool sendingVideo = false;

            foreach (ICapability cv in p.Capabilities)
            {
                // Pri2: Bind this to the object type somehow -- watch interdependencies
                MSR.LST.Net.Rtp.PayloadType pt = (MSR.LST.Net.Rtp.PayloadType)cv.PayloadType;
                if (pt == MSR.LST.Net.Rtp.PayloadType.dynamicVideo)
                {
                    sendingVideo = true;
                }
                if (pt == MSR.LST.Net.Rtp.PayloadType.dynamicAudio)
                {
                    sendingAudio = true;
                }
            }

            // Draw audio, video, or audiovideo icons on bitmap
            if (sendingAudio && sendingVideo)
            {
                System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.AudioAndVideoDecoration.png");
                g.DrawImage(new Bitmap(stream), new Rectangle(new Point(1, 1), new Size(32, 24)));
            }
            else
            if (sendingAudio)
            {
                System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.AudioDecoration.png");
                g.DrawImage(new Bitmap(stream), new Rectangle(new Point(1, 1), new Size(32, 24)));
            }
            else
            if (sendingVideo)
            {
                System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MSR.LST.ConferenceXP.VideoDecoration.png");
                g.DrawImage(new Bitmap(stream), new Rectangle(new Point(1, 1), new Size(32, 24)));
            }

            // Write out the new bitmap
            MemoryStream ms = new MemoryStream();

            partBit.Save(ms, ImageFormat.Png);
            return(new Bitmap(ms));
        }
Example #3
0
        public void Connect()
        {
            try
            {
                // - Display wait message
                Cursor.Current = Cursors.WaitCursor;

                // - Get conferences ordered by start time
                Conference[] confs = DBHelper.GetConferences();

                // - Add items with parents: year, month, date
                TreeNode   lastNode = null;
                Conference lastConf = null;

                if (confs != null && confs.Length > 0)
                {
                    this.Nodes.Clear();
                }
                foreach (Conference conf in confs)
                {
                    TreeNode newNode = new TreeNode(string.Format(CultureInfo.CurrentCulture, Strings.Conference,
                                                                  conf.Start.ToShortTimeString(), conf.Description));
                    newNode.Tag                = conf;
                    newNode.ImageIndex         = conferenceImageIndex;
                    newNode.SelectedImageIndex = conferenceImageIndex;

                    TreeNode parent     = null;
                    bool     tripSwitch = (lastNode == null);

                    #region Add parents for this node
                    // Optimize creation of parents by tracking the last node & using the knowledge
                    //  that confs is organized by startTime (thank you, Mr. SQL, for the "order by" command.)

                    // My apologies for the lack of readability of this code.  It _was_ worse...
                    if (tripSwitch || conf.Start.Year != lastConf.Start.Year)
                    {
                        parent                    = this.Nodes.Add(conf.Start.Year.ToString(CultureInfo.InvariantCulture));
                        parent.Tag                = ParentNode.Year;
                        parent.ImageIndex         = folderImageIndex;
                        parent.SelectedImageIndex = parent.ImageIndex;

                        if (tripSwitch != true)
                        {
                            tripSwitch = true;
                        }
                    }
                    if (tripSwitch || conf.Start.Month != lastConf.Start.Month)
                    {
                        if (!tripSwitch)
                        {
                            parent = lastNode.Parent.Parent.Parent;
                        }

                        parent                    = parent.Nodes.Add(conf.Start.ToString("MMMM", CultureInfo.InvariantCulture));
                        parent.Tag                = ParentNode.Month;
                        parent.ImageIndex         = folderImageIndex;
                        parent.SelectedImageIndex = parent.ImageIndex;

                        if (tripSwitch != true)
                        {
                            tripSwitch = true;
                        }
                    }
                    if (tripSwitch || conf.Start.Day != lastConf.Start.Day)
                    {
                        if (!tripSwitch)
                        {
                            parent = lastNode.Parent.Parent;
                        }

                        parent                    = parent.Nodes.Add(conf.Start.ToLongDateString());
                        parent.Tag                = ParentNode.Date;
                        parent.ImageIndex         = folderImageIndex;
                        parent.SelectedImageIndex = parent.ImageIndex;
                    }
                    else
                    {
                        parent = lastNode.Parent;
                    }
                    #endregion

                    // Pri3: Optimize getting of participants/streams.  Try to find a way to do it only after
                    //  each conference is expanded (note that a conference can't be "expanded" if it doesn't
                    //  have any children yet.  consider using a placeholder)
                    #region Get participants / streams
                    Participant[] participants = DBHelper.GetParticipants(conf.ConferenceID);
                    foreach (Participant part in participants)
                    {
                        // Create Participant node
                        TreeNode partNode = new TreeNode(string.Format(CultureInfo.CurrentCulture,
                                                                       Strings.Participant, part.CName));
                        partNode.Tag                = part;
                        partNode.ImageIndex         = participantImageIndex;
                        partNode.SelectedImageIndex = partNode.ImageIndex;

                        // Add all of the streams for this participant
                        Stream[] streams = DBHelper.GetStreamsFaster(part.ParticipantID);
                        foreach (Stream str in streams)
                        {
                            TreeNode streamNode = partNode.Nodes.Add(string.Format(CultureInfo.CurrentCulture,
                                                                                   Strings.Stream, str.Name));
                            streamNode.Tag = str;

                            // Set the payload type icon
                            MSR.LST.Net.Rtp.PayloadType payload = (MSR.LST.Net.Rtp.PayloadType)Enum.Parse(typeof(MSR.LST.Net.Rtp.PayloadType), str.Payload);
                            if (payload == MSR.LST.Net.Rtp.PayloadType.dynamicVideo)
                            {
                                streamNode.ImageIndex = videoImageIndex;
                            }
                            else if (payload == MSR.LST.Net.Rtp.PayloadType.dynamicAudio)
                            {
                                streamNode.ImageIndex = soundImageIndex;
                            }
                            else //if( payload == MSR.LST.Net.Rtp.PayloadType.dynamicPresentation )
                            {
                                streamNode.ImageIndex = presentationImageIndex;
                            }

                            streamNode.SelectedImageIndex = streamNode.ImageIndex;
                        }

                        newNode.Nodes.Add(partNode);
                    }
                    #endregion

                    parent.Nodes.Add(newNode);
                    lastNode = newNode;
                    lastConf = conf;
                }

                foreach (TreeNode rootNode in base.Nodes)
                {
                    rootNode.Expand();
                }

                this.canConnect = true;

                // - Remove wait message
                Cursor.Current = Cursors.Default;
            }
            catch
            {
                this.canConnect = false;
            }
        }