Revision af74c95a

View differences:

libavformat/rtp.c
737 737
// following 2 FIXMies could be set based on the current time, theres normaly no info leak, as rtp will likely be transmitted immedeatly
738 738
    s->base_timestamp = 0; /* FIXME: was random(), what should this be? */
739 739
    s->timestamp = s->base_timestamp;
740
    s->cur_timestamp = 0;
740 741
    s->ssrc = 0; /* FIXME: was random(), what should this be? */
741 742
    s->first_packet = 1;
742 743
    s->first_rtcp_ntp_time = AV_NOPTS_VALUE;
......
746 747
        return AVERROR(EIO);
747 748
    s->max_payload_size = max_packet_size - 12;
748 749

  
750
    av_set_pts_info(st, 32, 1, 90000);
749 751
    switch(st->codec->codec_id) {
750 752
    case CODEC_ID_MP2:
751 753
    case CODEC_ID_MP3:
752 754
        s->buf_ptr = s->buf + 4;
753
        s->cur_timestamp = 0;
754 755
        break;
755 756
    case CODEC_ID_MPEG1VIDEO:
756
        s->cur_timestamp = 0;
757 757
        break;
758 758
    case CODEC_ID_MPEG2TS:
759 759
        n = s->max_payload_size / TS_PACKET_SIZE;
......
835 835
    /* not needed, but who nows */
836 836
    if ((size % sample_size) != 0)
837 837
        av_abort();
838
    n = 0;
838 839
    while (size > 0) {
839
        len = (max_packet_size - (s->buf_ptr - s->buf));
840
        if (len > size)
841
            len = size;
840
        s->buf_ptr = s->buf;
841
        len = FFMIN(max_packet_size, size);
842 842

  
843 843
        /* copy data */
844 844
        memcpy(s->buf_ptr, buf1, len);
845 845
        s->buf_ptr += len;
846 846
        buf1 += len;
847 847
        size -= len;
848
        n = (s->buf_ptr - s->buf);
849
        /* if buffer full, then send it */
850
        if (n >= max_packet_size) {
851
            ff_rtp_send_data(s1, s->buf, n, 0);
852
            s->buf_ptr = s->buf;
853
            /* update timestamp */
854
            s->timestamp += n / sample_size;
855
        }
848
        s->timestamp = s->cur_timestamp + n / sample_size;
849
        ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
850
        n += (s->buf_ptr - s->buf);
856 851
    }
857 852
}
858 853

  
......
862 857
                               const uint8_t *buf1, int size)
863 858
{
864 859
    RTPDemuxContext *s = s1->priv_data;
865
    AVStream *st = s1->streams[0];
866 860
    int len, count, max_packet_size;
867 861

  
868 862
    max_packet_size = s->max_payload_size;
......
873 867
        if (len > 4) {
874 868
            ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0);
875 869
            s->buf_ptr = s->buf + 4;
876
            /* 90 KHz time stamp */
877
            s->timestamp = s->base_timestamp +
878
                (s->cur_timestamp * 90000LL) / st->codec->sample_rate;
879 870
        }
880 871
    }
872
    if (s->buf_ptr == s->buf + 4) {
873
        s->timestamp = s->cur_timestamp;
874
    }
881 875

  
882 876
    /* add the packet */
883 877
    if (size > max_packet_size) {
......
909 903
        memcpy(s->buf_ptr, buf1, size);
910 904
        s->buf_ptr += size;
911 905
    }
912
    s->cur_timestamp += st->codec->frame_size;
913 906
}
914 907

  
915 908
static void rtp_send_raw(AVFormatContext *s1,
916 909
                         const uint8_t *buf1, int size)
917 910
{
918 911
    RTPDemuxContext *s = s1->priv_data;
919
    AVStream *st = s1->streams[0];
920 912
    int len, max_packet_size;
921 913

  
922 914
    max_packet_size = s->max_payload_size;
......
926 918
        if (len > size)
927 919
            len = size;
928 920

  
929
        /* 90 KHz time stamp */
930
        s->timestamp = s->base_timestamp +
931
            av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps
921
        s->timestamp = s->cur_timestamp;
932 922
        ff_rtp_send_data(s1, buf1, len, (len == size));
933 923

  
934 924
        buf1 += len;
935 925
        size -= len;
936 926
    }
937
    s->cur_timestamp++;
938 927
}
939 928

  
940 929
/* NOTE: size is assumed to be an integer multiple of TS_PACKET_SIZE */
......
982 971
        s->last_octet_count = s->octet_count;
983 972
        s->first_packet = 0;
984 973
    }
974
    s->cur_timestamp = s->base_timestamp + pkt->pts;
985 975

  
986 976
    switch(st->codec->codec_id) {
987 977
    case CODEC_ID_PCM_MULAW:
libavformat/rtp_mpv.c
28 28
void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size)
29 29
{
30 30
    RTPDemuxContext *s = s1->priv_data;
31
    AVStream *st = s1->streams[0];
32 31
    int len, h, max_packet_size;
33 32
    uint8_t *q;
34 33
    int begin_of_slice, end_of_slice, frame_type, temporal_reference;
......
105 104
        q += len;
106 105

  
107 106
        /* 90 KHz time stamp */
108
        s->timestamp = s->base_timestamp +
109
            av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps
107
        s->timestamp = s->cur_timestamp;
110 108
        ff_rtp_send_data(s1, s->buf, q - s->buf, (len == size));
111 109

  
112 110
        buf1 += len;
......
114 112
        begin_of_slice = end_of_slice;
115 113
        end_of_slice = 0;
116 114
    }
117
    s->cur_timestamp++;
118 115
}
119 116

  
120 117

  

Also available in: Unified diff