Changeset 1641 for pjproject/trunk
- Timestamp:
- Dec 28, 2007 6:55:02 PM (17 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/config_site_sample.h
r1576 r1641 77 77 # define PJSIP_MAX_DIALOG_COUNT 31 78 78 # define PJSUA_MAX_CALLS 31 79 79 80 # define PJMEDIA_SOUND_BUFFER_COUNT 12 81 80 82 #endif 81 83 -
pjproject/trunk/pjmedia/src/pjmedia/symbian_sound.cpp
r1428 r1641 65 65 66 66 // Common settings. 67 pjmedia_dir dir; 67 68 unsigned clock_rate; 68 69 unsigned channel_count; … … 163 164 pj_uint32_t timeStamp_; 164 165 166 // cache variable 167 // to avoid calculating frame length repeatedly 168 TInt frameLen_; 169 170 // in some SymbianOS (e.g: OSv9.1), sometimes recorded size != requested framesize 171 // so let's provide a buffer to make sure the rec callback returns framesize as requested. 172 TUint8 *frameRecBuf_; 173 TInt frameRecBufLen_; 174 165 175 CPjAudioInputEngine(pjmedia_snd_stream *parent_strm, 166 176 pjmedia_snd_rec_cb rec_cb, … … 180 190 pjmedia_snd_rec_cb rec_cb, 181 191 void *user_data) 182 : state_(STATE_INACTIVE), parentStrm_(parent_strm), recCb_(rec_cb), 192 : state_(STATE_INACTIVE), parentStrm_(parent_strm), 193 recCb_(rec_cb), userData_(user_data), 183 194 iInputStream_(NULL), iStreamBuffer_(NULL), iFramePtr_(0, 0), 184 userData_(user_data), lastError_(KErrNone), timeStamp_(0) 195 lastError_(KErrNone), timeStamp_(0), 196 frameLen_(parent_strm->samples_per_frame * parent_strm->channel_count * BYTES_PER_SAMPLE), 197 frameRecBuf_(NULL), frameRecBufLen_(0) 185 198 { 186 199 } … … 189 202 { 190 203 Stop(); 204 191 205 delete iStreamBuffer_; 192 206 iStreamBuffer_ = NULL; 207 208 delete [] frameRecBuf_; 209 frameRecBuf_ = NULL; 210 frameRecBufLen_ = 0; 193 211 } 194 212 195 213 void CPjAudioInputEngine::ConstructL() 196 214 { 197 iStreamBuffer_ = HBufC8::NewL(parentStrm_->samples_per_frame * 198 parentStrm_->channel_count * 199 BYTES_PER_SAMPLE); 215 iStreamBuffer_ = HBufC8::NewL(frameLen_); 216 CleanupStack::PushL(iStreamBuffer_); 217 218 frameRecBuf_ = new TUint8[frameLen_*2]; 219 CleanupStack::PushL(frameRecBuf_); 200 220 } 201 221 … … 217 237 { 218 238 CPjAudioInputEngine *self = NewLC(parent, rec_cb, user_data); 239 CleanupStack::Pop(self->frameRecBuf_); 240 CleanupStack::Pop(self->iStreamBuffer_); 219 241 CleanupStack::Pop(self); 220 242 return self; … … 290 312 TPtr8 & CPjAudioInputEngine::GetFrame() 291 313 { 292 TInt l = parentStrm_->samples_per_frame * 293 parentStrm_->channel_count * 294 BYTES_PER_SAMPLE; 295 iStreamBuffer_->Des().FillZ(l); 296 iFramePtr_.Set((TUint8*)(iStreamBuffer_->Ptr()), l, l); 314 //iStreamBuffer_->Des().FillZ(frameLen_); 315 iFramePtr_.Set((TUint8*)(iStreamBuffer_->Ptr()), frameLen_, frameLen_); 297 316 return iFramePtr_; 298 317 } … … 327 346 } 328 347 329 // Call the callback. 330 recCb_(userData_, timeStamp_, (void*)aBuffer.Ptr(), aBuffer.Size()); 331 332 // Increment timestamp. 333 timeStamp_ += (aBuffer.Size() * BYTES_PER_SAMPLE); 348 if (frameRecBufLen_ || aBuffer.Size() < frameLen_) { 349 pj_memcpy(frameRecBuf_ + frameRecBufLen_, (void*) aBuffer.Ptr(), aBuffer.Size()); 350 frameRecBufLen_ += aBuffer.Size(); 351 } 352 353 if (frameRecBufLen_) { 354 while (frameRecBufLen_ >= frameLen_) { 355 // Call the callback. 356 recCb_(userData_, timeStamp_, frameRecBuf_, frameLen_); 357 // Increment timestamp. 358 timeStamp_ += parentStrm_->samples_per_frame; 359 360 frameRecBufLen_ -= frameLen_; 361 pj_memmove(frameRecBuf_, frameRecBuf_+frameLen_, frameRecBufLen_); 362 } 363 } else { 364 // Call the callback. 365 recCb_(userData_, timeStamp_, (void*) aBuffer.Ptr(), aBuffer.Size()); 366 // Increment timestamp. 367 timeStamp_ += parentStrm_->samples_per_frame; 368 } 334 369 335 370 // Record next frame … … 526 561 iSettings.iChannels); 527 562 528 // set volume to 1/ 4th of stream max volume529 iOutputStream_->SetVolume(iOutputStream_->MaxVolume()/ 4);563 // set volume to 1/2th of stream max volume 564 iOutputStream_->SetVolume(iOutputStream_->MaxVolume()/2); 530 565 531 566 // set stream priority to normal and time sensitive … … 629 664 { 630 665 /* Always return the default sound device */ 666 if (index == (unsigned)-1) 667 index = 0; 668 631 669 PJ_ASSERT_RETURN(index==0, NULL); 632 670 return &symbian_snd_dev_info; … … 663 701 strm = (pjmedia_snd_stream*) pj_pool_zalloc(pool, 664 702 sizeof(pjmedia_snd_stream)); 703 strm->dir = PJMEDIA_DIR_CAPTURE; 665 704 strm->pool = pool; 666 705 strm->clock_rate = clock_rate; … … 677 716 if (err != KErrNone) { 678 717 pj_pool_release(pool); 679 return PJ_RETURN_OS_ERROR(err); 680 } 681 718 return PJ_RETURN_OS_ERROR(err); 719 } 682 720 683 721 // Done. … … 711 749 strm = (pjmedia_snd_stream*) pj_pool_zalloc(pool, 712 750 sizeof(pjmedia_snd_stream)); 751 strm->dir = PJMEDIA_DIR_PLAYBACK; 713 752 strm->pool = pool; 714 753 strm->clock_rate = clock_rate; … … 762 801 strm = (pjmedia_snd_stream*) pj_pool_zalloc(pool, 763 802 sizeof(pjmedia_snd_stream)); 803 strm->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 764 804 strm->pool = pool; 765 805 strm->clock_rate = clock_rate; … … 795 835 } 796 836 837 /* 838 * Get stream info. 839 */ 840 PJ_DEF(pj_status_t) pjmedia_snd_stream_get_info(pjmedia_snd_stream *strm, 841 pjmedia_snd_stream_info *pi) 842 { 843 PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL); 844 845 pj_bzero(pi, sizeof(*pi)); 846 pi->dir = strm->dir; 847 pi->play_id = 0; 848 pi->rec_id = 0; 849 pi->clock_rate = strm->clock_rate; 850 pi->channel_count = strm->channel_count; 851 pi->samples_per_frame = strm->samples_per_frame; 852 pi->bits_per_sample = BYTES_PER_SAMPLE * 8; 853 pi->rec_latency = 0; 854 pi->play_latency = 0; 855 856 return PJ_SUCCESS; 857 } 858 797 859 798 860 PJ_DEF(pj_status_t) pjmedia_snd_stream_start(pjmedia_snd_stream *stream) -
pjproject/trunk/pjsip-apps/src/symbian_ua/ua.cpp
r1606 r1641 32 32 // Destination URI (to make call, or to subscribe presence) 33 33 // 34 #define SIP_DST_URI "sip:192.168.0. 7:5061"34 #define SIP_DST_URI "sip:192.168.0.11:5060" 35 35 36 36 // … … 58 58 // 59 59 // STUN server 60 #if 160 #if 0 61 61 // Use this to have the STUN server resolved normally 62 62 # define STUN_DOMAIN NULL … … 75 75 // Use ICE? 76 76 // 77 #define USE_ICE 177 #define USE_ICE 0 78 78 79 79 … … 321 321 med_cfg.has_ioqueue = PJ_FALSE; 322 322 med_cfg.clock_rate = 8000; 323 med_cfg.audio_frame_ptime = 40; 323 324 med_cfg.ec_tail_len = 0; 324 325 med_cfg.enable_ice = USE_ICE; … … 453 454 " D Dump states detail\n" 454 455 " P Dump pool factory\n" 456 " l Start loopback audio device\n" 457 " L Stop loopback audio device\n" 455 458 " m Call " SIP_DST_URI "\n" 456 459 " a Answer call\n" … … 482 485 pj_pool_factory_dump(pjsua_get_pool_factory(), PJ_TRUE); 483 486 break; 487 case 'l': 488 pjsua_conf_connect(0, 0); 489 break; 490 case 'L': 491 pjsua_conf_disconnect(0, 0); 492 break; 484 493 case 'm': 485 494 if (g_call_id != PJSUA_INVALID_ID) { -
pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp
r1428 r1641 29 29 #define CHANNEL_COUNT 1 30 30 #define PTIME 100 31 #define SAMPLES_PER_FRAME ( 2048)31 #define SAMPLES_PER_FRAME (80) 32 32 #define BITS_PER_SAMPLE 16 33 33 #define LOOPBACK_BUFF_COUNT 100 34 34 35 35 extern CConsoleBase* console; … … 40 40 static pj_time_val t_start; 41 41 42 43 static pj_int16_t buff_loopback[SAMPLES_PER_FRAME*LOOPBACK_BUFF_COUNT]; 44 static pj_uint32_t pointer_w, pointer_r; 42 45 43 46 /* Logging callback */ … … 71 74 pj_log_set_log_func((void (*)(int,const char*,int)) &log_writer); 72 75 pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 76 pj_log_set_level(5); 73 77 74 78 /* Init pjlib */ … … 115 119 PJ_UNUSED_ARG(input); 116 120 PJ_UNUSED_ARG(size); 121 122 pj_memcpy(&buff_loopback[pointer_w*SAMPLES_PER_FRAME], input, size); 123 124 if (size != SAMPLES_PER_FRAME*2) { 125 PJ_LOG(3, (THIS_FILE, "Size captured = %u", 126 size)); 127 pj_bzero(&buff_loopback[pointer_w*SAMPLES_PER_FRAME]+size/2, SAMPLES_PER_FRAME*2 - size); 128 } 129 130 if (++pointer_w >= LOOPBACK_BUFF_COUNT) { 131 pointer_w = 0; 132 } 117 133 118 134 ++rec_cnt; … … 129 145 PJ_UNUSED_ARG(timestamp); 130 146 131 pj_bzero(output, size); 147 //pj_bzero(output, size); 148 pj_memcpy(output, &buff_loopback[pointer_r*SAMPLES_PER_FRAME], SAMPLES_PER_FRAME*2); 149 150 if (++pointer_r >= LOOPBACK_BUFF_COUNT) { 151 pointer_r = 0; 152 } 132 153 133 154 ++play_cnt; … … 174 195 } 175 196 197 pointer_w = LOOPBACK_BUFF_COUNT/2; 198 pointer_r = 0; 199 176 200 return PJ_SUCCESS; 177 201 } … … 298 322 case 'p': 299 323 snd_start(PJMEDIA_DIR_PLAYBACK); 300 324 break; 301 325 case 'c': 302 326 snd_stop();
Note: See TracChangeset
for help on using the changeset viewer.