static inline int parse_command_line(AVFormatContext *s, const char *line,
                                     int linelen, char *uri, int urisize,
                                     char *method, int methodsize,
                                     enum RTSPMethod *methodcode)
{
    RTSPState *rt = s->priv_data;
    const char *linept, *searchlinept;
    linept = strchr(line, ' ');
    if (linept - line > methodsize - 1) {
        av_log(s, AV_LOG_ERROR, "Method string too long\n");
        return AVERROR(EIO);
    }
    memcpy(method, line, linept - line);
    method[linept - line] = '\0';
    linept++;
    if (!strcmp(method, "ANNOUNCE"))
        *methodcode = ANNOUNCE;
    else if (!strcmp(method, "OPTIONS"))
        *methodcode = OPTIONS;
    else if (!strcmp(method, "RECORD"))
        *methodcode = RECORD;
    else if (!strcmp(method, "SETUP"))
        *methodcode = SETUP;
    else if (!strcmp(method, "PAUSE"))
        *methodcode = PAUSE;
    else if (!strcmp(method, "TEARDOWN"))
        *methodcode = TEARDOWN;
    else
        *methodcode = UNKNOWN;
    /* Check method with the state  */
    if (rt->state == RTSP_STATE_IDLE) {
        if ((*methodcode != ANNOUNCE) && (*methodcode != OPTIONS)) {
            av_log(s, AV_LOG_ERROR, "Unexpected command in Idle State %s\n",
                   line);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else if (rt->state == RTSP_STATE_PAUSED) {
        if ((*methodcode != OPTIONS) && (*methodcode != RECORD)
            && (*methodcode != SETUP)) {
            av_log(s, AV_LOG_ERROR, "Unexpected command in Paused State %s\n",
                   line);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else if (rt->state == RTSP_STATE_STREAMING) {
        if ((*methodcode != PAUSE) && (*methodcode != OPTIONS)
            && (*methodcode != TEARDOWN)) {
            av_log(s, AV_LOG_ERROR, "Unexpected command in Streaming State"
                   " %s\n", line);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else {
        av_log(s, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state);
        return AVERROR_BUG;
    }
    searchlinept = strchr(linept, ' ');
    if (!searchlinept) {
        av_log(s, AV_LOG_ERROR, "Error parsing message URI\n");
    }
    if (searchlinept - linept > urisize - 1) {
        av_log(s, AV_LOG_ERROR, "uri string length exceeded buffer size\n");
        return AVERROR(EIO);
    }
    memcpy(uri, linept, searchlinept - linept);
    uri[searchlinept - linept] = '\0';
    if (strcmp(rt->control_uri, uri)) {
        char host[128], path[512], auth[128];
        int port;
        char ctl_host[128], ctl_path[512], ctl_auth[128];
        int ctl_port;
        av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
                     path, sizeof(path), uri);
        av_url_split(NULL, 0, ctl_auth, sizeof(ctl_auth), ctl_host,
                     sizeof(ctl_host), &ctl_port, ctl_path, sizeof(ctl_path),
                     rt->control_uri);
        if (strcmp(host, ctl_host))
            av_log(s, AV_LOG_INFO, "Host %s differs from expected %s\n",
                   host, ctl_host);
        if (strcmp(path, ctl_path) && *methodcode != SETUP)
            av_log(s, AV_LOG_WARNING, "WARNING: Path %s differs from expected"
                   " %s\n", path, ctl_path);
        if (*methodcode == ANNOUNCE) {
            av_log(s, AV_LOG_INFO,
                   "Updating control URI to %s\n", uri);
            av_strlcpy(rt->control_uri, uri, sizeof(rt->control_uri));
        }
    }
    linept = searchlinept + 1;
    if (!av_strstart(linept, "RTSP/1.0", NULL)) {
        av_log(s, AV_LOG_ERROR, "Error parsing protocol or version\n");
        return AVERROR_PROTOCOL_NOT_FOUND;
    }
    return 0;
}
static inline int parse_command_line(AVFormatContext *s, const char *line,
                                     int linelen, char *uri, int urisize,
                                     char *method, int methodsize,
                                     enum RTSPMethod *methodcode)
{
    RTSPState *rt = s->priv_data;
    const char *linept, *searchlinept;
    linept = strchr(line, ' ');
    if (linept - line > methodsize - 1) {
        av_log(s, AV_LOG_ERROR, "Method string too long\n");
        return AVERROR(EIO);
    }
    memcpy(method, line, linept - line);
    method[linept - line] = '\0';
    linept++;
    if (!strcmp(method, "ANNOUNCE"))
        *methodcode = ANNOUNCE;
    else if (!strcmp(method, "OPTIONS"))
        *methodcode = OPTIONS;
    else if (!strcmp(method, "RECORD"))
        *methodcode = RECORD;
    else if (!strcmp(method, "SETUP"))
        *methodcode = SETUP;
    else if (!strcmp(method, "PAUSE"))
        *methodcode = PAUSE;
    else if (!strcmp(method, "TEARDOWN"))
        *methodcode = TEARDOWN;
    else
        *methodcode = UNKNOWN;
    
    if (rt->state == RTSP_STATE_IDLE) {
        if ((*methodcode != ANNOUNCE) && (*methodcode != OPTIONS)) {
            av_log(s, AV_LOG_ERROR, "Unexpected command in Idle State %s\n",
                   line);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else if (rt->state == RTSP_STATE_PAUSED) {
        if ((*methodcode != OPTIONS) && (*methodcode != RECORD)
            && (*methodcode != SETUP)) {
            av_log(s, AV_LOG_ERROR, "Unexpected command in Paused State %s\n",
                   line);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else if (rt->state == RTSP_STATE_STREAMING) {
        if ((*methodcode != PAUSE) && (*methodcode != OPTIONS)
            && (*methodcode != TEARDOWN)) {
            av_log(s, AV_LOG_ERROR, "Unexpected command in Streaming State"
                   " %s\n", line);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else {
        av_log(s, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state);
        return AVERROR_BUG;
    }
    searchlinept = strchr(linept, ' ');
    if (!searchlinept) {
        av_log(s, AV_LOG_ERROR, "Error parsing message URI\n");
    }
    if (searchlinept - linept > urisize - 1) {
        av_log(s, AV_LOG_ERROR, "uri string length exceeded buffer size\n");
        return AVERROR(EIO);
    }
    memcpy(uri, linept, searchlinept - linept);
    uri[searchlinept - linept] = '\0';
    if (strcmp(rt->control_uri, uri)) {
        char host[128], path[512], auth[128];
        int port;
        char ctl_host[128], ctl_path[512], ctl_auth[128];
        int ctl_port;
        av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port,
                     path, sizeof(path), uri);
        av_url_split(NULL, 0, ctl_auth, sizeof(ctl_auth), ctl_host,
                     sizeof(ctl_host), &ctl_port, ctl_path, sizeof(ctl_path),
                     rt->control_uri);
        if (strcmp(host, ctl_host))
            av_log(s, AV_LOG_INFO, "Host %s differs from expected %s\n",
                   host, ctl_host);
        if (strcmp(path, ctl_path) && *methodcode != SETUP)
            av_log(s, AV_LOG_WARNING, "WARNING: Path %s differs from expected"
                   " %s\n", path, ctl_path);
        if (*methodcode == ANNOUNCE) {
            av_log(s, AV_LOG_INFO,
                   "Updating control URI to %s\n", uri);
            av_strlcpy(rt->control_uri, uri, sizeof(rt->control_uri));
        }
    }
    linept = searchlinept + 1;
    if (!av_strstart(linept, "RTSP/1.0", NULL)) {
        av_log(s, AV_LOG_ERROR, "Error parsing protocol or version\n");
        return AVERROR_PROTOCOL_NOT_FOUND;
    }
    return 0;
}
static inline int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1,
                                     int VAR_2, char *VAR_3, int VAR_4,
                                     char *VAR_5, int VAR_6,
                                     enum RTSPMethod *VAR_7)
{
    RTSPState *rt = VAR_0->priv_data;
    const char *VAR_8, *VAR_9;
    VAR_8 = strchr(VAR_1, ' ');
    if (VAR_8 - VAR_1 > VAR_6 - 1) {
        av_log(VAR_0, AV_LOG_ERROR, "Method string too long\n");
        return AVERROR(EIO);
    }
    memcpy(VAR_5, VAR_1, VAR_8 - VAR_1);
    VAR_5[VAR_8 - VAR_1] = '\0';
    VAR_8++;
    if (!strcmp(VAR_5, "ANNOUNCE"))
        *VAR_7 = ANNOUNCE;
    else if (!strcmp(VAR_5, "OPTIONS"))
        *VAR_7 = OPTIONS;
    else if (!strcmp(VAR_5, "RECORD"))
        *VAR_7 = RECORD;
    else if (!strcmp(VAR_5, "SETUP"))
        *VAR_7 = SETUP;
    else if (!strcmp(VAR_5, "PAUSE"))
        *VAR_7 = PAUSE;
    else if (!strcmp(VAR_5, "TEARDOWN"))
        *VAR_7 = TEARDOWN;
    else
        *VAR_7 = UNKNOWN;
    
    if (rt->state == RTSP_STATE_IDLE) {
        if ((*VAR_7 != ANNOUNCE) && (*VAR_7 != OPTIONS)) {
            av_log(VAR_0, AV_LOG_ERROR, "Unexpected command in Idle State %VAR_0\n",
                   VAR_1);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else if (rt->state == RTSP_STATE_PAUSED) {
        if ((*VAR_7 != OPTIONS) && (*VAR_7 != RECORD)
            && (*VAR_7 != SETUP)) {
            av_log(VAR_0, AV_LOG_ERROR, "Unexpected command in Paused State %VAR_0\n",
                   VAR_1);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else if (rt->state == RTSP_STATE_STREAMING) {
        if ((*VAR_7 != PAUSE) && (*VAR_7 != OPTIONS)
            && (*VAR_7 != TEARDOWN)) {
            av_log(VAR_0, AV_LOG_ERROR, "Unexpected command in Streaming State"
                   " %VAR_0\n", VAR_1);
            return AVERROR_PROTOCOL_NOT_FOUND;
        }
    } else {
        av_log(VAR_0, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state);
        return AVERROR_BUG;
    }
    VAR_9 = strchr(VAR_8, ' ');
    if (!VAR_9) {
        av_log(VAR_0, AV_LOG_ERROR, "Error parsing message URI\n");
    }
    if (VAR_9 - VAR_8 > VAR_4 - 1) {
        av_log(VAR_0, AV_LOG_ERROR, "VAR_3 string length exceeded buffer size\n");
        return AVERROR(EIO);
    }
    memcpy(VAR_3, VAR_8, VAR_9 - VAR_8);
    VAR_3[VAR_9 - VAR_8] = '\0';
    if (strcmp(rt->control_uri, VAR_3)) {
        char VAR_10[128], VAR_11[512], VAR_12[128];
        int VAR_13;
        char VAR_14[128], VAR_15[512], VAR_16[128];
        int VAR_17;
        av_url_split(NULL, 0, VAR_12, sizeof(VAR_12), VAR_10, sizeof(VAR_10), &VAR_13,
                     VAR_11, sizeof(VAR_11), VAR_3);
        av_url_split(NULL, 0, VAR_16, sizeof(VAR_16), VAR_14,
                     sizeof(VAR_14), &VAR_17, VAR_15, sizeof(VAR_15),
                     rt->control_uri);
        if (strcmp(VAR_10, VAR_14))
            av_log(VAR_0, AV_LOG_INFO, "Host %VAR_0 differs from expected %VAR_0\n",
                   VAR_10, VAR_14);
        if (strcmp(VAR_11, VAR_15) && *VAR_7 != SETUP)
            av_log(VAR_0, AV_LOG_WARNING, "WARNING: Path %VAR_0 differs from expected"
                   " %VAR_0\n", VAR_11, VAR_15);
        if (*VAR_7 == ANNOUNCE) {
            av_log(VAR_0, AV_LOG_INFO,
                   "Updating control URI to %VAR_0\n", VAR_3);
            av_strlcpy(rt->control_uri, VAR_3, sizeof(rt->control_uri));
        }
    }
    VAR_8 = VAR_9 + 1;
    if (!av_strstart(VAR_8, "RTSP/1.0", NULL)) {
        av_log(VAR_0, AV_LOG_ERROR, "Error parsing protocol or version\n");
        return AVERROR_PROTOCOL_NOT_FOUND;
    }
    return 0;
}
static inline int FUNC_0(AVFormatContext *VAR_0, const char *VAR_1,
int VAR_2, char *VAR_3, int VAR_4,
char *VAR_5, int VAR_6,
enum RTSPMethod *VAR_7)
{ RTSPState *rt = VAR_0->priv_data; const char *VAR_8, *VAR_9; VAR_8 = strchr(VAR_1, ' '); if (VAR_8 - VAR_1 > VAR_6 - 1) { av_log(VAR_0, AV_LOG_ERROR, "Method string too long\n"); return AVERROR(EIO); } memcpy(VAR_5, VAR_1, VAR_8 - VAR_1); VAR_5[VAR_8 - VAR_1] = '\0'; VAR_8++; if (!strcmp(VAR_5, "ANNOUNCE"))
*VAR_7 = ANNOUNCE; else if (!strcmp(VAR_5, "OPTIONS"))
*VAR_7 = OPTIONS; else if (!strcmp(VAR_5, "RECORD"))
*VAR_7 = RECORD; else if (!strcmp(VAR_5, "SETUP"))
*VAR_7 = SETUP; else if (!strcmp(VAR_5, "PAUSE"))
*VAR_7 = PAUSE; else if (!strcmp(VAR_5, "TEARDOWN"))
*VAR_7 = TEARDOWN; else
*VAR_7 = UNKNOWN; if (rt->state == RTSP_STATE_IDLE) { if ((*VAR_7 != ANNOUNCE) && (*VAR_7 != OPTIONS)) { av_log(VAR_0, AV_LOG_ERROR, "Unexpected command in Idle State %VAR_0\n",
VAR_1); return AVERROR_PROTOCOL_NOT_FOUND; } } else if (rt->state == RTSP_STATE_PAUSED) { if ((*VAR_7 != OPTIONS) && (*VAR_7 != RECORD)
&& (*VAR_7 != SETUP)) { av_log(VAR_0, AV_LOG_ERROR, "Unexpected command in Paused State %VAR_0\n",
VAR_1); return AVERROR_PROTOCOL_NOT_FOUND; } } else if (rt->state == RTSP_STATE_STREAMING) { if ((*VAR_7 != PAUSE) && (*VAR_7 != OPTIONS)
&& (*VAR_7 != TEARDOWN)) { av_log(VAR_0, AV_LOG_ERROR, "Unexpected command in Streaming State"
" %VAR_0\n", VAR_1); return AVERROR_PROTOCOL_NOT_FOUND; } } else { av_log(VAR_0, AV_LOG_ERROR, "Unexpected State [%d]\n", rt->state); return AVERROR_BUG; } VAR_9 = strchr(VAR_8, ' '); if (!VAR_9) { av_log(VAR_0, AV_LOG_ERROR, "Error parsing message URI\n"); } if (VAR_9 - VAR_8 > VAR_4 - 1) { av_log(VAR_0, AV_LOG_ERROR, "VAR_3 string length exceeded buffer size\n"); return AVERROR(EIO); } memcpy(VAR_3, VAR_8, VAR_9 - VAR_8); VAR_3[VAR_9 - VAR_8] = '\0'; if (strcmp(rt->control_uri, VAR_3)) { char VAR_10[128], VAR_11[512], VAR_12[128]; int VAR_13; char VAR_14[128], VAR_15[512], VAR_16[128]; int VAR_17; av_url_split(NULL, 0, VAR_12, sizeof(VAR_12), VAR_10, sizeof(VAR_10), &VAR_13,
VAR_11, sizeof(VAR_11), VAR_3); av_url_split(NULL, 0, VAR_16, sizeof(VAR_16), VAR_14,
sizeof(VAR_14), &VAR_17, VAR_15, sizeof(VAR_15),
rt->control_uri); if (strcmp(VAR_10, VAR_14))
av_log(VAR_0, AV_LOG_INFO, "Host %VAR_0 differs from expected %VAR_0\n",
VAR_10, VAR_14); if (strcmp(VAR_11, VAR_15) && *VAR_7 != SETUP)
av_log(VAR_0, AV_LOG_WARNING, "WARNING: Path %VAR_0 differs from expected"
" %VAR_0\n", VAR_11, VAR_15); if (*VAR_7 == ANNOUNCE) { av_log(VAR_0, AV_LOG_INFO,
"Updating control URI to %VAR_0\n", VAR_3); av_strlcpy(rt->control_uri, VAR_3, sizeof(rt->control_uri)); } } VAR_8 = VAR_9 + 1; if (!av_strstart(VAR_8, "RTSP/1.0", NULL)) { av_log(VAR_0, AV_LOG_ERROR, "Error parsing protocol or version\n"); return AVERROR_PROTOCOL_NOT_FOUND; } return 0; }