Changeset 417 for pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
- Timestamp:
- Apr 28, 2006 2:48:02 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r415 r417 19 19 #include <pjmedia/sound_port.h> 20 20 #include <pjmedia/errno.h> 21 #include <pjmedia/plc.h> 21 22 #include <pj/assert.h> 22 23 #include <pj/log.h> … … 25 26 26 27 27 //#define SIMULATE_LOST_PCT 1028 //#define SIMULATE_LOST_PCT 20 28 29 29 30 … … 35 36 }; 36 37 37 #define DEFAULT_OPTIONS PJMEDIA_PLC_ENABLED38 38 //#define DEFAULT_OPTIONS PJMEDIA_PLC_ENABLED 39 #define DEFAULT_OPTIONS 0 39 40 40 41 … … 48 49 unsigned options; 49 50 50 void *last_frame; 51 unsigned last_frame_size; 52 unsigned last_replay_count; 51 pjmedia_plc *plc; 53 52 54 53 unsigned clock_rate; … … 104 103 #endif 105 104 106 /* Keep frame if PLC is enabled. */ 107 if (snd_port->options & PJMEDIA_PLC_ENABLED) { 108 /* Must have the same length as last_frame_size */ 109 pj_assert(frame.size == snd_port->last_frame_size); 110 111 /* Copy frame to last_frame */ 112 pj_memcpy(snd_port->last_frame, output, snd_port->last_frame_size); 113 114 snd_port->last_replay_count = 0; 115 } 105 if (snd_port->plc) 106 pjmedia_plc_save(snd_port->plc, output); 116 107 117 108 return PJ_SUCCESS; … … 119 110 no_frame: 120 111 121 /* Replay last frame if PLC is enabled */ 122 if ((snd_port->options & PJMEDIA_PLC_ENABLED) && 123 snd_port->last_replay_count < 8) 124 { 125 126 /* Must have the same length as last_frame_size */ 127 pj_assert(size == snd_port->last_frame_size); 128 129 /* Replay last frame */ 130 pj_memcpy(output, snd_port->last_frame, snd_port->last_frame_size); 131 132 /* Reduce replay frame signal level to half */ 133 if (snd_port->bits_per_sample == 16) { 134 unsigned i, count; 135 pj_int16_t *samp; 136 137 count = snd_port->last_frame_size / 2; 138 samp = (pj_int16_t *) snd_port->last_frame; 139 140 for (i=0; i<count; ++i) 141 samp[i] = (pj_int16_t) (samp[i] >> 2); 142 143 } 144 112 /* Apply PLC */ 113 if (snd_port->plc) { 114 115 pjmedia_plc_generate(snd_port->plc, output); 145 116 #ifdef SIMULATE_LOST_PCT 146 PJ_LOG(4,(THIS_FILE, " Frame replayed"));117 PJ_LOG(4,(THIS_FILE, "Lost frame generated")); 147 118 #endif 148 149 ++snd_port->last_replay_count;150 151 } else {152 153 /* Just zero the frame */154 pj_memset(output, 0, size);155 156 119 } 157 120 … … 255 218 (snd_port->options & PJMEDIA_PLC_ENABLED)) 256 219 { 257 258 snd_port->last_frame_size = snd_port->samples_per_frame *259 snd_port->channel_count *260 snd_port->bits_per_sample / 8;261 snd_port->last_frame = pj_pool_zalloc(pool,262 snd_port->last_frame_size);220 status = pjmedia_plc_create(pool, snd_port->clock_rate, 221 snd_port->samples_per_frame * 222 snd_port->channel_count, 223 0, &snd_port->plc); 224 if (status != PJ_SUCCESS) 225 snd_port->plc = NULL; 263 226 } 264 227
Note: See TracChangeset
for help on using the changeset viewer.