- /* find RTP context */
- c->packet_stream_index = pkt.stream_index;
- ctx = c->rtp_ctx[c->packet_stream_index];
- if(!ctx) {
- av_free_packet(&pkt);
- break;
- }
- codec = ctx->streams[0]->codec;
- /* only one stream per RTP connection */
- pkt.stream_index = 0;
- } else {
- ctx = &c->fmt_ctx;
- /* Fudge here */
- codec = ctx->streams[pkt.stream_index]->codec;
- }
-
- codec->coded_frame->key_frame = ((pkt.flags & PKT_FLAG_KEY) != 0);
- if (c->is_packetized) {
- int max_packet_size;
- if (c->rtp_protocol == RTSP_PROTOCOL_RTP_TCP)
- max_packet_size = RTSP_TCP_MAX_PACKET_SIZE;
- else
- max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]);
- ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size);
- } else {
- ret = url_open_dyn_buf(&ctx->pb);
- }
- if (ret < 0) {
- /* XXX: potential leak */
- return -1;
- }
- if (pkt.dts != AV_NOPTS_VALUE)
- pkt.dts = av_rescale_q(pkt.dts,
- c->fmt_in->streams[pkt.stream_index]->time_base,
- ctx->streams[pkt.stream_index]->time_base);
- if (pkt.pts != AV_NOPTS_VALUE)
- pkt.pts = av_rescale_q(pkt.pts,
- c->fmt_in->streams[pkt.stream_index]->time_base,
- ctx->streams[pkt.stream_index]->time_base);
- if (av_write_frame(ctx, &pkt))
- c->state = HTTPSTATE_SEND_DATA_TRAILER;
-
- len = url_close_dyn_buf(ctx->pb, &c->pb_buffer);
- c->cur_frame_bytes = len;
- c->buffer_ptr = c->pb_buffer;
- c->buffer_end = c->pb_buffer + len;
-
- codec->frame_number++;
- if (len == 0) {