Changeset 4685


Ignore:
Timestamp:
Dec 5, 2013 10:53:12 AM (7 years ago)
Author:
nanang
Message:

Re #1519: Added typecast methods for AudioMedia? & its descendants, as Python cannot downcast among C++ classes, e.g: Media to AudioMedia?.

Location:
pjproject/branches/projects/pjsua2/pjsip
Files:
2 edited

Legend:

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

    r4680 r4685  
    262262 
    263263    /** 
     264     * Typecast from base class Media. This is useful for application written 
     265     * in language that does not support downcasting such as Python. 
     266     * 
     267     * @param media             The object to be downcasted 
     268     * 
     269     * @return                  The object as AudioMedia instance 
     270     */ 
     271    static AudioMedia* typecastFromMedia(Media *media); 
     272 
     273    /** 
    264274     * Virtual Destructor 
    265275     */ 
     
    351361     */ 
    352362    void setPos(pj_uint32_t samples) throw(Error); 
     363 
     364    /** 
     365     * Typecast from base class AudioMedia. This is useful for application 
     366     * written in language that does not support downcasting such as Python. 
     367     * 
     368     * @param media             The object to be downcasted 
     369     * 
     370     * @return                  The object as AudioMediaPlayer instance 
     371     */ 
     372    static AudioMediaPlayer* typecastFromAudioMedia(AudioMedia *media); 
    353373 
    354374    /** 
     
    398418 
    399419    /** 
     420     * Typecast from base class AudioMedia. This is useful for application 
     421     * written in language that does not support downcasting such as Python. 
     422     * 
     423     * @param media             The object to be downcasted 
     424     * 
     425     * @return                  The object as AudioMediaRecorder instance 
     426     */ 
     427    static AudioMediaRecorder* typecastFromAudioMedia(AudioMedia *media); 
     428 
     429    /** 
    400430     * Virtual destructor. 
    401431     */ 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/media.cpp

    r4680 r4685  
    233233} 
    234234 
     235AudioMedia* AudioMedia::typecastFromMedia(Media *media) 
     236{ 
     237    return static_cast<AudioMedia*>(media); 
     238} 
     239 
    235240/////////////////////////////////////////////////////////////////////////////// 
    236241 
     
    296301{ 
    297302    PJSUA2_CHECK_EXPR( pjsua_player_set_pos(playerId, samples) ); 
     303} 
     304 
     305AudioMediaPlayer* AudioMediaPlayer::typecastFromAudioMedia( 
     306                                                AudioMedia *media) 
     307{ 
     308    return static_cast<AudioMediaPlayer*>(media); 
    298309} 
    299310 
     
    333344    registerMediaPort(NULL); 
    334345} 
     346 
     347AudioMediaRecorder* AudioMediaRecorder::typecastFromAudioMedia( 
     348                                                AudioMedia *media) 
     349{ 
     350    return static_cast<AudioMediaRecorder*>(media); 
     351} 
     352 
    335353/////////////////////////////////////////////////////////////////////////////// 
    336354void AudioDevInfo::fromPj(const pjmedia_aud_dev_info &dev_info) 
Note: See TracChangeset for help on using the changeset viewer.