static void rtsp_send_cmd(AVFormatContext *s, 

                          const char *cmd, RTSPHeader *reply, 

                          unsigned char **content_ptr)

{

    RTSPState *rt = s->priv_data;

    char buf[4096], buf1[1024], *q;

    unsigned char ch;

    const char *p;

    int content_length, line_count;

    unsigned char *content = NULL;



    memset(reply, 0, sizeof(RTSPHeader));



    rt->seq++;

    pstrcpy(buf, sizeof(buf), cmd);

    snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);

    pstrcat(buf, sizeof(buf), buf1);

    if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {

        snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);

        pstrcat(buf, sizeof(buf), buf1);

    }

    pstrcat(buf, sizeof(buf), "\r\n");

#ifdef DEBUG

    printf("Sending:\n%s--\n", buf);

#endif

    url_write(rt->rtsp_hd, buf, strlen(buf));



    /* parse reply (XXX: use buffers) */

    line_count = 0;

    rt->last_reply[0] = '\0';

    for(;;) {

        q = buf;

        for(;;) {

            if (url_read(rt->rtsp_hd, &ch, 1) == 0)

                break;

            if (ch == '\n')

                break;

            if (ch != '\r') {

                if ((q - buf) < sizeof(buf) - 1)

                    *q++ = ch;

            }

        }

        *q = '\0';

#ifdef DEBUG

        printf("line='%s'\n", buf);

#endif

        /* test if last line */

        if (buf[0] == '\0')

            break;

        p = buf;

        if (line_count == 0) {

            /* get reply code */

            get_word(buf1, sizeof(buf1), &p);

            get_word(buf1, sizeof(buf1), &p);

            reply->status_code = atoi(buf1);

        } else {

            rtsp_parse_line(reply, p);

            pstrcat(rt->last_reply, sizeof(rt->last_reply), p);

            pstrcat(rt->last_reply, sizeof(rt->last_reply), "\n");

        }

        line_count++;

    }

    

    if (rt->session_id[0] == '\0' && reply->session_id[0] != '\0')

        pstrcpy(rt->session_id, sizeof(rt->session_id), reply->session_id);

    

    content_length = reply->content_length;

    if (content_length > 0) {

        /* leave some room for a trailing '\0' (useful for simple parsing) */

        content = av_malloc(content_length + 1);

        url_read(rt->rtsp_hd, content, content_length);

        content[content_length] = '\0';

    }

    if (content_ptr)

        *content_ptr = content;

}

static void rtsp_send_cmd(AVFormatContext *s, 

                          const char *cmd, RTSPHeader *reply, 

                          unsigned char **content_ptr)

{

    RTSPState *rt = s->priv_data;

    char buf[4096], buf1[1024], *q;

    unsigned char ch;

    const char *p;

    int content_length, line_count;

    unsigned char *content = NULL;



    memset(reply, 0, sizeof(RTSPHeader));



    rt->seq++;

    pstrcpy(buf, sizeof(buf), cmd);

    snprintf(buf1, sizeof(buf1), "CSeq: %d\r\n", rt->seq);

    pstrcat(buf, sizeof(buf), buf1);

    if (rt->session_id[0] != '\0' && !strstr(cmd, "\nIf-Match:")) {

        snprintf(buf1, sizeof(buf1), "Session: %s\r\n", rt->session_id);

        pstrcat(buf, sizeof(buf), buf1);

    }

    pstrcat(buf, sizeof(buf), "\r\n");

#ifdef DEBUG

    printf("Sending:\n%s--\n", buf);

#endif

    url_write(rt->rtsp_hd, buf, strlen(buf));



    

    line_count = 0;

    rt->last_reply[0] = '\0';

    for(;;) {

        q = buf;

        for(;;) {

            if (url_read(rt->rtsp_hd, &ch, 1) == 0)

                break;

            if (ch == '\n')

                break;

            if (ch != '\r') {

                if ((q - buf) < sizeof(buf) - 1)

                    *q++ = ch;

            }

        }

        *q = '\0';

#ifdef DEBUG

        printf("line='%s'\n", buf);

#endif

        

        if (buf[0] == '\0')

            break;

        p = buf;

        if (line_count == 0) {

            

            get_word(buf1, sizeof(buf1), &p);

            get_word(buf1, sizeof(buf1), &p);

            reply->status_code = atoi(buf1);

        } else {

            rtsp_parse_line(reply, p);

            pstrcat(rt->last_reply, sizeof(rt->last_reply), p);

            pstrcat(rt->last_reply, sizeof(rt->last_reply), "\n");

        }

        line_count++;

    }

    

    if (rt->session_id[0] == '\0' && reply->session_id[0] != '\0')

        pstrcpy(rt->session_id, sizeof(rt->session_id), reply->session_id);

    

    content_length = reply->content_length;

    if (content_length > 0) {

        

        content = av_malloc(content_length + 1);

        url_read(rt->rtsp_hd, content, content_length);

        content[content_length] = '\0';

    }

    if (content_ptr)

        *content_ptr = content;

}

static void FUNC_0(AVFormatContext *VAR_0, 

                          const char *VAR_1, RTSPHeader *VAR_2, 

                          unsigned char **VAR_3)

{

    RTSPState *rt = VAR_0->priv_data;

    char VAR_4[4096], VAR_5[1024], *VAR_6;

    unsigned char VAR_7;

    const char *VAR_8;

    int VAR_9, VAR_10;

    unsigned char *VAR_11 = NULL;



    memset(VAR_2, 0, sizeof(RTSPHeader));



    rt->seq++;

    pstrcpy(VAR_4, sizeof(VAR_4), VAR_1);

    snprintf(VAR_5, sizeof(VAR_5), "CSeq: %d\r\n", rt->seq);

    pstrcat(VAR_4, sizeof(VAR_4), VAR_5);

    if (rt->session_id[0] != '\0' && !strstr(VAR_1, "\nIf-Match:")) {

        snprintf(VAR_5, sizeof(VAR_5), "Session: %VAR_0\r\n", rt->session_id);

        pstrcat(VAR_4, sizeof(VAR_4), VAR_5);

    }

    pstrcat(VAR_4, sizeof(VAR_4), "\r\n");

#ifdef DEBUG

    printf("Sending:\n%VAR_0--\n", VAR_4);

#endif

    url_write(rt->rtsp_hd, VAR_4, strlen(VAR_4));



    

    VAR_10 = 0;

    rt->last_reply[0] = '\0';

    for(;;) {

        VAR_6 = VAR_4;

        for(;;) {

            if (url_read(rt->rtsp_hd, &VAR_7, 1) == 0)

                break;

            if (VAR_7 == '\n')

                break;

            if (VAR_7 != '\r') {

                if ((VAR_6 - VAR_4) < sizeof(VAR_4) - 1)

                    *VAR_6++ = VAR_7;

            }

        }

        *VAR_6 = '\0';

#ifdef DEBUG

        printf("line='%VAR_0'\n", VAR_4);

#endif

        

        if (VAR_4[0] == '\0')

            break;

        VAR_8 = VAR_4;

        if (VAR_10 == 0) {

            

            get_word(VAR_5, sizeof(VAR_5), &VAR_8);

            get_word(VAR_5, sizeof(VAR_5), &VAR_8);

            VAR_2->status_code = atoi(VAR_5);

        } else {

            rtsp_parse_line(VAR_2, VAR_8);

            pstrcat(rt->last_reply, sizeof(rt->last_reply), VAR_8);

            pstrcat(rt->last_reply, sizeof(rt->last_reply), "\n");

        }

        VAR_10++;

    }

    

    if (rt->session_id[0] == '\0' && VAR_2->session_id[0] != '\0')

        pstrcpy(rt->session_id, sizeof(rt->session_id), VAR_2->session_id);

    

    VAR_9 = VAR_2->VAR_9;

    if (VAR_9 > 0) {

        

        VAR_11 = av_malloc(VAR_9 + 1);

        url_read(rt->rtsp_hd, VAR_11, VAR_9);

        VAR_11[VAR_9] = '\0';

    }

    if (VAR_3)

        *VAR_3 = VAR_11;

}

static void FUNC_0(AVFormatContext *VAR_0,
const char *VAR_1, RTSPHeader *VAR_2,
unsigned char **VAR_3)
{ RTSPState *rt = VAR_0->priv_data; char VAR_4[4096], VAR_5[1024], *VAR_6; unsigned char VAR_7; const char *VAR_8; int VAR_9, VAR_10; unsigned char *VAR_11 = NULL; memset(VAR_2, 0, sizeof(RTSPHeader)); rt->seq++; pstrcpy(VAR_4, sizeof(VAR_4), VAR_1); snprintf(VAR_5, sizeof(VAR_5), "CSeq: %d\r\n", rt->seq); pstrcat(VAR_4, sizeof(VAR_4), VAR_5); if (rt->session_id[0] != '\0' && !strstr(VAR_1, "\nIf-Match:")) { snprintf(VAR_5, sizeof(VAR_5), "Session: %VAR_0\r\n", rt->session_id); pstrcat(VAR_4, sizeof(VAR_4), VAR_5); } pstrcat(VAR_4, sizeof(VAR_4), "\r\n"); #ifdef DEBUG
printf("Sending:\n%VAR_0--\n", VAR_4); #endif
url_write(rt->rtsp_hd, VAR_4, strlen(VAR_4)); VAR_10 = 0; rt->last_reply[0] = '\0'; for(;;) { VAR_6 = VAR_4; for(;;) { if (url_read(rt->rtsp_hd, &VAR_7, 1) == 0)
break; if (VAR_7 == '\n')
break; if (VAR_7 != '\r') { if ((VAR_6 - VAR_4) < sizeof(VAR_4) - 1)
*VAR_6++ = VAR_7; } } *VAR_6 = '\0'; #ifdef DEBUG
printf("line='%VAR_0'\n", VAR_4); #endif
if (VAR_4[0] == '\0')
break; VAR_8 = VAR_4; if (VAR_10 == 0) { get_word(VAR_5, sizeof(VAR_5), &VAR_8); get_word(VAR_5, sizeof(VAR_5), &VAR_8); VAR_2->status_code = atoi(VAR_5); } else { rtsp_parse_line(VAR_2, VAR_8); pstrcat(rt->last_reply, sizeof(rt->last_reply), VAR_8); pstrcat(rt->last_reply, sizeof(rt->last_reply), "\n"); } VAR_10++; } if (rt->session_id[0] == '\0' && VAR_2->session_id[0] != '\0')
pstrcpy(rt->session_id, sizeof(rt->session_id), VAR_2->session_id); VAR_9 = VAR_2->VAR_9; if (VAR_9 > 0) { VAR_11 = av_malloc(VAR_9 + 1); url_read(rt->rtsp_hd, VAR_11, VAR_9); VAR_11[VAR_9] = '\0'; } if (VAR_3)
*VAR_3 = VAR_11; }