Exemple #1
0
 private void DescriptionTableReceived(object sender, TsStreamEventArgs eventArgs)
 {
     if (eventArgs is TsStreamEventArgs <TsTable> )
     {
         Debug.WriteLine("Received Description Table");
     }
 }
Exemple #2
0
 public void OnUnitReceived(TsStreamEventArgs e)
 {
     if (UnitReceived != null)
     {
         UnitReceived(this, e);
     }
 }
Exemple #3
0
        void ProgramMapTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs <TsTable>;

            if (e == null)
            {
                return;
            }

            lock (_syncObject)
            {
                var pmt = e.DecodedUnit.TableIdentifier == TableIdentifier.ProgramMap ? (ProgramMapTable)e.DecodedUnit : null;
                if (pmt == null)
                {
                    return;
                }

                Debug.WriteLine("Program Map Received");
                Debug.WriteLine("Program Number: " + pmt.ProgramNumber + " Program Clock Reference PID: " +
                                pmt.ProgramClockReferencePid);

                Info = pmt.ProgramInfo;
                foreach (var pm in pmt.Rows)
                {
                    Debug.WriteLine("******** " + pm.StreamType + " on PID " + pm.PacketIdentifier);
#if DEBUG
                    foreach (var descriptor in pm.StreamInfo)
                    {
                        Debug.WriteLine("\tHas " + descriptor.Tag + " descriptor.");
                    }
#endif
                    var stream =
                        (from s in Streams where s.PacketIdentifier == pm.PacketIdentifier select s).FirstOrDefault();
                    if (stream == null)
                    {
                        try
                        {
                            stream = (TsStream)Activator.CreateInstance(TsStream.StreamTypes[pm.StreamType]);
                            stream.PacketIdentifier = pm.PacketIdentifier;
                        }
                        catch (Exception)
                        {
                            stream = new ByteStream()
                            {
                                PacketIdentifier = pm.PacketIdentifier
                            };
                        }
                        Streams.Add(stream);
                        OnStreamAdded(stream);
                    }
                    stream.Type = pm.StreamType;
                    stream.Info = pm.StreamInfo;
                }
            }
        }
Exemple #4
0
        private void DescriptionTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs <TsTable>;

            if (e == null)
            {
                return;
            }

            Debug.WriteLine("Received Description Table");
        }
Exemple #5
0
        void ProgramMapTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs<TsTable>;
            if (e == null) return;

            lock (_syncObject)
            {
                var pmt = e.DecodedUnit.TableIdentifier == TableIdentifier.ProgramMap ? (ProgramMapTable) e.DecodedUnit : null;
                if (pmt == null) return;

                Debug.WriteLine("Program Map Received");
                Debug.WriteLine("Program Number: " + pmt.ProgramNumber + " Program Clock Reference PID: " +
                                pmt.ProgramClockReferencePid);

                Info = pmt.ProgramInfo;
                foreach (var pm in pmt.Rows)
                {
                    Debug.WriteLine("******** " + pm.StreamType + " on PID " + pm.PacketIdentifier);
#if DEBUG
                    foreach (var descriptor in pm.StreamInfo)
                        Debug.WriteLine("\tHas " + descriptor.Tag + " descriptor.");
#endif
                    var stream =
                        (from s in Streams where s.PacketIdentifier == pm.PacketIdentifier select s).FirstOrDefault();
                    if (stream == null)
                    {
                        try
                        {
                            stream = (TsStream) Activator.CreateInstance(TsStream.StreamTypes[pm.StreamType]);
                            stream.PacketIdentifier = pm.PacketIdentifier;
                        }
                        catch (Exception)
                        {
                            stream = new ByteStream() {PacketIdentifier = pm.PacketIdentifier};
                        }
                        Streams.Add(stream);
                        OnStreamAdded(stream);
                    }
                    stream.Type = pm.StreamType;
                    stream.Info = pm.StreamInfo;
                }
            }
        }
Exemple #6
0
        private void DescriptionTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs<TsTable>;
            if (e == null) return;

            Debug.WriteLine("Received Description Table");
        }
Exemple #7
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;
                    }
                }
            }
        }
Exemple #8
0
 public void OnUnitReceived(TsStreamEventArgs e)
 {
     if (UnitReceived != null)
         UnitReceived(this, e);
 }
Exemple #9
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;
                    }
                }
            }
        }
Exemple #10
0
 public void OnUnitReceived(TsStreamEventArgs e)
 {
     UnitReceived?.Invoke(this, e);
 }