代码调用流程说明.md 4.8 KB

舱端请求

  • qt舱端接收4010(SC_NotifyRep)消息后,创建offer,返回2004(CS_Offer)消息流程
    • SocketClient::Start 定义了接收4010(SC_NotifyRep)消息时,触发SocketClient::OnNotifyRep
    • SocketClient::OnNotifyRep 调用了 CEgoClient::OnVideoRep
    • CEgoClient::OnVideoRep 触发了 CEgoWindow::OnNotifyRep
    • CEgoWindow::OnNotifyRep 调用了 CPeerConnection::CreateOffer
    • CPeerConnection::CreateOffer 调用了 mrsPeerConnectionCreateOffer
    • mrsPeerConnectionCreateOffer 会触发 CPeerConnection::LocalSdpReadytoSendCallback
    • CPeerConnection::LocalSdpReadytoSendCallback 调用了 CPeerConnection::OnLocalSdpReadytoSend
    • CPeerConnection::OnLocalSdpReadytoSend 调用了 SocketClient::WriteOffer
    • SocketClient::WriteOffer 向服务端发送2004(CS_Offer)消息

服务器端监听

  • 服务器端,监听2001(CS_Req),发送4009/4001,给车端

    • CUserSocket::InitFnDirector 定义了接收2001(CS_Req)消息时,触发 CUserSocket::OnReqVideo
      • CUserSocket::OnReqVideo 调用了 RemoNet::VideoDesc CUserManager::ConnectPeerVideo
      • RemoNet::VideoDesc CUserManager::ConnectPeerVideo 调用了 CUserSocket::ReqVideo
      • CUserSocket::ReqVideo 发送了4009(SC_NotifyReq)消息给车端
    • CUserSocket::OnReqVideo 发送了4001(SC_Req)消息给车端 (注:4001消息是车端舱端都没有用到的)
  • 服务器端,监听2002(CS_Rep)消息,返回4010(SC_NotifyRep)消息流程

    • SocketClient::InitFnDirector 定义了接收2002(CS_Rep)消息时,触发 CUserSocket::OnRepVideo
    • CUserSocket::OnRepVideo 调用了 CUserManager::GetInstance().ReplyPeerVideo
    • CUserManager::ReplyPeerVideo 调用了 CUserSocket::RepVideo
    • CUserSocket::RepVideo 发送了4010(SC_NotifyRep)消息
  • 服务器端,监听舱端2004(CS_Offer)消息,发送4012(SC_NotifyOffer)给车端

    • CUserSocket::InitFnDirector 定义了接收2004(CS_Offer)消息时,触发 CUserSocket::OnOffer
    • CUserSocket::OnOffer 会调用 CUserManager::GetInstance().NotifyOffer
    • CUserManager::GetInstance().NotifyOffer 会调用 CUserSocket::NotifyOffer
    • CUserSocket::NotifyOffer 发送4012(SC_NotifyOffer)消息,给车端
  • 服务器端,监听2005(CS_Answer)消息,发送4011(SC_NotifyAnswer),给舱端

    • CUserSocket::InitFnDirector 定义了接收2005(CS_Answer)消息时,触发 CUserSocket::OnAnswer
    • CUserSocket::OnAnswer 调用了 CUserManager::GetInstance().NotifyAnswer
    • CUserManager::GetInstance().NotifyAnswer 调用了 CUserSocket::NotifyAnswer
    • CUserSocket::NotifyAnswer 发送4011(SC_NotifyAnswer)消息给舱端
  • 服务器端,监听车端2009(CS_Add)消息

    • CUserSocket::InitFnDirector 定义了监听2009(CS_Add)消息,触发 CUserSocket::OnAdd
    • CUserSocket::OnAdd 发送了4016(SC_NotifyAdd)给全部舱端
    • CUserSocket::OnAdd 发送了4007(SC_Add)返回给车端执行结果
  • 服务器端,监听舱端2000(CS_Sign)消息

    • CUserSocket::InitFnDirector 定义了监听2000(CS_Sign)消息,触发 CUserSocket::OnSigin
    • CUserSocket::OnSigin 发送了4000(SC_Sign)返回给舱端执行结果

车端监听

  • 车端监听4012(SC_NotifyOffer)消息,发送2005(CS_Answer)消息流程

    • SocketClient::Start 中定义了,如果接收到4012消息(SC_NotifyOffer)后,会调用SocketClient::OnNotifyOffer;
    • SocketClient::OnNotifyOffer 调用了 CMessageQueue::OnVideoOffer
      • CMessageQueue::OnVideoOffer 调用了 CMessageQueue::InitPeerConnection,建立pc对象
      • CMessageQueue::OnVideoOffer 调用了 CPeerConnection::SetRemoteDescription
      • CMessageQueue::OnVideoOffer 调用了 CPeerConnection::CreateAnswer
        • CPeerConnection::CreateAnswer 会调用 mrsPeerConnectionCreateAnswer
        • mrsPeerConnectionCreateAnswer 会触发 CPeerConnection::LocalSdpReadytoSendCallback
        • CPeerConnection::LocalSdpReadytoSendCallback 调用了 CPeerConnection::OnLocalSdpReadytoSend
        • CPeerConnection::OnLocalSdpReadytoSend 调用了 SocketClient::WriteAnswer
        • SocketClient::WriteAnswer 向服务端发送了2005(CS_Answer)消息
  • 车端监听4009(SC_NotifyReq)消息,发送2002消息流程

    • SocketClient::Start 中定义了,如果接收到4009消息(SC_NotifyReq),会调用SocketClient::OnNotifyReq
    • SocketClient::OnNotifyReq 调用了 CMessageQueue::OnVideoReq
    • CMessageQueue::OnVideoReq 触发了 CMessageQueue::OnNotifyReq
    • CMessageQueue::OnNotifyReq 创建了 CPeerConnection 对象,放置在全局列表中
    • CMessageQueue::OnNotifyReq 调用了 SocketClient::WriteVideoRep,发送了2002(CS_Rep)消息