Mercurial > libavformat.hg
comparison sdp.c @ 2317:2adc9f64ecfb libavformat
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)
author | lucabe |
---|---|
date | Sun, 05 Aug 2007 13:44:56 +0000 |
parents | 5a4914f78109 |
children | f3a8f7d55bd1 |
comparison
equal
deleted
inserted
replaced
2316:5a4914f78109 | 2317:2adc9f64ecfb |
---|---|
167 dest_write(buff, size, dest_addr, ttl); | 167 dest_write(buff, size, dest_addr, ttl); |
168 | 168 |
169 sdp_media_attributes(buff, size, c, payload_type); | 169 sdp_media_attributes(buff, size, c, payload_type); |
170 } | 170 } |
171 | 171 |
172 #define SDP_BUFFER_SIZE 2048 | 172 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) |
173 char *avf_sdp_create(AVFormatContext *ac[], int n_files) | 173 { |
174 { | |
175 char *buff; | |
176 struct sdp_session_level s; | 174 struct sdp_session_level s; |
177 int i, j, port, ttl; | 175 int i, j, port, ttl; |
178 char dst[32]; | 176 char dst[32]; |
179 | |
180 buff = av_mallocz(SDP_BUFFER_SIZE); | |
181 if (buff == NULL) { | |
182 return NULL; | |
183 } | |
184 | 177 |
185 memset(&s, 0, sizeof(struct sdp_session_level)); | 178 memset(&s, 0, sizeof(struct sdp_session_level)); |
186 s.user = "-"; | 179 s.user = "-"; |
187 s.src_addr = "127.0.0.1"; /* FIXME: Properly set this */ | 180 s.src_addr = "127.0.0.1"; /* FIXME: Properly set this */ |
188 s.name = ac[0]->title; | 181 s.name = ac[0]->title; |
194 if (port > 0) { | 187 if (port > 0) { |
195 s.dst_addr = dst; | 188 s.dst_addr = dst; |
196 s.ttl = ttl; | 189 s.ttl = ttl; |
197 } | 190 } |
198 } | 191 } |
199 sdp_write_header(buff, SDP_BUFFER_SIZE, &s); | 192 sdp_write_header(buff, size, &s); |
200 | 193 |
201 dst[0] = 0; | 194 dst[0] = 0; |
202 for (i = 0; i < n_files; i++) { | 195 for (i = 0; i < n_files; i++) { |
203 if (n_files != 1) { | 196 if (n_files != 1) { |
204 port = get_address(dst, sizeof(dst), &ttl, ac[i]->filename); | 197 port = get_address(dst, sizeof(dst), &ttl, ac[i]->filename); |
205 } | 198 } |
206 for (j = 0; j < ac[i]->nb_streams; j++) { | 199 for (j = 0; j < ac[i]->nb_streams; j++) { |
207 sdp_write_media(buff, SDP_BUFFER_SIZE, | 200 sdp_write_media(buff, size, |
208 ac[i]->streams[j]->codec, dst[0] ? dst : NULL, | 201 ac[i]->streams[j]->codec, dst[0] ? dst : NULL, |
209 (port > 0) ? port + j * 2 : 0, ttl); | 202 (port > 0) ? port + j * 2 : 0, ttl); |
210 if (port <= 0) { | 203 if (port <= 0) { |
211 av_strlcatf(buff, SDP_BUFFER_SIZE, | 204 av_strlcatf(buff, size, |
212 "a=control:streamid=%d\r\n", i + j); | 205 "a=control:streamid=%d\r\n", i + j); |
213 } | 206 } |
214 } | 207 } |
215 } | 208 } |
216 | 209 |
217 return buff; | 210 return 0; |
218 } | 211 } |
219 #else | 212 #else |
220 char *avf_sdp_create(AVFormatContext *ac[], int n_files) | 213 int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size) |
221 { | 214 { |
222 return NULL; | 215 return AVERROR(ENOSYS); |
223 } | 216 } |
224 #endif | 217 #endif |