- Timestamp:
- Oct 25, 2013 10:34:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp
r4608 r4638 43 43 44 44 /** 45 * Argument to E pCallback::onNatDetectionComplete() callback.45 * Argument to Endpoint::onNatDetectionComplete() callback. 46 46 */ 47 47 struct OnNatDetectionCompleteParam … … 73 73 74 74 /** 75 * Argument to E pCallback::onNatCheckStunServersComplete() callback.75 * Argument to Endpoint::onNatCheckStunServersComplete() callback. 76 76 */ 77 77 struct OnNatCheckStunServersCompleteParam … … 104 104 105 105 /** 106 * Parameter of E pCallback::OnTimer() callback.106 * Parameter of Endpoint::onTimer() callback. 107 107 */ 108 108 struct OnTimerParam … … 121 121 122 122 /** 123 * Parameter of E pCallback::onTransportState() callback.123 * Parameter of Endpoint::onTransportState() callback. 124 124 */ 125 125 struct OnTransportStateParam … … 142 142 143 143 /** 144 * Parameter of E pCallback::onSelectAccount() callback.144 * Parameter of Endpoint::onSelectAccount() callback. 145 145 */ 146 146 struct OnSelectAccountParam … … 159 159 int accountIndex; 160 160 }; 161 162 //////////////////////////////////////////////////////////////////////////////163 164 /**165 * Interface for receiving callbacks from the library. Application inherits166 * this class and specify the instance when calling Endpoint::libInit().167 */168 class EpCallback169 {170 public:171 /** Virtual destructor */172 virtual ~EpCallback() {}173 174 /**175 * Callback when the Endpoint has finished performing NAT type176 * detection that is initiated with Endpoint::natDetectType().177 *178 * @param prm Callback parameters containing the detection179 * result.180 */181 virtual void onNatDetectionComplete(182 const OnNatDetectionCompleteParam &prm)183 {}184 185 /**186 * Callback when the Endpoint has finished performing STUN server187 * checking that is initiated with Endpoint::natCheckStunServers().188 *189 * @param prm Callback parameters.190 */191 virtual void onNatCheckStunServersComplete(192 const OnNatCheckStunServersCompleteParam &prm)193 {}194 195 /**196 * This callback is called when transport state has changed.197 *198 * @param prm Callback parameters.199 */200 virtual void onTransportState(201 const OnTransportStateParam &prm)202 {}203 204 /**205 * Callback when a timer has fired. The timer was scheduled by206 * Endpoint::utilTimerSchedule().207 *208 * @param prm Callback parameters.209 */210 virtual void onTimer(const OnTimerParam &prm)211 {}212 213 /**214 * This callback can be used by application to override the account215 * to be used to handle an incoming message. Initially, the account to216 * be used will be calculated automatically by the library. This initial217 * account will be used if application does not implement this callback,218 * or application sets an invalid account upon returning from this219 * callback.220 *221 * Note that currently the incoming messages requiring account assignment222 * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback223 * may be called before the callback of the SIP event itself, i.e:224 * incoming call, pager, subscription, or unsolicited-event.225 *226 * @param prm Callback parameters.227 */228 virtual void onSelectAccount(OnSelectAccountParam &prm)229 {}230 };231 232 161 233 162 ////////////////////////////////////////////////////////////////////////////// … … 313 242 * 314 243 * If this is enabled, the library will respond 200/OK to the NOTIFY 315 * request and forward the request to E pCallback.onMwiInfo() callback.244 * request and forward the request to Endpoint::onMwiInfo() callback. 316 245 * 317 246 * See also AccountMwiConfig.enabled. … … 407 336 408 337 /** 409 * Custom log writer, if required. If specified, the instance of LogWriter410 * must be kept alive througout the duration of the application.338 * Custom log writer, if required. This instance will be destroyed 339 * by the endpoint when the endpoint is destroyed. 411 340 */ 412 341 LogWriter *writer; … … 655 584 public: 656 585 /** Retrieve the singleton instance of the endpoint */ 657 static Endpoint &instance(); 658 659 /* For testing */ 660 void testException() throw(Error); 586 static Endpoint &instance() throw(Error); 587 588 /** Default constructor */ 589 Endpoint(); 590 591 /** Virtual destructor */ 592 virtual ~Endpoint(); 661 593 662 594 … … 688 620 * 689 621 * @param prmEpConfig Endpoint configurations 690 * @param prmCb Optional callback to receive events from the 691 * library. If specified, this instance must be 692 * kept alive throughout the lifetime of the 693 * library. 694 */ 695 void libInit( const EpConfig &prmEpConfig, 696 EpCallback *prmCb = NULL) throw(Error); 622 */ 623 void libInit( const EpConfig &prmEpConfig) throw(Error); 697 624 698 625 /** … … 770 697 /** 771 698 * Schedule a timer with the specified interval and user data. When the 772 * interval elapsed, E pCallback::OnTimer() callback will be699 * interval elapsed, Endpoint::onTimer() callback will be 773 700 * called. Note that the callback may be executed by different thread, 774 701 * depending on whether worker thread is enabled or not. … … 803 730 * This is a utility function to detect NAT type in front of this endpoint. 804 731 * Once invoked successfully, this function will complete asynchronously 805 * and report the result in E pCallback::onNatDetectionComplete().732 * and report the result in Endpoint::onNatDetectionComplete(). 806 733 * 807 734 * After NAT has been detected and the callback is called, application can … … 817 744 * Get the NAT type as detected by #natDetectType() function. This 818 745 * function will only return useful NAT type after #natDetectType() 819 * has completed successfully and E pCallback::onNatDetectionComplete()746 * has completed successfully and Endpoint::onNatDetectionComplete() 820 747 * callback has been called. 821 748 * … … 926 853 void transportClose(TransportId id) throw(Error); 927 854 855 public: 856 /* 857 * Overrideables callbacks 858 */ 859 860 /** 861 * Callback when the Endpoint has finished performing NAT type 862 * detection that is initiated with Endpoint::natDetectType(). 863 * 864 * @param prm Callback parameters containing the detection 865 * result. 866 */ 867 virtual void onNatDetectionComplete( 868 const OnNatDetectionCompleteParam &prm) 869 {} 870 871 /** 872 * Callback when the Endpoint has finished performing STUN server 873 * checking that is initiated with Endpoint::natCheckStunServers(). 874 * 875 * @param prm Callback parameters. 876 */ 877 virtual void onNatCheckStunServersComplete( 878 const OnNatCheckStunServersCompleteParam &prm) 879 {} 880 881 /** 882 * This callback is called when transport state has changed. 883 * 884 * @param prm Callback parameters. 885 */ 886 virtual void onTransportState( 887 const OnTransportStateParam &prm) 888 {} 889 890 /** 891 * Callback when a timer has fired. The timer was scheduled by 892 * Endpoint::utilTimerSchedule(). 893 * 894 * @param prm Callback parameters. 895 */ 896 virtual void onTimer(const OnTimerParam &prm) 897 {} 898 899 /** 900 * This callback can be used by application to override the account 901 * to be used to handle an incoming message. Initially, the account to 902 * be used will be calculated automatically by the library. This initial 903 * account will be used if application does not implement this callback, 904 * or application sets an invalid account upon returning from this 905 * callback. 906 * 907 * Note that currently the incoming messages requiring account assignment 908 * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback 909 * may be called before the callback of the SIP event itself, i.e: 910 * incoming call, pager, subscription, or unsolicited-event. 911 * 912 * @param prm Callback parameters. 913 */ 914 virtual void onSelectAccount(OnSelectAccountParam &prm) 915 {} 916 928 917 929 918 private: 930 /* Anybody else can't instantiate Endpoint */ 931 Endpoint(); 932 933 private: 934 /* Custom writer, if any */ 935 LogWriter *writer; 936 EpCallback *epCallback; 937 938 /* 939 * Callbacks (static) 940 */ 919 static Endpoint *instance_; // static instance 920 LogWriter *writer; // Custom writer, if any 921 922 /* Endpoint static callbacks */ 941 923 static void logFunc(int level, const char *data, int len); 942 924 static void stun_resolve_cb(const pj_stun_resolve_result *result); … … 947 929 pjsip_transport_state state, 948 930 const pjsip_transport_state_info *info); 931 932 private: 933 /* 934 * Account 935 */ 936 static Account *lookupAcc(int acc_id, const char *op); 937 938 /* static callbacks */ 939 static void on_incoming_call(pjsua_acc_id acc_id, 940 pjsua_call_id call_id, 941 pjsip_rx_data *rdata); 942 static void on_reg_started(pjsua_acc_id acc_id, 943 pj_bool_t renew); 944 static void on_reg_state2(pjsua_acc_id acc_id, 945 pjsua_reg_info *info); 946 static void on_incoming_subscribe(pjsua_acc_id acc_id, 947 pjsua_srv_pres *srv_pres, 948 pjsua_buddy_id buddy_id, 949 const pj_str_t *from, 950 pjsip_rx_data *rdata, 951 pjsip_status_code *code, 952 pj_str_t *reason, 953 pjsua_msg_data *msg_data); 954 static void on_pager2(pjsua_call_id call_id, 955 const pj_str_t *from, 956 const pj_str_t *to, 957 const pj_str_t *contact, 958 const pj_str_t *mime_type, 959 const pj_str_t *body, 960 pjsip_rx_data *rdata, 961 pjsua_acc_id acc_id); 962 static void on_pager_status2(pjsua_call_id call_id, 963 const pj_str_t *to, 964 const pj_str_t *body, 965 void *user_data, 966 pjsip_status_code status, 967 const pj_str_t *reason, 968 pjsip_tx_data *tdata, 969 pjsip_rx_data *rdata, 970 pjsua_acc_id acc_id); 971 static void on_typing2(pjsua_call_id call_id, 972 const pj_str_t *from, 973 const pj_str_t *to, 974 const pj_str_t *contact, 975 pj_bool_t is_typing, 976 pjsip_rx_data *rdata, 977 pjsua_acc_id acc_id); 978 static void on_mwi_info(pjsua_acc_id acc_id, 979 pjsua_mwi_info *mwi_info); 949 980 }; 950 981
Note: See TracChangeset
for help on using the changeset viewer.