Ignore:
Timestamp:
Apr 15, 2019 10:52:16 AM (5 years ago)
Author:
nanang
Message:

Close #2189: fixed PJSUA2 thread safety issue in list of objects manipulation.

File:
1 edited

Legend:

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

    r5956 r5969  
    214214 
    215215/** 
    216  * Audio Media. 
     216 * Audio Media. This is a lite wrapper class for audio conference bridge port, 
     217 * i.e: this class only maintains one data member, conference slot ID, and  
     218 * the methods are simply proxies for conference bridge operations. 
     219 * 
     220 * Application can create a derived class and use registerMediaPort2()/ 
     221 * unregisterMediaPort() to register/unregister a media port to/from the 
     222 * conference bridge. 
     223 * 
     224 * The library will not keep a list of AudioMedia instances, so any 
     225 * AudioMedia (descendant) instances instantiated by application must be 
     226 * maintained and destroyed by the application itself. 
     227 * 
     228 * Note that any PJSUA2 APIs that return AudioMedia instance(s) such as 
     229 * Endpoint::mediaEnumPorts2() or Call::getAudioMedia() will just return 
     230 * generated copy. All AudioMedia methods should work normally on this 
     231 * generated copy instance. 
    217232 */ 
    218233class AudioMedia : public Media 
     
    321336 
    322337    /** 
     338     * Warning: deprecated and will be removed in future release. 
     339     * 
    323340     * Typecast from base class Media. This is useful for application written 
    324341     * in language that does not support downcasting such as Python. 
     
    331348 
    332349    /** 
    333      * Virtual Destructor 
     350     * Default Constructor. Normally application will not create AudioMedia 
     351     * object directly, but it may instantiate an AudioMedia derived class. 
     352     */ 
     353    AudioMedia(); 
     354 
     355    /** 
     356     * Virtual Destructor. 
    334357     */ 
    335358    virtual ~AudioMedia(); 
     
    343366protected: 
    344367    /** 
    345      * Default Constructor. 
    346      */ 
    347     AudioMedia(); 
    348  
    349     /** 
     368     * Warning: deprecated and will be removed in future release, use 
     369     * registerMediaPort2() instead. 
     370     * 
    350371     * This method needs to be called by descendants of this class to register 
    351372     * the media port created to the conference bridge and Endpoint's 
    352373     * media list. 
    353374     * 
    354      * param port  the media port to be registered to the conference bridge. 
     375     * param port  The media port to be registered to the conference bridge. 
    355376     * 
    356377     */ 
    357378    void registerMediaPort(MediaPort port) throw(Error); 
     379 
     380    /** 
     381     * This method needs to be called by descendants of this class to register 
     382     * the media port created to the conference bridge and Endpoint's 
     383     * media list. 
     384     * 
     385     * param port  The media port to be registered to the conference bridge. 
     386     * param pool  The memory pool. 
     387     * 
     388     */ 
     389    void registerMediaPort2(MediaPort port, pj_pool_t *pool) throw(Error); 
    358390 
    359391    /** 
     
    366398 
    367399private: 
     400    /* Memory pool for deprecated registerMediaPort() */ 
    368401    pj_caching_pool      mediaCachingPool; 
    369402    pj_pool_t           *mediaPool; 
    370 }; 
     403 
     404    friend class Endpoint; 
     405}; 
     406 
     407/**  
     408 * Warning: deprecated, use AudioMediaVector2 instead. 
     409 * 
     410 * Array of Audio Media. 
     411 */ 
     412typedef std::vector<AudioMedia*> AudioMediaVector; 
     413 
    371414 
    372415/** Array of Audio Media */ 
    373 typedef std::vector<AudioMedia*> AudioMediaVector; 
     416typedef std::vector<AudioMedia> AudioMediaVector2; 
    374417 
    375418/** 
     
    465508 
    466509    /** 
     510     * Warning: deprecated and will be removed in future release. 
     511     * 
    467512     * Typecast from base class AudioMedia. This is useful for application 
    468513     * written in language that does not support downcasting such as Python. 
     
    475520 
    476521    /** 
    477      * Destructor. 
     522     * Destructor. This will unregister the player port from the conference 
     523     * bridge. 
    478524     */ 
    479525    virtual ~AudioMediaPlayer(); 
     
    546592    void createRecorder(const string &file_name, 
    547593                        unsigned enc_type=0, 
    548                         pj_ssize_t max_size=0, 
     594                        long max_size=0, 
    549595                        unsigned options=0) throw(Error); 
    550596 
    551597    /** 
     598     * Warning: deprecated and will be removed in future release. 
     599     * 
    552600     * Typecast from base class AudioMedia. This is useful for application 
    553601     * written in language that does not support downcasting such as Python. 
     
    560608 
    561609    /** 
    562      * Destructor. 
     610     * Destructor. This will unregister the recorder port from the conference 
     611     * bridge. 
    563612     */ 
    564613    virtual ~AudioMediaRecorder(); 
     
    635684 
    636685    /** 
    637      * Destructor. 
     686     * Destructor. This will unregister the tone generator port from the 
     687     * conference bridge. 
    638688     */ 
    639689    ~ToneGenerator(); 
    640690 
    641691    /** 
    642      * Create tone generator. 
     692     * Create tone generator and register the port to the conference bridge. 
    643693     */ 
    644694    void createToneGenerator(unsigned clock_rate = 16000, 
     
    776826}; 
    777827 
     828/**  
     829 * Warning: deprecated, use AudioDevInfoVector2 instead. 
     830 * 
     831 * Array of audio device info. 
     832 */ 
     833typedef std::vector<AudioDevInfo*> AudioDevInfoVector; 
     834 
    778835/** Array of audio device info */ 
    779 typedef std::vector<AudioDevInfo*> AudioDevInfoVector; 
     836typedef std::vector<AudioDevInfo> AudioDevInfoVector2; 
    780837 
    781838/** 
     
    836893 
    837894    /** 
     895     * Warning: deprecated, use enumDev2 instead. This function is not 
     896     * safe in multithreaded environment. 
     897     * 
     898     * Enum all audio devices installed in the system. This function is not 
     899     * safe in multithreaded environment. 
     900     * 
     901     * @return                  The list of audio device info. 
     902     */ 
     903    const AudioDevInfoVector &enumDev() throw(Error); 
     904 
     905    /** 
    838906     * Enum all audio devices installed in the system. 
    839907     * 
    840908     * @return                  The list of audio device info. 
    841909     */ 
    842     const AudioDevInfoVector &enumDev() throw(Error); 
     910    AudioDevInfoVector2 enumDev2() const throw(Error); 
    843911 
    844912    /** 
     
    14171485public: 
    14181486    /** 
    1419      * Constructor 
     1487     * Constructor. 
    14201488     * 
    14211489     * @param playdev           Playback device ID. 
     
    14251493 
    14261494    /** 
    1427      * Destructor 
     1495     * Destructor. 
    14281496     */ 
    14291497    virtual ~ExtraAudioDevice(); 
     
    14321500     * Open the audio device using format (e.g.: clock rate, bit per sample, 
    14331501     * samples per frame) matched to the conference bridge's format, except 
    1434      * the channel count, which will be set to one (mono channel). 
     1502     * the channel count, which will be set to one (mono channel). This will 
     1503     * also register the audio device port to conference bridge. 
    14351504     */ 
    14361505    void open(); 
    14371506 
    14381507    /** 
    1439      * Close the audio device. 
     1508     * Close the audio device and unregister the audio device port from the 
     1509     * conference bridge. 
    14401510     */ 
    14411511    void close(); 
     
    17661836}; 
    17671837 
     1838/**  
     1839 * Warning: deprecated, use VideoDevInfoVector2 instead. 
     1840 * 
     1841 * Array of video device info. 
     1842 */ 
     1843typedef std::vector<VideoDevInfo*> VideoDevInfoVector; 
     1844 
    17681845/** Array of video device info */ 
    1769 typedef std::vector<VideoDevInfo*> VideoDevInfoVector; 
     1846typedef std::vector<VideoDevInfo> VideoDevInfoVector2; 
    17701847 
    17711848/** 
     
    18131890 
    18141891    /** 
     1892     * Warning: deprecated, use enumDev2() instead. This function is not 
     1893     * safe in multithreaded environment. 
     1894     * 
    18151895     * Enum all video devices installed in the system. 
    18161896     * 
     
    18181898     */ 
    18191899    const VideoDevInfoVector &enumDev() throw(Error); 
     1900 
     1901    /** 
     1902     * Enum all video devices installed in the system. 
     1903     * 
     1904     * @return          The list of video device info 
     1905     */ 
     1906    VideoDevInfoVector2 enumDev2() const throw(Error); 
    18201907 
    18211908    /** 
     
    20562143}; 
    20572144 
     2145/**  
     2146 * Warning: deprecated, use CodecInfoVector2 instead. 
     2147 * 
     2148 * Array of codec info. 
     2149 */ 
     2150typedef std::vector<CodecInfo*> CodecInfoVector; 
     2151 
    20582152/** Array of codec info */ 
    2059 typedef std::vector<CodecInfo*> CodecInfoVector; 
     2153typedef std::vector<CodecInfo> CodecInfoVector2; 
    20602154 
    20612155/** 
Note: See TracChangeset for help on using the changeset viewer.