- Timestamp:
- May 19, 2014 5:51:10 AM (11 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/swig/pjsua2.i
r4704 r4845 95 95 %template(BuddyVector) std::vector<pj::Buddy*>; 96 96 %template(AudioMediaVector) std::vector<pj::AudioMedia*>; 97 %template(ToneDescVector) std::vector<pj::ToneDesc>; 98 %template(ToneDigitVector) std::vector<pj::ToneDigit>; 99 %template(ToneDigitMapVector) std::vector<pj::ToneDigitMapDigit>; 97 100 %template(MediaFormatVector) std::vector<pj::MediaFormat*>; 98 101 %template(AudioDevInfoVector) std::vector<pj::AudioDevInfo*>; -
pjproject/trunk/pjsip-apps/src/swig/python/test.py
r4704 r4845 1 1 import pjsua2 as pj 2 2 import sys 3 import time 3 4 4 5 # … … 101 102 102 103 # 104 # Tone generator 105 # 106 def ua_tonegen_test(): 107 print "UA tonegen test.." 108 ep_cfg = pj.EpConfig() 109 110 ep = pj.Endpoint() 111 ep.libCreate() 112 ep.libInit(ep_cfg) 113 ep.libStart() 114 115 tonegen = pj.ToneGenerator() 116 tonegen.createToneGenerator() 117 118 tone = pj.ToneDesc() 119 tone.freq1 = 400 120 tone.freq2 = 600 121 tone.on_msec = 1000 122 tone.off_msec = 1000 123 tones = pj.ToneDescVector() 124 tones.append(tone) 125 126 digit = pj.ToneDigit() 127 digit.digit = '0' 128 digit.on_msec = 1000 129 digit.off_msec = 1000 130 digits = pj.ToneDigitVector() 131 digits.append(digit) 132 133 adm = ep.audDevManager() 134 spk = adm.getPlaybackDevMedia() 135 136 tonegen.play(tones, True) 137 tonegen.startTransmit(spk) 138 time.sleep(5) 139 140 tonegen.stop() 141 tonegen.playDigits(digits, True) 142 time.sleep(5) 143 144 dm = tonegen.getDigitMap() 145 print dm[0].digit 146 dm[0].freq1 = 400 147 dm[0].freq2 = 600 148 tonegen.setDigitMap(dm) 149 150 tonegen.stop() 151 tonegen.playDigits(digits, True) 152 time.sleep(5) 153 154 tonegen = None 155 156 ep.libDestroy() 157 158 # 103 159 # main() 104 160 # … … 108 164 ua_run_log_test() 109 165 ua_run_ua_test() 166 ua_tonegen_test() 110 167 sys.exit(0) 111 168 -
pjproject/trunk/pjsip-apps/src/swig/symbols.i
r4746 r4845 1 1 // This file is autogenerated by importsym script, do not modify! 2 2 3 typedef int pj_status_t; 3 4 … … 30 31 } pj_qos_params; 31 32 32 typedef enum pj_ssl_cipher {PJ_TLS_ NULL_WITH_NULL_NULL = 0x00000000, PJ_TLS_RSA_WITH_NULL_MD5 = 0x00000001, PJ_TLS_RSA_WITH_NULL_SHA = 0x00000002, PJ_TLS_RSA_WITH_NULL_SHA256 = 0x0000003B, PJ_TLS_RSA_WITH_RC4_128_MD5 = 0x00000004, PJ_TLS_RSA_WITH_RC4_128_SHA = 0x00000005, PJ_TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x0000000A, PJ_TLS_RSA_WITH_AES_128_CBC_SHA = 0x0000002F, PJ_TLS_RSA_WITH_AES_256_CBC_SHA = 0x00000035, PJ_TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003C, PJ_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x0000003D, PJ_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x0000000D, PJ_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000010, PJ_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x00000013, PJ_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000016, PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x00000030, PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x00000031, PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x00000032, PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x00000033, PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x00000036, PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x00000037, PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x00000038, PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x00000039, PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x0000003E, PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003F, PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x00000040, PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x00000067, PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x00000068, PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x00000069, PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x0000006A, PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x0000006B, PJ_TLS_DH_anon_WITH_RC4_128_MD5 = 0x00000018, PJ_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x0000001B, PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x00000034, PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x0000003A, PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x0000006C, PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x0000006D, PJ_TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x00000003, PJ_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x00000006, PJ_TLS_RSA_WITH_IDEA_CBC_SHA = 0x00000007, PJ_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000008, PJ_TLS_RSA_WITH_DES_CBC_SHA = 0x00000009, PJ_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0000000B, PJ_TLS_DH_DSS_WITH_DES_CBC_SHA = 0x0000000C, PJ_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0000000E, PJ_TLS_DH_RSA_WITH_DES_CBC_SHA = 0x0000000F, PJ_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x00000011, PJ_TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x00000012, PJ_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000014, PJ_TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x00000015, PJ_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x00000017, PJ_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x00000019, PJ_TLS_DH_anon_WITH_DES_CBC_SHA = 0x0000001A, PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA = 0x0000001C, PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 0x0000001D, PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 0x0000001E, PJ_SSL_CK_RC4_128_WITH_MD5 = 0x00010080, PJ_SSL_CK_RC4_128_EXPORT40_WITH_MD5 = 0x00020080, PJ_SSL_CK_RC2_128_CBC_WITH_MD5 = 0x00030080, PJ_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 = 0x00040080, PJ_SSL_CK_IDEA_128_CBC_WITH_MD5 = 0x00050080, PJ_SSL_CK_DES_64_CBC_WITH_MD5 = 0x00060040, PJ_SSL_CK_DES_192_EDE3_CBC_WITH_MD5 = 0x000700C0} pj_ssl_cipher;33 typedef enum pj_ssl_cipher {PJ_TLS_UNKNOWN_CIPHER = -1, PJ_TLS_NULL_WITH_NULL_NULL = 0x00000000, PJ_TLS_RSA_WITH_NULL_MD5 = 0x00000001, PJ_TLS_RSA_WITH_NULL_SHA = 0x00000002, PJ_TLS_RSA_WITH_NULL_SHA256 = 0x0000003B, PJ_TLS_RSA_WITH_RC4_128_MD5 = 0x00000004, PJ_TLS_RSA_WITH_RC4_128_SHA = 0x00000005, PJ_TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x0000000A, PJ_TLS_RSA_WITH_AES_128_CBC_SHA = 0x0000002F, PJ_TLS_RSA_WITH_AES_256_CBC_SHA = 0x00000035, PJ_TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003C, PJ_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x0000003D, PJ_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x0000000D, PJ_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000010, PJ_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x00000013, PJ_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x00000016, PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x00000030, PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x00000031, PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x00000032, PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x00000033, PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x00000036, PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x00000037, PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x00000038, PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x00000039, PJ_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x0000003E, PJ_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x0000003F, PJ_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x00000040, PJ_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x00000067, PJ_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x00000068, PJ_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x00000069, PJ_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x0000006A, PJ_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x0000006B, PJ_TLS_DH_anon_WITH_RC4_128_MD5 = 0x00000018, PJ_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x0000001B, PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x00000034, PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x0000003A, PJ_TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x0000006C, PJ_TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x0000006D, PJ_TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x00000003, PJ_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x00000006, PJ_TLS_RSA_WITH_IDEA_CBC_SHA = 0x00000007, PJ_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000008, PJ_TLS_RSA_WITH_DES_CBC_SHA = 0x00000009, PJ_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0000000B, PJ_TLS_DH_DSS_WITH_DES_CBC_SHA = 0x0000000C, PJ_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0000000E, PJ_TLS_DH_RSA_WITH_DES_CBC_SHA = 0x0000000F, PJ_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x00000011, PJ_TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x00000012, PJ_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x00000014, PJ_TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x00000015, PJ_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x00000017, PJ_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x00000019, PJ_TLS_DH_anon_WITH_DES_CBC_SHA = 0x0000001A, PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA = 0x0000001C, PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 0x0000001D, PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 0x0000001E, PJ_SSL_CK_RC4_128_WITH_MD5 = 0x00010080, PJ_SSL_CK_RC4_128_EXPORT40_WITH_MD5 = 0x00020080, PJ_SSL_CK_RC2_128_CBC_WITH_MD5 = 0x00030080, PJ_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 = 0x00040080, PJ_SSL_CK_IDEA_128_CBC_WITH_MD5 = 0x00050080, PJ_SSL_CK_DES_64_CBC_WITH_MD5 = 0x00060040, PJ_SSL_CK_DES_192_EDE3_CBC_WITH_MD5 = 0x000700C0} pj_ssl_cipher; 33 34 34 35 typedef enum pj_stun_nat_type {PJ_STUN_NAT_TYPE_UNKNOWN, PJ_STUN_NAT_TYPE_ERR_UNKNOWN, PJ_STUN_NAT_TYPE_OPEN, PJ_STUN_NAT_TYPE_BLOCKED, PJ_STUN_NAT_TYPE_SYMMETRIC_UDP, PJ_STUN_NAT_TYPE_FULL_CONE, PJ_STUN_NAT_TYPE_SYMMETRIC, PJ_STUN_NAT_TYPE_RESTRICTED, PJ_STUN_NAT_TYPE_PORT_RESTRICTED} pj_stun_nat_type; … … 54 55 enum pjmedia_file_player_option {PJMEDIA_FILE_NO_LOOP = 1}; 55 56 57 typedef struct pjmedia_tone_digit 58 { 59 char digit; 60 short on_msec; 61 short off_msec; 62 short volume; 63 } pjmedia_tone_digit; 64 65 typedef struct pjmedia_tone_digit_map 66 { 67 unsigned count; 68 struct 69 { 70 char digit; 71 short freq1; 72 short freq2; 73 } digits[16]; 74 } pjmedia_tone_digit_map; 75 76 typedef struct pjmedia_tone_desc 77 { 78 short freq1; 79 short freq2; 80 short on_msec; 81 short off_msec; 82 short volume; 83 short flags; 84 } pjmedia_tone_desc; 85 56 86 typedef enum pjmedia_type {PJMEDIA_TYPE_NONE, PJMEDIA_TYPE_AUDIO, PJMEDIA_TYPE_VIDEO, PJMEDIA_TYPE_APPLICATION, PJMEDIA_TYPE_UNKNOWN} pjmedia_type; 57 87 … … 76 106 enum pjsip_transport_flags_e {PJSIP_TRANSPORT_RELIABLE = 1, PJSIP_TRANSPORT_SECURE = 2, PJSIP_TRANSPORT_DATAGRAM = 4}; 77 107 78 typedef enum pjsip_transport_state {PJSIP_TP_STATE_CONNECTED, PJSIP_TP_STATE_DISCONNECTED } pjsip_transport_state;108 typedef enum pjsip_transport_state {PJSIP_TP_STATE_CONNECTED, PJSIP_TP_STATE_DISCONNECTED, PJSIP_TP_STATE_SHUTDOWN, PJSIP_TP_STATE_DESTROY} pjsip_transport_state; 79 109 80 110 typedef enum pjsip_ssl_method {PJSIP_SSL_UNSPECIFIED_METHOD = 0, PJSIP_TLSV1_METHOD = 31, PJSIP_SSLV2_METHOD = 20, PJSIP_SSLV3_METHOD = 30, PJSIP_SSLV23_METHOD = 23} pjsip_ssl_method; -
pjproject/trunk/pjsip-apps/src/swig/symbols.lst
r4704 r4845 14 14 pjmedia-audiodev/audiodev.h pjmedia_aud_dev_route pjmedia_aud_dev_cap 15 15 pjmedia/wav_port.h pjmedia_file_writer_option pjmedia_file_player_option 16 pjmedia/tonegen.h pjmedia_tone_digit pjmedia_tone_digit_map pjmedia_tone_desc 16 17 pjmedia/types.h pjmedia_type pjmedia_dir pjmedia_tp_proto 17 18 pjmedia/format.h pjmedia_format_id -
pjproject/trunk/pjsip/include/pjsua2/media.hpp
r4793 r4845 512 512 }; 513 513 514 /** 515 * Tone descriptor (abstraction for pjmedia_tone_desc) 516 */ 517 class ToneDesc : public pjmedia_tone_desc 518 { 519 public: 520 ToneDesc() 521 { 522 pj_bzero(this, sizeof(*this)); 523 } 524 ~ToneDesc() {} 525 }; 526 527 /** 528 * Array of tone descriptor. 529 */ 530 typedef std::vector<ToneDesc> ToneDescVector; 531 532 /** 533 * Tone digit (abstraction for pjmedia_tone_digit) 534 */ 535 class ToneDigit : public pjmedia_tone_digit 536 { 537 public: 538 ToneDigit() 539 { 540 pj_bzero(this, sizeof(*this)); 541 } 542 ~ToneDigit() {} 543 }; 544 545 /** 546 * Array of tone digits. 547 */ 548 typedef std::vector<ToneDigit> ToneDigitVector; 549 550 /** 551 * A digit in tone digit map 552 */ 553 struct ToneDigitMapDigit 554 { 555 public: 556 string digit; 557 int freq1; 558 int freq2; 559 }; 560 561 /** 562 * Tone digit map 563 */ 564 typedef std::vector<ToneDigitMapDigit> ToneDigitMapVector; 565 566 /** 567 * Tone generator. 568 */ 569 class ToneGenerator : public AudioMedia 570 { 571 public: 572 /** 573 * Constructor. 574 */ 575 ToneGenerator(); 576 577 /** 578 * Destructor. 579 */ 580 ~ToneGenerator(); 581 582 /** 583 * Create tone generator. 584 */ 585 void createToneGenerator(unsigned clock_rate = 16000, 586 unsigned channel_count = 1) throw(Error); 587 588 /** 589 * Check if the tone generator is still busy producing some tones. 590 * @return Non-zero if busy. 591 */ 592 bool isBusy() const; 593 594 /** 595 * Instruct the tone generator to stop current processing. 596 */ 597 void stop() throw(Error); 598 599 /** 600 * Rewind the playback. This will start the playback to the first 601 * tone in the playback list. 602 */ 603 void rewind() throw(Error); 604 605 /** 606 * Instruct the tone generator to play single or dual frequency tones 607 * with the specified duration. The new tones will be appended to 608 * currently playing tones, unless stop() is called before calling this 609 * function. The playback will begin as soon as the tone generator is 610 * connected to other media. 611 * 612 * @param tones Array of tones to be played. 613 * @param loop Play the tone in a loop. 614 */ 615 void play(const ToneDescVector &tones, 616 bool loop=false) throw(Error); 617 618 /** 619 * Instruct the tone generator to play multiple MF digits with each of 620 * the digits having individual ON/OFF duration. Each of the digit in the 621 * digit array must have the corresponding descriptor in the digit map. 622 * The new tones will be appended to currently playing tones, unless 623 * stop() is called before calling this function. The playback will begin 624 * as soon as the tone generator is connected to a sink media. 625 * 626 * @param digits Array of MF digits. 627 * @param loop Play the tone in a loop. 628 */ 629 void playDigits(const ToneDigitVector &digits, 630 bool loop=false) throw(Error); 631 632 /** 633 * Get the digit-map currently used by this tone generator. 634 * 635 * @return The digitmap currently used by the tone generator 636 */ 637 ToneDigitMapVector getDigitMap() const throw(Error); 638 639 /** 640 * Set digit map to be used by the tone generator. 641 * 642 * @param digit_map Digitmap to be used by the tone generator. 643 */ 644 void setDigitMap(const ToneDigitMapVector &digit_map) throw(Error); 645 646 private: 647 pj_pool_t *pool; 648 pjmedia_port *tonegen; 649 pjmedia_tone_digit_map digitMap; 650 }; 651 652 514 653 /************************************************************************* 515 654 * Sound device management -
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r4793 r4845 424 424 425 425 /////////////////////////////////////////////////////////////////////////////// 426 427 ToneGenerator::ToneGenerator() 428 : pool(NULL), tonegen(NULL) 429 { 430 } 431 432 ToneGenerator::~ToneGenerator() 433 { 434 if (tonegen) { 435 unregisterMediaPort(); 436 pjmedia_port_destroy(tonegen); 437 tonegen = NULL; 438 } 439 if (pool) { 440 pj_pool_release(pool); 441 pool = NULL; 442 } 443 } 444 445 void ToneGenerator::createToneGenerator(unsigned clock_rate, 446 unsigned channel_count) throw(Error) 447 { 448 pj_status_t status; 449 450 if (pool) { 451 PJSUA2_RAISE_ERROR(PJ_EEXISTS); 452 } 453 454 pool = pjsua_pool_create( "tonegen%p", 512, 512); 455 if (!pool) { 456 PJSUA2_RAISE_ERROR(PJ_ENOMEM); 457 } 458 459 status = pjmedia_tonegen_create( pool, clock_rate, channel_count, 460 clock_rate * 20 / 1000, 16, 461 0, &tonegen); 462 if (status != PJ_SUCCESS) { 463 PJSUA2_RAISE_ERROR(status); 464 } 465 466 registerMediaPort(tonegen); 467 } 468 469 bool ToneGenerator::isBusy() const 470 { 471 return tonegen && pjmedia_tonegen_is_busy(tonegen) != 0; 472 } 473 474 void ToneGenerator::stop() throw(Error) 475 { 476 pj_status_t status; 477 478 if (!tonegen) { 479 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 480 } 481 482 status = pjmedia_tonegen_stop(tonegen); 483 PJSUA2_CHECK_RAISE_ERROR2(status, "ToneGenerator::stop()"); 484 } 485 486 void ToneGenerator::rewind() throw(Error) 487 { 488 pj_status_t status; 489 490 if (!tonegen) { 491 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 492 } 493 494 status = pjmedia_tonegen_rewind(tonegen); 495 PJSUA2_CHECK_RAISE_ERROR2(status, "ToneGenerator::rewind()"); 496 } 497 498 void ToneGenerator::play(const ToneDescVector &tones, 499 bool loop) throw(Error) 500 { 501 pj_status_t status; 502 503 if (!tonegen) { 504 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 505 } 506 if (tones.size() == 0) { 507 PJSUA2_RAISE_ERROR(PJ_EINVAL); 508 } 509 510 status = pjmedia_tonegen_play(tonegen, tones.size(), &tones[0], 511 loop? PJMEDIA_TONEGEN_LOOP : 0); 512 PJSUA2_CHECK_RAISE_ERROR2(status, "ToneGenerator::play()"); 513 } 514 515 void ToneGenerator::playDigits(const ToneDigitVector &digits, 516 bool loop) throw(Error) 517 { 518 pj_status_t status; 519 520 if (!tonegen) { 521 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 522 } 523 if (digits.size() == 0) { 524 PJSUA2_RAISE_ERROR(PJ_EINVAL); 525 } 526 527 status = pjmedia_tonegen_play_digits(tonegen, digits.size(), &digits[0], 528 loop? PJMEDIA_TONEGEN_LOOP : 0); 529 PJSUA2_CHECK_RAISE_ERROR2(status, "ToneGenerator::playDigits()"); 530 } 531 532 ToneDigitMapVector ToneGenerator::getDigitMap() const throw(Error) 533 { 534 const pjmedia_tone_digit_map *pdm; 535 ToneDigitMapVector tdm; 536 unsigned i; 537 pj_status_t status; 538 539 if (!tonegen) { 540 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 541 } 542 543 status = pjmedia_tonegen_get_digit_map(tonegen, &pdm); 544 PJSUA2_CHECK_RAISE_ERROR2(status, "ToneGenerator::getDigitMap()"); 545 546 for (i=0; i<pdm->count; ++i) { 547 ToneDigitMapDigit d; 548 char str_digit[2]; 549 550 str_digit[0] = pdm->digits[i].digit; 551 str_digit[1] = '\0'; 552 553 d.digit = str_digit; 554 d.freq1 = pdm->digits[i].freq1; 555 d.freq2 = pdm->digits[i].freq2; 556 557 tdm.push_back(d); 558 } 559 560 return tdm; 561 } 562 563 void ToneGenerator::setDigitMap(const ToneDigitMapVector &digit_map) 564 throw(Error) 565 { 566 unsigned i; 567 pj_status_t status; 568 569 if (!tonegen) { 570 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 571 } 572 573 digitMap.count = digit_map.size(); 574 if (digitMap.count > PJ_ARRAY_SIZE(digitMap.digits)) 575 digitMap.count = PJ_ARRAY_SIZE(digitMap.digits); 576 577 for (i=0; i<digitMap.count; ++i) { 578 digitMap.digits[i].digit = digit_map[i].digit.c_str()[0]; 579 digitMap.digits[i].freq1 = digit_map[i].freq1; 580 digitMap.digits[i].freq2 = digit_map[i].freq2; 581 } 582 583 status = pjmedia_tonegen_set_digit_map(tonegen, &digitMap); 584 PJSUA2_CHECK_RAISE_ERROR2(status, "ToneGenerator::setDigitMap()"); 585 } 586 587 588 /////////////////////////////////////////////////////////////////////////////// 426 589 void AudioDevInfo::fromPj(const pjmedia_aud_dev_info &dev_info) 427 590 {
Note: See TracChangeset
for help on using the changeset viewer.