- Timestamp:
- Apr 27, 2006 10:36:40 PM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 4 added
- 2 deleted
- 27 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/Makefile
r366 r411 65 65 export PJMEDIA_SRCDIR = ../src/pjmedia 66 66 export PJMEDIA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 67 codec.o conference.o endpoint.o errno.o file_player.o \ 68 file_writer.o \ 69 g711.o jbuf.o null_port.o port.o resample.o resample_port.o \ 70 rtcp.o rtp.o sdp.o sdp_cmp.o sdp_neg.o session.o silencedet.o \ 71 sound_port.o stream.o wave.o $(SOUND_OBJS) $(NULLSOUND_OBJS) 67 clock_thread.o codec.o conference.o endpoint.o errno.o \ 68 wav_player.o wav_writer.o g711.o jbuf.o \ 69 master_port.o null_port.o port.o resample.o \ 70 resample_port.o rtcp.o rtp.o sdp.o sdp_cmp.o sdp_neg.o \ 71 session.o silencedet.o sound_port.o stream.o wave.o \ 72 $(SOUND_OBJS) $(NULLSOUND_OBJS) 72 73 73 74 export PJMEDIA_CFLAGS += $(_CFLAGS) … … 88 89 SPEEX_OBJS := speex_codec.o \ 89 90 speex/bits.o speex/cb_search.o speex/exc_10_16_table.o \ 90 speex/exc_10_32_table.o speex/exc_20_32_table.o speex/exc_5_256_table.o \ 91 speex/exc_5_64_table.o speex/exc_8_128_table.o speex/filters.o \ 92 speex/gain_table.o speex/gain_table_lbr.o speex/hexc_10_32_table.o \ 93 speex/hexc_table.o speex/high_lsp_tables.o speex/lpc_spx.o \ 94 speex/lsp.o speex/lsp_tables_nb.o speex/ltp.o speex/math_approx.o \ 95 speex/misc.o speex/modes.o speex/nb_celp.o speex/preprocess_spx.o \ 96 speex/quant_lsp.o speex/sb_celp.o speex/smallft.o speex/speex.o \ 97 speex/speex_callbacks.o speex/speex_header.o speex/stereo.o \ 98 speex/vbr.o speex/vq.o 91 speex/exc_10_32_table.o speex/exc_20_32_table.o \ 92 speex/exc_5_256_table.o speex/exc_5_64_table.o \ 93 speex/exc_8_128_table.o speex/filters.o \ 94 speex/gain_table.o speex/gain_table_lbr.o \ 95 speex/hexc_10_32_table.o speex/hexc_table.o \ 96 speex/high_lsp_tables.o speex/lpc_spx.o \ 97 speex/lsp.o speex/lsp_tables_nb.o speex/ltp.o \ 98 speex/math_approx.o speex/misc.o speex/modes.o \ 99 speex/nb_celp.o speex/preprocess_spx.o \ 100 speex/quant_lsp.o speex/sb_celp.o speex/smallft.o \ 101 speex/speex.o speex/speex_callbacks.o speex/speex_header.o \ 102 speex/stereo.o speex/vbr.o speex/vq.o 99 103 SPEEX_CFLAGS := -DHAVE_CONFIG=1 -I../src/pjmedia-codec 100 104 -
pjproject/trunk/pjmedia/build/pjmedia.dsp
r404 r411 66 66 # PROP Target_Dir "" 67 67 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /D "_DEBUG" /D "PA_NO_ASIO" /D " WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c68 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjlib/include" /I "../../pjlib-util/include" /I "../src/pjmedia/portaudio" /D "_DEBUG" /D "PA_NO_ASIO" /D "PA_NO_WMME" /D "WIN32" /D "_MBCS" /D "_LIB" /D PJ_WIN32=1 /D PJ_M_I386=1 /FR /FD /GZ /c 69 69 # SUBTRACT CPP /YX 70 70 # ADD BASE RSC /l 0x409 /d "_DEBUG" … … 112 112 # Begin Source File 113 113 114 SOURCE=..\src\pjmedia\file_player.c115 # End Source File116 # Begin Source File117 118 SOURCE=..\src\pjmedia\file_writer.c119 # End Source File120 # Begin Source File121 122 114 SOURCE=..\src\pjmedia\g711.c 123 115 # End Source File … … 189 181 190 182 SOURCE=..\src\pjmedia\stream.c 183 # End Source File 184 # Begin Source File 185 186 SOURCE=..\src\pjmedia\wav_player.c 187 # End Source File 188 # Begin Source File 189 190 SOURCE=..\src\pjmedia\wav_writer.c 191 191 # End Source File 192 192 # Begin Source File … … 228 228 # Begin Source File 229 229 230 SOURCE=..\include\pjmedia\file_port.h231 # End Source File232 # Begin Source File233 234 230 SOURCE=..\include\pjmedia\g711.h 235 231 # End Source File … … 297 293 298 294 SOURCE=..\include\pjmedia\types.h 295 # End Source File 296 # Begin Source File 297 298 SOURCE=..\include\pjmedia\wav_port.h 299 299 # End Source File 300 300 # Begin Source File -
pjproject/trunk/pjmedia/build/pjmedia_codec.dsp
r328 r411 92 92 # Begin Source File 93 93 94 SOURCE="..\src\pjmedia-codec\l16.c" 95 # End Source File 96 # Begin Source File 97 94 98 SOURCE="..\src\pjmedia-codec\speex_codec.c" 95 99 # End Source File … … 105 109 106 110 SOURCE="..\include\pjmedia-codec\gsm.h" 111 # End Source File 112 # Begin Source File 113 114 SOURCE="..\include\pjmedia-codec\l16.h" 107 115 # End Source File 108 116 # Begin Source File -
pjproject/trunk/pjmedia/include/pjmedia-codec.h
r320 r411 20 20 #define __PJMEDIA_CODEC_PJMEDIA_CODEC_H__ 21 21 22 #include <pjmedia-codec/l16.h> 22 23 #include <pjmedia-codec/gsm.h> 23 24 #include <pjmedia-codec/speex.h> -
pjproject/trunk/pjmedia/include/pjmedia-codec/config.h
r320 r411 24 24 25 25 /** 26 * Unless specified otherwise, L16 codec is included by default. 27 */ 28 #ifndef PJMEDIA_HAS_L16_CODEC 29 # define PJMEDIA_HAS_L16_CODEC 1 30 #endif 31 32 33 /** 26 34 * Unless specified otherwise, GSM codec is included by default. 27 35 */ -
pjproject/trunk/pjmedia/include/pjmedia-codec/types.h
r320 r411 23 23 24 24 25 /** 26 * These are the dynamic payload types that are used by codecs in 27 * this library. Also see the header file <pjmedia/codec.h> for list 28 * of static payload types. 29 */ 30 enum 31 { 32 /* Telephone events must have pt=101, or otherwise some code needs 33 * to be updated (this would not affect outgoing pt). 34 */ 35 PJMEDIA_RTP_PT_TELEPHONE_EVENTS = 101, /**< telephone-events */ 36 37 PJMEDIA_RTP_PT_SPEEX_NB, /**< Speex narrowband/8KHz */ 38 PJMEDIA_RTP_PT_SPEEX_WB, /**< Speex wideband/16KHz */ 39 PJMEDIA_RTP_PT_SPEEX_UWB, /**< Speex 32KHz */ 40 PJMEDIA_RTP_PT_L16_8KHZ_MONO, /**< L16 @ 8KHz, mono */ 41 PJMEDIA_RTP_PT_L16_8KHZ_STEREO, /**< L16 @ 8KHz, stereo */ 42 PJMEDIA_RTP_PT_L16_11KHZ_MONO, /**< L16 @ 11KHz, mono */ 43 PJMEDIA_RTP_PT_L16_11KHZ_STEREO, /**< L16 @ 11KHz, stereo */ 44 PJMEDIA_RTP_PT_L16_16KHZ_MONO, /**< L16 @ 16KHz, mono */ 45 PJMEDIA_RTP_PT_L16_16KHZ_STEREO, /**< L16 @ 16KHz, stereo */ 46 PJMEDIA_RTP_PT_L16_22KHZ_MONO, /**< L16 @ 22KHz, mono */ 47 PJMEDIA_RTP_PT_L16_22KHZ_STEREO, /**< L16 @ 22KHz, stereo */ 48 PJMEDIA_RTP_PT_L16_32KHZ_MONO, /**< L16 @ 32KHz, mono */ 49 PJMEDIA_RTP_PT_L16_32KHZ_STEREO, /**< L16 @ 32KHz, stereo */ 50 PJMEDIA_RTP_PT_L16_48KHZ_MONO, /**< L16 @ 48KHz, mono */ 51 PJMEDIA_RTP_PT_L16_48KHZ_STEREO, /**< L16 @ 48KHz, stereo */ 52 }; 53 54 55 25 56 #endif /* __PJMEDIA_CODEC_TYPES_H__ */ -
pjproject/trunk/pjmedia/include/pjmedia.h
r404 r411 31 31 #include <pjmedia/endpoint.h> 32 32 #include <pjmedia/errno.h> 33 #include <pjmedia/file_port.h>34 33 #include <pjmedia/g711.h> 35 34 #include <pjmedia/jbuf.h> … … 46 45 #include <pjmedia/sound.h> 47 46 #include <pjmedia/sound_port.h> 47 #include <pjmedia/wav_port.h> 48 48 #include <pjmedia/wave.h> 49 49 -
pjproject/trunk/pjmedia/include/pjmedia/codec.h
r276 r411 49 49 /** 50 50 * Standard RTP static payload types, as defined by RFC 3551. 51 * The header file <pjmedia-codec/types.h> also declares dynamic payload 52 * types that are supported by pjmedia-codec library. 51 53 */ 52 54 enum pjmedia_rtp_pt … … 92 94 unsigned pt; /**< Payload type (can be dynamic). */ 93 95 pj_str_t encoding_name; /**< Encoding name. */ 94 unsigned sample_rate; /**< Sampling rate. */ 95 }; 96 unsigned clock_rate; /**< Sampling rate. */ 97 unsigned channel_cnt; /**< Channel count. */ 98 }; 99 100 101 /** 102 * @see pjmedia_codec_info 103 */ 104 typedef struct pjmedia_codec_info pjmedia_codec_info; 96 105 97 106 … … 102 111 struct pjmedia_codec_param 103 112 { 104 pj_uint32_t sample_rate; /**< Sampling rate in Hz */ 113 unsigned clock_rate; /**< Sampling rate in Hz */ 114 unsigned channel_cnt; /**< Channel count. */ 105 115 pj_uint32_t avg_bps; /**< Average bandwidth in bits/sec */ 106 116 117 pj_uint16_t ptime; /**< Packet time in miliseconds */ 107 118 pj_uint8_t pcm_bits_per_sample;/**< Bits/sample in the PCM side */ 108 pj_uint16_t ptime; /**< Packet time in miliseconds */109 119 110 120 unsigned pt:8; /**< Payload type. */ 111 unsigned vad_enabled:1; /**< Voice Activity Detector. */ 112 unsigned cng_enabled:1; /**< Comfort Noise Generator. */ 113 unsigned lpf_enabled:1; /**< Low pass filter */ 114 unsigned hpf_enabled:1; /**< High pass filter */ 115 unsigned penh_enabled:1; /**< Perceptual Enhancement */ 116 unsigned concl_enabled:1; /**< Packet loss concealment */ 117 unsigned reserved_bit:1; /**< Reserved, must be NULL. */ 118 119 }; 121 unsigned vad:1; /**< Voice Activity Detector. */ 122 unsigned cng:1; /**< Comfort Noise Generator. */ 123 unsigned lpf:1; /**< Low pass filter */ 124 unsigned hpf:1; /**< High pass filter */ 125 unsigned penh:1; /**< Perceptual Enhancement */ 126 unsigned concl:1; /**< Packet loss concealment */ 127 unsigned reserved:1; /**< Reserved, must be NULL. */ 128 129 }; 130 131 /** 132 * @see pjmedia_codec_param 133 */ 134 typedef struct pjmedia_codec_param pjmedia_codec_param; 135 136 137 /** 138 * @see pjmedia_codec 139 */ 140 typedef struct pjmedia_codec pjmedia_codec; 120 141 121 142 … … 126 147 struct pjmedia_codec_op 127 148 { 128 /**129 * Get default attributes for this codec.130 *131 * @param codec The codec instance.132 * @param attr Pointer to receive default codec attributes.133 *134 * @return PJ_SUCCESS on success.135 */136 pj_status_t (*default_attr)(pjmedia_codec *codec,137 pjmedia_codec_param *attr);138 139 149 /** 140 150 * Initialize codec using the specified attribute. … … 226 236 227 237 /** 238 * Codec operation. 239 */ 240 typedef struct pjmedia_codec_op pjmedia_codec_op; 241 242 243 /** 244 * @see pjmedia_codec_factory 245 */ 246 typedef struct pjmedia_codec_factory pjmedia_codec_factory; 247 248 249 /** 228 250 * This structure describes a codec instance. 229 251 */ … … 234 256 235 257 /** Codec's private data. */ 236 void *codec_data;258 void *codec_data; 237 259 238 260 /** Codec factory where this codec was allocated. */ 239 pjmedia_codec_factory *factory;261 pjmedia_codec_factory *factory; 240 262 241 263 /** Operations to codec. */ 242 pjmedia_codec_op *op; 243 }; 264 pjmedia_codec_op *op; 265 }; 266 244 267 245 268 … … 274 297 */ 275 298 pj_status_t (*default_attr)(pjmedia_codec_factory *factory, 276 const pjmedia_codec_info *info,277 pjmedia_codec_param *attr );299 const pjmedia_codec_info *info, 300 pjmedia_codec_param *attr ); 278 301 279 302 /** … … 323 346 324 347 /** 348 * @see pjmedia_codec_factory_op 349 */ 350 typedef struct pjmedia_codec_factory_op pjmedia_codec_factory_op; 351 352 353 /** 325 354 * Codec factory describes a module that is able to create codec with specific 326 355 * capabilities. These capabilities can be queried by codec manager to create … … 340 369 }; 341 370 371 342 372 /** 343 373 * Declare maximum codecs … … 345 375 #define PJMEDIA_CODEC_MGR_MAX_CODECS 32 346 376 347 /** 348 * Codec manager maintains codec factory etc. 377 378 /** 379 * Specify these values to set the codec priority, by calling 380 * #pjmedia_codec_mgr_set_codec_priority(). 381 */ 382 enum pjmedia_codec_priority 383 { 384 /** 385 * This priority makes the codec the highest in the order. 386 * The last codec specified with this priority will get the 387 * highest place in the order, and will change the priority 388 * of previously highest priority codec to NEXT_HIGHER. 389 */ 390 PJMEDIA_CODEC_PRIO_HIGHEST, 391 392 /** 393 * This priority will put the codec as the next codec after 394 * codecs with this same priority. 395 */ 396 PJMEDIA_CODEC_PRIO_NEXT_HIGHER, 397 398 /** 399 * This is the initial codec priority when it is registered to 400 * codec manager by codec factory. 401 */ 402 PJMEDIA_CODEC_PRIO_NORMAL, 403 404 /** 405 * This priority makes the codec the lowest in the order. 406 * The last codec specified with this priority will be put 407 * in the last place in the order. 408 */ 409 PJMEDIA_CODEC_PRIO_LOWEST, 410 411 /** 412 * This priority will prevent the codec from being listed in the 413 * SDP created by media endpoint, thus should prevent the codec 414 * from being used in the sessions. However, the codec will still 415 * be listed by #pjmedia_codec_mgr_enum_codecs() and other codec 416 * query functions. 417 */ 418 PJMEDIA_CODEC_PRIO_DISABLED, 419 }; 420 421 422 /** 423 * @see pjmedia_codec_priority 424 */ 425 typedef enum pjmedia_codec_priority pjmedia_codec_priority; 426 427 428 /** Fully qualified codec name (e.g. "pcmu/8000/1") */ 429 typedef char pjmedia_codec_id[32]; 430 431 432 /** 433 * Codec manager maintains array of these structs for each supported 434 * codec. 435 */ 436 struct pjmedia_codec_desc 437 { 438 pjmedia_codec_info info; /**< Codec info. */ 439 pjmedia_codec_id id; /**< Fully qualified name */ 440 pjmedia_codec_priority prio; /**< Priority. */ 441 pjmedia_codec_factory *factory; /**< The factory. */ 442 }; 443 444 445 /** 446 * The declaration for codec manager. Application doesn't normally need 447 * to see this declaration, but nevertheless this declaration is needed 448 * by media endpoint to instantiate the codec manager. 349 449 */ 350 450 struct pjmedia_codec_mgr 351 451 { 352 452 /** List of codec factories registered to codec manager. */ 353 pjmedia_codec_factory 453 pjmedia_codec_factory factory_list; 354 454 355 455 /** Number of supported codesc. */ 356 unsigned codec_cnt; 357 358 /** Array of codec info. */ 359 pjmedia_codec_info codecs[PJMEDIA_CODEC_MGR_MAX_CODECS]; 360 }; 361 362 363 364 /** 365 * Initialize codec manager. 456 unsigned codec_cnt; 457 458 /** Array of codec descriptor. */ 459 struct pjmedia_codec_desc codec_desc[PJMEDIA_CODEC_MGR_MAX_CODECS]; 460 }; 461 462 463 /** 464 * @see pjmedia_codec_mgr 465 */ 466 typedef struct pjmedia_codec_mgr pjmedia_codec_mgr; 467 468 469 470 /** 471 * Initialize codec manager. Normally this function is called by pjmedia 472 * endpoint's initialization code. 366 473 * 367 474 * @param mgr Codec manager instance. … … 373 480 374 481 /** 375 * Register codec factory to codec manager. 376 * 377 * @param mgr The codec manager. 482 * Register codec factory to codec manager. This will also register 483 * all supported codecs in the factory to the codec manager. 484 * 485 * @param mgr The codec manager instance. Application can get the 486 * instance by calling #pjmedia_endpt_get_codec_mgr(). 378 487 * @param factory The codec factory to be registered. 379 488 * … … 385 494 386 495 /** 387 * Unregister codec factory from the codec manager. 388 * 389 * @param mgr The codec manager. 496 * Unregister codec factory from the codec manager. This will also 497 * remove all the codecs registered by the codec factory from the 498 * codec manager's list of supported codecs. 499 * 500 * @param mgr The codec manager instance. Application can get the 501 * instance by calling #pjmedia_endpt_get_codec_mgr(). 390 502 * @param factory The codec factory to be unregistered. 391 503 * … … 397 509 398 510 /** 399 * Enumerate all supported codec. 400 * 401 * @param mgr The codec manager. 511 * Enumerate all supported codecs that have been registered to the 512 * codec manager by codec factories. 513 * 514 * @param mgr The codec manager instance. Application can get the 515 * instance by calling #pjmedia_endpt_get_codec_mgr(). 402 516 * @param count On input, specifies the number of elements in 403 517 * the array. On output, the value will be set to … … 406 520 * @param info The codec info array, which contents will be 407 521 * initialized upon return. 522 * @param prio Optional pointer to receive array of codec priorities. 408 523 * 409 524 * @return PJ_SUCCESS on success. … … 411 526 PJ_DECL(pj_status_t) pjmedia_codec_mgr_enum_codecs( pjmedia_codec_mgr *mgr, 412 527 unsigned *count, 413 pjmedia_codec_info info[]); 414 415 /** 416 * Get codec info for the specified static payload type. 417 * 418 * @param mgr The codec manager. 528 pjmedia_codec_info info[], 529 unsigned *prio); 530 531 /** 532 * Get codec info for the specified static payload type. Note that 533 * this can only find codec with static payload types. This function can 534 * be used to find codec info for a payload type inside SDP which doesn't 535 * have the corresponding rtpmap attribute. 536 * 537 * @param mgr The codec manager instance. Application can get the 538 * instance by calling #pjmedia_endpt_get_codec_mgr(). 419 539 * @param pt Static payload type/number. 420 540 * @param inf Pointer to receive codec info. … … 422 542 * @return PJ_SUCCESS on success. 423 543 */ 424 PJ_DECL(pj_status_t) pjmedia_codec_mgr_get_codec_info(pjmedia_codec_mgr *mgr, 425 unsigned pt, 426 pjmedia_codec_info *inf); 544 PJ_DECL(pj_status_t) 545 pjmedia_codec_mgr_get_codec_info( pjmedia_codec_mgr *mgr, 546 unsigned pt, 547 const pjmedia_codec_info **inf); 548 549 /** 550 * Convert codec info struct into a unique codec identifier. 551 * A codec identifier looks something like "L16/44100/2". 552 * 553 * @param info The codec info 554 * @param id Buffer to put the codec info string. 555 * @param max_len The length of the buffer. 556 * 557 * @return The null terminated codec info string, or NULL if 558 * the buffer is not long enough. 559 */ 560 PJ_DECL(char*) pjmedia_codec_info_to_id(const pjmedia_codec_info *info, 561 char *id, unsigned max_len ); 562 563 564 /** 565 * Find codecs by the unique codec identifier. This function will find 566 * all codecs that match the codec identifier prefix. For example, if 567 * "L16" is specified, then it will find "L16/8000/1", "L16/16000/1", 568 * and so on, up to the maximum count specified in the argument. 569 * 570 * @param mgr The codec manager instance. Application can get the 571 * instance by calling #pjmedia_endpt_get_codec_mgr(). 572 * @param codec_id The full codec ID or codec ID prefix. If an empty 573 * string is given, it will match all codecs. 574 * @param count Maximum number of codecs to find. On return, it 575 * contains the actual number of codecs found. 576 * @param p_info Array of pointer to codec info to be filled. This 577 * argument may be NULL, which in this case, only 578 * codec count will be returned. 579 * @param prio Optional array of codec priorities. 580 * 581 * @return PJ_SUCCESS if at least one codec info is found. 582 */ 583 PJ_DECL(pj_status_t) 584 pjmedia_codec_mgr_find_codecs_by_id( pjmedia_codec_mgr *mgr, 585 const pj_str_t *codec_id, 586 unsigned *count, 587 const pjmedia_codec_info *p_info[], 588 unsigned prio[]); 589 590 591 /** 592 * Set codec priority. The codec priority determines the order of 593 * the codec in the SDP created by the endpoint. If more than one codecs 594 * are found with the same codec_id prefix, then the function sets the 595 * priorities of all those codecs. 596 * 597 * @param mgr The codec manager instance. Application can get the 598 * instance by calling #pjmedia_endpt_get_codec_mgr(). 599 * @param codec_id The full codec ID or codec ID prefix. If an empty 600 * string is given, it will match all codecs. 601 * @param prio Priority to be set. 602 * 603 * @return PJ_SUCCESS if at least one codec info is found. 604 */ 605 PJ_DECL(pj_status_t) 606 pjmedia_codec_mgr_set_codec_priority(pjmedia_codec_mgr *mgr, 607 const pj_str_t *codec_id, 608 pjmedia_codec_priority prio); 609 427 610 428 611 /** 429 612 * Get default codec param for the specified codec info. 430 613 * 431 * @param mgr The codec manager. 614 * @param mgr The codec manager instance. Application can get the 615 * instance by calling #pjmedia_endpt_get_codec_mgr(). 432 616 * @param info The codec info, which default parameter's is being 433 617 * queried. … … 437 621 * @return PJ_SUCCESS on success. 438 622 */ 439 PJ_DECL(pj_status_t) pjmedia_codec_mgr_get_default_param(pjmedia_codec_mgr *mgr, 440 const pjmedia_codec_info *info, 441 pjmedia_codec_param *param ); 623 PJ_DECL(pj_status_t) 624 pjmedia_codec_mgr_get_default_param( pjmedia_codec_mgr *mgr, 625 const pjmedia_codec_info *info, 626 pjmedia_codec_param *param ); 442 627 443 628 /** … … 446 631 * until it finds factory that is able to create the specified codec. 447 632 * 448 * @param mgr The codec manager. 633 * @param mgr The codec manager instance. Application can get the 634 * instance by calling #pjmedia_endpt_get_codec_mgr(). 449 635 * @param info The information about the codec to be created. 450 636 * @param p_codec Pointer to receive the codec instance. … … 452 638 * @return PJ_SUCCESS on success. 453 639 */ 454 PJ_DECL(pj_status_t) pjmedia_codec_mgr_alloc_codec(pjmedia_codec_mgr *mgr, 455 const pjmedia_codec_info *info, 456 pjmedia_codec **p_codec); 640 PJ_DECL(pj_status_t) 641 pjmedia_codec_mgr_alloc_codec( pjmedia_codec_mgr *mgr, 642 const pjmedia_codec_info *info, 643 pjmedia_codec **p_codec); 457 644 458 645 /** … … 460 647 * the instance of the codec back to its factory. 461 648 * 462 * @param mgr The codec manager. 649 * @param mgr The codec manager instance. Application can get the 650 * instance by calling #pjmedia_endpt_get_codec_mgr(). 463 651 * @param codec The codec instance. 464 652 * … … 468 656 pjmedia_codec *codec); 469 657 658 659 660 661 470 662 /** 471 663 * @} -
pjproject/trunk/pjmedia/include/pjmedia/endpoint.h
r350 r411 40 40 #include <pjmedia/sound.h> 41 41 #include <pjmedia/codec.h> 42 #include <pjmedia/sdp.h> 42 43 43 44 -
pjproject/trunk/pjmedia/include/pjmedia/port.h
r321 r411 78 78 unsigned pt; /**< Payload type (can be dynamic). */ 79 79 pj_str_t encoding_name; /**< Encoding name. */ 80 unsigned sample_rate;/**< Sampling rate. */80 unsigned clock_rate; /**< Sampling rate. */ 81 81 unsigned channel_count; /**< Number of channels. */ 82 82 unsigned bits_per_sample; /**< Bits/sample */ … … 102 102 }; 103 103 104 105 /** 106 * @see pjmedia_frame_type 107 */ 108 typedef enum pjmedia_frame_type pjmedia_frame_type; 109 110 104 111 /** 105 112 * This structure describes a media frame. … … 112 119 pj_timestamp timestamp; /**< Frame timestamp. */ 113 120 }; 121 122 123 /** 124 * @see pjmedia_frame 125 */ 126 typedef struct pjmedia_frame pjmedia_frame; 127 114 128 115 129 /** -
pjproject/trunk/pjmedia/include/pjmedia/sdp.h
r295 r411 78 78 pj_str_t value; /**< Attribute value. */ 79 79 }; 80 81 /** 82 * @see pjmedia_sdp_attr 83 */ 84 typedef struct pjmedia_sdp_attr pjmedia_sdp_attr; 80 85 81 86 … … 203 208 }; 204 209 210 /** 211 * @see pjmedia_sdp_rtpmap 212 */ 213 typedef struct pjmedia_sdp_rtpmap pjmedia_sdp_rtpmap; 214 205 215 206 216 /** … … 262 272 pj_str_t fmt_param; /**< Format specific parameter. */ 263 273 }; 274 275 276 /** 277 * @see pjmedia_sdp_fmtp 278 */ 279 typedef struct pjmedia_sdp_fmtp pjmedia_sdp_fmtp; 280 264 281 265 282 … … 291 308 pj_str_t addr; /**< The address. */ 292 309 }; 310 311 312 /** 313 * @see pjmedia_sdp_conn 314 */ 315 typedef struct pjmedia_sdp_conn pjmedia_sdp_conn; 293 316 294 317 … … 336 359 337 360 361 /** 362 * @see pjmedia_sdp_media 363 */ 364 typedef struct pjmedia_sdp_media pjmedia_sdp_media; 365 366 338 367 /** 339 368 * Clone SDP media description. … … 482 511 }; 483 512 513 /** 514 * @see pjmedia_sdp_session 515 */ 516 typedef struct pjmedia_sdp_session pjmedia_sdp_session; 517 518 484 519 485 520 /** -
pjproject/trunk/pjmedia/include/pjmedia/sdp_neg.h
r207 r411 234 234 */ 235 235 236 #include <pjmedia/ types.h>236 #include <pjmedia/sdp.h> 237 237 238 238 PJ_BEGIN_DECL … … 277 277 278 278 /** 279 * @see pjmedia_sdp_neg_state 280 */ 281 typedef enum pjmedia_sdp_neg_state pjmedia_sdp_neg_state; 282 283 284 /** 285 * Opaque declaration of SDP negotiator. 286 */ 287 typedef struct pjmedia_sdp_neg pjmedia_sdp_neg; 288 289 290 /** 279 291 * Get the state string description of the specified state. 280 292 * -
pjproject/trunk/pjmedia/include/pjmedia/types.h
r352 r411 44 44 }; 45 45 46 /** 47 * @see pjmedia_type 48 */ 49 typedef enum pjmedia_type pjmedia_type; 50 51 46 52 47 53 /** … … 64 70 }; 65 71 72 /** 73 * @see pjmedia_dir 74 */ 75 typedef enum pjmedia_dir pjmedia_dir; 76 77 66 78 /* Alternate names for media direction: */ 67 79 … … 81 93 #define PJMEDIA_DIR_CAPTURE_PLAYBACK PJMEDIA_DIR_ENCODING_DECODING 82 94 83 84 /**85 * Top level media type.86 */87 typedef enum pjmedia_type pjmedia_type;88 89 /**90 * Media direction.91 */92 typedef enum pjmedia_dir pjmedia_dir;93 94 /**95 * Codec info.96 */97 typedef struct pjmedia_codec_info pjmedia_codec_info;98 99 /**100 * Codec initialization parameter.101 */102 typedef struct pjmedia_codec_param pjmedia_codec_param;103 104 /**105 * Types of media frames.106 */107 typedef enum pjmedia_frame_type pjmedia_frame_type;108 109 /**110 * This structure describes a media frame.111 */112 typedef struct pjmedia_frame pjmedia_frame;113 114 /**115 * Codec instance.116 */117 typedef struct pjmedia_codec pjmedia_codec;118 119 /**120 * Codec factory.121 */122 typedef struct pjmedia_codec_factory pjmedia_codec_factory;123 124 /**125 * Codec operation.126 */127 typedef struct pjmedia_codec_op pjmedia_codec_op;128 129 /**130 * Codec factory operation.131 */132 typedef struct pjmedia_codec_factory_op pjmedia_codec_factory_op;133 134 /**135 * Codec manager.136 */137 typedef struct pjmedia_codec_mgr pjmedia_codec_mgr;138 95 139 96 /** … … 188 145 189 146 /** 190 * Forward declaration for SDP attribute (sdp.h)191 */192 typedef struct pjmedia_sdp_attr pjmedia_sdp_attr;193 194 /**195 * Forward declaration for SDP rtpmap attribute (sdp.h)196 */197 typedef struct pjmedia_sdp_rtpmap pjmedia_sdp_rtpmap;198 199 /**200 * Forward declaration for SDP fmtp attribute (sdp.h)201 */202 typedef struct pjmedia_sdp_fmtp pjmedia_sdp_fmtp;203 204 /**205 * Forward declaration for SDP connection info (sdp.h)206 */207 typedef struct pjmedia_sdp_conn pjmedia_sdp_conn;208 209 /**210 * Forward declaration for SDP media line (sdp.h)211 */212 typedef struct pjmedia_sdp_media pjmedia_sdp_media;213 214 /**215 * Forward declaration for SDP session (sdp.h)216 */217 typedef struct pjmedia_sdp_session pjmedia_sdp_session;218 219 /**220 * Forward declaration for SDP negotiator state (sdp_neg.h).221 */222 typedef enum pjmedia_sdp_neg_state pjmedia_sdp_neg_state;223 224 /**225 * Forward declaration for SDP negotiator (sdp_neg.h).226 */227 typedef struct pjmedia_sdp_neg pjmedia_sdp_neg;228 229 /**230 147 * Types of frame returned from jitter buffer (jbuf.h). 231 148 */ -
pjproject/trunk/pjmedia/include/pjmedia/wav_port.h
r409 r411 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 #ifndef __PJMEDIA_ FILE_PORT_H__20 #define __PJMEDIA_ FILE_PORT_H__19 #ifndef __PJMEDIA_WAV_PORT_H__ 20 #define __PJMEDIA_WAV_PORT_H__ 21 21 22 22 /** 23 * @file file_port.h24 * @brief File player and recorder.23 * @file wav_port.h 24 * @brief WAV file player and writer. 25 25 */ 26 26 #include <pjmedia/port.h> … … 36 36 * @param pool Pool to create memory buffers for this port. 37 37 * @param filename File name to open. 38 * @param ptime The duration (in miliseconds) of each frame read 39 * from this port. If the value is zero, the default 40 * duration (20ms) will be used. 38 41 * @param flags Port creation flags. 39 42 * @param buf_size Buffer size to be allocated. If the value is zero or … … 45 48 * @return PJ_SUCCESS on success. 46 49 */ 47 PJ_DECL(pj_status_t) pjmedia_ file_player_port_create( pj_pool_t *pool,48 49 unsigned flags,50 pj_ssize_t buff_size,51 void *user_data,52 pjmedia_port **p_port );53 50 PJ_DECL(pj_status_t) pjmedia_wav_player_port_create( pj_pool_t *pool, 51 const char *filename, 52 unsigned ptime, 53 unsigned flags, 54 pj_ssize_t buff_size, 55 void *user_data, 56 pjmedia_port **p_port ); 54 57 55 58 … … 70 73 * @return PJ_SUCCESS on success. 71 74 */ 72 PJ_DECL(pj_status_t) pjmedia_ file_writer_port_create( pj_pool_t *pool,75 PJ_DECL(pj_status_t) pjmedia_wav_writer_port_create( pj_pool_t *pool, 73 76 const char *filename, 74 77 unsigned sampling_rate, … … 87 90 88 91 89 #endif /* __PJMEDIA_ FILE_PORT_H__ */92 #endif /* __PJMEDIA_WAV_PORT_H__ */ -
pjproject/trunk/pjmedia/src/pjmedia-codec/gsm.c
r320 r411 50 50 51 51 /* Prototypes for GSM implementation. */ 52 static pj_status_t gsm_codec_default_attr(pjmedia_codec *codec,53 pjmedia_codec_param *attr);54 52 static pj_status_t gsm_codec_init( pjmedia_codec *codec, 55 53 pj_pool_t *pool ); … … 74 72 static pjmedia_codec_op gsm_op = 75 73 { 76 &gsm_codec_default_attr,77 74 &gsm_codec_init, 78 75 &gsm_codec_open, … … 234 231 235 232 pj_memset(attr, 0, sizeof(pjmedia_codec_param)); 236 attr->sample_rate = 8000; 233 attr->clock_rate = 8000; 234 attr->channel_cnt = 1; 237 235 attr->avg_bps = 13200; 238 236 attr->pcm_bits_per_sample = 16; … … 259 257 codecs[0].pt = PJMEDIA_RTP_PT_GSM; 260 258 codecs[0].type = PJMEDIA_TYPE_AUDIO; 261 codecs[0].sample_rate = 8000; 259 codecs[0].clock_rate = 8000; 260 codecs[0].channel_cnt = 1; 262 261 263 262 *count = 1; … … 329 328 330 329 /* 331 * Get codec default attributes.332 */333 static pj_status_t gsm_codec_default_attr( pjmedia_codec *codec,334 pjmedia_codec_param *attr)335 {336 return gsm_default_attr( codec->factory, NULL, attr);337 }338 339 /*340 330 * Init codec. 341 331 */ -
pjproject/trunk/pjmedia/src/pjmedia-codec/speex_codec.c
r320 r411 57 57 58 58 /* Prototypes for Speex implementation. */ 59 static pj_status_t spx_codec_default_attr(pjmedia_codec *codec,60 pjmedia_codec_param *attr);61 59 static pj_status_t spx_codec_init( pjmedia_codec *codec, 62 60 pj_pool_t *pool ); … … 81 79 static pjmedia_codec_op spx_op = 82 80 { 83 &spx_codec_default_attr,84 81 &spx_codec_init, 85 82 &spx_codec_open, … … 231 228 spx_factory.speex_param[PARAM_NB].enabled = 232 229 ((options & PJMEDIA_SPEEX_NO_NB) == 0); 233 spx_factory.speex_param[PARAM_NB].pt = 102;230 spx_factory.speex_param[PARAM_NB].pt = PJMEDIA_RTP_PT_SPEEX_NB; 234 231 spx_factory.speex_param[PARAM_NB].mode = &speex_nb_mode; 235 232 spx_factory.speex_param[PARAM_NB].clock_rate = 8000; … … 239 236 spx_factory.speex_param[PARAM_WB].enabled = 240 237 ((options & PJMEDIA_SPEEX_NO_WB) == 0); 241 spx_factory.speex_param[PARAM_WB].pt = 103;238 spx_factory.speex_param[PARAM_WB].pt = PJMEDIA_RTP_PT_SPEEX_WB; 242 239 spx_factory.speex_param[PARAM_WB].mode = &speex_wb_mode; 243 240 spx_factory.speex_param[PARAM_WB].clock_rate = 16000; … … 247 244 spx_factory.speex_param[PARAM_UWB].enabled = 248 245 ((options & PJMEDIA_SPEEX_NO_UWB) == 0); 249 spx_factory.speex_param[PARAM_UWB].pt = 104;246 spx_factory.speex_param[PARAM_UWB].pt = PJMEDIA_RTP_PT_SPEEX_UWB; 250 247 spx_factory.speex_param[PARAM_UWB].mode = &speex_uwb_mode; 251 248 spx_factory.speex_param[PARAM_UWB].clock_rate = 32000; … … 359 356 /* Check clock-rate */ 360 357 for (i=0; i<PJ_ARRAY_SIZE(spx_factory.speex_param); ++i) { 361 if (info-> sample_rate == spx_factory.speex_param[i].clock_rate) {358 if (info->clock_rate == spx_factory.speex_param[i].clock_rate) { 362 359 /* Okay, let's Speex! */ 363 360 return PJ_SUCCESS; … … 382 379 pj_memset(attr, 0, sizeof(pjmedia_codec_param)); 383 380 attr->pt = id->pt; 384 385 if (id->sample_rate <= 8000) { 386 attr->sample_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 381 attr->channel_cnt = 1; 382 383 if (id->clock_rate <= 8000) { 384 attr->clock_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 387 385 attr->avg_bps = spx_factory.speex_param[PARAM_NB].bitrate; 388 386 389 } else if (id-> sample_rate <= 16000) {390 attr-> sample_rate = spx_factory.speex_param[PARAM_WB].clock_rate;387 } else if (id->clock_rate <= 16000) { 388 attr->clock_rate = spx_factory.speex_param[PARAM_WB].clock_rate; 391 389 attr->avg_bps = spx_factory.speex_param[PARAM_WB].bitrate; 392 390 393 391 } else { 394 392 /* Wow.. somebody is doing ultra-wideband. Cool...! */ 395 attr-> sample_rate = spx_factory.speex_param[PARAM_UWB].clock_rate;393 attr->clock_rate = spx_factory.speex_param[PARAM_UWB].clock_rate; 396 394 attr->avg_bps = spx_factory.speex_param[PARAM_UWB].bitrate; 397 395 } … … 402 400 403 401 /* Default flags. */ 404 attr->cng _enabled= 1;405 attr->concl _enabled= 1;406 attr->hpf _enabled= 1;407 attr->lpf _enabled=1 ;408 attr->penh _enabled=1 ;402 attr->cng = 1; 403 attr->concl = 1; 404 attr->hpf = 1; 405 attr->lpf =1 ; 406 attr->penh =1 ; 409 407 410 408 /* Default, set VAD off as it caused voice chip off */ 411 attr->vad _enabled= 0;409 attr->vad = 0; 412 410 413 411 return PJ_SUCCESS; … … 443 441 codecs[*count].pt = spx_factory.speex_param[i].pt; 444 442 codecs[*count].type = PJMEDIA_TYPE_AUDIO; 445 codecs[*count].sample_rate = spx_factory.speex_param[i].clock_rate; 443 codecs[*count].clock_rate = spx_factory.speex_param[i].clock_rate; 444 codecs[*count].channel_cnt = 1; 446 445 447 446 ++*count; … … 487 486 spx->dec = NULL; 488 487 489 if (id-> sample_rate <= 8000)488 if (id->clock_rate <= 8000) 490 489 spx->param_id = PARAM_NB; 491 else if (id-> sample_rate <= 16000)490 else if (id->clock_rate <= 16000) 492 491 spx->param_id = PARAM_WB; 493 492 else … … 521 520 522 521 return PJ_SUCCESS; 523 }524 525 /*526 * Get codec default attributes.527 */528 static pj_status_t spx_codec_default_attr( pjmedia_codec *codec,529 pjmedia_codec_param *attr)530 {531 struct spx_private *spx;532 pjmedia_codec_info info;533 534 spx = (struct spx_private*) codec->codec_data;535 536 info.encoding_name = pj_str("speex");537 info.pt = 200; /* Don't care */538 info.sample_rate = spx_factory.speex_param[spx->param_id].clock_rate;539 info.type = PJMEDIA_TYPE_AUDIO;540 541 return spx_default_attr( codec->factory, &info, attr);542 522 } 543 523 … … 580 560 581 561 /* Sampling rate. */ 582 tmp = attr-> sample_rate;562 tmp = attr->clock_rate; 583 563 speex_encoder_ctl(spx->enc, SPEEX_SET_SAMPLING_RATE, 584 564 &spx_factory.speex_param[id].clock_rate); 585 565 586 566 /* VAD */ 587 tmp = attr->vad _enabled;567 tmp = attr->vad; 588 568 speex_encoder_ctl(spx->enc, SPEEX_SET_VAD, &tmp); 589 569 … … 609 589 610 590 /* PENH */ 611 tmp = attr->penh _enabled;591 tmp = attr->penh; 612 592 speex_decoder_ctl(spx->dec, SPEEX_SET_ENH, &tmp); 613 593 -
pjproject/trunk/pjmedia/src/pjmedia/codec.c
r276 r411 19 19 #include <pjmedia/codec.h> 20 20 #include <pjmedia/errno.h> 21 #include <pj/array.h> 22 #include <pj/assert.h> 23 #include <pj/log.h> 21 24 #include <pj/pool.h> 22 25 #include <pj/string.h> 23 #include <pj/assert.h>24 #include <pj/log.h>25 26 26 27 #define THIS_FILE "codec.c" 27 28 28 /* 29 * Reinitialize array of supported codecs. 30 */ 31 static void enum_all_codecs (pjmedia_codec_mgr *mgr) 32 { 33 pjmedia_codec_factory *factory; 34 35 mgr->codec_cnt = 0; 36 37 factory = mgr->factory_list.next; 38 while (factory != &mgr->factory_list) { 39 unsigned count; 40 pj_status_t status; 41 42 count = PJ_ARRAY_SIZE(mgr->codecs) - mgr->codec_cnt; 43 status = factory->op->enum_info(factory, &count, 44 mgr->codecs+mgr->codec_cnt); 45 if (status == PJ_SUCCESS) 46 mgr->codec_cnt += count; 47 48 factory = factory->next; 49 } 50 } 29 30 31 32 /* Sort codecs in codec manager based on priorities */ 33 static void sort_codecs(pjmedia_codec_mgr *mgr); 34 51 35 52 36 /* … … 62 46 return PJ_SUCCESS; 63 47 } 48 64 49 65 50 /* … … 70 55 pjmedia_codec_factory *factory) 71 56 { 57 pjmedia_codec_info info[PJMEDIA_CODEC_MGR_MAX_CODECS]; 58 unsigned i, count; 59 pj_status_t status; 60 72 61 PJ_ASSERT_RETURN(mgr && factory, PJ_EINVAL); 73 62 63 /* Enum codecs */ 64 count = PJ_ARRAY_SIZE(info); 65 status = factory->op->enum_info(factory, &count, info); 66 if (status != PJ_SUCCESS) 67 return status; 68 69 70 /* Check codec count */ 71 if (count + mgr->codec_cnt > PJ_ARRAY_SIZE(mgr->codec_desc)) 72 return PJ_ETOOMANY; 73 74 75 /* Save the codecs */ 76 for (i=0; i<count; ++i) { 77 pj_memcpy( &mgr->codec_desc[mgr->codec_cnt+i], 78 &info[i], sizeof(pjmedia_codec_info)); 79 mgr->codec_desc[mgr->codec_cnt+i].prio = PJMEDIA_CODEC_PRIO_NORMAL; 80 mgr->codec_desc[mgr->codec_cnt+i].factory = factory; 81 pjmedia_codec_info_to_id( &info[i], 82 mgr->codec_desc[mgr->codec_cnt+i].id, 83 sizeof(pjmedia_codec_id)); 84 } 85 86 /* Update count */ 87 mgr->codec_cnt += count; 88 89 /* Re-sort codec based on priorities */ 90 sort_codecs(mgr); 91 92 /* Add factory to the list */ 74 93 pj_list_push_back(&mgr->factory_list, factory); 75 enum_all_codecs (mgr); 94 76 95 77 96 return PJ_SUCCESS; 78 97 } 98 79 99 80 100 /* … … 85 105 pjmedia_codec_factory *factory) 86 106 { 87 107 unsigned i; 88 108 PJ_ASSERT_RETURN(mgr && factory, PJ_EINVAL); 89 109 … … 92 112 PJ_ENOTFOUND); 93 113 94 114 /* Erase factory from the factory list */ 95 115 pj_list_erase(factory); 96 enum_all_codecs (mgr); 116 117 118 /* Remove all supported codecs from the codec manager that were created 119 * by the specified factory. 120 */ 121 for (i=0; i<mgr->codec_cnt; ) { 122 123 if (mgr->codec_desc[i].factory == factory) { 124 125 pj_array_erase(mgr->codec_desc, sizeof(mgr->codec_desc[0]), 126 mgr->codec_cnt, i); 127 --mgr->codec_cnt; 128 129 } else { 130 ++i; 131 } 132 } 133 97 134 98 135 return PJ_SUCCESS; 99 136 } 137 100 138 101 139 /* … … 105 143 pjmedia_codec_mgr_enum_codecs(pjmedia_codec_mgr *mgr, 106 144 unsigned *count, 107 pjmedia_codec_info codecs[]) 108 { 145 pjmedia_codec_info codecs[], 146 unsigned *prio) 147 { 148 unsigned i; 149 109 150 PJ_ASSERT_RETURN(mgr && count && codecs, PJ_EINVAL); 110 151 … … 112 153 *count = mgr->codec_cnt; 113 154 114 pj_memcpy(codecs, mgr->codecs, *count * sizeof(pjmedia_codec_info)); 155 for (i=0; i<*count; ++i) { 156 pj_memcpy(&codecs[i], 157 &mgr->codec_desc[i].info, 158 sizeof(pjmedia_codec_info)); 159 } 160 161 if (prio) { 162 for (i=0; i < *count; ++i) 163 prio[i] = mgr->codec_desc[i].prio; 164 } 115 165 116 166 return PJ_SUCCESS; 117 167 } 118 168 169 119 170 /* 120 171 * Get codec info for static payload type. 121 172 */ 122 PJ_DEF(pj_status_t) pjmedia_codec_mgr_get_codec_info(pjmedia_codec_mgr *mgr, 123 unsigned pt, 124 pjmedia_codec_info *inf) 173 PJ_DEF(pj_status_t) 174 pjmedia_codec_mgr_get_codec_info( pjmedia_codec_mgr *mgr, 175 unsigned pt, 176 const pjmedia_codec_info **p_info) 125 177 { 126 178 unsigned i; 127 179 128 PJ_ASSERT_RETURN(mgr && inf&& pt>=0 && pt < 96, PJ_EINVAL);180 PJ_ASSERT_RETURN(mgr && p_info && pt>=0 && pt < 96, PJ_EINVAL); 129 181 130 182 for (i=0; i<mgr->codec_cnt; ++i) { 131 if (mgr->codec s[i].pt == pt) {132 pj_memcpy(inf, &mgr->codecs[i], sizeof(pjmedia_codec_info));183 if (mgr->codec_desc[i].info.pt == pt) { 184 *p_info = &mgr->codec_desc[i].info; 133 185 return PJ_SUCCESS; 134 186 } … … 137 189 return PJMEDIA_CODEC_EUNSUP; 138 190 } 191 192 193 /* 194 * Convert codec info struct into a unique codec identifier. 195 * A codec identifier looks something like "L16/44100/2". 196 */ 197 PJ_DEF(char*) pjmedia_codec_info_to_id( const pjmedia_codec_info *info, 198 char *id, unsigned max_len ) 199 { 200 int len; 201 202 PJ_ASSERT_RETURN(info && id && max_len, NULL); 203 204 len = pj_ansi_snprintf(id, max_len, "%.*s/%u/%u", 205 (int)info->encoding_name.slen, 206 info->encoding_name.ptr, 207 info->clock_rate, 208 info->channel_cnt); 209 210 if (len < 1 || len >= (int)max_len) { 211 id[0] = '\0'; 212 return NULL; 213 } 214 215 return id; 216 } 217 218 219 /* 220 * Find codecs by the unique codec identifier. This function will find 221 * all codecs that match the codec identifier prefix. For example, if 222 * "L16" is specified, then it will find "L16/8000/1", "L16/16000/1", 223 * and so on, up to the maximum count specified in the argument. 224 */ 225 PJ_DEF(pj_status_t) 226 pjmedia_codec_mgr_find_codecs_by_id( pjmedia_codec_mgr *mgr, 227 const pj_str_t *codec_id, 228 unsigned *count, 229 const pjmedia_codec_info *p_info[], 230 unsigned prio[]) 231 { 232 unsigned i, found = 0; 233 234 PJ_ASSERT_RETURN(mgr && codec_id && count && *count, PJ_EINVAL); 235 236 for (i=0; i<mgr->codec_cnt; ++i) { 237 238 if (pj_strnicmp2(codec_id, mgr->codec_desc[i].id, 239 codec_id->slen) == 0) 240 { 241 242 if (p_info) 243 p_info[found] = &mgr->codec_desc[i].info; 244 if (prio) 245 prio[found] = mgr->codec_desc[i].prio; 246 247 ++found; 248 249 if (found >= *count) 250 break; 251 } 252 253 } 254 255 *count = found; 256 257 return found ? PJ_SUCCESS : PJ_ENOTFOUND; 258 } 259 260 261 /* Swap two codecs positions in codec manager */ 262 static void swap_codec(pjmedia_codec_mgr *mgr, unsigned i, unsigned j) 263 { 264 struct pjmedia_codec_desc tmp; 265 266 pj_memcpy(&tmp, &mgr->codec_desc[i], sizeof(struct pjmedia_codec_desc)); 267 268 pj_memcpy(&mgr->codec_desc[i], &mgr->codec_desc[j], 269 sizeof(struct pjmedia_codec_desc)); 270 271 pj_memcpy(&mgr->codec_desc[j], &tmp, sizeof(struct pjmedia_codec_desc)); 272 } 273 274 275 /* Sort codecs in codec manager based on priorities */ 276 static void sort_codecs(pjmedia_codec_mgr *mgr) 277 { 278 unsigned i; 279 280 /* Re-sort */ 281 for (i=0; i<mgr->codec_cnt; ++i) { 282 unsigned j, max; 283 284 for (max=i, j=i+1; j<mgr->codec_cnt; ++j) { 285 if (mgr->codec_desc[j].prio > mgr->codec_desc[max].prio) 286 max = j; 287 } 288 289 if (max != i) 290 swap_codec(mgr, i, max); 291 } 292 293 /* Change PJMEDIA_CODEC_PRIO_HIGHEST codecs to NEXT_HIGHER */ 294 for (i=0; i<mgr->codec_cnt; ++i) { 295 if (mgr->codec_desc[i].prio == PJMEDIA_CODEC_PRIO_HIGHEST) 296 mgr->codec_desc[i].prio = PJMEDIA_CODEC_PRIO_NEXT_HIGHER; 297 else 298 break; 299 } 300 } 301 302 303 /** 304 * Set codec priority. The codec priority determines the order of 305 * the codec in the SDP created by the endpoint. If more than one codecs 306 * are found with the same codec_id prefix, then the function sets the 307 * priorities of all those codecs. 308 */ 309 PJ_DEF(pj_status_t) 310 pjmedia_codec_mgr_set_codec_priority(pjmedia_codec_mgr *mgr, 311 const pj_str_t *codec_id, 312 pjmedia_codec_priority prio) 313 { 314 unsigned i, found = 0; 315 316 PJ_ASSERT_RETURN(mgr && codec_id, PJ_EINVAL); 317 318 /* Update the priorities of affected codecs */ 319 for (i=0; i<mgr->codec_cnt; ++i) 320 { 321 if (codec_id->slen == 0 || 322 pj_strnicmp2(codec_id, mgr->codec_desc[i].id, 323 codec_id->slen) == 0) 324 { 325 mgr->codec_desc[i].prio = prio; 326 ++found; 327 } 328 } 329 330 if (!found) 331 return PJ_ENOTFOUND; 332 333 /* Re-sort codecs */ 334 sort_codecs(mgr); 335 336 337 return PJ_SUCCESS; 338 } 339 139 340 140 341 /* -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r358 r411 238 238 if (port) { 239 239 conf_port->port = port; 240 conf_port->clock_rate = port->info. sample_rate;240 conf_port->clock_rate = port->info.clock_rate; 241 241 conf_port->samples_per_frame = port->info.samples_per_frame; 242 242 } else { … … 443 443 conf->master_port->info.need_info = 0; 444 444 conf->master_port->info.pt = 0xFF; 445 conf->master_port->info. sample_rate = clock_rate;445 conf->master_port->info.clock_rate = clock_rate; 446 446 conf->master_port->info.samples_per_frame = samples_per_frame; 447 447 conf->master_port->info.signature = 0; … … 1091 1091 pj_int16_t *buf; 1092 1092 unsigned j; 1093 pj_status_t status; 1093 1094 1094 1095 /* If port is muted or nobody is transmitting to this port, … … 1181 1182 } 1182 1183 1183 /* If port has the same clock_ date and samples_per_frame settings as1184 /* If port has the same clock_rate and samples_per_frame settings as 1184 1185 * the conference bridge, transmit the frame as is. 1185 1186 */ … … 1225 1226 } 1226 1227 1227 /* Transmit once we have enough frame in the tx_buf. */ 1228 if (cport->tx_buf_count >= cport->samples_per_frame) { 1228 /* Transmit while we have enough frame in the tx_buf. */ 1229 status = PJ_SUCCESS; 1230 while (cport->tx_buf_count >= cport->samples_per_frame && 1231 status == PJ_SUCCESS) 1232 { 1229 1233 1230 pj_status_t status;1231 1232 1234 TRACE_((THIS_FILE, "write_port %.*s: count=%d", 1233 1235 (int)cport->name.slen, cport->name.ptr, … … 1260 1262 TRACE_((THIS_FILE, " tx_buf count now is %d", 1261 1263 cport->tx_buf_count)); 1262 1263 return status; 1264 } 1265 1266 return PJ_SUCCESS; 1264 } 1265 1266 return status; 1267 1267 } 1268 1268 -
pjproject/trunk/pjmedia/src/pjmedia/endpoint.c
r350 r411 330 330 for (i=0; i<endpt->codec_mgr.codec_cnt; ++i) { 331 331 332 pjmedia_codec_info *codec_info = &endpt->codec_mgr.codecs[i];332 pjmedia_codec_info *codec_info; 333 333 pjmedia_sdp_rtpmap rtpmap; 334 char tmp_param[3]; 334 335 pjmedia_sdp_attr *attr; 335 pj_str_t *fmt = &m->desc.fmt[m->desc.fmt_count++]; 336 pj_str_t *fmt; 337 338 if (endpt->codec_mgr.codec_desc[i].prio == PJMEDIA_CODEC_PRIO_DISABLED) 339 break; 340 341 codec_info = &endpt->codec_mgr.codec_desc[i].info; 342 fmt = &m->desc.fmt[m->desc.fmt_count++]; 336 343 337 344 fmt->ptr = pj_pool_alloc(pool, 8); … … 339 346 340 347 rtpmap.pt = *fmt; 341 rtpmap.clock_rate = codec_info-> sample_rate;348 rtpmap.clock_rate = codec_info->clock_rate; 342 349 rtpmap.enc_name = codec_info->encoding_name; 343 rtpmap.param.slen = 0; 350 351 /* For audio codecs, rtpmap parameters denotes the number 352 * of channels, which can be omited if the value is 1. 353 */ 354 if (codec_info->type == PJMEDIA_TYPE_AUDIO && 355 codec_info->channel_cnt > 1) 356 { 357 /* Can only support one digit channel count */ 358 pj_assert(codec_info->channel_cnt < 10); 359 360 tmp_param[0] = '/'; 361 tmp_param[1] = (char)('0' + codec_info->channel_cnt); 362 363 rtpmap.param.ptr = tmp_param; 364 rtpmap.param.slen = 2; 365 366 } else { 367 rtpmap.param.slen = 0; 368 } 344 369 345 370 pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr); … … 389 414 count = PJ_ARRAY_SIZE(codec_info); 390 415 if (pjmedia_codec_mgr_enum_codecs(&endpt->codec_mgr, 391 &count, codec_info ) != PJ_SUCCESS)416 &count, codec_info, NULL) != PJ_SUCCESS) 392 417 { 393 418 PJ_LOG(3,(THIS_FILE, " -error: failed to enum codecs")); … … 417 442 418 443 PJ_LOG(3,(THIS_FILE, 419 " %s codec #%2d: pt=%d (%.*s @%dKHz , %d bps, ptime=%d ms, vad=%d, cng=%d)",444 " %s codec #%2d: pt=%d (%.*s @%dKHz/%d, %d bps, ptime=%d ms, vad=%d, cng=%d)", 420 445 type, i, codec_info[i].pt, 421 446 (int)codec_info[i].encoding_name.slen, 422 447 codec_info[i].encoding_name.ptr, 423 codec_info[i].sample_rate/1000, 448 codec_info[i].clock_rate/1000, 449 codec_info[i].channel_cnt, 424 450 param.avg_bps, param.ptime, 425 param.vad _enabled,426 param.cng _enabled));451 param.vad, 452 param.cng)); 427 453 } 428 454 #endif -
pjproject/trunk/pjmedia/src/pjmedia/g711.c
r320 r411 36 36 /* These are the only public functions exported to applications */ 37 37 PJ_DECL(pj_status_t) g711_init_factory (pjmedia_codec_factory *factory, pj_pool_t *pool); 38 PJ_DECL(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory);39 38 40 39 /* Algorithm prototypes. */ … … 60 59 61 60 /* Prototypes for G711 implementation. */ 62 static pj_status_t g711_codec_default_attr (pjmedia_codec *codec,63 pjmedia_codec_param *attr);64 61 static pj_status_t g711_init( pjmedia_codec *codec, 65 62 pj_pool_t *pool ); … … 84 81 static pjmedia_codec_op g711_op = 85 82 { 86 &g711_codec_default_attr ,87 83 &g711_init, 88 84 &g711_open, … … 120 116 121 117 122 PJ_DEF(pj_status_t) g711_deinit_factory (pjmedia_codec_factory *factory)123 {124 PJ_ASSERT_RETURN(factory==&g711_factory.base, PJ_EINVAL);125 126 /* Invalidate member to help detect errors */127 g711_factory.codec_list.next = g711_factory.codec_list.prev = NULL;128 return 0;129 }130 131 118 PJ_DEF(pj_status_t) pjmedia_codec_g711_init(pjmedia_endpt *endpt) 132 119 { … … 223 210 } 224 211 225 static pj_status_t g711_test_alloc( pjmedia_codec_factory *factory, const pjmedia_codec_info *id ) 212 static pj_status_t g711_test_alloc(pjmedia_codec_factory *factory, 213 const pjmedia_codec_info *id ) 226 214 { 227 215 PJ_UNUSED_ARG(factory); … … 238 226 239 227 pj_memset(attr, 0, sizeof(pjmedia_codec_param)); 240 attr->sample_rate = 8000; 228 attr->clock_rate = 8000; 229 attr->channel_cnt = 1; 241 230 attr->avg_bps = G711_BPS; 242 231 attr->pcm_bits_per_sample = 16; … … 261 250 codecs[count].pt = PJMEDIA_RTP_PT_PCMU; 262 251 codecs[count].encoding_name = pj_str("PCMU"); 263 codecs[count].sample_rate = 8000; 252 codecs[count].clock_rate = 8000; 253 codecs[count].channel_cnt = 1; 264 254 ++count; 265 255 } 266 256 if (count < *max_count) { 267 codecs[1].type = PJMEDIA_TYPE_AUDIO; 268 codecs[1].pt = PJMEDIA_RTP_PT_PCMA; 269 codecs[1].encoding_name = pj_str("PCMA"); 270 codecs[1].sample_rate = 8000; 257 codecs[count].type = PJMEDIA_TYPE_AUDIO; 258 codecs[count].pt = PJMEDIA_RTP_PT_PCMA; 259 codecs[count].encoding_name = pj_str("PCMA"); 260 codecs[count].clock_rate = 8000; 261 codecs[count].channel_cnt = 1; 271 262 ++count; 272 263 } … … 293 284 294 285 codec = pj_pool_alloc(g711_factory.pool, sizeof(pjmedia_codec)); 295 codec_priv = pj_pool_alloc(g711_factory.pool, sizeof(struct g711_private)); 286 codec_priv = pj_pool_alloc(g711_factory.pool, 287 sizeof(struct g711_private)); 296 288 if (!codec || !codec_priv) { 297 289 pj_mutex_unlock(g711_factory.mutex); … … 320 312 } 321 313 322 static pj_status_t g711_dealloc_codec( pjmedia_codec_factory *factory, pjmedia_codec *codec ) 314 static pj_status_t g711_dealloc_codec(pjmedia_codec_factory *factory, 315 pjmedia_codec *codec ) 323 316 { 324 317 … … 343 336 } 344 337 345 static pj_status_t g711_codec_default_attr (pjmedia_codec *codec, pjmedia_codec_param *attr)346 {347 struct g711_private *priv = codec->codec_data;348 pjmedia_codec_info id;349 350 id.pt = priv->pt;351 return g711_default_attr (NULL, &id, attr);352 }353 354 338 static pj_status_t g711_init( pjmedia_codec *codec, pj_pool_t *pool ) 355 339 { … … 361 345 } 362 346 363 static pj_status_t g711_open( pjmedia_codec *codec, pjmedia_codec_param *attr ) 347 static pj_status_t g711_open(pjmedia_codec *codec, 348 pjmedia_codec_param *attr ) 364 349 { 365 350 struct g711_private *priv = codec->codec_data; … … 401 386 } 402 387 403 static pj_status_t g711_encode( pjmedia_codec *codec, const struct pjmedia_frame *input, 404 unsigned output_buf_len, struct pjmedia_frame *output) 388 static pj_status_t g711_encode(pjmedia_codec *codec, 389 const struct pjmedia_frame *input, 390 unsigned output_buf_len, 391 struct pjmedia_frame *output) 405 392 { 406 393 pj_int16_t *samples = (pj_int16_t*) input->buf; … … 409 396 /* Check output buffer length */ 410 397 if (output_buf_len < input->size / 2) 411 return -1;398 return PJMEDIA_CODEC_EFRMTOOSHORT; 412 399 413 400 /* Encode */ … … 428 415 429 416 } else { 430 return -1;417 return PJMEDIA_EINVALIDPT; 431 418 } 432 419 … … 434 421 output->size = input->size / 2; 435 422 436 return 0; 437 } 438 439 static pj_status_t g711_decode( pjmedia_codec *codec, const struct pjmedia_frame *input, 440 unsigned output_buf_len, struct pjmedia_frame *output) 423 return PJ_SUCCESS; 424 } 425 426 static pj_status_t g711_decode(pjmedia_codec *codec, 427 const struct pjmedia_frame *input, 428 unsigned output_buf_len, 429 struct pjmedia_frame *output) 441 430 { 442 431 struct g711_private *priv = codec->codec_data; … … 444 433 /* Check output buffer length */ 445 434 if (output_buf_len < input->size * 2) 446 return -1;435 return PJMEDIA_CODEC_EPCMTOOSHORT; 447 436 448 437 /* Decode */ … … 465 454 466 455 } else { 467 return -1;456 return PJMEDIA_EINVALIDPT; 468 457 } 469 458 … … 471 460 output->size = input->size * 2; 472 461 473 return 0;462 return PJ_SUCCESS; 474 463 } 475 464 -
pjproject/trunk/pjmedia/src/pjmedia/jbuf.c
r408 r411 323 323 static void jbuf_calculate_jitter(pjmedia_jbuf *jb) 324 324 { 325 enum { STABLE_HISTORY_LIMIT = ( 500/20) };325 enum { STABLE_HISTORY_LIMIT = (100*2) }; 326 326 327 327 jb->jb_last_jitter = PJ_ABS(jb->jb_level-jb->jb_last_level); … … 342 342 jb->jb_max_hist_jitter = 0; 343 343 344 if (jb->jb_op_count >= 100&&344 if (jb->jb_op_count >= STABLE_HISTORY_LIMIT*2 && 345 345 (int)jb_framelist_size(&jb->jb_framelist) > jb->jb_prefetch+2) 346 346 { … … 361 361 jb->jb_max_hist_jitter = 0; 362 362 363 if (jb->jb_op_count >= 100) {363 if (jb->jb_op_count >= STABLE_HISTORY_LIMIT * 2) { 364 364 if ((int)jb_framelist_size(&jb->jb_framelist) > jb->jb_prefetch+2) 365 365 { -
pjproject/trunk/pjmedia/src/pjmedia/master_port.c
r404 r411 60 60 61 61 /* Both ports MUST have the equal ptime */ 62 PJ_ASSERT_RETURN(u_port->info. sample_rate/u_port->info.samples_per_frame==63 d_port->info. sample_rate/d_port->info.samples_per_frame,62 PJ_ASSERT_RETURN(u_port->info.clock_rate/u_port->info.samples_per_frame== 63 d_port->info.clock_rate/d_port->info.samples_per_frame, 64 64 PJMEDIA_ENCSAMPLESPFRAME); 65 65 66 66 67 67 /* Get clock_rate and samples_per_frame from one of the port. */ 68 clock_rate = u_port->info. sample_rate;68 clock_rate = u_port->info.clock_rate; 69 69 samples_per_frame = u_port->info.samples_per_frame; 70 70 -
pjproject/trunk/pjmedia/src/pjmedia/null_port.c
r322 r411 52 52 port->info.need_info = 0; 53 53 port->info.pt = 0xFF; 54 port->info. sample_rate = sampling_rate;54 port->info.clock_rate = sampling_rate; 55 55 port->info.samples_per_frame = samples_per_frame; 56 56 port->info.channel_count = channel_count; -
pjproject/trunk/pjmedia/src/pjmedia/resample_port.c
r358 r411 76 76 rport->base.info.need_info = 0; 77 77 rport->base.info.pt = 0xFF; 78 rport->base.info. sample_rate = upstream_rate;78 rport->base.info.clock_rate = upstream_rate; 79 79 rport->base.info.samples_per_frame = upstream_samples_per_frame; 80 80 rport->base.info.signature = 0; -
pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
r408 r411 134 134 pj_time_val now; 135 135 136 /* Reset packet */ 136 137 pj_memset(rtcp_pkt, 0, sizeof(pjmedia_rtcp_pkt)); 137 138 139 /* Reset statistics */ 140 pj_memset(&sess->stat, 0, sizeof(pjmedia_rtcp_stat)); 141 138 142 /* Name */ 139 143 sess->name = name ? name : THIS_FILE, -
pjproject/trunk/pjmedia/src/pjmedia/session.c
r390 r411 195 195 si->fmt.pt = pj_strtoul(&local_m->desc.fmt[0]); 196 196 pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name); 197 si->fmt.sample_rate = rtpmap->clock_rate; 197 si->fmt.clock_rate = rtpmap->clock_rate; 198 199 /* For audio codecs, rtpmap parameters denotes the number of 200 * channels. 201 */ 202 if (si->type == PJMEDIA_TYPE_AUDIO && rtpmap->param.slen) { 203 204 if (rtpmap->param.slen == 2) { 205 si->fmt.channel_cnt = rtpmap->param.ptr[1] - '0'; 206 } else { 207 pj_str_t cnt; 208 cnt.ptr = rtpmap->param.ptr + 1; 209 cnt.slen = rtpmap->param.slen - 1; 210 si->fmt.channel_cnt = (unsigned) pj_strtoul(&cnt); 211 } 212 213 } else { 214 si->fmt.channel_cnt = 1; 215 } 198 216 199 217 } else { 200 218 pjmedia_codec_mgr *mgr; 219 pjmedia_codec_info *p_info; 201 220 202 221 mgr = pjmedia_endpt_get_codec_mgr(endpt); 203 222 204 status = pjmedia_codec_mgr_get_codec_info( mgr, pt, & si->fmt);223 status = pjmedia_codec_mgr_get_codec_info( mgr, pt, &p_info); 205 224 if (status != PJ_SUCCESS) 206 225 return status; 226 227 pj_memcpy(&si->fmt, p_info, sizeof(pjmedia_codec_info)); 207 228 } 208 229 … … 225 246 si->fmt.pt = pj_strtoul(&local_m->desc.fmt[0]); 226 247 pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name); 227 si->fmt.sample_rate = rtpmap->clock_rate; 248 si->fmt.clock_rate = rtpmap->clock_rate; 249 250 /* For audio codecs, rtpmap parameters denotes the number of 251 * channels. 252 */ 253 if (si->type == PJMEDIA_TYPE_AUDIO && rtpmap->param.slen) { 254 255 if (rtpmap->param.slen == 2) { 256 si->fmt.channel_cnt = rtpmap->param.ptr[1] - '0'; 257 } else { 258 pj_str_t cnt; 259 cnt.ptr = rtpmap->param.ptr + 1; 260 cnt.slen = rtpmap->param.slen - 1; 261 si->fmt.channel_cnt = (unsigned) pj_strtoul(&cnt); 262 } 263 264 } else { 265 si->fmt.channel_cnt = 1; 266 } 228 267 229 268 /* Determine payload type for outgoing channel, by finding -
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r358 r411 345 345 */ 346 346 pinfo = &port->info; 347 if (pinfo-> sample_rate != snd_port->clock_rate)347 if (pinfo->clock_rate != snd_port->clock_rate) 348 348 return PJMEDIA_ENCCLOCKRATE; 349 349 -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r408 r411 159 159 struct pjmedia_frame frame_in, frame_out; 160 160 161 /* Return no frame is channel is paused */ 162 if (channel->paused) { 163 frame->type = PJMEDIA_FRAME_TYPE_NONE; 164 return PJ_SUCCESS; 165 } 166 161 167 /* Lock jitter buffer mutex */ 162 168 pj_mutex_lock( stream->jb_mutex ); … … 175 181 return PJ_SUCCESS; 176 182 } 177 178 183 179 184 /* Decode */ … … 321 326 int rtphdrlen; 322 327 pj_ssize_t sent; 328 329 330 /* Don't do anything if stream is paused */ 331 if (channel->paused) 332 return PJ_SUCCESS; 333 323 334 324 335 /* Number of samples in the frame */ … … 758 769 /* Allocate buffer for decoding to PCM: */ 759 770 760 channel->pcm_buf_size = codec_param->sample_rate * 771 channel->pcm_buf_size = codec_param->clock_rate * 772 codec_param->channel_cnt * 761 773 codec_param->pcm_bits_per_sample / 8 * 762 774 PJMEDIA_MAX_FRAME_DURATION_MS / 1000; … … 791 803 pj_ioqueue_callback ioqueue_cb; 792 804 pj_uint16_t rtcp_port; 805 unsigned jbuf_init, jbuf_max; 793 806 pj_status_t status; 794 807 … … 814 827 stream->port.info.pt = info->fmt.pt; 815 828 pj_strdup(pool, &stream->port.info.encoding_name, &info->fmt.encoding_name); 816 stream->port.info.c hannel_count = 1;817 stream->port.info. sample_rate = info->fmt.sample_rate;829 stream->port.info.clock_rate = info->fmt.clock_rate; 830 stream->port.info.channel_count = info->fmt.channel_cnt; 818 831 stream->port.user_data = stream; 819 832 stream->port.put_frame = &put_frame; … … 832 845 stream->rem_rtcp_addr.sin_port = pj_htons(rtcp_port); 833 846 stream->rtcp_interval = (PJMEDIA_RTCP_INTERVAL + (pj_rand() % 8000)) * 834 info->fmt. sample_rate / 1000;847 info->fmt.clock_rate / 1000; 835 848 836 849 stream->tx_event_pt = info->tx_event_pt ? info->tx_event_pt : -1; … … 856 869 /* Get default codec param: */ 857 870 858 status = stream->codec->op->default_attr(stream->codec, &codec_param); 871 //status = stream->codec->op->default_attr(stream->codec, &codec_param); 872 status = pjmedia_codec_mgr_get_default_param( stream->codec_mgr, 873 &info->fmt, &codec_param); 859 874 if (status != PJ_SUCCESS) 860 875 goto err_cleanup; … … 862 877 /* Set additional info. */ 863 878 stream->port.info.bits_per_sample = 16; 864 stream->port.info.samples_per_frame = info->fmt. sample_rate*codec_param.ptime/1000;879 stream->port.info.samples_per_frame = info->fmt.clock_rate*codec_param.ptime/1000; 865 880 stream->port.info.bytes_per_frame = codec_param.avg_bps/8 * codec_param.ptime/1000; 866 881 … … 881 896 882 897 pjmedia_rtcp_init(&stream->rtcp, stream->port.info.name.ptr, 883 info->fmt. sample_rate,898 info->fmt.clock_rate, 884 899 stream->port.info.samples_per_frame, 885 900 info->ssrc); … … 887 902 888 903 /* Create jitter buffer: */ 889 904 jbuf_init = 100 / (stream->port.info.samples_per_frame * 1000 / 905 info->fmt.clock_rate); 906 jbuf_max = 600 / (stream->port.info.samples_per_frame * 1000 / 907 info->fmt.clock_rate); 890 908 status = pjmedia_jbuf_create(pool, &stream->port.info.name, 891 stream->frame_size, 15, 100, 909 stream->frame_size, 910 jbuf_init, jbuf_max, 892 911 &stream->jb); 893 912 if (status != PJ_SUCCESS)
Note: See TracChangeset
for help on using the changeset viewer.