现在基本实现live555转发ps流,但是由于没有正确处理时间戳及分帧问题,导致接收端数据回调的不正确。
问题可以分为两个:1、时间戳 2、marker的标记
最终的处理方法为
void SimpleRTPSink::doSpecialFrameHandling(unsigned fragmentationOffset,
unsigned char* frameStart,
unsigned numBytesInFrame,
struct timeval frameTimestamp,
unsigned numRemainingBytes) {
if (numBytesInFrame> 3 &&(frameStart[0] == 0x00 && frameStart[1] == 0x00 & frameStart[2] == 0x01 && frameStart[3] == 0xBA) ) {
// This packet contains the last (or only) fragment of the frame.
// Set the RTP 'M' ('marker') bit, if appropriate:
//fNumFramesUsedSoFar = 0;
//if (fSetMBitOnLastFrames) setMarkerBit();
//2014-06-13 fix me, marker not set now
//setMarkerBit();
// Important: Also call our base class's doSpecialFrameHandling(),
// to set the packet's timestamp:
MultiFramedRTPSink::doSpecialFrameHandling(fragmentationOffset,
frameStart, numBytesInFrame,
frameTimestamp,
numRemainingBytes);
}
}
时间戳的问题得以解决,而marker标准位的问题可以通过setMarkerBit();该函数实现。一所检测环境中,视频流也没有加marker,所以我暂不处理。 后面可以通过前面传入或缓存一帧的方式解决该问题。