live555 h264 videostream 資料流和時間戳的分析
阿新 • • 發佈:2019-01-01
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 is H264FUAFragmenter
7.FramedSource::getNextFrame
8.FramedSource::doGetNextFrame ->H264FUAFragmenter::doGetNextFrame -> fInputSource->getNextFrame fInputSource type is H264VideoStreamFramer
9.H264VideoStreamFramer::getNextFrame -> MPEGVideoStreamFramer::doGetNextFrame
10.MPEGVideoStreamFramer::continueReadProcessing -> fParser->parse() fParser type is H264VideoStreamParser
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,然後計算下一幀的時間戳