~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-updates

« back to all changes in this revision

Viewing changes to libavformat/rtsp.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-03-13 09:18:28 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090313091828-n4ktby5eca487uhv
Tags: 3:0.svn20090303-1ubuntu1+unstripped1
merge from ubuntu.jaunty branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "network.h"
35
35
#include "rtsp.h"
36
36
 
37
 
#include "rtp.h"
 
37
#include "rtpdec.h"
38
38
#include "rdt.h"
39
39
 
40
40
//#define DEBUG
425
425
            st->codec->codec_type = codec_type;
426
426
            if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
427
427
                /* if standard payload type, we can find the codec right now */
428
 
                rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type);
 
428
                ff_rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type);
429
429
            }
430
430
        }
431
431
        /* put a default control url */
570
570
}
571
571
 
572
572
/* XXX: only one transport specification is parsed */
573
 
static void rtsp_parse_transport(RTSPHeader *reply, const char *p)
 
573
static void rtsp_parse_transport(RTSPMessageHeader *reply, const char *p)
574
574
{
575
575
    char transport_protocol[16];
576
576
    char profile[16];
672
672
    }
673
673
}
674
674
 
675
 
void rtsp_parse_line(RTSPHeader *reply, const char *buf)
 
675
void rtsp_parse_line(RTSPMessageHeader *reply, const char *buf)
676
676
{
677
677
    const char *p;
678
678
 
738
738
}
739
739
 
740
740
static void rtsp_send_cmd(AVFormatContext *s,
741
 
                          const char *cmd, RTSPHeader *reply,
 
741
                          const char *cmd, RTSPMessageHeader *reply,
742
742
                          unsigned char **content_ptr)
743
743
{
744
744
    RTSPState *rt = s->priv_data;
748
748
    int content_length, line_count;
749
749
    unsigned char *content = NULL;
750
750
 
751
 
    memset(reply, 0, sizeof(RTSPHeader));
 
751
    memset(reply, 0, sizeof(*reply));
752
752
 
753
753
    rt->seq++;
754
754
    av_strlcpy(buf, cmd, sizeof(buf));
829
829
    for(i=0;i<rt->nb_rtsp_streams;i++) {
830
830
        rtsp_st = rt->rtsp_streams[i];
831
831
        if (rtsp_st) {
832
 
            if (rtsp_st->tx_ctx) {
 
832
            if (rtsp_st->transport_priv) {
833
833
                if (rt->transport == RTSP_TRANSPORT_RDT)
834
 
                    ff_rdt_parse_close(rtsp_st->tx_ctx);
 
834
                    ff_rdt_parse_close(rtsp_st->transport_priv);
835
835
                else
836
 
                    rtp_parse_close(rtsp_st->tx_ctx);
 
836
                    rtp_parse_close(rtsp_st->transport_priv);
837
837
            }
838
838
            if (rtsp_st->rtp_handle)
839
839
                url_close(rtsp_st->rtp_handle);
857
857
        s->ctx_flags |= AVFMTCTX_NOHEADER;
858
858
 
859
859
    if (rt->transport == RTSP_TRANSPORT_RDT)
860
 
        rtsp_st->tx_ctx = ff_rdt_parse_open(s, st->index,
 
860
        rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
861
861
                                            rtsp_st->dynamic_protocol_context,
862
862
                                            rtsp_st->dynamic_handler);
863
863
    else
864
 
        rtsp_st->tx_ctx = rtp_parse_open(s, st, rtsp_st->rtp_handle,
 
864
        rtsp_st->transport_priv = rtp_parse_open(s, st, rtsp_st->rtp_handle,
865
865
                                         rtsp_st->sdp_payload_type,
866
866
                                         &rtsp_st->rtp_payload_data);
867
867
 
868
 
    if (!rtsp_st->tx_ctx) {
 
868
    if (!rtsp_st->transport_priv) {
869
869
         return AVERROR(ENOMEM);
870
870
    } else if (rt->transport != RTSP_TRANSPORT_RDT) {
871
871
        if(rtsp_st->dynamic_handler) {
872
 
            rtp_parse_set_dynamic_protocol(rtsp_st->tx_ctx,
 
872
            rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv,
873
873
                                           rtsp_st->dynamic_protocol_context,
874
874
                                           rtsp_st->dynamic_handler);
875
875
        }
888
888
    RTSPState *rt = s->priv_data;
889
889
    int j, i, err, interleave = 0;
890
890
    RTSPStream *rtsp_st;
891
 
    RTSPHeader reply1, *reply = &reply1;
 
891
    RTSPMessageHeader reply1, *reply = &reply1;
892
892
    char cmd[2048];
893
893
    const char *trans_pref;
894
894
 
1064
1064
    char host[1024], path[1024], tcpname[1024], cmd[2048], *option_list, *option;
1065
1065
    URLContext *rtsp_hd;
1066
1066
    int port, ret, err;
1067
 
    RTSPHeader reply1, *reply = &reply1;
 
1067
    RTSPMessageHeader reply1, *reply = &reply1;
1068
1068
    unsigned char *content = NULL;
1069
1069
    int lower_transport_mask = 0;
1070
1070
    char real_challenge[64];
1097
1097
    }
1098
1098
 
1099
1099
    if (!lower_transport_mask)
1100
 
        lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_LAST) - 1;
 
1100
        lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1;
1101
1101
 
1102
1102
    /* open the tcp connexion */
1103
1103
    snprintf(tcpname, sizeof(tcpname), "tcp://%s:%d", host, port);
1313
1313
 
1314
1314
    if (rt->server_type == RTSP_SERVER_REAL) {
1315
1315
        int i;
1316
 
        RTSPHeader reply1, *reply = &reply1;
 
1316
        RTSPMessageHeader reply1, *reply = &reply1;
1317
1317
        enum AVDiscard cache[MAX_STREAMS];
1318
1318
        char cmd[1024];
1319
1319
 
1374
1374
    }
1375
1375
 
1376
1376
    /* get next frames from the same RTP packet */
1377
 
    if (rt->cur_tx) {
 
1377
    if (rt->cur_transport_priv) {
1378
1378
        if (rt->transport == RTSP_TRANSPORT_RDT)
1379
 
            ret = ff_rdt_parse_packet(rt->cur_tx, pkt, NULL, 0);
 
1379
            ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);
1380
1380
        else
1381
 
            ret = rtp_parse_packet(rt->cur_tx, pkt, NULL, 0);
 
1381
            ret = rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0);
1382
1382
        if (ret == 0) {
1383
 
            rt->cur_tx = NULL;
 
1383
            rt->cur_transport_priv = NULL;
1384
1384
            return 0;
1385
1385
        } else if (ret == 1) {
1386
1386
            return 0;
1387
1387
        } else {
1388
 
            rt->cur_tx = NULL;
 
1388
            rt->cur_transport_priv = NULL;
1389
1389
        }
1390
1390
    }
1391
1391
 
1399
1399
    case RTSP_LOWER_TRANSPORT_UDP:
1400
1400
    case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
1401
1401
        len = udp_read_packet(s, &rtsp_st, buf, sizeof(buf));
1402
 
        if (len >=0 && rtsp_st->tx_ctx && rt->transport == RTSP_TRANSPORT_RTP)
1403
 
            rtp_check_and_send_back_rr(rtsp_st->tx_ctx, len);
 
1402
        if (len >=0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
 
1403
            rtp_check_and_send_back_rr(rtsp_st->transport_priv, len);
1404
1404
        break;
1405
1405
    }
1406
1406
    if (len < 0)
1407
1407
        return len;
1408
1408
    if (rt->transport == RTSP_TRANSPORT_RDT)
1409
 
        ret = ff_rdt_parse_packet(rtsp_st->tx_ctx, pkt, buf, len);
 
1409
        ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, buf, len);
1410
1410
    else
1411
 
        ret = rtp_parse_packet(rtsp_st->tx_ctx, pkt, buf, len);
 
1411
        ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, buf, len);
1412
1412
    if (ret < 0)
1413
1413
        goto redo;
1414
1414
    if (ret == 1) {
1415
1415
        /* more packets may follow, so we save the RTP context */
1416
 
        rt->cur_tx = rtsp_st->tx_ctx;
 
1416
        rt->cur_transport_priv = rtsp_st->transport_priv;
1417
1417
    }
1418
1418
    return 0;
1419
1419
}
1421
1421
static int rtsp_read_play(AVFormatContext *s)
1422
1422
{
1423
1423
    RTSPState *rt = s->priv_data;
1424
 
    RTSPHeader reply1, *reply = &reply1;
 
1424
    RTSPMessageHeader reply1, *reply = &reply1;
1425
1425
    char cmd[1024];
1426
1426
 
1427
1427
    av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state);
1451
1451
static int rtsp_read_pause(AVFormatContext *s)
1452
1452
{
1453
1453
    RTSPState *rt = s->priv_data;
1454
 
    RTSPHeader reply1, *reply = &reply1;
 
1454
    RTSPMessageHeader reply1, *reply = &reply1;
1455
1455
    char cmd[1024];
1456
1456
 
1457
1457
    rt = s->priv_data;
1495
1495
static int rtsp_read_close(AVFormatContext *s)
1496
1496
{
1497
1497
    RTSPState *rt = s->priv_data;
1498
 
    RTSPHeader reply1, *reply = &reply1;
 
1498
    RTSPMessageHeader reply1, *reply = &reply1;
1499
1499
    char cmd[1024];
1500
1500
 
1501
1501
#if 0