Revision 29db7c3a

View differences:

libavformat/rtsp.c
684 684
    }
685 685
}
686 686

  
687
static void handle_rtp_info(RTSPState *rt, const char *url,
688
                            uint32_t seq, uint32_t rtptime)
689
{
690
    int i;
691
    if (!rtptime || !url[0])
692
        return;
693
    if (rt->transport != RTSP_TRANSPORT_RTP)
694
        return;
695
    for (i = 0; i < rt->nb_rtsp_streams; i++) {
696
        RTSPStream *rtsp_st = rt->rtsp_streams[i];
697
        RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
698
        if (!rtpctx)
699
            continue;
700
        if (!strcmp(rtsp_st->control_url, url)) {
701
            rtpctx->base_timestamp = rtptime;
702
            break;
703
        }
704
    }
705
}
706

  
707
static void rtsp_parse_rtp_info(RTSPState *rt, const char *p)
708
{
709
    int read = 0;
710
    char key[20], value[1024], url[1024] = "";
711
    uint32_t seq = 0, rtptime = 0;
712

  
713
    for (;;) {
714
        p += strspn(p, SPACE_CHARS);
715
        if (!*p)
716
            break;
717
        get_word_sep(key, sizeof(key), "=", &p);
718
        if (*p != '=')
719
            break;
720
        p++;
721
        get_word_sep(value, sizeof(value), ";, ", &p);
722
        read++;
723
        if (!strcmp(key, "url"))
724
            av_strlcpy(url, value, sizeof(url));
725
        else if (!strcmp(key, "seq"))
726
            seq = strtol(value, NULL, 10);
727
        else if (!strcmp(key, "rtptime"))
728
            rtptime = strtol(value, NULL, 10);
729
        if (*p == ',') {
730
            handle_rtp_info(rt, url, seq, rtptime);
731
            url[0] = '\0';
732
            seq = rtptime = 0;
733
            read = 0;
734
        }
735
        if (*p)
736
            p++;
737
    }
738
    if (read > 0)
739
        handle_rtp_info(rt, url, seq, rtptime);
740
}
741

  
687 742
void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf,
688 743
                        RTSPState *rt, const char *method)
689 744
{
......
728 783
        p += strspn(p, SPACE_CHARS);
729 784
        if (method && !strcmp(method, "DESCRIBE"))
730 785
            av_strlcpy(rt->control_uri, p , sizeof(rt->control_uri));
786
    } else if (av_stristart(p, "RTP-Info:", &p) && rt) {
787
        p += strspn(p, SPACE_CHARS);
788
        if (method && !strcmp(method, "PLAY"))
789
            rtsp_parse_rtp_info(rt, p);
731 790
    }
732 791
}
733 792

  

Also available in: Unified diff