Changeset 1985
- Timestamp:
- Jun 6, 2008 12:15:23 PM (16 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/codec.h
r1983 r1985 254 254 unsigned channel_cnt; /**< Channel count. */ 255 255 pj_uint32_t avg_bps; /**< Average bandwidth in bits/sec */ 256 pj_uint32_t max_bps; /**< Maximum bandwidth in bits/sec */ 256 257 pj_uint16_t frm_ptime; /**< Decoder frame ptime in msec. */ 257 258 pj_uint16_t enc_ptime; /**< Encoder ptime, or zero if it's -
pjproject/trunk/pjmedia/src/pjmedia-codec/g722.c
r1983 r1985 271 271 attr->info.channel_cnt = 1; 272 272 attr->info.avg_bps = 64000; 273 attr->info.max_bps = 64000; 273 274 attr->info.pcm_bits_per_sample = 16; 274 275 attr->info.frm_ptime = PTIME; -
pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c
r1983 r1985 265 265 attr->info.channel_cnt = 1; 266 266 attr->info.avg_bps = 13200; 267 attr->info.max_bps = 13200; 267 268 attr->info.pcm_bits_per_sample = 16; 268 269 attr->info.frm_ptime = 20; -
pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c
r1983 r1985 265 265 attr->info.channel_cnt = 1; 266 266 attr->info.avg_bps = ilbc_factory.bps; 267 attr->info.max_bps = 15200; 267 268 attr->info.pcm_bits_per_sample = 16; 268 269 attr->info.frm_ptime = (short)ilbc_factory.mode; -
pjproject/trunk/pjmedia/src/pjmedia-codec/l16.c
r1983 r1985 243 243 attr->info.channel_cnt = id->channel_cnt; 244 244 attr->info.avg_bps = id->clock_rate * id->channel_cnt * 16; 245 attr->info.max_bps = attr->info.avg_bps; 245 246 attr->info.pcm_bits_per_sample = 16; 246 247 -
pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
r1983 r1985 122 122 int framesize; /* Frame size for current mode. */ 123 123 int bitrate; /* Bit rate for current mode. */ 124 int max_bitrate; /* Max bit rate for current mode. */ 124 125 }; 125 126 … … 161 162 return PJMEDIA_CODEC_EFAILED; 162 163 163 /* We have to get maximum bitrate, so let's set maximumquality */164 tmp = 10;165 speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp);164 /* Set the quality */ 165 if (p->quality != -1) 166 speex_encoder_ctl(state, SPEEX_SET_QUALITY, &p->quality); 166 167 167 168 /* Sampling rate. */ … … 179 180 speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &p->samples_per_frame); 180 181 181 /* Now get the the averate bitrate */182 /* Now get the average bitrate */ 182 183 speex_encoder_ctl(state, SPEEX_GET_BITRATE, &p->bitrate); 183 184 184 185 /* Calculate framesize. */ 185 186 p->framesize = p->bitrate * 20 / 1000; 187 188 /* Now get the maximum bitrate by using maximum quality (=10) */ 189 tmp = 10; 190 speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp); 191 speex_encoder_ctl(state, SPEEX_GET_BITRATE, &p->max_bitrate); 186 192 187 193 /* Destroy encoder. */ … … 238 244 ((options & PJMEDIA_SPEEX_NO_NB) == 0); 239 245 spx_factory.speex_param[PARAM_NB].pt = PJMEDIA_RTP_PT_SPEEX_NB; 240 spx_factory.speex_param[PARAM_NB].mode = &speex_nb_mode;246 spx_factory.speex_param[PARAM_NB].mode = speex_lib_get_mode(SPEEX_MODEID_NB); 241 247 spx_factory.speex_param[PARAM_NB].clock_rate = 8000; 242 248 spx_factory.speex_param[PARAM_NB].quality = quality; … … 246 252 ((options & PJMEDIA_SPEEX_NO_WB) == 0); 247 253 spx_factory.speex_param[PARAM_WB].pt = PJMEDIA_RTP_PT_SPEEX_WB; 248 spx_factory.speex_param[PARAM_WB].mode = &speex_wb_mode;254 spx_factory.speex_param[PARAM_WB].mode = speex_lib_get_mode(SPEEX_MODEID_WB); 249 255 spx_factory.speex_param[PARAM_WB].clock_rate = 16000; 250 256 spx_factory.speex_param[PARAM_WB].quality = quality; … … 254 260 ((options & PJMEDIA_SPEEX_NO_UWB) == 0); 255 261 spx_factory.speex_param[PARAM_UWB].pt = PJMEDIA_RTP_PT_SPEEX_UWB; 256 spx_factory.speex_param[PARAM_UWB].mode = &speex_uwb_mode;262 spx_factory.speex_param[PARAM_UWB].mode = speex_lib_get_mode(SPEEX_MODEID_UWB); 257 263 spx_factory.speex_param[PARAM_UWB].clock_rate = 32000; 258 264 spx_factory.speex_param[PARAM_UWB].quality = quality; … … 438 444 attr->info.clock_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 439 445 attr->info.avg_bps = spx_factory.speex_param[PARAM_NB].bitrate; 446 attr->info.max_bps = spx_factory.speex_param[PARAM_NB].max_bitrate; 440 447 441 448 } else if (id->clock_rate <= 16000) { 442 449 attr->info.clock_rate = spx_factory.speex_param[PARAM_WB].clock_rate; 443 450 attr->info.avg_bps = spx_factory.speex_param[PARAM_WB].bitrate; 451 attr->info.max_bps = spx_factory.speex_param[PARAM_WB].max_bitrate; 444 452 445 453 } else { … … 447 455 attr->info.clock_rate = spx_factory.speex_param[PARAM_UWB].clock_rate; 448 456 attr->info.avg_bps = spx_factory.speex_param[PARAM_UWB].bitrate; 457 attr->info.max_bps = spx_factory.speex_param[PARAM_UWB].max_bitrate; 449 458 } 450 459 -
pjproject/trunk/pjmedia/src/pjmedia/codec.c
r1417 r1985 386 386 387 387 status = (*factory->op->default_attr)(factory, info, param); 388 if (status == PJ_SUCCESS) 388 if (status == PJ_SUCCESS) { 389 /* Check for invalid max_bps. */ 390 if (param->info.max_bps < param->info.avg_bps) 391 param->info.max_bps = param->info.avg_bps; 392 389 393 return PJ_SUCCESS; 394 } 390 395 391 396 } -
pjproject/trunk/pjmedia/src/pjmedia/g711.c
r1929 r1985 250 250 attr->info.channel_cnt = 1; 251 251 attr->info.avg_bps = G711_BPS; 252 attr->info.max_bps = G711_BPS; 252 253 attr->info.pcm_bits_per_sample = 16; 253 254 attr->info.frm_ptime = PTIME; -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r1983 r1985 1264 1264 1265 1265 channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) + 1266 stream->codec_param.info. avg_bps/8*1266 stream->codec_param.info.max_bps * 1267 1267 PJMEDIA_MAX_FRAME_DURATION_MS / 1268 1000;1268 8 / 1000; 1269 1269 1270 1270 if (channel->out_pkt_size > PJMEDIA_MAX_MTU) … … 1374 1374 } 1375 1375 1376 /* Check for invalid max_bps. */ 1377 if (stream->codec_param.info.max_bps < stream->codec_param.info.avg_bps) 1378 stream->codec_param.info.max_bps = stream->codec_param.info.avg_bps; 1379 1376 1380 /* Check for invalid frame per packet. */ 1377 1381 if (stream->codec_param.setting.frm_per_pkt < 1) … … 1385 1389 stream->codec_param.setting.frm_per_pkt / 1386 1390 1000; 1387 stream->port.info.bytes_per_frame = stream->codec_param.info. avg_bps/8*1391 stream->port.info.bytes_per_frame = stream->codec_param.info.max_bps * 1388 1392 stream->codec_param.info.frm_ptime * 1389 1393 stream->codec_param.setting.frm_per_pkt / 1390 1000; 1394 8 / 1000; 1395 if ((stream->codec_param.info.max_bps * stream->codec_param.info.frm_ptime * 1396 stream->codec_param.setting.frm_per_pkt) % 8000 != 0) 1397 { 1398 ++stream->port.info.bytes_per_frame; 1399 } 1391 1400 1392 1401 /* Open the codec: */ … … 1442 1451 } 1443 1452 1444 /* Get the frame size: */ 1445 1446 stream->frame_size = ((stream->codec_param.info.avg_bps + 7) / 8) * 1447 stream->codec_param.info.frm_ptime / 1000; 1448 1453 /* Get the frame size */ 1454 stream->frame_size = stream->codec_param.info.max_bps * 1455 stream->codec_param.info.frm_ptime / 8 / 1000; 1456 if ((stream->codec_param.info.max_bps * stream->codec_param.info.frm_ptime) 1457 % 8000 != 0) 1458 { 1459 ++stream->frame_size; 1460 } 1449 1461 1450 1462 #if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0)
Note: See TracChangeset
for help on using the changeset viewer.