/// <summary>
        /// Adds the specified packet and automatically places it on the right track.
        /// If the track requires sorting it does so by reordering packets based on their timestamp.
        /// </summary>
        /// <param name="item">The item.</param>
        public void Add(ClosedCaptionPacket item)
        {
            CurrentNtscField = item.NtscField != 0 ? item.NtscField : 1;
            CurrentChannel   = item.Channel != 0 ? item.Channel : CurrentChannel;
            var targetCC = CC1;

            if (CurrentNtscField == 1)
            {
                if (CurrentChannel == 1)
                {
                    targetCC = CC1;
                }
                else
                {
                    targetCC = CC2;
                }
            }
            else
            {
                if (CurrentChannel == 1)
                {
                    targetCC = CC3;
                }
                else
                {
                    targetCC = CC4;
                }
            }

            var performSort = targetCC.Count != 0;

            if (targetCC.Count > 0 && targetCC.Last().Timestamp.Ticks <= item.Timestamp.Ticks)
            {
                performSort = false;
            }

            targetCC.Add(item);

            if (performSort)
            {
                targetCC.Sort();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Determines whether a previous packet is a repeated control code.
 /// This is according to CEA-608 Section D.2 Transmission of Control Code Pairs
 /// </summary>
 /// <param name="previousPacket">The previous packet.</param>
 /// <returns>
 ///   <c>true</c> it is a repeated control code packet.
 /// </returns>
 public bool IsRepeatedControlCode(ClosedCaptionPacket previousPacket)
 {
     return(IsControlPacket && previousPacket.D0 == D0 && previousPacket.D1 == D1);
 }