def _process_packet(self):
        # Returns (packet_type, packet), where packet_type = 'video' or
        # 'audio'; and packet is VideoPacket or AudioData.  In either case,
        # packet is buffered or queued for decoding; no further action is
        # necessary.  Returns (None, None) if packet was neither type.

        if self._packet.stream_index == self._video_stream_index:
            if self._packet.timestamp < 0:
                # XXX TODO
                # AVbin needs hack to decode timestamp for B frames in
                # some containers (OGG?).  See
                # http://www.dranger.com/ffmpeg/tutorial05.html
                # For now we just drop these frames.
                return None, None

            video_packet = VideoPacket(self._packet)

            if _debug:
                print 'Created and queued frame %d (%f)' % \
                    (video_packet.id, video_packet.timestamp)

            self._video_timestamp = max(self._video_timestamp,
                                        video_packet.timestamp)
            self._video_packets.append(video_packet)
            self._decode_thread.put_job(
                lambda: self._decode_video_packet(video_packet))

            return 'video', video_packet

        elif self._packet.stream_index == self._audio_stream_index:
            audio_data = self._decode_audio_packet()
            if audio_data:
                if _debug:
                    print 'Got an audio packet at', audio_data.timestamp
                self._buffered_audio_data.append(audio_data)
                return 'audio', audio_data

        return None, None
dataset/ETHPy150Open ardekantur/pyglet/pyglet/media/avbin.py/AVbinSource._process_packet/original