1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338 |
- package kr.co.icontrols.callengine.sip;
- import android.app.ActivityManager;
- import android.app.Service;
- import android.content.BroadcastReceiver;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.SharedPreferences;
- import android.media.AudioManager;
- import android.media.MediaPlayer;
- import android.media.audiofx.Equalizer;
- import android.net.ConnectivityManager;
- import android.net.NetworkInfo;
- import android.os.Build;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.IBinder;
- import android.os.Looper;
- import android.os.Message;
- import android.os.Messenger;
- import android.os.RemoteException;
- import android.util.Log;
- import com.artncore.WallPadDataMgr.WallpadDeviceSet;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.WallPadDataMgr.wallpaddbmgr;
- import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
- import com.artncore.commons.define;
- import com.util.LogUtil;
- import java.io.IOException;
- import java.net.DatagramPacket;
- import java.net.DatagramSocket;
- import java.net.InetAddress;
- import java.net.NetworkInterface;
- import java.net.SocketException;
- import java.net.SocketTimeoutException;
- import java.net.UnknownHostException;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Date;
- import java.util.List;
- import java.util.StringTokenizer;
- import java.util.TimerTask;
- import java.util.regex.Pattern;
- import bssoft.stack.sip.BSSVideo;
- import bssoft.stack.sip.CMCore;
- import bssoft.stack.sip.SIPCONTACTHeader;
- import bssoft.stack.sip.SIPCall;
- import bssoft.stack.sip.SIPHeader;
- import bssoft.stack.sip.SIPRequestLine;
- import bssoft.stack.sip.SIPStack;
- import kr.co.icontrols.callengine.engine.CallManager;
- import kr.co.icontrols.callengine.remotecall.AVPacket;
- import kr.co.icontrols.callengine.engine.CallManager.CALLEVENTTYPE;
- import kr.co.icontrols.callengine.engine.CallManager.CALLTYPE;
- import kr.co.icontrols.wallpadcall.MainActivity;
- import kr.co.icontrols.wallpadcall.declare.Common;
- import kr.co.icontrols.wallpadcall.declare.Declare;
- import kr.co.icontrols.wallpadcall.declare.Declare.CALLTRIGGER;
- import kr.co.icontrols.wallpadcall.declare.Global;
- public class SIPStun extends Service {
- static final String TAG = "SIPStun";
- boolean bLOG = true;
- private void LOG(String log) {
- if (bLOG) Log.v(TAG, log);
- }
- boolean bLOG_DEBUG = true;
- private void LOG_DEBUG(String log) {
- if (bLOG_DEBUG) Log.d(TAG, log);
- }
- boolean bLOG_INFO = true;
- private void LOG_INFO(String log) {
- if (bLOG_INFO) Log.i(TAG, log);
- }
- boolean bLOG_WARN = true;
- private void LOG_WARN(String log) {
- if (bLOG_WARN) Log.w(TAG, log);
- }
- boolean bLOG_ERROR = true;
- private void LOG_ERROR(String log) {
- if (bLOG_ERROR) Log.e(TAG, log);
- }
- public SIPSignalReceiver mSIPSignalReceiver = null;
- android.media.Ringtone oRingTone = null;
- MediaPlayer oRingbackTone = null;
- CMCore cmcore = null;
- ConnectivityManager connectivityManager = null;
- protected static String padNumber = "";
- protected static int officeNumber = 0; // 1:정문 2:후문 3:관할 4:관리사무소
- protected int latestMenu = 0;
- private static boolean isRunning = false;
- ArrayList<Messenger> mClients = new ArrayList<Messenger>();
- final Messenger mMessenger = new Messenger(new CmPiper());
- public static boolean bBlackCall = false;
- public static boolean bBlackCallSupport = true;
- public static boolean bBlackcallBackgroundMode = true;
- boolean bBLOCK_INVITE_MSG = false;
- static AVPacket avPacket = null; // 방문객 원격통화 모바일 오디오 데이터
- private boolean bLobbyCallUse = false, bGuardCallUse = false, bResiCallUse = false;
- @Override
- public IBinder onBind(Intent intent) {
- return mMessenger.getBinder();
- }
- class CmPiper extends Handler { // Handler of incoming messages from UI.
- @Override
- public void handleMessage(Message msg) {
- String value = "null";
- switch (msg.what) {
- case CMCore.BSSSIPStun_ICONTROLS_REGISTER:
- mClients.add(msg.replyTo);
- Log.i(TAG, "SIPStun CmPiper DIALER_REGISTER : " + msg.toString());
- updateBlockStatus();
- if (SIPStack.bDirectCall == true) {
- if (padNumber == null || padNumber.length() == 0) {
- boolean bValidroom = getMyroomname();
- if (bValidroom == false) {
- Log.i(TAG, "Invalid room");
- dialerPadNumber("");
- } else dialerPadNumber(padNumber);
- } else dialerPadNumber(padNumber);
- if (SIPStun.bBlackcallBackgroundMode == true) {
- if (SIPStun.bBlackCall == true && SIPController.sipCall.flag == true && SIPController.sipCall.bResponsebackgroundcall == true && SIPController.sipCall.bResponsebackgroundcallReady == false) {
- SIPController.sipCall.bResponsebackgroundcallReady = true;
- SIPController.sipCall.responsebackgroundcallTimer = new Date();
- } else {
- dialerPadType(BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED, officeNumber);
- }
- } else {
- dialerPadType(BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED, officeNumber);
- }
- }
- break;
- case CMCore.BSSSIPStun_ICONTROLS_UNREGISTER:
- mClients.remove(msg.replyTo);
- Log.i(TAG, "SIPStun CmPiper CMCore.BSSSIPStun_ICONTROLS_UNREGISTER : " + msg.toString());
- callTerminate();
- break;
- case CMCore.BSSSIPStun_ICONTROLS_DIALER_COMMAND:
- Log.i(TAG, "SIPStun CmPiper CMCore.BSSSIPStun_ICONTROLS_DIALER_COMMAND : " + msg.toString());
- break;
- case CMCore.BSSSIPStun_ICONTROLS_CONTACT_CALLNEIGHBOR:
- value = msg.getData().getString("CALLNEIGHBOR");
- Log.i(TAG, ">>>SIPStun CmPiper BSSSIPStun_ICONTROLS_CONTACT_CALLNEIGHBOR : " + value);
- break;
- case CMCore.BSSSIPStun_ICONTROLS_CONTACT_CALLGUARD:
- value = msg.getData().getString("CALLGUARD");
- Log.i(TAG, ">>>SIPStun CmPiper BSSSIPStun_ICONTROLS_CONTACT_CALLGUARD : " + value);
- break;
- case CMCore.BSSSIPStun_ICONTROLS_DIALER_ACCEPTMULTICALL:
- value = msg.getData().getString("ACCEPTMULTICALL");
- if (SIPController.pendingCall != null && SIPController.pendingCall.flag == true) {
- SIPController.pendingCall.bAsMaster = true;
- }
- Log.i(TAG, ">>>SIPStun CmPiper BSSSIPStun_ICONTROLS_DIALER_ACCEPTMULTICALL");
- break;
- case CMCore.BSSSIPStun_ICONTROLS_DIALER_REJECTMULTICALL:
- value = msg.getData().getString("REJECTMULTICALL");
- if (SIPController.pendingCall != null && SIPController.pendingCall.flag == true) {
- SIPController.pendingCall.bRejectRequest = true;
- }
- Log.i(TAG, ">>>SIPStun CmPiper BSSSIPStun_ICONTROLS_DIALER_REJECTMULTICALL");
- break;
- case CMCore.BSSSIPStun_ICONTROLS_DIALER_FORWARD:
- value = msg.getData().getString("FORWARD");
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true) {
- Log.i(TAG, ">>>SIPStun CmPiper BSSSIPStun_ICONTROLS_DIALER_FORWARD : " + value);
- SIPController.forward.contact = new String(value);
- SIPController.sipCall.bForwardRequest = true;
- }
- Log.i(TAG, ">>>SIPStun CmPiper BSSSIPStun_ICONTROLS_DIALER_FORWARD");
- Log.d(TAG, "FORWARD : " + value);
- break;
- case CMCore.BSSSIPStun_ICONTROLS_SET_INT_VALUE:
- String strEQCtrl = msg.getData().getString("cmd");
- Log.w(TAG, "strEQCtrl [" + strEQCtrl + "]");
- if (strEQCtrl.equals("get_eq_values")) {
- replyEQValue();
- } else if (strEQCtrl.equals("set_eq_value")) {
- String strEQ = msg.getData().getString("eq");
- short sValue = msg.getData().getShort("value");
- setEQValue(strEQ, sValue);
- }
- break;
- case CMCore.BSSSIPStun_ICONTROLS_BLOCK_INVITE_MSG:
- Log.e(TAG, "[CmPiper] BSSSIPStun_ICONTROLS_BLOCK_INVITE_MSG");
- // BR을 수신하여 처리하는 것으로 변경하였으나, 혹시몰라 여기도 남겨둠
- bBLOCK_INVITE_MSG = true;
- StunHandler.removeMessages(HANDLERMSG.RELEASE_BLOCK_INVITE_MSG);
- sendHandlerMsgDelayed(HANDLERMSG.RELEASE_BLOCK_INVITE_MSG, 0, 0, 3000);
- break;
- case Declare.VISITORREMOTECALL.BSSSIPStun_ICONTROLS_RECEIVE_MOBILE_AUDIO_LOBBY:
- avPacket = (AVPacket) msg.getData().getSerializable(Declare.VISITORREMOTECALL.MOBILE_AUDIO_TO_LOBBY);
- SIPSound.bufferringMobileAudio(avPacket.data, avPacket.length);
- break;
- case Declare.VISITORREMOTECALL.BSSSIPStun_ICONTROLS_RECEIVE_MOBILE_AUDIO_GUARD:
- avPacket = (AVPacket) msg.getData().getSerializable(Declare.VISITORREMOTECALL.MOBILE_AUDIO_TO_GUARD);
- SIPSound.bufferringMobileAudio(avPacket.data, avPacket.length);
- break;
- default:
- Log.i(TAG, "SIPStun CmPiper default:" + msg.toString());
- super.handleMessage(msg);
- }
- }
- }
- public final class HANDLERMSG {
- public final static int RELEASE_BLOCK_INVITE_MSG = 100;
- public final static int NEWCALL_TRY_01 = 200;
- public final static int NEWCALL_TRY_02 = 300;
- public final static int NEWCALL_TRY_03 = 400;
- public final static int NEWCALL_TRY_04 = 500;
- public final static int NEWCALL_TRY_05 = 600;
- }
- boolean bRECEIVE_REMOTE_AUDIO = false;
- public Handler StunHandler = new Handler(Looper.getMainLooper()) {
- public void handleMessage(Message msg) {
- LOG("[StunHandler] StunHandler : what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
- switch (msg.what) {
- case HANDLERMSG.RELEASE_BLOCK_INVITE_MSG:
- bBLOCK_INVITE_MSG = false;
- updateBlockStatus();
- break;
- case HANDLERMSG.NEWCALL_TRY_01:
- break;
- case HANDLERMSG.NEWCALL_TRY_02:
- break;
- case HANDLERMSG.NEWCALL_TRY_03:
- break;
- case HANDLERMSG.NEWCALL_TRY_04:
- break;
- case HANDLERMSG.NEWCALL_TRY_05:
- break;
- default:
- LOG("StunHandler : " + msg.what);
- break;
- }
- }
- };
- public void sendHandlerMsg(int what, int arg1, int arg2) {
- try {
- LOG("[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
- Message HandleMsg = StunHandler.obtainMessage();
- HandleMsg.what = what;
- HandleMsg.arg1 = arg1;
- HandleMsg.arg2 = arg2;
- StunHandler.sendMessage(HandleMsg);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void sendHandlerMsg(int what, int arg1, int arg2, Object obj) {
- try {
- LOG("[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
- Message HandleMsg = StunHandler.obtainMessage();
- HandleMsg.what = what;
- HandleMsg.arg1 = arg1;
- HandleMsg.arg2 = arg2;
- HandleMsg.obj= obj;
- StunHandler.sendMessage(HandleMsg);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay) {
- try {
- LOG("[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
- Message HandleMsg = StunHandler.obtainMessage();
- HandleMsg.what = what;
- HandleMsg.arg1 = arg1;
- HandleMsg.arg2 = arg2;
- StunHandler.sendMessageDelayed(HandleMsg, delay);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- @Override
- public void onCreate() {
- SIPStack.SIP_MESSAGE_DEBUG = true;
- Log.i(TAG, " SIPStun onCreate called newly");
- super.onCreate();
- SIPStack.setLicense("주식회사아이콘트롤스 200701243005451");
- SIPStack.bootTime = new Date();
- BSSVideo.bService = false;
- BSSVideo.bViewme = false;
- SIPStack.ventureCall = true;
- // 서비스폰 타입설정 ////////////////////////////////////////////////////////////
- BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED = BSSVideo.HNS_SERVICE_NEIGHBOR;
- //세대기:HNS_SERVICE_NEIGHBOR,
- //로비폰:HNS_SERVICE_LOBBY,
- //경비실폰:HNS_SERVICE_GUARD
- BSSVideo.HNS_SERVICE_RECEIVER_SELECTED = BSSVideo.HNS_SERVICE_NONE;
- latestMenu = BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED;
- if (BSSVideo.HNS_SERVICE_ORIGINATOR_SELECTED == BSSVideo.HNS_SERVICE_GUARD) {
- officeNumber = 1; //1:정문 2:후문 3:관할 4:관리사무소
- } else officeNumber = 0; //not assign
- if (SIPStack.bActive == false) {
- if (SIPController.BACKGROUNDTimer != null) SIPController.BACKGROUNDTimer.cancel();
- Log.i(TAG, "===================== SIPStack.init!! =====================");
- SIPController.init();
- SIPStack.bNetworkActive = false;
- }
- SIPStack.bBackgroundRunning = false;
- SIPStack.bGeneralPhoneDetected = false;
- getStackKey();
- WallpadDeviceSet deviceSet = new WallpadDeviceSet(this);
- bLobbyCallUse = deviceSet.Get_LobbyCallUse();
- bGuardCallUse = deviceSet.Get_GuardCallUse();
- bResiCallUse = deviceSet.Get_ResidenceCallUse();
- deviceSet.closeDB();
- LOG("[onCreate] bLobbyCallUse [" + bLobbyCallUse + "], bGuardCallUse [" + bGuardCallUse + "], bResiCallUse [" + bResiCallUse + "]");
- try {
- String host = SIPController.getSHVE140SLocalIpAddress();
- Log.i(TAG, "Host : " + host);
- InetAddress thisComputer = null;
- if (host != null && host.length() > 0) thisComputer = InetAddress.getByName(host);
- else thisComputer = InetAddress.getByName("127.0.0.1");
- byte[] address = thisComputer.getAddress();
- if (address.length == 4) {
- int unsignedByte1 = address[0] < 0 ? address[0] + 256 : address[0];
- int unsignedByte2 = address[1] < 0 ? address[1] + 256 : address[1];
- int unsignedByte3 = address[2] < 0 ? address[2] + 256 : address[2];
- int unsignedByte4 = address[3] < 0 ? address[3] + 256 : address[3];
- SIPStack.strLocalip = unsignedByte1 + "." + unsignedByte2 + "." + unsignedByte3 + "." + unsignedByte4;
- } else if (SIPStack.SIP_MESSAGE_DEBUG == true) {
- Log.i(TAG, "no ipv4.");
- }
- if (SIPStack.SIP_MESSAGE_DEBUG == true) {
- Log.i(TAG, SIPStack.strLocalip + " founded.");
- }
- if (SIPStack.stackkey.strServerDomain == null) {
- SIPStack.stackkey.strServerDomain = "";
- }
- if (SIPStack.bDirectCall == true) {
- boolean bValidroom = getMyroomname();
- if (bValidroom == false) {
- Log.i("SIPStun", "Invalid room");
- dialerPadNumber("");
- } else {
- dialerPadNumber(padNumber);
- }
- }
- if (SIPStack.bActive == false) SIPController.initSound(SIPController.bMobileCall);
- if (SIPStack.bActive == false) {
- mSIPSignalReceiver = new SIPSignalReceiver(thisComputer, SIPStack.localPort);
- if (mSIPSignalReceiver != null) {
- mSIPSignalReceiver.start();
- SIPStack.localPort = SIPStack.SIP_SIGNAL_PORT;
- SIPStack.ipdns.bSipAddressResolved = false;
- cmcore = new CMCore();
- connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
- initializeCm(address, SIPStack.strLocalip.getBytes(), SIPStack.localPort, SIPStack.stackkey.strServerHost, SIPStack.stackkey.serverPort, SIPStack.stackkey.strServerDomain, SIPStack.stackkey.strId.getBytes(),
- SIPStack.stackkey.strCid.getBytes(), SIPStack.stackkey.strAuthid.getBytes(), SIPStack.stackkey.strAuthpassword.getBytes());
- SIPController.audioRTPManager = new RTPManager(this, SIPStack.SIP_MEDIATYPE_AUDIO);
- SIPSound.amAudioManager = (AudioManager) this.getSystemService(AUDIO_SERVICE);
- SIPSound.initRoute();
- if (SIPController.sipCall == null) {
- Log.i(TAG, "sipCall is null");
- }
- SIPStack.bActive = true;
- }
- }
- registerWallPadCallLiveBRReceiver();
- } catch (UnknownHostException uhe) {
- Log.e(TAG, "[UnknownHostException] onCreate()");
- //uhe.printStackTrace();
- LogUtil.errorLogInfo("", TAG, uhe);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] onCreate()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- Log.i(TAG, "===================== Service Started!! =====================");
- CMCore.bPausing = false;
- isRunning = true;
- }
- public boolean getMyroomname() {
- try {
- padNumber = "";
- boolean bJeffreyWay = true;
- // Log.i(TAG, "[getMyroomname] bJeffreyWay : " + bJeffreyWay);
- if (bJeffreyWay) {
- SIPStack.strLocalip = getDeviceIPAddress();
- Log.i(TAG, "[getMyroomname] SIPStack.strLocalip [" + SIPStack.strLocalip + "]");
- int nMaxTryCnt = 10;
- int nCnt = 0;
- while ((!validateIPAddress(SIPStack.strLocalip)) && (nCnt < nMaxTryCnt)) {
- Thread.sleep(1000);
- SIPStack.strLocalip = getDeviceIPAddress();
- nCnt++;
- }
- Log.i(TAG, "[getMyroomname] After while loof!! SIPStack.strLocalip [" + SIPStack.strLocalip + "], nCnt [" + nCnt + "]");
- // System.out.print(unsignedByte + ".");
- String[] aDeviceName = makeDeviceName(SIPStack.strLocalip);
- if (aDeviceName[0] == DeviceString.strType_Lobby) {
- // 로비폰
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "번 로비";
- } else if (aDeviceName[0] == DeviceString.strType_Guard) {
- // 경비실기
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "번 경비실";
- } else if (aDeviceName[0] == DeviceString.strType_RentResi) {
- // 분리 세대 단말기
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "-1호";
- } else {
- // 세대단말기
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "호";
- }
- SIPStack.stackkey.strId = makeSIPID(SIPStack.strLocalip);
- SIPStack.stackkey.strAuthid = makeSIPID(SIPStack.strLocalip);
- return true;
- } else {
- String host = SIPController.getSHVE140SLocalIpAddress();
- InetAddress thisComputer = null;
- if (host != null && host.length() > 0) thisComputer = InetAddress.getByName(host);
- else thisComputer = InetAddress.getByName("127.0.0.1");
- byte[] address = thisComputer.getAddress();
- if (address.length == 4) {
- int unsignedByte1 = address[0] < 0 ? address[0] + 256 : address[0];
- int unsignedByte2 = address[1] < 0 ? address[1] + 256 : address[1];
- int unsignedByte3 = address[2] < 0 ? address[2] + 256 : address[2];
- int unsignedByte4 = address[3] < 0 ? address[3] + 256 : address[3];
- SIPStack.strLocalip = unsignedByte1 + "." + unsignedByte2 + "." + unsignedByte3 + "." + unsignedByte4;
- Log.i(TAG, "[getMyroomname] SIPStack.strLocalip : " + SIPStack.strLocalip);
- // System.out.print(unsignedByte + ".");
- String[] aDeviceName = makeDeviceName(SIPStack.strLocalip);
- if (aDeviceName[0] == DeviceString.strType_Lobby) {
- // 로비폰
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "번 로비";
- } else if (aDeviceName[0] == DeviceString.strType_Guard) {
- // 경비실기
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "번 경비실";
- } else {
- // 세대단말기
- padNumber = aDeviceName[1] + "동 " + aDeviceName[2] + "호";
- }
- SIPStack.stackkey.strId = makeSIPID(SIPStack.strLocalip);
- SIPStack.stackkey.strAuthid = makeSIPID(SIPStack.strLocalip);
- return true;
- } else return false;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getMyroomname()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- private Pattern mPattern = Pattern.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$");
- private boolean validateIPAddress(String IPAddress) {
- Log.i(TAG, "[validateIPAddress] IPAddress [" + IPAddress + "]");
- if (IPAddress == null) return false;
- return mPattern.matcher(IPAddress).matches();
- }
- public String getDeviceIPAddress() {
- try {
- LOG("[getDeviceIPAddress] START!");
- if (Integer.parseInt(Build.VERSION.RELEASE.substring(0, 1)) >= 7) {
- // // 메이드인랩 김수진 선임 (A0S 7.0)
- List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
- for (NetworkInterface intf : interfaces) {
- List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
- for (InetAddress addr : addrs) {
- if (!addr.isLoopbackAddress()) {
- String sAddr = addr.getHostAddress();
- boolean isIPv4 = sAddr.indexOf(':') < 0;
- if (isIPv4)
- return sAddr;
- }
- }
- }
- } else {
- // 기존코드 (AOS 6.0)
- String strResult = "";
- String strNetInfo ="";
- if(NetworkInterface.getByName("eth0")!=null)
- strNetInfo = NetworkInterface.getByName("eth0").toString();
- LOG_DEBUG("strNetInfo " + strNetInfo);
- LOG("[getDeviceIPAddress] strNetInfo : " + strNetInfo + "]");
- strNetInfo.trim();
- String[] Parse_01 = strNetInfo.split("\\]");
- String[] Parse_02 = Parse_01[Parse_01.length - 1].split("\\/");
- strResult = Parse_02[1];
- LOG("[getDeviceIPAddress] DONE! [IP Address : " + strResult + "]");
- return strResult;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getDeviceIPAddress()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return "";
- }
- private void getStackKey() {
- SharedPreferences prefs = getSharedPreferences("PrefName", MODE_PRIVATE);
- String textId = prefs.getString(SIPStack.stackkey.KEY_BSS_ID, "");
- String textAuthid = prefs.getString(SIPStack.stackkey.KEY_BSS_AUTHID, "");
- String textPassword = prefs.getString(SIPStack.stackkey.KEY_BSS_PASSWORD, "");
- String textCid = prefs.getString(SIPStack.stackkey.KEY_BSS_CID, "");
- String textServerip = prefs.getString(SIPStack.stackkey.KEY_BSS_SERVERIP, "");
- String textDomain = prefs.getString(SIPStack.stackkey.KEY_BSS_SERVERDOMAIN, "");
- String textPort = prefs.getString(SIPStack.stackkey.KEY_BSS_SERVERPORT, "");
- String textImsi = prefs.getString(SIPStack.stackkey.KEY_BSS_IMSI, "");
- String textGeneralPhone = prefs.getString(SIPStack.stackkey.KEY_BSS_GENERALPHONE, "");
- String textWebid = prefs.getString(SIPStack.stackkey.KEY_BSS_WEBID, "");
- String textWebpwd = prefs.getString(SIPStack.stackkey.KEY_BSS_WEBPWD, "");
- String textLatestdial = prefs.getString(SIPStack.stackkey.KEY_BSS_LATESTDIAL, "");
- String textForward = prefs.getString(SIPStack.stackkey.KEY_BSS_FORWARD, "");
- SIPStack.stackkey.strImsi = textImsi.trim();
- SIPStack.stackkey.strGeneralPhone = textGeneralPhone.trim();
- SIPStack.stackkey.strWebId = textWebid.trim();
- SIPStack.stackkey.strWebPwd = textWebpwd.trim();
- SIPStack.userDial.latestDial = textLatestdial.trim();
- Log.i(TAG, "[getStackKey] >>>>>WEB ID : " + SIPStack.stackkey.strWebId + " WEB PWD : " + SIPStack.stackkey.strWebPwd);
- SIPStack.stackkey.strId = textId.trim();
- SIPStack.stackkey.strCid = textCid.trim();
- SIPStack.stackkey.strAuthid = textAuthid.trim();
- SIPStack.stackkey.strAuthpassword = textPassword.trim();
- SIPStack.stackkey.strServerHost = textServerip.trim();
- SIPStack.stackkey.strServerDomain = textDomain.trim();
- if (textPort.trim().length() > 0)
- SIPStack.stackkey.serverPort = Integer.parseInt(textPort.trim());
- else SIPStack.stackkey.serverPort = 5060;
- // 192.168.10.21
- SIPStack.stackkey.strId = "07077392005";
- SIPStack.stackkey.strAuthid = "07077392005";
- SIPStack.stackkey.strAuthpassword = "002005";
- SIPStack.stackkey.strServerHost = "192.168.10.2";
- SIPStack.stackkey.serverPort = 5060;
- SIPController.forward.setValue(textForward.trim());
- if (SIPStack.SIP_MESSAGE_DEBUG == true) {
- Log.i(TAG, "ID : " + SIPStack.stackkey.strId);
- Log.i(TAG, "CID : " + SIPStack.stackkey.strCid);
- Log.i(TAG, "AUTHID : " + SIPStack.stackkey.strAuthid);
- Log.i(TAG, "AUTHPASSWORD : " + SIPStack.stackkey.strAuthpassword);
- Log.i(TAG, "SERVERHOST : " + SIPStack.stackkey.strServerHost);
- Log.i(TAG, "SERVERDOMAIN : " + SIPStack.stackkey.strServerDomain);
- Log.i(TAG, "SERVERPORT : " + SIPStack.stackkey.serverPort);
- Log.i(TAG, "FORWARD set : " + SIPController.forward.bForward + " type : " + SIPController.forward.iForwardTarget + " number : " + SIPController.forward.number);
- }
- return;
- }
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- LOG_WARN("[onStartCommand] flags [" + flags + "], startId [" + startId + "]");
- return START_STICKY; // run until explicitly stopped.
- }
- public static boolean isRunning() {
- return isRunning;
- }
- @Override
- public void onDestroy() {
- super.onDestroy();
- unregisterWallPadCallLiveBRReceiver();
- if (SIPStack.bUseCtrlTimer == true) {
- if (cmcore.SIGNALCTRLTimer != null) {
- cmcore.SIGNALCTRLTimer.cancel();
- }
- cmcore.SIGNALCTRLTimer = null;
- } else {
- if (cmcore.SIGNALCTRLThread != null && cmcore.SIGNALCTRLThread.isAlive() == true) {
- cmcore.SIGNALCTRLThread.interrupt();
- cmcore.SIGNALCTRLRunning = false;
- }
- }
- mSIPSignalReceiver.interrupt();
- SIPStack.bActive = false;
- Log.i(TAG, "===================== Service Stopped!! =====================");
- isRunning = false;
- }
- // SignalReceiver
- class SIPSignalReceiver extends Thread {
- InetAddress thisComputer;
- protected DatagramSocket theSocket;
- protected DatagramPacket dp;
- protected boolean bFlag = false;
- boolean bReady = false;
- byte[] buffer;
- public SIPSignalReceiver(InetAddress thisComputer, int port) {
- bReady = false;
- try {
- if (port > 0 && port <= 65556) {
- SIPStack.SIP_SIGNAL_PORT = port;
- for (int i = 0; i < SIPStack.MAX_SIGNAL_PORTS; i++) {
- SIPStack.SIP_SIGNAL_PORT = port + i;
- Log.i(TAG, "try SIP Signal socket create on " + SIPStack.SIP_SIGNAL_PORT);
- try {
- theSocket = new DatagramSocket(SIPStack.SIP_SIGNAL_PORT);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] SipSignalReceiver -> SipSignalReceiver (InetAddress thisComputer, int port)");
- }
- if (theSocket != null) {
- bFlag = true;
- break;
- }
- }
- if (theSocket == null) {
- Log.i(TAG, "[SipSignalReceiver] theSocket is null!!!");
- bFlag = false;
- return;
- }
- theSocket.setReuseAddress(true);
- this.thisComputer = thisComputer;
- }
- buffer = new byte[SIPStack.SIP_MAXMESSAGE_SIZE];
- } catch (SocketException se) {
- Log.e(TAG, "[SocketException] ERROR SipSignalReceiver Construct");
- //System.err.println(se);
- LogUtil.errorLogInfo("", TAG, se);
- SIPStack.exceptionCountAtCurrentCall++;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] SipSignalReceiver construct exception occurred.");
- }
- }
- public void run() {
- Log.i(TAG, "[SipSignalReceiver] run() >>>> Signal Thread receive ready.");
- try {
- dp = new DatagramPacket(buffer, buffer.length);
- } catch (NullPointerException ne) {
- //System.err.println(ne);
- LogUtil.errorLogInfo("", TAG, ne);
- SIPStack.exceptionCountAtCurrentCall++;
- return;
- }
- bReady = true;
- this.setPriority(1);
- while (bReady && theSocket != null && dp != null) {
- try {
- Log.i(TAG, "[SipSignalReceiver] >>>> SOCKET SoTimeout : " + theSocket.getSoTimeout());
- dp.setLength(SIPStack.SIP_MAXMESSAGE_SIZE);
- dp.setData(buffer);
- theSocket.receive(dp);
- if (CMCore.bPausing == true) {
- Date currentTime = new Date();
- int milli = (int) (currentTime.getTime() - CMCore.pauseTime.getTime());
- if (milli < CMCore.BSSSIPStun_ICONTROLS_PAUSING_DURATION) {
- Log.e(TAG, "CMCore.bPausing [" + CMCore.bPausing + "], pause duration [" + milli + "]. signal is ignored!!!");
- continue;
- }
- }
- if (0 != BSSSipParser(dp)) {
- if (SIPStack.SIP_MESSAGE_DEBUG == true)
- Log.i(TAG, "SIP MESSAGE PARSER ERROR");
- Thread.yield();
- }
- SIPStack.bIntraffic = true;
- } catch (SocketTimeoutException se) {
- Log.e(TAG, "[SocketTimeoutException] Socket time out...");
- //se.printStackTrace();
- LogUtil.errorLogInfo("", TAG, se);
- } catch (IOException e) {
- Log.e(TAG, "[IOException] IOException");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- //System.err.println(e);
- SIPStack.exceptionCountAtCurrentCall++;
- } catch (Exception e1) {
- Log.e(TAG, "[Exception] +++ SipSignalReceiver receive thread exception occurred.");
- //e1.printStackTrace();
- //System.err.println(e1);
- LogUtil.errorLogInfo("", TAG, e1);
- }
- }
- Log.e(TAG, "Signal Thread terminated");
- }
- public int BSSSipParser(DatagramPacket dp) {
- if (dp == null) return -1;
- String remoteIp = null;
- byte[] address = dp.getAddress().getAddress();
- if (address == null || address.length <= 0) return -1;
- if (address.length == 4) {
- int unsignedByte1 = address[0] < 0 ? address[0] + 256 : address[0];
- int unsignedByte2 = address[1] < 0 ? address[1] + 256 : address[1];
- int unsignedByte3 = address[2] < 0 ? address[2] + 256 : address[2];
- int unsignedByte4 = address[3] < 0 ? address[3] + 256 : address[3];
- remoteIp = unsignedByte1 + "." + unsignedByte2 + "." + unsignedByte3 + "." + unsignedByte4;
- } else return -1;
- int remotePort = dp.getPort();
- if (remotePort <= 0) return -1;
- int iMessageType = 0;
- int iMethodType = 0;
- String s = new String(dp.getData(), 0, 0, dp.getLength());
- if (s == null || s.length() <= 0) return -1;
- // SIP PARSE
- StringTokenizer st = new StringTokenizer(s, "\n", true);
- // int headerCount = 0;
- if (st.hasMoreTokens()) {
- String str = st.nextToken();
- if (str.length() > 0) {
- iMethodType = SIPStack.getRequestlineMethod(str);
- // Log.d(TAG, "[BSSSipParser] iMethodType [" + iMethodType + "]");
- if (iMethodType == SIPStack.SIP_METHODTYPE_NONE) {
- return 0;
- } else if (iMethodType == SIPStack.SIP_METHODTYPE_RESPONSE) {
- iMethodType = SIPStack.getCSeqMethod(s);
- // Log.i(TAG, ">>>>>>>>>> RESPONSE iMethodType : " + iMethodType);
- if (iMethodType == SIPStack.SIP_METHODTYPE_NONE) return 0;
- iMessageType = SIPStack.SIP_MSGTYPE_RESPONSE;
- if (iMethodType == SIPStack.SIP_METHODTYPE_REGISTER)
- SIPParser(s, iMessageType, iMethodType);
- else if (iMethodType != SIPStack.SIP_METHODTYPE_NONE)
- SIPParser(s, iMessageType, iMethodType, remoteIp, remotePort);
- return 0;
- } else {
- iMessageType = SIPStack.SIP_MSGTYPE_REQUEST;
- SIPParser(s, iMessageType, iMethodType, remoteIp, remotePort);
- }
- }
- }
- return 0; // normal
- } // BSSSipParser()
- public int BSSSipSendUdpPacket(String sIp, int iPort, byte[] data, int dataSize) {
- int sent = 0;
- if (sIp == null || sIp.length() == 0) return 0;
- if (iPort <= 0) return 0;
- if (dataSize <= 0) return 0;
- try {
- InetAddress ia = InetAddress.getByName(sIp);
- if (ia != null) {
- DatagramPacket dp = new DatagramPacket(data, dataSize, ia, iPort);
- if (dp != null && theSocket!=null ) theSocket.send(dp);
- sent = dataSize;
- SIPStack.bOuttraffic = true;
- if (bPrintSIPMsgIO) printSIPMessage(MESSAGE.SEND, new String(data));
- }
- } catch (UnknownHostException uhe) {
- Log.e(TAG, "[UnknownHostException] BSSSipSendUdpPacket(String sIp, int iPort, byte[] data, int dataSize)");
- //System.err.println(uhe);
- LogUtil.errorLogInfo("", TAG, uhe);
- SIPStack.exceptionCountAtCurrentCall++;
- } catch (java.net.SocketException she) {
- Log.e(TAG, "[SocketException] Cause: " + she.getCause());
- Log.e(TAG, "[SocketException] Reason: " + she.getMessage());
- if (she.getMessage().indexOf("ENETUNREACH") >= 0 || she.getMessage().indexOf("Network is unreachable") >= 0) {
- SIPStack.networkStatus = SIPStack.SIP_NETIF_UNREACHABLE;
- Log.e(TAG, "[BSSSipSendUdpPacket] networkStatus was set to SIP_NETIF_UNREACHABLE");
- }
- //System.err.println(she);
- LogUtil.errorLogInfo("", TAG, she);
- try {
- Log.e(TAG, "!!! Socket is invalid, renew.");
- theSocket = new DatagramSocket(SIPStack.SIP_SIGNAL_PORT);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] !!! Socket is invalid, renew.");
- }
- SIPStack.exceptionCountAtCurrentCall++;
- } catch (IOException ie) {
- Log.e(TAG, "[IOException] BSSSipSendUdpPacket(String sIp, int iPort, byte[] data, int dataSize)");
- //System.err.println(ie);
- LogUtil.errorLogInfo("", TAG, ie);
- SIPStack.exceptionCountAtCurrentCall++;
- } catch (Exception e) {
- // when call OnNetworkException error processing
- Log.e(TAG, "[Exception] BSSSipSendUdpPacket(String sIp, int iPort, byte[] data, int dataSize)");
- Log.e(TAG, "!!!BSSSipSendUdpPacket Exception occurred. <BSS> : " + sent);
- //System.err.println(e);
- LogUtil.errorLogInfo("", TAG, e);
- return -1;
- }
- return sent;
- }
- }
- class SIGNALCTRLThread extends Thread {
- @Override
- public void run() {
- Log.d(TAG, "[SIGNALCTRLThread.run]");
- while (cmcore.SIGNALCTRLRunning == true) {
- try {
- Thread.sleep(SIPStack.SIPCTRL_INTERVAL);
- if (cmcore.SIGNALCTRLThread == null) {
- break;
- }
- if (cmcore.SIGNALCTRLThread.isInterrupted()) {
- break;
- }
- if (SIPStack.networkStatus != SIPStack.SIP_NETIF_AVAILABLE) {
- if (SIPStack.networkStatus == SIPStack.SIP_NETIF_UNREACHABLE) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("NETWORK UNREACHABLE.", true);
- } else if (SIPStack.networkStatus == SIPStack.SIP_NETIF_UNAVAILABLE) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("NETWORK not ready.", true);
- }
- if (SIPStack.networkStatus == SIPStack.SIP_NETIF_UNAVAILABLE || SIPStack.networkStatus == SIPStack.SIP_NETIF_UNREACHABLE) {
- if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) {
- NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
- switch (activeNetwork.getType()) {
- case ConnectivityManager.TYPE_WIMAX: // 4g 망 체크
- if (SIPStack.isInternetWiMax == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = true;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_WIFI: // wifi망 체크
- if (SIPStack.isInternetWiFi == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = false;
- SIPStack.isInternetWiFi = true;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_MOBILE: // 3g 망 체크
- if (SIPStack.isInternetMobile == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = false; //false;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = true;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- }
- }
- cmcore.netcheckIntervalTimer = new Date();
- try {
- String host = SIPController.getSHVE140SLocalIpAddress();
- cmcore.action_net_1(host);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] String host = SIPController.getSHVE140SLocalIpAddress();");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- continue;
- }
- if (SIPStack.bDirectCall == false && cmcore.regState != SIPStack.SIP_REGSTATE_REGISTERED) {
- if (true == cmcore.action_net_0()) sendRegister();
- }
- // REGIST CONTROL
- if (cmcore.ctrlIndex == 0) {
- if (SIPStack.bShutdownApplication) {
- if (SIPStack.bDirectCall == false) {
- sendUNRegister();
- }
- SIPStack.bShutdownApplication = false;
- // SERVICE MESSAGE NEEDED
- dialerShutdownApplication();
- }
- if (SIPStack.bDirectCall == false) {
- SIPCTRLRegister();
- }
- } else if (cmcore.ctrlIndex == 1) {
- // CALL CONTROL
- if (SIPStack.bVibrating == true) {
- if (!(SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED)) {
- // SERVICE MESSAGE NEEDED
- dialerVibrator(false);
- }
- }
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bResponsebackgroundcall == true &&
- SIPController.sipCall.bResponsebackgroundcallReady == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- if (SIPStun.bBlackcallBackgroundMode == true) {
- if (SIPController.sipCall.bResponsebackgroundcallReady == true) {
- Date currentTime = new Date();
- long durationMilliSeconds = Math.abs(currentTime.getTime() - SIPController.sipCall.responsebackgroundcallTimer.getTime());
- if (durationMilliSeconds > 1000) {
- Log.i(TAG, "MILL TIME : " + durationMilliSeconds);
- SIPController.sipCall.responsebackgroundcallTimer = new Date();
- SIPController.sipCall.bResponsebackgroundcall = false;
- SIPController.sipCall.bResponsebackgroundcallReady = false;
- // SERVICE MESSAGE NEEDED
- dialerNotifyIncomingCall(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- if (SIPStack.bDirectCall == true) {
- dialerVideoSet(true);
- }
- }
- }
- } else {
- Date currentTime = new Date();
- long durationSeconds = Math.abs((currentTime.getTime() - SIPController.sipCall.responsebackgroundcallTimer.getTime()) / 1000);
- if (durationSeconds > 0) {
- SIPController.sipCall.bResponsebackgroundcall = false;
- // SERVICE MESSAGE NEEDED
- dialerNotifyIncomingCall(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- }
- }
- }
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bCancelRequest) {
- callTerminate();
- SIPController.sipCall.bCancelRequest = false;
- } else if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bRejectRequest) {
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.RTPEnd(1);
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == true) {
- dialerVideoSet(false);
- }
- }
- }
- }
- SIPController.sipCall.bRejectRequest = false;
- SIPController.sipCall.bCancelRequest = true;
- } else if (SIPController.sipCall != null && SIPController.sipCall.bNewcallRequest) {
- if (SIPController.sipCall.bDirectcall == true) {
- SIPController.sipCall.bNewcallRequest = false;
- // Log.d(TAG, "[SIGNALCTRLThread] SIPController.bMobileCall [" + SIPController.bMobileCall + "]");
- directcallActivate(SIPController.sipCall.number, SIPController.bMobileCall);
- } else if (cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERED) {
- SIPController.sipCall.bNewcallRequest = false;
- callActivate(SIPController.sipCall.number);
- }
- } else if (SIPController.sipCall != null && SIPController.sipCall.bUpdateRequest) {
- if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) {
- sendHold();
- }
- SIPController.sipCall.bUpdateRequest = false;
- } else if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.forward.bForward == true && SIPController.sipCall.bForwardRequest == true) {
- SIPController.sipCall.bForwardRequest = false;
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.RTPEnd(2);
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == true) {
- dialerVideoSet(false);
- }
- }
- }
- }
- redirectTerminate(SIPController.forward.contact);
- cancelCallForwardToStun();
- } else {
- SIPCTRLCall();
- }
- }
- if (cmcore.ctrlIndex == 0) cmcore.ctrlIndex = 1;
- else cmcore.ctrlIndex = 0;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] SIGNALCTRLThread.while(cmcore.SIGNALCTRLRunning)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- cmcore.SIGNALCTRLRunning = false;
- cmcore.SIGNALCTRLThread = null;
- } // run()
- }
- class CTRLTimerTask extends TimerTask {
- public void run() {
- if (cmcore.SIGNALCTRLTimer == null) {
- Log.e(TAG, "cmcore.SIGNALCTRLTimer is null!! ");
- return;
- }
- Log.w(TAG, "[CTRLTimerTask]");
- if (SIPStack.networkStatus != SIPStack.SIP_NETIF_AVAILABLE) {
- if (SIPStack.networkStatus == SIPStack.SIP_NETIF_UNREACHABLE) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("NETWORK UNREACHABLE.", true);
- } else if (SIPStack.networkStatus == SIPStack.SIP_NETIF_UNAVAILABLE) {
- //SERVICE MESSAGE NEEDED
- updateDialerStatus("NETWORK not ready.", true);
- }
- if (SIPStack.networkStatus == SIPStack.SIP_NETIF_UNAVAILABLE || SIPStack.networkStatus == SIPStack.SIP_NETIF_UNREACHABLE) {
- if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) {
- NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
- switch (activeNetwork.getType()) {
- case ConnectivityManager.TYPE_WIMAX: // 4g 망 체크
- if (SIPStack.isInternetWiMax == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = true;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_WIFI: // wifi망 체크
- if (SIPStack.isInternetWiFi == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = false;
- SIPStack.isInternetWiFi = true;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_MOBILE: // 3g 망 체크
- if (SIPStack.isInternetMobile == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = false; // false;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = true;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- }
- }
- cmcore.netcheckIntervalTimer = new Date();
- try {
- String host = SIPController.getSHVE140SLocalIpAddress();
- cmcore.action_net_1(host);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] String host = SIPController.getSHVE140SLocalIpAddress()");
- }
- }
- return;
- }
- if (SIPStack.bDirectCall == false && cmcore.regState != SIPStack.SIP_REGSTATE_REGISTERED) {
- if (true == cmcore.action_net_0()) sendRegister();
- }
- // REGIST CONTROL
- if (cmcore.ctrlIndex == 0) {
- if (SIPStack.bShutdownApplication) {
- if (SIPStack.bDirectCall == false) sendUNRegister();
- SIPStack.bShutdownApplication = false;
- // SERVICE MESSAGE NEEDED
- dialerShutdownApplication();
- }
- if (SIPStack.bDirectCall == false) SIPCTRLRegister();
- } else if (cmcore.ctrlIndex == 1) {
- // CALL CONTROL
- if (SIPStack.bVibrating == true) {
- if (!(SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED)) {
- // SERVICE MESSAGE NEEDED
- dialerVibrator(false);
- }
- }
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bResponsebackgroundcall == true &&
- SIPController.sipCall.bResponsebackgroundcallReady == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- if (SIPStun.bBlackcallBackgroundMode == true) {
- if (SIPController.sipCall.bResponsebackgroundcallReady == true) {
- Date currentTime = new Date();
- int durationMilliSeconds = (int) (currentTime.getTime() - SIPController.sipCall.responsebackgroundcallTimer.getTime());
- if (durationMilliSeconds > 1000) {
- Log.i(TAG, "MILL TIME : " + durationMilliSeconds);
- SIPController.sipCall.responsebackgroundcallTimer = new Date();
- SIPController.sipCall.bResponsebackgroundcall = false;
- SIPController.sipCall.bResponsebackgroundcallReady = false;
- // SERVICE MESSAGE NEEDED
- dialerNotifyIncomingCall(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- if (SIPStack.bDirectCall == true) {
- dialerVideoSet(true);
- }
- }
- }
- } else {
- Date currentTime = new Date();
- int durationSeconds = (int) (currentTime.getTime() - SIPController.sipCall.responsebackgroundcallTimer.getTime()) / 1000;
- if (durationSeconds > 0) {
- SIPController.sipCall.bResponsebackgroundcall = false;
- // SERVICE MESSAGE NEEDED
- dialerNotifyIncomingCall(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- }
- }
- }
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bCancelRequest) {
- callTerminate();
- SIPController.sipCall.bCancelRequest = false;
- } else if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.bRejectRequest) {
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.RTPEnd(3);
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == true) dialerVideoSet(false);
- }
- }
- }
- SIPController.sipCall.bRejectRequest = false;
- SIPController.sipCall.bCancelRequest = true;
- } else if (SIPController.sipCall != null && SIPController.sipCall.bNewcallRequest) {
- if (SIPController.sipCall.bDirectcall == true) {
- SIPController.sipCall.bNewcallRequest = false;
- // Log.d(TAG, "[CTRLTimerTask] SIPController.bMobileCall [" + SIPController.bMobileCall + "]");
- directcallActivate(SIPController.sipCall.number, SIPController.bMobileCall);
- } else if (cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERED) {
- SIPController.sipCall.bNewcallRequest = false;
- callActivate(SIPController.sipCall.number);
- }
- } else if (SIPController.sipCall != null && SIPController.sipCall.bUpdateRequest) {
- if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) {
- sendHold();
- }
- SIPController.sipCall.bUpdateRequest = false;
- } else if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.forward.bForward == true && SIPController.sipCall.bForwardRequest == true) {
- SIPController.sipCall.bForwardRequest = false;
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.RTPEnd(4);
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == true) dialerVideoSet(false);
- }
- }
- }
- redirectTerminate(SIPController.forward.contact);
- SIPController.forward.contact = "";
- } else {
- SIPCTRLCall();
- }
- }
- if (cmcore.ctrlIndex == 0) cmcore.ctrlIndex = 1;
- else cmcore.ctrlIndex = 0;
- }
- }
- public void initializeCm(byte[] byteAddress, byte[] byteLocalip, int localport, byte[] byteServerip, int serverport, byte[] byteServerdomain, byte[] byteId, byte[] byteCid, byte[] byteAuthid, byte[] byteAuthpassword) {
- SIPController.sipCall = new SIPCall();
- // Multicall part
- SIPController.pendingCall = new SIPCall(true);
- if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) {
- NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
- switch (activeNetwork.getType()) {
- case ConnectivityManager.TYPE_WIMAX: // 4g 망 체크
- SIPStack.isInternetWiMax = true;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_WIFI: // wifi망 체크
- SIPStack.isInternetWiMax = false;
- SIPStack.isInternetWiFi = true;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_MOBILE: // 3g 망 체크
- SIPStack.isInternetWiMax = false;//false;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = true;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- }
- }
- cmcore.action_0(byteLocalip, localport, byteServerip, serverport, byteServerdomain, byteId, byteCid, byteAuthid, byteAuthpassword);
- if (SIPStack.bUseCtrlTimer == true) {
- cmcore.SIGNALCTRLTimer.scheduleAtFixedRate(new CTRLTimerTask(), 0, SIPStack.SIPCTRL_INTERVAL);
- } else {
- cmcore.SIGNALCTRLThread = new SIGNALCTRLThread();
- if (cmcore.SIGNALCTRLThread != null) {
- cmcore.SIGNALCTRLRunning = true;
- cmcore.SIGNALCTRLThread.start();
- }
- }
- if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) {
- NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
- switch (activeNetwork.getType()) {
- case ConnectivityManager.TYPE_WIMAX: // 4g 망 체크
- SIPStack.isInternetWiMax = true;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_WIFI: // wifi망 체크
- SIPStack.isInternetWiMax = false;
- SIPStack.isInternetWiFi = true;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_MOBILE: // 3g 망 체크
- SIPStack.isInternetWiMax = false;//false;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = true;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- }
- }
- cmcore.netcheckIntervalTimer = new Date();
- try {
- String host = SIPController.getSHVE140SLocalIpAddress();
- if (true == cmcore.action_net_2(host)) {
- sendRegister();
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] String host = SIPController.getSHVE140SLocalIpAddress()");
- }
- } // SipSignalReceiver()
- public void initializeCm(byte[] byteAddress, byte[] byteLocalip, int localport, String strServerHost, int serverport, String strServerDomain, byte[] byteId, byte[] byteCid, byte[] byteAuthid, byte[] byteAuthpassword) {
- SIPController.sipCall = new SIPCall();
- // Multicall part
- SIPController.pendingCall = new SIPCall(true);
- cmcore.action_1(byteAddress, byteLocalip, localport, strServerHost, serverport, strServerDomain, byteId, byteCid, byteAuthid, byteAuthpassword);
- if (SIPStack.bUseCtrlTimer == true) {
- cmcore.SIGNALCTRLTimer.scheduleAtFixedRate(new CTRLTimerTask(), 0, SIPStack.SIPCTRL_INTERVAL);
- } else {
- cmcore.SIGNALCTRLThread = new SIGNALCTRLThread();
- if (cmcore.SIGNALCTRLThread != null) {
- cmcore.SIGNALCTRLRunning = true;
- cmcore.SIGNALCTRLThread.start();
- }
- }
- }
- public void resumeCm(byte[] byteAddress, byte[] byteLocalip, int localport, String strServerHost, int serverport, String strServerDomain, byte[] byteId, byte[] byteCid, byte[] byteAuthid, byte[] byteAuthpassword) {
- SIPStack.ipdns.bSipAddressResolved = true;
- SIPStack.ipdns.sipTry = 0;
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == false) dialerRegistStatus(SIPStack.bNetworkActive);
- }//SipSignalReceiver()
- public void resetConfiguration(String strId, String strCid, String strAuthid, String strAuthpassword, String strServerHost, String strServerDomain, int serverport) {
- // Set server information
- cmcore.action_2(strId, strCid, strAuthid, strAuthpassword, strServerHost, strServerDomain, serverport);
- sendRegister();
- }
- public void SIPCTRLRegister() {
- if (SIPStack.ipdns.bSipAddressResolved == false) {
- return;
- }
- Date currentTime = new Date();
- int duration = (int) (currentTime.getTime() - cmcore.regTime.getTime()) / 1000;
- int startduration = (int) (currentTime.getTime() - SIPStack.bootTime.getTime()) / 1000;
- if (cmcore.regState == SIPStack.SIP_REGSTATE_IDLE && startduration > 0 && startduration < 10 && mSIPSignalReceiver != null && mSIPSignalReceiver.bReady == true) {
- byte[] buffer = cmcore.message.getBytes();
- if (cmcore.message.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, cmcore.message);
- cmcore.regState = SIPStack.SIP_REGSTATE_REGISTERING;
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(cmcore.serverIp, cmcore.serverPort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- cmcore.regTime = new Date();
- }
- } else if (decideRegister() == true && cmcore.regState != SIPStack.SIP_REGSTATE_REGISTERING && cmcore.regState != SIPStack.SIP_REGSTATE_AUTHORIZING && cmcore.regState != SIPStack.SIP_REGSTATE_UNAVAILABLE) {
- cmcore.regState = SIPStack.SIP_REGSTATE_REGISTERING;
- sendRegister();
- } else if (duration >= SIPStack.CS_TIMEOUT_RESPONSE && cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERING) { // 30
- cmcore.regState = SIPStack.SIP_REGSTATE_REGISTERING;
- sendRegister();
- }
- return;
- }
- public void SIPCTRLCall() {
- Date currentTime = new Date();
- long durationMilli = Math.abs(currentTime.getTime() - cmcore.ctrlIntervalTimer.getTime());
- long durationRegistStatus = Math.abs((currentTime.getTime() - cmcore.registStatusTimer.getTime()) / 1000);
- if (durationMilli < 500) {
- return;
- } else {
- cmcore.ctrlIntervalTimer = new Date();
- durationMilli = Math.abs((currentTime.getTime() - cmcore.netcheckIntervalTimer.getTime()) / 1000);
- if (durationMilli > SIPStack.NETWORKIF_CHECK_TIME) {
- if (connectivityManager != null && connectivityManager.getActiveNetworkInfo() != null) {
- NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
- switch (activeNetwork.getType()) {
- case ConnectivityManager.TYPE_WIMAX: // 4g 망 체크
- if (SIPStack.isInternetWiMax == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = true;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_WIFI: // wifi망 체크
- if (SIPStack.isInternetWiFi == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = false;
- SIPStack.isInternetWiFi = true;
- SIPStack.isInternetMobile = false;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- case ConnectivityManager.TYPE_MOBILE: // 3g 망 체크
- if (SIPStack.isInternetMobile == false && SIPStack.bBackgroundRunning)
- SIPStack.bShutdownApplication = true;
- SIPStack.isInternetWiMax = false; // false;
- SIPStack.isInternetWiFi = false;
- SIPStack.isInternetMobile = true;
- SIPStack.PRIMARY_CODEC_AUDIO = SIPStack.SIP_CODEC_G711U;
- break;
- }
- }
- cmcore.netcheckIntervalTimer = new Date();
- try {
- String host = SIPController.getSHVE140SLocalIpAddress();
- if (true == cmcore.action_net_3(host)) {
- sendUNRegister(cmcore.previfIp, cmcore.previfPort);
- cmcore.regState = SIPStack.SIP_REGSTATE_UNREGISTERING;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] String host = SIPController.getSHVE140SLocalIpAddress()");
- }
- }
- }
- if (durationRegistStatus > 0) {
- if ((SIPStack.bIntraffic || SIPStack.bOuttraffic) && SIPController.sipCall != null && SIPController.sipCall.flag == false) {
- if (cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERED) {
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == false) dialerRegistStatus(true);
- } else {
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == false) dialerRegistStatus(false);
- }
- cmcore.registStatusTimer = new Date();
- } else if (durationRegistStatus > 3) {
- if (cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERED) {
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == false) dialerRegistStatus(true);
- } else {
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == false) dialerRegistStatus(false);
- }
- cmcore.registStatusTimer = new Date();
- }
- }
- // Multicall call state processing
- if (SIPController.pendingCall != null && SIPController.pendingCall.flag == true) {
- // Log.d(TAG, "[SIPCTRLCall]");
- if (SIPController.pendingCall.callTime_TI != null)
- SIPController.pendingCall.expiresTI = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_TI.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T0 != null)
- SIPController.pendingCall.expiresT0 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T0.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T00 != null)
- SIPController.pendingCall.expiresT00 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T00.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T1 != null)
- SIPController.pendingCall.expiresT1 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T1.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T2 != null)
- SIPController.pendingCall.expiresT2 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T2.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T3 != null)
- SIPController.pendingCall.expiresT3 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T3.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T4 != null)
- SIPController.pendingCall.expiresT4 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T4.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T5 != null)
- SIPController.pendingCall.expiresT5 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T5.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T6 != null)
- SIPController.pendingCall.expiresT6 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T6.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T7 != null)
- SIPController.pendingCall.expiresT7 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T7.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T8 != null)
- SIPController.pendingCall.expiresT8 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T8.getTime()) / 1000;
- if (SIPController.pendingCall.callTime_T9 != null)
- SIPController.pendingCall.expiresT9 = (int) (currentTime.getTime() - SIPController.pendingCall.callTime_T9.getTime());//milli seconds
- // Log.d(TAG, "[SIPCTRLCall] SIPController.sipCall.callState [" + SIPController.sipCall.callState + "]");
- if (SIPController.pendingCall.bAsMaster == true) {
- // CONNECTED TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT4();
- // CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(5);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- sendBye();
- SIPController.sipCall.resetCall();
- SIPController.sipCall = SIPController.pendingCall;
- SIPController.pendingCall = new SIPCall();
- // for temporary
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- Log.i(TAG, "call exchange : " + SIPController.sipCall.remoteIp);
- BSSVideo.bProgressvideooffer = true;
- sendProgressingwithbody(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort);
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Incoming call accept.", false);
- directsendAccept(false); // 방문객 원격통화로 인하여 CallOwner (boolean) 파라미터 추가
- return;
- }
- }
- return;
- } else {
- if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_TERMINATING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_DISCONNECTING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_IDLE) {
- // CONNECTED TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT4();
- // CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(6);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- sendBye();
- SIPController.sipCall.resetCall();
- SIPController.sipCall = SIPController.pendingCall;
- SIPController.pendingCall = new SIPCall();
- // for temporary
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- Log.i(TAG, "call exchange : " + SIPController.sipCall.remoteIp);
- BSSVideo.bProgressvideooffer = true;
- sendProgressingwithbody(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort);
- }
- return;
- }
- }
- if (SIPController.pendingCall.bRejectRequest == true) {
- if (SIPController.bMulticallBusyResponse == true) rejectPendingCall(486);
- else rejectPendingCall(480);
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_IDLE) {
- if (SIPController.pendingCall.expiresTI > SIPStack.CS_TIMEOUT_TI) {
- SIPController.pendingCall.resetCall();
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_DISCONNECTING) {
- if (SIPController.pendingCall.expiresT5 > SIPStack.CS_TIMEOUT_T5) {
- // DISCONNECTING TIMEOUT PROCESSING
- SIPController.pendingCall.resetCall();
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_TERMINATING) {
- if (SIPController.pendingCall.expiresT6 > SIPStack.CS_TIMEOUT_T6) {
- SIPController.pendingCall.resetCall();
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- if (SIPController.pendingCall.expiresT7 > SIPStack.CS_TIMEOUT_T7) {
- SIPController.pendingCall.exceptionT7();
- rejectPendingCall(408);
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_CANCELLING) {
- if (SIPController.pendingCall.expiresT8 > SIPStack.CS_TIMEOUT_T8) {
- SIPController.pendingCall.resetCall();
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_RECANCELLING) {
- if (SIPController.pendingCall.expiresT8 > SIPStack.CS_TIMEOUT_T8) {
- SIPController.pendingCall.resetCall();
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_CANCELREMOTEACCEPTED) {
- if (SIPController.pendingCall.expiresT8 > SIPStack.CS_TIMEOUT_T8) {
- SIPController.pendingCall.resetCall();
- }
- } else if (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_CANCELLED) {
- if (SIPController.pendingCall.expiresT8 > SIPStack.CS_TIMEOUT_T8) {
- SIPController.pendingCall.resetCall();
- }
- }
- }
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) {
- if (cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERED) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Ready.", cmcore.bRequestReadySet);
- } else {
- // SERVICE MESSAGE NEEDED
- if (SIPStack.bDirectCall == false)
- updateDialerStatus("Not registered.", cmcore.bRequestReadySet);
- }
- if (cmcore.bRequestReadySet == true) {
- cmcore.bRequestReadySet = false;
- }
- return;
- }
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true) {
- if (SIPController.sipCall.callTime_TI != null)
- SIPController.sipCall.expiresTI = (int) (currentTime.getTime() - SIPController.sipCall.callTime_TI.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T0 != null)
- SIPController.sipCall.expiresT0 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T0.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T00 != null)
- SIPController.sipCall.expiresT00 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T00.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T1 != null)
- SIPController.sipCall.expiresT1 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T1.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T2 != null)
- SIPController.sipCall.expiresT2 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T2.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T3 != null)
- SIPController.sipCall.expiresT3 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T3.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T4 != null)
- SIPController.sipCall.expiresT4 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T4.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T5 != null)
- SIPController.sipCall.expiresT5 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T5.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T6 != null)
- SIPController.sipCall.expiresT6 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T6.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T7 != null)
- SIPController.sipCall.expiresT7 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T7.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T8 != null)
- SIPController.sipCall.expiresT8 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T8.getTime()) / 1000;
- if (SIPController.sipCall.callTime_T9 != null)
- SIPController.sipCall.expiresT9 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T9.getTime());
- if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_IDLE) {
- if (SIPController.sipCall.expiresTI > SIPStack.CS_TIMEOUT_TI) {
- // IDLE TIMEOUT PROCESSING
- SIPController.sipCall.exceptionTI();
- //SERVICE MESSAGE NEEDED
- updateDialerStatus("Ready.", true);
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING) {
- if ((SIPStack.ventureCall == true || SIPStack.bDirectCall == true) && SIPController.sipCall.expiresT00 > 3) {
- sendReInvite();
- SIPStack.ventureCall = false;
- } else if (SIPController.sipCall.expiresT00 > SIPStack.CS_TIMEOUT_T00) {
- //INVITING REPEAT TIMEOUT PROCESSING
- sendReInvite();
- SIPStack.ventureCall = false;
- }
- if (SIPController.sipCall.expiresT0 > SIPStack.CS_TIMEOUT_T000) {
- Log.i(TAG, " " + SIPController.sipCall.expiresT0);
- sendCancel();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING) {
- if (SIPController.sipCall.expiresT1 > SIPStack.CS_TIMEOUT_T1) {
- //PROCEEDING TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT1();
- // CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(7);
- if (SIPStack.bDirectCall == true) {
- //SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- sendCancel();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING) {
- if (SIPController.sipCall.expiresT2 > SIPStack.CS_TIMEOUT_T2) {
- //PROGRESSING TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT2();
- // CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(8);
- if (SIPStack.bDirectCall == true) {
- //SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- sendCancel();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_ACCEPTED || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_REMOTEACCEPTED) {
- if (SIPController.sipCall.expiresT3 > SIPStack.CS_TIMEOUT_T3) {
- //ACCEPTED TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT3();
- // CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(9);
- if (SIPStack.bDirectCall == true) {
- //SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- sendBye();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) {
- if (SIPController.sipCall.expiresT4 > SIPStack.CS_TIMEOUT_T4) {
- //CONNECTED TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT4();
- // CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(10);
- if (SIPStack.bDirectCall == true) {
- //SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- sendBye();
- } else {
- int expiresT40 = 0;
- if (SIPController.sipCall.callTime_T40 != null) {
- expiresT40 = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T40.getTime()) / 1000;
- if (expiresT40 > 0) {
- SIPController.sipCall.callTime_T40 = new Date();
- }
- }
- // try {
- // if (SIPController.audioRTPManager != null && SIPController.sipCall.expiresT4 > 1 && SIPController.audioRTPManager.bDisableVoice == false) {
- // int muteDuration = (int) (currentTime.getTime() - SIPController.audioRTPManager.rtpCore.rtpArrivalTime.getTime());
- // Log.e(TAG, "[SIPStun] ========== RTP END ========== muteDuration [" + muteDuration + "]");
- // if (muteDuration > 5000) {
- // // milliseconds
- // // CONFERENCE CALL CHECK NEEDED
- // if (SIPController.audioRTPManager != null)
- // SIPController.audioRTPManager.RTPEnd(11);
- // if (SIPStack.bDirectCall == true) {
- // //SERVICE MESSAGE NEEDED
- // dialerVideoSet(false);
- // }
- // sendBye();
- // //SERVICE MESSAGE NEEDED
- // updateDialerStatus("No Audio Packet Received for 3Sec!", false);
- // //SERVICE MESSAGE NEEDED
- // dialerNotifyCallEnd("No Audio Packet Received for 3Sec!", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- // }
- // }
- // } catch (RuntimeException re) {
- // LogUtil.errorLogInfo("", TAG, re);
- // } catch (Exception e) {
- // Log.e(TAG, "[Exception] dialerVideoSet(false)");
- // }
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_DISCONNECTING) {
- if (SIPController.sipCall.bByedisconnected == true && SIPController.sipCall.expiresT9 > 500) {
- //resend bye
- resendBye();
- }
- if (SIPController.sipCall.expiresT5 > SIPStack.CS_TIMEOUT_T5) {
- //DISCONNECTING TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT5();
- SIPController.sipCall.resetCall();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_TERMINATING) {
- if (SIPController.sipCall.expiresT6 > SIPStack.CS_TIMEOUT_T6) {
- dialerNotifyCallEnd("Call Terminating.", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.exceptionT6();
- cmcore.ctrlIntervalTimer = new Date();
- cmcore.bRequestReadySet = true;
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- if (SIPController.sipCall.expiresT7 > SIPStack.CS_TIMEOUT_T7) {
- //OFFERRED TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT7();
- //CONFERENCE CALL CHECK NEEDED
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(12);
- if (SIPStack.bDirectCall == true) {
- //SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- rejectCall(408);
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELLING) {
- //more code needed !!!!
- if (SIPController.sipCall.expiresT8 > SIPStack.CS_TIMEOUT_T80) {
- //CANCELLING TIMEOUT PROCESSING
- sendRecancel();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_RECANCELLING) {
- //more code needed !!!!
- if (SIPController.sipCall.expiresT8 > SIPStack.CS_TIMEOUT_T8) {
- //CANCELLING TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT8();
- //SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("전화를 받지 않습니다.", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- }
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELREMOTEACCEPTED) {
- if (SIPController.sipCall.expiresT8 > SIPStack.CS_TIMEOUT_T8) {
- dialerNotifyCallFail(487, SIPController.sipCall.remoteIp, makeSIPID(SIPController.sipCall.remoteIp));
- // CANCELLING TIMEOUT PROCESSING
- SIPController.sipCall.exceptionT8();
- SIPController.sipCall.resetCall();
- }
- }
- } else if (SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_HOLD) {
- // more job
- }
- return;
- }
- public int SIPParser(String strMessage, int nMSGType, int nMethodType) {
- if (strMessage == null || strMessage.length() <= 0) return 0;
- boolean bSendRegister = false;
- if (bPrintSIPMsgIO) {
- Log.i(TAG, "[SIPParser] nMSGType [" + nMSGType + "], nMethodType [" + nMethodType + "]");
- printSIPMessage(MESSAGE.RECEIVE, strMessage);
- }
- if (nMSGType != SIPStack.SIP_MSGTYPE_RESPONSE || nMethodType != SIPStack.SIP_METHODTYPE_REGISTER)
- return -1;
- SIPRequestLine requestLine = new SIPRequestLine(strMessage);
- if (requestLine == null || requestLine.flag == false) return 0;
- switch (requestLine.code) {
- case 200:
- cmcore.repeatRegisterCount = 0;
- if (cmcore.regState == SIPStack.SIP_REGSTATE_REGISTERING || cmcore.regState == SIPStack.SIP_REGSTATE_AUTHORIZING || cmcore.regState == SIPStack.SIP_REGSTATE_UNREGISTERING) {
- SIPCONTACTHeader contactHeader = cmcore.action_reg_0(strMessage);
- if (contactHeader != null && contactHeader.flag == false) {
- contactHeader = new SIPCONTACTHeader(strMessage);
- }
- if (contactHeader == null || contactHeader.flag == false || contactHeader.expires == 0 || cmcore.regState == SIPStack.SIP_REGSTATE_UNREGISTERING) {
- if (cmcore.bInterfaceChanged == true) {
- cmcore.bInterfaceChanged = false;
- cmcore.regState = SIPStack.SIP_REGSTATE_REGISTERING;
- sendRegister();
- } else {
- cmcore.regState = SIPStack.SIP_REGSTATE_IDLE;
- }
- break;
- }
- if (contactHeader.expires > 0) {
- cmcore.expiresSeconds = contactHeader.getExpires();
- } else if (contactHeader.expires < 0) {
- SIPHeader expiresHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_EXPIRES);
- if (expiresHeader != null && expiresHeader.flag == true && expiresHeader.headerValue != null && expiresHeader.headerValue.length() > 0) {
- cmcore.expiresSeconds = Integer.parseInt(expiresHeader.headerValue.trim());
- }
- }
- // SET REGISTERSTATE AS REGISTERED
- if (cmcore.expiresSeconds > 0) {
- cmcore.regTime = new Date();
- cmcore.regState = SIPStack.SIP_REGSTATE_REGISTERED;
- // Phone status set
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Ready.", false);
- }
- if (true == cmcore.action_reg_1(strMessage)) {
- cmcore.regState = SIPStack.SIP_REGSTATE_UNREGISTERING;
- sendUNRegister(cmcore.previfIp, cmcore.previfPort);
- }
- } else if (cmcore.expiresSeconds == 0) {
- cmcore.regTime = new Date();
- cmcore.regState = SIPStack.SIP_REGSTATE_IDLE;
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Service Off mode", false);
- }
- }
- break;
- case 401:
- if (cmcore.repeatRegisterCount > 3) {
- cmcore.regState = SIPStack.SIP_REGSTATE_UNAVAILABLE;
- cmcore.repeatRegisterCount = 0;
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Server 인증 실패하였습니다.", false);
- break;
- }
- cmcore.regState = SIPStack.SIP_REGSTATE_UNAUTHORIZED;
- // Phone status set
- if (SIPController.sipCall.flag == false) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Regist Unauthorized.", false);
- }
- if (true == cmcore.action_reg_2(strMessage)) {
- bSendRegister = true;
- cmcore.repeatRegisterCount++;
- }
- break;
- case 407:
- if (cmcore.repeatRegisterCount > 3) {
- cmcore.regState = SIPStack.SIP_REGSTATE_UNAVAILABLE;
- cmcore.repeatRegisterCount = 0;
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Server 인증 실패하였습니다.", false);
- break;
- }
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Regist Unauthorized.", false);
- if (true == cmcore.action_reg_3(strMessage)) {
- bSendRegister = true;
- }
- break;
- case 423:
- cmcore.action_reg_4(strMessage);
- sendRegister();
- break;
- default:
- if (requestLine.code >= 400) cmcore.regState = SIPStack.SIP_REGSTATE_UNAVAILABLE;
- break;
- }
- if (bSendRegister) {
- cmcore.regState = SIPStack.SIP_REGSTATE_AUTHORIZING;
- if (cmcore.authorizationH != null && cmcore.authorizationH.length() > 0)
- sendRegister();
- }
- return 0; // normal
- } // SIPParser()
- public void UPDATEParser(String message, int msgType, String remoteIp, int remotePort) {
- Log.d(TAG, "[UPDATEParser]");
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false || (SIPController.sipCall.callMode != SIPStack.SIP_CALLMODE_BASIC && SIPController.sipCall.callMode != SIPStack.SIP_CALLMODE_HOLD)) {
- if (msgType == SIPStack.SIP_MSGTYPE_RESPONSE) {
- SIPRequestLine requestLine = new SIPRequestLine(message);
- if (requestLine != null && requestLine.flag == true && requestLine.code >= 300) {
- sendFinalAck(message, remoteIp, remotePort);
- }
- }
- return;
- }
- if (msgType == SIPStack.SIP_MSGTYPE_REQUEST) {
- if (SIPController.sipCall != null) {
- if (SIPController.sipCall.flag == true) {
- // busy
- // validate call
- SIPHeader sipHeader = new SIPHeader(message, SIPStack.SIP_HEADERTYPE_CALLID);
- boolean bValidCall = false;
- if (sipHeader != null && sipHeader.flag == true) {
- if (sipHeader.headerValue != null && sipHeader.headerValue.length() > 0 && SIPController.sipCall.callId != null && sipHeader.headerValue.compareTo(SIPController.sipCall.callId) == 0) {
- bValidCall = true;
- }
- }
- if (bValidCall == true) {
- // EXIST CALL
- // IF HOLDMODE
- if (SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_HOLD) {
- if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEOFFERRED) {
- // ACCEPT
- }
- return;
- } else if (SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_BASIC && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) {
- // IF CONNECTED
- // SET CALLMODE AS UPDATE
- SIPController.sipCall.callMode = SIPStack.SIP_CALLMODE_HOLD;
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEOFFERRED;
- SIPController.sipCall.callDirection = SIPStack.SIP_CALLDIRECTION_IN;
- //parse message + construct local and remote sdp +negotiate codec
- if (true == SIPController.sipCall.constructUPDATEHeaders(message, remoteIp, remotePort)) {
- // response trying
- sendProceeding(remoteIp, remotePort);
- if (false == sendUpdateAccept()) {
- rejectCall(message, 480, remoteIp, remotePort);
- return;
- }
- } else {
- rejectCall(message, 480, remoteIp, remotePort);
- return;
- }
- // ACCEPT
- return;
- } else {
- // DISCARD
- return;
- }
- } else {
- // invalid update call
- rejectCall(message, 400, remoteIp, remotePort);
- return;
- }
- } else {
- // invalid update call
- rejectCall(message, 400, remoteIp, remotePort);
- return;
- }
- } else {
- // response 400
- // no sip call handle
- // response only
- rejectCall(message, 400, remoteIp, remotePort);
- return;
- }
- } else if (msgType == SIPStack.SIP_MSGTYPE_RESPONSE && SIPController.sipCall.flag == true && SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_OUT) {
- if (SIPController.sipCall.callMode != SIPStack.SIP_CALLMODE_HOLD) return;
- SIPRequestLine requestLine = new SIPRequestLine(message);
- if (requestLine != null) {
- // validate call
- SIPHeader sipHeader = new SIPHeader(message, SIPStack.SIP_HEADERTYPE_CALLID);
- boolean bValidCall = false;
- if (sipHeader != null && sipHeader.flag == true) {
- if (sipHeader.headerValue != null && sipHeader.headerValue.length() > 0 && SIPController.sipCall.callId != null && sipHeader.headerValue.compareTo(SIPController.sipCall.callId) == 0) {
- SIPHeader seqHeader = new SIPHeader(message, SIPStack.SIP_HEADERTYPE_CSEQ);
- if (seqHeader != null && seqHeader.callSequenceNumber() == SIPController.sipCall.CSEQ_NUMBER) {
- bValidCall = true;
- } else if (requestLine.code < 200) {
- return;
- }
- }
- }
- if (bValidCall == true) {
- sipHeader = null;
- sipHeader = new SIPHeader(message, SIPStack.SIP_HEADERTYPE_TO);
- if (sipHeader != null) {
- SIPController.sipCall.toH = sipHeader.header;
- SIPController.sipCall.toTag = sipHeader.getTag();
- }
- }
- sipHeader = new SIPHeader(message, SIPStack.SIP_HEADERTYPE_CSEQ);
- if (bValidCall == true) {
- SIPController.sipCall.remoteIp = remoteIp;
- SIPController.sipCall.remotePort = remotePort;
- if (requestLine.code >= 200 && sipHeader != null && sipHeader.flag == true) {
- SIPController.sipCall.CSEQ_NUMBER = sipHeader.callSequenceNumber();
- }
- if (requestLine.code == 100) {
- // trying
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEPROCEEDING;
- SIPController.sipCall.callTime_T1 = new Date();
- } else if (requestLine.code >= 180 && requestLine.code <= 183) {
- // progressing
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEPROGRESSING;
- SIPController.sipCall.callTime_T2 = new Date();
- if (true == SIPController.sipCall.parseRemoteSdp(message)) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.flag == true) {
- SIPController.sipCall.negotiateAudioCodec();
- }
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager.rtpCore.bActive == false) {
- SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 1);
- }
- }
- }
- }
- }
- } else if (requestLine.code == 200 && SIPController.sipCall.CSEQ_NUMBER == sipHeader.callSequenceNumber() &&
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROCEEDING ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROGRESSING)) {
- // connected
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEREMOTEACCEPTED;
- SIPController.sipCall.callTime_T3 = new Date();
- boolean ret = sendAck(message);
- if (ret == true) {
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_CONNECTED;
- SIPController.sipCall.callMode = SIPStack.SIP_CALLMODE_BASIC;
- SIPSound.resetBufferInfo();
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallConnected(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- }
- // remote body analysis
- // MUST BE CHANGE
- if (true == SIPController.sipCall.parseRemoteSdp(message)) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.flag == true) {
- SIPController.sipCall.negotiateAudioCodec();
- }
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager.rtpCore.bActive == false) {
- SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 2);
- }
- }
- }
- }
- }
- } else if (requestLine.code == 401 && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROCEEDING ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROGRESSING)) {
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEUNAUTHORIZED;
- sendFinalAck(message);
- if (reactionForWWWAUTHENTICATE(message) == false) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(13);
- SIPController.sipCall.resetCall();
- }
- } else if (requestLine.code == 407 && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROCEEDING ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROGRESSING)) {
- // Proxy-Athenticate
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEUNAUTHORIZED;
- sendFinalAck(message);
- if (reactionForPROXYAUTHENTICATE(message) == false) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(14);
- SIPController.sipCall.resetCall();
- }
- } else if (requestLine.code == 302 && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROCEEDING ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROGRESSING)) {
- // terminating
- // FORWARD - MUST BE PROCESSED MORE
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- sendFinalAck(message);
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(15);
- SIPController.sipCall.resetCall();
- } else if (requestLine.code >= 300 && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROCEEDING ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEPROGRESSING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UPDATEUNAUTHORIZED)) {
- // terminating
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- sendFinalAck(message);
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(16);
- SIPController.sipCall.resetCall();
- }
- } else {
- sendFinalAck(message, remoteIp, remotePort);
- }
- }
- }
- return;
- }
- String m_strMessage = "", m_strRemoteIP = "";
- int m_strRemotePort = 0;
- public void INVITEParser(String strMessage, int nMSGType, String strRemoteIP, int strRemotePort) {
- try {
- Log.w(TAG, "[INVITEParser] bBLOCK_INVITE_MSG [" + bBLOCK_INVITE_MSG + "]");
- Log.w(TAG, "[INVITEParser] strMessage [" + strMessage + "]");
- //m_strMessage = strMessage;
- //m_strRemoteIP = strRemoteIP;
- //m_strRemotePort = strRemotePort;
- if (bBLOCK_INVITE_MSG) {
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- return;
- }
- if (nMSGType == SIPStack.SIP_MSGTYPE_REQUEST) {
- if (SIPController.sipCall != null) {
- Log.d(TAG, "[INVITEParser] [SIPController.sipCall.flag = " + SIPController.sipCall.flag + "]");
- if (SIPController.sipCall.flag == true) {
- // busy
- boolean bValidCall = SIPController.sipCall.isCurrentCall(strMessage);
- Log.d(TAG, "[INVITEParser] bValidCall = " + bValidCall);
- if (bValidCall == true) {
- //EXIST CALL
- //IF HOLDEMODE
- if (SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_HOLD) {
- UPDATEParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- return;
- }
- else if (SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_BASIC && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) {
- // IF CONNECTED
- // UPDATE PROCESSING
- UPDATEParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- return;
- }
- else {
- // DISCARD
- return;
- }
- }
- else {
- Log.i(TAG, "BUSY CHECK : callState : " + SIPController.sipCall.callState);
- if (SIPController.sipCall.callState != SIPStack.SIP_CALLSTATE_CONNECTED) {
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- return;
- }
- if (SIPController.bMulticallSupport == true) {
- if (SIPController.pendingCall != null) {
- if (SIPController.pendingCall.flag == true) {
- if (SIPController.pendingCall.isCurrentCall(strMessage) == true) {
- // pendingCall self
- // no action
- } else {
- /* KSJ 2022.06.16
- invite 두번 들어오는 경우가 발생 하여 먼저 들어온 remoteIP 를 저장 하여,
- 통화 중인 같은 IP 에서 call 발생할 경우 multi call 처리를 하지 않고 내용 버리기 위한 코드.
- */
- if(m_strRemoteIP != strRemoteIP) {
- // pendingCall exist and another pending call incoming
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- }
- }
- return;
- } else {
- // New incoming pending call
- CMCore.bDialerActive = true;
- if (CMCore.bDialerActive == false) {
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- return;
- }
- // pending call construct
- String fromId = null;
- String toId = null;
- SIPHeader sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_TO);
- if (sipHeader != null && sipHeader.flag == true) {
- toId = sipHeader.getId().trim();
- if (toId != null && toId.length() > 0) {
- sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_FROM);
- if (sipHeader != null && sipHeader.flag == true) {
- fromId = sipHeader.getId().trim();
- }
- }
- toId = makeSIPID(toId);
- fromId = makeSIPID(fromId);
- Log.d(TAG, "[INVITEParser111] cmcore.id [" + cmcore.id + "], toId [" + toId + "]");
- if (cmcore.id != null && toId.compareTo(cmcore.id) == 0) {
- // activate call handler
- boolean ret = false;
- if (SIPStack.bDirectCall == false) {
- if (strRemoteIP.compareTo(cmcore.serverIp) == 0) {
- ret = SIPController.pendingCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, cmcore.serverDomain, cmcore.localIp, cmcore.localPort);
- } else {
- ret = SIPController.pendingCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, strRemoteIP, cmcore.localIp, cmcore.localPort);
- }
- } else {
- ret = SIPController.pendingCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, strRemoteIP, cmcore.localIp, cmcore.localPort);
- }
- if (ret == true) {
- SIPController.pendingCall.callState = SIPStack.SIP_CALLSTATE_OFFERRED;
- SIPController.pendingCall.callDirection = SIPStack.SIP_CALLDIRECTION_IN;
- SIPController.pendingCall.callTime_T7 = new Date();//offerred timer
- if (true == SIPController.pendingCall.constructHeaders(strMessage, strRemoteIP, strRemotePort)) {
- if (SIPController.sipCall.remoteContactUri.contains("Lobby") && SIPController.pendingCall.remoteContactUri.contains("Lobby")) {
- rejectPendingCall(486);
- return;
- }
- else if (SIPController.sipCall.remoteContactUri.contains("Guard") && SIPController.pendingCall.remoteContactUri.contains("Guard")) {
- rejectPendingCall(486);
- return;
- }
- else if (SIPController.sipCall.remoteContactUri.contains("Resi") && SIPController.pendingCall.remoteContactUri.contains("Resi")) {
- rejectPendingCall(486);
- return;
- }
- sendPendingProceeding(strRemoteIP, strRemotePort);
- dialerNotifyIncomingMultiCall(SIPController.pendingCall.dnis, SIPController.pendingCall.dnis + "@" + SIPController.pendingCall.remoteIp + ":" + SIPController.pendingCall.remotePort);
- } else {
- rejectCall(strMessage, 480, strRemoteIP, strRemotePort);
- return;
- }
- } else {
- rejectCall(strMessage, 480, strRemoteIP, strRemotePort);
- return;
- }
- sendPendingProgressing(strRemoteIP, strRemotePort);
- return;
- } else {
- rejectCall(strMessage, 404, strRemoteIP, strRemotePort);
- return;
- }
- } else {
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- }
- }
- } else {
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- }
- }
- else {
- // BUSY
- rejectCall(strMessage, 486, strRemoteIP, strRemotePort);
- }
- }
- }
- else {
- // BUSY UPDATE END
- // processing inviting call
- SIPStun.bBlackCall = false;
- boolean bCallPopup = false;
- String fromId = null;
- String toId = null;
- SIPHeader sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_TO);
- if (sipHeader != null && sipHeader.flag == true) {
- toId = sipHeader.getId().trim();
- if (toId != null && toId.length() > 0) {
- sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_FROM);
- if (sipHeader != null && sipHeader.flag == true) {
- fromId = sipHeader.getId().trim();
- }
- }
- sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_CONTACT);
- Log.d(TAG, "[INVITEParser22222] SIP_HEADERTYPE_CONTACT [" + sipHeader.header + "]");
- if(!sipHeader.header.contains("Lobby") && !sipHeader.header.contains("Resi"))
- {
- sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_CALLID);
- if(sipHeader.header.contains("HNSLOBBY"))
- {
- bCallPopup = true;
- }
- else if(sipHeader.header.contains("CNSTEC"))
- {
- bCallPopup = true;
- }
- }
- toId = makeSIPID(toId);
- fromId = makeSIPID(fromId);
- Log.d(TAG, "[INVITEParser22222] cmcore.id [" + cmcore.id + "], toId [" + toId + "]");
- // KSJ 호출이 온 IP를 저장 하고 이후 사용 하기 위한 코드 2022.06.16
- m_strMessage = strMessage;
- m_strRemoteIP = strRemoteIP;
- m_strRemotePort = strRemotePort;
- if (cmcore.id != null && toId.compareTo(cmcore.id) == 0) {
- // activate call handler
- boolean ret = false;
- if (SIPStack.bDirectCall == false) {
- if (strRemoteIP.compareTo(cmcore.serverIp) == 0) {
- ret = SIPController.sipCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, cmcore.serverDomain, cmcore.localIp, cmcore.localPort);
- } else {
- ret = SIPController.sipCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, strRemoteIP, cmcore.localIp, cmcore.localPort);
- }
- }
- else {
- Log.i(TAG, "[INVITEParser] New call. Dialer awaken.");
- Log.i(TAG, "[INVITEParser] strRemoteIP [" + strRemoteIP + "], fromId [" + fromId + "]");
- receiveNewCall(strRemoteIP, fromId, bCallPopup);
- Log.d(TAG, "[INVITEParser] CMCore.bDialerActive [" + CMCore.bDialerActive + "]");
- // CMCore.bDialerActive는 GUI의 foreground 여부를 의미한다. (true: foreground)
- // 통화어플 적용시에는 상관없으므로 주석처리한다.
- // GUI는 receiveNewCall(String strRemoteIP, String strRemoteSIPID) 함수에서 실행한다.
- if (CMCore.bDialerActive == false) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 2 ============");
- SIPStun.bBlackCall = true;
- Log.d(TAG, "[INVITEParser] SIPStun.bBlackcallBackgroundMode [" + SIPStun.bBlackcallBackgroundMode + "]");
- if (SIPStun.bBlackcallBackgroundMode == true) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 3 ============");
- ret = SIPController.sipCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, strRemoteIP, cmcore.localIp, cmcore.localPort);
- if (ret == true) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 4 ============");
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_OFFERRED;
- SIPController.sipCall.callDirection = SIPStack.SIP_CALLDIRECTION_IN;
- SIPController.sipCall.callTime_T7 = new Date(); // offerred timer
- // parse message + construct local and remote sdp +negotiate codec
- if (true == SIPController.sipCall.constructHeaders(strMessage, strRemoteIP, strRemotePort)) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 5 ============");
- // response trying
- sendProceeding(strRemoteIP, strRemotePort);
- SIPController.sipCall.bResponsebackgroundcall = true;
- SIPController.sipCall.bResponsebackgroundcallReady = false;
- if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_LOBBY) {
- SIPController.latestMenu = 1;
- } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_GUARD) {
- SIPController.latestMenu = 2;
- } else if (SIPController.sipCall.hnsOriginatorServiceType == BSSVideo.HNS_SERVICE_NEIGHBOR) {
- SIPController.latestMenu = 3;
- }
- if ((BSSVideo.bProgressvideooffer == true) || (SIPController.forward.bForward == true)) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 6 ============");
- sendProgressingBlackcallwithbody(strRemoteIP, strRemotePort);
- } else {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 7 ============");
- sendProgressing(strRemoteIP, strRemotePort);
- }
- }
- }
- }
- return;
- }
- ret = SIPController.sipCall.activeCallHandle(cmcore.id, cmcore.cid, cmcore.authid, cmcore.authpassword, fromId, strRemoteIP, strRemotePort, strRemoteIP, cmcore.localIp, cmcore.localPort);
- }
- if (ret == true) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 8 ============");
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_OFFERRED;
- SIPController.sipCall.callDirection = SIPStack.SIP_CALLDIRECTION_IN;
- SIPController.sipCall.callTime_T7 = new Date();//offerred timer
- //parse message + construct local and remote sdp +negotiate codec
- if (true == SIPController.sipCall.constructHeaders(strMessage, strRemoteIP, strRemotePort)) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 9 ============");
- // response trying
- sendProceeding(strRemoteIP, strRemotePort);
- updateDialerStatus("전화가 왔습니다.", false);
- dialerNotifyIncomingCall(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- } else {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 10 ============");
- rejectCall(strMessage, 480, strRemoteIP, strRemotePort);
- updateDialerStatus("전화를 종료했습니다.", false);
- return;
- }
- } else {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 11 ============");
- rejectCall(strMessage, 480, strRemoteIP, strRemotePort);
- return;
- }
- if (BSSVideo.bProgressvideooffer == true || SIPController.forward.bForward == true) {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 12 ============");
- //KSJ 2443 1세대 버전 호환을 위해 주석
- //sendProgressingwithbody(strRemoteIP, strRemotePort);
- } else {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 13 ============");
- sendProgressing(strRemoteIP, strRemotePort);
- }
- } else {
- Log.e(TAG, "[INVITEParser] ============ SEULKI 14 ============");
- rejectCall(strMessage, 404, strRemoteIP, strRemotePort);
- return;
- }
- }
- }
- } else {
- // response 480
- // no sip call handle
- // response only
- Log.e(TAG, "[INVITEParser] ============ SEULKI 15 ============");
- rejectCall(strMessage, 480, strRemoteIP, strRemotePort);
- }
- } else if (nMSGType == SIPStack.SIP_MSGTYPE_RESPONSE) {
- if (true == cmcore.INVITEParser_action_0(SIPController.sipCall, strMessage)) {
- SIPHeader sipHeader = null;
- sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_TO);
- if (sipHeader != null) {
- SIPController.sipCall.toH = sipHeader.header;
- SIPController.sipCall.toTag = sipHeader.getTag();
- }
- sipHeader = new SIPHeader(strMessage, SIPStack.SIP_HEADERTYPE_CSEQ);
- if (SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_HOLD) {
- UPDATEParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- return;
- }
- SIPController.sipCall.remoteIp = strRemoteIP;
- SIPController.sipCall.remotePort = strRemotePort;
- if ((SIPController.sipCall.responseCode >= 200) && (sipHeader != null) && (sipHeader.flag == true)) {
- SIPController.sipCall.CSEQ_NUMBER = sipHeader.callSequenceNumber();
- }
- if (SIPController.sipCall.responseCode == 100) {
- // trying
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_PROCEEDING;
- SIPController.sipCall.callTime_T1 = new Date();
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call proceeding.", false);
- } else if ((SIPController.sipCall.responseCode >= 180) && (SIPController.sipCall.responseCode <= 183)) {
- // progressing
- // SERVICE MESSAGE NEEDED
- dialerNotifyRingbackTone(true);
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call progressing.", false);
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_PROGRESSING;
- SIPController.sipCall.callTime_T2 = new Date();
- if (true == SIPController.sipCall.parseRemoteSdp(strMessage)) {
- if ((SIPController.sipCall.sdp != null) && (SIPController.sipCall.sdp.flag == true)) {
- SIPController.sipCall.negotiateAudioCodec();
- }
- if ((SIPController.sipCall.remoteSdp != null) && (SIPController.sipCall.remoteSdp.flag == true) && (SIPController.audioRTPManager != null)) {
- if ((SIPController.sipCall.remoteSdp.audioM != null) && (SIPController.sipCall.remoteSdp.audioM.flag == true)) {
- if (SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- if ((SIPController.sipCall.sdp != null) && (SIPController.sipCall.sdp.audioM != null) && (SIPController.audioRTPManager.rtpCore.bActive == false)) {
- if ((SIPStack.bDirectCall == true) && (BSSVideo.bProgressvideooffer == true)) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(true);
- } else {
- SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 3);
- }
- }
- }
- }
- }
- } else {
- // local ringbacktone play
- // SERVICE MESSAGE NEEDED
- dialerNotifyRingbackTone(true);
- }
- } else if ((SIPController.sipCall.responseCode == 200) && (SIPController.sipCall.CSEQ_NUMBER == sipHeader.callSequenceNumber()) &&
- ((SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING) || (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING) || (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING))) {
- // connected
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Connected.", false);
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_REMOTEACCEPTED;
- SIPController.sipCall.callTime_T3 = new Date();
- boolean ret = sendAck(strMessage);
- if (ret == true) {
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_CONNECTED;
- SIPController.sipCall.callTime_T4 = new Date();
- SIPController.sipCall.callTime_T40 = new Date();
- SIPSound.resetBufferInfo();
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallConnected(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- }
- if (true == SIPController.sipCall.parseRemoteSdp(strMessage)) {
- if ((SIPController.sipCall.sdp != null) && (SIPController.sipCall.sdp.flag == true)) {
- SIPController.sipCall.negotiateAudioCodec();
- }
- if ((SIPController.sipCall.remoteSdp != null) && (SIPController.sipCall.remoteSdp.flag == true) && (SIPController.audioRTPManager != null)) {
- if ((SIPController.sipCall.remoteSdp.audioM != null) && (SIPController.sipCall.remoteSdp.audioM.flag == true)) {
- if (SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- if ((SIPController.sipCall.sdp != null) && (SIPController.sipCall.sdp.audioM != null) && (SIPController.audioRTPManager.rtpCore.bActive == false)) {
- if (SIPStack.bDirectCall == true) {
- if (SIPController.bMobileCall) SIPController.audioRTPManager.RTPRemoteCallInit(SIPController.sipCall.sdp.audioM.mediaPort);
- else SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 4);
- // SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 4);
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(true);
- } else {
- SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 5);
- }
- }
- }
- }
- }
- }
- } else if ((SIPController.sipCall.responseCode == 401) && ((SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING) || (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING))) {
- // Athenticate
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call Unauthorized(401).", false);
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UNAUTHORIZED;
- SIPController.sipCall.authorizationACKH = "";
- sendFinalAck(strMessage);
- if (reactionForWWWAUTHENTICATE(strMessage) == false) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(17);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- dialerNotifyCallFail(SIPController.sipCall.responseCode, SIPController.sipCall.remoteIp, makeSIPID(SIPController.sipCall.remoteIp));
- //SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("Call Unauthorized(401).", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- }
- } else if ((SIPController.sipCall.responseCode == 407) && ((SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING) || (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING))) {
- // Proxy-Athenticate
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call Unauthorized(407).", false);
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UNAUTHORIZED;
- SIPController.sipCall.authorizationACKH = "";
- sendFinalAck(strMessage);
- if (reactionForPROXYAUTHENTICATE(strMessage) == false) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(18);
- if (SIPStack.bDirectCall == true) {
- //SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- dialerNotifyCallFail(SIPController.sipCall.responseCode, SIPController.sipCall.remoteIp, makeSIPID(SIPController.sipCall.remoteIp));
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("Call Unauthorized(407).", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- }
- } else if ((SIPController.sipCall.responseCode == 302) && ((SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING))) {
- // terminating
- // SERVICE MESSAGE NEEDED
- LOG_INFO("[INVITEParser] BSSVideo.HNS_SERVICE_RECEIVER_SELECTED [" + BSSVideo.HNS_SERVICE_RECEIVER_SELECTED + "]");
- LOG_INFO("[INVITEParser] SIPController.sipCall.remoteIp : " + SIPController.sipCall.remoteIp);
- LOG_INFO("[INVITEParser] SIPController.sipCall.number : " + SIPController.sipCall.number);
- LOG_INFO("[INVITEParser] SIPController.sipCall.cid : " + SIPController.sipCall.cid);
- LOG_INFO("[INVITEParser] SIPController.sipCall.dnis : " + SIPController.sipCall.dnis);
- LOG_INFO("[INVITEParser] SIPController.sipCall.dong_number : " + SIPController.sipCall.dong_number);
- LOG_INFO("[INVITEParser] SIPController.sipCall.ho_number : " + SIPController.sipCall.ho_number);
- LOG_INFO("[INVITEParser] SIPController.sipCall.id : " + SIPController.sipCall.id);
- SIPCONTACTHeader contactHeader = new SIPCONTACTHeader(strMessage);
- updateDialerStatus("Call forwarded./" + contactHeader.getSipuri(), true);
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_REDIRECTED;
- sendRedirectFinalAck(strMessage);
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(19);
- if (SIPStack.bDirectCall == true) {
- dialerVideoSet(false);
- }
- SIPController.sipCall.resetCall();
- } else if ((SIPController.sipCall.responseCode >= 300) && ((SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_UNAUTHORIZED) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELLING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_RECANCELLING) ||
- (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELREMOTEACCEPTED))) {
- // terminating
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call rejected by remoter.", true);
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- sendFinalAck(strMessage);
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(20);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- dialerNotifyCallFail(SIPController.sipCall.responseCode, SIPController.sipCall.remoteIp, makeSIPID(SIPController.sipCall.remoteIp));
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("Call rejected by remoter.", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- } else {
- }
- } else {
- }
- } else {
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] INVITEParser(String message, int msgType, String remoteIp, int remotePort)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void ACKParser(String message, int msgType, String remoteIp, int remotePort) {
- boolean bValid = false;
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true) {
- bValid = SIPController.sipCall.isCurrentCall(message);
- }
- if (bValid == true) {
- if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.sipCall.flag == true && SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_HOLD) {
- if (true == cmcore.ACKParser_action_0(SIPController.sipCall, message)) {
- SIPSound.resetBufferInfo();
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallConnected(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- }
- } else if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.sipCall.flag == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_ACCEPTED) {
- if (true == cmcore.ACKParser_action_1(SIPController.sipCall, message)) {
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Connected.", false);
- SIPSound.resetBufferInfo();
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallConnected(SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort);
- }
- } else if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.sipCall.flag == true && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELLED ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_TERMINATING)) {
- //Log.i(TAG, "ACK arrived.");
- if (true == cmcore.ACKParser_action_2(SIPController.sipCall, message)) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(21);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- }
- }
- return;
- }
- if (SIPController.pendingCall != null && SIPController.pendingCall.flag == true) {
- bValid = SIPController.pendingCall.isCurrentCall(message);
- }
- if (bValid == true) {
- if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.pendingCall.flag == true && (SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_CANCELLED ||
- SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_TERMINATING)) {
- SIPController.pendingCall.resetCall();
- }
- }
- return;
- }
- public void CANCELParser(String message, int msgType, String remoteIp, int remotePort) {
- boolean bValid = false;
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true) {
- bValid = SIPController.sipCall.isCurrentCall(message);
- }
- if (bValid == true) {
- if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.sipCall.flag == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- if (true == cmcore.CANCELParser_action_0(SIPController.sipCall, message)) {
- acceptCancelRequest(message, remoteIp, remotePort);
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.RTPEnd(22);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- }
- }
- }
- rejectCall(487);
- }
- } else if (msgType == SIPStack.SIP_MSGTYPE_RESPONSE && SIPController.sipCall.flag == true && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELLING ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_RECANCELLING)) {
- if (true == cmcore.CANCELParser_action_1(SIPController.sipCall, message)) {
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_CANCELREMOTEACCEPTED;
- // none action
- }
- }
- return;
- }
- // Multicall
- if (SIPController.pendingCall != null && SIPController.pendingCall.flag == true) {
- bValid = SIPController.pendingCall.isCurrentCall(message);
- }
- if (bValid == true) {
- if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.pendingCall.flag == true && SIPController.pendingCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- if (true == cmcore.CANCELParser_action_0(SIPController.pendingCall, message)) {
- acceptPendingCancelRequest(message, remoteIp, remotePort);
- rejectPendingCall(487);
- dialerNotifyMulticallCancel(getSIPIDfromMessage(message), remoteIp);
- }
- }
- return;
- }
- }
- private String getSIPIDfromMessage(String strMessage) {
- try {
- String[] strParsed_01 = strMessage.split("Contact: <sip:");
- 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] getSIPIDfromMessage(String strMessage)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- public void BYEParser(String message, int msgType, String remoteIp, int remotePort) {
- try {
- Log.i(TAG, "[BYEParser] msgType [" + msgType + "], remoteIp [" + remoteIp + "], remotePort [" + remotePort + "]");
- if (msgType == SIPStack.SIP_MSGTYPE_REQUEST && SIPController.sipCall.flag == true && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_ACCEPTED ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_REMOTEACCEPTED ||
- SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED)) {
- if (true == cmcore.action_bye_0(SIPController.sipCall, message)) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(23);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- int duration = 0;
- Date currentTime = new Date();
- if (SIPController.sipCall.callTime_T4 != null) {
- duration = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T4.getTime()) / 1000;
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN)
- duration -= 1;
- if (duration < 0) duration = 0;
- }
- sendByeResponse(message, remoteIp, remotePort);
- Log.d(TAG, "[BYEParser] SIPController.sipCall.dnis [" + SIPController.sipCall.dnis + "], SIPController.sipCall.remoteIp [" + SIPController.sipCall.remoteIp + "], SIPController.sipCall.remotePort [" + SIPController.sipCall.remotePort + "]");
- dialerNotifyCallFail(700, remoteIp, makeSIPID(remoteIp));
- //SERVICE MESSAGE NEEDED
- updateDialerStatus("상대가 전화를 끊었습니다.", false);
- //SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("상대가 전화를 끊었습니다.", makeSIPID(remoteIp), makeSIPID(remoteIp) + "@" + remoteIp + ":" + remotePort, false);
- }
- } else if (msgType == SIPStack.SIP_MSGTYPE_RESPONSE && SIPController.sipCall.flag == true && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_DISCONNECTING) {
- if (true == cmcore.action_bye_1(SIPController.sipCall, message)) {
- if (SIPController.audioRTPManager != null)
- SIPController.audioRTPManager.RTPEnd(24);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Ready.", true);
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("Ready.", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] BYEParser(String message, int msgType, String remoteIp, int remotePort)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public int SIPParser(String strMessage, int nMSGType, int nMethodType, String strRemoteIP, int strRemotePort) {
- try {
- if (bPrintSIPMsgIO) {
- Log.i(TAG, "[SIPParser] nMSGType [" + nMSGType + "], nMethodType [" + nMethodType + "], strRemoteIP [" + strRemoteIP + "], strRemotePort [" + strRemotePort + "]");
- printSIPMessage(MESSAGE.RECEIVE, strMessage);
- }
- if (nMethodType == SIPStack.SIP_METHODTYPE_INVITE) {
- // INVITE MESSAGE PROCESSING
- INVITEParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_ACK) {
- // ACK MESSAGE PROCESSING
- ACKParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_OPTIONS) {
- // OPTIONS MESSAGE PROCESSING
- if (nMSGType == SIPStack.SIP_MSGTYPE_REQUEST) {
- sendOptionsResponse(strMessage, strRemoteIP, strRemotePort, 200);
- }
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_INFO) {
- // INFO MESSAGE PROCESSING
- if (true == cmcore.action_info_0(SIPController.sipCall, strMessage, nMSGType)) {
- sendInfoResponse(strMessage, strRemoteIP, strRemotePort, 200);
- }
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_CANCEL) {
- // CANCEL MESSAGE PROCESSING
- CANCELParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_BYE) {
- // BYE MESSAGE PROCESSING
- BYEParser(strMessage, nMSGType, strRemoteIP, strRemotePort);
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_REFER) {
- // REFER
- // IF NEED,CODING NEEDED
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_NOTIFY) {
- // NOTIFY
- // IF NEED,CODING NEEDED
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_MESSAGE) {
- // MESSAGE
- if (nMSGType == SIPStack.SIP_MSGTYPE_REQUEST) {
- sendMessageResponse(strMessage, strRemoteIP, strRemotePort, 200);
- }
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_SUBSCRIBE) {
- // SUBSCRIBE
- // IF NEED,CODING NEEDED
- } else if (nMethodType == SIPStack.SIP_METHODTYPE_PRACK) {
- // PRACK
- // IF NEED,CODING NEEDED
- }
- return 0;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -1;
- } catch (Exception e) {
- Log.e(TAG, "SIPParser(String strMessage, int nMSGType, int nMethodType, String strRemoteIP, int strRemotePort)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -1;
- }
- }
- public void registRTPManager(RTPManager rtpmanager, int mediaType) {
- if (mediaType == SIPStack.SIP_MEDIATYPE_AUDIO) {
- SIPController.audioRTPManager = rtpmanager;
- if (SIPStack.SIP_MESSAGE_DEBUG == true)
- Log.i(TAG, "AUDIO RTPMANAGER SET Notified to RegisterManager.");
- }
- }
- public boolean sendRegister() {
- if (cmcore.makeRegister() == true) {
- if (cmcore.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = cmcore.message.getBytes();
- if (cmcore.message.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, cmcore.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(cmcore.serverIp, cmcore.serverPort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- cmcore.regTime = new Date();
- }
- }
- return true;
- }
- return false;
- }
- public boolean sendUNRegister() {
- if (cmcore.makeUNRegister() == true) {
- if (cmcore.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = cmcore.message.getBytes();
- if (cmcore.message.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, cmcore.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(cmcore.serverIp, cmcore.serverPort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- cmcore.regTime = new Date();
- }
- }
- return true;
- }
- return false;
- }
- public boolean sendUNRegister(String contactip, int contactport) {
- if (cmcore.makeUNRegister(contactip, contactport) == true) {
- if (cmcore.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = cmcore.message.getBytes();
- if (cmcore.message.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, cmcore.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(cmcore.serverIp, cmcore.serverPort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- cmcore.regTime = new Date();
- }
- }
- return true;
- }
- return false;
- }
- public boolean decideRegister() {
- Date currentDate = new Date();
- int seconds = (int) (currentDate.getTime() - cmcore.regTime.getTime()) / 1000;
- if (seconds > cmcore.expiresSeconds - 10) return true;
- else return false;
- }
- public boolean callActivate(String number) {
- if (SIPController.sipCall == null) return false;
- String dial = "";
- if (SIPController.sipCall.flag == false) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Calling to " + number, false);
- if (number.length() > 32) {
- dial = number.substring(0, 32);
- } else {
- dial = new String(number);
- }
- return callMake(dial);
- } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Incoming call accept.", false);
- return sendAccept();
- }
- return false;
- }
- public boolean directcallActivate(String strNumber, boolean bMobile) {
- try {
- LOG_DEBUG("[directcallActivate] strNumber [" + strNumber + "], bMobile [" + bMobile + "]");
- if (SIPController.sipCall == null) {
- LOG("[directcallActivate] SIPController.sipCall is null!!");
- return false;
- }
- String dial = "";
- LOG_DEBUG("[directcallActivate] SIPController.sipCall.flag = " + SIPController.sipCall.flag);
- if (SIPController.sipCall.flag == false) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Calling to " + strNumber, false);
- if (strNumber.length() > 32) {
- dial = strNumber.substring(0, 32);
- } else {
- dial = new String(strNumber);
- }
- return directcallMake(dial);
- } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Incoming call accept.", false);
- return directsendAccept(bMobile);
- }
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] directcallActivate(String strNumber)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- public boolean callMake(String number) {
- if (cmcore.regState != SIPStack.SIP_REGSTATE_REGISTERED) {
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("Not registered.", "", "", true);
- return false;
- }
- if (true == cmcore.makeCallMake(SIPController.sipCall, number)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T0 = new Date();
- SIPController.sipCall.callTime_T00 = new Date();
- SIPController.sipCall.invitingTimes++;
- return true;
- }
- }
- return false;
- }
- public boolean directcallMake(String number) {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == true) return false;
- if (true == cmcore.makeDirectcallMake(SIPController.sipCall, number)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- // INVITING
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T0 = new Date();
- SIPController.sipCall.callTime_T00 = new Date();
- SIPController.sipCall.invitingTimes++;
- }
- return true;
- }
- return false;
- }
- public boolean sendReInvite() {
- if (true == cmcore.makeSendReInvite(SIPController.sipCall)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T00 = new Date();
- SIPController.sipCall.invitingTimes++;
- return true;
- }
- }
- return false;
- }
- public boolean sendRepeatInvite() {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (SIPController.sipCall.message == null || SIPController.sipCall.message.length() == 0)
- return false;
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (SIPController.sipCall.message.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T00 = new Date();
- SIPController.sipCall.invitingTimes++;
- }
- }
- return true;
- }
- public boolean sendRedirectCall(String message) {
- if (true == cmcore.makeSendRedirectCall(SIPController.sipCall, message)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = new byte[SIPController.sipCall.message.length()];
- SIPController.sipCall.message.getBytes(0, SIPController.sipCall.message.length(), buffer, 0);
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_INVITING;
- SIPController.sipCall.callDirection = SIPStack.SIP_CALLDIRECTION_OUT;
- SIPController.sipCall.callTime_T0 = new Date();
- SIPController.sipCall.invitingTimes++;
- return true;
- }
- } else {
- SIPController.sipCall.resetCall();
- }
- return false;
- }
- public boolean reactionForWWWAUTHENTICATE(String message) {
- if (true == cmcore.makeReactionForWWWAUTHENTICATE(SIPController.sipCall, message)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T0 = new Date();
- SIPController.sipCall.callTime_T00 = new Date();
- return true;
- }
- }
- return false;
- }
- public boolean reactionForPROXYAUTHENTICATE(String message) {
- if (true == cmcore.makeReactionForPROXYAUTHENTICATE(SIPController.sipCall, message)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T0 = new Date();
- SIPController.sipCall.callTime_T00 = new Date();
- return true;
- }
- }
- return false;
- }
- public boolean sendProceeding(String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeSendProceeding(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- }
- return true;
- }
- //MultiCall Proceeding
- public boolean sendPendingProceeding(String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeSendProceeding(SIPController.pendingCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.pendingCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- }
- return true;
- }
- public boolean sendProgressing(String remoteIp, int remotePort) {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- String sendmessage = cmcore.makeSendProgressing(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- }
- return true;
- }
- //Multicall Progressing
- public boolean sendPendingProgressing(String remoteIp, int remotePort) {
- if (SIPController.pendingCall == null || SIPController.pendingCall.flag == false)
- return false;
- String sendmessage = cmcore.makeSendProgressing(SIPController.pendingCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.pendingCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- }
- return true;
- }
- public boolean sendProgressingwithbody(String remoteIp, int remotePort) {
- Log.d(TAG, "[sendProgressingwithbody] remoteIp [" + remoteIp + "], remotePort [" + remotePort + "]");
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- String sendmessage = cmcore.makeSendProgressingwithbody(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(true);
- }
- }
- }
- }
- }
- }
- }
- return true;
- }
- public boolean sendProgressingBlackcallwithbody(String remoteIp, int remotePort) {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED) {
- String sendmessage = cmcore.makeSendProgressingwithbody(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- //if(SIPStack.bDirectCall==true) {
- //SERVICE MESSAGE NEEDED
- // dialerVideoSet(true);
- //}
- }
- }
- }
- }
- }
- }
- return true;
- }
- public boolean acceptCancelRequest(String strMessage, String strRemoteIP, int strRemotePort) {
- try {
- LOG("[acceptCancelRequest] strMessage [" + strMessage + "], strRemoteIP [" + strRemoteIP + "], strRemotePort [" + strRemotePort + "]");
- String strSendMessage = cmcore.makeAcceptCancelRequest(SIPController.sipCall, strMessage);
- if (strSendMessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = strSendMessage.getBytes();
- if (strSendMessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, strMessage);
- SIPController.sipCall.callTime_T8 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(strRemoteIP, strRemotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "acceptCancelRequest(String strMessage, String strRemoteIP, int strRemotePort)");
- return false;
- }
- }
- public boolean acceptPendingCancelRequest(String message, String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeAcceptCancelRequest(SIPController.pendingCall, message);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- // if (SIPStack.SIP_MESSAGE_DEBUG == true) Log.i(TAG, "SENT\n" + sendmessage);
- SIPController.pendingCall.callTime_T8 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- return false;
- }
- public boolean sendAccept() {
- Log.d(TAG, "[sendAccept]");
- String sendmessage = cmcore.makeSendAccept(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T3 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_ACCEPTED;
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 6);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(true);
- }
- }
- }
- }
- }
- return true;
- } else return false;
- }
- public boolean directsendAccept(boolean bMobile) {
- try {
- LOG_INFO("[directsendAccept] bMobile [" + bMobile + "]");
- String sendmessage = cmcore.makeDirectsendAccept(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (sendmessage.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T3 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_ACCEPTED;
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- LOG_INFO("[directsendAccept] SIPController.audioRTPManager.rtpCore.bActive [" + SIPController.audioRTPManager.rtpCore.bActive + "]");
- if (SIPController.audioRTPManager.rtpCore.bActive == false) {
- if (bMobile) SIPController.audioRTPManager.RTPRemoteCallInit(SIPController.sipCall.sdp.audioM.mediaPort);
- else SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 7);
- }
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(true);
- }
- }
- }
- }
- }
- return true;
- }
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] directsendAccept()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- public boolean sendUpdateAccept() {
- Log.d(TAG, "[sendUpdateAccept]");
- String sendmessage = cmcore.makeSendUpdateAccept(SIPController.sipCall);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_UPDATEACCEPTED;
- if (SIPController.sipCall.remoteSdp != null && SIPController.sipCall.remoteSdp.flag == true && SIPController.audioRTPManager != null) {
- if (SIPController.sipCall.remoteSdp.audioM != null && SIPController.sipCall.remoteSdp.audioM.flag == true) {
- if (SIPController.audioRTPManager != null) {
- SIPController.audioRTPManager.setRemoteMediaInfo(SIPController.sipCall.remoteSdp.audioM.commonCodec, SIPController.sipCall.remoteSdp.audioM.mediaIp, SIPController.sipCall.remoteSdp.audioM.mediaPort);
- if (SIPController.sipCall.sdp != null && SIPController.sipCall.sdp.audioM != null && SIPController.audioRTPManager.rtpCore.bActive == false) {
- SIPController.audioRTPManager.RTPInit(SIPController.sipCall.sdp.audioM.mediaPort, 8);
- }
- }
- }
- }
- return true;
- }
- return false;
- }
- public boolean rejectCall(int code) {
- String sendmessage = cmcore.makeRejectCall(SIPController.sipCall, code);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- Log.i(TAG, "rejectCall code : " + code);
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call reject.", true);
- return true;
- }
- return false;
- }
- public boolean redirectResponse(String contact) {
- String sendmessage = cmcore.makeRejectCall(SIPController.sipCall, 302, contact);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call reject.", true);
- return true;
- }
- return false;
- }
- public boolean rejectPendingCall(int code) {
- Log.i("SIPStun", ">>>rejectPendingCall debug 1 " + SIPController.pendingCall.remoteIp + " port:" + SIPController.pendingCall.remotePort);
- String sendmessage = cmcore.makeRejectCall(SIPController.pendingCall, code);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.pendingCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.pendingCall.remoteIp, SIPController.pendingCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.pendingCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- }
- return true;
- }
- public boolean rejectCall(String message, int code, String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeRejectCall(message, code, cmcore.localIp, cmcore.localPort, remoteIp, remotePort);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- public boolean redirectIncomingCall(String redirectId) {
- String sendmessage = cmcore.makeRedirectIncomingCall(SIPController.sipCall, redirectId);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call forwarding to " + redirectId, true);
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_TERMINATING;
- return true;
- }
- return false;
- }
- public boolean sendProgressing(String body, String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeSendProgressing(SIPController.sipCall, body);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- public boolean sendAck(String message) {
- if (true == cmcore.makeSendAck(SIPController.sipCall, message)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- SIPController.sipCall.callTime_T4 = new Date();
- SIPController.sipCall.callTime_T40 = new Date();
- if (SIPController.sipCall.routeIp != null && SIPController.sipCall.routeIp.length() > 0 && SIPController.sipCall.routePort > 0) {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.routeIp, SIPController.sipCall.routePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- } else {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- }
- return false;
- }
- public boolean sendFinalAck(String message) {
- if (true == cmcore.makeSendFinalAck(SIPController.sipCall, message)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- // if (SIPStack.SIP_MESSAGE_DEBUG == true) Log.i(TAG, "SEND\n" + SIPController.sipCall.message);
- if (SIPController.sipCall.routeIp != null && SIPController.sipCall.routeIp.length() > 0 && SIPController.sipCall.routePort > 0) {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.routeIp, SIPController.sipCall.routePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.routeIp, SIPController.sipCall.routePort, buffer, buffer.length);
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.routeIp, SIPController.sipCall.routePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- } else {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- }
- return false;
- }
- public boolean sendFinalAck(String message, String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeSendFinalAck(SIPController.sipCall, message, remoteIp, remotePort);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- if (remoteIp != null && remoteIp.length() > 0 && remotePort > 0) {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length);
- mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length);
- break;
- }
- }
- return true;
- }
- }
- return false;
- }
- public boolean sendRedirectFinalAck(String message) {
- if (true == cmcore.makeSendRedirectFinalAck(SIPController.sipCall, message)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- if (SIPController.sipCall.routeIp != null && SIPController.sipCall.routeIp.length() > 0 && SIPController.sipCall.routePort > 0) {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.routeIp, SIPController.sipCall.routePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- } else {
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- }
- return false;
- }
- // REJECT OR BYE OR CANCEL
- public boolean callTerminate() {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) {
- return false;
- }
- SIPController.sipCall.bCancelRequest = false;
- if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_ACCEPTED || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_REMOTEACCEPTED) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call disconnecting./" + SIPController.sipCall.dnis, false);
- int duration = 0;
- Date currentTime = new Date();
- if (SIPController.sipCall.callTime_T4 != null) {
- duration = (int) (currentTime.getTime() - SIPController.sipCall.callTime_T4.getTime()) / 1000;
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN)
- duration -= 1;
- if (duration < 0) duration = 0;
- }
- if (SIPController.audioRTPManager != null) SIPController.audioRTPManager.RTPEnd(25);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- return sendBye();
- } else if (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_INVITING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROCEEDING || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_PROGRESSING) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- updateDialerStatus("Call cancelling./" + SIPController.sipCall.dnis, false);
- rejectPendingCall(480);
- //rejectCall(486);
- if (SIPController.audioRTPManager != null) SIPController.audioRTPManager.RTPEnd(26);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- return sendCancel();
- } else if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED || SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CANCELLED)) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- if (SIPController.bSinglecallBusyResponse == true) {
- SIPController.bSinglecallBusyResponse = false;
- updateDialerStatus("Busy Call reject./" + SIPController.sipCall.dnis, false);
- return rejectCall(486);
- } else {
- updateDialerStatus("Call reject./" + SIPController.sipCall.dnis, false);
- return rejectCall(480);
- }
- } else if (SIPController.sipCall.flag == true && SIPController.sipCall.callState != SIPStack.SIP_CALLSTATE_TERMINATING) {
- if (SIPController.audioRTPManager != null) SIPController.audioRTPManager.RTPEnd(27);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- } else {
- Log.e(TAG, "[callTerminate] NO IF");
- }
- return true;
- }
- // Redirect response
- public boolean redirectTerminate(String contact) {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) {
- return false;
- }
- LOG_INFO("[redirectTerminate] contact [" + contact + "]");
- SIPController.sipCall.bForwardRequest = false;
- if (SIPController.sipCall.callDirection == SIPStack.SIP_CALLDIRECTION_IN && (SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_OFFERRED)) {
- // Phone status set
- // SERVICE MESSAGE NEEDED
- LOG_INFO("[redirectTerminate] BSSVideo.HNS_SERVICE_RECEIVER_SELECTED [" + BSSVideo.HNS_SERVICE_RECEIVER_SELECTED + "]");
- LOG_INFO("[redirectTerminate] SIPController.sipCall.remoteIp : " + SIPController.sipCall.remoteIp);
- LOG_INFO("[redirectTerminate] SIPController.sipCall.number : " + SIPController.sipCall.number);
- LOG_INFO("[redirectTerminate] SIPController.sipCall.cid : " + SIPController.sipCall.cid);
- LOG_INFO("[redirectTerminate] SIPController.sipCall.dnis : " + SIPController.sipCall.dnis);
- LOG_INFO("[redirectTerminate] SIPController.sipCall.dong_number : " + SIPController.sipCall.dong_number);
- LOG_INFO("[redirectTerminate] SIPController.sipCall.ho_number : " + SIPController.sipCall.ho_number);
- LOG_INFO("[redirectTerminate] SIPController.sipCall.id : " + SIPController.sipCall.id);
- updateDialerStatus("Call forwarded.", false);
- return redirectResponse(contact);
- } else if (SIPController.sipCall.flag == true && SIPController.sipCall.callState != SIPStack.SIP_CALLSTATE_TERMINATING) {
- if (SIPController.audioRTPManager != null) SIPController.audioRTPManager.RTPEnd(28);
- if (SIPStack.bDirectCall == true) {
- // SERVICE MESSAGE NEEDED
- dialerVideoSet(false);
- }
- // SERVICE MESSAGE NEEDED
- dialerNotifyCallEnd("", SIPController.sipCall.dnis, SIPController.sipCall.dnis + "@" + SIPController.sipCall.remoteIp + ":" + SIPController.sipCall.remotePort, false);
- SIPController.sipCall.resetCall();
- }
- return true;
- }
- // BYE
- public boolean sendBye() {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (true == cmcore.makeBye(SIPController.sipCall)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (SIPController.sipCall.message.length() > 0) {
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- SIPController.sipCall.callTime_T5 = new Date();
- SIPController.sipCall.callTime_T6 = new Date();
- SIPController.sipCall.callTime_T9 = new Date();
- SIPController.sipCall.bByedisconnected = true;
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_DISCONNECTING;
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- }
- }
- return true;
- }
- return false;
- }
- public boolean resendBye() {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (SIPController.sipCall.callState != SIPStack.SIP_CALLSTATE_DISCONNECTING) return false;
- if (true == cmcore.makeReBye(SIPController.sipCall)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (SIPController.sipCall.message.length() > 0) {
- if (bPrintSIPMsg)
- printSIPMessage(MESSAGE.RESEND, SIPController.sipCall.message);
- SIPController.sipCall.callTime_T9 = new Date();
- SIPController.sipCall.bByedisconnected = true;
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- }
- }
- return true;
- }
- return false;
- }
- public boolean sendByeResponse(String message, String remoteIp, int remotePort) {
- String sendmessage = cmcore.makeSendByeResponse(SIPController.sipCall, message);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- // if (SIPStack.SIP_MESSAGE_DEBUG == true) Log.i(TAG, "SENT\n" + sendmessage);
- SIPController.sipCall.callTime_T6 = new Date();
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length);
- mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length);
- break;
- }
- repeatSendCount++;
- }
- }
- return true;
- }
- // CANCEL
- public boolean sendCancel() {
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (true == cmcore.makeCancel(SIPController.sipCall)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- // if (SIPStack.SIP_MESSAGE_DEBUG == true) Log.i(TAG, "SEND\n" + SIPController.sipCall.message);
- SIPController.sipCall.callTime_T8 = new Date();
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_CANCELLING;
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- return true;
- }
- }
- return false;
- }
- public boolean sendRecancel() {
- //Log.i(TAG, "RECANCELLING");
- if (SIPController.sipCall == null || SIPController.sipCall.flag == false) return false;
- if (true == cmcore.makeRecancel(SIPController.sipCall)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- // if (SIPStack.SIP_MESSAGE_DEBUG == true) Log.i(TAG, "SEND\n" + SIPController.sipCall.message);
- SIPController.sipCall.callTime_T8 = new Date();
- SIPController.sipCall.callState = SIPStack.SIP_CALLSTATE_RECANCELLING;
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- return true;
- }
- }
- return false;
- }
- // OPTIONS
- public boolean sendOptionsResponse(String message, String remoteIp, int remotePort, int code) {
- String sendmessage = cmcore.makeSendOptionsResponse(SIPController.sipCall, message, code);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- return true;
- }
- return false;
- }
- //INFO
- public boolean sendInfoResponse(String message, String remoteIp, int remotePort, int code) {
- String sendmessage = cmcore.makeSendInfoResponse(SIPController.sipCall, message, code);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- } else return false;
- // DTMF PARSE
- SIPHeader sipHeader = new SIPHeader(message, SIPStack.SIP_HEADERTYPE_CONTENTTYPE);
- if (sipHeader != null && sipHeader.flag == true && sipHeader.headerValue != null && sipHeader.headerValue.length() > 0) {
- if (sipHeader.headerValue.compareTo("application/dtmf-relay") == 0) {
- // DTMF-RELAY TYPE
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.parseDtmfSdp(message, SIPStack.SIP_DTMFINFO_DTMFRELAY) == true) {
- // SERVICE MESSAGE NEEDED
- dialerNotifyDtmf(SIPController.sipCall.detectedDtmf);
- }
- } else if (sipHeader.headerValue.compareTo("application/dtmf") == 0) {
- // DTMF TYPE
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.parseDtmfSdp(message, SIPStack.SIP_DTMFINFO_DTMF) == true) {
- // SERVICE MESSAGE NEEDED
- dialerNotifyDtmf(SIPController.sipCall.detectedDtmf);
- }
- }
- }
- return true;
- }
- // OPTIONS
- public boolean sendMessageResponse(String message, String remoteIp, int remotePort, int code) {
- String sendmessage = cmcore.makeSendInfoResponse(SIPController.sipCall, message, code);
- if (sendmessage.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = sendmessage.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, sendmessage);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(remoteIp, remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- return true;
- }
- return false;
- }
- public boolean sendUpdate() {
- if (true == cmcore.makeSendUpdate(SIPController.sipCall)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T0 = new Date();
- return true;
- }
- }
- return false;
- }
- public boolean sendUpdate(String flow) {
- if (true == cmcore.makeSendUpdate(SIPController.sipCall, flow)) {
- if (SIPController.sipCall.message.length() > 0 && mSIPSignalReceiver != null) {
- byte[] buffer = SIPController.sipCall.message.getBytes();
- if (bPrintSIPMsg) printSIPMessage(MESSAGE.SEND, SIPController.sipCall.message);
- int repeatSendCount = 0;
- while (repeatSendCount < SIPStack.REPEAT_SENDCOUNT) {
- if (buffer.length == mSIPSignalReceiver.BSSSipSendUdpPacket(SIPController.sipCall.remoteIp, SIPController.sipCall.remotePort, buffer, buffer.length)) {
- break;
- }
- repeatSendCount++;
- }
- SIPController.sipCall.callTime_T0 = new Date();
- return true;
- }
- }
- return false;
- }
- public void sendHold() {
- if (SIPController.sipCall != null && SIPController.sipCall.flag == true && SIPController.sipCall.callMode == SIPStack.SIP_CALLMODE_BASIC && SIPController.sipCall.callState == SIPStack.SIP_CALLSTATE_CONNECTED) {
- if (SIPController.sipCall.bHolding == true) {
- SIPController.sipCall.bHolding = false;
- sendUpdate("sendrecv");
- if (SIPController.sipSound != null)
- SIPController.sipSound.flowIndicator = SIPStack.SIP_MEDIAFLOW_SENDRECV;
- } else {
- SIPController.sipCall.bHolding = true;
- sendUpdate();
- if (SIPController.sipSound != null)
- SIPController.sipSound.flowIndicator = SIPStack.SIP_MEDIAFLOW_SENDONLY;
- }
- }
- }
- public void updateDialerStatus(String arg1, boolean bSet) {
- Log.d(TAG, "[updateDialerStatus] arg1 [" + arg1 + "], bSet [" + bSet + "]");
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("UPDATESTATUS", arg1);
- Message msg = null;
- if (bSet == true)
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_UPDATESTATUS_TRUE);
- else msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_UPDATESTATUS_FALSE);
- msg.setData(b);
- mClients.get(i).send(msg);
- // Log.d(TAG, "[updateDialerStatus]" + MainActivity.mCallController.mCallInfo.getRESI().toString());
- // if(MainActivity.mCallController.mCallInfo.getRESI() == CallManager.CALLSTATUS.IDLE) {
- // Log.d(TAG, "[updateDialerStatus]" + MainActivity.mCallController.mCallInfo.getRESI().toString());
- //rejectPendingCall(480);
- //rejectCall(m_strMessage, 487, m_strRemoteIP, m_strRemotePort);
- //Thread.sleep(1000);
- // }
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] updateDialerStatus(String arg1, boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] updateDialerStatus(String arg1, boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void dialerVideoSet(boolean bSet) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("VIDEOSET", SIPController.sipCall.dnis);
- Message msg = null;
- if (bSet == true)
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_VIDEOSET_TRUE);
- else msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_VIDEOSET_FALSE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerVideoSet(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerVideoSet(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void dialerNotifyIncomingCall(String dn, String uri) {
- Log.i(TAG, "[dialerNotifyIncomingCall] dn [" + dn + "], uri [" + uri + "], mClients.size() [" + mClients.size() + "]");
- int nCnt = 0;
- while (mClients.size() == 0) {
- if (nCnt == 5) continue;
- nCnt++;
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- Log.e(TAG, "[InterruptedException] dialerNotifyIncomingCall(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("INCOMINGCALL", dn + ";" + uri);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_INCOMINGCALL);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyIncomingCall(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyIncomingCall(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void dialerNotifyIncomingMultiCall(String dn, String uri) {
- // 멀티콜 사용을 위해 콜 정보를 임시로 저장한다.
- getMultiCallInfo();
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("INCOMINGMULTICALL", dn + ";" + uri);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_INCOMINGMULTICALL);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyIncomingMultiCall(String dn,String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyIncomingMultiCall(String dn,String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- private void getMultiCallInfo() {
- try {
- Log.d(TAG, "[getMultiCallInfo] SIPController.sipCall.bPending = " + SIPController.sipCall.bPending);
- Log.d(TAG, "[getMultiCallInfo] SIPController.sipCall.remoteIp = " + SIPController.sipCall.remoteIp);
- Log.d(TAG, "[getMultiCallInfo] SIPController.sipCall.remoteContactUri = " + SIPController.sipCall.remoteContactUri);
- Log.d(TAG, "[getMultiCallInfo] SIPController.sipCall.remoteContactIp = " + SIPController.sipCall.remoteContactIp);
- Log.d(TAG, "[getMultiCallInfo] SIPController.sipCall.cid = " + SIPController.sipCall.cid);
- Log.d(TAG, "[getMultiCallInfo] SIPController.sipCall.dnis = " + SIPController.sipCall.dnis);
- Log.d(TAG, "[getMultiCallInfo] SIPController.pendingCall.bPending = " + SIPController.pendingCall.bPending);
- Log.d(TAG, "[getMultiCallInfo] SIPController.pendingCall.remoteIp = " + SIPController.pendingCall.remoteIp);
- Log.d(TAG, "[getMultiCallInfo] SIPController.pendingCall.remoteContactUri = " + SIPController.pendingCall.remoteContactUri);
- Log.d(TAG, "[getMultiCallInfo] SIPController.pendingCall.remoteContactIp = " + SIPController.pendingCall.remoteContactIp);
- Log.d(TAG, "[getMultiCallInfo] SIPController.pendingCall.cid = " + SIPController.pendingCall.cid);
- Log.d(TAG, "[getMultiCallInfo] SIPController.pendingCall.dnis = " + SIPController.pendingCall.dnis);
- SIPController.MultiCall = new SIPCall();
- SIPController.MultiCall = SIPController.pendingCall;
- Log.d(TAG, "[getMultiCallInfo] SIPController.MultiCall.bPending = " + SIPController.MultiCall.bPending);
- Log.d(TAG, "[getMultiCallInfo] SIPController.MultiCall.remoteIp = " + SIPController.MultiCall.remoteIp);
- Log.d(TAG, "[getMultiCallInfo] SIPController.MultiCall.remoteContactUri = " + SIPController.MultiCall.remoteContactUri);
- Log.d(TAG, "[getMultiCallInfo] SIPController.MultiCall.remoteContactIp = " + SIPController.MultiCall.remoteContactIp);
- Log.d(TAG, "[getMultiCallInfo] SIPController.MultiCall.cid = " + SIPController.MultiCall.cid);
- Log.d(TAG, "[getMultiCallInfo] SIPController.MultiCall.dnis = " + SIPController.MultiCall.dnis);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getMultiCallInfo()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void dialerNotifyCallConnected(String dn, String uri) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("CALLCONNECTED", dn + ";" + uri);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_CALLCONNECTED);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyCallConnected(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyCallConnected(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void dialerNotifyBackgroundIncomingCall(String dn, String uri) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("BACKGROUNDINCOMINGCALL", dn + ";" + uri);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_BACKGROUNDINCOMINGCALL);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyBackgroundIncomingCall(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyBackgroundIncomingCall(String dn, String uri)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- // shutdownApplication()
- public void dialerShutdownApplication() {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("SHUTDOWNAPPLICATION", "");
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_SHUTDOWNAPPLICATION);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerShutdownApplication()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerShutdownApplication()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- // vibrator(boolean bSet)
- public void dialerVibrator(boolean bSet) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("VIBRATOR", "null");
- Message msg = null;
- if (bSet == true)
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_VIBRATOR_TRUE);
- else msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_VIBRATOR_FALSE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerVibrator(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerVibrator(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- // registStatus(SIPStack.bNetworkActive);
- public void dialerRegistStatus(boolean bSet) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("REGISTSTATUS", "null");
- Message msg = null;
- if (bSet == true)
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_REGISTSTATUS_TRUE);
- else msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_REGISTSTATUS_FALSE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerRegistStatus(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerRegistStatus(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- // notifyRingbackTone(false)
- public void dialerNotifyRingbackTone(boolean bSet) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("RINGBACKTONE", SIPController.sipCall.dnis);
- Message msg = null;
- if (bSet == true)
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_RINGBACKTONE_TRUE);
- else msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_RINGBACKTONE_FALSE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyRingbackTone(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyRingbackTone(boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- // notifyCallEnd(value, false);
- public void dialerNotifyCallEnd(String status, String dn, String uri, boolean bSet) {
- Log.d(TAG, "[dialerNotifyCallEnd] status: " + status);
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("CALLEND", status + ";" + dn + ";" + uri);
- Message msg = null;
- if (bSet == true)
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_CALLEND_TRUE);
- else msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_CALLEND_FALSE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyCallEnd(String status, String dn, String uri, boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyCallEnd(String status, String dn, String uri, boolean bSet)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- if (SIPStun.bBlackCall == true) {
- SIPStun.bBlackCall = false;
- if (SIPStun.bBlackCallSupport == true) SIPStack.bShutdownApplication = true;
- }
- }
- // dialerNotifyCallFail(SIPController.sipCall.responseCode,SIPController.sipCall.remoteIp);
- public void dialerNotifyCallFail(int finalCode, String remoteip, String uri) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("CALLFAIL", finalCode + "|" + remoteip + "|" + uri);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_OUTCALLFAIL);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyCallFail(int finalCode, String remoteip)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyCallFail(int finalCode, String remoteip)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- //notifyDtmf(SIPController.sipCall.detectedDtmf);
- public void dialerNotifyDtmf(int dtmf) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("OUTBANDDTMF", dtmf + "");
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_OUTBANDDTMF);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyDtmf(int dtmf)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyDtmf(int dtmf)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void dialerPadNumber(String number) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("PADNUMBER", number);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_PADNUMBER);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerPadNumber(String number)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerPadNumber(String number)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- public void dialerPadType(int padType, int officeNumber) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- String value = padType + "." + officeNumber;
- b.putString("PADTYPE", value);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_PADTYPE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerPadType(int padType, int officeNumber)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerPadType(int padType, int officeNumber)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- // BSSSIPStun_ICONTROLS_CM_CANCELMULTICALL
- public void dialerNotifyMulticallCancel(String dn, String uri) {
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("CANCELMULTICALL", dn + ";" + uri);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_CM_CANCELMULTICALL);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] dialerNotifyMulticallCancel()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] dialerNotifyMulticallCancel()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- enum MESSAGE {
- SEND, // 전송
- RESEND, // 재전송
- RECEIVE, // 수신
- }
- boolean bPrintSIPMsg = true;
- boolean bPrintSIPMsgIO = false;
- private void printSIPMessage(MESSAGE eType, String strMessage) {
- try {
- Log.w(TAG, "[printSIPMessage] eType [" + eType + "]");
- Log.d(TAG, strMessage);
- Log.w(TAG, "[printSIPMessage] End of SIP message");
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] printSIPMessage(MESSAGE eType, String strMessage)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public static class DeviceString {
- public static String strType_Resi = "Resi";
- public static String strType_RentResi = "RentResi";
- public static String strType_Lobby = "Lobby";
- public static String strType_Guard = "Guard";
- public static String strType_Ihub = "Ihub";
- }
- public String[] makeDeviceName(String ipaddress) {
- String[] aDeviceName = new String[3];
- try {
- String dong = "101";
- String ho = "101";
- String type = DeviceString.strType_Resi;
- String[] IP_Parse = ipaddress.split("\\.");
- dong = Integer.toString((((Integer.parseInt(getDongString()) / 100) * 100) + Integer.parseInt(IP_Parse[1])));
- if (IP_Parse[2] == "128") {
- // 경비실폰
- type = DeviceString.strType_Guard;
- ho = IP_Parse[3];
- } else if (IP_Parse[2] == "0") {
- // 로비폰
- type = DeviceString.strType_Lobby;
- ho = IP_Parse[3];
- } else {
- int nIP_DClass = Integer.parseInt(IP_Parse[3]);
- if (nIP_DClass < 200) {
- // 메인 세대 월패드
- type = DeviceString.strType_Resi;
- } else {
- // 분리 세대 월패드
- type = DeviceString.strType_RentResi;
- nIP_DClass = nIP_DClass - 200;
- }
- ho = IP_Parse[2] + ZeroPadding_Head(2, Integer.toString(nIP_DClass));
- }
- aDeviceName[0] = type;
- aDeviceName[1] = dong;
- aDeviceName[2] = ho;
- return aDeviceName;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return aDeviceName;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] makeDeviceName(String ipaddress)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return aDeviceName;
- }
- }
- public String makeSIPID(String strIPAddress) {
- try {
- LOG_INFO("[makeSIPID] strIPAddress : " + strIPAddress);
- String SIPID = "12345678_Resi_0101_0101_01";
- String dong = "101";
- String ho = "101";
- String strType = DeviceString.strType_Resi;
- String strDeviceCnt = "01";
- String[] IP_Parse = strIPAddress.split("\\.");
- if (IP_Parse != null) {
- dong = Integer.toString((((Integer.parseInt(getDongString()) / 100) * 100) + Integer.parseInt(IP_Parse[1])));
- if (IP_Parse[2].equals("128")) {
- // 경비실폰
- strType = DeviceString.strType_Guard;
- ho = IP_Parse[3];
- } else if (IP_Parse[2].equals("0")) {
- // 로비폰
- strType = DeviceString.strType_Lobby;
- ho = IP_Parse[3];
- } else if (IP_Parse[2].equals("201")) {
- // 아이허브
- strType = DeviceString.strType_Ihub;
- ho = IP_Parse[3];
- } else {
- int nIP_DClass = Integer.parseInt(IP_Parse[3]);
- if (nIP_DClass < 200) {
- // 메인 세대 월패드
- strType = DeviceString.strType_Resi;
- } else {
- // 분리 세대 월패드
- strType = DeviceString.strType_RentResi;
- nIP_DClass = nIP_DClass - 200;
- }
- ho = IP_Parse[2] + ZeroPadding_Head(2, Integer.toString(nIP_DClass));
- }
- SIPID = ZeroPadding_Head(8, getSitecodeString()) + "_" + strType + "_" + ZeroPadding_Head(4, dong) + "_" + ZeroPadding_Head(4, ho) + "_" + strDeviceCnt;
- LOG_INFO("[makeSIPID] SIPID : " + SIPID);
- return SIPID;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] MakeSIPID(...) : " + e);
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return "ERROR";
- }
- private String getSitecodeString() {
- try {
- String strResult = "";
- WallpadDeviceSet Devset = new WallpadDeviceSet(this);
- String[] getData = Devset.GetSettingData("site_code");
- Devset.closeDB();
- if ((getData != null) && getData.length > 1) {
- strResult = getData[1];
- }
- LOG("[getSitecodeString] strResult [" + strResult + "]");
- return strResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getSitecodeString()");
- return null;
- }
- }
- private String getDongString() {
- try {
- String strResult = "";
- wallpaddbmgr DBMGR = new wallpaddbmgr(this);
- AddressSet Addr = DBMGR.getAddressMGR();
- DBMGR.closeDB();
- strResult = Addr.Dong;
- LOG("[getDongString] strResult [" + strResult + "]");
- return strResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getDongString()");
- return null;
- }
- }
- private String getHoString() {
- try {
- String strResult = "";
- wallpaddbmgr DBMGR = new wallpaddbmgr(this);
- AddressSet Addr = DBMGR.getAddressMGR();
- DBMGR.closeDB();
- strResult = Addr.Ho;
- LOG("[getHoString] strResult [" + strResult + "]");
- return strResult;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getHoString()");
- return null;
- }
- }
- public static String ZeroPadding_Head(int nOutLength, String strOriginalString) {
- String strResult = strOriginalString;
- try {
- if (strOriginalString.length() < nOutLength) {
- for (int i = strOriginalString.length(); i < nOutLength; i++) {
- strResult = "0" + strResult;
- }
- return strResult;
- } else if (strOriginalString.length() == nOutLength) {
- return strResult;
- } else {
- Log.d(TAG, "[ZeroPadding_Head] strOriginalString(" + strOriginalString.length() + ") is longer than nOutLength(" + nOutLength + ")");
- return strResult;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return strResult;
- } catch (Exception e) {
- Log.e(TAG, "[ZeroPadding_Head] (Exception) ZeroPadding_Head(...) + e");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return strResult;
- }
- }
- public void receiveNewCall(String strRemoteIP, String strRemoteSIPID, boolean bCallPopup) {
- try {
- LOG_INFO("[receiveNewCall] strRemoteIP [" + strRemoteIP + "], strRemoteSIPID [" + strRemoteSIPID + "]");
- LOG_INFO("[receiveNewCall] CMCore.bDialerActive [" + CMCore.bDialerActive + "]");
- if (!CMCore.bDialerActive) CMCore.bDialerActive = true;
- CALLEVENTTYPE mCALLEVENTTYPE = CALLEVENTTYPE.RECEIVE_CALL;
- CALLTYPE mCALLTYPE = CALLTYPE.NONE;
- if (strRemoteSIPID.contains(DeviceString.strType_Lobby)) {
- if (bLobbyCallUse) mCALLTYPE = CALLTYPE.LOBBY;
- else return;
- }
- else if (strRemoteSIPID.contains(DeviceString.strType_Guard)) {
- if (bGuardCallUse) mCALLTYPE = CALLTYPE.GUARD;
- else return;
- }
- else if (strRemoteSIPID.contains(DeviceString.strType_Resi)) {
- if (bResiCallUse) mCALLTYPE = CALLTYPE.RESIDENCE;
- else return;
- }
- else {
- Log.e(TAG, "[receiveNewCall] SIPID is not correct!!!");
- return;
- }
- runCallMainActivity(mCALLEVENTTYPE, mCALLTYPE, bCallPopup);
- sendHandlerMsgDelayed(HANDLERMSG.RELEASE_BLOCK_INVITE_MSG, 0, 0, 0);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] receiveNewCall(String strRemoteIP, String strRemoteSIPID)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- String strWallPadCallPackageName = "kr.co.icontrols.wallpadcall";
- public void runCallMainActivity(CALLEVENTTYPE eEventType, CALLTYPE eCallType, boolean bCallPopup) {
- try {
- if (!bWallPadCallLive) {
- // 통화어플을 실행시킨다.
- LOG_WARN("[runCallMainActivity] ########## START ##########");
- sendLCDBacklightStatus(true);
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
- int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- if (nAlramStatus != WallpadStatusData.GUARD_OUT) sendBR_AppFinish(getApplicationContext());
- ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
- Intent mIntent = new Intent(Intent.ACTION_MAIN);
- mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
- mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
- if(bCallPopup)
- mIntent.putExtra("CALLPOPUP", "yes");
- else
- mIntent.putExtra("CALLPOPUP", "no");
- mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mIntent.setComponent(mComponentName);
- startActivity(mIntent);
- Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
- } else {
- LOG_WARN("[runCallMainActivity] WallPadCall is already running!! bRecordingStatus[" + Global.getRecordingStatus() + "] FrontStatus[" + MainActivity.mCallController.mCallInfo.getFRONT() + "]");
- Intent iIntent = new Intent();
- if (Global.getRecordingStatus() || (!Global.getRecordingStatus() && MainActivity.mCallController.mCallInfo.getFRONT() == CallManager.CALLSTATUS.RECORDING)) {
- // yjyoon.
- // 거동수상자 녹화 중 세대/로비/경비에서 콜이 왔을 때, 새로운 콜을 생성하기 전 녹화를 중지시킨다.
- // TalkFront > startStrangerRecord 에서 bRecordingStatus = true 로 설정.
- // bRecordingStatus = false 이면 아직 녹화 시작 전.
- LOG_INFO("[runCallMainActivity] Send Br - Declare.BR.BR_REQUEST_RECORD_STOP");
- iIntent.setAction(Declare.BR.BR_REQUEST_RECORD_STOP);
- iIntent.putExtra(define.NOTIBR_KIND, 2);
- } else {
- // 새로운 콜 정보 전달.
- LOG_INFO("[runCallMainActivity] Send Br - Declare.BR.BR_REQUEST_NEW_CALL");
- iIntent.setAction(Declare.BR.BR_REQUEST_NEW_CALL);
- }
- iIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
- iIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
- if (bCallPopup) {
- iIntent.putExtra("CALLPOPUP", "yes");
- } else {
- iIntent.putExtra("CALLPOPUP", "no");
- }
- getApplicationContext().sendBroadcast(iIntent);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] runCallMainActivity()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * Edited by jeff (2020.06.22)
- * LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
- * backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
- * @param bOn
- */
- private void sendLCDBacklightStatus(boolean bOn) {
- try {
- Log.d(TAG,"[sendLCDBacklightStatus] bOn [" + bOn + "]");
- Intent mIntent = new Intent();
- if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
- else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
- getApplicationContext().sendBroadcast(mIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private boolean getCallAppRunningStatus() {
- boolean bRunning = false;
- try {
- WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
- bRunning = DBMGR.GetCallAPKStatusRunning();
- DBMGR.closeDB();
- Log.d(TAG, "[getCallAppRunningStatus] bRunning : " + bRunning);
- return bRunning;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.d(TAG, "[Exception] getCallAppRunningStatus()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- return bRunning;
- }
- private boolean CanIStartCallApp() {
- try {
- for (int i = 0; i < 10; i++) {
- LOG_WARN("[isCallAppRun] Check Count [" + i + "]");
- if (!getTopActivity().equals(strWallPadCallPackageName)) {
- return true;
- } else {
- if (mClients.size() > 0) {
- LOG_WARN("[isCallAppRun] mClients.size() [" + mClients.size() + "]");
- return false;
- }
- }
- Thread.sleep(100);
- }
- return false;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] CanIStartCallApp()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- private String getTopActivity() {
- try {
- ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- List<ActivityManager.RunningTaskInfo> mTaskInfo = mActivityManager.getRunningTasks(1);
- LOG_INFO("[getTopActivity] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
- ComponentName mComponentName = mTaskInfo.get(0).topActivity;
- LOG_INFO("[getTopActivity] getPackageName = " + mComponentName.getPackageName());
- return mComponentName.getPackageName();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return null;
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getTopActivity()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return null;
- }
- }
- private void sendBR_AppFinish(Context context) {
- try {
- LOG_WARN("[sendBR_AppFinish] Send App Finish!!");
- Intent mIntent = new Intent();
- mIntent.setAction(define.BR_APP_FINISH);
- context.sendBroadcast(mIntent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendBR_AppFinish(Context context)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private 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);
- }
- }
- // Audio Tune
- public static short nEQ_60 = -1500; // dB
- public static short nEQ_230 = 0; // dB
- public static short nEQ_910 = 0; // dB
- public static short nEQ_4K = -1500; // dB
- public static short nEQ_14K = -1500; // dB
- static Equalizer mEqualizer;
- public void replyEQValue() {
- try {
- short[] EQValues = SIPSound.getEQValues();
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- // Send data as a String
- Bundle b = new Bundle();
- b.putString("cmd", "reply_get_eq_values");
- b.putShort("60", EQValues[0]);
- b.putShort("230", EQValues[1]);
- b.putShort("910", EQValues[2]);
- b.putShort("4k", EQValues[3]);
- b.putShort("14k", EQValues[4]);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_SET_INT_VALUE);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] replyEQValue -> mClients");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] replyEQValue()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void setEQValue(String strEQ, short Value) {
- try {
- Log.i(TAG, "strEQ [" + strEQ + "], Value [" + Value + "]");
- if (strEQ.equals("60")) SIPSound.ctrlEQ60(Value);
- else if (strEQ.equals("230")) SIPSound.ctrlEQ230(Value);
- else if (strEQ.equals("910")) SIPSound.ctrlEQ910(Value);
- else if (strEQ.equals("4k")) SIPSound.ctrlEQ4K(Value);
- else if (strEQ.equals("14k")) SIPSound.ctrlEQ14K(Value);
- else {
- Log.e(TAG, "strEQ is not available [" + strEQ + "]");
- }
- replyEQValue();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] setEQValue(String strEQ, short Value)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * JEFF, 2019.12.25
- * WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
- * WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
- * WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
- * WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
- */
- int MAX_WALLPADCALL_LIVE_CNT = 3;
- int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
- public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
- boolean bCheckThreadRun = false;
- checkWallPadLive mcheckWallPadLive;
- class checkWallPadLive extends Thread {
- public checkWallPadLive() {
- Log.w(TAG,"[Thread.checkWallPadLive] bCheckThreadRun [" + bCheckThreadRun + "]");
- }
- @Override
- public void run() {
- super.run();
- try {
- while (bCheckThreadRun) {
- if (nWallPadCallACKCnt >= 0) {
- nWallPadCallACKCnt--;
- }
- else {
- bWallPadCallLive = false;
- Global.setRecordingStatus(false);
- }
- // Log.w(TAG,"[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "]");
- Thread.sleep(1000);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] checkWallPadLive.run()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- BroadcastReceiver SIPStunBR = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- try {
- String strActionName = intent.getAction();
- // Log.i(TAG,"[SIPStunBR] strActionName [" + strActionName + "]");
- if (strActionName.equals(Declare.BR.BR_ACK_WALLPADCALL_LIVE)) {
- bWallPadCallLive = true;
- nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
- // Log.w(TAG,"[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "]");
- }
- else if (strActionName.equals(Declare.BR.BR_BLOCK_SIPCALL)) {
- bBLOCK_INVITE_MSG = true;
- StunHandler.removeMessages(HANDLERMSG.RELEASE_BLOCK_INVITE_MSG);
- sendHandlerMsgDelayed(HANDLERMSG.RELEASE_BLOCK_INVITE_MSG, 0, 0, 5000);
- }
- else {
- Log.w(TAG,"[SIPStunBR] Not supported strActionName [" + strActionName + "]");
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] BroadcastReceiver -> SIPStunBR");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- };
- private void registerWallPadCallLiveBRReceiver() {
- try {
- LOG_INFO("[registerWallPadCallLiveBRReceiver] ========== START ==========");
- IntentFilter mIntentFilter = new IntentFilter();
- mIntentFilter.addAction(Declare.BR.BR_ACK_WALLPADCALL_LIVE);
- mIntentFilter.addAction(Declare.BR.BR_BLOCK_SIPCALL);
- registerReceiver(SIPStunBR, mIntentFilter);
- bCheckThreadRun = true;
- mcheckWallPadLive = new checkWallPadLive();
- mcheckWallPadLive.start();
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] registerWallPadCallLiveBRReceiver()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void unregisterWallPadCallLiveBRReceiver() {
- try {
- LOG_INFO("[unregisterBRReceiver] ========== START ==========");
- unregisterReceiver(SIPStunBR);
- bCheckThreadRun = false;
- mcheckWallPadLive = null;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] unregisterWallPadCallLiveBRReceiver()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void updateBlockStatus() {
- Log.v(TAG, "updateBlockStatus()");
- for (int i = mClients.size() - 1; i >= 0; i--) {
- try {
- Bundle b = new Bundle();
- b.putBoolean("ISBLOCK", bBLOCK_INVITE_MSG);
- Message msg = null;
- msg = Message.obtain(null, CMCore.BSSSIPStun_ICONTROLS_UPDATE_BLOCK_STATUS);
- msg.setData(b);
- mClients.get(i).send(msg);
- } catch (RemoteException e) {
- Log.e(TAG, "[RemoteException] updateBlockStatus()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mClients.remove(i);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] updateBlockStatus()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
- }
|