             // Parse the PES, split by Packet ID.
             switch (pid) {
                 case PAT_ID:
-                    todo -= _parsePAT(stt);
+                    todo -= _parsePAT(stt,data);
                     CONFIG::LOGGING {
                         if (_pmtParsed == false) {
                             Log.debug("TS: PAT found.PMT PID:" + _pmtId);

        private var _tags : Vector.<FLVTag>;
        /** Display Object used to schedule parsing **/
        private var _displayObject : DisplayObject;
        /** Byte data to be read **/
        private var _data : ByteArray;
        /* callback functions for audio selection, and parsing progress/complete */
        private var _callback_audioselect : Function;
        private var _callback_progress : Function;

        }

        /** Parse TS packet. **/
        private function _parseTSPacket(data : ByteArray) : void {
            // Each packet is 188 bytes.
            var todo : uint = TSDemuxer.PACKETSIZE;
            // Sync byte.
            if (data.readByte() != TSDemuxer.SYNCBYTE) {
                var pos_start : uint = data.position - 1;
                if (probe(data) == true) {
                    var pos_end : uint = data.position;
                    CONFIG::LOGGING {
                        Log.warn("TS: lost sync between offsets:" + pos_start + "/" + pos_end);
                        if (HLSSettings.logDebug2) {
                            var ba : ByteArray = new ByteArray();
                            data.position = pos_start;
                            data.readBytes(ba, 0, pos_end - pos_start);
                            Log.debug2("TS: lost sync dump:" + Hex.fromArray(ba));
                        }
                    }
                    data.position = pos_end + 1;
                } else {
                    throw new Error("TS: Could not parse file: sync byte not found @ offset/len " + data.position + "/" + data.length);
                }
            }
            todo--;
            // Payload unit start indicator.
            var stt : uint = (data.readUnsignedByte() & 64) >> 6;
            data.position--;

            // Packet ID (last 13 bits of UI16).
            var pid : uint = data.readUnsignedShort() & 8191;
            // Check for adaptation field.
            todo -= 2;
            var atf : uint = (data.readByte() & 48) >> 4;
            todo--;
            // Read adaptation field if available.
            if (atf > 1) {
                // Length of adaptation field.
                var len : uint = data.readUnsignedByte();
                todo--;
                // Random access indicator (keyframe).
                // var rai:uint = data.readUnsignedByte() & 64;
                data.position += len;
                todo -= len;
                // Return if there's only adaptation field.
                if (atf == 2 || len == 183) {
                    data.position += todo;
                    return;
                }
            }
