fixes rtp ts handling bug in receiving introduced in r281.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@306 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 20 years ago
parent 7f5296e849
commit 027de94734

@ -18,7 +18,6 @@
#define MAX_DELAY 8000 /* 1 second */
AmPlayoutBuffer::AmPlayoutBuffer(AmRtpAudio *owner)
: r_ts(0),w_ts(0), last_ts_i(false), m_owner(owner)
{
@ -31,7 +30,7 @@ void AmPlayoutBuffer::direct_write_buffer(unsigned int ts, ShortSample* buf, uns
void AmPlayoutBuffer::write(u_int32_t ref_ts, u_int32_t rtp_ts,
int16_t* buf, u_int32_t len, bool begin_talk)
{
{
unsigned int mapped_ts;
if(!recv_offset_i)
{

@ -103,18 +103,18 @@ int AmRtpAudio::receive(unsigned int audio_buffer_ts)
return size;
}
int AmRtpAudio::get(unsigned int user_ts, unsigned char* buffer, unsigned int nb_samples)
int AmRtpAudio::get(unsigned int ref_ts, unsigned char* buffer, unsigned int nb_samples)
{
int size = read(user_ts,PCM16_S2B(nb_samples));
int size = read(ref_ts,PCM16_S2B(nb_samples));
memcpy(buffer,(unsigned char*)samples,size);
return size;
}
int AmRtpAudio::read(unsigned int user_ts, unsigned int size)
int AmRtpAudio::read(unsigned int ref_ts, unsigned int size)
{
u_int32_t rlen =
playout_buffer
->read(user_ts,
->read(ref_ts,
(ShortSample*)((unsigned char*)samples),
PCM16_B2S(size));

@ -91,12 +91,19 @@ void AmRtpReceiver::run()
if(p.recv(tmp_fds[i].fd) > 0){
int parse_res = p.parse();
gettimeofday(&p.recv_time,NULL);
streams_mut.lock();
Streams::iterator it = streams.find(tmp_fds[i].fd);
if(it != streams.end())
it->second->bufferPacket(&p);
if(it != streams.end()) {
if (parse_res == -1) {
DBG("error while parsing RTP packet.\n");
it->second->clearRTPTimeout(&p.recv_time);
} else {
it->second->bufferPacket(&p);
}
}
streams_mut.unlock();
}
}

@ -403,15 +403,20 @@ void AmRtpStream::icmpError()
void AmRtpStream::bufferPacket(const AmRtpPacket* p)
{
memcpy(&last_recv_time, &p->recv_time, sizeof(struct timeval));
if (!receiving && !passive)
return;
jitter_mut.lock();
gettimeofday(&last_recv_time,NULL);
jitter_buf[p->timestamp].copy(p);
jitter_mut.unlock();
}
void AmRtpStream::clearRTPTimeout(struct timeval* recv_time) {
memcpy(&last_recv_time, recv_time, sizeof(struct timeval));
}
int AmRtpStream::nextPacket(AmRtpPacket& p)
{
if (!receiving && !passive)

@ -126,7 +126,7 @@ protected:
/* get next packet in buffer */
int nextPacket(AmRtpPacket& p);
AmSession* session;
/** Initializes a new random local port, and sets own attributes properly. */
@ -236,6 +236,11 @@ public:
*/
void bufferPacket(const AmRtpPacket* p);
/*
* clear RTP timeout at time recv_time
*/
void clearRTPTimeout(struct timeval* recv_time);
virtual unsigned int bytes2samples(unsigned int) const = 0;
};
/** \brief represents info about an \ref AmRtpStream */

Loading…
Cancel
Save