Revision 5465b0d4

View differences:

libavformat/rtsp.c
73 73
    enum RTSPLowerTransport lower_transport;
74 74
    enum RTSPServerType server_type;
75 75
    char last_reply[2048]; /* XXX: allocate ? */
76
    RTPDemuxContext *cur_rtp;
76
    void *cur_tx;
77 77
    int need_subscription;
78 78
} RTSPState;
79 79

  
80 80
typedef struct RTSPStream {
81 81
    URLContext *rtp_handle; /* RTP stream handle */
82
    RTPDemuxContext *rtp_ctx; /* RTP parse context */
82
    void *tx_ctx; /* RTP/RDT parse context */
83 83

  
84 84
    int stream_index; /* corresponding stream index, if any. -1 if none (MPEG2TS case) */
85 85
    int interleaved_min, interleaved_max;  /* interleave ids, if TCP transport */
......
873 873
    for(i=0;i<rt->nb_rtsp_streams;i++) {
874 874
        rtsp_st = rt->rtsp_streams[i];
875 875
        if (rtsp_st) {
876
            if (rtsp_st->rtp_ctx)
877
                rtp_parse_close(rtsp_st->rtp_ctx);
876
            if (rtsp_st->tx_ctx)
877
                rtp_parse_close(rtsp_st->tx_ctx);
878 878
            if (rtsp_st->rtp_handle)
879 879
                url_close(rtsp_st->rtp_handle);
880 880
            if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
......
894 894
        st = s->streams[rtsp_st->stream_index];
895 895
    if (!st)
896 896
        s->ctx_flags |= AVFMTCTX_NOHEADER;
897
    rtsp_st->rtp_ctx = rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, &rtsp_st->rtp_payload_data);
897
    rtsp_st->tx_ctx = rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, &rtsp_st->rtp_payload_data);
898 898

  
899
    if (!rtsp_st->rtp_ctx) {
899
    if (!rtsp_st->tx_ctx) {
900 900
         return AVERROR(ENOMEM);
901 901
    } else {
902 902
        if(rtsp_st->dynamic_handler) {
903
            rtp_parse_set_dynamic_protocol(rtsp_st->rtp_ctx,
903
            rtp_parse_set_dynamic_protocol(rtsp_st->tx_ctx,
904 904
                                           rtsp_st->dynamic_protocol_context,
905 905
                                           rtsp_st->dynamic_handler);
906 906
        }
......
1347 1347
            ff_rdt_subscribe_rule(cmd, sizeof(cmd), i, 0);
1348 1348
            if (rt->transport == RTSP_TRANSPORT_RDT)
1349 1349
                ff_rdt_subscribe_rule2(
1350
                    rt->rtsp_streams[i]->rtp_ctx,
1350
                    rt->rtsp_streams[i]->tx_ctx,
1351 1351
                    cmd, sizeof(cmd), i, 0);
1352 1352
        }
1353 1353
        av_strlcat(cmd, "\r\n", sizeof(cmd));
......
1361 1361
    }
1362 1362

  
1363 1363
    /* get next frames from the same RTP packet */
1364
    if (rt->cur_rtp) {
1364
    if (rt->cur_tx) {
1365 1365
        if (rt->transport == RTSP_TRANSPORT_RDT)
1366
            ret = ff_rdt_parse_packet(rt->cur_rtp, pkt, NULL, 0);
1366
            ret = ff_rdt_parse_packet(rt->cur_tx, pkt, NULL, 0);
1367 1367
        else
1368
            ret = rtp_parse_packet(rt->cur_rtp, pkt, NULL, 0);
1368
            ret = rtp_parse_packet(rt->cur_tx, pkt, NULL, 0);
1369 1369
        if (ret == 0) {
1370
            rt->cur_rtp = NULL;
1370
            rt->cur_tx = NULL;
1371 1371
            return 0;
1372 1372
        } else if (ret == 1) {
1373 1373
            return 0;
1374 1374
        } else {
1375
            rt->cur_rtp = NULL;
1375
            rt->cur_tx = NULL;
1376 1376
        }
1377 1377
    }
1378 1378

  
......
1386 1386
    case RTSP_LOWER_TRANSPORT_UDP:
1387 1387
    case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
1388 1388
        len = udp_read_packet(s, &rtsp_st, buf, sizeof(buf));
1389
        if (len >=0 && rtsp_st->rtp_ctx)
1390
            rtp_check_and_send_back_rr(rtsp_st->rtp_ctx, len);
1389
        if (len >=0 && rtsp_st->tx_ctx)
1390
            rtp_check_and_send_back_rr(rtsp_st->tx_ctx, len);
1391 1391
        break;
1392 1392
    }
1393 1393
    if (len < 0)
1394 1394
        return len;
1395 1395
    if (rt->transport == RTSP_TRANSPORT_RDT)
1396
        ret = ff_rdt_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len);
1396
        ret = ff_rdt_parse_packet(rtsp_st->tx_ctx, pkt, buf, len);
1397 1397
    else
1398
        ret = rtp_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len);
1398
        ret = rtp_parse_packet(rtsp_st->tx_ctx, pkt, buf, len);
1399 1399
    if (ret < 0)
1400 1400
        goto redo;
1401 1401
    if (ret == 1) {
1402 1402
        /* more packets may follow, so we save the RTP context */
1403
        rt->cur_rtp = rtsp_st->rtp_ctx;
1403
        rt->cur_tx = rtsp_st->tx_ctx;
1404 1404
    }
1405 1405
    return 0;
1406 1406
}

Also available in: Unified diff