Revision e9dea59f libavformat/rtsp.c

View differences:

libavformat/rtsp.c
32 32
#include "rtsp.h"
33 33

  
34 34
#include "rtp_internal.h"
35
#include "rdt.h"
35 36

  
36 37
//#define DEBUG
37 38
//#define DEBUG_RTP_TCP
......
870 871
 * @returns 0 on success, <0 on error, 1 if protocol is unavailable.
871 872
 */
872 873
static int
873
make_setup_request (AVFormatContext *s, const char *host, int port, int protocol)
874
make_setup_request (AVFormatContext *s, const char *host, int port,
875
                    int protocol, const char *real_challenge)
874 876
{
875 877
    RTSPState *rt = s->priv_data;
876 878
    int j, i, err;
......
878 880
    AVStream *st;
879 881
    RTSPHeader reply1, *reply = &reply1;
880 882
    char cmd[2048];
883
    const char *trans_pref;
884

  
885
    if (rt->server_type == RTSP_SERVER_RDT)
886
        trans_pref = "x-pn-tng";
887
    else
888
        trans_pref = "RTP/AVP";
881 889

  
882 890
    /* for each stream, make the setup request */
883 891
    /* XXX: we assume the same server is used for the control of each
......
918 926
            if (transport[0] != '\0')
919 927
                av_strlcat(transport, ",", sizeof(transport));
920 928
            snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1,
921
                     "RTP/AVP/UDP;unicast;client_port=%d-%d",
922
                     port, port + 1);
929
                     "%s/UDP;unicast;client_port=%d",
930
                     trans_pref, port);
931
            if (rt->server_type == RTSP_SERVER_RTP)
932
                av_strlcatf(transport, sizeof(transport), "-%d", port + 1);
923 933
        }
924 934

  
925 935
        /* RTP/TCP */
......
927 937
            if (transport[0] != '\0')
928 938
                av_strlcat(transport, ",", sizeof(transport));
929 939
            snprintf(transport + strlen(transport), sizeof(transport) - strlen(transport) - 1,
930
                     "RTP/AVP/TCP");
940
                     "%s/TCP", trans_pref);
931 941
        }
932 942

  
933 943
        else if (protocol == RTSP_PROTOCOL_RTP_UDP_MULTICAST) {
......
935 945
                av_strlcat(transport, ",", sizeof(transport));
936 946
            snprintf(transport + strlen(transport),
937 947
                     sizeof(transport) - strlen(transport) - 1,
938
                     "RTP/AVP/UDP;multicast");
948
                     "%s/UDP;multicast", trans_pref);
939 949
        }
950
        if (rt->server_type == RTSP_SERVER_RDT)
951
            av_strlcat(transport, ";mode=play", sizeof(transport));
940 952
        snprintf(cmd, sizeof(cmd),
941 953
                 "SETUP %s RTSP/1.0\r\n"
942 954
                 "Transport: %s\r\n",
943 955
                 rtsp_st->control_url, transport);
956
        if (i == 0 && rt->server_type == RTSP_SERVER_RDT) {
957
            char real_res[41], real_csum[9];
958
            ff_rdt_calc_response_and_checksum(real_res, real_csum,
959
                                              real_challenge);
960
            av_strlcatf(cmd, sizeof(cmd),
961
                        "If-Match: %s\r\n"
962
                        "RealChallenge2: %s, sd=%s\r\n",
963
                        rt->session_id, real_res, real_csum);
964
        }
944 965
        rtsp_send_cmd(s, cmd, reply, NULL);
945 966
        if (reply->status_code == 461 /* Unsupported protocol */ && i == 0) {
946 967
            err = 1;
......
1155 1176
    do {
1156 1177
        int protocol = ff_log2_tab[protocol_mask & ~(protocol_mask - 1)];
1157 1178

  
1158
        err = make_setup_request(s, host, port, protocol);
1179
        err = make_setup_request(s, host, port, protocol,
1180
                                 rt->server_type == RTSP_SERVER_RDT ?
1181
                                     real_challenge : NULL);
1159 1182
        if (err < 0)
1160 1183
            goto fail;
1161 1184
        protocol_mask &= ~(1 << protocol);

Also available in: Unified diff