Ignore:
Timestamp:
08/25/10 19:30:12 (21 months ago)
Author:
shiretu
Message:

-- added another version for handling NAL units

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/thelib/src/protocols/ts/innettsstream.cpp

    r56 r105  
    4747        _feedTime = 0; 
    4848        _cursor = 0; 
     49 
     50        _firstNAL = true; 
    4951} 
    5052 
     
    150152                } 
    151153        } 
     154 
     155        //#define HandleVideoData HandleVideoData_version1 
     156#define HandleVideoData HandleVideoData_version2 
    152157 
    153158        if (isAudio) 
     
    277282} 
    278283 
    279 bool InNetTSStream::HandleVideoData(uint8_t *pBuffer, uint32_t length, 
     284bool InNetTSStream::HandleVideoData_version1(uint8_t *pBuffer, uint32_t length, 
    280285                double timestamp, bool packetStart) { 
    281286        //1. Store the data inside our buffer 
     
    327332} 
    328333 
     334bool InNetTSStream::HandleVideoData_version2(uint8_t *pBuffer, uint32_t length, 
     335                double timestamp, bool packetStart) { 
     336        //1. Store the data inside our buffer 
     337        _currentNal.ReadFromBuffer(pBuffer, length); 
     338 
     339        uint32_t size = GETAVAILABLEBYTESCOUNT(_currentNal); 
     340        if (size < 4) 
     341                return true; 
     342 
     343        uint8_t *pNalBuffer = GETIBPOINTER(_currentNal); 
     344 
     345        _cursor = 0; 
     346        if (_firstNAL) { 
     347                while (_cursor < size - 4) { 
     348                        if (ntohlp(pNalBuffer + _cursor) == 1) { 
     349                                _currentNal.Ignore(_cursor + 4); 
     350                                _firstNAL = false; 
     351                                _cursor += 4; 
     352                                break; 
     353                        } 
     354                        _cursor++; 
     355                } 
     356        } 
     357 
     358        while (_cursor < size - 4) { 
     359                if (ntohlp(pNalBuffer + _cursor) == 1) { 
     360                        if (!ProcessNal(timestamp)) { 
     361                                FATAL("Unable to process NALU"); 
     362                                return false; 
     363                        } 
     364                        _currentNal.Ignore(_cursor + 4); 
     365                        pNalBuffer = GETIBPOINTER(_currentNal); 
     366                        size = GETAVAILABLEBYTESCOUNT(_currentNal); 
     367                        _cursor = 0; 
     368                        if (size < 4) 
     369                                break; 
     370                } else { 
     371                        _cursor++; 
     372                } 
     373        } 
     374 
     375        return true; 
     376} 
     377 
    329378bool InNetTSStream::ProcessNal(double timestamp) { 
    330379        InitializeVideoCapabilities(GETIBPOINTER(_currentNal), _cursor); 
Note: See TracChangeset for help on using the changeset viewer.