diff options
author | Luca Abeni <lucabe72@email.it> | 2007-08-05 13:44:56 +0000 |
---|---|---|
committer | Luca Abeni <lucabe72@email.it> | 2007-08-05 13:44:56 +0000 |
commit | 8767b80f5faa59bace5360465b68c39a24075bf1 (patch) | |
tree | 32403fc500c5309dc3e491e34b81650354bbbf51 /libavformat/sdp.c | |
parent | fe4ff07aa0085e3db704b9aaa74fbf4d37b5c217 (diff) | |
download | ffmpeg-streaming-8767b80f5faa59bace5360465b68c39a24075bf1.zip ffmpeg-streaming-8767b80f5faa59bace5360465b68c39a24075bf1.tar.gz |
Change avf_sdp_create() to get a pre-allocated buffer as input, and to
return an integer (0 if the SDP has been succesfully created, < 0 in case
of error)
Originally committed as revision 9947 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/sdp.c')
-rw-r--r-- | libavformat/sdp.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 2809163..1062c8d 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -169,19 +169,12 @@ static void sdp_write_media(char *buff, int size, AVCodecContext *c, const char sdp_media_attributes(buff, size, c, payload_type); } -#define SDP_BUFFER_SIZE 2048 -char *avf_sdp_create(AVFormatContext *ac[], int n_files) +int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) { - char *buff; struct sdp_session_level s; int i, j, port, ttl; char dst[32]; - buff = av_mallocz(SDP_BUFFER_SIZE); - if (buff == NULL) { - return NULL; - } - memset(&s, 0, sizeof(struct sdp_session_level)); s.user = "-"; s.src_addr = "127.0.0.1"; /* FIXME: Properly set this */ @@ -196,7 +189,7 @@ char *avf_sdp_create(AVFormatContext *ac[], int n_files) s.ttl = ttl; } } - sdp_write_header(buff, SDP_BUFFER_SIZE, &s); + sdp_write_header(buff, size, &s); dst[0] = 0; for (i = 0; i < n_files; i++) { @@ -204,21 +197,21 @@ char *avf_sdp_create(AVFormatContext *ac[], int n_files) port = get_address(dst, sizeof(dst), &ttl, ac[i]->filename); } for (j = 0; j < ac[i]->nb_streams; j++) { - sdp_write_media(buff, SDP_BUFFER_SIZE, + sdp_write_media(buff, size, ac[i]->streams[j]->codec, dst[0] ? dst : NULL, (port > 0) ? port + j * 2 : 0, ttl); if (port <= 0) { - av_strlcatf(buff, SDP_BUFFER_SIZE, + av_strlcatf(buff, size, "a=control:streamid=%d\r\n", i + j); } } } - return buff; + return 0; } #else -char *avf_sdp_create(AVFormatContext *ac[], int n_files) +int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) { - return NULL; + return AVERROR(ENOSYS); } #endif |