- Timestamp:
- Feb 16, 2018 9:37:00 AM (7 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/swig/java
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/swig/java/android/app/src/main/java/org/pjsip/pjsua2/app/MainActivity.java
r5649 r5738 233 233 } else if (m.what == MSG_TYPE.CALL_STATE) { 234 234 235 CallInfo ci = (CallInfo) m.obj; 236 237 /* Forward the message to CallActivity */ 238 if (CallActivity.handler_ != null) { 235 MyCall call = (MyCall) m.obj; 236 CallInfo ci; 237 try { 238 ci = call.getInfo(); 239 } catch (Exception e) { 240 ci = null; 241 } 242 243 /* Forward the call info to CallActivity */ 244 if (ci != null && CallActivity.handler_ != null) { 239 245 Message m2 = Message.obtain(CallActivity.handler_, 240 246 MSG_TYPE.CALL_STATE, ci); 241 247 m2.sendToTarget(); 248 } 249 250 if (ci != null && 251 ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) 252 { 253 call.delete(); 242 254 } 243 255 … … 602 614 ci = null; 603 615 } 604 Message m = Message.obtain(handler, MSG_TYPE.CALL_STATE, c i);616 Message m = Message.obtain(handler, MSG_TYPE.CALL_STATE, call); 605 617 m.sendToTarget(); 606 618 -
pjproject/trunk/pjsip-apps/src/swig/java/android/app/src/main/java/org/pjsip/pjsua2/app/MyApp.java
r5649 r5738 62 62 public void onCallState(OnCallStateParam prm) 63 63 { 64 MyApp.observer.notifyCallState(this); 65 try { 66 CallInfo ci = getInfo(); 67 if (ci.getState() == 68 pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) 69 { 70 MyApp.ep.utilLogWrite(3, "MyCall", this.dump(true, "")); 71 this.delete(); 72 } 73 } catch (Exception e) { 74 return; 75 } 64 try { 65 CallInfo ci = getInfo(); 66 if (ci.getState() == 67 pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) 68 { 69 MyApp.ep.utilLogWrite(3, "MyCall", this.dump(true, "")); 70 } 71 } catch (Exception e) { 72 } 73 74 // Should not delete this call instance (self) in this context, 75 // so the observer should manage this call instance deletion 76 // out of this callback context. 77 MyApp.observer.notifyCallState(this); 76 78 } 77 79 -
pjproject/trunk/pjsip-apps/src/swig/java/sample.java
r5649 r5738 26 26 class MyObserver implements MyAppObserver { 27 27 private static MyCall currentCall = null; 28 private boolean del_call_scheduled = false; 29 30 public void check_call_deletion() 31 { 32 if (del_call_scheduled && currentCall != null) { 33 currentCall.delete(); 34 currentCall = null; 35 del_call_scheduled = false; 36 } 37 } 28 38 29 39 @Override … … 58 68 ci = null; 59 69 } 60 if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) 61 currentCall = null; 70 if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) { 71 // Should not delete call instance in this context, 72 // so let's just schedule it, the call will be deleted 73 // in our main worker thread context. 74 del_call_scheduled = true; 75 } 76 62 77 } 63 78 … … 86 101 public class sample { 87 102 private static MyApp app = new MyApp(); 88 private static My AppObserver observer = new MyObserver();103 private static MyObserver observer = new MyObserver(); 89 104 private static MyAccount account = null; 90 105 private static AccountConfig accCfg = null; … … 142 157 143 158 while (!Thread.currentThread().isInterrupted()) { 159 // Handle events 144 160 MyApp.ep.libHandleEvents(10); 161 162 // Check if any call instance need to be deleted 163 observer.check_call_deletion(); 164 145 165 try { 146 166 Thread.currentThread().sleep(50); 147 167 } catch (InterruptedException ie) { 148 168 break; 149 } 169 } 150 170 } 151 171 app.deinit(); -
pjproject/trunk/pjsip-apps/src/swig/java/sample2.java
r5402 r5738 34 34 class MyObserver implements MyAppObserver { 35 35 private static MyCall currentCall = null; 36 private static boolean del_call_scheduled = false; 37 38 public void check_call_deletion() 39 { 40 if (del_call_scheduled && currentCall != null) { 41 currentCall.delete(); 42 currentCall = null; 43 del_call_scheduled = false; 44 } 45 } 36 46 37 47 @Override … … 67 77 } 68 78 if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) { 69 currentCall = null; 79 // Should not delete call instance here, so let's schedule it. 80 // The call will be deleted by our main worker thread. 81 del_call_scheduled = true; 70 82 } else if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED) { 71 83 if (ci.getSetting().getVideoCount() != 0) { … … 89 101 class MyThread extends Thread { 90 102 private static MyApp app = new MyApp(); 91 private static My AppObserver observer = new MyObserver();103 private static MyObserver observer = new MyObserver(); 92 104 private static MyAccount account = null; 93 105 private static AccountConfig accCfg = null; … … 118 130 119 131 while (!Thread.currentThread().isInterrupted()) { 132 // Handle events 120 133 MyApp.ep.libHandleEvents(10); 134 135 // Check if any call instance need to be deleted 136 observer.check_call_deletion(); 121 137 try { 122 138 Thread.currentThread().sleep(50);
Note: See TracChangeset
for help on using the changeset viewer.