Module: sems
Branch: master
Commit: 1682dccc9b203c9b0cbaa2a2aeb33d0f1bfbf571
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=1682dccc9b203c9b0cbaa2a2aeb33d0f1bfbf571

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Mon Mar  5 11:15:47 2012 +0100

b/f: fix timestamp translation & input resampling.

---

 core/AmAudio.cpp |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/core/AmAudio.cpp b/core/AmAudio.cpp
index 4975bc7..61c68ad 100644
--- a/core/AmAudio.cpp
+++ b/core/AmAudio.cpp
@@ -61,12 +61,13 @@ int AmAudioRtpFormat::setCurrentPayload(Payload pl)
 {
   if (this->codec_id != pl.codec_id) {
     this->codec_id = pl.codec_id;
+    DBG("fmt.codec_id = %d", this->codec_id);
     this->channels = 1;
     this->rate = pl.clock_rate;
     DBG("fmt.rate = %d", this->rate);
     this->advertized_rate = pl.advertised_clock_rate;
     DBG("fmt.advertized_rate = %d", this->advertized_rate);
-    this->frame_size = 20*this->advertized_rate/1000;
+    this->frame_size = 20*this->rate/1000;
     if (this->codec != NULL) {
       destroyCodec();
     }
@@ -379,15 +380,19 @@ int AmAudio::put(unsigned int user_ts, unsigned char* 
buffer, int input_sample_r
   if(max_rec_time > -1 && rec_time >= max_rec_time)
     return -1;
 
-  size = resampleInput((unsigned char*)samples, size, input_sample_rate, 
fmt->rate);
-
   memcpy((unsigned char*)samples,buffer,size);
+  size = resampleInput((unsigned char*)samples, size, input_sample_rate, 
fmt->rate);
 
   int s = encode(size);
   if(s>0){
     //DBG("%s\n",typeid(this).name());
     incRecordTime(bytes2samples(size));
-    unsigned int wr_ts = user_ts * ((double) fmt->advertized_rate / (double) 
SYSTEM_SAMPLECLOCK_RATE);
+
+    unsigned int wr_ts = user_ts * ((double) (fmt->advertized_rate > 0 ?
+                                             fmt->advertized_rate
+                                             : fmt->rate)
+                                   / (double) SYSTEM_SAMPLECLOCK_RATE);
+
     return write(wr_ts,(unsigned int)s);
   }
   else{

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to