live555 server 資料流傳送流程和時間戳的分析
阿新 • • 發佈:2019-02-10
rtsp客戶端傳送播放請求後,rtsp伺服器呼叫流程如下
h264 video rtsp
1.ServerMediaSubsession::startStream ->OnDemandServerMediaSubsession::startStream
2.startStream -> StreamState::startPlaying
3.MediaSink::startPlaying
4.MediaSink::continuePlaying->MultiFramedRTPSink::continuePlaying
5.MultiFramedRTPSink::buildAndSendPacket
6.MultiFramedRTPSink::packFrame() fSource->getNextFrame fSource type isH264FUAFragmenter
7.FramedSource::getNextFrame
8.FramedSource::doGetNextFrame->H264FUAFragmenter::doGetNextFrame -> fInputSource->getNextFrame fInputSource typeis H264VideoStreamFramer
9.H264VideoStreamFramer::getNextFrame ->MPEGVideoStreamFramer::doGetNextFrame
10.MPEGVideoStreamFramer::continueReadProcessing ->fParser->parse() fParser type isH264VideoStreamParser
11.H264VideoStreamParser::parse() ->ByteStreamFileSource::doGetNextFrame ->ByteStreamFileSource::doReadFromFile
時間戳生成流程
1.MultiFramedRTPSink::buildAndSendPacket中組建rtp包頭時,獲取時間戳的位置fTimestampPosition,然後等待獲取資料與時間戳後寫入
2.MultiFramedRTPSink::afterGettingFrame1->H264VideoRTPSink::doSpecialFrameHandling->MultiFramedRTPSink::setTimestamp將時間戳寫入到rtp包中
3.H264VideoStreamParser::parse中呼叫H264VideoStreamFramer::setPresentationTime { fPresentationTime =fNextPresentationTime; } 此fPresentationTime最終將傳到步驟2中
4.fNextPresentationTime 初始化由建構函式獲取當前時間戳,後續在H264VideoStreamParser::parse當thisNALUnitEndsAccessUnit=TRUE後,根據幀率計算幀duration,然後計算下一幀的時間戳