示例#1
0
        //E.g. This index can be used in GetTimeDescription(index)
        public static int GetIndexFor(this SessionDescription sdp, TimeDescription td)
        {
            if (sdp == null || td == null)
            {
                return(-1);
            }

            return(sdp.m_TimeDescriptions.IndexOf(td));
        }
示例#2
0
        public void Add(TimeDescription timeDescription, bool updateVersion = true)
        {
            if (UnderModification || timeDescription == null)
            {
                return;
            }

            var token = BeginUpdate();

            m_TimeDescriptions.Add(timeDescription);

            EndUpdate(token, updateVersion);
        }
示例#3
0
        public bool Remove(TimeDescription timeDescription, bool updateVersion = true)
        {
            if (UnderModification || timeDescription == null)
            {
                return(false);
            }

            var token = BeginUpdate();

            bool result = m_TimeDescriptions.Remove(timeDescription);

            EndUpdate(token, updateVersion && result);

            return(result);
        }
示例#4
0
        public TimeDescription(TimeDescription other, bool referenceRepeatTimes = false)
        {
            StartTime = other.StartTime;

            StopTime = other.StopTime;

            if (referenceRepeatTimes)
            {
                RepeatLines = other.RepeatLines;
            }
            else
            {
                RepeatLines = new List <Lines.SessionRepeatTimeLine>(other.RepeatLines);
            }
        }
        //Should have a date when or should return the date playable, which would then be used by another method to compare against a time.
        public static bool IsPlayable(this MediaDescription mediaDescription, SessionDescription sessionDescription) //, DateTime? check = null) ,TimeSpan within = TimeSpan.Zero
        {
            if (mediaDescription == null || sessionDescription == null)
            {
                return(false);
            }

            //Get index of mediaDesription

            //Check TimeDescription @ index.

            TimeDescription td = GetTimeDescription(mediaDescription, sessionDescription);

            if (td == null)
            {
                return(true);
            }

            //Unbound start and end ?
            if (td.IsPermanent)
            {
                return(true);
            }

            //Notes multiple calls to UtcNow... (avoid with a within parameter)?
            try
            {
                //Ensure not a bounded end and that the end time is less than now
                if (td.StopTime != 0
                    &&
                    td.NtpStopDateTime >= DateTime.UtcNow)
                {
                    return(false);
                }

                //Ensure start time is not bounded and that the start time is greater than now
                if (td.StartTime != 0
                    &&
                    td.NtpStartDateTime > DateTime.UtcNow)
                {
                    return(false);
                }

                //Check repeat times.

                //td.RepeatTimes;
            }
            catch
            {
                //Out of range values for conversion, assume true if end is unbounded
                if (td.StopTime != 0)
                {
                    return(false);
                }
            }
            finally
            {
                td = null;
            }

            return(true);
        }
示例#6
0
 public bool Equals(TimeDescription other)
 {
     return(Media.Common.Extensions.EnumerableExtensions.SequenceEquals(this, other));
 }
示例#7
0
        //Should have a date when or should return the date playable, which would then be used by another method to compare against a time.
        public static bool IsPlayable(this MediaDescription mediaDescription, SessionDescription sessionDescription) //, DateTime? check = null) ,TimeSpan within = TimeSpan.Zero
        {
            if (Common.IDisposedExtensions.IsNullOrDisposed(mediaDescription) || Common.IDisposedExtensions.IsNullOrDisposed(sessionDescription))
            {
                return(false);
            }

            //Get index of mediaDesription

            //Check TimeDescription @ index.

            TimeDescription td = GetTimeDescription(mediaDescription, sessionDescription);

            //Assume true
            if (Common.IDisposedExtensions.IsNullOrDisposed(td))
            {
                return(true);
            }

            //Unbound start and end ?
            if (td.IsPermanent)
            {
                return(true);
            }

            //Notes multiple calls to UtcNow... (avoid with a within parameter)?
            try
            {
                //Ensure not a bounded end and that the end time is less than now
                if (false.Equals(td.StopTime.Equals(0))
                    &&
                    td.NtpStopDateTime >= DateTime.UtcNow)
                {
                    return(false);
                }

                //Ensure start time is not bounded and that the start time is greater than now
                if (false.Equals(td.StartTime.Equals(0))
                    &&
                    td.NtpStartDateTime > DateTime.UtcNow)
                {
                    return(false);
                }

                //Check repeat times.

                //td.RepeatTimes;
            }
            //Todo, should not access property again during exception especially when out of range is potential.
            catch
            {
                //Out of range values for conversion, assume true if end is unbounded
                if (false.Equals(td.StopTime.Equals(0)))
                {
                    return(false);
                }
            }
            finally
            {
                td = null;
            }

            return(true);
        }