source: titan/plugins/instar/instar.h @ 40786

Last change on this file since 40786 was 40786, checked in by gost, 6 years ago

[plugins] ip-kamera... new type

  • Property svn:executable set to *
File size: 15.2 KB
Line 
1//#ifndef INSTAR_H
2//#define INSTAR_H
3
4char* cam1 = NULL;
5char* cam2 = NULL;
6char* cam11 = NULL;
7char* cam21 = NULL;
8struct skin* instar_screen = NULL;
9struct skin* instar_pic1 = NULL;
10struct skin* instar_actcam1 = NULL;
11int actcam = 1;
12
13struct clist *myconfig[LISTHASHSIZE] = {NULL};
14char* instarconf = NULL;
15
16int show_control()
17{
18        char* tmpstr = NULL;
19        char* tempcam = NULL;
20        char* position = NULL;
21        char* positionstop = NULL;
22        int rcret = 0;
23        int rcode = 0;
24        int ohnestop = 0;
25       
26        if(actcam == 1)
27                tempcam = cam1;
28        if(actcam == 2)
29                tempcam = cam2;
30       
31        setfbtransparent(255);
32       
33        printf("[ip-cam] Aufruf1: %s\n", cam1);
34        printf("[ip-cam] Aufruf2: %s\n", cam2);
35       
36        while(1)
37        {
38                        if(cam1 != NULL)
39                        {
40                                if(getconfigint("instar_1", NULL) == 1)
41                                        tmpstr = ostrcat(cam1, "/image/jpeg.cgi", 0, 0);
42                                else if(getconfigint("instar_1", NULL) == 2)
43                                        tmpstr = ostrcat(cam1, "/tmpfs/auto.jpg", 0, 0);
44                                else if(getconfigint("instar_1", NULL) == 3)
45                                        tmpstr = ostrcat(cam1, "/onvif/GetSnapshotUri", 0, 0);
46                                else if(getconfigint("instar_1", NULL) == 4)
47                                        tmpstr = ostrcat(cam1, "/image", 0, 0);
48                                else if(getconfigint("instar_1", NULL) == 5)
49                                {
50                                        tmpstr = ostrcat(cam1, "/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2", 0, 0);
51                                        tmpstr = ostrcat(tmpstr, cam11, 1, 0);
52                                }
53                                else
54                                        tmpstr = ostrcat(cam1, "/snapshot.cgi", 0, 0);
55                                if(getconfigint("instar_alterwebif", NULL) == 1)
56                                        tmpstr = ostrcat(tmpstr, " > /tmp/instar1.jpg", 1, 0);
57                                system(tmpstr);
58                                free(tmpstr); tmpstr = NULL;
59                        }
60                        if(cam2 != NULL)
61                        {
62                                if(getconfigint("instar_2", NULL) == 1)
63                                        tmpstr = ostrcat(cam2, "/image/jpeg.cgi", 0, 0);
64                                else if(getconfigint("instar_2", NULL) == 2)
65                                        tmpstr = ostrcat(cam2, "/tmpfs/auto.jpg", 0, 0);
66                                else if(getconfigint("instar_2", NULL) == 3)
67                                        tmpstr = ostrcat(cam2, "/onvif/GetSnapshotUri", 0, 0);
68                                else if(getconfigint("instar_2", NULL) == 4)
69                                        tmpstr = ostrcat(cam2, "/image", 0, 0);
70                                else if(getconfigint("instar_2", NULL) == 5)
71                                {
72                                        tmpstr = ostrcat(cam2, "/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2", 0, 0);
73                                        tmpstr = ostrcat(tmpstr, cam21, 1, 0);
74                                }
75                                else
76                                        tmpstr = ostrcat(cam2, "/snapshot.cgi", 0, 0);
77                                if(getconfigint("instar_alterwebif", NULL) == 1)
78                                        tmpstr = ostrcat(tmpstr, " > /tmp/instar2.jpg", 1, 0);
79                                system(tmpstr);
80                                free(tmpstr); tmpstr = NULL;
81                        }
82                               
83                drawscreen(instar_screen, 0, 0);
84                rcret = waitrc(instar_screen, 100, 0);
85                ohnestop = 0;
86
87                if(rcret == getrcconfigint("rcexit", NULL)) break;
88               
89                if(rcret == getrcconfigint("rcinfo", NULL))
90                {
91                        //addlist(myconfig, "InstarCamAutostart", "nein");
92                        rcode = 1;
93                        break;
94                }       
95                       
96                if(rcret == getrcconfigint("rc1", NULL)) {
97                        position = ostrcat("/decoder_control.cgi?command=", "31", 0 , 0);
98                        ohnestop = 1;
99                }
100                if(rcret == getrcconfigint("rc2", NULL)) {
101                        position = ostrcat("/decoder_control.cgi?command=", "33", 0 , 0);
102                        ohnestop = 1;
103                }
104                if(rcret == getrcconfigint("rc3", NULL)) {
105                        position = ostrcat("/decoder_control.cgi?command=", "35", 0 , 0);
106                        ohnestop = 1;
107                }
108                if(rcret == getrcconfigint("rc4", NULL)) {
109                        position = ostrcat("/decoder_control.cgi?command=", "37", 0 , 0);
110                        ohnestop = 1;
111                }
112                if(rcret == getrcconfigint("rc5", NULL)) {
113                        position = ostrcat("/decoder_control.cgi?command=", "39", 0 , 0);
114                        ohnestop = 1;
115                }
116                if(rcret == getrcconfigint("rc6", NULL)) {
117                        position = ostrcat("/decoder_control.cgi?command=", "41", 0 , 0);
118                        ohnestop = 1;
119                }
120                if(rcret == getrcconfigint("rc7", NULL)) {
121                        position = ostrcat("/decoder_control.cgi?command=", "43", 0 , 0);
122                        ohnestop = 1;
123                }
124                if(rcret == getrcconfigint("rc8", NULL)) {
125                        position = ostrcat("/decoder_control.cgi?command=", "45", 0 , 0);
126                        ohnestop = 1;
127                }
128                if(rcret == getrcconfigint("rc9", NULL)) {
129                        position = ostrcat("/decoder_control.cgi?command=", "47", 0 , 0);
130                        ohnestop = 1;
131                }
132                if(positionstop == NULL)
133                {
134                        if(rcret == getrcconfigint("rcup", NULL)) {
135                                position = ostrcat("/decoder_control.cgi?command=", "0", 0 , 0);
136                                positionstop = ostrcat("/decoder_control.cgi?command=", "1", 0 , 0);
137                        }
138                        if(rcret == getrcconfigint("rcdown", NULL)) {
139                                position = ostrcat("/decoder_control.cgi?command=", "2", 0 , 0);
140                                positionstop = ostrcat("/decoder_control.cgi?command=", "3", 0 , 0);
141                        }
142                        if(rcret == getrcconfigint("rcleft", NULL)) {
143                                position = ostrcat("/decoder_control.cgi?command=", "4", 0 , 0);
144                                positionstop = ostrcat("/decoder_control.cgi?command=", "5", 0 , 0);
145                        }
146                        if(rcret == getrcconfigint("rcright", NULL)) {
147                                position = ostrcat("/decoder_control.cgi?command=", "6", 0 , 0);
148                                positionstop = ostrcat("/decoder_control.cgi?command=", "7", 0 , 0);
149                        }
150                        if(rcret == getrcconfigint("rcchup", NULL)) {
151                                position = ostrcat("/decoder_control.cgi?command=", "16", 0 , 0);
152                                positionstop = ostrcat("/decoder_control.cgi?command=", "17", 0 , 0);
153                        }
154                        if(rcret == getrcconfigint("rcchdown", NULL)) {
155                                position = ostrcat("/decoder_control.cgi?command=", "18", 0 , 0);
156                                positionstop = ostrcat("/decoder_control.cgi?command=", "19", 0 , 0);
157                        }
158                }
159               
160                if(tempcam != NULL && rcret != RCTIMEOUT)
161                {
162                        if(positionstop != NULL && ohnestop == 1)
163                        {
164                                tmpstr = ostrcat(tempcam, positionstop, 0, 0);
165                                system(tmpstr);
166                                free(tmpstr); tmpstr = NULL;   
167                                free(positionstop); positionstop = NULL;
168                        }
169                        if(position != NULL)
170                        {
171                                tmpstr = ostrcat(tempcam, position, 0, 0);
172                                system(tmpstr);
173                                free(tmpstr); tmpstr = NULL;   
174                                free(position); position = NULL;
175                        }
176                        else if(positionstop != NULL)
177                        {
178                                tmpstr = ostrcat(tempcam, positionstop, 0, 0);
179                                system(tmpstr);
180                                free(tmpstr); tmpstr = NULL;   
181                                free(positionstop); positionstop = NULL;
182                        }
183                        if(rcret == getrcconfigint("rcred", NULL)) {
184                                if(actcam == 1 && cam2 != NULL) {
185                                        actcam = 2;
186                                        changepic(instar_pic1, "/tmp/instar2.jpg");
187                                        changetext(instar_actcam1, "CAM2");
188                                        tempcam = cam2;
189                                        addlist(myconfig, "InstarActCam", "2");
190                                }
191                                else if(actcam == 2 && cam1 != NULL) {
192                                        actcam = 1;
193                                        changepic(instar_pic1, "/tmp/instar1.jpg");
194                                        changetext(instar_actcam1, "CAM1");
195                                        tempcam = cam1;
196                                        addlist(myconfig, "InstarActCam", "1");
197                                }
198                        }
199                }
200        }
201
202        clearscreen(instar_screen);
203        setosdtransparent(getskinconfigint("osdtransparent", NULL));
204        return rcode;
205}
206
207int instar_settings()
208{
209       
210        int rcret = 0;
211        int rcode = 0;
212       
213        struct skin* instar_einstellungen = getscreen("instar_einstellungen");
214        struct skin* listbox = getscreennode(instar_einstellungen, "listbox");
215        struct skin* alterwebif = getscreennode(instar_einstellungen, "alterwebif");
216        struct skin* autoCam = getscreennode(instar_einstellungen, "autoCam");
217        struct skin* onCam1 = getscreennode(instar_einstellungen, "onCam1");
218        struct skin* typCam1 = getscreennode(instar_einstellungen, "typCam1");
219        struct skin* ipCam1 = getscreennode(instar_einstellungen, "ipCam1");
220        struct skin* portCam1 = getscreennode(instar_einstellungen, "portCam1");
221        struct skin* userCam1 = getscreennode(instar_einstellungen, "userCam1");
222        struct skin* passCam1 = getscreennode(instar_einstellungen, "passCam1");
223        struct skin* onCam2 = getscreennode(instar_einstellungen, "onCam2");
224        struct skin* typCam2 = getscreennode(instar_einstellungen, "typCam2");
225        struct skin* ipCam2 = getscreennode(instar_einstellungen, "ipCam2");
226        struct skin* portCam2 = getscreennode(instar_einstellungen, "portCam2");
227        struct skin* userCam2 = getscreennode(instar_einstellungen, "userCam2");
228        struct skin* passCam2 = getscreennode(instar_einstellungen, "passCam2");
229       
230        struct skin* tmp = NULL;
231
232  addchoicebox(autoCam, "nein", _("nein"));
233        addchoicebox(autoCam, "ja", _("ja"));
234        setchoiceboxselection(autoCam, getlist(myconfig, "InstarCamAutostart", NULL));
235       
236        addchoicebox(alterwebif, "0", "off");
237        addchoicebox(alterwebif, "1", "on");
238        setchoiceboxselection(alterwebif, getconfig("instar_alterwebif", NULL));
239 
240  addchoicebox(onCam1, "aus", _("aus"));
241        addchoicebox(onCam1, "ein", _("ein"));
242        setchoiceboxselection(onCam1, getlist(myconfig, "InstarCam1", NULL));   
243        addchoicebox(typCam1, "0", "0");
244        addchoicebox(typCam1, "1", "1");
245        addchoicebox(typCam1, "2", "2");
246        addchoicebox(typCam1, "3", "3");
247        addchoicebox(typCam1, "4", "4");
248        setchoiceboxselection(typCam1, getconfig("instar_1", NULL));
249        changemask(ipCam1, "abcdefghijklmnopqrstuvwxyz");
250  changeinput(ipCam1, getlist(myconfig, "InstarCam1IP", NULL));
251  changemask(portCam1, "0000");
252  changeinput(portCam1, getlist(myconfig, "InstarCam1Port", NULL));
253  changemask(userCam1, "abcdefghijklmnopqrstuvwxyz");
254  changeinput(userCam1, getlist(myconfig, "InstarCam1User", NULL));
255  changemask(passCam1, "abcdefghijklmnopqrstuvwxyz");
256  changeinput(passCam1, getlist(myconfig, "InstarCam1Pass", NULL));
257 
258  addchoicebox(onCam2, "aus", _("aus"));
259        addchoicebox(onCam2, "ein", _("ein"));
260        setchoiceboxselection(onCam2, getlist(myconfig, "InstarCam2", NULL));   
261        addchoicebox(typCam2, "0", "0");
262        addchoicebox(typCam2, "1", "1");
263        addchoicebox(typCam2, "2", "2");
264        addchoicebox(typCam2, "3", "3");
265        addchoicebox(typCam2, "4", "4");
266        setchoiceboxselection(typCam2, getconfig("instar_2", NULL));
267        changemask(ipCam2, "abcdefghijklmnopqrstuvwxyz");
268  changeinput(ipCam2, getlist(myconfig, "InstarCam2IP", NULL));
269  changemask(portCam2, "0000");
270  changeinput(portCam2, getlist(myconfig, "InstarCam2Port", NULL));
271  changemask(userCam2, "abcdefghijklmnopqrstuvwxyz");
272  changeinput(userCam2, getlist(myconfig, "InstarCam2User", NULL));
273  changemask(passCam2, "abcdefghijklmnopqrstuvwxyz");
274  changeinput(passCam2, getlist(myconfig, "InstarCam2Pass", NULL));
275 
276        drawscreen(instar_einstellungen, 0, 0);
277        addscreenrc(instar_einstellungen, listbox);
278        tmp = listbox->select;
279       
280        while(1)
281        {
282                addscreenrc(instar_einstellungen, tmp);
283                rcret = waitrc(instar_einstellungen, 1000, 0);
284                tmp = listbox->select;
285               
286                if(rcret == getrcconfigint("rcexit", NULL)) break;
287                if(rcret == getrcconfigint("rcgreen", NULL) || rcret == getrcconfigint("rcblue", NULL))
288                {
289                        addlist(myconfig, "InstarCamAutostart", autoCam->ret);
290                        addlist(myconfig, "InstarCam1", onCam1->ret);
291                        addlist(myconfig, "InstarCam1IP", ipCam1->ret);
292                        addlist(myconfig, "InstarCam1Port", portCam1->ret);
293                        addlist(myconfig, "InstarCam1User", userCam1->ret);
294                        addlist(myconfig, "InstarCam1Pass", passCam1->ret);
295                        addlist(myconfig, "InstarCam2", onCam2->ret);
296                        addlist(myconfig, "InstarCam2IP", ipCam2->ret);
297                        addlist(myconfig, "InstarCam2Port", portCam2->ret);
298                        addlist(myconfig, "InstarCam2User", userCam2->ret);
299                        addlist(myconfig, "InstarCam2Pass", passCam2->ret);
300                        writelist(myconfig, instarconf);
301                        addconfig("instar_1", typCam1->ret);
302                        addconfig("instar_2", typCam2->ret);
303                        addconfig("instar_alterwebif", alterwebif->ret);
304                        if(rcret == getrcconfigint("rcblue", NULL))
305                        {
306                                rcode = 1;
307                                break;
308                        }
309                }
310        }
311        delownerrc(instar_einstellungen);
312        clearscreen(instar_einstellungen);
313        return rcode;   
314}
315
316
317
318void instar_main()
319{
320        int rcode = 0;
321        int ext = 0;
322       
323        instarconf = createpluginpath("/instar/instar.conf", 0);
324        readconfig(instarconf, myconfig);
325
326        char* CURL = NULL;
327        CURL = createpluginpath("/instar/curl", 0);
328        if(!file_exist(CURL))
329        {
330                free(CURL); CURL = NULL;
331                CURL = ostrcat("curl", NULL, 0, 0);
332        }
333
334        if(file_exist("/tmp/callcam1"))
335        {
336                ext = 1;
337                system("rm /callcam*");
338        }
339  else if(file_exist("/tmp/callcam2"))
340        {
341                ext = 2;
342                system("rm /callcam*");
343        }
344  else
345        ext = 0;
346 
347  if(ext > 0)
348        rcode = 1;
349  else if(ostrcmp(getlist(myconfig, "InstarCamAutostart", NULL), "ja") == 0)
350                rcode = 1;
351        else
352                rcode = instar_settings();
353       
354        if(rcode == 1)
355        {
356                if(checkbox("ATEMIO5200") == 1)
357                        addconfig("pic_scale", "1");
358                while(1)
359                {
360                        if(ostrcmp(getlist(myconfig, "InstarCam1", NULL), "ein") == 0 || ext == 1)
361                        {
362                                if(getconfigint("instar_1", NULL) != 5)
363                                {
364                                        if(getconfigint("instar_alterwebif", NULL) == 0)
365                                                cam1 = ostrcat("wget --output-document=/tmp/instar1.jpg http://", getlist(myconfig, "InstarCam1User", NULL), 0, 0);
366                                        else
367                                        {
368                                                cam1 = ostrcat(CURL, " http://", 0, 0);
369                                                cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1User", NULL), 1, 0);
370                                        }
371                                        cam1 = ostrcat(cam1, ":",1, 0);
372                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Pass", NULL), 1, 0);
373                                        cam1 = ostrcat(cam1, "@",1, 0);
374                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1IP", NULL), 1, 0);
375                                        cam1 = ostrcat(cam1, ":",1, 0);
376                                        cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Port", NULL), 1, 0);
377                                }
378                                else
379                                {
380                                        if(getconfigint("instar_alterwebif", NULL) == 0)
381                                                cam1 = ostrcat("wget --output-document=/tmp/instar1.jpg http://", NULL, 0, 0);
382                                        else
383                                        {
384                                                cam1 = ostrcat(CURL, " http://", 0, 0);
385                                                cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1IP", NULL), 1, 0);
386                                                cam1 = ostrcat(cam1, ":",1, 0);
387                                                cam1 = ostrcat(cam1, getlist(myconfig, "InstarCam1Port", NULL), 1, 0);
388                                                cam11 = ostrcat("&usr=", getlist(myconfig, "InstarCam1User", NULL), 0, 0);
389                                                cam11 = ostrcat(cam11, "&pwd=", 1, 0);
390                                                cam11 = ostrcat(cam11, getlist(myconfig, "InstarCam1Pass", NULL), 1, 0);
391                                                cam11 = ostrcat(cam11, "&", 1, 0);
392                                        }
393                                }
394                        }
395                       
396               
397                       
398                        if(ostrcmp(getlist(myconfig, "InstarCam2", NULL), "ein") == 0 || ext == 2)
399                        {
400                                if(getconfigint("instar_2", NULL) != 5)
401                                {                               
402                                        if(getconfigint("instar_alterwebif", NULL) == 0)
403                                                cam2 = ostrcat("wget --output-document=/tmp/instar2.jpg http://", getlist(myconfig, "InstarCam2User", NULL), 0, 0);
404                                        else
405                                        {
406                                                cam2 = ostrcat(CURL, " http://", 0, 0);
407                                                cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2User", NULL), 1, 0);
408                                        }
409                                        cam2 = ostrcat(cam2, ":",1, 0);
410                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Pass", NULL), 1, 0);
411                                        cam2 = ostrcat(cam2, "@",1, 0);
412                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2IP", NULL), 1, 0);
413                                        cam2 = ostrcat(cam2, ":",1, 0);
414                                        cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Port", NULL), 1, 0);
415                                }
416                                else
417                                {
418                                        if(getconfigint("instar_alterwebif", NULL) == 0)
419                                                cam2 = ostrcat("wget --output-document=/tmp/instar2.jpg http://", NULL, 0, 0);
420                                        else
421                                        {
422                                                cam2 = ostrcat(CURL, " http://", 0, 0);
423                                                cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2IP", NULL), 1, 0);
424                                                cam2 = ostrcat(cam2, ":",1, 0);
425                                                cam2 = ostrcat(cam2, getlist(myconfig, "InstarCam2Port", NULL), 1, 0);
426                                                cam21 = ostrcat("&usr=", getlist(myconfig, "InstarCam2User", NULL), 0, 0);
427                                                cam21 = ostrcat(cam21, "&pwd=", 1, 0);
428                                                cam21 = ostrcat(cam21, getlist(myconfig, "InstarCam2Pass", NULL), 1, 0);
429                                                cam21 = ostrcat(cam21, "&", 1, 0);
430                                        }
431                                }                               
432                        }
433                                       
434                        instar_screen = getscreen("instar_full");
435                        instar_pic1 = getscreennode(instar_screen, "pic1");
436                        instar_actcam1 = getscreennode(instar_screen, "actcam1");
437       
438                        if(ostrcmp(getlist(myconfig, "InstarActCam", NULL), "2") == 0 && ext != 1)
439                        {
440                                actcam = 2;
441                                changepic(instar_pic1, "/tmp/instar2.jpg");
442                                changetext(instar_actcam1, "CAM2");
443                        }
444                        else
445                        {
446                                actcam = 1;
447                                changepic(instar_pic1, "/tmp/instar1.jpg");
448                                changetext(instar_actcam1, "CAM1");
449                        }
450                       
451                        rcode = show_control();
452       
453                        free(cam1), cam1 = NULL;
454                        free(cam2), cam2 = NULL;
455                        free(cam11), cam11 = NULL;
456                        free(cam21), cam21 = NULL;
457                       
458                        if(rcode == 0)
459                                break;
460                        rcode = 0;
461                       
462                        rcode = instar_settings();
463                        if(rcode == 0)
464                                break;
465                }
466                if(checkbox("ATEMIO5200") == 1)
467                        addconfig("pic_scale", "0");
468        }
469        writelist(myconfig, instarconf);
470        freelist(myconfig);
471        free(instarconf); instarconf = NULL;
472        free(CURL); CURL = NULL;
473}
Note: See TracBrowser for help on using the repository browser.