Changeset 278
- Timestamp:
- Mar 4, 2006 8:43:52 PM (19 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 102 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/pjmedia.dsp
r277 r278 206 206 # Begin Source File 207 207 208 SOURCE=..\include\pjmedia\g711.h 209 # End Source File 210 # Begin Source File 211 208 212 SOURCE=..\include\pjmedia\jbuf.h 209 213 # End Source File -
pjproject/trunk/pjmedia/build/pjmedia_codec.dsp
r198 r278 42 42 # PROP Target_Dir "" 43 43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 # ADD CPP /nologo /MD /W4 /GX /O2 /I "../include" /I "../../pjlib/include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /YX /FD /c 44 # ADD CPP /nologo /MD /W4 /GX- /O2 /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FD /c 45 # SUBTRACT CPP /YX 45 46 # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 47 # ADD RSC /l 0x409 /d "NDEBUG" … … 65 66 # PROP Target_Dir "" 66 67 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /YX /FD /GZ /c 68 # ADD CPP /nologo /MTd /W4 /Gm /GX- /ZI /Od /I "../include" /I "../../pjlib/include" /I "../src/pjmedia-codec" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "HAVE_CONFIG_H" /FR /FD /GZ /c 69 # SUBTRACT CPP /YX 68 70 # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 71 # ADD RSC /l 0x409 /d "_DEBUG" … … 92 94 SOURCE="..\src\pjmedia-codec\pjmedia-codec-lib.c" 93 95 # End Source File 96 # Begin Source File 97 98 SOURCE="..\src\pjmedia-codec\speex_codec.c" 99 # End Source File 94 100 # End Group 95 101 # Begin Group "Header Files" … … 110 116 # Begin Source File 111 117 118 SOURCE="..\include\pjmedia-codec\speex.h" 119 # End Source File 120 # Begin Source File 121 112 122 SOURCE="..\include\pjmedia-codec\types.h" 113 123 # End Source File … … 204 214 SOURCE="..\src\pjmedia-codec\gsm\unproto.h" 205 215 # End Source File 216 # End Group 217 # Begin Group "Speex Codec" 218 219 # PROP Default_Filter "" 220 # Begin Group "Speex Header Files" 221 222 # PROP Default_Filter "" 223 # Begin Source File 224 225 SOURCE="..\src\pjmedia-codec\speex\arch.h" 226 # End Source File 227 # Begin Source File 228 229 SOURCE="..\src\pjmedia-codec\speex\cb_search.h" 230 # End Source File 231 # Begin Source File 232 233 SOURCE="..\src\pjmedia-codec\speex\cb_search_arm4.h" 234 # End Source File 235 # Begin Source File 236 237 SOURCE="..\src\pjmedia-codec\speex\cb_search_bfin.h" 238 # End Source File 239 # Begin Source File 240 241 SOURCE="..\src\pjmedia-codec\speex\cb_search_sse.h" 242 # End Source File 243 # Begin Source File 244 245 SOURCE="..\src\pjmedia-codec\speex\config.h" 246 # End Source File 247 # Begin Source File 248 249 SOURCE="..\src\pjmedia-codec\speex\filters.h" 250 # End Source File 251 # Begin Source File 252 253 SOURCE="..\src\pjmedia-codec\speex\filters_arm4.h" 254 # End Source File 255 # Begin Source File 256 257 SOURCE="..\src\pjmedia-codec\speex\filters_bfin.h" 258 # End Source File 259 # Begin Source File 260 261 SOURCE="..\src\pjmedia-codec\speex\filters_sse.h" 262 # End Source File 263 # Begin Source File 264 265 SOURCE="..\src\pjmedia-codec\speex\fixed_arm4.h" 266 # End Source File 267 # Begin Source File 268 269 SOURCE="..\src\pjmedia-codec\speex\fixed_arm5e.h" 270 # End Source File 271 # Begin Source File 272 273 SOURCE="..\src\pjmedia-codec\speex\fixed_bfin.h" 274 # End Source File 275 # Begin Source File 276 277 SOURCE="..\src\pjmedia-codec\speex\fixed_debug.h" 278 # End Source File 279 # Begin Source File 280 281 SOURCE="..\src\pjmedia-codec\speex\fixed_generic.h" 282 # End Source File 283 # Begin Source File 284 285 SOURCE="..\src\pjmedia-codec\speex\lpc.h" 286 # End Source File 287 # Begin Source File 288 289 SOURCE="..\src\pjmedia-codec\speex\lpc_bfin.h" 290 # End Source File 291 # Begin Source File 292 293 SOURCE="..\src\pjmedia-codec\speex\lsp.h" 294 # End Source File 295 # Begin Source File 296 297 SOURCE="..\src\pjmedia-codec\speex\ltp.h" 298 # End Source File 299 # Begin Source File 300 301 SOURCE="..\src\pjmedia-codec\speex\ltp_arm4.h" 302 # End Source File 303 # Begin Source File 304 305 SOURCE="..\src\pjmedia-codec\speex\ltp_bfin.h" 306 # End Source File 307 # Begin Source File 308 309 SOURCE="..\src\pjmedia-codec\speex\ltp_sse.h" 310 # End Source File 311 # Begin Source File 312 313 SOURCE="..\src\pjmedia-codec\speex\math_approx.h" 314 # End Source File 315 # Begin Source File 316 317 SOURCE="..\src\pjmedia-codec\speex\misc.h" 318 # End Source File 319 # Begin Source File 320 321 SOURCE="..\src\pjmedia-codec\speex\misc_bfin.h" 322 # End Source File 323 # Begin Source File 324 325 SOURCE="..\src\pjmedia-codec\speex\modes.h" 326 # End Source File 327 # Begin Source File 328 329 SOURCE="..\src\pjmedia-codec\speex\nb_celp.h" 330 # End Source File 331 # Begin Source File 332 333 SOURCE="..\src\pjmedia-codec\speex\pseudofloat.h" 334 # End Source File 335 # Begin Source File 336 337 SOURCE="..\src\pjmedia-codec\speex\quant_lsp.h" 338 # End Source File 339 # Begin Source File 340 341 SOURCE="..\src\pjmedia-codec\speex\sb_celp.h" 342 # End Source File 343 # Begin Source File 344 345 SOURCE="..\src\pjmedia-codec\speex\smallft.h" 346 # End Source File 347 # Begin Source File 348 349 SOURCE="..\src\pjmedia-codec\speex\speex.h" 350 # End Source File 351 # Begin Source File 352 353 SOURCE="..\src\pjmedia-codec\speex\speex_bits.h" 354 # End Source File 355 # Begin Source File 356 357 SOURCE="..\src\pjmedia-codec\speex\speex_callbacks.h" 358 # End Source File 359 # Begin Source File 360 361 SOURCE="..\src\pjmedia-codec\speex\speex_echo.h" 362 # End Source File 363 # Begin Source File 364 365 SOURCE="..\src\pjmedia-codec\speex\speex_header.h" 366 # End Source File 367 # Begin Source File 368 369 SOURCE="..\src\pjmedia-codec\speex\speex_jitter.h" 370 # End Source File 371 # Begin Source File 372 373 SOURCE="..\src\pjmedia-codec\speex\speex_preprocess.h" 374 # End Source File 375 # Begin Source File 376 377 SOURCE="..\src\pjmedia-codec\speex\speex_stereo.h" 378 # End Source File 379 # Begin Source File 380 381 SOURCE="..\src\pjmedia-codec\speex\speex_types.h" 382 # End Source File 383 # Begin Source File 384 385 SOURCE="..\src\pjmedia-codec\speex\stack_alloc.h" 386 # End Source File 387 # Begin Source File 388 389 SOURCE="..\src\pjmedia-codec\speex\vbr.h" 390 # End Source File 391 # Begin Source File 392 393 SOURCE="..\src\pjmedia-codec\speex\vq.h" 394 # End Source File 395 # Begin Source File 396 397 SOURCE="..\src\pjmedia-codec\speex\vq_arm4.h" 398 # End Source File 399 # Begin Source File 400 401 SOURCE="..\src\pjmedia-codec\speex\vq_bfin.h" 402 # End Source File 403 # Begin Source File 404 405 SOURCE="..\src\pjmedia-codec\speex\vq_sse.h" 406 # End Source File 407 # End Group 408 # Begin Group "Speex Source Files" 409 410 # PROP Default_Filter "" 411 # Begin Source File 412 413 SOURCE="..\src\pjmedia-codec\speex\bits.c" 414 # End Source File 415 # Begin Source File 416 417 SOURCE="..\src\pjmedia-codec\speex\cb_search.c" 418 # End Source File 419 # Begin Source File 420 421 SOURCE="..\src\pjmedia-codec\speex\exc_10_16_table.c" 422 # End Source File 423 # Begin Source File 424 425 SOURCE="..\src\pjmedia-codec\speex\exc_10_32_table.c" 426 # End Source File 427 # Begin Source File 428 429 SOURCE="..\src\pjmedia-codec\speex\exc_20_32_table.c" 430 # End Source File 431 # Begin Source File 432 433 SOURCE="..\src\pjmedia-codec\speex\exc_5_256_table.c" 434 # End Source File 435 # Begin Source File 436 437 SOURCE="..\src\pjmedia-codec\speex\exc_5_64_table.c" 438 # End Source File 439 # Begin Source File 440 441 SOURCE="..\src\pjmedia-codec\speex\exc_8_128_table.c" 442 # End Source File 443 # Begin Source File 444 445 SOURCE="..\src\pjmedia-codec\speex\filters.c" 446 # End Source File 447 # Begin Source File 448 449 SOURCE="..\src\pjmedia-codec\speex\gain_table.c" 450 # End Source File 451 # Begin Source File 452 453 SOURCE="..\src\pjmedia-codec\speex\gain_table_lbr.c" 454 # End Source File 455 # Begin Source File 456 457 SOURCE="..\src\pjmedia-codec\speex\hexc_10_32_table.c" 458 # End Source File 459 # Begin Source File 460 461 SOURCE="..\src\pjmedia-codec\speex\hexc_table.c" 462 # End Source File 463 # Begin Source File 464 465 SOURCE="..\src\pjmedia-codec\speex\high_lsp_tables.c" 466 # End Source File 467 # Begin Source File 468 469 SOURCE="..\src\pjmedia-codec\speex\lpc_spx.c" 470 # End Source File 471 # Begin Source File 472 473 SOURCE="..\src\pjmedia-codec\speex\lsp.c" 474 # End Source File 475 # Begin Source File 476 477 SOURCE="..\src\pjmedia-codec\speex\lsp_tables_nb.c" 478 # End Source File 479 # Begin Source File 480 481 SOURCE="..\src\pjmedia-codec\speex\ltp.c" 482 # End Source File 483 # Begin Source File 484 485 SOURCE="..\src\pjmedia-codec\speex\math_approx.c" 486 # End Source File 487 # Begin Source File 488 489 SOURCE="..\src\pjmedia-codec\speex\misc.c" 490 # End Source File 491 # Begin Source File 492 493 SOURCE="..\src\pjmedia-codec\speex\modes.c" 494 # End Source File 495 # Begin Source File 496 497 SOURCE="..\src\pjmedia-codec\speex\nb_celp.c" 498 # End Source File 499 # Begin Source File 500 501 SOURCE="..\src\pjmedia-codec\speex\preprocess_spx.c" 502 # End Source File 503 # Begin Source File 504 505 SOURCE="..\src\pjmedia-codec\speex\quant_lsp.c" 506 # End Source File 507 # Begin Source File 508 509 SOURCE="..\src\pjmedia-codec\speex\sb_celp.c" 510 # End Source File 511 # Begin Source File 512 513 SOURCE="..\src\pjmedia-codec\speex\smallft.c" 514 # End Source File 515 # Begin Source File 516 517 SOURCE="..\src\pjmedia-codec\speex\speex.c" 518 # End Source File 519 # Begin Source File 520 521 SOURCE="..\src\pjmedia-codec\speex\speex_callbacks.c" 522 # End Source File 523 # Begin Source File 524 525 SOURCE="..\src\pjmedia-codec\speex\speex_header.c" 526 # End Source File 527 # Begin Source File 528 529 SOURCE="..\src\pjmedia-codec\speex\stereo.c" 530 # End Source File 531 # Begin Source File 532 533 SOURCE="..\src\pjmedia-codec\speex\vbr.c" 534 # End Source File 535 # Begin Source File 536 537 SOURCE="..\src\pjmedia-codec\speex\vq.c" 538 # End Source File 539 # End Group 206 540 # End Group 207 541 # End Target -
pjproject/trunk/pjmedia/include/pjmedia-codec.h
r176 r278 20 20 #define __PJMEDIA_CODEC1_H__ 21 21 22 #include <pjmedia-codec/types.h> 22 #include <pjmedia-codec/gsm.h> 23 #include <pjmedia-codec/speex.h> 24 23 25 24 26 PJ_BEGIN_DECL … … 27 29 /** 28 30 * Initialize pjmedia-codec library, and register all codec factories 29 * in this library. 31 * in this library. If application wants to controll the order of 32 * the codec, it MUST NOT call this function, but instead register 33 * each codec individually. 30 34 * 31 35 * @param endpt The pjmedia endpoint. -
pjproject/trunk/pjmedia/include/pjmedia-codec/config.h
r176 r278 31 31 32 32 33 /* 34 * Include Speex codec? 35 */ 36 #ifndef PJMEDIA_CODEC_HAS_SPEEX 37 # define PJMEDIA_CODEC_HAS_SPEEX 1 38 #endif 39 40 33 41 34 42 #endif /* __PJMEDIA_CODEC_CONFIG_H__ */ -
pjproject/trunk/pjmedia/include/pjmedia.h
r222 r278 31 31 #include <pjmedia/errno.h> 32 32 #include <pjmedia/file_port.h> 33 #include <pjmedia/g711.h> 33 34 #include <pjmedia/jbuf.h> 34 35 #include <pjmedia/port.h> -
pjproject/trunk/pjmedia/src/pjmedia-codec/pjmedia-codec-lib.c
r198 r278 22 22 #include <pjmedia-codec/config.h> 23 23 #include <pjmedia-codec/gsm.h> 24 #include <pjmedia-codec/speex.h> 24 25 25 26 … … 34 35 #if PJMEDIA_CODEC_HAS_GSM 35 36 { &pjmedia_codec_gsm_init, &pjmedia_codec_gsm_deinit}, 37 #endif 38 39 #if PJMEDIA_CODEC_HAS_SPEEX 40 { &pjmedia_codec_speex_init_default, &pjmedia_codec_speex_deinit}, 36 41 #endif 37 42 -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r277 r278 890 890 { 891 891 pj_int16_t *buf; 892 pj_bool_t sent = PJ_FALSE; 892 893 unsigned j; 893 894 … … 965 966 966 967 pjmedia_frame frame; 968 pj_status_t status; 967 969 968 970 frame.type = PJMEDIA_FRAME_TYPE_AUDIO; … … 972 974 973 975 if (cport->port) 974 returnpjmedia_port_put_frame(cport->port, &frame);976 status = pjmedia_port_put_frame(cport->port, &frame); 975 977 else 976 return PJ_SUCCESS; 978 status = PJ_SUCCESS; 979 980 cport->tx_buf_count -= cport->samples_per_frame; 981 if (cport->tx_buf_count) { 982 copy_samples(cport->tx_buf, 983 cport->tx_buf + cport->samples_per_frame, 984 cport->tx_buf_count); 985 } 986 987 return status; 977 988 } 978 989 -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r215 r278 39 39 40 40 41 PJ_DECL(pj_status_t) g711_init_factory (pjmedia_codec_factory *factory, pj_pool_t *pool);42 PJ_DECL(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory);43 41 44 42 /* Flag to indicate whether pjmedia error subsystem has been registered … … 90 88 pj_pool_t *pool; 91 89 pjmedia_endpt *endpt; 92 pjmedia_codec_factory *factory;93 90 pj_status_t status; 94 91 … … 120 117 121 118 /* Init and register G.711 codec. */ 119 #if 0 120 // Starting from 0.5.4, codec factory is registered by applications. 122 121 factory = pj_pool_alloc (endpt->pool, sizeof(pjmedia_codec_factory)); 123 122 … … 133 132 goto on_error; 134 133 } 134 #endif 135 135 136 136 *p_endpt = endpt; … … 327 327 328 328 PJ_LOG(3,(THIS_FILE, 329 " %s codec #%2d: pt=%d (%.*s , %d bps, ptime=%d ms, vad=%d, cng=%d)",329 " %s codec #%2d: pt=%d (%.*s @%dKHz, %d bps, ptime=%d ms, vad=%d, cng=%d)", 330 330 type, i, codec_info[i].pt, 331 331 (int)codec_info[i].encoding_name.slen, 332 332 codec_info[i].encoding_name.ptr, 333 codec_info[i].sample_rate/1000, 333 334 param.avg_bps, param.ptime, 334 335 param.vad_enabled, -
pjproject/trunk/pjmedia/src/pjmedia/g711.c
r205 r278 21 21 */ 22 22 #include <pjmedia/codec.h> 23 #include <pjmedia/endpoint.h> 23 24 #include <pjmedia/errno.h> 24 25 #include <pjmedia/port.h> … … 101 102 102 103 /* G711 factory private data */ 103 struct g711_factory_private 104 { 105 pj_pool_t *pool; 106 pjmedia_codec codec_list; 107 }; 104 static struct g711_factory 105 { 106 pjmedia_codec_factory base; 107 pjmedia_endpt *endpt; 108 pj_pool_t *pool; 109 pj_mutex_t *mutex; 110 pjmedia_codec codec_list; 111 } g711_factory; 108 112 109 113 /* G711 codec private data. */ … … 114 118 115 119 116 PJ_DEF(pj_status_t) g711_init_factory (pjmedia_codec_factory *factory, pj_pool_t *pool) 117 { 118 struct g711_factory_private *priv; 119 //enum { CODEC_MEM_SIZE = sizeof(pjmedia_codec) + sizeof(struct g711_private) + 4 }; 120 121 /* Create pool. */ 122 /* 123 pool = pj_pool_pool_create_pool(pp, "g711ftry", 124 G711_CODEC_CNT*CODEC_MEM_SIZE + 125 sizeof(struct g711_factory_private), 126 CODEC_MEM_SIZE, NULL); 127 if (!pool) 128 return -1; 129 */ 130 131 priv = pj_pool_alloc(pool, sizeof(struct g711_factory_private)); 132 if (!priv) 133 return -1; 134 135 factory->factory_data = priv; 136 factory->op = &g711_factory_op; 137 138 priv->pool = pool; 139 pj_list_init(&priv->codec_list); 120 PJ_DEF(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory) 121 { 122 PJ_ASSERT_RETURN(factory==&g711_factory.base, PJ_EINVAL); 123 124 /* Invalidate member to help detect errors */ 125 g711_factory.codec_list.next = g711_factory.codec_list.prev = NULL; 140 126 return 0; 141 127 } 142 128 143 PJ_DEF(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory) 144 { 145 struct g711_factory_private *priv = factory->factory_data; 146 147 /* Invalidate member to help detect errors */ 148 priv->pool = NULL; 149 priv->codec_list.next = priv->codec_list.prev = NULL; 150 return 0; 129 PJ_DEF(pj_status_t) pjmedia_codec_g711_init(pjmedia_endpt *endpt) 130 { 131 pjmedia_codec_mgr *codec_mgr; 132 pj_status_t status; 133 134 if (g711_factory.endpt != NULL) { 135 /* Already initialized. */ 136 return PJ_SUCCESS; 137 } 138 139 /* Init factory */ 140 g711_factory.base.op = &g711_factory_op; 141 g711_factory.base.factory_data = NULL; 142 g711_factory.endpt = endpt; 143 144 pj_list_init(&g711_factory.codec_list); 145 146 /* Create pool */ 147 g711_factory.pool = pjmedia_endpt_create_pool(endpt, "g711", 4000, 4000); 148 if (!g711_factory.pool) 149 return PJ_ENOMEM; 150 151 /* Create mutex. */ 152 status = pj_mutex_create_simple(g711_factory.pool, "g611", 153 &g711_factory.mutex); 154 if (status != PJ_SUCCESS) 155 goto on_error; 156 157 /* Get the codec manager. */ 158 codec_mgr = pjmedia_endpt_get_codec_mgr(endpt); 159 if (!codec_mgr) { 160 return PJ_EINVALIDOP; 161 } 162 163 /* Register codec factory to endpoint. */ 164 status = pjmedia_codec_mgr_register_factory(codec_mgr, 165 &g711_factory.base); 166 if (status != PJ_SUCCESS) 167 return status; 168 169 170 return PJ_SUCCESS; 171 172 on_error: 173 if (g711_factory.mutex) { 174 pj_mutex_destroy(g711_factory.mutex); 175 g711_factory.mutex = NULL; 176 } 177 if (g711_factory.pool) { 178 pj_pool_release(g711_factory.pool); 179 g711_factory.pool = NULL; 180 } 181 return status; 182 } 183 184 PJ_DEF(pj_status_t) pjmedia_codec_g711_deinit(void) 185 { 186 pjmedia_codec_mgr *codec_mgr; 187 pj_status_t status; 188 189 if (g711_factory.endpt == NULL) { 190 /* Not registered. */ 191 return PJ_SUCCESS; 192 } 193 194 /* Lock mutex. */ 195 pj_mutex_lock(g711_factory.mutex); 196 197 /* Get the codec manager. */ 198 codec_mgr = pjmedia_endpt_get_codec_mgr(g711_factory.endpt); 199 if (!codec_mgr) { 200 g711_factory.endpt = NULL; 201 pj_mutex_unlock(g711_factory.mutex); 202 return PJ_EINVALIDOP; 203 } 204 205 /* Unregister G711 codec factory. */ 206 status = pjmedia_codec_mgr_unregister_factory(codec_mgr, 207 &g711_factory.base); 208 g711_factory.endpt = NULL; 209 210 /* Destroy mutex. */ 211 pj_mutex_destroy(g711_factory.mutex); 212 g711_factory.mutex = NULL; 213 214 215 /* Release pool. */ 216 pj_pool_release(g711_factory.pool); 217 g711_factory.pool = NULL; 218 219 220 return status; 151 221 } 152 222 … … 209 279 pjmedia_codec **p_codec) 210 280 { 211 struct g711_factory_private *priv = factory->factory_data;212 281 pjmedia_codec *codec = NULL; 213 282 283 PJ_ASSERT_RETURN(factory==&g711_factory.base, PJ_EINVAL); 284 285 /* Lock mutex. */ 286 pj_mutex_lock(g711_factory.mutex); 287 214 288 /* Allocate new codec if no more is available */ 215 if (pj_list_empty(& priv->codec_list)) {289 if (pj_list_empty(&g711_factory.codec_list)) { 216 290 struct g711_private *codec_priv; 217 291 218 codec = pj_pool_alloc(priv->pool, sizeof(pjmedia_codec)); 219 codec_priv = pj_pool_alloc(priv->pool, sizeof(struct g711_private)); 220 if (!codec || !codec_priv) 292 codec = pj_pool_alloc(g711_factory.pool, sizeof(pjmedia_codec)); 293 codec_priv = pj_pool_alloc(g711_factory.pool, sizeof(struct g711_private)); 294 if (!codec || !codec_priv) { 295 pj_mutex_unlock(g711_factory.mutex); 221 296 return PJ_ENOMEM; 297 } 222 298 223 299 codec_priv->pt = id->pt; … … 227 303 codec->codec_data = codec_priv; 228 304 } else { 229 codec = priv->codec_list.next;305 codec = g711_factory.codec_list.next; 230 306 pj_list_erase(codec); 231 307 } … … 235 311 236 312 *p_codec = codec; 313 314 /* Unlock mutex. */ 315 pj_mutex_unlock(g711_factory.mutex); 316 237 317 return PJ_SUCCESS; 238 318 } … … 240 320 static pj_status_t g711_dealloc_codec( pjmedia_codec_factory *factory, pjmedia_codec *codec ) 241 321 { 242 struct g711_factory_private *priv = factory->factory_data; 322 323 PJ_ASSERT_RETURN(factory==&g711_factory.base, PJ_EINVAL); 243 324 244 325 /* Check that this node has not been deallocated before */ … … 248 329 } 249 330 331 /* Lock mutex. */ 332 pj_mutex_lock(g711_factory.mutex); 333 250 334 /* Insert at the back of the list */ 251 pj_list_insert_before(&priv->codec_list, codec); 335 pj_list_insert_before(&g711_factory.codec_list, codec); 336 337 /* Unlock mutex. */ 338 pj_mutex_unlock(g711_factory.mutex); 252 339 253 340 return PJ_SUCCESS; -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r277 r278 187 187 pj_bool_t auto_conf; /**< Auto put to conference? */ 188 188 189 /* Codec arguments: */ 190 int codec_cnt; /**< Number of --add-codec args. */ 191 pj_str_t codec_arg[32]; /**< Array of --add-codec args. */ 192 pj_status_t (*codec_deinit[32])(void); /**< Array of funcs. */ 189 193 190 194 /* User Agent behaviour: */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r277 r278 529 529 } 530 530 531 /* Init pjmedia-codecs: */532 533 status = pjmedia_codec_init(pjsua.med_endpt);534 if (status != PJ_SUCCESS) {535 pj_caching_pool_destroy(&pjsua.cp);536 pjsua_perror(THIS_FILE,537 "Media codec initialization has returned error",538 status);539 return status;540 }541 542 543 531 /* Done. */ 544 532 return PJ_SUCCESS; … … 609 597 610 598 /* 611 * Start pjsua stack. 612 * This will start the registration process, if registration is configured. 613 */ 614 pj_status_t pjsua_start(void) 615 { 616 int i; /* Must be signed */ 617 pjsip_transport *udp_transport; 618 pj_status_t status = PJ_SUCCESS; 599 * Init media. 600 */ 601 static pj_status_t init_media(void) 602 { 603 604 pj_status_t status; 605 606 /* If user doesn't specify any codecs, register all of them. */ 607 if (pjsua.codec_cnt == 0) { 608 609 unsigned option = PJMEDIA_SPEEX_NO_WB | PJMEDIA_SPEEX_NO_UWB; 610 611 /* Register speex. */ 612 if (pjsua.clock_rate >= 16000) 613 option &= ~(PJMEDIA_SPEEX_NO_WB); 614 if (pjsua.clock_rate >= 32000) 615 option &= ~(PJMEDIA_SPEEX_NO_UWB); 616 617 status = pjmedia_codec_speex_init(pjsua.med_endpt, option, -1, -1); 618 if (status != PJ_SUCCESS) { 619 pjsua_perror(THIS_FILE, "Error initializing Speex codec", 620 status); 621 return status; 622 } 623 624 pjsua.codec_arg[pjsua.codec_cnt] = pj_str("speex"); 625 pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_speex_deinit; 626 pjsua.codec_cnt++; 627 628 /* Register GSM */ 629 status = pjmedia_codec_gsm_init(pjsua.med_endpt); 630 if (status != PJ_SUCCESS) { 631 pjsua_perror(THIS_FILE, "Error initializing GSM codec", 632 status); 633 return status; 634 } 635 636 pjsua.codec_arg[pjsua.codec_cnt] = pj_str("gsm"); 637 pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_gsm_deinit; 638 pjsua.codec_cnt++; 639 640 /* Register PCMA and PCMU */ 641 status = pjmedia_codec_g711_init(pjsua.med_endpt); 642 if (status != PJ_SUCCESS) { 643 pjsua_perror(THIS_FILE, "Error initializing G711 codec", 644 status); 645 return status; 646 } 647 648 pjsua.codec_arg[pjsua.codec_cnt] = pj_str("pcmu"); 649 pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_g711_deinit; 650 pjsua.codec_cnt++; 651 pjsua.codec_arg[pjsua.codec_cnt] = pj_str("pcma"); 652 pjsua.codec_deinit[pjsua.codec_cnt] = &pjmedia_codec_g711_deinit; 653 pjsua.codec_cnt++; 654 655 } else { 656 657 /* If user specifies the exact codec to be used, then create only 658 * those codecs. 659 */ 660 int i; 661 662 for (i=0; i<pjsua.codec_cnt; ++i) { 663 664 /* Is it speex? */ 665 if (!pj_stricmp2(&pjsua.codec_arg[i], "speex")) { 666 667 unsigned option = PJMEDIA_SPEEX_NO_WB | PJMEDIA_SPEEX_NO_UWB; 668 669 /* Register speex. */ 670 if (pjsua.clock_rate >= 16000) 671 option &= ~(PJMEDIA_SPEEX_NO_WB); 672 if (pjsua.clock_rate >= 32000) 673 option &= ~(PJMEDIA_SPEEX_NO_UWB); 674 675 status = pjmedia_codec_speex_init(pjsua.med_endpt, option, 676 -1, -1); 677 if (status != PJ_SUCCESS) { 678 pjsua_perror(THIS_FILE, "Error initializing Speex codec", 679 status); 680 return status; 681 } 682 683 pjsua.codec_deinit[i] = &pjmedia_codec_speex_deinit; 684 } 685 /* Is it gsm? */ 686 else if (!pj_stricmp2(&pjsua.codec_arg[i], "gsm")) { 687 688 status = pjmedia_codec_gsm_init(pjsua.med_endpt); 689 if (status != PJ_SUCCESS) { 690 pjsua_perror(THIS_FILE, "Error initializing GSM codec", 691 status); 692 return status; 693 } 694 695 pjsua.codec_deinit[i] = &pjmedia_codec_gsm_deinit; 696 697 } 698 /* Is it pcma/pcmu? */ 699 else if (!pj_stricmp2(&pjsua.codec_arg[i], "pcmu") || 700 !pj_stricmp2(&pjsua.codec_arg[i], "pcma")) 701 { 702 703 status = pjmedia_codec_g711_init(pjsua.med_endpt); 704 if (status != PJ_SUCCESS) { 705 pjsua_perror(THIS_FILE, "Error initializing G711 codec", 706 status); 707 return status; 708 } 709 710 pjsua.codec_deinit[i] = &pjmedia_codec_g711_deinit; 711 712 } 713 /* Don't know about this codec... */ 714 else { 715 716 PJ_LOG(1,(THIS_FILE, "Error: unsupported codecs %s", 717 pjsua.codec_arg[i].ptr)); 718 return PJMEDIA_CODEC_EUNSUP; 719 } 720 } 721 } 619 722 620 723 /* Init conference bridge. */ … … 662 765 663 766 767 return PJ_SUCCESS; 768 } 769 770 771 /* 772 * Start pjsua stack. 773 * This will start the registration process, if registration is configured. 774 */ 775 pj_status_t pjsua_start(void) 776 { 777 int i; /* Must be signed */ 778 pjsip_transport *udp_transport; 779 pj_status_t status = PJ_SUCCESS; 780 781 /* 782 * Init media subsystem (codecs, conference bridge, et all). 783 */ 784 status = init_media(); 785 if (status != PJ_SUCCESS) 786 return status; 787 664 788 /* Init sockets (STUN etc): */ 665 789 for (i=0; i<(int)pjsua.max_calls; ++i) { … … 871 995 pj_status_t pjsua_destroy(void) 872 996 { 873 int i; 997 int i; /* Must be signed */ 874 998 875 999 /* Signal threads to quit: */ … … 908 1032 pjmedia_conf_destroy(pjsua.mconf); 909 1033 910 /* Shutdown pjmedia-codec: */911 pjmedia_codec_deinit();912 913 1034 /* Destroy sound framework: 914 1035 * (this should be done in pjmedia_shutdown()) … … 916 1037 pj_snd_deinit(); 917 1038 1039 /* Shutdown all codecs: */ 1040 for (i = pjsua.codec_cnt-1; i >= 0; --i) { 1041 (*pjsua.codec_deinit[i])(); 1042 } 1043 1044 /* Destroy media endpoint. */ 1045 1046 pjmedia_endpt_destroy(pjsua.med_endpt); 1047 918 1048 /* Destroy endpoint. */ 919 1049 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r277 r278 91 91 puts(" --auto-loop Automatically loop incoming RTP to outgoing RTP"); 92 92 puts(" --auto-conf Automatically put incoming calls to conference"); 93 puts(" --rtp-port=N Base port to try for RTP"); 93 puts(" --rtp-port=N Base port to try for RTP"); 94 puts(" --add-codec=name Specify alternate codec order"); 94 95 puts(""); 95 96 puts("Buddy List (can be more than one):"); … … 221 222 OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP, 222 223 OPT_AUTO_CONF, 223 OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT, 224 OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT, OPT_ADD_CODEC, 224 225 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 225 226 }; … … 256 257 { "play-file", 1, 0, OPT_PLAY_FILE}, 257 258 { "rtp-port", 1, 0, OPT_RTP_PORT}, 259 { "add-codec", 1, 0, OPT_ADD_CODEC}, 258 260 { "next-account",0,0, OPT_NEXT_ACCOUNT}, 259 261 { "next-cred", 0, 0, OPT_NEXT_CRED}, … … 490 492 return -1; 491 493 } 494 495 case OPT_ADD_CODEC: 496 pjsua.codec_arg[pjsua.codec_cnt++] = pj_str(optarg); 497 break; 492 498 493 499 case OPT_AUTO_ANSWER:
Note: See TracChangeset
for help on using the changeset viewer.