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

Function http_prepare_data

ffserver.c:2228–2453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2226
2227
2228static int http_prepare_data(HTTPContext *c)
2229{
2230 int i, len, ret;
2231 AVFormatContext *ctx;
2232
2233 av_freep(&c->pb_buffer);
2234 switch(c->state) {
2235 case HTTPSTATE_SEND_DATA_HEADER:
2236 memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
2237 av_metadata_set2(&c->fmt_ctx.metadata, "author" , c->stream->author , 0);
2238 av_metadata_set2(&c->fmt_ctx.metadata, "comment" , c->stream->comment , 0);
2239 av_metadata_set2(&c->fmt_ctx.metadata, "copyright", c->stream->copyright, 0);
2240 av_metadata_set2(&c->fmt_ctx.metadata, "title" , c->stream->title , 0);
2241
2242 for(i=0;i<c->stream->nb_streams;i++) {
2243 AVStream *st;
2244 AVStream *src;
2245 st = av_mallocz(sizeof(AVStream));
2246 c->fmt_ctx.streams[i] = st;
2247 /* if file or feed, then just take streams from FFStream struct */
2248 if (!c->stream->feed ||
2249 c->stream->feed == c->stream)
2250 src = c->stream->streams[i];
2251 else
2252 src = c->stream->feed->streams[c->stream->feed_streams[i]];
2253
2254 *st = *src;
2255 st->priv_data = 0;
2256 st->codec->frame_number = 0; /* XXX: should be done in
2257 AVStream, not in codec */
2258 }
2259 /* set output format parameters */
2260 c->fmt_ctx.oformat = c->stream->fmt;
2261 c->fmt_ctx.nb_streams = c->stream->nb_streams;
2262
2263 c->got_key_frame = 0;
2264
2265 /* prepare header and save header data in a stream */
2266 if (url_open_dyn_buf(&c->fmt_ctx.pb) < 0) {
2267 /* XXX: potential leak */
2268 return -1;
2269 }
2270 c->fmt_ctx.pb->is_streamed = 1;
2271
2272 /*
2273 * HACK to avoid mpeg ps muxer to spit many underflow errors
2274 * Default value from FFmpeg
2275 * Try to set it use configuration option
2276 */
2277 c->fmt_ctx.preload = (int)(0.5*AV_TIME_BASE);
2278 c->fmt_ctx.max_delay = (int)(0.7*AV_TIME_BASE);
2279
2280 av_set_parameters(&c->fmt_ctx, NULL);
2281 if (av_write_header(&c->fmt_ctx) < 0) {
2282 http_log("Error writing output header\n");
2283 return -1;
2284 }
2285 av_metadata_free(&c->fmt_ctx.metadata);

Callers 1

http_send_dataFunction · 0.85

Calls 15

av_freepFunction · 0.85
av_metadata_set2Function · 0.85
av_malloczFunction · 0.85
url_open_dyn_bufFunction · 0.85
av_set_parametersFunction · 0.85
av_write_headerFunction · 0.85
http_logFunction · 0.85
av_metadata_freeFunction · 0.85
url_close_dyn_bufFunction · 0.85
ffm_set_write_indexFunction · 0.85
av_read_frameFunction · 0.85
av_close_input_fileFunction · 0.85

Tested by

no test coverage detected