-/* currently desactivated because the new PTS handling is not
- satisfactory yet */
-//#define AV_READ_FRAME
-#ifdef AV_READ_FRAME
-
-/* XXX: generalize that in ffmpeg for picture/audio/data. Currently
- the return packet MUST NOT be freed */
-int av_read_frame(AVFormatContext *s, AVPacket *pkt)
-{
- AVStream *st;
- int len, ret, old_nb_streams, i;
-
- /* see if remaining frames must be parsed */
- for(;;) {
- if (s->cur_len > 0) {
- st = s->streams[s->cur_pkt.stream_index];
- len = avcodec_parse_frame(&st->codec, &pkt->data, &pkt->size,
- s->cur_ptr, s->cur_len);
- if (len < 0) {
- /* error: get next packet */
- s->cur_len = 0;
- } else {
- s->cur_ptr += len;
- s->cur_len -= len;
- if (pkt->size) {
- /* init pts counter if not done */
- if (st->pts.den == 0) {
- switch(st->codec.codec_type) {
- case CODEC_TYPE_AUDIO:
- st->pts_incr = (int64_t)s->pts_den;
- av_frac_init(&st->pts, st->pts.val, 0,
- (int64_t)s->pts_num * st->codec.sample_rate);
- break;
- case CODEC_TYPE_VIDEO:
- st->pts_incr = (int64_t)s->pts_den * FRAME_RATE_BASE;
- av_frac_init(&st->pts, st->pts.val, 0,
- (int64_t)s->pts_num * st->codec.frame_rate);
- break;
- default:
- av_abort();
- }
- }
-
- /* a frame was read: return it */
- pkt->pts = st->pts.val;
-#if 0
- printf("add pts=%Lx num=%Lx den=%Lx incr=%Lx\n",
- st->pts.val, st->pts.num, st->pts.den, st->pts_incr);
-#endif
- switch(st->codec.codec_type) {
- case CODEC_TYPE_AUDIO:
- av_frac_add(&st->pts, st->pts_incr * st->codec.frame_size);
- break;
- case CODEC_TYPE_VIDEO:
- av_frac_add(&st->pts, st->pts_incr);
- break;
- default:
- av_abort();
- }
- pkt->stream_index = s->cur_pkt.stream_index;
- /* we use the codec indication because it is
- more accurate than the demux flags */
- pkt->flags = 0;
- if (st->codec.coded_frame->key_frame)
- pkt->flags |= PKT_FLAG_KEY;
- return 0;
- }
- }
- } else {
- /* free previous packet */
- av_free_packet(&s->cur_pkt);
-
- old_nb_streams = s->nb_streams;
- ret = av_read_packet(s, &s->cur_pkt);
- if (ret)
- return ret;
- /* open parsers for each new streams */
- for(i = old_nb_streams; i < s->nb_streams; i++)
- open_parser(s, i);
- st = s->streams[s->cur_pkt.stream_index];
-
- /* update current pts (XXX: dts handling) from packet, or
- use current pts if none given */
- if (s->cur_pkt.pts != AV_NOPTS_VALUE) {
- av_frac_set(&st->pts, s->cur_pkt.pts);
- } else {
- s->cur_pkt.pts = st->pts.val;
- }
- if (!st->codec.codec) {
- /* no codec opened: just return the raw packet */
- *pkt = s->cur_pkt;
-
- /* no codec opened: just update the pts by considering we
- have one frame and free the packet */
- if (st->pts.den == 0) {
- switch(st->codec.codec_type) {
- case CODEC_TYPE_AUDIO:
- st->pts_incr = (int64_t)s->pts_den * st->codec.frame_size;
- av_frac_init(&st->pts, st->pts.val, 0,
- (int64_t)s->pts_num * st->codec.sample_rate);
- break;
- case CODEC_TYPE_VIDEO:
- st->pts_incr = (int64_t)s->pts_den * FRAME_RATE_BASE;
- av_frac_init(&st->pts, st->pts.val, 0,
- (int64_t)s->pts_num * st->codec.frame_rate);
- break;
- default:
- av_abort();
- }
- }
- av_frac_add(&st->pts, st->pts_incr);
- return 0;
- } else {
- s->cur_ptr = s->cur_pkt.data;
- s->cur_len = s->cur_pkt.size;
- }
- }
- }
-}
-
-static int compute_send_delay(HTTPContext *c)