# Path: twimp/amf0.py
# def decode(data):
#     """Decode AMF0-encoded buffer of data.
# 
#     @type data: VecBuf
# 
#     @returns: list of objects
#     """
#     try:
#         return _decode(data)
#     except VecBufEOB:
#         raise DecoderError('Incomplete encoded data')
# 
# Path: twimp/chunks.py
# class Header(object):
# class ChunkStreamParseError(ValueError):
# class ChunkStreamValueError(ValueError):
# class Demuxer(object):
# class Chunker(object):
# class SimpleChunkProducer(object):
# class Muxer(object):
#     def __init__(self, cs_id, time, size, type, ms_id, **kw):
#     def __repr__(self):
#         def _repr_maybe(v, provided):
# def absolutize(h, base):
# def read_header_head(s):
#     def __init__(self, protocol):
#     def doSetChunkSize(self, header, new_size):
#     def doAbortMessage(self, header, cs_id):
#     def doACK(self, header, seq_num):
#     def doUserControlMessage(self, header, evt_type, body):
#     def doWindowSize(self, header, window_size):
#     def doSetBandwidth(self, header, window_size, limit_type):
#     def controlMessageUnknown(self, header, body):
#     def controlMessageReceived(self, header, body):
#     def gen_handler(self):
# def _encode_basic_header(h_type, cs_id, time=None):
# def encode_full_header(cs_id, time, size, msg_type, ms_id):
# def encode_comp_header(h_type, cs_id, time, size, msg_type, ms_id):
#     def set_chunk_size(self, new_chunk_size):
#     def __call__(self, cs_id, first_header, body, time=None):
#     def __init__(self, transport):
#     def queue_chunker(self, priority, chunker):
#     def sync(self, priority):
#     def pauseProducing(self):
#     def resumeProducing(self):
#     def stopProducing(self):
#     def __init__(self, transport):
#     def _precompute_dispatch(self, amf_ver):
#     def _make_adhoc_csid(self, mt):
#     def set_chunk_size(self, new_chunk_size):
#     def sendMessage(self, time, type_, ms_id, body, absolute=False):
# DEFAULT_CHUNK_SIZE = 128
# (PROTO_SET_CHUNK_SIZE, PROTO_ABORT_MESSAGE, PROTO_ACK, PROTO_USER_CONTROL,
#  PROTO_WINDOW_SIZE, PROTO_SET_BANDWIDTH, MSG_COMMAND, MSG_DATA, MSG_SO,
#  MSG_AUDIO, MSG_VIDEO, MSG_AGGREGATE) = range(12)
# 
# Path: twimp/helpers.py
# def vb(s):
#     # TODO: add this functionality to the vecbuf/VecBuf itself
#     return VecBuf([s])


from twisted.test import proto_helpers
from twimp.amf0 import decode as decode_amf
from twimp import chunks
from twimp.helpers import vb
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.







class StringTransport(proto_helpers.StringTransport):
    def writeSequence(self, iovec):
        """A writeSequence() implementation able to handle buffer
        instances in iovec."""

        for elt in iovec:
            self.write(elt)


def muxer_messages(mux):
    return [(m[0], m[1], m[2],
             (decode_amf(vb(m[3]))
              if m[1] in (chunks.MSG_COMMAND, chunks.MSG_DATA)
              else m[3]),
             m[4])
            for m in mux.messages]


def unvb(vb):

# Path: twimp/amf0.py
# def decode(data):
#     """Decode AMF0-encoded buffer of data.
# 
#     @type data: VecBuf
# 
#     @returns: list of objects
#     """
#     try:
#         return _decode(data)
#     except VecBufEOB:
#         raise DecoderError('Incomplete encoded data')
# 
# Path: twimp/chunks.py
# class Header(object):
# class ChunkStreamParseError(ValueError):
# class ChunkStreamValueError(ValueError):
# class Demuxer(object):
# class Chunker(object):
# class SimpleChunkProducer(object):
# class Muxer(object):
#     def __init__(self, cs_id, time, size, type, ms_id, **kw):
#     def __repr__(self):
#         def _repr_maybe(v, provided):
# def absolutize(h, base):
# def read_header_head(s):
#     def __init__(self, protocol):
#     def doSetChunkSize(self, header, new_size):
#     def doAbortMessage(self, header, cs_id):
#     def doACK(self, header, seq_num):
#     def doUserControlMessage(self, header, evt_type, body):
#     def doWindowSize(self, header, window_size):
#     def doSetBandwidth(self, header, window_size, limit_type):
#     def controlMessageUnknown(self, header, body):
#     def controlMessageReceived(self, header, body):
#     def gen_handler(self):
# def _encode_basic_header(h_type, cs_id, time=None):
# def encode_full_header(cs_id, time, size, msg_type, ms_id):
# def encode_comp_header(h_type, cs_id, time, size, msg_type, ms_id):
#     def set_chunk_size(self, new_chunk_size):
#     def __call__(self, cs_id, first_header, body, time=None):
#     def __init__(self, transport):
#     def queue_chunker(self, priority, chunker):
#     def sync(self, priority):
#     def pauseProducing(self):
#     def resumeProducing(self):
#     def stopProducing(self):
#     def __init__(self, transport):
#     def _precompute_dispatch(self, amf_ver):
#     def _make_adhoc_csid(self, mt):
#     def set_chunk_size(self, new_chunk_size):
#     def sendMessage(self, time, type_, ms_id, body, absolute=False):
# DEFAULT_CHUNK_SIZE = 128
# (PROTO_SET_CHUNK_SIZE, PROTO_ABORT_MESSAGE, PROTO_ACK, PROTO_USER_CONTROL,
#  PROTO_WINDOW_SIZE, PROTO_SET_BANDWIDTH, MSG_COMMAND, MSG_DATA, MSG_SO,
#  MSG_AUDIO, MSG_VIDEO, MSG_AGGREGATE) = range(12)
# 
# Path: twimp/helpers.py
# def vb(s):
#     # TODO: add this functionality to the vecbuf/VecBuf itself
#     return VecBuf([s])


# Path: test/helpers.py
from twisted.test import proto_helpers
from twimp.amf0 import decode as decode_amf
from twimp import chunks
from twimp.helpers import vb

#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.







class StringTransport(proto_helpers.StringTransport):
    def writeSequence(self, iovec):
        """A writeSequence() implementation able to handle buffer
        instances in iovec."""

        for elt in iovec:
            self.write(elt)


def muxer_messages(mux):
    return [(m[0], m[1], m[2],
             (decode_amf(vb(m[3]))
              if m[1] in (chunks.MSG_COMMAND, chunks.MSG_DATA)
              else m[3]),
             m[4])
            for m in mux.messages]


def unvb(vb):

    return vb.read(len(vb))[:]