相关结构的定义,见前一篇文字:http://blog.csdn.net/linyanwen99/article/details/8485475
一.updateVideoCache方法的实现,如下:
void updateVideoCache( VideoPkt *spProto) {
Poco::SharedPtr<VideoPkt> pProto(spProto);
VideoUidMap::Iterator itr = VideoUidMap.find(pProto->_from);//查找连接对象
if(itr == VideoUidMap.end()) {
if(VideoUidMap.size() < MAX_SPEAKERS) {
VideoSeqMap amap;
VideoUidMap.insert(std::make_pair(pProto->_from, amap));
itr = VideoUidMap.find(pProto->_from);
} else {
return;
}
}
VideoSeqMap seqMap = itr->second;
if(seqMap.find(pProto->_seq) == seqMap.end()) {
if(seqMap.size() == MAX_PKTS) {
seqMap.erase(itr->second.begin());
}
seqMap.insert(std::make_pair(pProto->_seq, pProto));
}
VideoSeqMap::iterator it = seqMap.find(pProto->_seq);
if(it != seqMap.begin() && (--it)->second->_seq != pProto->_seq - 2) {//根据视频包的序号判断前一个包是否丢失了
ReSendVoice reSendVoice(pProto->_from, pProto->_seq - 2);//如果丢失了,则直接重新请求
std::string packStr;
reSendVoice.serialTo(packStr);
sendData(MEDIA_UDP, packStr); //发送请求包
}
}
转载请注明出处:山水间博客,http://blog.csdn.net/linyanwen99/article/details/8543267