avformat/rtsp: load the sdp file with avio_read_to_bprint()
this allows getting rid of the hardcoded max size of SDP. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
@@ -2372,9 +2372,9 @@ static int sdp_read_header(AVFormatContext *s)
|
|||||||
{
|
{
|
||||||
RTSPState *rt = s->priv_data;
|
RTSPState *rt = s->priv_data;
|
||||||
RTSPStream *rtsp_st;
|
RTSPStream *rtsp_st;
|
||||||
int size, i, err;
|
int i, err;
|
||||||
char *content;
|
|
||||||
char url[MAX_URL_SIZE];
|
char url[MAX_URL_SIZE];
|
||||||
|
AVBPrint bp;
|
||||||
|
|
||||||
if (!ff_network_init())
|
if (!ff_network_init())
|
||||||
return AVERROR(EIO);
|
return AVERROR(EIO);
|
||||||
@@ -2385,22 +2385,15 @@ static int sdp_read_header(AVFormatContext *s)
|
|||||||
rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;
|
rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;
|
||||||
|
|
||||||
/* read the whole sdp file */
|
/* read the whole sdp file */
|
||||||
/* XXX: better loading */
|
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||||
content = av_malloc(SDP_MAX_SIZE);
|
err = avio_read_to_bprint(s->pb, &bp, INT_MAX);
|
||||||
if (!content) {
|
if (err < 0 ) {
|
||||||
ff_network_close();
|
ff_network_close();
|
||||||
return AVERROR(ENOMEM);
|
av_bprint_finalize(&bp, NULL);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
size = avio_read(s->pb, content, SDP_MAX_SIZE - 1);
|
err = ff_sdp_parse(s, bp.str);
|
||||||
if (size <= 0) {
|
av_bprint_finalize(&bp, NULL);
|
||||||
av_free(content);
|
|
||||||
ff_network_close();
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
content[size] ='\0';
|
|
||||||
|
|
||||||
err = ff_sdp_parse(s, content);
|
|
||||||
av_freep(&content);
|
|
||||||
if (err) goto fail;
|
if (err) goto fail;
|
||||||
|
|
||||||
/* open each RTP stream */
|
/* open each RTP stream */
|
||||||
|
Reference in New Issue
Block a user