LZ,帖个例子给你,记得给分啊
/*
This IPv4 example uses the background thread itself to process all packets.
You can use example one to send data to the session that's created in this
example.
*/
// check incoming packets
if (GotoFirstSourceWithData())
{
do
{
RTPPacket *pack;
RTPSourceData *srcdat;
srcdat = GetCurrentSourceInfo();
while ((pack = GetNextPacket()) != NULL)
{
ProcessRTPPacket(*srcdat,*pack);
DeletePacket(pack);
}
} while (GotoNextSourceWithData());
}
EndDataAccess();
}
void MyRTPSession::ProcessRTPPacket(const RTPSourceData &srcdat,const RTPPacket &rtppack)
{
// You can inspect the packet and the source's info here
std::cout << "Got packet " << rtppack.GetExtendedSequenceNumber() << " from SSRC " << srcdat.GetSSRC() << std::endl;
}
// IMPORTANT: The local timestamp unit MUST be set, otherwise
// RTCP Sender Report info will be calculated wrong
// In this case, we'll be just use 8000 samples per second.
sessparams.SetOwnTimestampUnit(1.0/8000.0);
transparams.SetPortbase(portbase);
status = sess.Create(sessparams,&transparams);
checkerror(status);
// Wait a number of seconds
RTPTime::Wait(RTPTime(num,0));