static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
    RTSPState *rt = s->priv_data;
    RTSPStream *rtsp_st;
    int size, i, err;
    char *content;
    char url[1024];
    if (!ff_network_init())
        return AVERROR(EIO);
    content = av_malloc(SDP_MAX_SIZE);
    size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);
    if (size <= 0) {
        av_free(content);
        return AVERROR_INVALIDDATA;
    }
    content[size] ='\0';
    ff_sdp_parse(s, content);
    av_free(content);
    for (i = 0; i < rt->nb_rtsp_streams; i++) {
        char namebuf[50];
        rtsp_st = rt->rtsp_streams[i];
        getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),
                    namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
        ff_url_join(url, sizeof(url), "rtp", NULL,
                    namebuf, rtsp_st->sdp_port,
                    "?localport=%d&ttl=%d", rtsp_st->sdp_port,
                    rtsp_st->sdp_ttl);
        if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {
            err = AVERROR_INVALIDDATA;
            goto fail;
        }
        if ((err = rtsp_open_transport_ctx(s, rtsp_st)))
            goto fail;
    }
    return 0;
fail:
    ff_rtsp_close_streams(s);
    ff_network_close();
    return err;
}
['static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap)\n{\n    RTSPState *rt = s->priv_data;\n    RTSPStream *rtsp_st;\n    int size, i, err;\n    char *content;\n    char url[1024];\n    if (!ff_network_init())\n        return AVERROR(EIO);\n    content = av_malloc(SDP_MAX_SIZE);\n    size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1);\n    if (size <= 0) {\n        av_free(content);\n        return AVERROR_INVALIDDATA;\n    }\n    content[size] =\'\\0\';\n    ff_sdp_parse(s, content);\n    av_free(content);\n    for (i = 0; i < rt->nb_rtsp_streams; i++) {\n        char namebuf[50];\n        rtsp_st = rt->rtsp_streams[i];\n        getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),\n                    namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);\n        ff_url_join(url, sizeof(url), "rtp", NULL,\n                    namebuf, rtsp_st->sdp_port,\n                    "?localport=%d&ttl=%d", rtsp_st->sdp_port,\n                    rtsp_st->sdp_ttl);\n        if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) {\n            err = AVERROR_INVALIDDATA;\n            goto fail;\n        }\n        if ((err = rtsp_open_transport_ctx(s, rtsp_st)))\n            goto fail;\n    }\n    return 0;\nfail:\n    ff_rtsp_close_streams(s);\n    ff_network_close();\n    return err;\n}', 'static inline int ff_network_init(void)\n{\n#if HAVE_WINSOCK2_H\n    WSADATA wsaData;\n    if (WSAStartup(MAKEWORD(1,1), &wsaData))\n        return 0;\n#endif\n    return 1;\n}', 'void *av_malloc(FF_INTERNAL_MEM_TYPE size)\n{\n    void *ptr = NULL;\n#if CONFIG_MEMALIGN_HACK\n    long diff;\n#endif\n    if(size > (INT_MAX-16) )\n        return NULL;\n#if CONFIG_MEMALIGN_HACK\n    ptr = malloc(size+16);\n    if(!ptr)\n        return ptr;\n    diff= ((-(long)ptr - 1)&15) + 1;\n    ptr = (char*)ptr + diff;\n    ((char*)ptr)[-1]= diff;\n#elif HAVE_POSIX_MEMALIGN\n    if (posix_memalign(&ptr,16,size))\n        ptr = NULL;\n#elif HAVE_MEMALIGN\n    ptr = memalign(16,size);\n#else\n    ptr = malloc(size);\n#endif\n    return ptr;\n}']