예제 #1
0
        private Collection <Mpeg2Section> getNextSection()
        {
            if (!initialized)
            {
                initialize();
            }

            if (currentOffset >= maxOffset)
            {
                getMaxOffset();
                return(null);
            }

            byte[] buffer = new byte[188];
            Marshal.Copy(currentPointer, buffer, 0, 188);
            currentPointer = new IntPtr(currentPointer.ToInt64() + 188);
            currentOffset += 188;

            if (RunParameters.Instance.TraceIDs.Contains("TRANSPORTPACKETS"))
            {
                Logger.Instance.Dump("Transport Packet", buffer, buffer.Length);
            }

            TransportPacket transportPacket = new TransportPacket();

            try
            {
                transportPacket.Process(buffer);
            }
            catch (ArgumentOutOfRangeException)
            {
                Logger.Instance.Write("Transport packet parsing failed at current offset  " + currentOffset +
                                      " max offset: " + maxOffset);
                return(null);
            }

            if (transportPacket.IsNullPacket || transportPacket.ErrorIndicator)
            {
                return(null);
            }

            /*Logger.Instance.Write("Processing PID 0x" + transportPacket.PID.ToString("X") + " from offset " + currentOffset);*/
            PidHandler pidHandler = findPidHandler(transportPacket.PID);

            pidHandler.Process(buffer, transportPacket);

            /*Logger.Instance.Write("PID handler 0x" + pidHandler.Pid.ToString("X") + " has created " + pidHandler.Sections.Count + " sections");*/

            return(pidHandler.Sections);
        }
예제 #2
0
        private PidHandler findPidHandler(int pid)
        {
            if (pidHandlers == null)
            {
                pidHandlers = new Collection <PidHandler>();
            }

            foreach (PidHandler pidHandler in pidHandlers)
            {
                if (pidHandler.Pid == pid)
                {
                    return(pidHandler);
                }
            }

            PidHandler newHandler = new PidHandler(pid);

            pidHandlers.Add(newHandler);

            /*Logger.Instance.Write("Created PID handler for pid 0x" + pid.ToString("X"));*/

            return(newHandler);
        }
예제 #3
0
        private PidHandler findPidHandler(int pid)
        {
            if (pidHandlers == null)
                pidHandlers = new Collection<PidHandler>();

            foreach (PidHandler pidHandler in pidHandlers)
            {
                if (pidHandler.Pid == pid)
                    return (pidHandler);
            }

            PidHandler newHandler = new PidHandler(pid);
            pidHandlers.Add(newHandler);

            /*Logger.Instance.Write("Created PID handler for pid 0x" + pid.ToString("X"));*/

            return (newHandler);
        }