Author: sayer
Date: 2008-08-21 20:29:40 +0200 (Thu, 21 Aug 2008)
New Revision: 1070

Modified:
   branches/wb/Makefile.defs
   branches/wb/core/AmAudio.cpp
   branches/wb/core/AmAudio.h
   branches/wb/core/AmMediaProcessor.cpp
   branches/wb/core/AmPlayoutBuffer.cpp
   branches/wb/core/AmPlugIn.cpp
   branches/wb/core/AmRtpAudio.cpp
   branches/wb/core/AmRtpStream.cpp
   branches/wb/core/AmRtpStream.h
   branches/wb/core/AmSdp.cpp
   branches/wb/core/amci/amci.h
   branches/wb/core/plug-in/adpcm/adpcm.c
   branches/wb/core/plug-in/g722/g722.c
   branches/wb/core/plug-in/gsm/gsm.c
   branches/wb/core/plug-in/ilbc/ilbc.c
   branches/wb/core/plug-in/l16/l16.c
   branches/wb/core/plug-in/speex/speex.c
   branches/wb/core/plug-in/wav/wav.c
Log:
first wideband version. conference and announcement works, adaptive playout 
untested.

Modified: branches/wb/Makefile.defs
===================================================================
--- branches/wb/Makefile.defs   2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/Makefile.defs   2008-08-21 18:29:40 UTC (rev 1070)
@@ -9,7 +9,7 @@
 VERSION = 1
 PATCHLEVEL = 0
 SUBLEVEL = 0
-EXTRAVERSION ?= -pre-$(SVN_REV)
+EXTRAVERSION ?= -wb-$(SVN_REV)
 
 REL_VERSION=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
 RELEASE=$(REL_VERSION)$(EXTRAVERSION)
@@ -37,7 +37,7 @@
 # compile with sample rate conversion from secret rabbit code? 
 # (see http://www.mega-nerd.com/SRC/)
 #
-#USE_LIBSAMPLERATE = yes
+USE_LIBSAMPLERATE = yes
 
 #
 # ZRTP support? (see zfoneproject.com)

Modified: branches/wb/core/AmAudio.cpp
===================================================================
--- branches/wb/core/AmAudio.cpp        2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmAudio.cpp        2008-08-21 18:29:40 UTC (rev 1070)
@@ -123,7 +123,8 @@
 
 AmAudioRtpFormat::~AmAudioRtpFormat()
 {
-  for (std::map<int, CodecContainer *>::iterator it = 
m_codecContainerByPayload.begin(); it != m_codecContainerByPayload.end(); ++it)
+  for (std::map<int, CodecContainer *>::iterator it = 
+        m_codecContainerByPayload.begin(); it != 
m_codecContainerByPayload.end(); ++it)
     delete it->second;
 }
 
@@ -151,10 +152,11 @@
 unsigned int AmAudioFormat::calcBytesToRead(unsigned int needed_samples) const
 {
   if (codec && codec->samples2bytes)
-    return codec->samples2bytes(h_codec, needed_samples) * channels; // FIXME: 
channels
+    return codec->samples2bytes(h_codec, needed_samples) * 
+      rate * channels / SYSTEM_SAMPLERATE; // FIXME: channels, system_channels
 
   WARN("Cannot convert samples to bytes\n");
-  return needed_samples * channels;
+  return needed_samples * channels * rate / SYSTEM_SAMPLERATE;
 }
 
 unsigned int AmAudioFormat::bytes2samples(unsigned int bytes) const
@@ -250,34 +252,49 @@
   : fmt(new AmAudioSimpleFormat(CODEC_PCM16)),
     max_rec_time(-1),
     rec_time(0)
-#ifdef USE_LIBSAMPLERATE 
-  , resample_state(NULL),
-    resample_buf_samples(0)
-#endif
+
 {
+  initSrc();
 }
 
 AmAudio::AmAudio(AmAudioFormat *_fmt)
   : fmt(_fmt),
     max_rec_time(-1),
     rec_time(0)
-#ifdef USE_LIBSAMPLERATE 
-  , resample_state(NULL),
-    resample_buf_samples(0)
-#endif
 {
+  initSrc();
 }
 
+void AmAudio::initSrc() {
+#ifdef USE_LIBSAMPLERATE   
+  src_state_in = new src_state();
+  src_state_out = new src_state();
+
+  src_state_in->resample_state = NULL;
+  src_state_in->resample_buf_samples = 0;
+  src_state_out->resample_state = NULL;
+  src_state_out->resample_buf_samples = 0;
+#endif
+}
+
 AmAudio::~AmAudio()
 {
 #ifdef USE_LIBSAMPLERATE 
-  if (NULL != resample_state) 
-    src_delete(resample_state);
+  if (NULL != src_state_in) {
+    if (src_state_in->resample_state)
+      src_delete(src_state_in->resample_state);
+    delete src_state_in;
+  }
+  if (NULL != src_state_out) {
+    if (src_state_out->resample_state) 
+      src_delete(src_state_out->resample_state);
+    
+    delete src_state_out;
+  }
 #endif
 }
 
 void AmAudio::setFormat(AmAudioFormat* new_fmt) {
-  DBG("set format to %p --------------------------\n", new_fmt);
   fmt.reset(new_fmt);
   fmt->resetCodec();
 }
@@ -292,8 +309,8 @@
   int size = calcBytesToRead(nb_samples);
 
   size = read(user_ts,size);
-  //DBG("size = %d\n",size);
-  if(size <= 0){
+
+  if(size <= 0) {
     return size;
   }
 
@@ -302,6 +319,7 @@
     DBG("decode returned %i\n",size);
     return -1; 
   }
+  /* into internal format */
   size = downMix(size);
     
   if(size>0)
@@ -323,11 +341,26 @@
 
   memcpy((unsigned char*)samples,buffer,size);
 
+  /* from internal format */
+  size = upMix(size);
+  unsigned long wr_ts = user_ts;
+  // unsigned int wr_ts =( (long)user_ts * (long)fmt->rate / 
(long)SYSTEM_SAMPLERATE);
+  if (fmt->rate != SYSTEM_SAMPLERATE) {
+    if (fmt->rate > SYSTEM_SAMPLERATE) {
+      unsigned int f = fmt->rate / SYSTEM_SAMPLERATE;
+      wr_ts = wr_ts * f; 
+    } else {
+      unsigned int f = SYSTEM_SAMPLERATE / fmt->rate ;
+      wr_ts = wr_ts / f; 
+    }
+  }
+  //  DBG("wr_ts = %ld\n", wr_ts);
+
   unsigned int s = encode(size);
   if(s>0){
     //DBG("%s\n",typeid(this).name());
     incRecordTime(bytes2samples(size));
-    return write(user_ts,(unsigned int)s);
+    return write(wr_ts,(unsigned int)s);
   }
   else{
     return s;
@@ -380,10 +413,11 @@
 {
   int s = size;
 
-//   if(!fmt.get()){
-//     DBG("no encode fmt\n");
-//     return 0;
-//   }
+  // todo: is his check needed? 
+  //   if(!fmt.get()){
+  //     DBG("no encode fmt\n");
+  //     return 0;
+  //   }
 
   amci_codec_t* codec = fmt->getCodec();
   long h_codec = fmt->getHCodec();
@@ -408,54 +442,87 @@
 
 #ifdef USE_LIBSAMPLERATE 
   if (fmt->rate != SYSTEM_SAMPLERATE) {
-    if (!resample_state) {
-      int src_error;
-      // for better quality but more CPU usage, use SRC_SINC_ converters
-      resample_state = src_new(SRC_LINEAR, 1, &src_error);
-      if (!resample_state) {
-       ERROR("samplerate initialization error: ");
-      }
-    }
+//     DBG("downmix %d->%d\n", SYSTEM_SAMPLERATE, fmt->rate);
+    s = resample(src_state_in, (double)SYSTEM_SAMPLERATE / (double)fmt->rate, 
size);
+  }
+#endif
+ 
+  return s;
+}
 
-    if (resample_state) {
-      if (resample_buf_samples + PCM16_B2S(s) > PCM16_B2S(AUDIO_BUFFER_SIZE) * 
2) {
-       WARN("resample input buffer overflow! (%d)\n",
-            resample_buf_samples + PCM16_B2S(s));
-      } else {
-       signed short* samples_s = (signed short*)(unsigned char*)samples;
-       src_short_to_float_array(samples_s, &resample_in[resample_buf_samples], 
PCM16_B2S(s));
-       resample_buf_samples += PCM16_B2S(s);
-      }
-      
-      SRC_DATA src_data;
-      src_data.data_in = resample_in;
-      src_data.input_frames = resample_buf_samples;
-      src_data.data_out = resample_out;
-      src_data.output_frames = PCM16_B2S(AUDIO_BUFFER_SIZE);
-      src_data.src_ratio = (double)SYSTEM_SAMPLERATE / (double)fmt->rate;
-      src_data.end_of_input = 0;
+unsigned int AmAudio::upMix(unsigned int size)
+{
+  unsigned int s = size;
+//   if(fmt->channels == 2){
+//     stereo2mono(samples.back_buffer(),(unsigned char*)samples,s);
+//     samples.swap();
+//   }
 
-      int src_err = src_process(resample_state, &src_data);
-      if (src_err) {
-       DBG("resample error: '%s'\n", src_strerror(src_err));
-      }else {
-       signed short* samples_s = (signed short*)(unsigned char*)samples;
-       src_float_to_short_array(resample_out, samples_s, 
src_data.output_frames_gen);
-       s = PCM16_S2B(src_data.output_frames_gen);
+#ifdef USE_LIBSAMPLERATE 
+  if (fmt->rate != SYSTEM_SAMPLERATE) {
+//     DBG("upmix %d->%d\n", fmt->rate,SYSTEM_SAMPLERATE);
+    s = resample(src_state_out, (double)fmt->rate / (double)SYSTEM_SAMPLERATE, 
size);
+  }
+#endif
+ 
+  return s;
+}
 
-       if (resample_buf_samples !=  (unsigned int)src_data.input_frames_used) {
-         memmove(resample_in, &resample_in[src_data.input_frames_used], 
-                 (resample_buf_samples - src_data.input_frames_used) * 
sizeof(float));
-       }
-       resample_buf_samples = resample_buf_samples - 
src_data.input_frames_used;
+#ifdef USE_LIBSAMPLERATE 
+
+unsigned int AmAudio::resample(src_state* m_src_state, double factor, unsigned 
int size) {
+  if (!m_src_state)
+    return size;
+
+  unsigned int s = size;
+
+  if (NULL == m_src_state->resample_state) {
+    int src_error;
+    // for better quality but more CPU usage, use SRC_SINC_ converters
+    m_src_state->resample_state = src_new(SRC_LINEAR, 1, &src_error);
+    if (!m_src_state->resample_state) {
+      ERROR("samplerate initialization error");
+      return size;
+    }
+  }
+  
+  if (m_src_state->resample_state) {
+    if (m_src_state->resample_buf_samples + PCM16_B2S(s) > 
PCM16_B2S(AUDIO_BUFFER_SIZE) * 2) {
+      WARN("resample input buffer overflow! (%d)\n",
+          m_src_state->resample_buf_samples + PCM16_B2S(s));
+    } else {
+      signed short* samples_s = (signed short*)(unsigned char*)samples;
+      src_short_to_float_array(samples_s, 
&m_src_state->resample_in[m_src_state->resample_buf_samples], PCM16_B2S(s));
+      m_src_state->resample_buf_samples += PCM16_B2S(s);
+    }
+    
+    SRC_DATA src_data;
+    src_data.data_in = m_src_state->resample_in;
+    src_data.input_frames = m_src_state->resample_buf_samples;
+    src_data.data_out = m_src_state->resample_out;
+    src_data.output_frames = PCM16_B2S(AUDIO_BUFFER_SIZE);
+    src_data.src_ratio = factor;
+    src_data.end_of_input = 0;
+    
+    int src_err = src_process(m_src_state->resample_state, &src_data);
+    if (src_err) {
+      DBG("resample error: '%s'\n", src_strerror(src_err));
+    }else {
+      signed short* samples_s = (signed short*)(unsigned char*)samples;
+      src_float_to_short_array(m_src_state->resample_out, samples_s, 
src_data.output_frames_gen);
+      s = PCM16_S2B(src_data.output_frames_gen);
+      
+      if (m_src_state->resample_buf_samples !=  (unsigned 
int)src_data.input_frames_used) {
+       memmove(m_src_state->resample_in, 
&m_src_state->resample_in[src_data.input_frames_used], 
+               (m_src_state->resample_buf_samples - 
src_data.input_frames_used) * sizeof(float));
       }
+      m_src_state->resample_buf_samples -= src_data.input_frames_used;
     }
   }
-#endif
- 
 
   return s;
 }
+#endif
 
 unsigned int AmAudio::getFrameSize()
 {

Modified: branches/wb/core/AmAudio.h
===================================================================
--- branches/wb/core/AmAudio.h  2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmAudio.h  2008-08-21 18:29:40 UTC (rev 1070)
@@ -47,7 +47,7 @@
 #define PCM16_B2S(b) ((b) >> 1)
 #define PCM16_S2B(s) ((s) << 1)
 
-#define SYSTEM_SAMPLERATE 8000 // fixme: sr per session
+#define SYSTEM_SAMPLERATE 16000 // fixme: sr per session
 
 class SdpPayload;
 class CodecContainer;
@@ -199,6 +199,16 @@
   int getCurrentPayload() { return m_currentPayload; };
 };
 
+// for resampling
+struct src_state {
+#ifdef USE_LIBSAMPLERATE 
+  SRC_STATE* resample_state;
+  float resample_in[PCM16_B2S(AUDIO_BUFFER_SIZE)*2];
+  float resample_out[PCM16_B2S(AUDIO_BUFFER_SIZE)];
+  size_t resample_buf_samples;
+#endif
+};
+
 /**
  * \brief base for classes that input or output audio.
  *
@@ -212,12 +222,9 @@
   int rec_time; // in samples
   int max_rec_time;
 
-#ifdef USE_LIBSAMPLERATE 
-  SRC_STATE* resample_state;
-  float resample_in[PCM16_B2S(AUDIO_BUFFER_SIZE)*2];
-  float resample_out[PCM16_B2S(AUDIO_BUFFER_SIZE)];
-  size_t resample_buf_samples;
-#endif
+  src_state* src_state_in;
+  src_state* src_state_out;
+  void initSrc();
 
 protected:
   /** Sample buffer. */
@@ -258,12 +265,23 @@
   int encode(unsigned int size);
 
   /**
-   * Converts to mono depending on the format.
+   * Converts to internal format(-> mono, SYSTEM_SAMPLERATE)
    * @return new size in bytes
    */
   unsigned int downMix(unsigned int size);
 
   /**
+   * Converts from internal format (<- mono, SYSTEM_SAMPLERATE)
+   * @return new size in bytes
+   */
+  unsigned int upMix(unsigned int size);
+
+#ifdef USE_LIBSAMPLERATE 
+  /** resampler helper function */
+  unsigned int resample(src_state* m_src_state, double factor, unsigned int 
size);
+#endif
+
+  /**
    * Get the number of bytes to read from encoded, depending on the format.
    */
   unsigned int calcBytesToRead(unsigned int needed_samples) const;

Modified: branches/wb/core/AmMediaProcessor.cpp
===================================================================
--- branches/wb/core/AmMediaProcessor.cpp       2008-08-21 17:27:45 UTC (rev 
1069)
+++ branches/wb/core/AmMediaProcessor.cpp       2008-08-21 18:29:40 UTC (rev 
1070)
@@ -245,7 +245,7 @@
     if (s->rtp_str.checkInterval(ts, f_size)) {
       s->lockAudio();
 
-      int got_audio = -1;
+      int rcvd_audio_len = -1;
 
       // get/receive audio
       if (!s->getAudioLocal(AM_AUDIO_IN)) {
@@ -272,25 +272,25 @@
              break;
            }
          } else {
-           got_audio = s->rtp_str.get(ts,buffer,f_size);
+           rcvd_audio_len = s->rtp_str.get(ts,buffer,f_size);
            
-           if (s->isDtmfDetectionEnabled() && got_audio > 0)
-             s->putDtmfAudio(buffer, got_audio, ts);
+           if (s->isDtmfDetectionEnabled() && rcvd_audio_len > 0)
+             s->putDtmfAudio(buffer, rcvd_audio_len, ts);
          }
        }
       } else {
        // input is local - get audio from local_in
        AmAudio* local_input = s->getLocalInput(); 
        if (local_input) {
-         got_audio = local_input->get(ts,buffer,f_size);
+         rcvd_audio_len = local_input->get(ts,buffer,f_size);
        }
       }
 
       // process received audio
-      if (got_audio >= 0) {
+      if (rcvd_audio_len >= 0) {
        AmAudio* input = s->getInput();
        if (input) {
-         int ret = input->put(ts,buffer,got_audio);
+         int ret = input->put(ts,buffer,rcvd_audio_len);
          if(ret < 0){
            DBG("input->put() returned: %i\n",ret);
            postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s));
@@ -313,6 +313,7 @@
     if(output && s->rtp_str.sendIntReached()){
                
       int size = output->get(ts,buffer,s->rtp_str.getFrameSize());
+      
       if(size <= 0){
        DBG("output->get() returned: %i\n",size);
        postRequest(new SchedRequest(AmMediaProcessor::ClearSession,s)); 

Modified: branches/wb/core/AmPlayoutBuffer.cpp
===================================================================
--- branches/wb/core/AmPlayoutBuffer.cpp        2008-08-21 17:27:45 UTC (rev 
1069)
+++ branches/wb/core/AmPlayoutBuffer.cpp        2008-08-21 18:29:40 UTC (rev 
1070)
@@ -59,6 +59,7 @@
 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)
     {
@@ -70,6 +71,7 @@
     }
   else {
     mapped_ts = rtp_ts - recv_offset;
+    //    DBG("write ref_ts %u mapped_ts %u len %u rtp_ts %u\n", ref_ts, 
mapped_ts, len, rtp_ts);
 
     // resync
     if( ts_less()(mapped_ts, ref_ts - MAX_DELAY/2) || 
@@ -305,7 +307,7 @@
 
   if(ts_less()(w_ts,ts+len) && (plc_cnt < 6)){
        
-    if(!plc_cnt){
+    if(!plc_cnt){  
       int nlen = time_scale(w_ts-len,2.0, len);
       wsola_off += nlen-len;
     }

Modified: branches/wb/core/AmPlugIn.cpp
===================================================================
--- branches/wb/core/AmPlugIn.cpp       2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmPlugIn.cpp       2008-08-21 18:29:40 UTC (rev 1070)
@@ -93,6 +93,7 @@
   -1,
   "telephone-event",
   8000, // telephone-event has always SR 8000 
+  8000, // telephone-event has always SR 8000 
   -1,
   CODEC_TELEPHONE_EVENT,
   -1 
@@ -688,12 +689,12 @@
   }
   if (i >= AmConfig::CodecOrder.size()) {
       payload_order.insert(std::make_pair(id + 100, id));
-      DBG("payload '%s' inserted with id %i and order %i\n",
-         p->name, id, id + 100);
+      DBG("payload '%s'/%d inserted with id %i and order %i\n",
+         p->name, p->sample_rate, id, id + 100);
   } else {
       payload_order.insert(std::make_pair(i, id));
-      DBG("payload '%s' inserted with id %i and order %i\n",
-         p->name, id, i);
+      DBG("payload '%s'/%d inserted with id %i and order %i\n",
+         p->name, p->sample_rate, id, i);
   }
 
   return 0;

Modified: branches/wb/core/AmRtpAudio.cpp
===================================================================
--- branches/wb/core/AmRtpAudio.cpp     2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmRtpAudio.cpp     2008-08-21 18:29:40 UTC (rev 1070)
@@ -90,6 +90,7 @@
     size = AmRtpStream::receive((unsigned char*)samples,
                                (unsigned int)AUDIO_BUFFER_SIZE, rtp_ts,
                                payload);
+    //    DBG("rtp_ts recvd %u\n", rtp_ts);
     if(size <= 0)
       break;
 
@@ -110,6 +111,21 @@
       return -1;
     }
 
+    /* into internal format */
+    size = downMix(size);
+
+
+    // rtp_ts = SYSTEM_SAMPLERATE * rtp_ts / fmt->rate;
+    if (fmt->rate && fmt->rate != SYSTEM_SAMPLERATE) {
+      if (fmt->rate > SYSTEM_SAMPLERATE) {
+       unsigned int f = fmt->rate / SYSTEM_SAMPLERATE;
+       rtp_ts = rtp_ts / f;
+      } else {
+       unsigned int f = SYSTEM_SAMPLERATE / fmt->rate;
+       rtp_ts = rtp_ts * f;
+      }
+    }
+
     playout_buffer->write(wallclock_ts, rtp_ts, (ShortSample*)((unsigned char 
*)samples), 
                          PCM16_B2S(size), begin_talk);
   }

Modified: branches/wb/core/AmRtpStream.cpp
===================================================================
--- branches/wb/core/AmRtpStream.cpp    2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmRtpStream.cpp    2008-08-21 18:29:40 UTC (rev 1070)
@@ -335,6 +335,9 @@
 
   memcpy(buffer,rp->getData(),rp->getDataSize());
   ts = rp->timestamp;
+  if (rp->payload == PAYLOAD_ID_G722)
+    ts*=2; // G722 rate registered as 8khz due to historical error
+
   out_payload = rp->payload;
 
   int res = rp->getDataSize();

Modified: branches/wb/core/AmRtpStream.h
===================================================================
--- branches/wb/core/AmRtpStream.h      2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmRtpStream.h      2008-08-21 18:29:40 UTC (rev 1070)
@@ -52,6 +52,8 @@
 #define RTP_UNKNOWN_PL  -5 // unknown payload
 
 
+#define PAYLOAD_ID_G722  9
+
 struct amci_payload_t;
 
 class AmAudio;

Modified: branches/wb/core/AmSdp.cpp
===================================================================
--- branches/wb/core/AmSdp.cpp  2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/AmSdp.cpp  2008-08-21 18:29:40 UTC (rev 1070)
@@ -257,7 +257,7 @@
     if(it2 != payloads.end()){
       out_buf += "a=rtpmap:" + int2str(it2->first)
        + " " + string(it2->second->name)
-       + "/" + int2str(it2->second->sample_rate)
+       + "/" + int2str(it2->second->advertised_sample_rate)
        + "\r\n";
     } else {
       ERROR("Payload %d was not found in payloads map!\n", it->second);
@@ -300,7 +300,7 @@
        payload  = &(*it);
        payload->int_pt = a_pl->payload_id;
        payload->encoding_name = a_pl->name;
-       payload->clock_rate = a_pl->sample_rate;
+       payload->clock_rate = a_pl->advertised_sample_rate;
        sup_pl.push_back(payload);
       }
       else {

Modified: branches/wb/core/amci/amci.h
===================================================================
--- branches/wb/core/amci/amci.h        2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/amci/amci.h        2008-08-21 18:29:40 UTC (rev 1070)
@@ -381,6 +381,12 @@
      */
     int sample_rate;
 
+    /** 
+     * Sample rate that is advertised in SDP. 
+     * example: g722 has advertised_sample_rate 8000, and sample_rate 16000.
+     */
+    int advertised_sample_rate;
+
     /**
      * If this type is not bound to a fixed number of channels,
      * set this parameter to -1.
@@ -478,7 +484,7 @@
  * @hideinitializer
  */
 #define END_PAYLOADS \
-                    { -1, 0, -1, -1, -1, -1 } \
+                    { -1, 0, -1, -1, -1, -1, -1 } \
                 },
 
 /**
@@ -486,8 +492,8 @@
  * see example media plug-in 'wav' (plug-in/wav/wav.c).
  * @hideinitializer
  */
-#define PAYLOAD(id,name,rate,channels,codec_id,type) \
-                    { id, name, rate, channels, codec_id, type },
+#define PAYLOAD(id,name,rate,advertised_rate,channels,codec_id,type)   \
+  { id, name, rate, advertised_rate, channels, codec_id, type },
 
 /**
  * Portable export definition macro

Modified: branches/wb/core/plug-in/adpcm/adpcm.c
===================================================================
--- branches/wb/core/plug-in/adpcm/adpcm.c      2008-08-21 17:27:45 UTC (rev 
1069)
+++ branches/wb/core/plug-in/adpcm/adpcm.c      2008-08-21 18:29:40 UTC (rev 
1070)
@@ -91,11 +91,11 @@
 END_CODECS
     
 BEGIN_PAYLOADS
-PAYLOAD( -1, "G726-32", 8000, 1, CODEC_G726_32, AMCI_PT_AUDIO_LINEAR )
-PAYLOAD(  2, "G721",    8000, 1, CODEC_G726_32, AMCI_PT_AUDIO_LINEAR )
-PAYLOAD( -1, "G726-24", 8000, 1, CODEC_G726_24, AMCI_PT_AUDIO_LINEAR )
-PAYLOAD( -1, "G726-40", 8000, 1, CODEC_G726_40, AMCI_PT_AUDIO_LINEAR )
-PAYLOAD( -1, "G726-16", 8000, 1, CODEC_G726_16, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "G726-32", 8000, 8000, 1, CODEC_G726_32, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD(  2, "G721",    8000, 8000, 1, CODEC_G726_32, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "G726-24", 8000, 8000, 1, CODEC_G726_24, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "G726-40", 8000, 8000, 1, CODEC_G726_40, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "G726-16", 8000, 8000, 1, CODEC_G726_16, AMCI_PT_AUDIO_LINEAR )
 END_PAYLOADS
 
 BEGIN_FILE_FORMATS

Modified: branches/wb/core/plug-in/g722/g722.c
===================================================================
--- branches/wb/core/plug-in/g722/g722.c        2008-08-21 17:27:45 UTC (rev 
1069)
+++ branches/wb/core/plug-in/g722/g722.c        2008-08-21 18:29:40 UTC (rev 
1070)
@@ -52,7 +52,7 @@
 END_CODECS
   
 BEGIN_PAYLOADS
-PAYLOAD(9, "g722", 8000, 1, CODEC_G722_NB, AMCI_PT_AUDIO_FRAME)
+PAYLOAD(9, "g722", 16000, 8000, 1, CODEC_G722_NB, AMCI_PT_AUDIO_FRAME)
 END_PAYLOADS
   
 BEGIN_FILE_FORMATS
@@ -77,14 +77,14 @@
   }
 
   if (!g722_encode_init(&gs->encode_state, 
-                       64000, G722_SAMPLE_RATE_8000)) {
+                       64000, 0 /* G722_SAMPLE_RATE_8000 */)) {
     ERROR("error initializing G722 encoder\n");
     free(gs);
     return 0;
   }
 
   if (!g722_decode_init(&gs->decode_state, 
-                       64000, G722_SAMPLE_RATE_8000)) {
+                       64000, 0 /* G722_SAMPLE_RATE_8000 */)) {
     ERROR("error initializing G722 decoder\n");
     free(gs);
     return 0;
@@ -98,11 +98,11 @@
 }
 
 static unsigned int G722NB_bytes2samples(long h_codec, unsigned int num_bytes) 
{
-  return  num_bytes;
+  return  num_bytes * 2;
 }
 
 static unsigned int G722NB_samples2bytes(long h_codec, unsigned int 
num_samples) {
-  return num_samples;
+  return num_samples / 2;
 }
 
 
@@ -116,7 +116,7 @@
     return 0;
   }
 
-  if (rate != 8000) {
+  if (rate != 16000 /* 8000 */) {
     ERROR("only supports NB (8khz)\n");
     return 0;
   }
@@ -137,7 +137,7 @@
     return 0;
   }
 
-  if (rate != 8000) {
+  if (rate != 16000 /* 8000 */) {
     ERROR("only supports NB (8khz)\n");
     return 0;
   }

Modified: branches/wb/core/plug-in/gsm/gsm.c
===================================================================
--- branches/wb/core/plug-in/gsm/gsm.c  2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/plug-in/gsm/gsm.c  2008-08-21 18:29:40 UTC (rev 1070)
@@ -54,7 +54,7 @@
      END_CODECS
     
 BEGIN_PAYLOADS
-PAYLOAD( 3, "GSM", 8000, 1, CODEC_GSM0610, AMCI_PT_AUDIO_FRAME )
+PAYLOAD( 3, "GSM", 8000, 8000, 1, CODEC_GSM0610, AMCI_PT_AUDIO_FRAME )
      END_PAYLOADS
 
 BEGIN_FILE_FORMATS

Modified: branches/wb/core/plug-in/ilbc/ilbc.c
===================================================================
--- branches/wb/core/plug-in/ilbc/ilbc.c        2008-08-21 17:27:45 UTC (rev 
1069)
+++ branches/wb/core/plug-in/ilbc/ilbc.c        2008-08-21 18:29:40 UTC (rev 
1070)
@@ -87,7 +87,7 @@
      END_CODECS
     
 BEGIN_PAYLOADS
-PAYLOAD( -1, "iLBC", 8000, 1, CODEC_ILBC, AMCI_PT_AUDIO_FRAME )
+PAYLOAD( -1, "iLBC", 8000, 8000, 1, CODEC_ILBC, AMCI_PT_AUDIO_FRAME )
      END_PAYLOADS
 
 BEGIN_FILE_FORMATS

Modified: branches/wb/core/plug-in/l16/l16.c
===================================================================
--- branches/wb/core/plug-in/l16/l16.c  2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/plug-in/l16/l16.c  2008-08-21 18:29:40 UTC (rev 1070)
@@ -61,7 +61,9 @@
 END_CODECS
     
 BEGIN_PAYLOADS
-PAYLOAD( -1, "L16", 8000, 1, CODEC_L16, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "L16",  8000,  8000, 1, CODEC_L16, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "L16", 16000, 16000, 1, CODEC_L16, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( -1, "L16", 32000, 32000, 1, CODEC_L16, AMCI_PT_AUDIO_LINEAR )
 END_PAYLOADS
 
 BEGIN_FILE_FORMATS

Modified: branches/wb/core/plug-in/speex/speex.c
===================================================================
--- branches/wb/core/plug-in/speex/speex.c      2008-08-21 17:27:45 UTC (rev 
1069)
+++ branches/wb/core/plug-in/speex/speex.c      2008-08-21 18:29:40 UTC (rev 
1070)
@@ -88,8 +88,10 @@
       speexNB_bytes2samples, speexNB_samples2bytes)
 END_CODECS
   
+/*  TODO: wideband! */
+
 BEGIN_PAYLOADS
-PAYLOAD(-1, "speex", 8000, 1, CODEC_SPEEX_NB, AMCI_PT_AUDIO_FRAME)
+PAYLOAD(-1, "speex", 8000, 8000, 1, CODEC_SPEEX_NB, AMCI_PT_AUDIO_FRAME)
 END_PAYLOADS
   
 BEGIN_FILE_FORMATS

Modified: branches/wb/core/plug-in/wav/wav.c
===================================================================
--- branches/wb/core/plug-in/wav/wav.c  2008-08-21 17:27:45 UTC (rev 1069)
+++ branches/wb/core/plug-in/wav/wav.c  2008-08-21 18:29:40 UTC (rev 1070)
@@ -52,8 +52,8 @@
  END_CODECS
     
  BEGIN_PAYLOADS
- PAYLOAD( 0, "ulaw", 1, 8000, 1, CODEC_ULAW )
- PAYLOAD( 8, "alaw", 1, 8000, 1, CODEC_ALAW )
+ PAYLOAD( 0, "ulaw", 1, 8000, 8000,1, CODEC_ULAW )
+ PAYLOAD( 8, "alaw", 1, 8000, 8000,1, CODEC_ALAW )
  END_PAYLOADS
 
  BEGIN_FILE_FORMATS
@@ -104,9 +104,9 @@
      END_CODECS
     
 BEGIN_PAYLOADS
-PAYLOAD( 0, "PCMU", 8000, 1, CODEC_ULAW, AMCI_PT_AUDIO_LINEAR )
-     PAYLOAD( 8, "PCMA", 8000, 1, CODEC_ALAW, AMCI_PT_AUDIO_LINEAR )
-     END_PAYLOADS
+PAYLOAD( 0, "PCMU", 8000, 8000, 1, CODEC_ULAW, AMCI_PT_AUDIO_LINEAR )
+PAYLOAD( 8, "PCMA", 8000, 8000, 1, CODEC_ALAW, AMCI_PT_AUDIO_LINEAR )
+END_PAYLOADS
 
 BEGIN_FILE_FORMATS
 BEGIN_FILE_FORMAT( "Wav", "wav", "audio/x-wav", wav_open, wav_close, 
wav_mem_open, wav_mem_close)

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

Reply via email to