1、由上层设置关键帧请求方式
Conductor::VideoSetStream
->ViERTP_RTCPImpl::SetKeyFrameRequestMethod
->ViEChannel::SetKeyFrameRequestMethod
->ModuleRtpRtcpImpl::SetKeyFrameRequestMethod
方式共四种:
kKeyFrameReqNone = 0,
kKeyFrameReqFirRtp = 1,
kKeyFrameReqPliRtcp = 2,
kKeyFrameReqFirRtcp = 3
2、请求关键帧
VideoReceiver::Decode
->VideoReceiver::RequestKeyFrame
->ViEChannel::RequestKeyFrame
其中,在decode里
if (frame == NULL)
{
if (_receiver.NeedkeyFrame())
{
RequestKeyFrame();
}
return VCM_FRAME_NOT_READY;
}
NeedkeyFrame()定义:
int32_t VCMJitterBuffer::NeedkeyFrame()
{
if (need_key)
{
need_key = 0;
return 1;
}
return 0;
}
而need_key=1的情况有如下3种:
if (packet.seqNum > latest_received_sequence_number_ + 1)
if (start_time_ms - latest_recived_time > 500)
if (!frame->Complete())
3、RTCP接收及处理关键帧请求
ViENetworkImpl::ReceivedRTCPPacket
->ViEChannel::ReceivedRTCPPacket
->ViEReceiver::ReceivedRTCPPacket
->ViEReceiver::InsertRTCPPacket
->ModuleRtpRtcpImpl::IncomingRtcpPacket
->RTCPReceiver::TriggerCallbacksFromRTCPPacket
->OnReceivedIntraFrameRequest
->EncoderStateFeedback::OnReceivedIntraFrameRequest
->ViEEncoder::OnReceivedIntraFrameRequest
->IntraFrameRequest
->VideoSender::IntraFrameRequest
在VideoSender::IntraFrameRequest中,通过维持nextFrameTypes数组
_nextFrameTypes[stream_index] = kVideoFrameKey;
来在编码时,确定下一帧是I帧还是P帧。
------流程中还有一些细节没明白,尤其是关于STL模板库的内容,webrtc中有很多相关代码,后面再看看。