示例#1
0
        private void ProgramAssociationTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs<TsTable>;
            if (e == null) return;

            lock (_syncObject)
            {


                var pat = e.DecodedUnit.TableIdentifier == TableIdentifier.ProgramAssociation
                              ? (ProgramAssociationTable) e.DecodedUnit
                              : null;

                if (pat == null) return;

#if DEBUG2
            Debug.WriteLine("Table is a " + pat.TableIdentifier + " with Identifier 0x" + pat.Identifier.ToString("X4") +
                            " and IsCurrent=" + pat.IsCurrent);
            foreach (var pa in pat.Rows)
                Debug.WriteLine("Program " + pa.ProgramNumber + " is on PID " + pa.PacketIdentifier);
#endif
                var updatedPrograms = (from r in pat.Rows select r.ProgramNumber).ToArray();
                var existingPrograms = (from p in Programs select p.ProgramNumber).ToArray();

                var newProgramRows = from r in pat.Rows
                                     where updatedPrograms.Except(existingPrograms).Contains(r.ProgramNumber)
                                     select r;
                foreach (var r in newProgramRows)
                {
                    var newProgram = new TsProgram(r.ProgramNumber,
                                                   new TableStream() {PacketIdentifier = r.PacketIdentifier})
                                         {
                                             Status =
                                                 pat.IsCurrent ? TsProgramStatus.Current : TsProgramStatus.Next
                                         };
                    _streams.Add(r.PacketIdentifier, newProgram.ProgramMapStream);
                    Programs.Add(newProgram);
                    newProgram.StreamAdded += AddProgramStream;
                }

                if (pat.IsCurrent)
                {
                    var oldPrograms = from p in Programs
                                      where !updatedPrograms.Contains(p.ProgramNumber)
                                      select p;
                    foreach (var p in oldPrograms)
                    {
                        p.Status = TsProgramStatus.Dicontinued;
                    }
                }
            }
        }
示例#2
0
        private void ProgramAssociationTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs <TsTable>;

            if (e == null)
            {
                return;
            }

            lock (_syncObject)
            {
                var pat = e.DecodedUnit.TableIdentifier == TableIdentifier.ProgramAssociation
                    ? (ProgramAssociationTable)e.DecodedUnit
                    : null;

                if (pat == null)
                {
                    return;
                }

#if DEBUG2
                Debug.WriteLine("Table is a " + pat.TableIdentifier + " with Identifier 0x" + pat.Identifier.ToString("X4") +
                                " and IsCurrent=" + pat.IsCurrent);
                foreach (var pa in pat.Rows)
                {
                    Debug.WriteLine("Program " + pa.ProgramNumber + " is on PID " + pa.PacketIdentifier);
                }
#endif
                var updatedPrograms  = (from r in pat.Rows select r.ProgramNumber).ToArray();
                var existingPrograms = (from p in Programs select p.ProgramNumber).ToArray();

                var newProgramRows = from r in pat.Rows
                                     where updatedPrograms.Except(existingPrograms).Contains(r.ProgramNumber)
                                     select r;
                foreach (var r in newProgramRows)
                {
                    var newProgram = new TsProgram(r.ProgramNumber,
                                                   new TableStream()
                    {
                        PacketIdentifier = r.PacketIdentifier
                    })
                    {
                        Status =
                            pat.IsCurrent ? TsProgramStatus.Current : TsProgramStatus.Next
                    };
                    _streams.Add(r.PacketIdentifier, newProgram.ProgramMapStream);
                    Programs.Add(newProgram);
                    newProgram.StreamAdded += AddProgramStream;
                }

                if (pat.IsCurrent)
                {
                    var oldPrograms = from p in Programs
                                      where !updatedPrograms.Contains(p.ProgramNumber)
                                      select p;
                    foreach (var p in oldPrograms)
                    {
                        p.Status = TsProgramStatus.Dicontinued;
                    }
                }
            }
        }