Subversion Repositories tpanel

Rev

Rev 138 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 138 Rev 141
Line 70... Line 70...
70
 
70
 
71
        void cleanUp();
71
        void cleanUp();
72
        int getLineID() { return mLine; }
72
        int getLineID() { return mLine; }
73
        SIP_STATE_t getSIPState(pjsua_call_id id) { if (id >= 0 && id < PJSUA_MAX_CALLS) return mSIPState[id]; else return SIP_NONE; }
73
        SIP_STATE_t getSIPState(pjsua_call_id id) { if (id >= 0 && id < PJSUA_MAX_CALLS) return mSIPState[id]; else return SIP_NONE; }
74
        bool isRegistered() { return mRegistered; }
74
        bool isRegistered() { return mRegistered; }
-
 
75
        static TSIPClient *getSIPClient() { return mMyself; }
75
 
76
 
76
        bool call(const std::string& dest);         //<! Start a phone call
77
        bool call(const std::string& dest);         //<! Start a phone call
77
        bool pickup(pjsua_call_id call);            //<! Lift up if the phone is ringing
78
        bool pickup(pjsua_call_id call);            //<! Lift up if the phone is ringing
78
        bool terminate(int id);                     //<! Terminate a call
79
        bool terminate(int id);                     //<! Terminate a call
79
        bool hold(int id);                          //<! Pause a call
80
        bool hold(int id);                          //<! Pause a call
Line 85... Line 86...
85
        bool transfer(int id, const std::string& num);  //<! transfer the current call
86
        bool transfer(int id, const std::string& num);  //<! transfer the current call
86
        bool setDTMFduration(uint_t ms);            //<! Set the DTMF duration in ms.
87
        bool setDTMFduration(uint_t ms);            //<! Set the DTMF duration in ms.
87
        bool getPrivate() { return mDoNotDisturb; } //<! Returns the current private mode.
88
        bool getPrivate() { return mDoNotDisturb; } //<! Returns the current private mode.
88
 
89
 
89
    protected:
90
    protected:
90
        void start();
91
        void runRinger();                           //<! Plays a ring tone if a call is coming.
91
 
92
 
92
        static void _log_call(int level, const char *data, int len);
93
        static void _log_call(int level, const char *data, int len);
93
        static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata);
94
        static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, pjsip_rx_data *rdata);
94
        static void on_call_state(pjsua_call_id call_id, pjsip_event *e);
95
        static void on_call_state(pjsua_call_id call_id, pjsip_event *e);
95
        static void on_call_media_state(pjsua_call_id call_id);
96
        static void on_call_media_state(pjsua_call_id call_id);
Line 114... Line 115...
114
        int getNumberCalls();
115
        int getNumberCalls();
115
        pjsua_call_id getActiveCall();
116
        pjsua_call_id getActiveCall();
116
        void setSIPState(SIP_STATE_t s, pjsua_call_id id) { if (id >= 0 && id < PJSUA_MAX_CALLS) mSIPState[id] = s; }
117
        void setSIPState(SIP_STATE_t s, pjsua_call_id id) { if (id >= 0 && id < PJSUA_MAX_CALLS) mSIPState[id] = s; }
117
 
118
 
118
        static void sendConnectionStatus(SIP_STATE_t state, int id);
119
        static void sendConnectionStatus(SIP_STATE_t state, int id);
-
 
120
        static void init_ringtone_player();
-
 
121
        static pj_status_t start_ring_tone();
-
 
122
        static pj_status_t stop_ring_tone();
119
 
123
 
120
        int mLine{0};
124
        int mLine{0};
121
        bool mRegistered{false};
125
        bool mRegistered{false};
122
        SIP_STATE_t mSIPState[PJSUA_MAX_CALLS];
126
        SIP_STATE_t mSIPState[PJSUA_MAX_CALLS];
123
        pjsua_acc_id mAccountID{0};
127
        pjsua_acc_id mAccountID{0};
Line 126... Line 130...
126
        bool mDoNotDisturb{false};
130
        bool mDoNotDisturb{false};
127
 
131
 
128
        static TSIPClient *mMyself;
132
        static TSIPClient *mMyself;
129
        static pjsua_call_id mCurrentCall;
133
        static pjsua_call_id mCurrentCall;
130
        static std::atomic<bool> mRefreshRun;
134
        static std::atomic<bool> mRefreshRun;
-
 
135
        static bool mPhoneRingInit;
131
        // Here is the configuration for the PJSUA library
136
        // Here is the configuration for the PJSUA library
132
        typedef struct app_call_data
137
        typedef struct app_call_data
133
        {
138
        {
134
            pj_timer_entry      timer;
139
            pj_timer_entry      timer;
135
            pj_bool_t           ringback_on{PJ_FALSE};
140
            pj_bool_t           ringback_on{PJ_FALSE};
136
            pj_bool_t           ring_on{PJ_FALSE};
141
            pj_bool_t           ring_on{PJ_FALSE};
137
        } app_call_data;
142
        } app_call_data;
138
 
143
 
-
 
144
        typedef struct ringtone_port_info_t
-
 
145
        {
-
 
146
            pj_bool_t ring_on{PJ_FALSE};
-
 
147
            int ring_slot{0};
-
 
148
            pjmedia_port *ring_port{nullptr};
-
 
149
            pj_pool_t *pool{nullptr};
-
 
150
        } ringtone_port_info_t;
-
 
151
 
139
        typedef struct pjsua_app_config
152
        typedef struct pjsua_app_config
140
        {
153
        {
141
            pjsua_config        cfg;
154
            pjsua_config        cfg;
142
            pjsua_logging_config log_cfg;
155
            pjsua_logging_config log_cfg;
143
            pjsua_media_config  media_cfg;
156
            pjsua_media_config  media_cfg;
Line 165... Line 178...
165
            uint_t              codec_cnt{0};
178
            uint_t              codec_cnt{0};
166
            pj_str_t            codec_arg[32];
179
            pj_str_t            codec_arg[32];
167
            uint_t              codec_dis_cnt{0};
180
            uint_t              codec_dis_cnt{0};
168
            pj_str_t            codec_dis[32];
181
            pj_str_t            codec_dis[32];
169
            pj_bool_t           null_audio{PJ_FALSE};
182
            pj_bool_t           null_audio{PJ_FALSE};
170
            uint_t              wav_count;
183
            uint_t              wav_count{0};
171
            pj_str_t            wav_files[32];
184
            pj_str_t            wav_files[32];
172
            uint_t              tone_count{0};
185
            uint_t              tone_count{0};
173
            pjmedia_tone_desc   tones[32];
186
            pjmedia_tone_desc   tones[32];
174
            pjsua_conf_port_id  tone_slots[32];
187
            pjsua_conf_port_id  tone_slots[32];
175
            pjsua_player_id     wav_id{0};
188
            pjsua_player_id     wav_id{0};
Line 182... Line 195...
182
            pj_str_t            rec_file;
195
            pj_str_t            rec_file;
183
            pj_bool_t           auto_rec{PJ_FALSE};
196
            pj_bool_t           auto_rec{PJ_FALSE};
184
            pjsua_recorder_id   rec_id{0};
197
            pjsua_recorder_id   rec_id{0};
185
            pjsua_conf_port_id  rec_port{0};
198
            pjsua_conf_port_id  rec_port{0};
186
            unsigned            auto_answer{0};
199
            unsigned            auto_answer{0};
187
            unsigned            duration{0};
200
            unsigned            duration{36000};
188
            float               mic_level{0.0};
201
            float               mic_level{100.0};
189
            float               speaker_level{0.0};
202
            float               speaker_level{100.0};
190
 
203
 
191
            int                 capture_dev{0};
204
            int                 capture_dev{0};
192
            int                 playback_dev{0};
205
            int                 playback_dev{0};
193
            uint_t              capture_lat{0};
206
            uint_t              capture_lat{0};
194
            uint_t              playback_lat{0};
207
            uint_t              playback_lat{0};
Line 203... Line 216...
203
 
216
 
204
            uint_t              aud_cnt{0};
217
            uint_t              aud_cnt{0};
205
        }pjsua_app_config;
218
        }pjsua_app_config;
206
 
219
 
207
        static pjsua_app_config mAppConfig;
220
        static pjsua_app_config mAppConfig;
-
 
221
        static ringtone_port_info_t mRingtonePortInfo;
208
};
222
};
209
#endif  // _NOSIP_
223
#endif  // _NOSIP_
210
#endif  // __TSIPCLIENT_H__
224
#endif  // __TSIPCLIENT_H__