| 3048 | } |
| 3049 | |
| 3050 | static void rtsp_cmd_setup(HTTPContext *c, const char *url, |
| 3051 | RTSPMessageHeader *h) |
| 3052 | { |
| 3053 | FFStream *stream; |
| 3054 | int stream_index, rtp_port, rtcp_port; |
| 3055 | char buf[1024]; |
| 3056 | char path1[1024]; |
| 3057 | const char *path; |
| 3058 | HTTPContext *rtp_c; |
| 3059 | RTSPTransportField *th; |
| 3060 | struct sockaddr_in dest_addr; |
| 3061 | RTSPActionServerSetup setup; |
| 3062 | |
| 3063 | /* find which url is asked */ |
| 3064 | ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); |
| 3065 | path = path1; |
| 3066 | if (*path == '/') |
| 3067 | path++; |
| 3068 | |
| 3069 | /* now check each stream */ |
| 3070 | for(stream = first_stream; stream != NULL; stream = stream->next) { |
| 3071 | if (!stream->is_feed && |
| 3072 | stream->fmt && !strcmp(stream->fmt->name, "rtp")) { |
| 3073 | /* accept aggregate filenames only if single stream */ |
| 3074 | if (!strcmp(path, stream->filename)) { |
| 3075 | if (stream->nb_streams != 1) { |
| 3076 | rtsp_reply_error(c, RTSP_STATUS_AGGREGATE); |
| 3077 | return; |
| 3078 | } |
| 3079 | stream_index = 0; |
| 3080 | goto found; |
| 3081 | } |
| 3082 | |
| 3083 | for(stream_index = 0; stream_index < stream->nb_streams; |
| 3084 | stream_index++) { |
| 3085 | snprintf(buf, sizeof(buf), "%s/streamid=%d", |
| 3086 | stream->filename, stream_index); |
| 3087 | if (!strcmp(path, buf)) |
| 3088 | goto found; |
| 3089 | } |
| 3090 | } |
| 3091 | } |
| 3092 | /* no stream found */ |
| 3093 | rtsp_reply_error(c, RTSP_STATUS_SERVICE); /* XXX: right error ? */ |
| 3094 | return; |
| 3095 | found: |
| 3096 | |
| 3097 | /* generate session id if needed */ |
| 3098 | if (h->session_id[0] == '\0') |
| 3099 | snprintf(h->session_id, sizeof(h->session_id), "%08x%08x", |
| 3100 | av_lfg_get(&random_state), av_lfg_get(&random_state)); |
| 3101 | |
| 3102 | /* find rtp session, and create it if none found */ |
| 3103 | rtp_c = find_rtp_session(h->session_id); |
| 3104 | if (!rtp_c) { |
| 3105 | /* always prefer UDP */ |
| 3106 | th = find_transport(h, RTSP_LOWER_TRANSPORT_UDP); |
| 3107 | if (!th) { |
no test coverage detected