- Timestamp:
- Dec 10, 2010 11:04:30 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia/stereo_port.c
r2394 r3392 40 40 41 41 static pj_status_t stereo_put_frame(pjmedia_port *this_port, 42 constpjmedia_frame *frame);42 pjmedia_frame *frame); 43 43 static pj_status_t stereo_get_frame(pjmedia_port *this_port, 44 44 pjmedia_frame *frame); … … 61 61 62 62 /* Only supports 16bit samples per frame */ 63 PJ_ASSERT_RETURN(dn_port->info.bits_per_sample == 16, PJMEDIA_ENCBITS); 63 PJ_ASSERT_RETURN(PJMEDIA_PIA_BITS(&dn_port->info) == 16, 64 PJMEDIA_ENCBITS); 64 65 65 66 /* Validate channel counts */ 66 PJ_ASSERT_RETURN(((dn_port->info.channel_count>1 && channel_count==1) || 67 (dn_port->info.channel_count==1 && channel_count>1)), 67 PJ_ASSERT_RETURN(((PJMEDIA_PIA_CCNT(&dn_port->info)>1 && 68 channel_count==1) || 69 (PJMEDIA_PIA_CCNT(&dn_port->info)==1 && 70 channel_count>1)), 68 71 PJ_EINVAL); 69 72 … … 72 75 PJ_ASSERT_RETURN(sport != NULL, PJ_ENOMEM); 73 76 74 samples_per_frame = dn_port->info.samples_per_frame* channel_count /75 dn_port->info.channel_count;77 samples_per_frame = PJMEDIA_PIA_SPF(&dn_port->info) * channel_count / 78 PJMEDIA_PIA_CCNT(&dn_port->info); 76 79 77 80 pjmedia_port_info_init(&sport->base.info, &name, SIGNATURE, 78 dn_port->info.clock_rate,81 PJMEDIA_PIA_SRATE(&dn_port->info), 79 82 channel_count, 80 dn_port->info.bits_per_sample,83 PJMEDIA_PIA_BITS(&dn_port->info), 81 84 samples_per_frame); 82 85 … … 86 89 /* We always need buffer for put_frame */ 87 90 sport->put_buf = (pj_int16_t*) 88 pj_pool_alloc(pool, dn_port->info.bytes_per_frame); 91 pj_pool_alloc(pool, 92 PJMEDIA_PIA_AVG_FSZ(&dn_port->info)); 89 93 90 94 /* See if we need buffer for get_frame */ 91 if ( dn_port->info.channel_count> channel_count) {95 if (PJMEDIA_PIA_CCNT(&dn_port->info) > channel_count) { 92 96 sport->get_buf = (pj_int16_t*) 93 pj_pool_alloc(pool, dn_port->info.bytes_per_frame); 97 pj_pool_alloc(pool, 98 PJMEDIA_PIA_AVG_FSZ(&dn_port->info)); 94 99 } 95 100 … … 107 112 108 113 static pj_status_t stereo_put_frame(pjmedia_port *this_port, 109 constpjmedia_frame *frame)114 pjmedia_frame *frame) 110 115 { 111 116 struct stereo_port *sport = (struct stereo_port*) this_port; 117 const pjmedia_audio_format_detail *s_afd, *dn_afd; 112 118 pjmedia_frame tmp_frame; 113 119 … … 117 123 } 118 124 125 s_afd = pjmedia_format_get_audio_format_detail(&this_port->info.fmt, 1); 126 dn_afd = pjmedia_format_get_audio_format_detail(&sport->dn_port->info.fmt, 127 1); 128 119 129 if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) { 120 130 tmp_frame.buf = sport->put_buf; 121 if ( sport->dn_port->info.channel_count == 1) {131 if (dn_afd->channel_count == 1) { 122 132 pjmedia_convert_channel_nto1((pj_int16_t*)tmp_frame.buf, 123 133 (const pj_int16_t*)frame->buf, 124 s port->base.info.channel_count,125 sport->base.info.samples_per_frame,134 s_afd->channel_count, 135 PJMEDIA_AFD_SPF(s_afd), 126 136 (sport->options & PJMEDIA_STEREO_MIX), 127 137 0); … … 129 139 pjmedia_convert_channel_1ton((pj_int16_t*)tmp_frame.buf, 130 140 (const pj_int16_t*)frame->buf, 131 sport->dn_port->info.channel_count,132 sport->base.info.samples_per_frame,141 dn_afd->channel_count, 142 PJMEDIA_AFD_SPF(s_afd), 133 143 sport->options); 134 144 } 135 tmp_frame.size = sport->dn_port->info.bytes_per_frame;145 tmp_frame.size = PJMEDIA_AFD_AVG_FSZ(dn_afd); 136 146 } else { 137 147 tmp_frame.buf = frame->buf; … … 151 161 { 152 162 struct stereo_port *sport = (struct stereo_port*) this_port; 163 const pjmedia_audio_format_detail *s_afd, *dn_afd; 153 164 pjmedia_frame tmp_frame; 154 165 pj_status_t status; … … 160 171 } 161 172 173 s_afd = pjmedia_format_get_audio_format_detail(&this_port->info.fmt, 1); 174 dn_afd = pjmedia_format_get_audio_format_detail(&sport->dn_port->info.fmt, 175 1); 176 162 177 tmp_frame.buf = sport->get_buf? sport->get_buf : frame->buf; 163 tmp_frame.size = sport->dn_port->info.bytes_per_frame;178 tmp_frame.size = PJMEDIA_PIA_AVG_FSZ(&sport->dn_port->info); 164 179 tmp_frame.timestamp.u64 = frame->timestamp.u64; 165 180 tmp_frame.type = PJMEDIA_FRAME_TYPE_AUDIO; … … 178 193 } 179 194 180 if (s port->base.info.channel_count == 1) {195 if (s_afd->channel_count == 1) { 181 196 pjmedia_convert_channel_nto1((pj_int16_t*)frame->buf, 182 197 (const pj_int16_t*)tmp_frame.buf, 183 sport->dn_port->info.channel_count,184 sport->dn_port->info.samples_per_frame,198 dn_afd->channel_count, 199 PJMEDIA_AFD_SPF(s_afd), 185 200 (sport->options & PJMEDIA_STEREO_MIX), 0); 186 201 } else { 187 202 pjmedia_convert_channel_1ton((pj_int16_t*)frame->buf, 188 203 (const pj_int16_t*)tmp_frame.buf, 189 s port->base.info.channel_count,190 sport->dn_port->info.samples_per_frame,204 s_afd->channel_count, 205 PJMEDIA_AFD_SPF(dn_afd), 191 206 sport->options); 192 207 } 193 208 194 frame->size = sport->base.info.bytes_per_frame;209 frame->size = PJMEDIA_AFD_AVG_FSZ(s_afd); 195 210 frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 196 211
Note: See TracChangeset
for help on using the changeset viewer.