Ignore:
Timestamp:
May 19, 2014 5:51:10 AM (10 years ago)
Author:
bennylp
Message:

Fixed #1767: Tone generation API in pjsua2 and SWIG wrappers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua2/media.hpp

    r4793 r4845  
    512512}; 
    513513 
     514/** 
     515 * Tone descriptor (abstraction for pjmedia_tone_desc) 
     516 */ 
     517class ToneDesc : public pjmedia_tone_desc 
     518{ 
     519public: 
     520    ToneDesc() 
     521    { 
     522        pj_bzero(this, sizeof(*this)); 
     523    } 
     524    ~ToneDesc() {} 
     525}; 
     526 
     527/** 
     528 * Array of tone descriptor. 
     529 */ 
     530typedef std::vector<ToneDesc> ToneDescVector; 
     531 
     532/** 
     533 * Tone digit (abstraction for pjmedia_tone_digit) 
     534 */ 
     535class ToneDigit : public pjmedia_tone_digit 
     536{ 
     537public: 
     538    ToneDigit() 
     539    { 
     540        pj_bzero(this, sizeof(*this)); 
     541    } 
     542    ~ToneDigit() {} 
     543}; 
     544 
     545/** 
     546 * Array of tone digits. 
     547 */ 
     548typedef std::vector<ToneDigit> ToneDigitVector; 
     549 
     550/** 
     551 * A digit in tone digit map 
     552 */ 
     553struct ToneDigitMapDigit 
     554{ 
     555public: 
     556    string      digit; 
     557    int         freq1; 
     558    int         freq2; 
     559}; 
     560 
     561/** 
     562 * Tone digit map 
     563 */ 
     564typedef std::vector<ToneDigitMapDigit> ToneDigitMapVector; 
     565 
     566/** 
     567 * Tone generator. 
     568 */ 
     569class ToneGenerator : public AudioMedia 
     570{ 
     571public: 
     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 
     646private: 
     647    pj_pool_t *pool; 
     648    pjmedia_port *tonegen; 
     649    pjmedia_tone_digit_map digitMap; 
     650}; 
     651 
     652 
    514653/************************************************************************* 
    515654* Sound device management 
Note: See TracChangeset for help on using the changeset viewer.