Changeset 3664 for pjproject/trunk/pjsip-apps/src/samples/playsine.c
- Timestamp:
- Jul 19, 2011 3:42:28 AM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
- Property svn:mergeinfo changed
-
pjproject/trunk/pjsip-apps/src/samples/playsine.c
r3553 r3664 87 87 88 88 /* Get number of samples */ 89 count = frame->size / 2 / port->info.channel_count;89 count = frame->size / 2 / PJMEDIA_PIA_CCNT(&port->info); 90 90 91 91 left = 0; … … 96 96 ++left; 97 97 98 if ( port->info.channel_count== 2) {98 if (PJMEDIA_PIA_CCNT(&port->info) == 2) { 99 99 *samples++ = sine->samples[right]; 100 100 right += 2; /* higher pitch so we can distinguish left and right. */ … … 127 127 unsigned i; 128 128 unsigned count; 129 pj_str_t name; 129 130 port_data *sine; 130 131 … … 136 137 137 138 /* Fill in port info. */ 138 port->info.bits_per_sample = 16; 139 port->info.channel_count = channel_count; 140 port->info.encoding_name = pj_str("pcm"); 141 port->info.has_info = 1; 142 port->info.name = pj_str("sine generator"); 143 port->info.need_info = 0; 144 port->info.pt = 0xFF; 145 port->info.clock_rate = sampling_rate; 146 port->info.samples_per_frame = sampling_rate * 20 / 1000 * channel_count; 147 port->info.bytes_per_frame = port->info.samples_per_frame * 2; 148 port->info.type = PJMEDIA_TYPE_AUDIO; 139 name = pj_str("sine generator"); 140 pjmedia_port_info_init(&port->info, &name, 141 PJMEDIA_SIG_CLASS_PORT_AUD('s', 'i'), 142 sampling_rate, 143 channel_count, 144 16, sampling_rate * 20 / 1000 * channel_count); 149 145 150 146 /* Set the function to feed frame */ … … 155 151 156 152 /* Create samples */ 157 count = port->info.samples_per_frame/ channel_count;153 count = PJMEDIA_PIA_SPF(&port->info) / channel_count; 158 154 sine->samples = pj_pool_alloc(pool, count * sizeof(pj_int16_t)); 159 155 PJ_ASSERT_RETURN(sine->samples != NULL, PJ_ENOMEM); … … 245 241 pool, /* pool */ 246 242 -1, /* use default dev. */ 247 sine_port->info.clock_rate,/* clock rate. */248 sine_port->info.channel_count,/* # of channels. */249 sine_port->info.samples_per_frame, /* samples per frame. */250 sine_port->info.bits_per_sample,/* bits per sample. */243 PJMEDIA_PIA_SRATE(&sine_port->info),/* clock rate. */ 244 PJMEDIA_PIA_CCNT(&sine_port->info),/* # of channels. */ 245 PJMEDIA_PIA_SPF(&sine_port->info), /* samples per frame. */ 246 PJMEDIA_PIA_BITS(&sine_port->info),/* bits per sample. */ 251 247 0, /* options */ 252 248 &snd_port /* returned port */
Note: See TracChangeset
for help on using the changeset viewer.