For the definition of the relevant structure, see the previous article: http://blog.csdn.net/linyanwen99/article/details/8485475
1. Implement the updatevideocache method as follows:
Void updatevideocache (videopkt * spproto ){
Poco: sharedptr <videopkt> pproto (spproto );
Videouidmap: iterator itr = videouidmap. Find (pproto-> _ from); // query the connection object
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) {// determine whether the previous package is lost based on the video package number
Resendvoice (pproto-> _ from, pproto-> _ seq-2); // if it is lost, directly re-Request
STD: String packstr;
Resendvoice. serialto (packstr );
Senddata (media_udp, packstr); // send a request packet
}
}
Reprinted please indicate the source: zhujian blog, http://blog.csdn.net/linyanwen99/article/details/8543267