tvs.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  1. var UseActiveX = 1;
  2. var USEIVS = 1;
  3. var TVS_VERSION = ((parseInt(readSetupByKey("SYS_BOARDID")) & 0xF000) == 0xD000 || (parseInt(readSetupByKey("SYS_BOARDID")) & 0xF000) == 0xE000) ? '1,6,57,124' : '1,6,57,118';
  4. var TN_CS_CONNECTED = 0x00000001;
  5. var TN_CS_STREAMED = 0x00000002;
  6. var TN_CS_DECODED = 0x00000004;
  7. var TN_CS_DISPLAYED = 0x00000008;
  8. var TN_CS_RECORDED = 0x00000010;
  9. var TN_SNC_CN_SERVER_UNREACHABLE = 10;
  10. var TN_SNC_CN_TOO_MANY_CONNECTION = 11;
  11. var TN_SNC_CN_PASSWORD_MISMATCH = 12;
  12. var TN_SNC_CN_CONNECTION_DISABLED = 13;
  13. var TN_SNC_CN_ID_NOT_EXIST = 14;
  14. var TN_SNC_CN_DOMAINNAME_UNKNOWN = 15;
  15. var TN_SNC_CN_PARAMETER_OUTOFRANGE = 16;
  16. var TN_SNC_CN_DUPLICATE_CONNECT = 17;
  17. var TN_SNC_CN_KEEPALIVE_FAILED = 18;
  18. var TN_SNC_CN_NO_AUTHORITY_OPERATION = 19;
  19. var TN_SNC_CN_OPERATION_FAILED = 20;
  20. var TN_ET_DI = 0;
  21. var TN_ET_VIDEOLOSS = 1;
  22. var TN_ET_MOTION = 2;
  23. var TN_ET_DO = 4;
  24. var TN_ET_RECORD = 5;
  25. var TN_ET_RESOLUTION = 6;
  26. var TN_ES_OFF = 0;
  27. var TN_ES_ON = 1;
  28. var TN_ET_OFF = 0;
  29. var TN_ET_SET = 1;
  30. var TN_ET_ERASE = 2;
  31. var TN_ET_APPLY = 3;
  32. var TN_ET_ERASEALL = 4;
  33. var TN_ET_SETALL = 5;
  34. var TN_MVD_PAUSE = 0;
  35. var TN_MVD_KEYFRAME = 1;
  36. var TN_MVD_LIVE = 2;
  37. var g_lChID = 0;
  38. var g_display = null;
  39. var g_lOsdID_VL = -1;
  40. var g_lOsdsysID = -1;
  41. var g_lOsdsysTime = -1;
  42. var g_ivs = null;
  43. const SUPPORT_DETECTION_CAM_4CH = 1;
  44. const NOT_SUPPORT_DETECTION_CAM_4CH = 0 ;
  45. var g_detection_4ch_support = NOT_SUPPORT_DETECTION_CAM_4CH;
  46. var g_detection_4ch_IDs = [0,0,0,0] ;
  47. var g_detection_4ch_Displays = [null ,null ,null ,null ];
  48. function tvs_init_detection_4ch(index , server_addr , port, id, password)
  49. {
  50. var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
  51. if(UseActiveX == 1){
  52. var agt = navigator.userAgent.toLowerCase();
  53. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  54. }
  55. if (UseActiveX == 1) {
  56. tvs_connect_detection_4ch(server_addr, port, id, password, index, max_resolution);
  57. }
  58. else{
  59. // setTimeout(function() { tvs_connect(server_addr, ori_port, id, password, sub, max_resolution); }, 0);
  60. }
  61. }
  62. function tvs_init(server_addr, port, id, password, sub)
  63. {
  64. var http_port = parseInt(readSetupByKey("NET_HTTPPORT"));
  65. var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
  66. var url = document.URL;
  67. var change_url;
  68. var change_port;
  69. var ori_port;
  70. if(UseActiveX == 1){
  71. var agt = navigator.userAgent.toLowerCase();
  72. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  73. }
  74. ori_port = port;
  75. change_url = url.split(":");
  76. if(typeof change_url[2] != "undefined")
  77. {
  78. change_port = change_url[2].split("/");
  79. if( typeof change_port[0] != "undefined")
  80. {
  81. if(parseInt(change_port[0]) >= parseInt(59000) && parseInt(change_port[0]) <= parseInt(59255))
  82. {
  83. if(http_port != change_port[0])
  84. {
  85. ori_port = parseInt(change_port[0]) - parseInt(1000);
  86. }
  87. }
  88. }
  89. }
  90. if(UseActiveX == 1){
  91. g_display = document.Tvs.GetDisplay();
  92. if(USEIVS == 1){
  93. g_ivs = document.Tvs.GetIVSControl();
  94. }
  95. }
  96. if (UseActiveX == 1) {
  97. tvs_connect(server_addr, ori_port, id, password, sub, max_resolution);
  98. }
  99. else{
  100. setTimeout(function() { tvs_connect(server_addr, ori_port, id, password, sub, max_resolution); }, 0);
  101. }
  102. }
  103. /*
  104. * max_resolution (tvs activeX object width/height)
  105. * 2 : 2056x1536
  106. * 5 : 1944x2592
  107. * 6 : 4096x3000
  108. * else : 800x600
  109. */
  110. function tvs_init2(server_addr, port, id, password, sub, max_resolution)
  111. {
  112. var http_port = parseInt(readSetupByKey("NET_HTTPPORT"));
  113. var url = document.URL;
  114. var change_url;
  115. var change_port;
  116. var ori_port;
  117. if(UseActiveX == 1){
  118. var agt = navigator.userAgent.toLowerCase();
  119. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  120. }
  121. ori_port = port;
  122. change_url = url.split(":");
  123. if(typeof change_url[2] != "undefined")
  124. {
  125. change_port = change_url[2].split("/");
  126. if( typeof change_port[0] != "undefined")
  127. {
  128. if(parseInt(change_port[0]) >= parseInt(59000) && parseInt(change_port[0]) <= parseInt(59255))
  129. {
  130. if(http_port != change_port[0])
  131. {
  132. ori_port = parseInt(change_port[0]) - parseInt(1000);
  133. }
  134. }
  135. }
  136. }
  137. if(UseActiveX == 1){
  138. g_display = document.Tvs.GetDisplay();
  139. if(USEIVS == 1){
  140. g_ivs = document.Tvs.GetIVSControl();
  141. }
  142. }
  143. if (UseActiveX == 1) {
  144. tvs_connect(server_addr, ori_port, id, password, sub, max_resolution);
  145. }
  146. else{
  147. setTimeout(function() { tvs_connect(server_addr, ori_port, id, password, sub, max_resolution); }, 0);
  148. }
  149. }
  150. function tvs_init_playback(server_addr, port, id, password, time)
  151. {
  152. var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
  153. var url = document.URL;
  154. if(UseActiveX == 1){
  155. var agt = navigator.userAgent.toLowerCase();
  156. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  157. }
  158. if(UseActiveX == 1){
  159. g_display = document.Tvs.GetDisplay();
  160. if(USEIVS == 1){
  161. g_ivs = document.Tvs.GetIVSControl();
  162. }
  163. }
  164. if (UseActiveX == 1) {
  165. tvs_connect_playback(server_addr, port, id, password, time, max_resolution);
  166. }
  167. else{
  168. setTimeout(function() { tvs_connect_playback(server_addr, port, id, password, time, max_resolution); }, 0);
  169. }
  170. }
  171. function tvs_term(sub)
  172. {
  173. if(UseActiveX == 1){
  174. var agt = navigator.userAgent.toLowerCase();
  175. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  176. }
  177. tvs_discon(sub);
  178. }
  179. function tvs_connect_detection_4ch(server_addr, port, id, password, index, max_resolution)
  180. {
  181. var disable_vsnm = parseInt(readSetupByKey("SYS_DISABLE_VSNM"));
  182. var uri_str = 'vsnm://';
  183. if(g_detection_4ch_IDs[index] > 0) {
  184. tvs_discon_detection_4ch(index);
  185. return ;
  186. }
  187. if(disable_vsnm == 1){
  188. if(document.URL.indexOf("https://") == -1){
  189. uri_str = 'rtsp://';
  190. port = parseInt(readSetupByKey("NET_RTSPPORT"));
  191. }
  192. else{
  193. uri_str = 'https://';
  194. port = parseInt(readSetupByKey("NET_HTTPSPORT"));
  195. }
  196. }
  197. if(index == 0){
  198. sAddress = uri_str + server_addr + ':' + port + '/video1';
  199. }
  200. else if(index == 1){
  201. sAddress = uri_str + server_addr + ':' + port + '/video2';
  202. }
  203. else if(index == 2){
  204. sAddress = uri_str + server_addr + ':' + port + '/video3';
  205. }
  206. else if(index == 3){
  207. sAddress = uri_str + server_addr + ':' + port + '/video4';
  208. }
  209. else if(index == 8){
  210. if (disable_vsnm == 1) {
  211. sAddress = uri_str + server_addr + ':' + port + '/quad';
  212. } else {
  213. sAddress = uri_str + server_addr + ':' + port + '/video5';
  214. }
  215. }
  216. else{
  217. sAddress = uri_str + server_addr + ':' + port + '/video1';
  218. }
  219. console.log("index : " + index + ", address : " + sAddress);
  220. if(0 == index) {
  221. document.Tvs4_0.SetLocalConfig(3,max_resolution);
  222. document.Tvs4_0.SetLocalConfig(9, -1); // Autoplay on
  223. document.Tvs4_0.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  224. g_detection_4ch_IDs[index] = document.Tvs4_0.Connect(sAddress, id, password);
  225. document.Tvs4_0.SetMute(g_detection_4ch_IDs[index], 0);
  226. document.Tvs4_0.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
  227. document.Tvs4_0.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
  228. document.Tvs4_0.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
  229. document.Tvs4_0.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
  230. g_detection_4ch_Displays[0] = document.Tvs4_0.GetDisplay();
  231. }
  232. else if(1 == index) {
  233. document.Tvs4_1.SetLocalConfig(3,max_resolution);
  234. document.Tvs4_1.SetLocalConfig(9, -1); // Autoplay on
  235. document.Tvs4_1.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  236. g_detection_4ch_IDs[index] = document.Tvs4_1.Connect(sAddress, id, password);
  237. document.Tvs4_1.SetMute(g_detection_4ch_IDs[index], 0);
  238. document.Tvs4_1.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
  239. document.Tvs4_1.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
  240. document.Tvs4_1.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
  241. document.Tvs4_1.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
  242. g_detection_4ch_Displays[1] = document.Tvs4_1.GetDisplay();
  243. }
  244. else if(2 == index) {
  245. document.Tvs4_2.SetLocalConfig(3,max_resolution);
  246. document.Tvs4_2.SetLocalConfig(9, -1); // Autoplay on
  247. document.Tvs4_2.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  248. g_detection_4ch_IDs[index] = document.Tvs4_2.Connect(sAddress, id, password);
  249. document.Tvs4_2.SetMute(g_detection_4ch_IDs[index], 0);
  250. document.Tvs4_2.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
  251. document.Tvs4_2.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
  252. document.Tvs4_2.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
  253. document.Tvs4_2.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
  254. g_detection_4ch_Displays[2] = document.Tvs4_2.GetDisplay();
  255. }
  256. else {
  257. document.Tvs4_3.SetLocalConfig(3,max_resolution);
  258. document.Tvs4_3.SetLocalConfig(9, -1); // Autoplay on
  259. document.Tvs4_3.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  260. g_detection_4ch_IDs[index] = document.Tvs4_3.Connect(sAddress, id, password);
  261. document.Tvs4_3.SetMute(g_detection_4ch_IDs[index], 0);
  262. document.Tvs4_3.SetAutoReconnect(g_detection_4ch_IDs[index], -1);
  263. document.Tvs4_3.SetPTZControlSpeed(g_detection_4ch_IDs[index], 0, -1);
  264. document.Tvs4_3.SetPTZControlSpeed(g_detection_4ch_IDs[index], 1, -1);
  265. document.Tvs4_3.SetPTZControlSpeed(g_detection_4ch_IDs[index], 2, -1);
  266. g_detection_4ch_Displays[3] = document.Tvs4_3.GetDisplay();
  267. }
  268. }
  269. function tvs_connect(server_addr, port, id, password, sub, max_resolution)
  270. {
  271. var disable_vsnm = parseInt(readSetupByKey("SYS_DISABLE_VSNM"));
  272. var uri_str = 'vsnm://';
  273. if (g_lChID > 0)
  274. {
  275. tvs_discon(0);
  276. return;
  277. }
  278. if(disable_vsnm == 1){
  279. if(document.URL.indexOf("https://") == -1){
  280. uri_str = 'rtsp://';
  281. port = parseInt(readSetupByKey("NET_RTSPPORT"));
  282. }
  283. else{
  284. uri_str = 'https://';
  285. port = parseInt(readSetupByKey("NET_HTTPSPORT"));
  286. }
  287. }
  288. if($("[name=SYS_BOARDID]").val() == 0x1003 || $("[name=SYS_BOARDID]").val() == 0x1007){
  289. if(sub == 0){
  290. sAddress = uri_str + server_addr + ':' + port + '/video1+audio1';
  291. }
  292. else if(sub == 1){
  293. sAddress = uri_str + server_addr + ':' + port + '/video2';
  294. }
  295. else if(sub == 2){
  296. sAddress = uri_str + server_addr + ':' + port + '/video3';
  297. }
  298. else if(sub == 3){
  299. sAddress = uri_str + server_addr + ':' + port + '/video4';
  300. }
  301. else if(sub == 4){
  302. sAddress = uri_str + server_addr + ':' + port + '/video1s+audio1';
  303. }
  304. else if(sub == 5){
  305. sAddress = uri_str + server_addr + ':' + port + '/video2s';
  306. }
  307. else if(sub == 6){
  308. sAddress = uri_str + server_addr + ':' + port + '/video3s';
  309. }
  310. else if(sub == 7){
  311. sAddress = uri_str + server_addr + ':' + port + '/video4s';
  312. }
  313. else if(sub == 8){
  314. if (disable_vsnm == 1) {
  315. sAddress = uri_str + server_addr + ':' + port + '/quad';
  316. } else {
  317. sAddress = uri_str + server_addr + ':' + port + '/video5';
  318. }
  319. }
  320. }
  321. else if($("[name=SYS_BOARDID]").val() == 0xB001){ // A400 (4Ch + Quad Channel)
  322. if(sub == 0){
  323. sAddress = uri_str + server_addr + ':' + port + '/video1';
  324. }
  325. else if(sub == 1){
  326. sAddress = uri_str + server_addr + ':' + port + '/video2';
  327. }
  328. else if(sub == 2){
  329. sAddress = uri_str + server_addr + ':' + port + '/video3';
  330. }
  331. else if(sub == 3){
  332. sAddress = uri_str + server_addr + ':' + port + '/video4';
  333. }
  334. else if(sub == 4){
  335. sAddress = uri_str + server_addr + ':' + port + '/video1s';
  336. }
  337. else if(sub == 5){
  338. sAddress = uri_str + server_addr + ':' + port + '/video2s';
  339. }
  340. else if(sub == 6){
  341. sAddress = uri_str + server_addr + ':' + port + '/video3s';
  342. }
  343. else if(sub == 7){
  344. sAddress = uri_str + server_addr + ':' + port + '/video4s';
  345. }
  346. else if(sub == 8){
  347. if (disable_vsnm == 1) {
  348. sAddress = uri_str + server_addr + ':' + port + '/quad';
  349. } else {
  350. sAddress = uri_str + server_addr + ':' + port + '/video5';
  351. }
  352. }
  353. else if(sub == 9){
  354. if (disable_vsnm == 1) {
  355. sAddress = uri_str + server_addr + ':' + port + '/quads';
  356. } else {
  357. sAddress = uri_str + server_addr + ':' + port + '/video5s';
  358. }
  359. }
  360. else{
  361. sAddress = uri_str + server_addr + ':' + port + '/video1';
  362. }
  363. console.log("sub : " + sub + ", address : " + sAddress);
  364. }
  365. else{
  366. if(sub == 0){
  367. sAddress = uri_str + server_addr + ':' + port + '/video1+audio1';
  368. }
  369. else if(sub == 1){
  370. sAddress = uri_str + server_addr + ':' + port + '/video1s+audio1';
  371. }
  372. else if(sub == 2){
  373. sAddress = uri_str + server_addr + ':' + port + '/video1s2+audio1';
  374. }
  375. else if(sub == 3){
  376. sAddress = uri_str + server_addr + ':' + port + '/video1s3+audio1';
  377. }
  378. else{
  379. sAddress = uri_str + server_addr + ':' + port + '/video1+audio1';
  380. }
  381. }
  382. document.Tvs.SetLocalConfig(3,max_resolution);
  383. document.Tvs.SetLocalConfig(9, -1); // Autoplay on
  384. document.Tvs.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  385. g_lChID = document.Tvs.Connect(sAddress, id, password);
  386. // if (!document.Tvs.Play(g_lChID))
  387. // {
  388. // return;
  389. // }
  390. document.Tvs.SetMute(g_lChID, 0);
  391. document.Tvs.SetAutoReconnect(g_lChID, -1);
  392. document.Tvs.SetPTZControlSpeed(g_lChID, 0, -1);
  393. document.Tvs.SetPTZControlSpeed(g_lChID, 1, -1);
  394. document.Tvs.SetPTZControlSpeed(g_lChID, 2, -1);
  395. // document.Tvs.DecodingOption(2) = 0;
  396. }
  397. function tvs_connect_playback(server_addr, port, id, password, time, max_resolution)
  398. {
  399. if (g_lChID > 0)
  400. {
  401. tvs_discon(0);
  402. return;
  403. }
  404. if($("[name=SYS_BOARDID]").val() == 0x1003 || $("[name=SYS_BOARDID]").val() == 0x1007){
  405. return;
  406. }
  407. else{
  408. sAddress = 'rtsp://' + server_addr + ':' + port + '/playback_' + time;
  409. }
  410. document.Tvs.SetLocalConfig(3,max_resolution);
  411. document.Tvs.SetLocalConfig(9, -1); // Autoplay on
  412. document.Tvs.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  413. g_lChID = document.Tvs.Connect(sAddress, id, password);
  414. document.Tvs.SetMute(g_lChID, 0);
  415. document.Tvs.SetAutoReconnect(g_lChID, -1);
  416. }
  417. function tvs_SetBuffer_DirectionCam(buffer)
  418. {
  419. if(UseActiveX == 1){
  420. var agt = navigator.userAgent.toLowerCase();
  421. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  422. }
  423. if(buffer <= 0){
  424. if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
  425. document.Tvs4_0.SetLocalConfig(7, 1); // Buffer
  426. document.Tvs4_1.SetLocalConfig(7, 1); // Buffer
  427. document.Tvs4_2.SetLocalConfig(7, 1); // Buffer
  428. document.Tvs4_3.SetLocalConfig(7, 1); // Buffer
  429. }
  430. }
  431. else if(buffer >= 90){
  432. if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
  433. document.Tvs4_0.SetLocalConfig(7, 30); // Buffer
  434. document.Tvs4_1.SetLocalConfig(7, 30); // Buffer
  435. document.Tvs4_2.SetLocalConfig(7, 30); // Buffer
  436. document.Tvs4_3.SetLocalConfig(7, 30); // Buffer
  437. }
  438. }
  439. else{
  440. if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
  441. document.Tvs4_0.SetLocalConfig(7, buffer/3); // Buffer
  442. document.Tvs4_1.SetLocalConfig(7, buffer/3); // Buffer
  443. document.Tvs4_2.SetLocalConfig(7, buffer/3); // Buffer
  444. document.Tvs4_3.SetLocalConfig(7, buffer/3); // Buffer
  445. }
  446. }
  447. }
  448. function tvs_SetBuffer(buffer)
  449. {
  450. if(UseActiveX == 1){
  451. var agt = navigator.userAgent.toLowerCase();
  452. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  453. }
  454. if(buffer <= 0){
  455. document.Tvs.SetLocalConfig(7, 1); // Buffer
  456. }
  457. else if(buffer >= 90){
  458. document.Tvs.SetLocalConfig(7, 30); // Buffer
  459. }
  460. else{
  461. document.Tvs.SetLocalConfig(7, buffer/3); // Buffer
  462. }
  463. }
  464. var g_lSession;
  465. function tvs_recstart(path)
  466. {
  467. g_lSession = document.Tvs.StartFileRecord(g_lChID, 1, path);
  468. if(g_lSession != 0){
  469. if(g_lSession == -2147024773){
  470. alert(GetLan(641));
  471. }
  472. else if(g_lSession == -2147024893){
  473. alert(GetLan(642));
  474. }
  475. else if(g_lSession == -2147024891){
  476. alert(GetLan(643));
  477. }
  478. else {
  479. alert(GetLan(644));
  480. }
  481. return -1;
  482. // alert('tvs_recstart' + g_lSession);
  483. }
  484. else{
  485. return 0;
  486. // alert('ok');
  487. }
  488. }
  489. function tvs_recstop()
  490. {
  491. document.Tvs.StopFileRecord(g_lChID);
  492. }
  493. function tvs_digitalzoom(ratio, nx, ny)
  494. {
  495. if (g_lChID > 0){
  496. if(UseActiveX == 1){
  497. g_display.SetDigitalZoom(g_lChID, ratio, nx, ny);
  498. }
  499. else{
  500. document.Tvs.SetDigitalZoom(g_lChID, ratio, nx, ny);
  501. }
  502. }
  503. }
  504. function tvs_setnewosd(sysid, time, position, idstr, width, height)
  505. {
  506. var x, y, w, h, f;
  507. if(sysid == 1){
  508. if(g_lOsdsysID >= 0){
  509. if(UseActiveX == 1){
  510. g_display.RemoveOsdArea(g_lOsdsysID);
  511. }
  512. else{
  513. document.Tvs.RemoveOsdArea(0);
  514. }
  515. g_lOsdsysID = -1;
  516. }
  517. x = width/60 *2;
  518. w = x + (width/3*2);
  519. if(position == 0){
  520. y = height - height/24 - height/12; // bottom
  521. }
  522. else{
  523. y = height/24; // top
  524. }
  525. h = y + height/12+4;
  526. f = width/36;
  527. if(UseActiveX == 1){
  528. g_lOsdsysID = g_display.AddOsdArea(g_lChID, x, y, w, h, 0);
  529. g_display.SetOsdFontSize(g_lOsdsysID, f);
  530. g_display.UpdateOsdArea(g_lOsdsysID, idstr);
  531. }
  532. else{
  533. g_lOsdsysID = 0;
  534. document.Tvs.UpdateOsdArea(g_lChID, 0, x, y, w, h, f, idstr, 0);
  535. }
  536. }
  537. if(time == 1){
  538. if(g_lOsdsysTime >= 0){
  539. if(UseActiveX == 1){
  540. g_display.RemoveOsdArea(g_lOsdsysTime);
  541. }
  542. else{
  543. document.Tvs.RemoveOsdArea(1);
  544. }
  545. g_lOsdsysTime = -1;
  546. }
  547. x = width - (width/60 *2) - (width/6) - 20;
  548. w = x + (width/3);
  549. if(position == 0){
  550. y = height - height/24 - height/12; // bottom
  551. }
  552. else{
  553. y = height/24; // top
  554. }
  555. h = y + height/12+4;
  556. f = width/36;
  557. if(UseActiveX == 1){
  558. g_lOsdsysTime = g_display.AddOsdArea(g_lChID, x, y, w, h, 0);
  559. g_display.SetOsdFontSize(g_lOsdsysTime, f);
  560. g_display.UpdateOsdArea(g_lOsdsysTime, '%SERVERTIME%');
  561. }
  562. else{
  563. g_lOsdsysTime = 1;
  564. document.Tvs.UpdateOsdArea(g_lChID, 1, x, y, w, h, f, '%SERVERTIME%', 0);
  565. }
  566. }
  567. }
  568. function tvs_setvideolossosd(x, y, w, h)
  569. {
  570. if(UseActiveX == 1){
  571. g_lOsdID_VL = g_display.AddOsdArea(g_lChID, x, y, w, h, 0);
  572. g_display.SetOsdFontSize(g_lOsdID_VL, 20);
  573. g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
  574. }
  575. else{
  576. g_lOsdID_VL = 2;
  577. document.Tvs.UpdateOsdArea(g_lChID, 2, x, y, w, h, 20, 'Video Loss', 0);
  578. }
  579. }
  580. function tvs_clrvideolossosd()
  581. {
  582. if (g_lOsdID_VL >= 0)
  583. {
  584. if(UseActiveX == 1){
  585. g_display.RemoveOsdArea(g_lOsdID_VL);
  586. }
  587. else{
  588. document.Tvs.RemoveOsdArea(2);
  589. }
  590. g_lOsdID_VL = -1;
  591. }
  592. }
  593. function pause(msec) {
  594. var now = new Date();
  595. var exitTime = now.getTime() + (msec);
  596. while (true) {
  597. now = new Date();
  598. if (now.getTime() > exitTime) return;
  599. }
  600. }
  601. function tvs_discon_detection_4ch(index)
  602. {
  603. if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
  604. if(index >= 0 && index < 4 ) {
  605. if(0 == index) {
  606. document.Tvs4_0.Pause(g_detection_4ch_IDs[index]);
  607. document.Tvs4_0.SetMute(g_detection_4ch_IDs[index], 1);
  608. document.Tvs4_0.Disconnect(g_detection_4ch_IDs[index]);
  609. g_detection_4ch_IDs[index] = 0;
  610. }
  611. else if(1 == index) {
  612. document.Tvs4_1.Pause(g_detection_4ch_IDs[index]);
  613. document.Tvs4_1.SetMute(g_detection_4ch_IDs[index], 1);
  614. document.Tvs4_1.Disconnect(g_detection_4ch_IDs[index]);
  615. g_detection_4ch_IDs[index] = 0;
  616. }
  617. else if(2 == index) {
  618. document.Tvs4_2.Pause(g_detection_4ch_IDs[index]);
  619. document.Tvs4_2.SetMute(g_detection_4ch_IDs[index], 1);
  620. document.Tvs4_2.Disconnect(g_detection_4ch_IDs[index]);
  621. g_detection_4ch_IDs[index] = 0;
  622. }
  623. else {
  624. document.Tvs4_3.Pause(g_detection_4ch_IDs[index]);
  625. document.Tvs4_3.SetMute(g_detection_4ch_IDs[index], 1);
  626. document.Tvs4_3.Disconnect(g_detection_4ch_IDs[index]);
  627. g_detection_4ch_IDs[index] = 0;
  628. }
  629. }
  630. // alert('disconnect ' + index );
  631. pause(500);
  632. }
  633. }
  634. function tvs_discon(sub)
  635. {
  636. if (g_lChID == 0)
  637. {
  638. return;
  639. }
  640. document.Tvs.Pause(g_lChID);
  641. document.Tvs.SetMute(g_lChID, 1);
  642. document.Tvs.Disconnect(g_lChID);
  643. g_lChID = 0;
  644. // alert('connected');
  645. pause(500);
  646. }
  647. /*
  648. function tvs_on_ChannelNotify(lChID, eNewState, eReason)
  649. {
  650. // alert('tvs_on_ChannelNofy');
  651. if (eNewState & TN_CS_CONNECTED)
  652. {
  653. // alert('connected');
  654. }
  655. else
  656. {
  657. // alert('disconnected(reason=' + eReason + ')');
  658. if (eReason >= TN_SNC_CN_SERVER_UNREACHABLE)
  659. {
  660. switch (eReason)
  661. {
  662. case TN_SNC_CN_SERVER_UNREACHABLE:
  663. // alert('Server is unreachable for connection');
  664. break;
  665. case TN_SNC_CN_TOO_MANY_CONNECTION:
  666. // alert('Too many connections on the server');
  667. break;
  668. case TN_SNC_CN_PASSWORD_MISMATCH:
  669. // alert('Password is incorrect');
  670. break;
  671. case TN_SNC_CN_CONNECTION_DISABLED:
  672. // alert('Server disabled the connection');
  673. break;
  674. case TN_SNC_CN_ID_NOT_EXIST:
  675. // alert('Login ID does not exist');
  676. break;
  677. case TN_SNC_CN_DOMAINNAME_UNKNOWN:
  678. // alert('Can not resolve the domain name');
  679. break;
  680. case TN_SNC_CN_PARAMETER_OUTOFRANGE:
  681. // alert('Invalid channels is one of this case');
  682. break;
  683. case TN_SNC_CN_DUPLICATE_CONNECT:
  684. // alert('Multiple connections to a channel are not allowed');
  685. break;
  686. case TN_SNC_CN_KEEPALIVE_FAILED:
  687. // alert('Disconnected due to keep alive timeout');
  688. break;
  689. case TN_SNC_CN_NO_AUTHORITY_OPERATION:
  690. // alert('No authority operation');
  691. break;
  692. case TN_SNC_CN_OPERATION_FAILED:
  693. // alert('General failure');
  694. break;
  695. }
  696. }
  697. }
  698. }
  699. function tvs_on_MouseEvent(lChID, lMsg, wParam, lParam)
  700. {
  701. }
  702. function tvs_on_ServerEvent(lChID, eEventType, nIndex, eEventStatus, vData, motion_img, record_img)
  703. {
  704. switch (eEventType)
  705. {
  706. case TN_ET_MOTION:
  707. if (eEventStatus)
  708. {
  709. document[motion_img].src = '/image/motion.jpg';
  710. }
  711. else
  712. {
  713. document[motion_img].src = '/image/null.jpg';
  714. }
  715. break;
  716. case TN_ET_RECORD:
  717. if (eEventStatus == 1)
  718. {
  719. document[record_img].src = '/image/rec_on.jpg';
  720. }
  721. else if (eEventStatus == -1)
  722. {
  723. document[record_img].src = '/image/rec_err.jpg';
  724. }
  725. else
  726. {
  727. document[record_img].src = '/image/null.jpg';
  728. }
  729. break;
  730. case TN_ET_VIDEOLOSS:
  731. if (eEventStatus)
  732. {
  733. // alert('Video Loss(1)');
  734. if (g_lOsdID_VL >= 0)
  735. {
  736. g_display.RemoveOsdArea(g_lOsdID_VL);
  737. g_lOsdID_VL = -1;
  738. }
  739. }
  740. else
  741. {
  742. // alert('Video Loss(0)');
  743. var rcVL = new Array(document.Tvs.width / 2 - 60, document.Tvs.height / 2 - 30, document.Tvs.width / 2 + 80, document.Tvs.height / 2 + 30);
  744. g_lOsdID_VL = g_display.AddOsdArea(g_lChID, rcVL[0], rcVL[1], rcVL[2], rcVL[3], 0);
  745. g_display.SetOsdFontSize(g_lOsdID_VL, 20);
  746. g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
  747. }
  748. break;
  749. }
  750. }
  751. function tvs_ResetVLossOSD()
  752. {
  753. if (g_lOsdID_VL >= 0)
  754. {
  755. var rcVL = new Array(document.Tvs.width / 2 - 60, document.Tvs.height / 2 - 30, document.Tvs.width / 2 + 80, document.Tvs.height / 2 + 30);
  756. g_display.RemoveOsdArea(g_lOsdID_VL);
  757. g_lOsdID_VL = g_display.AddOsdArea(g_lChID, rcVL[0], rcVL[1], rcVL[2], rcVL[3], 0);
  758. g_display.SetOsdFontSize(g_lOsdID_VL, 20);
  759. g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
  760. }
  761. }
  762. function tvs_on_ServerEventVLoss(lChID, eEventType, nIndex, eEventStatus, vData)
  763. {
  764. switch (eEventType)
  765. {
  766. case TN_ET_VIDEOLOSS:
  767. if (eEventStatus)
  768. {
  769. // alert('Video Loss1 - 1');
  770. if (g_lOsdID_VL >= 0)
  771. {
  772. g_display.RemoveOsdArea(g_lOsdID_VL);
  773. g_lOsdID_VL = -1;
  774. }
  775. }
  776. else
  777. {
  778. // alert('Video Loss0 - 1');
  779. var rcVL = new Array(document.Tvs.width / 2 - 60, document.Tvs.height / 2 - 30, document.Tvs.width / 2 + 80, document.Tvs.height / 2 + 30);
  780. g_lOsdID_VL = g_display.AddOsdArea(g_lChID, rcVL[0], rcVL[1], rcVL[2], rcVL[3], 0);
  781. g_display.SetOsdFontSize(g_lOsdID_VL, 20);
  782. g_display.UpdateOsdArea(g_lOsdID_VL, 'Video Loss');
  783. }
  784. break;
  785. }
  786. }
  787. function tvs_on_ServerEventVideo(lChID, eEventType, nIndex, eEventStatus, vData, vmotion_img)
  788. {
  789. switch (eEventType)
  790. {
  791. case TN_ET_MOTION:
  792. if (eEventStatus)
  793. {
  794. document[vmotion_img].src = '/image/motion.jpg';
  795. }
  796. else
  797. {
  798. document[vmotion_img].src = '/image/null.jpg';
  799. }
  800. break;
  801. }
  802. }
  803. function tvs_on_ServerEventView(lChID, eEventType, nIndex, eEventStatus, vData, sensor_img, alarm_img, sensor2_img, alarm2_img, sensor3_img, sensor4_img)
  804. {
  805. }
  806. function tvs_on_SystemNotify(lNotifyCode, vData)
  807. {
  808. }
  809. */
  810. function tvs_snapshot(fileName)
  811. {
  812. if (g_lChID == 0) return;
  813. // document.Tvs.Snapshot(g_lChID, true);
  814. document.Tvs.Snapshot(g_lChID, 0, false); // 0 = bmp, 1=jpg
  815. // document.Tvs.Snapshot(g_lChID, false); // 0 = bmp, 1=jpg
  816. document.Tvs.PreviewSnapshot(g_lChID);
  817. }
  818. function tvs_setDO(index, value)
  819. {
  820. if (g_lChID == 0) return;
  821. document.Tvs.SetDO(g_lChID, index, value);
  822. }
  823. function tvs_enable_talk(enable)
  824. {
  825. if (g_lChID == 0) return;
  826. if (enable)
  827. {
  828. document.Tvs.StartTalking(g_lChID);
  829. }
  830. else
  831. {
  832. document.Tvs.StopTalking(g_lChID);
  833. }
  834. }
  835. function tvs_set_motion_region_edit(set)
  836. {
  837. if (g_lChID == 0) return;
  838. document.Tvs.SetMotionRegionEdit(g_lChID, set, TN_MVD_KEYFRAME);
  839. }
  840. function tvs_set_motion_region_edit2(set,region)
  841. {
  842. if (g_lChID == 0) return;
  843. document.Tvs.SetMotionRegionEdit2(g_lChID, region,set,TN_MVD_LIVE);
  844. }
  845. function tvs_set_motion_region_edit2_detection_cam(channel,set,region)
  846. {
  847. if(channel >= 0 && channel < 4) {
  848. if(0 == g_detection_4ch_IDs[channel]) {
  849. return ;
  850. }
  851. if(0 == channel) {
  852. document.Tvs4_0.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
  853. }
  854. else if(1 == channel) {
  855. document.Tvs4_1.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
  856. }
  857. else if(2 == channel) {
  858. document.Tvs4_2.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
  859. }
  860. else {
  861. document.Tvs4_3.SetMotionRegionEdit2(g_detection_4ch_IDs[channel], region,set,TN_MVD_LIVE);
  862. }
  863. }
  864. }
  865. function tvs_set_scale_enable(mode,id)
  866. {
  867. if (g_lChID == 0) return;
  868. document.Tvs.SetScaleEnable(g_lChID, mode,id);
  869. }
  870. function tvs_set_scale_edit(id,x,y,w,h)
  871. {
  872. if (g_lChID == 0) return;
  873. document.Tvs.SetScaleEdit(g_lChID, id,x,y,w,h);
  874. }
  875. function tvs_get_scale_x(id)
  876. {
  877. if (g_lChID == 0) return 0;
  878. return document.Tvs.GetScaleX(g_lChID, id);
  879. }
  880. function tvs_get_scale_y(id)
  881. {
  882. if (g_lChID == 0) return 0;
  883. return document.Tvs.GetScaleY(g_lChID, id);
  884. }
  885. function tvs_get_scale_w(id)
  886. {
  887. if (g_lChID == 0) return 255;
  888. return document.Tvs.GetScaleWidth(g_lChID, id);
  889. }
  890. function tvs_get_scale_h(id)
  891. {
  892. if (g_lChID == 0) return 255;
  893. return document.Tvs.GetScaleheight(g_lChID, id);
  894. }
  895. function tvs_set_privacy_mask_region_edit(set,region)
  896. {
  897. if (g_lChID == 0) return;
  898. document.Tvs.SetPrivacyRegionEdit(g_lChID, region,set,TN_MVD_LIVE);
  899. }
  900. function tvs_set_privacy_mask_region_edit3(set,region)
  901. {
  902. if (g_lChID == 0) return;
  903. document.Tvs.SetPrivacyRegionEdit3(g_lChID, region,set,TN_MVD_LIVE);
  904. }
  905. function tvs_set_screen_calibration_mode(mode)
  906. {
  907. if (g_lChID == 0) return;
  908. setTimeout(function() { document.Tvs.SetScreenCalibrationMode(g_lChID, mode); }, 0);
  909. }
  910. function tvs_config_camera_module(code, down)
  911. {
  912. if (g_lChID == 0) return;
  913. document.Tvs.ConfigCameraModule(g_lChID, code, down);
  914. }
  915. function tvs_get_keepaspectratio()
  916. {
  917. if (g_lChID == 0) return true;
  918. return document.Tvs.KeepAspectRatio(g_lChID);
  919. }
  920. function tvs_set_fullscreen(mode)
  921. {
  922. if (g_lChID == 0) return;
  923. return document.Tvs.SetFullScreen(g_lChID, mode);
  924. }
  925. function tvs_get_width()
  926. {
  927. return document.Tvs.width;
  928. }
  929. function tvs_get_height()
  930. {
  931. return document.Tvs.height;
  932. }
  933. function tvs_set_width(w)
  934. {
  935. document.Tvs.width = w;
  936. }
  937. function tvs_set_height(h)
  938. {
  939. document.Tvs.height = h;
  940. }
  941. function tvs_set_width_detection_4ch(w)
  942. {
  943. if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
  944. document.Tvs4_0.width = w ;
  945. document.Tvs4_1.width = w ;
  946. document.Tvs4_2.width = w ;
  947. document.Tvs4_3.width = w ;
  948. }
  949. }
  950. function tvs_set_height_detection_4ch(h)
  951. {
  952. if(SUPPORT_DETECTION_CAM_4CH == g_detection_4ch_support) {
  953. document.Tvs4_0.height = h ;
  954. document.Tvs4_1.height = h ;
  955. document.Tvs4_2.height = h ;
  956. document.Tvs4_3.height = h ;
  957. }
  958. }
  959. function tvs_get_width_detection_4ch(ch)
  960. {
  961. if(ch >= 0 && ch < 4) {
  962. if(0 == ch) {
  963. return document.Tvs4_0.width ;
  964. }
  965. else if(1 == ch) {
  966. return document.Tvs4_1.width ;
  967. }
  968. else if(2 == ch) {
  969. return document.Tvs4_2.width ;
  970. }
  971. else if(3 == ch) {
  972. return document.Tvs4_3.width ;
  973. }
  974. }
  975. return document.Tvs4_0.width ;
  976. }
  977. function tvs_get_height_detection_4ch(ch)
  978. {
  979. if(ch >= 0 && ch < 4) {
  980. if(0 == ch) {
  981. return document.Tvs4_0.height ;
  982. }
  983. else if(1 == ch) {
  984. return document.Tvs4_1.height ;
  985. }
  986. else if(2 == ch) {
  987. return document.Tvs4_2.height ;
  988. }
  989. else if(3 == ch) {
  990. return document.Tvs4_3.height ;
  991. }
  992. }
  993. return document.Tvs4_0.height ;
  994. }
  995. function tvs_get_location(path)
  996. {
  997. return document.Tvs.FindLocation(path);
  998. }
  999. function tvs_ivs_StartLineEdit()
  1000. {
  1001. if (g_lChID == 0) return;
  1002. if(USEIVS == 1){
  1003. g_ivs.StartLineEdit(g_lChID);
  1004. g_ivs.SetLineEditColor(g_lChID, 0x80FF0000);
  1005. g_ivs.SetLineEditWidth(g_lChID, 0.8);
  1006. }
  1007. }
  1008. function tvs_ivs_StopLineEdit()
  1009. {
  1010. if (g_lChID == 0) return;
  1011. if(USEIVS == 1)
  1012. g_ivs.StopLineEdit(g_lChID);
  1013. }
  1014. function tvs_ivs_SetLineData2(x1, y1, x2, y2)
  1015. {
  1016. if (g_lChID == 0) return;
  1017. if(USEIVS == 1)
  1018. g_ivs.SetLineData2(g_lChID, x1, y1, x2, y2);
  1019. }
  1020. function tvs_ivs_GetLineData2(n)
  1021. {
  1022. if (g_lChID == 0) return 0;
  1023. if(USEIVS == 1)
  1024. return g_ivs.GetLineData2(g_lChID, n);
  1025. }
  1026. function tvs_ivs_StartCellEdit()
  1027. {
  1028. if (g_lChID == 0) return;
  1029. if(USEIVS == 1){
  1030. g_ivs.StartCellEdit(g_lChID);
  1031. g_ivs.SetCellEditColor(g_lChID, 0xFF000000, 0x60FF8080);
  1032. g_ivs.SetCellCount(g_lChID, 24, 32);
  1033. }
  1034. }
  1035. function tvs_ivs_StopCellEdit()
  1036. {
  1037. if (g_lChID == 0) return;
  1038. if(USEIVS == 1)
  1039. g_ivs.StopCellEdit(g_lChID);
  1040. }
  1041. function tvs_ivs_SetCellEditMode(b)
  1042. {
  1043. if (g_lChID == 0) return;
  1044. if(USEIVS == 1)
  1045. g_ivs.SetCellEditMode(g_lChID, b);
  1046. }
  1047. function tvs_ivs_SetCellData2(str)
  1048. {
  1049. if (g_lChID == 0) return;
  1050. if(USEIVS == 1)
  1051. g_ivs.SetCellData2(g_lChID, 24, 32, str);
  1052. }
  1053. function tvs_ivs_GetCellData2()
  1054. {
  1055. if (g_lChID == 0) return null;
  1056. if(USEIVS == 1)
  1057. return g_ivs.GetCellData2(g_lChID);
  1058. }
  1059. function tvs_ivs_StartIVSObjectDisplay()
  1060. {
  1061. if (g_lChID == 0) return null;
  1062. if(USEIVS == 1)
  1063. g_ivs.StartIVSObjectDisplay(g_lChID, 3, 0xFF000000, 0xFFFF0000, 0, 0);
  1064. }
  1065. function tvs_ivs_StopIVSObjectDisplay()
  1066. {
  1067. if (g_lChID == 0) return null;
  1068. if(USEIVS == 1)
  1069. g_ivs.StopIVSObjectDisplay(g_lChID);
  1070. }
  1071. function tvs_StatShowTrigger()
  1072. {
  1073. if (g_lChID == 0) return null;
  1074. document.Tvs.StatShowTrigger();
  1075. }
  1076. var g_lChID2 = 0;
  1077. function tvs2_connect(server_addr, port, id, password, sub)
  1078. {
  1079. var max_resolution = parseInt(readSetupByKey("VID_TVS_DISPLAY_RES"));
  1080. if(UseActiveX == 1){
  1081. var agt = navigator.userAgent.toLowerCase();
  1082. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  1083. }
  1084. if (g_lChID2 > 0)
  1085. {
  1086. return;
  1087. }
  1088. if($("[name=SYS_BOARDID]").val() == 0x1003 || $("[name=SYS_BOARDID]").val() == 0x1007){
  1089. if(sub == 0){
  1090. sAddress = 'vsnm://' + server_addr + ':' + port + '//video1+audio1';
  1091. }
  1092. else if(sub == 1){
  1093. sAddress = 'vsnm://' + server_addr + ':' + port + '//video2';
  1094. }
  1095. else if(sub == 2){
  1096. sAddress = 'vsnm://' + server_addr + ':' + port + '//video3';
  1097. }
  1098. else if(sub == 3){
  1099. sAddress = 'vsnm://' + server_addr + ':' + port + '//video4';
  1100. }
  1101. else if(sub == 4){
  1102. sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s+audio1';
  1103. }
  1104. else if(sub == 5){
  1105. sAddress = 'vsnm://' + server_addr + ':' + port + '//video2s';
  1106. }
  1107. else if(sub == 6){
  1108. sAddress = 'vsnm://' + server_addr + ':' + port + '//video3s';
  1109. }
  1110. else if(sub == 7){
  1111. sAddress = 'vsnm://' + server_addr + ':' + port + '//video4s';
  1112. }
  1113. else if(sub == 8){
  1114. sAddress = 'vsnm://' + server_addr + ':' + port + '//video5';
  1115. }
  1116. }
  1117. else{
  1118. if(sub == 0){
  1119. sAddress = 'vsnm://' + server_addr + ':' + port + '//video1+audio1';
  1120. }
  1121. else if(sub == 1){
  1122. sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s+audio1';
  1123. }
  1124. else if(sub == 2){
  1125. sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s2+audio1';
  1126. }
  1127. else{
  1128. sAddress = 'vsnm://' + server_addr + ':' + port + '//video1s3+audio1';
  1129. }
  1130. }
  1131. document.Tvs2.SetLocalConfig(3,max_resolution);
  1132. document.Tvs2.SetLocalConfig(9, -1); // Autoplay on
  1133. document.Tvs2.SetLocalConfig(42, 0); // SetSnapshotAspectRatio
  1134. g_lChID2 = document.Tvs2.Connect(sAddress, id, password);
  1135. // alert('after connect');
  1136. // if (!document.Tvs2.Play(g_lChID))
  1137. // {
  1138. // return;
  1139. // }
  1140. document.Tvs2.SetMute(g_lChID2, 0);
  1141. document.Tvs2.SetAutoReconnect(g_lChID2, -1);
  1142. document.Tvs2.SetPTZControlSpeed(g_lChID2, 0, -1);
  1143. document.Tvs2.SetPTZControlSpeed(g_lChID2, 1, -1);
  1144. document.Tvs2.SetPTZControlSpeed(g_lChID2, 2, -1);
  1145. // document.Tvs2.DecodingOption(2) = 0;
  1146. }
  1147. function tvs2_discon()
  1148. {
  1149. if(UseActiveX == 1){
  1150. var agt = navigator.userAgent.toLowerCase();
  1151. if (agt.indexOf("msie") == -1 && agt.indexOf("trident") == -1) return;
  1152. }
  1153. if (g_lChID2 == 0)
  1154. {
  1155. return;
  1156. }
  1157. document.Tvs2.Pause(g_lChID2);
  1158. document.Tvs2.SetMute(g_lChID2, 1);
  1159. document.Tvs2.Disconnect(g_lChID2);
  1160. g_lChID2 = 0;
  1161. // alert('connected');
  1162. pause(500);
  1163. }
  1164. function OnServerNotify() {
  1165. }
  1166. function OnFileRecordNotify() {
  1167. }
  1168. function tvs_ivs_SetLineEditEntryDirection(){
  1169. if(g_lChID == 0) {
  1170. return;
  1171. }
  1172. if(USEIVS == 1) {
  1173. if(UseActiveX == 1) {
  1174. g_ivs.SetLineEditEntryDirection(g_lChID, 1); // 방향을 지정함.
  1175. }
  1176. }
  1177. }
  1178. function tvs_ivs_GetLineEditEntryDirection(){
  1179. if(g_lChID == 0) {
  1180. return;
  1181. }
  1182. if(USEIVS == 1) {
  1183. if(UseActiveX == 1) {
  1184. return g_ivs.GetLineEditEntryDirection(g_lChID); // 방향을 지정함.
  1185. }
  1186. }
  1187. }
  1188. function tvs_ivs_StartPolygonEdit()
  1189. {
  1190. if (g_lChID == 0) return;
  1191. if(USEIVS == 1){
  1192. g_ivs.StartPolygonEdit(g_lChID);
  1193. }
  1194. }
  1195. function tvs_ivs_StopPolygonEdit()
  1196. {
  1197. if (g_lChID == 0) return;
  1198. if(USEIVS == 1){
  1199. g_ivs.StopPolygonEdit(g_lChID);
  1200. }
  1201. }
  1202. function tvs_ivs_SetPolygonData(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8)
  1203. {
  1204. if (g_lChID == 0) return;
  1205. if(USEIVS == 1) {
  1206. g_ivs.SetPolygonData(g_lChID, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8);
  1207. }
  1208. }
  1209. function tvs_ivs_SetPolygonData16(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15, x16, y16)
  1210. {
  1211. if (g_lChID == 0) return;
  1212. if(USEIVS == 1) {
  1213. g_ivs.SetPolygonData16(g_lChID, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8, x9, y9, x10, y10, x11, y11, x12, y12, x13, y13, x14, y14, x15, y15, x16, y16)
  1214. }
  1215. }
  1216. function tvs_ivs_GetPolygonX(n)
  1217. {
  1218. if (g_lChID == 0) return;
  1219. if(USEIVS == 1) {
  1220. return g_ivs.GetPolygonDataX(g_lChID, n);
  1221. }
  1222. }
  1223. function tvs_ivs_GetPolygonY(n)
  1224. {
  1225. if (g_lChID == 0) return;
  1226. if(USEIVS == 1) {
  1227. return g_ivs.GetPolygonDataY(g_lChID, n);
  1228. }
  1229. }
  1230. function tvs_ivs_imp_StartLineCrossEdit()
  1231. {
  1232. if (g_lChID == 0) return;
  1233. if(USEIVS == 1){
  1234. g_ivs.StartLineCrossEdit(g_lChID);
  1235. g_ivs.SetLineCrossConfig(g_lChID, 0, 0.8, 0xFFD01202);
  1236. g_ivs.SetLineCrossConfig(g_lChID, 1, 0.8, 0xFFA35827);
  1237. g_ivs.SetLineCrossConfig(g_lChID, 2, 0.8, 0xFFCEB87B);
  1238. g_ivs.SetLineCrossConfig(g_lChID, 3, 0.8, 0xFF7CCC83);
  1239. g_ivs.SetLineCrossConfig(g_lChID, 4, 0.8, 0xFF7EC4CB);
  1240. g_ivs.SetLineCrossConfig(g_lChID, 5, 0.8, 0xFF7C93CC);
  1241. g_ivs.SetLineCrossConfig(g_lChID, 6, 0.8, 0xFFC783A3);
  1242. g_ivs.SetLineCrossConfig(g_lChID, 7, 0.8, 0xFF96A327);
  1243. }
  1244. }
  1245. function tvs_ivs_imp_StopLineCrossEdit()
  1246. {
  1247. if (g_lChID == 0) return;
  1248. if(USEIVS == 1){
  1249. g_ivs.StopLineCrossEdit(g_lChID);
  1250. }
  1251. }
  1252. // num(0~7), mode(0(erase), 1(set))
  1253. function tvs_ivs_imp_SetLineCrossEditMode(num, mode)
  1254. {
  1255. if (g_lChID == 0) return;
  1256. if(USEIVS == 1){
  1257. g_ivs.SetLineCrossEditMode(g_lChID, num, mode);
  1258. }
  1259. }
  1260. function tvs_ivs_imp_SetLineCrossData(startx1, starty1, endx1, endy1, startx2, starty2, endx2, endy2,
  1261. startx3, starty3, endx3, endy3, startx4, starty4, endx4, endy4, startx5, starty5, endx5, endy5,
  1262. startx6, starty6, endx6, endy6, startx7, starty7, endx7, endy7, startx8, starty8, endx8, endy8)
  1263. {
  1264. if (g_lChID == 0) return;
  1265. if(USEIVS == 1) {
  1266. g_ivs.SetLineCrossData(g_lChID, startx1, starty1, endx1, endy1, startx2, starty2, endx2, endy2,
  1267. startx3, starty3, endx3, endy3, startx4, starty4, endx4, endy4, startx5, starty5, endx5, endy5,
  1268. startx6, starty6, endx6, endy6, startx7, starty7, endx7, endy7, startx8, starty8, endx8, endy8);
  1269. }
  1270. }
  1271. function tvs_ivs_imp_GetLineCrossStartX(n)
  1272. {
  1273. if (g_lChID == 0) return;
  1274. if(USEIVS == 1) {
  1275. return g_ivs.GetLineCrossStartX(g_lChID, n);
  1276. }
  1277. }
  1278. function tvs_ivs_imp_GetLineCrossStartY(n)
  1279. {
  1280. if (g_lChID == 0) return;
  1281. if(USEIVS == 1) {
  1282. return g_ivs.GetLineCrossStartY(g_lChID, n);
  1283. }
  1284. }
  1285. function tvs_ivs_imp_GetLineCrossEndX(n)
  1286. {
  1287. if (g_lChID == 0) return;
  1288. if(USEIVS == 1) {
  1289. return g_ivs.GetLineCrossEndX(g_lChID, n);
  1290. }
  1291. }
  1292. function tvs_ivs_imp_GetLineCrossEndY(n)
  1293. {
  1294. if (g_lChID == 0) return;
  1295. if(USEIVS == 1) {
  1296. return g_ivs.GetLineCrossEndY(g_lChID, n);
  1297. }
  1298. }
  1299. function tvs_ivs_imp_SetPolygonConfig(line_thickness, line_color, circle_diameter, circle_color_selected)
  1300. {
  1301. /*
  1302. color : ARGB DWORD Value (Default : 0xFFFF0000)
  1303. thickness : 1.0(Default)
  1304. diameter : 1.0(Default)
  1305. */
  1306. if (g_lChID == 0) return;
  1307. if(USEIVS == 1){
  1308. g_ivs.SetPolygonConfig(g_lChID, line_thickness, line_color, circle_diameter, circle_color_selected);
  1309. }
  1310. }
  1311. function tvs_ivs_imp_SetLineCrossConfig(line_num, line_thickness, line_color)
  1312. {
  1313. /*
  1314. thickness : 1.0(Default)
  1315. */
  1316. if (g_lChID == 0) return;
  1317. if(USEIVS == 1){
  1318. g_ivs.SetLineCrossConfig(g_lChID, line_num, line_thickness, line_color);
  1319. }
  1320. }
  1321. function tvs_HiRoi_SetROIMode(stream_index, region_index, mode)
  1322. {
  1323. // mode : off(0), set(1), erase(2), display(3)
  1324. if(g_lChID == 0) return;
  1325. if(stream_index < 0 || stream_index > 15) {
  1326. return;
  1327. }
  1328. // if(region_index < 0 || region_index > 7) {
  1329. if(region_index < 0 || region_index > 3) {
  1330. return;
  1331. }
  1332. if(mode < 0 || mode > 3) {
  1333. return;
  1334. }
  1335. document.Tvs.SetROIMode(g_lChID, stream_index, region_index, mode);
  1336. }
  1337. function tvs_HiRoi_SetROIDataWithMin(stream_index, region_index, x, y, w, h, min_w, min_h)
  1338. {
  1339. if(g_lChID == 0) return;
  1340. if(stream_index < 0 || stream_index > 15) {
  1341. return;
  1342. }
  1343. // if(region_index < 0 || region_index > 7) {
  1344. if(region_index < 0 || region_index > 3) {
  1345. return;
  1346. }
  1347. document.Tvs.SetROIDataWithMin(g_lChID, stream_index, region_index, x, y, w, h, min_w, min_h);
  1348. }
  1349. function tvs_HiRoi_SetROIData(stream_index, region_index, x, y, w, h)
  1350. {
  1351. if(g_lChID == 0) return;
  1352. if(stream_index < 0 || stream_index > 15) {
  1353. return;
  1354. }
  1355. // if(region_index < 0 || region_index > 7) {
  1356. if(region_index < 0 || region_index > 3) {
  1357. return;
  1358. }
  1359. document.Tvs.SetROIData(g_lChID, stream_index, region_index, x, y, w, h);
  1360. }
  1361. function tvs_HiRoi_GetROIStartX(stream_index, region_index)
  1362. {
  1363. if(g_lChID == 0) return;
  1364. if(stream_index < 0 || stream_index > 15) {
  1365. return;
  1366. }
  1367. // if(region_index < 0 || region_index > 7) {
  1368. if(region_index < 0 || region_index > 3) {
  1369. return;
  1370. }
  1371. return document.Tvs.GetROIStartX(g_lChID, stream_index, region_index);
  1372. }
  1373. function tvs_HiRoi_GetROIStartY(stream_index, region_index)
  1374. {
  1375. if(g_lChID == 0) return;
  1376. if(stream_index < 0 || stream_index > 15) {
  1377. return;
  1378. }
  1379. // if(region_index < 0 || region_index > 7) {
  1380. if(region_index < 0 || region_index > 3) {
  1381. return;
  1382. }
  1383. return document.Tvs.GetROIStartY(g_lChID, stream_index, region_index);
  1384. }
  1385. function tvs_HiRoi_GetROIWidth(stream_index, region_index)
  1386. {
  1387. if(g_lChID == 0) return;
  1388. if(stream_index < 0 || stream_index > 15) {
  1389. return;
  1390. }
  1391. // if(region_index < 0 || region_index > 7) {
  1392. if(region_index < 0 || region_index > 3) {
  1393. return;
  1394. }
  1395. return document.Tvs.GetROIWidth(g_lChID, stream_index, region_index);
  1396. }
  1397. function tvs_HiRoi_GetROIHeight(stream_index, region_index)
  1398. {
  1399. if(g_lChID == 0) return;
  1400. if(stream_index < 0 || stream_index > 15) {
  1401. return;
  1402. }
  1403. // if(region_index < 0 || region_index > 7) {
  1404. if(region_index < 0 || region_index > 3) {
  1405. return;
  1406. }
  1407. return document.Tvs.GetROIHeight(g_lChID, stream_index, region_index);
  1408. }
  1409. // x, y : 0 ~ 100
  1410. function tvs_SetDrawCross(x, y, length, width, color)
  1411. {
  1412. if (g_lChID == 0) return;
  1413. setTimeout(function() { g_display.SetDrawCross(g_lChID, x, y, length, width, color); }, 0);
  1414. }
  1415. function tvs_SetDrawCross_4Ch(ch_id, x, y, length, width, color)
  1416. {
  1417. // console.log("-- ch_id : " + ch_id + " x : "+ x + " y :" + y );
  1418. if(UseActiveX == 1){
  1419. if(null != g_detection_4ch_Displays[ch_id]) {
  1420. g_detection_4ch_Displays[ch_id].SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
  1421. // g_detection_4ch_Displays[ch_id].SetDrawCross(g_detection_4ch_IDs[ch_id], "cross.png", x, y, width );
  1422. }
  1423. }
  1424. else {
  1425. if(0 == ch_id) {
  1426. document.Tvs4_0.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
  1427. }
  1428. else if(1 == ch_id) {
  1429. document.Tvs4_1.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
  1430. }
  1431. else if(2 == ch_id) {
  1432. document.Tvs4_2.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
  1433. }
  1434. else {
  1435. document.Tvs4_3.SetDrawCross(g_detection_4ch_IDs[ch_id], x, y, length, width , color);
  1436. }
  1437. }
  1438. }
  1439. function tvs_SetStraightLineMode(stream_index, region_index, mode, color, width)
  1440. {
  1441. // mode : off(0), set(1), erase(2), display(3)
  1442. if(g_lChID == 0) {
  1443. return;
  1444. }
  1445. if(stream_index < 0 || stream_index > 15) {
  1446. return;
  1447. }
  1448. if(region_index < 0 || region_index > 7) {
  1449. return;
  1450. }
  1451. if(mode < 0 || mode > 3) {
  1452. return;
  1453. }
  1454. document.Tvs.SetStraightLineMode(g_lChID, stream_index, region_index, mode);
  1455. document.Tvs.SetStraightLineColor(g_lChID, stream_index, region_index, color);
  1456. document.Tvs.SetStraightLineWidth(g_lChID, stream_index, region_index, width);
  1457. }
  1458. function tvs_SetStraightLineData(stream_index, region_index, direction, position)
  1459. {
  1460. // direction : horizontal(0), vertical(1)
  1461. if(g_lChID == 0) return;
  1462. if(stream_index < 0 || stream_index > 15) {
  1463. return;
  1464. }
  1465. if(region_index < 0 || region_index > 7) {
  1466. return;
  1467. }
  1468. if(direction != 0 && direction != 1) {
  1469. return;
  1470. }
  1471. if(position < 0) position = 0;
  1472. if(position > 1000) position = 1000;
  1473. document.Tvs.SetStraightLineData(g_lChID, stream_index, region_index, direction, position);
  1474. }
  1475. function tvs_GetStraightLineDirection(stream_index, region_index)
  1476. {
  1477. if(g_lChID == 0) return;
  1478. if(stream_index < 0 || stream_index > 15) {
  1479. return -1;
  1480. }
  1481. if(region_index < 0 || region_index > 7) {
  1482. return -1;
  1483. }
  1484. return document.Tvs.GetStraightLineDirection(g_lChID, stream_index, region_index);
  1485. }
  1486. function tvs_GetStraightLinePosition(stream_index, region_index)
  1487. {
  1488. if(g_lChID == 0) return;
  1489. if(stream_index < 0 || stream_index > 15) {
  1490. return -1;
  1491. }
  1492. if(region_index < 0 || region_index > 7) {
  1493. return -1;
  1494. }
  1495. return document.Tvs.GetStraightLinePosition(g_lChID, stream_index, region_index);
  1496. }
  1497. /* Polygon8 (TVS_VERSION >= 1,6,57,122) */
  1498. // mode : 0(off), 1(edit), 2(erase), 3(display)
  1499. // thick : float
  1500. // color : hex
  1501. function tvs_SetPolygon8Mode(stream_index, polygon_index, mode, thick, line_color, circle_color, circle_sel_color)
  1502. {
  1503. if (g_lChID == 0) return;
  1504. document.Tvs.SetPolygon8Color(g_lChID, stream_index, polygon_index, line_color, circle_color, circle_sel_color);
  1505. document.Tvs.SetPolygon8Thickness(g_lChID, stream_index, polygon_index, thick);
  1506. return document.Tvs.SetPolygon8Mode(g_lChID, stream_index, polygon_index, mode);
  1507. }
  1508. function tvs_SetPolygon8Data(stream_index, polygon_index, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7)
  1509. {
  1510. if (g_lChID == 0) return;
  1511. return document.Tvs.SetPolygon8Data(g_lChID, stream_index, polygon_index, x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7);
  1512. }
  1513. function tvs_GetPolygon8DataX(stream_index, polygon_index, point_index)
  1514. {
  1515. if (g_lChID == 0) return;
  1516. return document.Tvs.GetPolygon8DataX(g_lChID, stream_index, polygon_index, point_index);
  1517. }
  1518. function tvs_GetPolygon8DataY(stream_index, polygon_index, point_index)
  1519. {
  1520. if (g_lChID == 0) return;
  1521. return document.Tvs.GetPolygon8DataY(g_lChID, stream_index, polygon_index, point_index);
  1522. }
  1523. /* Line (TVS_VERSION >= 1,6,57,122) */
  1524. // mode : 0(off), 1(edit), 2(erase), 3(display)
  1525. // thick : float
  1526. // color : hex
  1527. function tvs_SetLineMode(stream_index, line_index, mode, thick, color)
  1528. {
  1529. if (g_lChID == 0) return;
  1530. document.Tvs.SetLineColor(g_lChID, stream_index, line_index, color);
  1531. document.Tvs.SetLineThickness(g_lChID, stream_index, line_index, thick);
  1532. return document.Tvs.SetLineMode(g_lChID, stream_index, line_index, mode);
  1533. }
  1534. // draw_arrow : 0(normal line), 1(arrow)
  1535. function tvs_SetLineData(stream_index, line_index, draw_arrow, startx, starty, endx, endy)
  1536. {
  1537. if (g_lChID == 0) return;
  1538. return document.Tvs.SetLineData(g_lChID, stream_index, line_index, draw_arrow, startx, starty, endx, endy);
  1539. }
  1540. // point_index : 0(start x), 1(end x)
  1541. function tvs_GetLineDataX(stream_index, line_index, point_index)
  1542. {
  1543. if (g_lChID == 0) return;
  1544. return document.Tvs.GetLineDataX(g_lChID, stream_index, line_index, point_index);
  1545. }
  1546. // point_index : 0(start y), 1(end y)
  1547. function tvs_GetLineDataY(stream_index, line_index, point_index)
  1548. {
  1549. if (g_lChID == 0) return;
  1550. return document.Tvs.GetLineDataY(g_lChID, stream_index, line_index, point_index);
  1551. }