コード例 #1
0
        /// <summary>
        /// Creates a copy of another SessionDescription
        /// </summary>
        /// <param name="other">The SessionDescription to copy</param>
        public SessionDescription(SessionDescription other, bool reference = false)
        {
            SessionDescriptionVersion = other.SessionDescriptionVersion;

            OriginatorAndSessionIdentifier = other.OriginatorAndSessionIdentifier;

            m_NameLine = other.m_NameLine;

            if (reference)
            {
                m_TimeDescriptions = other.m_TimeDescriptions;

                m_MediaDescriptions = other.m_MediaDescriptions;

                m_Lines = other.m_Lines;
            }
            else
            {
                m_TimeDescriptions = new List <TimeDescription>(other.TimeDescriptions);

                m_MediaDescriptions = new List <MediaDescription>(other.m_MediaDescriptions);

                m_Lines = new List <SessionDescriptionLine>(other.Lines);
            }
        }
コード例 #2
0
        public void Add(SessionDescriptionLine line, bool updateVersion = true)
        {
            if (UnderModification || line == null)
            {
                return;
            }

            var token = BeginUpdate();

            switch (line.m_Type)
            {
            case Sdp.Lines.SessionVersionLine.VersionType:
                m_SessionVersionLine = new Lines.SessionVersionLine(line);
                break;

            case Sdp.Lines.SessionOriginLine.OriginType:
                m_OriginatorLine = new Sdp.Lines.SessionOriginLine(line);
                break;

            case Sdp.Lines.SessionNameLine.NameType:
                m_NameLine = new Sdp.Lines.SessionNameLine(line);
                break;

            default:
                m_Lines.Add(line);
                break;
            }

            EndUpdate(token, updateVersion);
        }
コード例 #3
0
        /// <summary>
        /// Constructs a new Session Description
        /// </summary>
        /// <param name="protocolVersion">Usually 0</param>
        /// <param name="originatorAndSession">Compound string identifying origionator and session identifier</param>
        /// <param name="sessionName">name of the session</param>
        public SessionDescription(int protocolVersion, string originatorAndSession, string sessionName)
            : this(protocolVersion)
        {
            OriginatorAndSessionIdentifier = originatorAndSession;

            m_NameLine = new Lines.SessionNameLine(sessionName);
        }
コード例 #4
0
        public SessionDescription(string originatorString, string sessionName)
            : this(0)
        {
            OriginatorAndSessionIdentifier = originatorString;

            m_NameLine = new Lines.SessionNameLine(sessionName);
        }
コード例 #5
0
        public override void Dispose()
        {
            base.Dispose();

            if (false == IsDisposed)
            {
                return;
            }

            m_SessionVersionLine = null;

            m_OriginatorLine = null;

            m_NameLine = null;

            //Dispose all

            m_MediaDescriptions.Clear();

            //m_MediaDescriptions = null;

            m_TimeDescriptions.Clear();

            //m_TimeDescriptions = null;

            m_Lines.Clear();

            //m_Lines = null;
        }
コード例 #6
0
        public SessionDescription(int version)
        {
            m_OriginatorLine = new Lines.SessionOriginLine();

            m_NameLine = new Sdp.Lines.SessionNameLine();

            SessionDescriptionVersion = version;
        }
コード例 #7
0
        public bool Remove(SessionDescriptionLine line, bool updateVersion = true)
        {
            if (UnderModification || line == null)
            {
                return(false);
            }

            var token = BeginUpdate();

            bool result = false;

            switch (line.m_Type)
            {
            case Sdp.Lines.SessionVersionLine.VersionType:
                if (line == m_SessionVersionLine)
                {
                    m_SessionVersionLine = null;
                    result = true;
                }
                break;

            case Sdp.Lines.SessionOriginLine.OriginType:
                if (line == m_OriginatorLine)
                {
                    m_OriginatorLine = null;
                    result           = true;
                }
                break;

            case Sdp.Lines.SessionNameLine.NameType:
                if (line == m_OriginatorLine)
                {
                    m_NameLine = null;
                    result     = true;
                }
                break;
                //Handle remove of Time Description and its constituents
                ////case Sdp.MediaDescription.MediaDescriptionType:
                ////    {
                //Handle remove of Media Description and its constituents
                ////        foreach (MediaDescription md in MediaDescriptions) if (result = md.Remove(line)) break;
                ////    }
                ////    break;
                ////default:
                ////    {
                ////        result = m_Lines.Remove(line);
                ////    }
                ////    break;
            }

            if (false == result)
            {
                result = m_Lines.Remove(line);
            }

            if (false == result)
            {
                foreach (MediaDescription md in MediaDescriptions)
                {
                    if (result = md.Remove(line))
                    {
                        break;
                    }
                }
            }

            EndUpdate(token, updateVersion && result);

            return(result);
        }
コード例 #8
0
        /// <summary>
        /// Constructs a SessionDescription from the given contents of a Session Description Protocol message
        /// </summary>
        /// <param name="sdpContents">The Session Description Protocol usually recieved in the Describe request of a RtspClient</param>
        public SessionDescription(string sdpContents)
        {
            if (string.IsNullOrWhiteSpace(sdpContents))
            {
                return;
            }

            string[] lines = sdpContents.Split(SessionDescription.CRLFSplit, StringSplitOptions.RemoveEmptyEntries);

            if (lines.Length < 3)
            {
                Media.Common.TaggedExceptionExtensions.RaiseTaggedException(lines, "Invalid Session Description, At least 3 lines should be found.");
            }

            //The order should be maintained as it was given in the contents.

            //Parse remaining optional entries
            for (int lineIndex = 0, endIndex = lines.Length; lineIndex < endIndex; /*Advancement of the loop controlled by the corrsponding Lines via ref*/)
            {
                string line = lines[lineIndex].Trim();

                //Todo, use a Dictionary and allow registration.

                //Determine if there is a specialization, also performed in SessionDescriptionLine.TryParse
                switch (line[0])
                {
                case Media.Sdp.Lines.SessionVersionLine.VersionType:
                {
                    m_SessionVersionLine = new Media.Sdp.Lines.SessionVersionLine(lines, ref lineIndex);
                    continue;
                }

                case Media.Sdp.Lines.SessionOriginLine.OriginType:
                {
                    m_OriginatorLine = new Media.Sdp.Lines.SessionOriginLine(lines, ref lineIndex);
                    continue;
                }

                case Media.Sdp.Lines.SessionNameLine.NameType:
                {
                    m_NameLine = new Media.Sdp.Lines.SessionNameLine(lines, ref lineIndex);
                    continue;
                }

                case Media.Sdp.Lines.SessionTimeDescriptionLine.TimeType:
                {
                    m_TimeDescriptions.Add(new TimeDescription(lines, ref lineIndex));
                    continue;
                }

                case Media.Sdp.Lines.SessionMediaDescriptionLine.MediaDescriptionType:
                {
                    m_MediaDescriptions.Add(new MediaDescription(lines, ref lineIndex));
                    continue;
                }

                //case Media.Sdp.Lines.SessionAttributeLine.AttributeType:
                //    {
                //Should check or charset or sdpland attribute and switch currentEncoding.
                //        m_Lines.Add(new Media.Sdp.Lines.SessionAttributeLine(lines, ref lineIndex));
                //        continue;
                //    }
                //case Media.Sdp.Lines.SessionBandwidthLine.BandwidthType:
                //    {
                //        m_Lines.Add(new Media.Sdp.Lines.SessionBandwidthLine(lines, ref lineIndex));
                //        continue;
                //    }
                default:
                {
                    SessionDescriptionLine parsed;

                    if (SessionDescriptionLine.TryParse(lines, ref lineIndex, out parsed))
                    {
                        m_Lines.Add(parsed);
                    }
                    else
                    {
                        lineIndex++;         //No advance was made on lineIndex by SessionDescriptionLine if parsed was null
                    }
                    continue;
                }
                }
            }
        }