| 2028 | #define SDP_MAX_SIZE 8192 |
| 2029 | |
| 2030 | static int sdp_read_header(AVFormatContext *s, AVFormatParameters *ap) |
| 2031 | { |
| 2032 | RTSPState *rt = s->priv_data; |
| 2033 | RTSPStream *rtsp_st; |
| 2034 | int size, i, err; |
| 2035 | char *content; |
| 2036 | char url[1024]; |
| 2037 | |
| 2038 | if (!ff_network_init()) |
| 2039 | return AVERROR(EIO); |
| 2040 | |
| 2041 | /* read the whole sdp file */ |
| 2042 | /* XXX: better loading */ |
| 2043 | content = av_malloc(SDP_MAX_SIZE); |
| 2044 | size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1); |
| 2045 | if (size <= 0) { |
| 2046 | av_free(content); |
| 2047 | return AVERROR_INVALIDDATA; |
| 2048 | } |
| 2049 | content[size] ='\0'; |
| 2050 | |
| 2051 | sdp_parse(s, content); |
| 2052 | av_free(content); |
| 2053 | |
| 2054 | /* open each RTP stream */ |
| 2055 | for (i = 0; i < rt->nb_rtsp_streams; i++) { |
| 2056 | rtsp_st = rt->rtsp_streams[i]; |
| 2057 | |
| 2058 | ff_url_join(url, sizeof(url), "rtp", NULL, |
| 2059 | inet_ntoa(rtsp_st->sdp_ip), rtsp_st->sdp_port, |
| 2060 | "?localport=%d&ttl=%d", rtsp_st->sdp_port, |
| 2061 | rtsp_st->sdp_ttl); |
| 2062 | if (url_open(&rtsp_st->rtp_handle, url, URL_RDWR) < 0) { |
| 2063 | err = AVERROR_INVALIDDATA; |
| 2064 | goto fail; |
| 2065 | } |
| 2066 | if ((err = rtsp_open_transport_ctx(s, rtsp_st))) |
| 2067 | goto fail; |
| 2068 | } |
| 2069 | return 0; |
| 2070 | fail: |
| 2071 | ff_rtsp_close_streams(s); |
| 2072 | ff_network_close(); |
| 2073 | return err; |
| 2074 | } |
| 2075 | |
| 2076 | static int sdp_read_close(AVFormatContext *s) |
| 2077 | { |
nothing calls this directly
no test coverage detected