本文整理汇总了Java中com.csipsimple.service.SipService.SameThreadException类的典型用法代码示例。如果您正苦于以下问题:Java SameThreadException类的具体用法?Java SameThreadException怎么用?Java SameThreadException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SameThreadException类属于com.csipsimple.service.SipService包,在下文中一共展示了SameThreadException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBuddiesForAccount
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Add buddies for a given account
* @param acc
*/
private synchronized void addBuddiesForAccount(SipProfile acc) {
// Get buddies uris for this account
final List<String> toAdd = getBuddiesForAccount(acc);
if (toAdd.size() > 0 && service != null) {
service.getExecutor().execute(new SipRunnable() {
@Override
protected void doRun() throws SameThreadException {
for (String csipUri : toAdd) {
service.addBuddy("sip:" + csipUri);
}
}
});
}
addedAccounts.add(acc);
}
示例2: SimpleWavRecorderHandler
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
public SimpleWavRecorderHandler(SipCallSession callInfo, File recordFolder, int way)
throws SameThreadException, IOException {
this.way = way;
this.callInfo = callInfo;
File targetFile = getRecordFile(recordFolder, callInfo.getRemoteContact(), way);
if (targetFile == null) {
throw new IOException("No target file possible");
}
recordingPath = targetFile.getAbsolutePath();
pj_str_t file = pjsua.pj_str_copy(recordingPath);
int[] rcId = new int[1];
int status = pjsua.recorder_create(file, 0, (byte[]) null, 0, 0, rcId);
if (status == pjsua.PJ_SUCCESS) {
recorderId = rcId[0];
} else {
throw new IOException("Pjsip not able to write the file");
}
}
示例3: sipStop
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Stop sip service
*
* @return true if stop has been performed
*/
public boolean sipStop() throws SameThreadException {
Log.d(THIS_FILE, ">> SIP STOP <<");
if (getActiveCallInProgress() != null) {
Log.e(THIS_FILE, "We have a call in progress... DO NOT STOP !!!");
// TODO : queue quit on end call;
return false;
}
if (service.notificationManager != null) {
service.notificationManager.cancelRegisters();
}
if (created) {
cleanPjsua();
}
if (tasksTimer != null) {
tasksTimer.cancel();
tasksTimer.purge();
tasksTimer = null;
}
return true;
}
示例4: callAnswer
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Answer a call
*
* @param callId the id of the call to answer to
* @param code the status code to send in the response
* @return
*/
public int callAnswer(int callId, int code) throws SameThreadException {
if (created) {
pjsua_call_setting cs = new pjsua_call_setting();
pjsua.call_setting_default(cs);
cs.setAud_cnt(1);
cs.setVid_cnt(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_VIDEO) ? 1
: 0);
cs.setFlag(0);
return pjsua.call_answer2(callId, cs, code, null, null);
// return pjsua.call_answer(callId, code, null, null);
}
return -1;
}
示例5: sendDtmf
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Send a dtmf signal to a call
*
* @param callId the call to send the signal
* @param keyCode the keyCode to send (android style)
* @return
*/
public int sendDtmf(int callId, int keyCode) throws SameThreadException {
if (!created) {
return -1;
}
String keyPressed = "";
// Since some device (xoom...) are apparently buggy with key character
// map loading...
// we have to do crappy thing here
if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
keyPressed = Integer.toString(keyCode - KeyEvent.KEYCODE_0);
} else if (keyCode == KeyEvent.KEYCODE_POUND) {
keyPressed = "#";
} else if (keyCode == KeyEvent.KEYCODE_STAR) {
keyPressed = "*";
} else {
// Fallback... should never be there if using visible dialpad, but
// possible using keyboard
KeyCharacterMap km = KeyCharacterMap.load(KeyCharacterMap.NUMERIC);
keyPressed = Integer.toString(km.getNumber(keyCode));
}
return sendDtmf(callId, keyPressed);
}
示例6: sendMessage
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Send sms/message using SIP server
*/
public ToCall sendMessage(String callee, String message, long accountId)
throws SameThreadException {
if (!created) {
return null;
}
ToCall toCall = sanitizeSipUri(callee, accountId);
if (toCall != null) {
pj_str_t uri = pjsua.pj_str_copy(toCall.getCallee());
pj_str_t text = pjsua.pj_str_copy(message);
/*
* Log.d(THIS_FILE, "get for outgoing"); int finalAccountId =
* accountId; if (accountId == -1) { finalAccountId =
* pjsua.acc_find_for_outgoing(uri); }
*/
// Nothing to do with this values
byte[] userData = new byte[1];
int status = pjsua.im_send(toCall.getPjsipAccountId(), uri, null, text, null, userData);
return (status == pjsuaConstants.PJ_SUCCESS) ? toCall : null;
}
return toCall;
}
示例7: addBuddy
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Add a buddy to buddies list
*
* @param buddyUri the uri to register to
* @throws SameThreadException
*/
public int addBuddy(String buddyUri) throws SameThreadException {
if (!created) {
return -1;
}
int[] p_buddy_id = new int[1];
pjsua_buddy_config buddy_cfg = new pjsua_buddy_config();
pjsua.buddy_config_default(buddy_cfg);
buddy_cfg.setSubscribe(1);
buddy_cfg.setUri(pjsua.pj_str_copy(buddyUri));
pjsua.buddy_add(buddy_cfg, p_buddy_id);
return p_buddy_id[0];
}
示例8: setPresence
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Set self presence
*
* @param presence the SipManager.SipPresence
* @param statusText the text of the presence
* @throws SameThreadException
*/
public void setPresence(PresenceStatus presence, String statusText, long accountId)
throws SameThreadException {
if (!created) {
Log.e(THIS_FILE, "PJSIP is not started here, nothing can be done");
return;
}
SipProfile account = new SipProfile();
account.id = accountId;
SipProfileState profileState = getProfileState(account);
// In case of already added, we have to act finely
// If it's local we can just consider that we have to re-add account
// since it will actually just touch the account with a modify
if (profileState != null && profileState.isAddedToStack()) {
// The account is already there in accounts list
pjsua.acc_set_online_status(profileState.getPjsuaId(), getOnlineForStatus(presence));
}
}
示例9: stopRecording
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Stop recording of a call.
*
* @param callId the call to stop record for.
* @throws SameThreadException virtual exception to be sure we are calling
* this from correct thread
*/
public void stopRecording(int callId) throws SameThreadException {
if (!created) {
return;
}
List<IRecorderHandler> recoders = callRecorders.get(callId, null);
if (recoders != null) {
for (IRecorderHandler recoder : recoders) {
recoder.stopRecording();
// Broadcast to other apps the a new sip record has been done
SipCallSession callInfo = getPublicCallInfo(callId);
Intent it = new Intent(SipManager.ACTION_SIP_CALL_RECORDED);
it.putExtra(SipManager.EXTRA_CALL_INFO, callInfo);
recoder.fillBroadcastWithInfo(it);
service.sendBroadcast(it, SipManager.PERMISSION_USE_SIP);
}
// In first case we drop everything
callRecorders.delete(callId);
userAgentReceiver.updateRecordingStatus(callId, true, false);
}
}
示例10: onReceive
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
@Override
public void onReceive(final Context context, final Intent intent) {
// Run the handler in SipServiceExecutor to be protected by wake lock
service.getExecutor().execute(new SipRunnable() {
public void doRun() throws SameThreadException {
onReceiveInternal(context, intent, compatIsInitialStickyBroadcast(intent));
}
});
}
示例11: onConnectivityChanged
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Treat the fact that the connectivity has changed
* @param info Network info
* @param incomingOnly start only if for outgoing
* @throws SameThreadException
*/
private void onConnectivityChanged(NetworkInfo info, boolean isSticky) throws SameThreadException {
// We only care about the default network, and getActiveNetworkInfo()
// is the only way to distinguish them. However, as broadcasts are
// delivered asynchronously, we might miss DISCONNECTED events from
// getActiveNetworkInfo(), which is critical to our SIP stack. To
// solve this, if it is a DISCONNECTED event to our current network,
// respect it. Otherwise get a new one from getActiveNetworkInfo().
if (info == null || info.isConnected() ||
!info.getTypeName().equals(mNetworkType)) {
ConnectivityManager cm = (ConnectivityManager) service.getSystemService(Context.CONNECTIVITY_SERVICE);
info = cm.getActiveNetworkInfo();
}
boolean connected = (info != null && info.isConnected() && service.isConnectivityValid());
String networkType = connected ? info.getTypeName() : "null";
String currentRoutes = dumpRoutes();
String oldRoutes;
synchronized (mRoutes) {
oldRoutes = mRoutes;
}
// Ignore the event if the current active network is not changed.
if (connected == mConnected && networkType.equals(mNetworkType) && currentRoutes.equals(oldRoutes)) {
return;
}
if(Log.getLogLevel() >= 4) {
if(!networkType.equals(mNetworkType)) {
Log.d(THIS_FILE, "onConnectivityChanged(): " + mNetworkType +
" -> " + networkType);
}else {
Log.d(THIS_FILE, "Route changed : "+ mRoutes+" -> "+currentRoutes);
}
}
// Now process the event
synchronized (mRoutes) {
mRoutes = currentRoutes;
}
mConnected = connected;
mNetworkType = networkType;
if(!isSticky) {
if (connected) {
service.restartSipStack();
} else {
Log.d(THIS_FILE, "We are not connected, stop");
if(service.stopSipStack()) {
service.stopSelf();
}
}
}
}
示例12: startMonitoring
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
public void startMonitoring() {
int pollingIntervalMin = service.getPrefs().getPreferenceIntegerValue(SipConfigManager.NETWORK_ROUTES_POLLING);
Log.d(THIS_FILE, "Start monitoring of route file ? " + pollingIntervalMin);
if(pollingIntervalMin > 0) {
pollingTimer = new Timer("RouteChangeMonitor", true);
pollingTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
String currentRoutes = dumpRoutes();
String oldRoutes;
synchronized (mRoutes) {
oldRoutes = mRoutes;
}
if(!currentRoutes.equalsIgnoreCase(oldRoutes)) {
Log.d(THIS_FILE, "Route changed");
// Run the handler in SipServiceExecutor to be protected by wake lock
service.getExecutor().execute(new SipRunnable() {
public void doRun() throws SameThreadException {
onConnectivityChanged(null, false);
}
});
}
}
}, new Date(), pollingIntervalMin * 60 * 1000);
}
}
示例13: setSpeakerphoneOn
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
public void setSpeakerphoneOn(boolean on) throws SameThreadException {
if(service != null && restartAudioWhenRoutingChange && !ringer.isRinging()) {
service.setNoSnd();
userWantSpeaker = on;
service.setSnd();
}else {
userWantSpeaker = on;
audioManager.setSpeakerphoneOn(on);
}
broadcastMediaChanged();
}
示例14: setBluetoothOn
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
public void setBluetoothOn(boolean on) throws SameThreadException {
Log.d(THIS_FILE, "Set BT "+on);
if(service != null && restartAudioWhenRoutingChange && !ringer.isRinging()) {
service.setNoSnd();
userWantBluetooth = on;
service.setSnd();
}else {
userWantBluetooth = on;
bluetoothWrapper.setBluetoothOn(on);
}
broadcastMediaChanged();
}
示例15: setSoftwareVolume
import com.csipsimple.service.SipService.SameThreadException; //导入依赖的package包/类
/**
* Change the audio volume amplification according to the fact we are using bluetooth
*/
public void setSoftwareVolume(){
if(service != null) {
final boolean useBT = (bluetoothWrapper != null && bluetoothWrapper.isBluetoothOn());
String speaker_key = useBT ? SipConfigManager.SND_BT_SPEAKER_LEVEL : SipConfigManager.SND_SPEAKER_LEVEL;
String mic_key = useBT ? SipConfigManager.SND_BT_MIC_LEVEL : SipConfigManager.SND_MIC_LEVEL;
final float speakVolume = service.getPrefs().getPreferenceFloatValue(speaker_key);
final float micVolume = userWantMicrophoneMute? 0 : service.getPrefs().getPreferenceFloatValue(mic_key);
service.getExecutor().execute(new SipRunnable() {
@Override
protected void doRun() throws SameThreadException {
service.confAdjustTxLevel(speakVolume);
service.confAdjustRxLevel(micVolume);
// Force the BT mode to normal
if(useBT) {
audioManager.setMode(AudioManager.MODE_NORMAL);
}
}
});
}
}