X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffserver.c;h=65ae431752ad6d0dc53419e880dcad5f34105e34;hb=15206ffdbee3c04e638a01cd4572050cf4cfad42;hp=577ca6ff459daea9e0f406934ec59f379c58b0d5;hpb=1b86a6bb2cea5038a546a35d8ea844cf5487081a;p=ffmpeg diff --git a/ffserver.c b/ffserver.c index 577ca6ff459..65ae431752a 100644 --- a/ffserver.c +++ b/ffserver.c @@ -300,9 +300,9 @@ bail_eio: static void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size) { - FFMContext *ffm = s->priv_data; - ffm->write_index = pos; - ffm->file_size = file_size; + av_opt_set_int(s, "server_attached", 1, AV_OPT_SEARCH_CHILDREN); + av_opt_set_int(s, "write_index", pos, AV_OPT_SEARCH_CHILDREN); + av_opt_set_int(s, "file_size", file_size, AV_OPT_SEARCH_CHILDREN); } static char *ctime1(char *buf2, size_t buf_size) @@ -2276,7 +2276,7 @@ static int http_prepare_data(HTTPContext *c) } else { int source_index = pkt.stream_index; /* update first pts if needed */ - if (c->first_pts == AV_NOPTS_VALUE) { + if (c->first_pts == AV_NOPTS_VALUE && pkt.dts != AV_NOPTS_VALUE) { c->first_pts = av_rescale_q(pkt.dts, c->fmt_in->streams[pkt.stream_index]->time_base, AV_TIME_BASE_Q); c->start_time = cur_time; } @@ -2315,8 +2315,10 @@ static int http_prepare_data(HTTPContext *c) * XXX: need more abstract handling */ if (c->is_packetized) { /* compute send time and duration */ - c->cur_pts = av_rescale_q(pkt.dts, ist->time_base, AV_TIME_BASE_Q); - c->cur_pts -= c->first_pts; + if (pkt.dts != AV_NOPTS_VALUE) { + c->cur_pts = av_rescale_q(pkt.dts, ist->time_base, AV_TIME_BASE_Q); + c->cur_pts -= c->first_pts; + } c->cur_frame_duration = av_rescale_q(pkt.duration, ist->time_base, AV_TIME_BASE_Q); /* find RTP context */ c->packet_stream_index = pkt.stream_index; @@ -2835,7 +2837,7 @@ static int rtsp_parse_request(HTTPContext *c) len = sizeof(line) - 1; memcpy(line, p, len); line[len] = '\0'; - ff_rtsp_parse_line(header, line, NULL, NULL); + ff_rtsp_parse_line(NULL, header, line, NULL, NULL); p = p1 + 1; } @@ -3329,6 +3331,7 @@ static int rtp_new_av_stream(HTTPContext *c, URLContext *h = NULL; uint8_t *dummy_buf; int max_packet_size; + void *st_internal; /* now we can open the relevant output stream */ ctx = avformat_alloc_context(); @@ -3336,14 +3339,13 @@ static int rtp_new_av_stream(HTTPContext *c, return -1; ctx->oformat = av_guess_format("rtp", NULL, NULL); - st = av_mallocz(sizeof(AVStream)); + st = avformat_new_stream(ctx, NULL); if (!st) goto fail; - ctx->nb_streams = 1; - ctx->streams = av_mallocz_array(ctx->nb_streams, sizeof(AVStream *)); - if (!ctx->streams) - goto fail; - ctx->streams[0] = st; + + av_freep(&st->codec); + av_freep(&st->info); + st_internal = st->internal; if (!c->stream->feed || c->stream->feed == c->stream) @@ -3353,6 +3355,7 @@ static int rtp_new_av_stream(HTTPContext *c, c->stream->feed->streams[c->stream->feed_streams[stream_index]], sizeof(AVStream)); st->priv_data = NULL; + st->internal = st_internal; /* build destination RTP address */ ipaddr = inet_ntoa(dest_addr->sin_addr);