static int write_begin(URLContext *s)
{
    RTMPContext *rt = s->priv_data;
    PutByteContext pbc;
    RTMPPacket spkt = { 0 };
    int ret;
    if ((ret = ff_rtmp_packet_create(&spkt, RTMP_NETWORK_CHANNEL,
                                     RTMP_PT_PING, 0, 6)) < 0) {
        av_log(s, AV_LOG_ERROR, "Unable to create response packet\n");
        return ret;
    }
    bytestream2_init_writer(&pbc, spkt.data, spkt.size);
    bytestream2_put_be16(&pbc, 0);
    bytestream2_put_be32(&pbc, rt->nb_streamid);
    ret = ff_rtmp_packet_write(rt->stream, &spkt, rt->out_chunk_size,
                               &rt->prev_pkt[1], &rt->nb_prev_pkt[1]);
    ff_rtmp_packet_destroy(&spkt);
    return ret;
}
['static int write_begin(URLContext *s)\n{\n    RTMPContext *rt = s->priv_data;\n    PutByteContext pbc;\n    RTMPPacket spkt = { 0 };\n    int ret;\n    if ((ret = ff_rtmp_packet_create(&spkt, RTMP_NETWORK_CHANNEL,\n                                     RTMP_PT_PING, 0, 6)) < 0) {\n        av_log(s, AV_LOG_ERROR, "Unable to create response packet\\n");\n        return ret;\n    }\n    bytestream2_init_writer(&pbc, spkt.data, spkt.size);\n    bytestream2_put_be16(&pbc, 0);\n    bytestream2_put_be32(&pbc, rt->nb_streamid);\n    ret = ff_rtmp_packet_write(rt->stream, &spkt, rt->out_chunk_size,\n                               &rt->prev_pkt[1], &rt->nb_prev_pkt[1]);\n    ff_rtmp_packet_destroy(&spkt);\n    return ret;\n}', 'int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,\n                          int timestamp, int size)\n{\n    if (size) {\n        pkt->data = av_realloc(NULL, size);\n        if (!pkt->data)\n            return AVERROR(ENOMEM);\n    }\n    pkt->size       = size;\n    pkt->channel_id = channel_id;\n    pkt->type       = type;\n    pkt->timestamp  = timestamp;\n    pkt->extra      = 0;\n    pkt->ts_field   = 0;\n    return 0;\n}', 'void *av_realloc(void *ptr, size_t size)\n{\n    if (size > (INT_MAX - 16))\n        return NULL;\n#if HAVE_ALIGNED_MALLOC\n    return _aligned_realloc(ptr, size, 32);\n#else\n    return realloc(ptr, size);\n#endif\n}', 'static av_always_inline void bytestream2_init_writer(PutByteContext *p,\n                                                     uint8_t *buf,\n                                                     int buf_size)\n{\n    p->buffer       = buf;\n    p->buffer_start = buf;\n    p->buffer_end   = buf + buf_size;\n    p->eof          = 0;\n}', 'DEF(unsigned int, be16, 2, AV_RB16, AV_WB16)', 'DEF(unsigned int, be32, 4, AV_RB32, AV_WB32)', 'void ff_rtmp_packet_destroy(RTMPPacket *pkt)\n{\n    if (!pkt)\n        return;\n    av_freep(&pkt->data);\n    pkt->size = 0;\n}']