MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / sdp_read_header

Function sdp_read_header

libavformat/rtsp.c:2030–2074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2028#define SDP_MAX_SIZE 8192
2029
2030static 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;
2070fail:
2071 ff_rtsp_close_streams(s);
2072 ff_network_close();
2073 return err;
2074}
2075
2076static int sdp_read_close(AVFormatContext *s)
2077{

Callers

nothing calls this directly

Calls 10

ff_network_initFunction · 0.85
av_mallocFunction · 0.85
get_bufferFunction · 0.85
av_freeFunction · 0.85
sdp_parseFunction · 0.85
ff_url_joinFunction · 0.85
url_openFunction · 0.85
rtsp_open_transport_ctxFunction · 0.85
ff_rtsp_close_streamsFunction · 0.85
ff_network_closeFunction · 0.85

Tested by

no test coverage detected