Пример #1
0
def build_createstream_resp():
    # build an example of "connect" reply
    builder = rtmp_build_t.rtmp_build_t()
    builder.amf0_element("_result")
    # 1 ? would be the connect id
    # from the connect invoke
    builder.amf0_element(2)
    builder.amf0_element(None)
    builder.amf0_element(1)
    body_data   = builder.output.getvalue();

    builder = rtmp_build_t.rtmp_build_t()
    builder.rtmp_packet(channel_id=3, timestamp=0, body_type=0x14, stream_id=0, body_data=body_data)
    return builder.output.getvalue();
Пример #2
0
def build_serverbw():
    output      = StringIO.StringIO();
    output.write(struct.pack('>I', 250000))
    body_data   = output.getvalue()

    builder = rtmp_build_t.rtmp_build_t()
    builder.rtmp_packet(channel_id=2, timestamp=0, body_type=0x05, stream_id=0, body_data=body_data)
    return builder.output.getvalue();
Пример #3
0
def build_connect_resp():
    # build an example of "connect" reply
    builder = rtmp_build_t.rtmp_build_t()
    builder.amf0_element("_result")
    # 1 ? would be the connect id
    # from the connect invoke
    builder.amf0_element(1)
    builder.amf0_element(None)
    builder.amf0_element({
                'level'         : 'status',
                'description'   : 'Connection succeeded.',
                'code'          : 'NetConnection.Connect.Success'
                })
    body_data   = builder.output.getvalue();

    builder = rtmp_build_t.rtmp_build_t()
    builder.rtmp_packet(channel_id=3, timestamp=0, body_type=0x14, stream_id=0, body_data=body_data)
    return builder.output.getvalue();