package kr.co.icontrols.callengine.engine; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.ToneGenerator; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.os.Vibrator; import android.util.DisplayMetrics; import android.util.Log; import android.view.SurfaceView; import android.widget.ListView; import android.widget.RelativeLayout; import com.artncore.WallPadDataMgr.WallpadStatusData; import com.util.LogUtil; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.SocketException; import java.net.UnknownHostException; import java.util.Date; import java.util.List; import bssoft.stack.sip.BSSVideo; import bssoft.stack.sip.CMCore; import bssoft.stack.sip.History; import bssoft.stack.sip.SIPCall; import bssoft.stack.sip.SIPStack; import bssoft.stack.sip.videoEnc; import kr.co.icontrols.callengine.engine.CallManager.CALLEVENTTYPE; import kr.co.icontrols.callengine.engine.CallManager.CALLSTATUS; import kr.co.icontrols.callengine.engine.CallManager.CALLTYPE; import kr.co.icontrols.callengine.remotecall.AVPacket; import kr.co.icontrols.callengine.sip.SIPController; import kr.co.icontrols.callengine.sip.SIPStun; import kr.co.icontrols.wallpadcall.MainActivity; import kr.co.icontrols.wallpadcall.declare.Declare; import kr.co.icontrols.wallpadcall.declare.Declare.DeviceType; import kr.co.icontrols.wallpadcall.declare.Global; import kr.co.icontrols.wallpadcall.declare.Global.BOARD_TYPE; import kr.co.icontrols.wallpadcall.declare.Global.ConfigValues; public class SIPInterface { private static final String TAG = "SIPInterface"; static boolean bLOG = true; private static void LOG(String log) { if (bLOG) Log.v(TAG, log); } static boolean bLOG_DEBUG = true; private static void LOG_DEBUG(String log) { if (bLOG_DEBUG) Log.d(TAG, log); } static boolean bLOG_INFO = true; private static void LOG_INFO(String log) { if (bLOG_INFO) Log.i(TAG, log); } static boolean bLOG_WARN = true; private static void LOG_WARN(String log) { if (bLOG_WARN) Log.w(TAG, log); } private static final boolean DEBUG_FRAME = true; private boolean bEncoderStarted = false; private boolean bDecoderStarted = false; private int mNativeSurfaceTexture = 0; // accessed by native methods Context mContext; public interface SIPEventListener { public void onSIPEvent(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strRemoteIP, String strRemoteSIPID, String strMessage); public void onVideoSet(boolean bSet, String strRemoteSIPID); public void onShowRemoteVideo(boolean bShow); } private SIPEventListener mSIPEventListener; public SIPInterface(Context context) { try { Log.d(TAG, "======================= [SIPInterface] ======================="); mContext = context; if (!SIPStack.bActive) { // SIPStun 서비스가 active 상태일 때 서비스 생성을 중복수행 않음. mContext.startService(new Intent(mContext, SIPStun.class)); CMCore.bDialerActive = true; } doBindService(); // BR 등록 IntentFilter filter = new IntentFilter(); filter.addAction(Declare.BR.NOTIFY_CHANGE_LOBBY_FILTER); mContext.registerReceiver(mFilterChangeBR, filter); // 안심통화 필터 Preset 초기화 if (ConfigValues.bReliefCall) { WallpadStatusData DBMGR = new WallpadStatusData(mContext); String[] presetArray = DBMGR.GetReliefCallDegree().split(":"); DBMGR.closeDB(); SIPController.nFilterPreset = new int[4]; for (int i = 0; i < SIPController.nFilterPreset.length; i++) { SIPController.nFilterPreset[i] = Integer.valueOf(presetArray[i]); LOG("[SIPInterface] SIPController.nFilterPreset[" + i + "] = " + SIPController.nFilterPreset[i]); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] SIPInterface(Context context) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void releaseSIPInterface() { try { mSIPEventListener = null; doUnbindService(); if (mCameraOpenCheckHandler != null) { mCameraOpenCheckHandler.removeMessages(0); mCameraOpenCheckHandler.removeMessages(1); } // BR 해제 mContext.unregisterReceiver(mFilterChangeBR); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] releaseSIPInterface() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setSIPEventListener(SIPEventListener SIPEV) { mSIPEventListener = SIPEV; } MediaPlayer oRingbackTone = null; int dipWidth = 0; int dipHeight = 0; DisplayMetrics displayMetrics = null; protected static int RTP_PORT = 3002; public VideoRtpmanager videoManager = null; protected static int iFrames = 0; protected static Date frameDate = new Date(); protected static RelativeLayout remoteLayer = null; protected static RelativeLayout myLayer = null; protected static SurfaceView myview = null; protected static SurfaceView remoteview = null; protected static String padNumber = ""; protected static int officeNumber = 0; // 1:정문, 2:후문, 3:관할, 4:관리사무소 protected static ListView mHistoryView = null; protected static List historyList = null; protected static boolean bIncomingcover_lock = false; ////////////////////////////////////////////////////////////////////////////// /////// service define ////////////////////////////////////////////////////////////////////////////// boolean mIsBound = false; Messenger mService = null; final Messenger mMessenger = new Messenger(new CmPiper()); class CmPiper extends Handler { @Override public void handleMessage(Message msg) { switch (msg.what) { case CMCore.BSSSIPStun_ICONTROLS_CM_UPDATESTATUS_TRUE: { String value = msg.getData().getString("UPDATESTATUS"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_UPDATESTATUS_TRUE [" + value + "]"); if (value.contains("Call forwarded.")) sendSIPEvent(CALLEVENTTYPE.FORWARD_CALL, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_UPDATESTATUS_FALSE: { String value = msg.getData().getString("UPDATESTATUS"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_UPDATESTATUS_FALSE [" + value + "]"); if (value.contains("Call disconnecting.")) sendSIPEvent(CALLEVENTTYPE.TERMINATE_CALL, value); if (value.contains("Call cancelling.")) sendSIPEvent(CALLEVENTTYPE.CANCEL_CALL, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_VIDEOSET_TRUE: { String value = msg.getData().getString("VIDEOSET"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_VIDEOSET_TRUE [" + value + "]"); LOG_INFO("[CmPiper] SIPController.sipCall.dnis [" + SIPController.sipCall.dnis + "]"); if (mSIPEventListener != null) { mSIPEventListener.onVideoSet(true, value); } else LOG_WARN("[CmPiper] mSIPEventListener is null!!!"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_VIDEOSET_FALSE: { String value = msg.getData().getString("VIDEOSET"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_VIDEOSET_FALSE [" + value + "]"); LOG_INFO("[CmPiper] SIPController.sipCall.dnis [" + SIPController.sipCall.dnis + "]"); if (mSIPEventListener != null) { CALLSTATUS eResiCallStatus = MainActivity.mCallController.mCallInfo.getRESI(); LOG("[CmPiper] eResiCallStatus [" + eResiCallStatus + "]"); if (eResiCallStatus != CALLSTATUS.HOMEVIEW) mSIPEventListener.onVideoSet(false, value); // 모바일에서 홈뷰어 실행중일 경우 비디오를 끄지 않음 } else LOG_WARN("[CmPiper] mSIPEventListener is null!!!"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_INCOMINGCALL: { String value = msg.getData().getString("INCOMINGCALL"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_INCOMINGCALL [" + value + "]"); sendSIPEvent(CALLEVENTTYPE.RECEIVE_CALL, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_INCOMINGMULTICALL: { String value = msg.getData().getString("INCOMINGMULTICALL"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_INCOMINGMULTICALL [" + value + "]"); sendSIPEvent(CALLEVENTTYPE.RECEIVE_CALL_2ND, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CALLCONNECTED: { String value = msg.getData().getString("CALLCONNECTED"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLCONNECTED [" + value + "]"); try { String dn = ""; String uri = ""; int pos = value.indexOf(";"); if (pos >= 0) { dn = value.substring(0, pos); uri = value.substring(pos + 1); notifyCallConnected(dn, uri); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] CmPiper -> BSSSIPStun_ICONTROLS_CM_CALLCONNECTED"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } sendSIPEvent(CALLEVENTTYPE.CONNECT_CALL, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_BACKGROUNDINCOMINGCALL: { String value = msg.getData().getString("BACKGROUNDINCOMINGCALL"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_BACKGROUNDINCOMINGCALL [" + value + "]"); sendSIPEvent(CALLEVENTTYPE.RECEIVE_CALL, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_SHUTDOWNAPPLICATION: { String value = msg.getData().getString("SHUTDOWNAPPLICATION"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_SHUTDOWNAPPLICATION [" + value + "]"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_VIBRATOR_TRUE: { String value = msg.getData().getString("VIBRATOR"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_VIBRATOR_TRUE [" + value + "]"); vibrator(true); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_VIBRATOR_FALSE: { String value = msg.getData().getString("VIBRATOR"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_VIBRATOR_FALSE [" + value + "]"); vibrator(false); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_REGISTSTATUS_TRUE: { String value = msg.getData().getString("REGISTSTATUS"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_REGISTSTATUS_TRUE [" + value + "]"); registStatus(true); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_REGISTSTATUS_FALSE: { String value = msg.getData().getString("REGISTSTATUS"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_REGISTSTATUS_FALSE [" + value + "]"); registStatus(false); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_RINGBACKTONE_TRUE: { String value = msg.getData().getString("RINGBACKTONE"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_RINGBACKTONE_TRUE [" + value + "]"); notifyRingbackTone(true); sendSIPEvent(CALLEVENTTYPE.RECEIVE_CALL_ACK, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_RINGBACKTONE_FALSE: { String value = msg.getData().getString("RINGBACKTONE"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_RINGBACKTONE_FALSE [" + value + "]"); notifyRingbackTone(false); sendSIPEvent(CALLEVENTTYPE.RECEIVE_CALL_ACK, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CALLEND_TRUE: { String value = msg.getData().getString("CALLEND"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLEND_TRUE [" + value + "]"); try { String status = ""; String dn = ""; String uri = ""; int pos = value.indexOf(";"); if (pos >= 0) { status = value.substring(0, pos); int posE = value.indexOf(";", pos + 1); if (posE > 0) { dn = value.substring(pos + 1, posE); uri = value.substring(posE + 1); notifyCallEnd(status, dn, uri, true); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLEND_TRUE [status : " + status + ", dn : " + dn + ", uri : " + uri + "]"); } } else { notifyCallEnd(status, dn, uri, true); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] CmPiper -> BSSSIPStun_ICONTROLS_CM_CALLEND_TRUE"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } sendSIPEvent(CALLEVENTTYPE.TERMINATE_CALL, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CALLEND_FALSE: { String value = msg.getData().getString("CALLEND"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLEND_FALSE [" + value + "]"); String status = ""; String dn = ""; String uri = ""; try { int pos = value.indexOf(";"); if (pos >= 0) { status = value.substring(0, pos); int posE = value.indexOf(";", pos + 1); if (posE > 0) { dn = value.substring(pos + 1, posE); uri = value.substring(posE + 1); notifyCallEnd(status, dn, uri, false); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLEND_FALSE [status : " + status + ", dn : " + dn + ", uri : " + uri + "]"); } } else { notifyCallEnd(status, dn, uri, false); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] CmPiper -> BSSSIPStun_ICONTROLS_CM_CALLEND_FALSE"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } if (status.contains("Call rejected by remoter")) { sendSIPEvent(CALLEVENTTYPE.REJECT_CALL, value); } else if (status.contains("Ready")) { } else { sendSIPEvent(CALLEVENTTYPE.TERMINATE_CALL, value); } break; } case CMCore.BSSSIPStun_ICONTROLS_CM_OUTBANDDTMF: { String value = msg.getData().getString("OUTBANDDTMF"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_OUTBANDDTMF [" + value + "]"); notifyDtmf(Integer.parseInt(value)); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_PADNUMBER: { String value = msg.getData().getString("PADNUMBER"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_PADNUMBER [" + value + "]"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_PADTYPE: { String value = msg.getData().getString("PADTYPE"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_PADTYPE [" + value + "]"); // set padNumber int pos = value.indexOf('.'); if (pos >= 0) { SIPController.latestMenu = Integer.parseInt(value.substring(0, pos)); officeNumber = Integer.parseInt(value.substring(pos + 1)); processCallProcessed(SIPController.latestMenu); } break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CALLNEIGHBOR: { String value = msg.getData().getString("CALLNEIGHBOR"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLNEIGHBOR [" + value + "]"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CALLGUARD: { String value = msg.getData().getString("CALLGUARD"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLGUARD [" + value + "]"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CALLTIME: { String value = msg.getData().getString("CALLTIME"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CALLTIME [" + value + "]"); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_CANCELMULTICALL: { String value = msg.getData().getString("CANCELMULTICALL"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_CANCELMULTICALL [" + value + "]"); sendSIPEvent(CALLEVENTTYPE.CANCEL_CALL_2ND, value); break; } case CMCore.BSSSIPStun_ICONTROLS_CM_OUTCALLFAIL: { String value = msg.getData().getString("CALLFAIL"); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_OUTCALLFAIL [" + value + "]"); // set padNumber int pos = value.indexOf('|'); if (pos >= 0) { int finalCode = Integer.parseInt(value.substring(0, pos)); String remoteip = value.substring(pos + 1); String desc = ""; desc = CMCore.getCallfailReason(finalCode); LOG_INFO("[CmPiper] BSSSIPStun_ICONTROLS_CM_OUTCALLFAIL [desc : " + desc + ", code : " + finalCode + ", ip : " + remoteip + "]"); if (finalCode == 486) { sendSIPEvent(CALLEVENTTYPE.REJECT_BUSY_CALL, value); } else if (finalCode == 487) { sendSIPEvent(CALLEVENTTYPE.CANCEL_CALL, value); } else if (finalCode == 488 || finalCode == 480) { sendSIPEvent(CALLEVENTTYPE.REJECT_CALL, value); } } break; } case CMCore.BSSSIPStun_ICONTROLS_SET_INT_VALUE: String strEQCtrl = msg.getData().getString("cmd"); Log.w(TAG, "[JstrEQCtrl [" + strEQCtrl + "]"); if (strEQCtrl.equals("reply_get_eq_values")) { short[] Reply = new short[5]; Reply[0] = msg.getData().getShort("60"); Reply[1] = msg.getData().getShort("230"); Reply[2] = msg.getData().getShort("910"); Reply[3] = msg.getData().getShort("4k"); Reply[4] = msg.getData().getShort("14k"); if (mAudioTuneInterface != null) { mAudioTuneInterface.onAudioTuneReply(Reply); } } else if (strEQCtrl.equals("reply_set_eq_value")) { } break; default: { LOG_INFO("[CmPiper] default [" + msg.toString() + "]"); super.handleMessage(msg); break; } } } } private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { mService = new Messenger(service); LOG_INFO("Messenger ServiceConnection Attached."); try { Message msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_REGISTER); msg.replyTo = mMessenger; mService.send(msg); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] onServiceConnected(ComponentName className, IBinder service)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void onServiceDisconnected(ComponentName className) { mService = null; LOG_INFO("Messenger ServiceConnection Disconnected."); } }; //@Override public void onVolumeChanged(int id) { } public int[] convertYVU420PtoRGB8888(byte[] data, int width, int height) { int size = width * height; int offset = size; int[] pixels = new int[size]; int u, v, y1, y2, y3, y4; // i percorre os Y and the final pixels // k percorre os pixles U e V for (int i = 0, k = 0; i < size; i += 2, k += 1) { y1 = data[i] & 0xFF; y2 = data[i + 1] & 0xFF; y3 = data[width + i] & 0xFF; y4 = data[width + i + 1] & 0xFF; v = data[offset + k] & 0xFF; u = data[offset + k + size / 4] & 0xFF; u = u - 128; v = v - 128; pixels[i] = convertYUVtoRGB(y1, u, v); pixels[i + 1] = convertYUVtoRGB(y2, u, v); pixels[width + i] = convertYUVtoRGB(y3, u, v); pixels[width + i + 1] = convertYUVtoRGB(y4, u, v); if (i != 0 && (i + 2) % width == 0) { i += width; } } return pixels; } private static int convertYUVtoRGB(int Y, int U, int V) { int R, G, B; R = Y + (int) 1.402F * V; G = Y - (int) (0.344F * U + 0.714F * V); B = Y + (int) 1.772F * U; R = R > 255 ? 255 : R < 0 ? 0 : R; G = G > 255 ? 255 : G < 0 ? 0 : G; B = B > 255 ? 255 : B < 0 ? 0 : B; return 0xFF000000 | (B << 16) | (G << 8) | R; } // bssoft private void sendCommandToUI(int msgType, String value) { if (mIsBound) { if (mService != null) { try { Bundle b = new Bundle(); b.putString("PADNUMBER", value); Message msg = null; msg = Message.obtain(null, msgType); msg.setData(b); mService.send(msg); } catch (RemoteException e) { Log.e(TAG, "[RemoteException] sendCommandToUI(int msgType,String value)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } } //multicall private void responseMulticallToStun(boolean bAccept) { if (mIsBound) { if (mService != null) { try { Bundle b = new Bundle(); Message msg = null; if (bAccept == true) { b.putString("ACCEPTMULTICALL", ""); msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_DIALER_ACCEPTMULTICALL); } else { b.putString("REJECTMULTICALL", ""); msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_DIALER_REJECTMULTICALL); } msg.setData(b); mService.send(msg); } catch (RemoteException e) { Log.e(TAG, "[RemoteException] responseMulticallToStun(boolean bAccept)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } } // multicall private void forwardNotifyToStun() { String contact = ""; String ip = ""; String redirectName = ""; if (SIPController.forward.bForward == false) return; if (SIPController.forward.iForwardTarget == 0) { // 세대기 String ip_field1 = ""; String ip_field2 = ""; String ip_field3 = ""; String ip_field4 = ""; if (SIPController.forward.dong.length() > 3) { ip_field1 = SIPController.forward.dong.substring(0, 3); ip_field2 = SIPController.forward.dong.substring(3); } if (SIPController.forward.ho.length() > 3) { int start = SIPController.forward.ho.length() - 3; ip_field3 = SIPController.forward.ho.substring(0, start); ip_field4 = SIPController.forward.ho.substring(start); } if (ip_field1.length() > 0 && ip_field2.length() > 0 && ip_field3.length() > 0 && ip_field4.length() > 0) { ip = Integer.parseInt(ip_field1) + "." + Integer.parseInt(ip_field2) + "." + Integer.parseInt(ip_field3) + "." + Integer.parseInt(ip_field4); } redirectName = "이웃세대기 " + SIPController.forward.dong + "동 " + SIPController.forward.ho + "호"; } else { // 경비실 SIPController.forward.dong = "office"; if (Integer.parseInt(SIPController.forward.ho) == 1) { // 정문 // ip = 경비실 정문 아이피주소 설정; redirectName = "정문 경비실"; } else if (Integer.parseInt(SIPController.forward.ho) == 2) { // 후문 // ip = 경비실 후문 아이피주소 설정; redirectName = "후문 경비실"; } else if (Integer.parseInt(SIPController.forward.ho) == 3) { // 관할 // ip = 경비실 관할 아이피주소 설정; redirectName = "관할 경비실"; } else if (Integer.parseInt(SIPController.forward.ho) == 4) { // 관리 // ip = 경비실 관리소 아이피주소 설정; redirectName = "관리사무소"; } } if (ip.length() == 0) { // 취소 if (SIPController.sipCall != null) { SIPController.sipCall.bRejectRequest = true; onconnectedScreen(false); } else { incomingScreen(SIPStack.userDial.dial, false); } } else { contact = "sip:" + SIPController.forward.dong + "*" + SIPController.forward.ho + "@" + ip + ":5060"; if (mIsBound) { if (mService != null) { try { Bundle b = new Bundle(); Message msg = null; b.putString("FORWARD", contact); msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_DIALER_FORWARD); msg.setData(b); mService.send(msg); LOG_INFO("[forwardNotifyToStun] Call Forward -> " + redirectName + "Call forwarded!!!"); } catch (RemoteException e) { Log.e(TAG, "[RemoteException] forwardNotifyToStun()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } } } public void requestCallForwardToStun(String strSIPContact) { try { LOG("[requestCallForwardToStun] strSIPContact [" + strSIPContact + "]"); SIPController.forward.bForward = true; SIPController.sipCall.bForwardRequest = true; SIPController.forward.contact = "sip:" + strSIPContact; String[] strParse = strSIPContact.split("_"); SIPController.forward.dong = Integer.toString(Integer.parseInt(strParse[2])); SIPController.forward.ho = Integer.toString(Integer.parseInt(strParse[3])); LOG("[requestCallForwardToStun] Forward Info"); LOG("[requestCallForwardToStun] SIPController.forward.bForward [" + SIPController.forward.bForward + "], SIPController.sipCall.bForwardRequest [" + SIPController.sipCall.bForwardRequest + "]"); LOG("[requestCallForwardToStun] SIPController.forward.contact [" + SIPController.forward.contact + "]"); LOG("[requestCallForwardToStun] SIPController.forward.dong [" + SIPController.forward.dong + "], SIPController.forward.ho [" + SIPController.forward.ho + "]"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] requestCallForwardToStun(strSIPContact) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setCallForwardToStun(String strSIPContact) { try { LOG("[setCallForwardToStun] strSIPContact [" + strSIPContact + "]"); SIPController.forward.bForward = true; SIPController.sipCall.bForwardRequest = true; SIPController.forward.contact = "sip:" + strSIPContact; String[] strParse = strSIPContact.split("_"); SIPController.forward.dong = Integer.toString(Integer.parseInt(strParse[2])); SIPController.forward.ho = Integer.toString(Integer.parseInt(strParse[3])); LOG("[setCallForwardToStun] Forward Info"); LOG("[setCallForwardToStun] SIPController.forward.bForward [" + SIPController.forward.bForward + "], SIPController.sipCall.bForwardRequest [" + SIPController.sipCall.bForwardRequest + "]"); LOG("[setCallForwardToStun] SIPController.forward.contact [" + SIPController.forward.contact + "]"); LOG("[setCallForwardToStun] SIPController.forward.dong [" + SIPController.forward.dong + "], SIPController.forward.ho [" + SIPController.forward.ho + "]"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setCallForwardToStun(strSIPContact) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void cancelCallForwardToStun() { try { LOG("[cancelCallForwardToStun]"); SIPController.sipCall.bForwardRequest = false; SIPController.forward.bForward = false; SIPController.forward.contact = ""; SIPController.forward.iForwardTarget = 0; SIPController.forward.dong = ""; SIPController.forward.ho = ""; SIPController.forward.number = ""; SIPController.forward.contact = ""; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] cancelCallForwardToStun() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void requestCallForwardToStun() { try { SIPController.forward.bForward = false; SIPController.sipCall.bForwardRequest = true; SIPController.forward.dong = "102"; SIPController.forward.ho = "26"; SIPController.forward.contact = "sip:" + "12345678_Guard_0102_0026_01@10.2.128.26:5060"; String contact = SIPController.forward.contact; String ip = "10.2.128.26"; String redirectName = "102동 26번 경비"; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] requestCallForwardToStun() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } void doBindService() { mContext.bindService(new Intent(mContext, SIPStun.class), mConnection, Context.BIND_AUTO_CREATE); mIsBound = true; LOG_INFO("[doBindService] SERVICE BIND NEWLY"); } void doUnbindService() { mIsBound = true; if (mIsBound) { // If we have received the service, and hence registered with it, then now is the time to unregister. if (mService != null) { try { Message msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_UNREGISTER); msg.replyTo = mMessenger; mService.send(msg); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (RemoteException e) { Log.e(TAG, "[RemoteException] doUnbindService() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } // Detach our existing connection. mContext.unbindService(mConnection); mIsBound = false; LOG_INFO(">>> Service Unbinding."); } } public void notifyDtmf(final int dtmf) { } /** * Updates the status box at the top of the UI with a messege of your choice. * * @param status The String to display in the status box. */ public final void updateStatus(final String status, final boolean bDialreset) { try { Runnable runner = new Runnable() { public void run() { } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] updateStatus(final String status,final boolean bDialreset) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public final void registStatus(final boolean bActive) { try { Runnable runner = new Runnable() { public void run() { if (SIPStack.bNetworkActive == bActive) { if (bActive == true) { } } else { SIPStack.bNetworkActive = bActive; } } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] registStatus(final boolean bActive) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void videoSet(final boolean bSet, final boolean bEncoding, final boolean bDecoding) { LOG_INFO("[videoSet] bSet [" + bSet + "], bEncoding [" + bEncoding + "], bDecoding [" + bDecoding + "]"); // Log.w(TAG, "[videoSet] ================= VIDEO [1] ================="); if (!bSet || !bDecoding) { if (mSIPEventListener != null) mSIPEventListener.onShowRemoteVideo(false); else LOG_INFO("[videoSet] mSIPEventListener is null!!"); } // Log.w(TAG, "[videoSet] ================= VIDEO [2] ================="); if (BSSVideo.bVideoMute == true) { LOG_INFO("[videoSet] BSSVideo.bVideoMute [" + BSSVideo.bVideoMute + "]"); return; } try { // Log.w(TAG, "[videoSet] ================= VIDEO [3] ================="); if (Build.VERSION.SDK_INT > 23) { // Log.w(TAG, "[videoSet] ================= VIDEO [4-1] ================="); // AOS 7.1.1 (메이드인랩 BSP) VideoSet mVideoSet = new VideoSet(bSet, bEncoding, bDecoding); mVideoSet.start(); } else { Runnable runner = new Runnable() { public void run() { // Log.w(TAG, "[videoSet] ================= VIDEO [4-2] ================="); if (bSet == false && BSSVideo.bService == true) { // Log.w(TAG, "[videoSet] ================= VIDEO [5] ================="); // video off BSSVideo.bService = false; BSSVideo.bRemoteview = false; if (videoManager != null && videoManager.videoenc.bReceiveRunning == true) { // Log.w(TAG, "[videoSet] ================= VIDEO [6] ================="); videoManager.videoenc.bReceiveRunning = false; videoManager.interrupt(); videoManager.closeSocket(); videoManager = null; } if (!bDecoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [7] ================="); if (bDecoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [8] ================="); MainActivity.mCallController.mVideoJNI.decoderStopOperation(); bDecoderStarted = false; } // Log.w(TAG, "[videoSet] ================= VIDEO [9] ================="); } // Log.w(TAG, "[videoSet] ================= VIDEO [10] ================="); if (!bEncoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [11] ================="); if (bEncoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [12] ================="); try { bEncoderStarted = false; MainActivity.mCallController.mVideoJNI.encoderStopOperation(); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { ((MainActivity) mContext).setEncodingStopError(); Log.e(TAG, "[Exception] videoSet.run() encoderStopOperation()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } BSSVideo.bViewme = false; } else if (bSet == true && BSSVideo.bService == false) { // Log.w(TAG, "[videoSet] ================= VIDEO [13] ================="); // video on BSSVideo.bCover = true; BSSVideo.bRemoteview = false; BSSVideo.bService = true; BSSVideo.dateVideoincoming = new Date(); if (bEncoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [14] ================="); if (!bEncoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [15] ================="); bEncoderStarted = true; if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT) mCameraOpenCheckHandler.sendEmptyMessage(0); else { ((MainActivity) mContext).checkEncodingStopError(); MainActivity.mCallController.mVideoJNI.encoderStartOperation(); } } } // Log.w(TAG, "[videoSet] ================= VIDEO [16] ================="); if (bDecoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [17] ================="); // Log.d(TAG, "[videoSet] bDecoderStarted: " + bDecoderStarted); if (!bDecoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [18] ================="); // Decode start bDecoderStarted = true; videoManager = new VideoRtpmanager(); videoManager.start(); MainActivity.mCallController.mVideoJNI.setComposite(true); try { Thread.sleep(1000); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (InterruptedException e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } MainActivity.mCallController.mVideoJNI.decoderStartOperation(); } // Log.w(TAG, "[videoSet] ================= VIDEO [19] ================="); // Log.d(TAG, "[videoSet] bEncoderStarted [" + bEncoderStarted + "], bDecoderStarted [" + bDecoderStarted + "]"); } } } }; if (runner != null) ((MainActivity) mContext).runOnUiThread(runner); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] videoSet(final boolean bSet, final boolean bEncoding, final boolean bDecoding)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return; } } class VideoSet extends Thread { boolean bSet = false, bEncoding = false, bDecoding = false; public VideoSet(final boolean set, final boolean encoding, final boolean decoding) { bSet = set; bEncoding = encoding; bDecoding = decoding; } @Override public void run() { super.run(); try { // Log.w(TAG, "[videoSet] ================= VIDEO [4] ================="); Log.d(TAG, "[videoSet] bSet [" + bSet + "], bService [" + BSSVideo.bService + "]"); if (bSet == false && BSSVideo.bService == true) { // Log.w(TAG, "[videoSet] ================= VIDEO [5] ================="); // video off BSSVideo.bService = false; BSSVideo.bRemoteview = false; if (videoManager != null && videoManager.videoenc.bReceiveRunning == true) { // Log.w(TAG, "[videoSet] ================= VIDEO [6] ================="); videoManager.videoenc.bReceiveRunning = false; videoManager.interrupt(); videoManager.closeSocket(); videoManager = null; } if (!bDecoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [7] ================="); if (bDecoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [8] ================="); MainActivity.mCallController.mVideoJNI.decoderStopOperation(); bDecoderStarted = false; } // Log.w(TAG, "[videoSet] ================= VIDEO [9] ================="); } // Log.w(TAG, "[videoSet] ================= VIDEO [10] ================="); if (!bEncoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [11] ================="); if (bEncoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [12] ================="); try { bEncoderStarted = false; MainActivity.mCallController.mVideoJNI.encoderStopOperation(); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { ((MainActivity) mContext).setEncodingStopError(); Log.e(TAG, "[Exception] VideoSet.run() encoderStopOperation()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } BSSVideo.bViewme = false; } else if (bSet == true && BSSVideo.bService == false) { // Log.w(TAG, "[videoSet] ================= VIDEO [13] ================="); // video on BSSVideo.bCover = true; BSSVideo.bRemoteview = false; BSSVideo.bService = true; BSSVideo.dateVideoincoming = new Date(); if (bEncoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [14] ================="); if (!bEncoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [15] ================="); bEncoderStarted = true; if (ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40 || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_NOUGAT || ConfigValues.DEVICE_BOARDTYPE == BOARD_TYPE.V40_IGW300_NOUGAT) { mCameraOpenCheckHandler.sendEmptyMessage(0); } else { ((MainActivity) mContext).checkEncodingStopError(); MainActivity.mCallController.mVideoJNI.encoderStartOperation(); } } } // Log.w(TAG, "[videoSet] ================= VIDEO [16] ================="); if (bDecoding) { // Log.w(TAG, "[videoSet] ================= VIDEO [17] ================="); Log.d(TAG, "[videoSet] bDecoderStarted: " + bDecoderStarted); if (!bDecoderStarted) { // Log.w(TAG, "[videoSet] ================= VIDEO [18] ================="); // Decode start bDecoderStarted = true; videoManager = new VideoRtpmanager(); videoManager.start(); MainActivity.mCallController.mVideoJNI.setComposite(true); // try { // Thread.sleep(1000); // } catch (InterruptedException e) { // //e.printStackTrace(); // LogUtil.errorLogInfo("", TAG, e); // } MainActivity.mCallController.mVideoJNI.decoderStartOperation(); } // Log.w(TAG, "[videoSet] ================= VIDEO [19] ================="); Log.d(TAG, "[videoSet] bEncoderStarted [" + bEncoderStarted + "], bDecoderStarted [" + bDecoderStarted + "]"); } } // Log.w(TAG, "[videoSet] ================= VIDEO [20] ================="); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] VideoSet.run()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } int nCheckCnt = 0; private Handler mCameraOpenCheckHandler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0) { nCheckCnt++; if (nCheckCnt > 100) { Log.w(TAG, "[mCameraOpenCheckHandler] Camera Open Fail!!"); mCameraOpenCheckHandler.removeMessages(0); mCameraOpenCheckHandler.removeMessages(1); } else { if (((MainActivity) mContext).mMyCamera != null) mCameraOpenCheckHandler.sendEmptyMessageDelayed(1, 100); else mCameraOpenCheckHandler.sendEmptyMessageDelayed(0, 100); } } else if (msg.what == 1) { // 카메라 인코딩 시작!! Log.d(TAG, "[mCameraOpenCheckHandler.handleMessage] Handler finish!! [CAMERA OPEN]"); ((MainActivity) mContext).checkEncodingStopError(); MainActivity.mCallController.mVideoJNI.encoderStartOperation(); } } }; public boolean contactCall(final String dialString) { return false; } // connected Screen public void onconnectedScreen(boolean bOn) { if (bOn == true && SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { LOG_INFO("[onconnectedScreen] LOBBY CONNECTED : " + BSSVideo.bProgressvideooffer + ", bCover : " + BSSVideo.bCover); if (BSSVideo.bProgressvideooffer == true && BSSVideo.bCover == true) { } else { } } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { LOG_INFO("[onconnectedScreen] GUARD CONNECTED : " + BSSVideo.bProgressvideooffer + " bCover : " + BSSVideo.bCover); if (BSSVideo.bProgressvideooffer == true && BSSVideo.bCover == true) { } else { } } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { LOG_INFO("[onconnectedScreen] RESIDENCE CONNECTED : " + BSSVideo.bProgressvideooffer + " bCover : " + BSSVideo.bCover); if (BSSVideo.bProgressvideooffer == true && BSSVideo.bCover == false) { } else { } } } } else if (bOn == true && SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) { // OUT if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_LOBBY) { if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_GUARD) { } else if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_GUARD) { } else if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_GUARD) { if (BSSVideo.bProgressvideooffer == true && BSSVideo.bCover == true) { } else { } } else if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (BSSVideo.bProgressvideooffer == true && BSSVideo.bCover == false) { } else { } } } } } // connected Screen public void onconnectedpadScreen(boolean bOn) { } // incoming Screen public void incomingScreen(String dnis, boolean bOn) { LOG_INFO("[incomingScreen] dnis [" + dnis + "]"); if (bOn == true && SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { String officeName = ""; if (dnis.startsWith("office*") == true) { } } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } } return; } public void playSound(boolean bPlay) { LOG_INFO("[playSound]"); } public void playDtmf(int dtmf, boolean bPlay) { try { ToneGenerator toneGenerator = new ToneGenerator(AudioManager.STREAM_DTMF, ToneGenerator.MAX_VOLUME);//ToneGenerator.MAX_VOLUME); //this will play tone for 2 seconds. toneGenerator.stopTone(); int dur = 100; switch (dtmf) { case 0: toneGenerator.startTone(ToneGenerator.TONE_DTMF_0, dur); break; case 1: toneGenerator.startTone(ToneGenerator.TONE_DTMF_1, dur); break; case 2: toneGenerator.startTone(ToneGenerator.TONE_DTMF_2, dur); break; case 3: toneGenerator.startTone(ToneGenerator.TONE_DTMF_3, dur); break; case 4: toneGenerator.startTone(ToneGenerator.TONE_DTMF_4, dur); break; case 5: toneGenerator.startTone(ToneGenerator.TONE_DTMF_5, dur); break; case 6: toneGenerator.startTone(ToneGenerator.TONE_DTMF_6, dur); break; case 7: toneGenerator.startTone(ToneGenerator.TONE_DTMF_7, dur); break; case 8: toneGenerator.startTone(ToneGenerator.TONE_DTMF_8, dur); break; case 9: toneGenerator.startTone(ToneGenerator.TONE_DTMF_9, dur); break; case 10: toneGenerator.startTone(ToneGenerator.TONE_DTMF_A, dur * 2); break; case 11: toneGenerator.startTone(ToneGenerator.TONE_DTMF_B, dur * 3); break; default: toneGenerator.startTone(ToneGenerator.TONE_DTMF_P, dur); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] playDtmf(int dtmf, boolean bPlay) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void vibrator(boolean bSet) { try { if (SIPStack.bVibrator) { if (bSet && SIPStack.bVibrating == false) { SIPController.vibe = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); long[] pattern = {1000, 200, 1000, 2000, 1200}; SIPController.vibe.vibrate(pattern, SIPStack.iVibrator); SIPStack.bVibrating = true; } else if (SIPStack.bVibrating == true && SIPController.vibe != null) { SIPController.vibe.cancel(); SIPStack.bVibrating = false; } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] vibrator(boolean bSet) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void notifyIncomingCall(final String status, final String dn, final String uri) { try { Runnable runner = new Runnable() { public void run() { if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return; else { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { processCallProcessed(1); incomingScreen(dn, true); } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { processCallProcessed(2); incomingScreen(dn, true); } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { processCallProcessed(3); incomingScreen(dn, true); } } } }; ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] notifyIncomingCall(final String status, final String dn, final String uri) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void notifyIncomingMultiCall(final String status, final String dn, final String uri) { try { Runnable runner = new Runnable() { public void run() { if (SIPController.sipCall == null || SIPController.sipCall.flag == false || SIPController.pendingCall == null || SIPController.pendingCall.flag == false) { return; } else { String multicallName = ""; if (dn.startsWith("lobby") == true) { multicallName = "로비로 부터"; } if (dn.startsWith("office") == true) { multicallName = "경비실로 부터"; } else { int pos = dn.indexOf("*"); if (pos > 0) { String dong = dn.substring(0, pos); String ho = dn.substring(pos + 1); multicallName = dong + "동 " + ho + "호로 부터"; } else { multicallName = "세대기로 부터"; } } } } }; ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] notifyIncomingMultiCall(final String status, final String dn, final String uri) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return; } } final boolean processCallProcessed(int iMenu) { LOG_INFO(">>>>>>>>> processVisitorPressed : " + iMenu); return true; } final boolean initializeCallWindow() { return true; } public void notifyBackgroundIncomingCall(final String status, final String dn, final String uri) { try { Runnable runner = new Runnable() { public void run() { Intent i = new Intent(SIPController.ownerContent, SIPInterface.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); SIPController.ownerContent.startActivity(i); } }; ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] notifyBackgroundIncomingCall(final String status, final String dn, final String uri) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return; } } public void updateCallMode(final int mode) { } public final void notifyCallEnd(final String status, final String dn, final String uri, final boolean bDialreset) { playSound(false); try { Runnable runner = new Runnable() { public void run() { incomingScreen("", false); SIPStack.userDial.dial = ""; SIPStack.userDial.dong = ""; SIPStack.userDial.ho = ""; BSSVideo.bService = false; BSSVideo.bRemoteview = false; BSSVideo.HNS_SERVICE_RECEIVER_SELECTED = BSSVideo.HNS_SERVICE_NONE; processCallProcessed(SIPController.latestMenu); } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] notifyCallEnd(final String status, final String dn, final String uri, final boolean bDialreset) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return; } } public final void notifyMultiCallEnd() { try { Runnable runner = new Runnable() { public void run() { } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] notifyMultiCallEnd() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return; } } public final void notifyCallConnected(final String dn, final String uri) { playSound(false); try { Runnable runner = new Runnable() { public void run() { onconnectedScreen(true); } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { return; } } public final void notifyRingbackTone(final boolean bActive) { try { Runnable runner = new Runnable() { public void run() { playSound(bActive); } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { return; } } public void youAreBackground() { CMCore.bDialerActive = false; SIPStack.backgroundEnteredTime = new Date(); SIPStack.bBackgroundRunning = true; LOG_INFO(">>> Background Running set. !!!!!!!!!!!"); } public void ongoingScreen(boolean bOn) { if (bOn == true) { if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_LOBBY) { if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { } else if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { } else if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { if (BSSVideo.bProgressvideooffer == false || BSSVideo.bCover == true) { } else { } } else if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { } } } else if (bOn == false) { } } public final int getIncomingcoverCase() { if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return 99; else { if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { return 0; } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { return 1; } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { return 2; } } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) { if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { return 3; } else if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_GUARD) { return 4; } } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) { return 5; } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) { return 6; } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { return 7; } } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) { if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { return 8; } else if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_GUARD) { return 9; } } } else if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_LOBBY) { if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) { if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { return 10; } else if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_GUARD) { return 11; } } } } return 99; } public void removeIncomingcover() { LOG_INFO("[removeIncomingcover] bIncomingcover_lock [" +bIncomingcover_lock + "]"); if (bIncomingcover_lock) return; LOG_INFO(">>>> removeIncomingcover"); bIncomingcover_lock = true; try { Runnable runner = new Runnable() { public void run() { try { if (mSIPEventListener != null) { mSIPEventListener.onShowRemoteVideo(true); } else { LOG_WARN("[removeIncomingcover] mSIPEventListener is null!!"); sendShowRemoteView(true); } int index = getIncomingcoverCase(); LOG_INFO("[removeIncomingcover] index = " + index); switch (index) { case 0: //neighbor<-, neighbor<-lobby if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } else if (BSSVideo.bProgressvideooffer == true) { if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { } else { } BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } break; case 1: //neighbor<-, neighbor<-guard if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } else if (BSSVideo.bProgressvideooffer == true) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } break; case 2: //neighbor<-, neighbor<-neighbor if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } break; case 3: //neighbor->, neighbor->neighbor if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } break; case 4: //neighbor->, neighbor->guard if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } else if (BSSVideo.bProgressvideooffer == true) { BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); } break; case 5: BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); break; case 9: BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); break; case 10://lobby->, lobby->neighbor break; case 11://lobby->, lobby->guard BSSVideo.bCover = false; BSSVideo.dateVideoincoming = new Date(); break; default: break; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] >>>> removeIncomingcover exception 1"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } bIncomingcover_lock = false; return; } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] >>>> removeIncomingcover exception 2"); bIncomingcover_lock = false; return; } } public void attachIncomingcover() { LOG_INFO("[attachIncomingcover] bIncomingcover_lock [" +bIncomingcover_lock + "]"); if (bIncomingcover_lock) return; bIncomingcover_lock = true; try { Runnable runner = new Runnable() { public void run() { if (mSIPEventListener != null) { mSIPEventListener.onShowRemoteVideo(false); } else { LOG_INFO("[attachIncomingcover] mSIPEventListener is null!!"); sendShowRemoteView(false); } if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) { try { BSSVideo.bCover = true; BSSVideo.dateVideoincoming = new Date(); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { LOG_INFO("[Exception] attachIncomingcover"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } bIncomingcover_lock = false; return; } }; if (runner != null) ((Activity) mContext).runOnUiThread(runner); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] >>>> attachIncomingcover exception 2"); bIncomingcover_lock = false; return; } } private void sendShowRemoteView(boolean bShow) { try { Log.i(TAG, "[sendShowRemoteView] bShow = " + bShow); Intent mIntent = new Intent(); if (bShow) mIntent.setAction(Declare.BR.BR_SHOW_REMOTEVIEW_TRUE); else mIntent.setAction(Declare.BR.BR_SHOW_REMOTEVIEW_FALSE); mContext.sendBroadcast(mIntent); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] sendShowRemoteView()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void dial(int iDial) { char cDial = '0'; try { playDtmf(iDial, true); // if (SIPStack.userDial.dial.length() > 16) return; cDial += iDial; SIPStack.userDial.dial = SIPStack.userDial.dial + cDial; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] dial(int iDial)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return; } public void ui_callEnd() { try { LOG("[ui_callEnd]"); BSSVideo.bViewme = false; SIPStack.userDial.dial = ""; SIPStack.userDial.dong = ""; SIPStack.userDial.ho = ""; if (SIPController.sipCall != null) { SIPController.sipCall.bCancelRequest = true; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] ui_callEnd() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return; } public void rejectCall() { try { BSSVideo.bViewme = false; SIPStack.userDial.dial = ""; SIPStack.userDial.dong = ""; SIPStack.userDial.ho = ""; if (SIPController.sipCall != null) { SIPController.sipCall.bRejectRequest = true; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] rejectCall()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void rejectMultiCall() { try { responseMulticallToStun(false); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] rejectMultiCall()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void rejectBusyCall() { try { LOG("[rejectBusyCall]"); if (SIPController.sipCall != null) { SIPController.sipCall.bRejectRequest = true; SIPController.bSinglecallBusyResponse = true; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] rejectBusyCall()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void rejectBusyMultiCall() { try { LOG("[rejectBusyMultiCall]"); SIPController.pendingCall.bRejectRequest = true; SIPController.bMulticallBusyResponse = true; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] rejectBusyCall()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void ui_callInvoke(CALLTYPE eCallType, String Head, String Tail) { try { Log.e(TAG, "[ui_callInvoke] SIPController.sipCall.flag [" + SIPController.sipCall.flag + "]"); LOG("[ui_callInvoke] eCallType [" + eCallType + "], Head [" + Head + "], Tail [" + Tail + "]"); SIPStack.userDial.dong = Head; SIPStack.userDial.ho = Tail; SIPStack.userDial.dial = Tail; if (SIPStack.userDial.dial.length() == 0) return; if (SIPController.sipCall == null) Log.e(TAG, "SIP CALL is null"); if (SIPController.sipCall != null && SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) { // Incoming Call SIPController.sipCall.bDirectcall = SIPStack.bDirectCall; SIPController.sipCall.bNewcallRequest = true; SIPController.sipCall.number = new String(SIPStack.userDial.dial); onconnectedScreen(true); } else { // Outgoing Call if (eCallType == CALLTYPE.RESIDENCE || eCallType == CALLTYPE.RENTRESIDENCE) { BSSVideo.HNS_SERVICE_RECEIVER_SELECTED = BSSVideo.HNS_SERVICE_NEIGHBOR; } else if (eCallType == CALLTYPE.GUARD) { BSSVideo.HNS_SERVICE_RECEIVER_SELECTED = BSSVideo.HNS_SERVICE_GUARD; } else { BSSVideo.HNS_SERVICE_RECEIVER_SELECTED = BSSVideo.HNS_SERVICE_NEIGHBOR; } if (SIPStack.userDial.dial == null) SIPStack.userDial.dial = ""; if (SIPStack.userDial.dial.length() == 0) { if (SIPStack.userDial.latestDial == null || SIPStack.userDial.latestDial.length() == 0) return; } SIPController.sipCall.number = MainActivity.mCallController.makeSIPID(eCallType, SIPStack.userDial.dong, SIPStack.userDial.ho); SIPController.sipCall.dong_number = SIPStack.userDial.dong; SIPController.sipCall.ho_number = SIPStack.userDial.ho; SIPController.sipCall.bDirectcall = false; if (eCallType == CALLTYPE.RESIDENCE) { SIPController.sipCall.remoteIp = Global.makeIPAddress(DeviceType.RESIDENCE, SIPStack.userDial.dong, SIPStack.userDial.ho); } else if (eCallType == CALLTYPE.GUARD) { SIPController.sipCall.remoteIp = Global.makeIPAddress(DeviceType.GUARD, SIPStack.userDial.dong, SIPStack.userDial.ho); } else if (eCallType == CALLTYPE.RENTRESIDENCE) { SIPController.sipCall.remoteIp = Global.makeIPAddress(DeviceType.RENTRESIDENCE, SIPStack.userDial.dong, SIPStack.userDial.ho); } else { SIPController.sipCall.remoteIp = Global.makeIPAddress(DeviceType.RESIDENCE, SIPStack.userDial.dong, SIPStack.userDial.ho); } SIPController.sipCall.serverIp = SIPController.sipCall.remoteIp; SIPController.sipCall.serverDomain = SIPController.sipCall.remoteIp; SIPController.sipCall.remoteContactIp = SIPController.sipCall.remoteIp; SIPController.sipCall.bDirectcall = true; SIPController.sipCall.bNewcallRequest = true; SIPStack.userDial.latestDial = new String(SIPController.sipCall.number); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] ui_callInvoke(CALLTYPE eCallType, String Head, String Tail) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return; } public void ui_guardcallInvoke(int iOffice) { String ip = ""; String dn = ""; if (iOffice == 1) { ip = "10.2.128.27"; //정문 아이피주소 dn = "office*1"; } else if (iOffice == 2) { ip = "192.168.10.24";//후문 아이피주소 dn = "office*2"; } else if (iOffice == 3) { ip = "192.168.10.25";//관할 아이피주소 dn = "office*3"; } else if (iOffice == 4) { ip = "192.168.10.26";//관리사무소 아이피주소 dn = "office*4"; } else return; try { SIPStack.userDial.dial = dn; if (SIPStack.userDial.dial.length() == 0) return; if (SIPController.sipCall == null) { Log.e(TAG, "SIPCALL is null"); } if (SIPController.sipCall != null && SIPController.sipCall != null && SIPController.sipCall.flag == true) { return; } else { if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_NONE) { BSSVideo.HNS_SERVICE_RECEIVER_SELECTED = BSSVideo.HNS_SERVICE_GUARD; } SIPStack.userDial.dial = dn; if (SIPController.sipCall != null) { SIPStack.userDial.dong = "office"; SIPStack.userDial.ho = "" + iOffice; SIPController.sipCall.number = dn; SIPController.sipCall.dong_number = SIPStack.userDial.dong; SIPController.sipCall.ho_number = SIPStack.userDial.ho; SIPController.sipCall.bDirectcall = false; if (ip.length() > 0) { SIPController.sipCall.remoteIp = ip; SIPController.sipCall.serverIp = SIPController.sipCall.remoteIp; SIPController.sipCall.serverDomain = SIPController.sipCall.remoteIp; SIPController.sipCall.remoteContactIp = SIPController.sipCall.remoteIp; SIPController.sipCall.bDirectcall = true; SIPController.sipCall.bNewcallRequest = true; SIPStack.userDial.latestDial = new String(SIPController.sipCall.number); } } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] ui_guardcallInvoke(int iOffice)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return; } public class VideoRtpmanager extends Thread { private DatagramSocket runningSocket = null; public videoEnc videoenc = new videoEnc(); protected DatagramSocket theSocket = null; protected boolean bOpenCover = false; @Override public void run() { try { LOG_INFO("[VideoRtpmanager] VideoRtpmanager started!"); try { RTP_PORT = 3002; LOG_INFO("[VideoRtpmanager] Video Port [" + RTP_PORT + "]"); theSocket = new DatagramSocket(RTP_PORT); theSocket.setReuseAddress(true); SIPController.dp = new DatagramPacket(videoenc.buffer, videoenc.buffer.length); } catch (SocketException se) { Log.e(TAG, "[SocketException] VideoRtpmanager().run()"); //se.printStackTrace(); LogUtil.errorLogInfo("", TAG, se); return; } catch (NullPointerException ne) { Log.e(TAG, "[NullPointerException] VideoRtpmanager().run()"); //ne.printStackTrace(); LogUtil.errorLogInfo("", TAG, ne); return; } //LOG_INFO("[VideoRtpmanager] ------- videoenc.init() -------"); videoenc.init(); videoenc.bReceiveRunning = true; runningSocket = theSocket; videoenc.bService = true; bOpenCover = false; //Log.e(TAG, "[VideoRtpmanager] videoenc.bReceiveRunning [" + videoenc.bReceiveRunning + "]"); if (runningSocket == null ) Log.e(TAG, "[VideoRtpmanager] runningSocket is null!!"); else Log.d(TAG, "[VideoRtpmanager] runningSocket is not null!!"); while (videoenc.bReceiveRunning == true && runningSocket != null) { //Log.e(TAG, "[VideoRtpmanager] ===== while ====="); try { if (videoManager == null) { Log.e(TAG, "[VideoRtpmanager] videoManager == null"); break; } if (videoManager.isInterrupted()) { Log.e(TAG, "[VideoRtpmanager] videoManager.isInterrupted()"); break; } if (videoenc.buffer == null) { Log.e(TAG, "[VideoRtpmanager] videoenc.buffer == null"); break; } if (SIPController.dp == null) { Log.e(TAG, "[VideoRtpmanager] SIPController.dp == null"); break; } SIPController.dp.setData(videoenc.buffer); SIPController.dp.setLength(videoenc.RTP_VIDEO_SIZE); runningSocket.receive(SIPController.dp); if (SIPController.dp == null) Log.e(TAG, "[VideoRtpmanager] SIPController.dp is null!!!"); //Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [1] ================="); if (SIPController.dp != null && SIPController.dp.getLength() > 0) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [2] ================="); if (false == videoenc.parseHNSRTPHeader()) { Log.e(TAG, "[VideoRtpmanager] videoenc.parseHNSRTPHeader() [" + videoenc.parseHNSRTPHeader() + "]"); continue; } // Log.e(TAG, "[VideoRtpmanager] videoenc.bView [" + videoenc.bView + "]"); if (videoenc.PARSEpayload != SIPStack.SIP_CODEC_H264) { Log.e(TAG, "[VideoRtpmanager] videoenc.PARSEpayload [" + videoenc.PARSEpayload + "]"); continue; } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [3] ================="); // if (SIPController.forward.bForward == true) { //// Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [4] ================="); // Log.d(TAG, "[VideoRtpmanager] [PARSEmark] = " + videoenc.PARSEmark + ", [flag] = " + SIPController.sipCall.flag + ", [bForwardRequest] = " + SIPController.sipCall.bForwardRequest); // if (videoenc.PARSEmark == 1 && SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bForwardRequest == false) { //// Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [5] ================="); // // recording forward picture // byte[] field = new byte[4]; // System.arraycopy(videoenc.buffer, 13, field, 0, 4); // int headerLen = getIntByByteArr(field); // System.arraycopy(videoenc.buffer, 17, field, 0, 4); // int frameLen = getIntByByteArr(field); // System.arraycopy(videoenc.buffer, 21, field, 0, 4); // int timeStamp = getIntByByteArr(field); // int frameSize = (frameLen > 0) ? frameLen : headerLen; // if (SIPController.dp.getLength() - 25 >= frameSize && bDecoderStarted == true) { // System.arraycopy(videoenc.buffer, 25, videoenc.data, 0, frameSize); // forwardNotifyToStun(); // Log.e(TAG, "[VideoRtpmanager] videoenc.PARSEpayload [" + videoenc.PARSEpayload + "]"); // } // } // continue; // } //Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [6] ================="); if (bOpenCover == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [7] ================="); if (videoenc.bIframeset == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [7-1] ================="); if (videoenc.PARSEmark == 1) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [7-2] ================="); videoenc.bIframeset = true; if (BSSVideo.bProgressvideooffer == true) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [7-3] ================="); bOpenCover = true; BSSVideo.incurtenLength = 100; //Milli seconds BSSVideo.outcurtenLength = 100; //Milli seconds } } } else if (videoenc.bIframedoubleset == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [7-4] ================="); if (videoenc.PARSEmark == 1) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [7-5] ================="); videoenc.bIframedoubleset = true; bOpenCover = true; BSSVideo.incurtenLength = 100; //Milli seconds BSSVideo.outcurtenLength = 100; //Milli seconds } } } //Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [8] ================="); byte[] field = new byte[4]; System.arraycopy(videoenc.buffer, 13, field, 0, 4); int headerLen = getIntByByteArr(field); System.arraycopy(videoenc.buffer, 17, field, 0, 4); int frameLen = getIntByByteArr(field); System.arraycopy(videoenc.buffer, 21, field, 0, 4); int timeStamp = getIntByByteArr(field); int frameSize = (frameLen > 0) ? frameLen : headerLen; //Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [9] ================="); if (SIPController.dp.getLength() - 25 >= frameSize && bDecoderStarted == true) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [10] ================="); System.arraycopy(videoenc.buffer, 25, videoenc.data, 0, frameSize); // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [11] ================="); MainActivity.mCallController.mVideoJNI.sendDataToDecoder(videoenc.data, headerLen, frameLen, timeStamp); // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [12] ================="); if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [13] ================="); if (ConfigValues.bRemoteCall) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [13-1] ================="); sendVideoToMobile(videoenc.data, frameSize, isH264iFrame(videoenc.data, videoenc.data.length)); // 방문객원격통화 로비 영상을 모바일로 전송 } if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [14] ================="); if (videoenc.bView == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [14-1] ================="); if (BSSVideo.bCover == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [14-2] ================="); BSSVideo.bRemoteview = false; BSSVideo.dateVideoincoming = new Date(); attachIncomingcover(); BSSVideo.bCover = true; } continue; } else if (bOpenCover == true && BSSVideo.bCover == true) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [14-3] ================="); removeIncomingcover(); } } } else { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [15] ================="); // SIP_CALLDIRECTION_OUT if (SIPController.sipCall.hnsReceiverServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [15-1] ================="); if (videoenc.bView == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [15-2] ================="); if (BSSVideo.bCover == false) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [15-3] ================="); BSSVideo.bRemoteview = false; BSSVideo.dateVideoincoming = new Date(); attachIncomingcover(); BSSVideo.bCover = true; } continue; } else if (bOpenCover == true && BSSVideo.bCover == true) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [15-4] ================="); removeIncomingcover(); } } } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [16] ================="); if (BSSVideo.bRemoteview == false && bOpenCover == true) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [16-1] ================="); BSSVideo.bRemoteview = true; BSSVideo.dateVideoincoming = new Date(); } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [17] ================="); if (BSSVideo.bCover == true) { if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [17-1] ================="); if (bOpenCover == true && ((new Date()).getTime() - BSSVideo.dateVideoincoming.getTime()) > BSSVideo.incurtenLength) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [17-2] ================="); removeIncomingcover(); } } else { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [17-3] ================="); if (bOpenCover == true && ((new Date()).getTime() - BSSVideo.dateVideoincoming.getTime()) > BSSVideo.outcurtenLength) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [17-4] ================="); removeIncomingcover(); } } } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [18] ================="); } else { Log.e(TAG, "[VideoRtpmanager] SIPController.dp.getLength() [" + SIPController.dp.getLength() + "], bDecoderStarted [" + bDecoderStarted +"]"); } } } catch (SocketException se) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [19] ================="); Log.e(TAG, "[SocketException] VideoRtpmanager().run().while loop"); //se.printStackTrace(); LogUtil.errorLogInfo("", TAG, se); break; } catch (Exception e) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [20] ================="); Log.e(TAG, "[Exception] VideoRtpmanager().run().while loop"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); break; } } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [21] ================="); LOG_INFO("[VideoRtpmanager] RTP Thread terminated. out of while!!"); if (runningSocket != null) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [22] ================="); if (runningSocket == theSocket) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [23] ================="); theSocket.close(); theSocket = null; } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [24] ================="); runningSocket.close(); runningSocket = null; theSocket = null; } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [25] ================="); videoenc.bReceiveRunning = false; videoManager = null; theSocket = null; videoenc.bService = false; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [26] ================="); Log.e(TAG, "[Exception] VideoRtpmanager().run()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); if (runningSocket != null) { // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [27] ================="); if (runningSocket == theSocket) { theSocket.close(); theSocket = null; } runningSocket.close(); runningSocket = null; theSocket = null; } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [28] ================="); videoenc.bReceiveRunning = false; videoManager = null; theSocket = null; videoenc.bService = false; } // Log.e(TAG, "[VideoRtpmanager] ================= VIDEO RTP [29] ================="); } public int isH264iFrame(byte[] data, int size) { // Log.d(TAG, "[isH264iFrame] data [" + Global.HexToString(data) + "], size [" + size + "]"); int index = 0; for (; index + 3 < size; index++) { // This should always succeed in the first iteration. if (data[index] == 0 && data[index + 1] == 0 && data[index + 2] == 1) break; } if (index + 3 >= size) return 0; index += 3; int nalType = data[index] & 0x1F; if (nalType == 0x05 || nalType == 0x07 || nalType == 0x08) return 1; return 2; } public int getBytesToInt(byte[] bytes) { int newValue = 0; newValue |= (((int) bytes[0]) << 24) & 0xFF000000; newValue |= (((int) bytes[1]) << 16) & 0xFF0000; newValue |= (((int) bytes[2]) << 8) & 0xFF00; newValue |= (((int) bytes[3])) & 0xFF; return newValue; } public byte[] getIntToBytes(int iValue) { byte[] newbytes = new byte[4]; newbytes[0] = (byte) (iValue >> 24); newbytes[1] = (byte) ((iValue << 8) >> 24); newbytes[2] = (byte) ((iValue << 16) >> 24); newbytes[3] = (byte) ((iValue << 24) >> 24); return newbytes; } //end of rtp private int getIntByByteArr(final byte[] byteArr) { int byte_0 = (((int) byteArr[0]) << 24) & 0xFF000000; int byte_1 = (((int) byteArr[1]) << 16) & 0x00FF0000; int byte_2 = (((int) byteArr[2]) << 8) & 0x0000FF00; int byte_3 = (((int) byteArr[3]) << 0) & 0x000000FF; return (byte_0 | byte_1 | byte_2 | byte_3); } public VideoRtpmanager getRtpManager() { if (videoManager == null) { videoManager = new VideoRtpmanager(); } return videoManager; } public byte[] getByteArrByInt(int intVal) { byte[] arrByte = new byte[4]; arrByte[0] = (byte) ((intVal >>> 24) & 0xFF); arrByte[1] = (byte) ((intVal >>> 16) & 0xFF); arrByte[2] = (byte) ((intVal >>> 8) & 0xFF); arrByte[3] = (byte) ((intVal >>> 0) & 0xFF); return arrByte; } public int SendRTPPacket(String sIp, int iPort, byte[] data, int dataSize) { if (videoenc.bReceiveRunning == false) return 0; int sent = 0; if (sIp == null || sIp.length() <= 0) return 0; if (data == null || dataSize <= 0) return 0; if (iPort <= 0) return 0; if (runningSocket == null) return 0; try { InetAddress ia = InetAddress.getByName(sIp); if (ia != null) { DatagramPacket dp = new DatagramPacket(data, dataSize, ia, iPort); if (dp != null) { runningSocket.send(dp); } } sent = dataSize; } catch (NullPointerException ne) { //System.err.println(ne); LogUtil.errorLogInfo("", TAG, ne); } catch (UnknownHostException uhe) { //System.err.println(uhe); LogUtil.errorLogInfo("", TAG, uhe); } catch (IOException ie) { //System.err.println(ie); LogUtil.errorLogInfo("", TAG, ie); } return sent; } public int SendRTPPacket(String sIp, int iPort, final byte[] encodedFrame, final int headerLen, final int frameLen, final int timeStamp) { int sent = 0; if (sIp == null || sIp.length() <= 0) return 0; if (encodedFrame == null || frameLen <= 0) return 0; if (iPort <= 0) return 0; if (runningSocket == null) return 0; try { InetAddress ia = InetAddress.getByName(sIp); int dataSize = 0; if (ia != null) { int frameSize = (frameLen > 0) ? frameLen : headerLen; byte[] headerByte = getByteArrByInt(headerLen); byte[] frameByte = getByteArrByInt(frameLen); byte[] timeByte = getByteArrByInt(timeStamp); System.arraycopy(headerByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(frameByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(timeByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(encodedFrame, 0, videoenc.rtpVideoBuffer, dataSize, frameSize + 12); dataSize += frameSize; DatagramPacket dp = new DatagramPacket(videoenc.rtpVideoBuffer, dataSize, ia, iPort); if (dp != null) { runningSocket.send(dp); } } sent = dataSize; } catch (NullPointerException ne) { //System.err.println(ne); LogUtil.errorLogInfo("", TAG, ne); } catch (UnknownHostException uhe) { //System.err.println(uhe); LogUtil.errorLogInfo("", TAG, uhe); } catch (IOException ie) { //System.err.println(ie); LogUtil.errorLogInfo("", TAG, ie); } return sent; } public int writeRTPPacket(final byte[] encodedFrame, final int headerLen, final int frameLen, final int timeStamp, final boolean bIframe) { if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return 0; else { //세대기이면서 상대가 세대기가 아니면 영상제공차단 if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { if (SIPController.sipCall.hnsOriginatorServiceType != BSSVideo.HNS_SERVICE_NEIGHBOR) return 0; } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) { if (SIPController.sipCall.hnsReceiverServiceType != BSSVideo.HNS_SERVICE_NEIGHBOR) return 0; } } } if (SIPController.audioRTPManager.rtpCore == null) return 0; videoenc.remoteIp = SIPController.audioRTPManager.rtpCore.remoteMediaIp; videoenc.remotePort = SIPController.audioRTPManager.rtpCore.remoteMediaPort + 2; int sent = 0; if (videoenc.remoteIp == null || videoenc.remoteIp.length() <= 0) return 0; if (encodedFrame == null || frameLen <= 0) return 0; if (videoenc.remotePort <= 0) return 0; if (runningSocket == null) return 0; try { InetAddress ia = InetAddress.getByName(videoenc.remoteIp); int dataSize = 12; if (ia != null) { int frameSize = (frameLen > 0) ? frameLen : headerLen; byte[] headerByte = getByteArrByInt(headerLen); byte[] frameByte = getByteArrByInt(frameLen); byte[] timeByte = getByteArrByInt(timeStamp); System.arraycopy(headerByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(frameByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(timeByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(encodedFrame, 0, videoenc.rtpVideoBuffer, dataSize, frameSize); dataSize += frameSize; int packetsize = 0; try { packetsize = dataSize; videoenc.RTPtimestamp = timeStamp; if (videoenc.rtpVideoBuffer != null && packetsize > 0) { if (bIframe == true) videoenc.RTPmark = 1; else videoenc.RTPmark = 0; videoenc.RTPsequence++; videoenc.encodeRtpHeader(SIPStack.SIP_CODEC_H264); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //System.err.println("I/O problems: " + e); LogUtil.errorLogInfo("", TAG, e); SIPStack.exceptionCountAtCurrentCall++; return 0; } DatagramPacket dp = new DatagramPacket(videoenc.rtpVideoBuffer, dataSize, ia, videoenc.remotePort); if (dp != null) { // runningSocket.send(dp); } } sent = dataSize; } catch (NullPointerException ne) { //System.err.println(ne); LogUtil.errorLogInfo("", TAG, ne); } catch (UnknownHostException uhe) { //System.err.println(uhe); LogUtil.errorLogInfo("", TAG, uhe); } catch (IOException ie) { //System.err.println(ie); LogUtil.errorLogInfo("", TAG, ie); } return sent; } public int writeHNSRTPPacket(final byte[] encodedFrame, final int headerLen, final int frameLen, final int timeStamp, final boolean bIframe) { // Log.d(TAG, "[writeHNSRTPPacket] headerLen [" + headerLen + "], frameLen [" + frameLen + "], timeStamp [" + timeStamp + "], bIframe [" + bIframe + "]"); CALLSTATUS eCallStatus = MainActivity.mCallController.mCallInfo.getRESI(); // LOG_INFO("[writeHNSRTPPacket] eCallStatus [" + eCallStatus + "]"); if (eCallStatus != CALLSTATUS.HOMEVIEW) { if (SIPController.sipCall == null || SIPController.sipCall.flag == false) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [1] ================="); return 0; } else { // Log.e(TAG, "[writeHNSRTPPacket] ================= [2] ================="); //세대기이면서 상대가 세대기가 아니면 영상제공차단 if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [3] ================="); if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [4] ================="); if (SIPController.sipCall.hnsOriginatorServiceType != BSSVideo.HNS_SERVICE_NEIGHBOR) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [4-1] ================="); return 0; } } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [5] ================="); if (SIPController.sipCall.hnsReceiverServiceType != BSSVideo.HNS_SERVICE_NEIGHBOR) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [5-1] ================="); return 0; } } } } // Log.e(TAG, "[writeHNSRTPPacket] ================= [6] ================="); if (SIPController.audioRTPManager.rtpCore == null) return 0; videoenc.remoteIp = SIPController.audioRTPManager.rtpCore.remoteMediaIp; videoenc.remotePort = SIPController.audioRTPManager.rtpCore.remoteMediaPort + 2; if (videoenc.remoteIp == null || videoenc.remoteIp.length() <= 0) return 0; if (encodedFrame == null || frameLen <= 0) return 0; if (videoenc.remotePort <= 0) return 0; if (runningSocket == null) return 0; } int sent = 0; // Log.e(TAG, "[writeHNSRTPPacket] ================= [7] ================="); try { int dataSize = 13; if (eCallStatus == CALLSTATUS.HOMEVIEW) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [7-1] ================="); int frameSize = (frameLen > 0) ? frameLen : headerLen; byte[] headerByte = getByteArrByInt(headerLen); byte[] frameByte = getByteArrByInt(frameLen); byte[] timeByte = getByteArrByInt(timeStamp); System.arraycopy(headerByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(frameByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(timeByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(encodedFrame, 0, videoenc.rtpVideoBuffer, dataSize, frameSize); dataSize += frameSize; int packetsize = dataSize; videoenc.RTPtimestamp = timeStamp; if (videoenc.rtpVideoBuffer != null && packetsize > 0) { if (bIframe == true) videoenc.RTPmark = 1; else videoenc.RTPmark = 0; videoenc.RTPsequence++; videoenc.encodeHNSRtpHeader(SIPStack.SIP_CODEC_H264, BSSVideo.bViewme); } sendVideoToMobile(encodedFrame, dataSize, isH264iFrame(encodedFrame, dataSize)); // 방문객원격통화 홈뷰어 영상을 모바일로 전송 } else { InetAddress ia = InetAddress.getByName(videoenc.remoteIp); if (ia != null) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [8] ================="); int frameSize = (frameLen > 0) ? frameLen : headerLen; byte[] headerByte = getByteArrByInt(headerLen); byte[] frameByte = getByteArrByInt(frameLen); byte[] timeByte = getByteArrByInt(timeStamp); System.arraycopy(headerByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(frameByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(timeByte, 0, videoenc.rtpVideoBuffer, dataSize, 4); dataSize += 4; System.arraycopy(encodedFrame, 0, videoenc.rtpVideoBuffer, dataSize, frameSize); dataSize += frameSize; int packetsize = 0; try { // Log.e(TAG, "[writeHNSRTPPacket] ================= [9] ================="); packetsize = dataSize; videoenc.RTPtimestamp = timeStamp; if (videoenc.rtpVideoBuffer != null && packetsize > 0) { if (bIframe == true) videoenc.RTPmark = 1; else videoenc.RTPmark = 0; videoenc.RTPsequence++; // Log.i(TAG, "[writeHNSRTPPacket] BSSVideo.bViewme = " + BSSVideo.bViewme); if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD || BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_LOBBY) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [10] ================="); videoenc.encodeHNSRtpHeader(SIPStack.SIP_CODEC_H264, true); } else { // Log.e(TAG, "[writeHNSRTPPacket] ================= [11] ================="); videoenc.encodeHNSRtpHeader(SIPStack.SIP_CODEC_H264, BSSVideo.bViewme); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { SIPStack.exceptionCountAtCurrentCall++; //System.err.println("I/O problems: " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return 0; } // Log.e(TAG, "[writeHNSRTPPacket] ================= [12] ================="); DatagramPacket dp = new DatagramPacket(videoenc.rtpVideoBuffer, dataSize, ia, videoenc.remotePort); if (dp != null) { // Log.e(TAG, "[writeHNSRTPPacket] ================= [13] ================="); runningSocket.send(dp); } } } sent = dataSize; } catch (NullPointerException ne) { //System.err.println(ne); LogUtil.errorLogInfo("", TAG, ne); } catch (UnknownHostException uhe) { //System.err.println(uhe); LogUtil.errorLogInfo("", TAG, uhe); } catch (IOException ie) { //System.err.println(ie); LogUtil.errorLogInfo("", TAG, ie); } return sent; } public void closeSocket() { try { LOG_INFO("[closeSocket] UDP Client Closed"); if (runningSocket != null) { if (runningSocket == theSocket) theSocket = null; runningSocket.close(); runningSocket = null; } videoenc.bReceiveRunning = false; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] closeSocket() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } // 1 : BSSVideo.HNS_SERVICE_LOBBY // 2 : BSSVideo.HNS_SERVICE_GUARD // 3 : BSSVideo.HNS_SERVICE_NEIGHBOR // 4 : BSSVideo.HNS_SERVICE_NONE public void acceptMoIPCall(boolean bMobile) { playSound(false); SIPController.bMobileCall = bMobile; Log.d(TAG, "[acceptMoIPCall] SIPController.bMobileCall [" + SIPController.bMobileCall + "], SIPController.nFilterMode [" + SIPController.nFilterMode + "]"); SIPController.sipCall.bNewcallRequest = true; SIPController.sipCall.number = new String(SIPStack.userDial.dial); } public void acceptMoIPMultiCall() { try { responseMulticallToStun(true); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] acceptMoIPMultiCallCall()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void makeResidenceCall(CALLTYPE eCallType, String dong, String ho) { LOG_DEBUG("[makeResidenceCall] eCallType [" + eCallType + "], dong [" + dong + "], ho [" + ho + "]"); try { ui_callInvoke(eCallType, dong, ho); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] makeResidenceCall(CALLTYPE eCallType, String dong, String ho)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void makeGuardCall(String dong, String id) { LOG("[makeGuardCall] dong = " + dong + ", id = " + id); try { ui_callInvoke(CALLTYPE.GUARD, dong, id); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] makeGuardCall(...) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } private void sendSIPEvent(CALLEVENTTYPE eEventType, String strMessage) { try { LOG_INFO("[sendSIPEvent] SIPController.sipCall.flag [" + SIPController.sipCall.flag + "]"); LOG_INFO("[sendSIPEvent] eEventType [" + eEventType + "], strMessage [" + strMessage + "]"); LOG_INFO("[sendSIPEvent] BSSVideo.HNS_SERVICE_RECEIVER_SELECTED [" + BSSVideo.HNS_SERVICE_RECEIVER_SELECTED + "]"); LOG_INFO("[sendSIPEvent] SIPController.sipCall.remoteIp : " + SIPController.sipCall.remoteIp); LOG_INFO("[sendSIPEvent] SIPController.sipCall.number : " + SIPController.sipCall.number); LOG_INFO("[sendSIPEvent] SIPController.sipCall.cid : " + SIPController.sipCall.cid); LOG_INFO("[sendSIPEvent] SIPController.sipCall.dnis : " + SIPController.sipCall.dnis); LOG_INFO("[sendSIPEvent] SIPController.sipCall.dong_number : " + SIPController.sipCall.dong_number); LOG_INFO("[sendSIPEvent] SIPController.sipCall.ho_number : " + SIPController.sipCall.ho_number); LOG_INFO("[sendSIPEvent] SIPController.sipCall.id : " + SIPController.sipCall.id); String strRemoteIP = SIPController.sipCall.remoteIp; String strRemoteSIPID = SIPController.sipCall.dnis; CALLTYPE eCallType = CALLTYPE.NONE; if (SIPController.sipCall.dnis != null) { if (SIPController.sipCall.dnis.contains("_Resi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (SIPController.sipCall.dnis.contains("_RentResi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (SIPController.sipCall.dnis.contains("_Lobby_")) { eCallType = CALLTYPE.LOBBY; } else if (SIPController.sipCall.dnis.contains("_Guard_")) { eCallType = CALLTYPE.GUARD; } } else { if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_NEIGHBOR) { eCallType = CALLTYPE.RESIDENCE; } else if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_LOBBY) { eCallType = CALLTYPE.LOBBY; } else if (BSSVideo.HNS_SERVICE_RECEIVER_SELECTED == BSSVideo.HNS_SERVICE_GUARD) { eCallType = CALLTYPE.GUARD; } } if (eCallType == CALLTYPE.NONE) { if (strMessage.contains("_Resi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (strMessage.contains("_RentResi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (strMessage.contains("_Lobby_")) { eCallType = CALLTYPE.LOBBY; } else if (strMessage.contains("_Guard_")) { eCallType = CALLTYPE.GUARD; } } else { CALLTYPE eCallType_Temp = CALLTYPE.NONE; if (strMessage.contains("_Resi_")) eCallType_Temp = CALLTYPE.RESIDENCE; else if (strMessage.contains("_RentResi_")) eCallType_Temp = CALLTYPE.RESIDENCE; else if (strMessage.contains("_Lobby_")) eCallType_Temp = CALLTYPE.LOBBY; else if (strMessage.contains("_Guard_")) eCallType_Temp = CALLTYPE.GUARD; if (eCallType != eCallType_Temp) eCallType = eCallType_Temp; } if (eCallType == CALLTYPE.NONE) { if (!SIPController.sipCall.dong_number.equals("") && !SIPController.sipCall.ho_number.equals("")) { if (SIPController.sipCall.ho_number.length() > 2) eCallType = CALLTYPE.RESIDENCE; } } if (eEventType == CALLEVENTTYPE.RECEIVE_CALL_2ND) { // 멀티콜의 경우 "strMessage" 값으로 상대를 파악한다. eEventType = CALLEVENTTYPE.RECEIVE_CALL; if (strMessage.contains("_Resi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (strMessage.contains("_RentResi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (strMessage.contains("_Lobby_")) { eCallType = CALLTYPE.LOBBY; } else if (strMessage.contains("_Guard_")) { eCallType = CALLTYPE.GUARD; } strRemoteIP = getMultiCallIPAddress(strMessage); strRemoteSIPID = getMultiCallSIPID(strMessage); } if (eEventType == CALLEVENTTYPE.CANCEL_CALL_2ND) { // 멀티콜의 경우 "strMessage" 값으로 상대를 파악한다. eEventType = CALLEVENTTYPE.CANCEL_CALL; if (strMessage.contains("_Resi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (strMessage.contains("_RentResi_")) { eCallType = CALLTYPE.RESIDENCE; } else if (strMessage.contains("_Lobby_")) { eCallType = CALLTYPE.LOBBY; } else if (strMessage.contains("_Guard_")) { eCallType = CALLTYPE.GUARD; } String[] strParsed = strMessage.split(";"); strRemoteIP = strParsed[1]; strRemoteSIPID = strParsed[0]; } if (mSIPEventListener != null) { mSIPEventListener.onSIPEvent(eEventType, eCallType, strRemoteIP, strRemoteSIPID, strMessage); } else LOG_WARN("[sendSIPEvent] mSIPEventListener is null!!!"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] sendSIPEvent(eEvent, strMessage)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public boolean checkSIPActivation() { try { return SIPStack.bActive; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return false; } catch (Exception e) { Log.e(TAG, "[Exception] checkSIPActivation() : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return false; } } public void setVoiceDisable(boolean bVoice) { try { SIPController.audioRTPManager.bDisableVoice = bVoice; LOG_INFO("[setVoiceDisable] SIPController.audioRTPManager.bDisableVoice [" + SIPController.audioRTPManager.bDisableVoice + "]"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setVoiceDisable(boolean bVoice) : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public boolean bShowMyVideo = false; public int nVideoSignalFlagCnt = 0; public void showMyVideo(boolean bShow) { try { Log.i(TAG, "[showMyVideo] bShow [" + bShow + "]"); if (bShow) { nVideoSignalFlagCnt = 0; MainActivity.mCallController.mVideoJNI.setCheckIFrame(true); bShowMyVideo = bShow; } else { bShowMyVideo = bShow; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] showMyVideo(boolean bShow)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } private String getMultiCallSIPID(String strMessage) { try { String[] strParsed_01 = strMessage.split(";"); return strParsed_01[0]; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return null; } catch (Exception e) { Log.e(TAG, "[Exception] getMultiCallSIPID(String strMessage)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return null; } } private String getMultiCallIPAddress(String strMessage) { try { String[] strParsed_01 = strMessage.split("@"); String[] strParsed_02 = strParsed_01[1].split(":"); return strParsed_02[0]; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return null; } catch (Exception e) { Log.e(TAG, "[Exception] getMultiCallIPAddress(String strMessage)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return null; } } public void setMultiCallasMainCall() { try { SIPController.sipCall.bPending = true; Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.bPending = " + SIPController.sipCall.bPending); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.remoteIp = " + SIPController.sipCall.remoteIp); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.remoteContactUri = " + SIPController.sipCall.remoteContactUri); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.remoteContactIp = " + SIPController.sipCall.remoteContactIp); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.cid = " + SIPController.sipCall.cid); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.dnis = " + SIPController.sipCall.dnis); Log.d(TAG, "[setMultiCallasMainCall] SIPController.MultiCall.bPending = " + SIPController.MultiCall.bPending); Log.d(TAG, "[setMultiCallasMainCall] SIPController.MultiCall.remoteIp = " + SIPController.MultiCall.remoteIp); Log.d(TAG, "[setMultiCallasMainCall] SIPController.MultiCall.remoteContactUri = " + SIPController.MultiCall.remoteContactUri); Log.d(TAG, "[setMultiCallasMainCall] SIPController.MultiCall.remoteContactIp = " + SIPController.MultiCall.remoteContactIp); Log.d(TAG, "[setMultiCallasMainCall] SIPController.MultiCall.cid = " + SIPController.MultiCall.cid); Log.d(TAG, "[setMultiCallasMainCall] SIPController.MultiCall.dnis = " + SIPController.MultiCall.dnis); SIPController.sipCall = new SIPCall(); SIPController.sipCall = SIPController.MultiCall; SIPController.MultiCall = new SIPCall(); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.bPending = " + SIPController.sipCall.bPending); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.remoteIp = " + SIPController.sipCall.remoteIp); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.remoteContactUri = " + SIPController.sipCall.remoteContactUri); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.remoteContactIp = " + SIPController.sipCall.remoteContactIp); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.cid = " + SIPController.sipCall.cid); Log.d(TAG, "[setMultiCallasMainCall] SIPController.sipCall.dnis = " + SIPController.sipCall.dnis); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setMultiCallasMainCall()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setBlockSIPInvite() { try { LOG("[setBlockSIPInvite]"); Message msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_BLOCK_INVITE_MSG); msg.replyTo = mMessenger; mService.send(msg); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setBlockSIPInvite()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setBlockSIPInvite(int nNewCallCnt, int nNewVisitorPicCnt) { try { Message msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_BLOCK_INVITE_MSG); msg.replyTo = mMessenger; Bundle mBundle = new Bundle(); mBundle.putInt("NEWCALL", nNewCallCnt); mBundle.putInt("NEWPIC", nNewVisitorPicCnt); msg.setData(mBundle); mService.send(msg); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setBlockSIPInvite(int nNewCallCnt, int nNewVisitorPicCnt)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } // Audio Tune public interface AudioTuneInterface { public void onAudioTuneReply(short[] value); } private AudioTuneInterface mAudioTuneInterface; public void setAudioTuneInterface(AudioTuneInterface ATI) { try { mAudioTuneInterface = ATI; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setAudioTuneInterface(AudioTuneInterface ATI)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void releaseAudioTuneInterface() { try { mAudioTuneInterface = null; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] releaseAudioTuneInterface()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void getEQValues() { try { if (mService != null) { try { Bundle bundle = new Bundle(); bundle.putString("cmd", "get_eq_values"); Message msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_SET_INT_VALUE); msg.setData(bundle); mService.send(msg); } catch (RemoteException e) { Log.e(TAG, "[RemoteException] getEQValues()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getEQValues()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setEQValue(String strEQ, short Value) { try { if (mService != null) { try { Bundle bundle = new Bundle(); bundle.putString("cmd", "set_eq_value"); bundle.putString("eq", strEQ); bundle.putShort("value", Value); Message msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_SET_INT_VALUE); msg.setData(bundle); mService.send(msg); } catch (RemoteException e) { Log.e(TAG, "[RemoteException] setEQValues(String strEQ, short Value)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setEQValues(String strEQ, short Value)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } //******************************************************* // 방문객 원격통화 관련 //******************************************************* public void sendVideoToMobile(byte[] data, int size, int IFrame) { try { // Log.d(TAG, "[sendVideoToMobile] data.length [" + data.length + "], size [" + size + "], IFrame [" + IFrame + "]"); if (MainActivity.mDataSender != null) { AVPacket avp = new AVPacket(); avp.avType = 0; // 0:video, 1:audio avp.data = data; avp.length = size; avp.frameType = IFrame; try { // Log.d(TAG, "[sendVideoToMobile] mDataSender.que.put()"); // Log.d(TAG, "[sendVideoToMobile] avp.length [" + avp.length + "]"); if (avp != null) MainActivity.mDataSender.blockingQueue.put(avp); } catch (InterruptedException e) { Log.e(TAG, "[InterruptedException] sendVideoToMobile(byte[] data, int size)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } else { Log.w(TAG, "[sendVideoToMobile] mDataSender is null!!"); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] sendVideoToMobile(byte[] data)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void receiveMobileAudio_moip(CALLTYPE eCallType, AVPacket avPacket) { try { // Log.d(TAG, "[receiveMobileAudio_moip] eCallType [" + eCallType + "]"); if (mService != null) { try { if (eCallType == CALLTYPE.LOBBY) { Bundle bundle = new Bundle(); bundle.putSerializable(Declare.VISITORREMOTECALL.MOBILE_AUDIO_TO_LOBBY, avPacket); Message msg = Message.obtain(null, Declare.VISITORREMOTECALL.BSSSIPStun_ICONTROLS_RECEIVE_MOBILE_AUDIO_LOBBY); msg.setData(bundle); mService.send(msg); } else if (eCallType == CALLTYPE.GUARD) { Bundle bundle = new Bundle(); bundle.putSerializable(Declare.VISITORREMOTECALL.MOBILE_AUDIO_TO_GUARD, avPacket); Message msg = Message.obtain(null, Declare.VISITORREMOTECALL.BSSSIPStun_ICONTROLS_RECEIVE_MOBILE_AUDIO_GUARD); msg.setData(bundle); mService.send(msg); } } catch (RemoteException e) { Log.e(TAG, "[RemoteException] receiveMobileAudio_moip()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] receiveMobileAudio_moip(CALLTYPE eCallType, AVPacket avPacket)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } //******************************************************* // 안심통화 관련 //******************************************************* BroadcastReceiver mFilterChangeBR = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String strAction = intent.getAction(); Log.d(TAG, "[mFilterChangeBR.onReceive] strAction [" + strAction + "]"); if (strAction.equals(Declare.BR.NOTIFY_CHANGE_LOBBY_FILTER)) { int filter = intent.getIntExtra(Declare.BR.RELIEFCALL_FILTER, 0); Log.d(TAG, "[mFilterChangeBR.onReceive] filter [" + filter + "]"); if (filter >= 0) SIPController.nFilterMode = filter; } } }; }