Revision a493f80a libavformat/rtsp.c
libavformat/rtsp.c | ||
---|---|---|
39 | 39 |
#include "rtpdec.h" |
40 | 40 |
#include "rdt.h" |
41 | 41 |
#include "rtpdec_formats.h" |
42 |
#include "rtpenc_chain.h" |
|
42 | 43 |
|
43 | 44 |
//#define DEBUG |
44 | 45 |
//#define DEBUG_RTP_TCP |
... | ... | |
502 | 503 |
av_free(rt->recvbuf); |
503 | 504 |
} |
504 | 505 |
|
505 |
static AVFormatContext *rtsp_rtp_mux_open(AVFormatContext *s, AVStream *st, |
|
506 |
URLContext *handle, int packet_size) |
|
507 |
{ |
|
508 |
AVFormatContext *rtpctx; |
|
509 |
int ret; |
|
510 |
AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); |
|
511 |
|
|
512 |
if (!rtp_format) |
|
513 |
return NULL; |
|
514 |
|
|
515 |
/* Allocate an AVFormatContext for each output stream */ |
|
516 |
rtpctx = avformat_alloc_context(); |
|
517 |
if (!rtpctx) |
|
518 |
return NULL; |
|
519 |
|
|
520 |
rtpctx->oformat = rtp_format; |
|
521 |
if (!av_new_stream(rtpctx, 0)) { |
|
522 |
av_free(rtpctx); |
|
523 |
return NULL; |
|
524 |
} |
|
525 |
/* Copy the max delay setting; the rtp muxer reads this. */ |
|
526 |
rtpctx->max_delay = s->max_delay; |
|
527 |
/* Copy other stream parameters. */ |
|
528 |
rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio; |
|
529 |
|
|
530 |
/* Set the synchronized start time. */ |
|
531 |
rtpctx->start_time_realtime = s->start_time_realtime; |
|
532 |
|
|
533 |
/* Remove the local codec, link to the original codec |
|
534 |
* context instead, to give the rtp muxer access to |
|
535 |
* codec parameters. */ |
|
536 |
av_free(rtpctx->streams[0]->codec); |
|
537 |
rtpctx->streams[0]->codec = st->codec; |
|
538 |
|
|
539 |
if (handle) { |
|
540 |
url_fdopen(&rtpctx->pb, handle); |
|
541 |
} else |
|
542 |
url_open_dyn_packet_buf(&rtpctx->pb, packet_size); |
|
543 |
ret = av_write_header(rtpctx); |
|
544 |
|
|
545 |
if (ret) { |
|
546 |
if (handle) { |
|
547 |
url_fclose(rtpctx->pb); |
|
548 |
} else { |
|
549 |
uint8_t *ptr; |
|
550 |
url_close_dyn_buf(rtpctx->pb, &ptr); |
|
551 |
av_free(ptr); |
|
552 |
} |
|
553 |
av_free(rtpctx->streams[0]); |
|
554 |
av_free(rtpctx); |
|
555 |
return NULL; |
|
556 |
} |
|
557 |
|
|
558 |
/* Copy the RTP AVStream timebase back to the original AVStream */ |
|
559 |
st->time_base = rtpctx->streams[0]->time_base; |
|
560 |
return rtpctx; |
|
561 |
} |
|
562 |
|
|
563 | 506 |
static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st) |
564 | 507 |
{ |
565 | 508 |
RTSPState *rt = s->priv_data; |
... | ... | |
572 | 515 |
s->ctx_flags |= AVFMTCTX_NOHEADER; |
573 | 516 |
|
574 | 517 |
if (s->oformat) { |
575 |
rtsp_st->transport_priv = rtsp_rtp_mux_open(s, st, rtsp_st->rtp_handle, |
|
576 |
RTSP_TCP_MAX_PACKET_SIZE); |
|
518 |
rtsp_st->transport_priv = ff_rtp_chain_mux_open(s, st, |
|
519 |
rtsp_st->rtp_handle, |
|
520 |
RTSP_TCP_MAX_PACKET_SIZE); |
|
577 | 521 |
/* Ownership of rtp_handle is passed to the rtp mux context */ |
578 | 522 |
rtsp_st->rtp_handle = NULL; |
579 | 523 |
} else if (rt->transport == RTSP_TRANSPORT_RDT) |
Also available in: Unified diff