Revision abbc1d27

View differences:

libavformat/rtsp.c
474 474
}
475 475
#endif /* CONFIG_RTPDEC */
476 476

  
477
void ff_rtsp_undo_setup(AVFormatContext *s)
478
{
479
    RTSPState *rt = s->priv_data;
480
    int i;
481

  
482
    for (i = 0; i < rt->nb_rtsp_streams; i++) {
483
        RTSPStream *rtsp_st = rt->rtsp_streams[i];
484
        if (!rtsp_st)
485
            continue;
486
        if (rtsp_st->transport_priv) {
487
            if (s->oformat) {
488
                AVFormatContext *rtpctx = rtsp_st->transport_priv;
489
                av_write_trailer(rtpctx);
490
                if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
491
                    uint8_t *ptr;
492
                    url_close_dyn_buf(rtpctx->pb, &ptr);
493
                    av_free(ptr);
494
                } else {
495
                    url_fclose(rtpctx->pb);
496
                }
497
                av_metadata_free(&rtpctx->streams[0]->metadata);
498
                av_metadata_free(&rtpctx->metadata);
499
                av_free(rtpctx->streams[0]);
500
                av_free(rtpctx);
501
            } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
502
                ff_rdt_parse_close(rtsp_st->transport_priv);
503
            else if (CONFIG_RTPDEC)
504
                rtp_parse_close(rtsp_st->transport_priv);
505
        }
506
        rtsp_st->transport_priv = NULL;
507
        if (rtsp_st->rtp_handle)
508
            url_close(rtsp_st->rtp_handle);
509
        rtsp_st->rtp_handle = NULL;
510
    }
511
}
512

  
477 513
/* close and free RTSP streams */
478 514
void ff_rtsp_close_streams(AVFormatContext *s)
479 515
{
......
481 517
    int i;
482 518
    RTSPStream *rtsp_st;
483 519

  
520
    ff_rtsp_undo_setup(s);
484 521
    for (i = 0; i < rt->nb_rtsp_streams; i++) {
485 522
        rtsp_st = rt->rtsp_streams[i];
486 523
        if (rtsp_st) {
487
            if (rtsp_st->transport_priv) {
488
                if (s->oformat) {
489
                    AVFormatContext *rtpctx = rtsp_st->transport_priv;
490
                    av_write_trailer(rtpctx);
491
                    if (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP) {
492
                        uint8_t *ptr;
493
                        url_close_dyn_buf(rtpctx->pb, &ptr);
494
                        av_free(ptr);
495
                    } else {
496
                        url_fclose(rtpctx->pb);
497
                    }
498
                    av_metadata_free(&rtpctx->streams[0]->metadata);
499
                    av_metadata_free(&rtpctx->metadata);
500
                    av_free(rtpctx->streams[0]);
501
                    av_free(rtpctx);
502
                } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC)
503
                    ff_rdt_parse_close(rtsp_st->transport_priv);
504
                else if (CONFIG_RTPDEC)
505
                    rtp_parse_close(rtsp_st->transport_priv);
506
            }
507
            if (rtsp_st->rtp_handle)
508
                url_close(rtsp_st->rtp_handle);
509 524
            if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
510 525
                rtsp_st->dynamic_handler->close(
511 526
                    rtsp_st->dynamic_protocol_context);
libavformat/rtsp.h
511 511
int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
512 512
                               int lower_transport, const char *real_challenge);
513 513

  
514
/**
515
 * Undo the effect of ff_rtsp_make_setup_request, close the
516
 * transport_priv and rtp_handle fields.
517
 */
518
void ff_rtsp_undo_setup(AVFormatContext *s);
519

  
514 520
#endif /* AVFORMAT_RTSP_H */

Also available in: Unified diff