Changeset 1965 for pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
- Timestamp:
- May 27, 2008 12:24:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
r1677 r1965 37 37 38 38 #define THIS_FILE "speex_codec.c" 39 40 #define DEFAULT_QUALITY 1041 #define DEFAULT_COMPLEXITY 1042 39 43 40 /* Prototypes for Speex factory */ … … 212 209 213 210 /* Get defaults */ 214 if (quality <= 0) quality = DEFAULT_QUALITY; 215 if (complexity <= 0) complexity = DEFAULT_COMPLEXITY; 211 if (quality < 0) quality = PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY; 212 if (complexity < 0) complexity = PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY; 213 214 /* Validate quality & complexity */ 215 PJ_ASSERT_RETURN(quality >= 0 && quality <= 10, PJ_EINVAL); 216 PJ_ASSERT_RETURN(complexity >= 1 && complexity <= 10, PJ_EINVAL); 216 217 217 218 /* Create Speex codec factory. */ … … 298 299 { 299 300 return pjmedia_codec_speex_init(endpt, 0, -1, -1); 301 } 302 303 /* 304 * Change the settings of Speex codec. 305 */ 306 PJ_DEF(pj_status_t) pjmedia_codec_speex_set_param(unsigned clock_rate, 307 int quality, 308 int complexity) 309 { 310 unsigned i; 311 312 /* Get defaults */ 313 if (quality < 0) quality = PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY; 314 if (complexity < 0) complexity = PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY; 315 316 /* Validate quality & complexity */ 317 PJ_ASSERT_RETURN(quality >= 0 && quality <= 10, PJ_EINVAL); 318 PJ_ASSERT_RETURN(complexity >= 1 && complexity <= 10, PJ_EINVAL); 319 320 /* Apply the settings */ 321 for (i=0; i<PJ_ARRAY_SIZE(spx_factory.speex_param); ++i) { 322 if (spx_factory.speex_param[i].clock_rate == clock_rate) { 323 pj_status_t status; 324 325 spx_factory.speex_param[i].quality = quality; 326 spx_factory.speex_param[i].complexity = complexity; 327 328 /* Somehow quality<=4 is broken in linux. */ 329 if (i == PARAM_UWB && quality <= 4 && quality >= 0) { 330 PJ_LOG(5,(THIS_FILE, "Adjusting quality to 5 for uwb")); 331 spx_factory.speex_param[PARAM_UWB].quality = 5; 332 } 333 334 status = get_speex_info(&spx_factory.speex_param[i]); 335 336 return status; 337 } 338 } 339 340 return PJ_EINVAL; 300 341 } 301 342
Note: See TracChangeset
for help on using the changeset viewer.