Changeset 232


Ignore:
Timestamp:
01/01/11 15:55:42 (17 months ago)
Author:
shiretu
Message:

-- fixed RTSP timestamp roll-over
-- added a timestamp on each log message and also flush on each line for file log appender

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/common/src/utils/logging/fileloglocation.cpp

    r148 r232  
    4646                return; 
    4747        } 
    48         string logEntry = format("%d:%s:%d:%s:%s\n", 
    49                         level, STR(fileName), lineNumber, STR(functionName), STR(message)); 
     48        string logEntry = format("%d:%d:%s:%d:%s:%s\n", 
     49                        time(NULL), level, STR(fileName), lineNumber, STR(functionName), 
     50                        STR(message)); 
    5051        _fileStream.write(STR(logEntry), logEntry.size()); 
    51         if ((_counter++) % 1000 == 0) { 
    52                 _fileStream.flush(); 
    53         } 
     52        _fileStream.flush(); 
    5453} 
    5554 
  • trunk/sources/thelib/include/protocols/rtp/inboundrtpprotocol.h

    r231 r232  
    3838        uint16_t _seqRollOver; 
    3939        uint64_t _lastTimestamp; 
    40         uint32_t _timestampRollover; 
     40        uint64_t _timestampRollover; 
    4141        bool _isAudio; 
    4242        uint32_t _packetsCount; 
    43         uint32_t _delta; 
    4443public: 
    4544        InboundRTPProtocol(); 
  • trunk/sources/thelib/src/protocols/rtp/inboundrtpprotocol.cpp

    r231 r232  
    3737        _isAudio = false; 
    3838        _packetsCount = 0; 
    39         _delta = 0; 
    4039} 
    4140 
     
    122121        length -= 12 + GET_RTP_CC(_rtpHeader)*4; 
    123122 
    124         //5. Normalize the timestamp to 0 
    125         if (_delta == 0) { 
    126                 _delta = _rtpHeader._timestamp; 
    127         } 
    128         _rtpHeader._timestamp -= _delta; 
    129  
    130  
    131         //      if (GetId() == 10) { 
    132         //              _rtpHeader._timestamp = (uint32_t) _rtpHeader._timestamp + 0xffdd0000; 
    133         //              //FINEST("%d: _rtpHeader._timestamp: %08x", GetId(), _rtpHeader._timestamp); 
    134         //      } 
    135         //      if (GetId() == 12) { 
    136         //              _rtpHeader._timestamp = (uint32_t) _rtpHeader._timestamp + 0xfff00000; 
    137                 //              //FINEST("%d: _rtpHeader._timestamp: %08x", GetId(), _rtpHeader._timestamp); 
    138         //      } 
    139  
    140123        //6. Detect rollover and adjust the timestamp 
    141124        if (_rtpHeader._timestamp < _lastTimestamp) { 
     125                FINEST("Possible roll over: _rtpHeader._timestamp: %016llx; _lastTimestamp: %016llx", 
     126                                _rtpHeader._timestamp, _lastTimestamp); 
    142127                if ((((_rtpHeader._timestamp & 0x80000000) >> 31) == 0) 
    143128                                && (((_lastTimestamp & 0x80000000) >> 31) == 1)) { 
    144129                        _timestampRollover++; 
    145130                        _lastTimestamp = _rtpHeader._timestamp; 
    146                         WARN("Roll over on %d", GetId()); 
     131                        WARN("Roll over on %d; _timestampRollover: %d", GetId(), _timestampRollover); 
    147132                } else { 
    148133                        WARN("Bogus timestamp. current ts: %016llx; last ts: %016llx", 
     
    154139                _lastTimestamp = _rtpHeader._timestamp; 
    155140        } 
    156         _rtpHeader._timestamp = _timestampRollover * 0xffffffff + _rtpHeader._timestamp; 
     141        //      string msg = ""; 
     142        //      if ((_lastSeq % 1000) == 0) { 
     143        //              msg = format("%d: %016llx", GetId(), _rtpHeader._timestamp); 
     144        //      } 
     145        _rtpHeader._timestamp = (_timestampRollover << 32) | _rtpHeader._timestamp; 
     146        //      if ((_lastSeq % 1000) == 0) { 
     147        //              msg += format("(%016llx)", _rtpHeader._timestamp); 
     148        //              FINEST(STR(msg)); 
     149        //      } 
    157150 
    158151        //5. Feed the data to the stream 
  • trunk/sources/thelib/src/protocols/rtp/streaming/innetrtpstream.cpp

    r187 r232  
    152152        double &lastTs = isAudio ? _lastAudioTs : _lastVideoTs; 
    153153 
    154         if ((uint64_t) (lastTs * 100.00) == (uint64_t) (absoluteTimestamp * 100.00)) { 
     154        if ((-1.0 < (lastTs * 100.00 - absoluteTimestamp * 100.00)) 
     155                        && ((lastTs * 100.00 - absoluteTimestamp * 100.00) < 1.00)) { 
    155156                absoluteTimestamp = lastTs; 
    156157        } 
    157158 
    158         if ((uint64_t) (lastTs * 100.00) > (uint64_t) (absoluteTimestamp * 100.00)) { 
    159                 WARN("Back time on %s. ATS: %.08f LTS: %.08f; D: %.8f", 
     159        if (lastTs * 100.00 > absoluteTimestamp * 100.00) { 
     160                WARN("Back time on %s. ATS: %.08f LTS: %.08f; D: %.8f; isAudio: %d", 
    160161                                STR(GetName()), 
    161162                                absoluteTimestamp, 
    162163                                lastTs, 
    163                                 absoluteTimestamp - lastTs); 
     164                                absoluteTimestamp - lastTs, 
     165                                isAudio); 
    164166                return true; 
    165167        } 
     
    214216 
    215217        //2. get the nalu 
    216         double ts = (double) rtpHeader._timestamp / _capabilities.avc._rate * 1000.0; 
     218        double ts = (double) rtpHeader._timestamp / (double) _capabilities.avc._rate * 1000.0; 
    217219        uint8_t naluType = NALU_TYPE(pData[0]); 
    218220        if (naluType <= 23) { 
Note: See TracChangeset for help on using the changeset viewer.