source: titan/plugins/hbbtv_mipsel/hbbtv.h @ 39442

Last change on this file since 39442 was 35138, checked in by fduenn, 9 years ago

Test hbbtv

File size: 17.8 KB
RevLine 
[15929]1#ifndef OPERA_H
2#define OPERA_H
3
[16143]4struct hbbtvfav
5{
6        char* name;
7        char* addr;
8        struct hbbtvfav* next;
9};
10
11struct hbbtvfav *hbbtvfav = NULL;
12
[15929]13#define NAME "YWNATIVE"
14#define CONTROL_PIPE_W "/tmp/"NAME"_control_w"
15#define CONTROL_PIPE_R "/tmp/"NAME"_control_r"
16#define RC_TITAN "/tmp/rc_enigma2"
17
18extern struct skin* skin;
19
20void operareceivercb(char* cmd);
21
22int operarcsockfd = -1;
23int operarcconnfd = -1;
[15959]24int opera_control_r_fd = -1;
[15929]25int operarcthread_ok = 0;
26int operareceiverthread_ok = 0;
[16297]27//100 = live play
28//0 = pause
29//1 = play
30//2 = stop
31int operaservicestate = 100;
[15929]32char* operaplayurl = NULL;
33
[16143]34struct hbbtvfav* addhbbtvfav(char *line, int count, struct hbbtvfav* last)
35{
36        //debug(1000, "in");
37        struct hbbtvfav *newnode = NULL, *prev = NULL, *node = hbbtvfav;
38        int ret = 0;
39
[19468]40        newnode = (struct hbbtvfav*)calloc(1, sizeof(struct hbbtvfav));
[16143]41        if(newnode == NULL)
42        {
43                err("no memory");
44                return NULL;
45        }
46
47        newnode->name = malloc(1024);
48        if(newnode->name == NULL)
49        {
50                err("no mem");
51                free(newnode);
52                return NULL;
53        }
54
55        newnode->addr = malloc(1024);
56        if(newnode->addr == NULL)
57        {
58                err("no mem");
59                free(newnode->name);
60                free(newnode);
61                return NULL;
62        }
63
64        ret = sscanf(line, "%[^#]#%s", newnode->name, newnode->addr);
65        if(ret != 2)
66        {
67                if(count > 0)
68                {
69                        err("hbbtvfav line %d not ok", count);
70                }
71                else
72                {
73                        err("add hbbtvfav");
74                }
75                free(newnode->name);
76                free(newnode->addr);
77                free(newnode);
78                return NULL;
79        }
80
[19468]81        newnode->name = ostrshrink(newnode->name);
82        newnode->addr = ostrshrink(newnode->addr);
[16143]83
84        if(last == NULL)
85        {
86                while(node != NULL)
87                {
88                        prev = node;
89                        node = node->next;
90                }
91        }
92        else
93        {
94                prev = last;
95                node = last->next;
96        }
97
98        if(prev == NULL)
99                hbbtvfav = newnode;
100        else
101                prev->next = newnode;
102        newnode->next = node;
103
104        //debug(1000, "out");
105        return newnode;
106}
107
108int readhbbtvfav(const char* filename)
109{
110        debug(1000, "in");
111        FILE *fd = NULL;
112        char *fileline = NULL;
[16365]113        int linecount = 0, len = 0;
[16143]114        struct hbbtvfav* last = NULL, *tmplast = NULL;
115
116        fileline = malloc(MINMALLOC);
117        if(fileline == NULL)
118        {
119                err("no memory");
120                return 1;
121        }
122
123        fd = fopen(filename, "r");
124        if(fd == NULL)
125        {
126                perr("can't open %s", filename);
127                free(fileline);
128                return 1;
129        }
130
131        while(fgets(fileline, MINMALLOC, fd) != NULL)
132        {
133                if(fileline[0] == '#' || fileline[0] == '\n')
134                        continue;
[16365]135                len = strlen(fileline) - 1;
[16367]136                if(len >= 0 && fileline[len] == '\n')
[16365]137                        fileline[len] = '\0';
[16367]138                len--;
139                if(len >= 0 && fileline[len] == '\r')
[16365]140                        fileline[len] = '\0';
[16143]141
142                linecount++;
143
144                if(last == NULL) last = tmplast;
145                last = addhbbtvfav(fileline, linecount, last);
146                if(last != NULL) tmplast = last;
147        }
148
149        free(fileline);
150        fclose(fd);
151        return 0;
152}
153
154int delhbbtvfav(char* name)
155{
156        debug(1000, "in");
157        int ret = 1;
158        struct hbbtvfav *node = hbbtvfav, *prev = hbbtvfav;
159
160        while(node != NULL)
161        {
162                if(ostrcmp(node->name, name) == 0)
163                {
164                        if(node == hbbtvfav)
165                                hbbtvfav = node->next;
166                        else
167                                prev->next = node->next;
168
169                        free(node);
170                        node = NULL;
171                        ret = 0;
172                        break;
173                }
174
175                prev = node;
176                node = node->next;
177        }
178        debug(1000, "out");
179        return ret;
180}
181
182void freehbbtvfav()
183{
184        debug(1000, "in");
185        struct hbbtvfav *node = hbbtvfav, *prev = hbbtvfav;
186
187        while(node != NULL)
188        {
189                prev = node;
190                node = node->next;
191                if(prev != NULL)
192                        delhbbtvfav(prev->name);
193        }
194        debug(1000, "out");
195}
196
[15929]197void operarcthread()
198{
199        int ret = 0;
200
201        debug(788, "opera create rc socket");
202
203        ret = sockcreate(&operarcsockfd, RC_TITAN, 1);
204        if(ret != 0) return;
205
[16297]206        //closeonexec(operarcsockfd);
[15929]207
208        debug(788, "opera wait for rc accept");
209        operarcthread_ok = 1;
210        operarcconnfd = sockaccept(&operarcsockfd, 0);
211        debug(788, "opera got rc accept");
212}
213
214void operareceiverthread(struct stimerthread* self)
215{
216        int ret = 0, control_w_fd = -1;
217        fd_set rfds;
218        struct timeval tv;
219        unsigned char* buf = NULL;
220
221        if(self == NULL) return;
222
223        control_w_fd = open(CONTROL_PIPE_W, O_RDONLY);
224        if(control_w_fd < 0)
225        {
226                perr("open or create %s", CONTROL_PIPE_W);
227                return;
228        }
229
230        fcntl(control_w_fd, F_SETFL, fcntl(control_w_fd, F_GETFL) | O_NONBLOCK);
[16297]231        //closeonexec(control_w_fd);
[15929]232
233        buf = malloc(MINMALLOC);
234        if(buf == NULL)
235        {
236                close(control_w_fd);
237                err("no mem");
238                return;
239        }
240
241        debug(788, "opera receive thread start");
242
243        operareceiverthread_ok = 1;
244        while(self->aktion != STOP)
245        {
246                tv.tv_sec = 1;
247                tv.tv_usec = 0;
248                FD_ZERO(&rfds);
249                FD_SET(control_w_fd, &rfds);
250
251                ret = TEMP_FAILURE_RETRY(select(control_w_fd + 1, &rfds, NULL, NULL, &tv));
252
253                if(ret > 0)
254                {
255                        memset(buf, 0, MINMALLOC);
256                        unsigned char* pbuf = buf;
257                        while(pbuf - buf < MINMALLOC)
258                        {
259                                unsigned char c;
260
261                                ret = read(control_w_fd, &c, 1);
262                                if(ret == 1)
263                                {
264                                        if(c == '\n') break;
265                                        *pbuf = c;
266                                        pbuf++;
267                                }
268                        }
269                        if(pbuf != buf)
270                                operareceivercb((char*)buf);
271                }
272                else if(ret == 0) //timeout
273                        continue;
274                else //error
275                {
276                        perr("select failed");
277                        usleep(10000);
278                }
279         }
280
281         close(control_w_fd); control_w_fd = -1;
282         free(buf); buf = NULL;
283         debug(788, "opera receive thread end");
284}
285
286void operasendkey(char* rckey)
287{
288        if(operarcconnfd > -1 && rckey != NULL)
289                socksend(&operarcconnfd, (unsigned char*)rckey, strlen(rckey), -1);
290        else
291        {
292                err("no opera rc context sockfd=%d", operarcconnfd);
293        }
294}
295
[16297]296//flag 0: stop live tv and start play service
297//flag 1: stop play and start live service
298//flag 2: stop play
299int operaservice(char* url, int flag)
[15991]300{
301        char* tmpstr = NULL;
302
[16297]303        //stop live tv service and start play
304        if(flag == 0)
[15991]305        {
[16297]306                if(operaservicestate == 100)
307                {
308                        int ret = servicestop(status.aktservice, 1, 1);
309                        if(ret == 1) return 1;
310                }
311
312                free(operaplayurl); operaplayurl = NULL;
313                operaplayurl = ostrcat(url, NULL, 0, 0);
314                playerstop();
315                playerafterend();
316                playerstart(operaplayurl);
317                operaservicestate = 1;
318        }
319
320        //stop play and start live service
321        if(flag == 1 && operaservicestate != 100)
322        {
323                //stop player if running
324                playerstop();
325                playerafterend();
326                free(operaplayurl); operaplayurl = NULL;
327
[16519]328                if(status.aktservice->channel != NULL)
329                {
330                        tmpstr = ostrcat(status.aktservice->channellist, NULL, 0, 0);
331                        servicestart(status.aktservice->channel, tmpstr, NULL, 3);
332                }
333                else
334                {
335                        tmpstr = ostrcat(status.lastservice->channellist, NULL, 0, 0);
336                        servicestart(status.lastservice->channel, tmpstr, NULL, 0);
337                }
[15991]338                free(tmpstr); tmpstr = NULL;
[16297]339                operaservicestate = 100;
[15991]340        }
[16297]341
342        //stop play
343        if(flag == 2 && operaservicestate != 100)
344        {
345                playerstop();
346                playerafterend();
347                free(operaplayurl); operaplayurl = NULL;
348                operaservicestate = 2;
349        }
350
351        return 0;
[15991]352}
353
[15929]354void screenopera(char* url)
355{
356        int rcret = 0, i = 0;
[15959]357        char* tmpstr = NULL, *savedir = NULL, *dirbuf = NULL;;
[15929]358        struct stimerthread* operareceiver = NULL;
[17596]359        char* opera_root, *opera_bin = NULL, *opera_dir = NULL;
360        char* opera_home = NULL, *opera_fonts = NULL, *opera_widgets = NULL;
[23953]361       
[24564]362        textbox(_("Message"), _("You can leave HBBTV with Record Key."), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1000, 200, 15, 0);
[23953]363       
[35116]364  //if(isdir("/var/usr/local/share/titan/plugins/hbbtv/opera"))
365  //            opera_root = ostrcat("/var/usr/local/share/titan/plugins/hbbtv/opera", NULL, 0, 0);
366  //    else if(isdir("/var/swap/usr/local/share/titan/plugins/hbbtv/opera"))
367  //            opera_root = ostrcat("/var/swap/usr/local/share/titan/plugins/hbbtv/opera", NULL, 0, 0);
368  //    else
369  //            opera_root = ostrcat("/mnt/swapextensions/usr/local/share/titan/plugins/hbbtv/opera", NULL, 0, 0);
[35138]370   
371        opera_root = ostrcat("/usr/local/OpenOpera", NULL, 0, 0);
[35116]372        opera_bin = ostrcat(opera_root, "/launcher start", 0, 0);
[17596]373        opera_dir = ostrcat(opera_root, "/opera_dir", 0, 0);
374        opera_home = ostrcat(opera_root, "/opera_home/", 0, 0);
375        opera_fonts = ostrcat(opera_root, "/fonts", 0, 0);
376        opera_widgets = ostrcat(opera_root, "/widgets", 0, 0);
377
[19845]378        resettvpic();
[16512]379        drawscreen(skin, 0, 0);
[15929]380
381        debug(788, "step 1, set env");
382        //setenv("DFBARGS", "pixelformat=ARGB,no-cursor,bg-none,no-linux-input-grab,no-vt", 1);
383        setenv("OPERA_MULTITAP", "NO", 1);
384        setenv("OPERA_SHOW_STATUSWINDOW", "NO", 1);
385        setenv("OPERA_FB_BORDERWIDTH", "0", 1);
386        setenv("OPERA_SHOW_IMEWINDOW", "NO", 1);
387        setenv("OPERA_SHOW_NAVIGATIONWINDOW", "NO", 1);
388        setenv("OPERA_SHOW_MOUSEPOINTER", "NO", 1);
389        setenv("OPERA_SHOW_HIGHLIGHT", "NO", 1);
390        setenv("OPERA_ESC_EXIT", "YES", 1);
391        setenv("FREETYPE_FONT_SET", "YES", 1);
[17596]392        setenv("OPERA_ROOT", opera_root, 1);
[15929]393        setenv("OPERA_FB_SIZE", "1280x720", 1);
[17596]394        setenv("OPERA_DIR", opera_dir, 1);
395        setenv("OPERA_HOME", opera_home, 1);
396        setenv("OPERA_FONTS", opera_fonts, 1);
397        setenv("OPERA_WIDGETS", opera_widgets, 1);
398        setenv("LD_LIBRARY_PATH", opera_root, 1); // + ":" + os.environ["LD_LIBRARY_PATH"]
[15929]399
400        unlink(CONTROL_PIPE_W);
401        unlink(CONTROL_PIPE_R);
402        unlink(RC_TITAN);
403
404        mkfifo(CONTROL_PIPE_W, 0666);
405        mkfifo(CONTROL_PIPE_R, 0666);
406        //mkfifo(RC_TITAN, 0666);
407
408        debug(788, "step 2, start opera");
[16339]409        //writesys("/proc/cpu/alignment", "0", 0);
[15929]410
411        operarcthread_ok = 0;
412        operareceiverthread_ok = 0;
413        addtimer(&operarcthread, START, 10, 1, NULL, NULL, NULL);
414        operareceiver = addtimer(&operareceiverthread, START, 10, 1, NULL, NULL, NULL);
415
416        //wait for threads
417        int count = 0;
418        while(operarcthread_ok == 0 || operareceiverthread_ok == 0)
419        {
420                usleep(100000);
421                count++;
422                if(count > 20) break;
423        }
424
[16309]425        //save working dir
426        dirbuf = malloc(PATH_MAX);
427        if(dirbuf != NULL)
428        {
429                savedir = getcwd(dirbuf, PATH_MAX);
[17596]430                chdir(opera_root);
[16309]431        }
[15929]432
433        fbsave();
434
[17596]435        tmpstr = ostrcat(tmpstr, opera_bin, 1, 0);
[15929]436        tmpstr = ostrcat(tmpstr, " -u ", 1, 0);
437        tmpstr = ostrcat(tmpstr, url, 1, 0);
438        tmpstr = ostrcat(tmpstr, " --dfb:mode=1280x720,no-debug,no-vt,no-vt-switch &", 1, 0);
439        system(tmpstr);
440        free(tmpstr); tmpstr = NULL;
441
[17596]442        //free all opera vars
443        free(opera_root); opera_root = NULL;
444        free(opera_bin); opera_bin = NULL;
445        free(opera_dir); opera_dir = NULL;
[17608]446        free(opera_home); opera_home = NULL;
[17596]447        free(opera_fonts); opera_fonts = NULL;
448        free(opera_widgets); opera_widgets = NULL;
449
[15959]450        //reset working dir
[16309]451        if(savedir != NULL)
452                chdir(dirbuf);
453        free(dirbuf); dirbuf = NULL;
454
[15929]455        while(1)
456        {
[15959]457                rcret = waitrc(NULL, 1000, 0);
[15989]458
[16309]459                //check for player EOF
460                if(operaservicestate < 2 && !playerisplaying())
461                        operaservice(NULL, 1);
462
[16334]463                if(rcret == getrcconfigint("rchbbtv", NULL) || rcret == getrcconfigint("rcrecord", NULL))
[15929]464                {
[15988]465                        //operasendkey("ESC\n");
[15929]466                        break;
467                }
[15988]468                else if(rcret == getrcconfigint("rcexit", NULL))
469                        operasendkey("BACK\n");
[15929]470                else if(rcret == getrcconfigint("rcred", NULL))
[15982]471                        operasendkey("RED\n");
[15929]472                else if(rcret == getrcconfigint("rcgreen", NULL))
[15982]473                        operasendkey("GREEN\n");
[15929]474                else if(rcret == getrcconfigint("rcyellow", NULL))
[15982]475                        operasendkey("YELLOW\n");
[15929]476                else if(rcret == getrcconfigint("rcblue", NULL))
[15982]477                        operasendkey("BLUE\n");
[15929]478                else if(rcret == getrcconfigint("rcok", NULL))
479                {
[15982]480                        operasendkey("OK\n");
481                        operasendkey("ENTER\n");
[15929]482                }
483                else if(rcret == getrcconfigint("rcup", NULL))
[15982]484                        operasendkey("UP\n");
[15929]485                else if(rcret == getrcconfigint("rcdown", NULL))
[15982]486                        operasendkey("DOWN\n");
[15929]487                else if(rcret == getrcconfigint("rcleft", NULL))
[15982]488                        operasendkey("LEFT\n");
[15929]489                else if(rcret == getrcconfigint("rcright", NULL))
[15982]490                        operasendkey("RIGHT\n");
[15929]491                else if(rcret == getrcconfigint("rc1", NULL))
[15982]492                        operasendkey("1\n");
[15929]493                else if(rcret == getrcconfigint("rc2", NULL))
[15982]494                        operasendkey("2\n");
[15929]495                else if(rcret == getrcconfigint("rc3", NULL))
[15982]496                        operasendkey("3\n");
[15929]497                else if(rcret == getrcconfigint("rc4", NULL))
[15982]498                        operasendkey("4\n");
[15929]499                else if(rcret == getrcconfigint("rc5", NULL))
[15982]500                        operasendkey("5\n");
[15929]501                else if(rcret == getrcconfigint("rc6", NULL))
[15982]502                        operasendkey("6\n");
[15929]503                else if(rcret == getrcconfigint("rc7", NULL))
[15982]504                        operasendkey("7\n");
[15929]505                else if(rcret == getrcconfigint("rc8", NULL))
[15982]506                        operasendkey("8\n");
[15929]507                else if(rcret == getrcconfigint("rc9", NULL))
[15982]508                        operasendkey("9\n");
[15929]509                else if(rcret == getrcconfigint("rc0", NULL))
[15982]510                        operasendkey("0\n");
[15929]511        }
512
513        if(operareceiver != NULL)
514        {
515                operareceiver->aktion = STOP;
[16297]516                while(operareceiver != NULL && operareceiver->status != DEACTIVE)
[15929]517                {
518                        usleep(100000);
519                        i++; if(i > 20) break;
520                }
521
522                if(i > 20)
523                {
524                        err("detect hanging timer sub thread (operareceiver)");
525                }
526        }
527
528        sockclose(&operarcsockfd);
529        sockclose(&operarcconnfd);
[15959]530        close(opera_control_r_fd);
[15929]531
[16296]532        debug(788, "killall -9 opera");
533        tmpstr = ostrcat(tmpstr, "killall -9 opera", 1, 0);
[15929]534        system(tmpstr);
535        free(tmpstr); tmpstr = NULL;
536
537        free(operaplayurl); operaplayurl = NULL;
538
[16339]539        //writesys("/proc/cpu/alignment", "3", 0);
[15929]540
[15982]541        //setvideomode("720p50", 0);
542        //changefbresolution("720p50");
543        //sleep(3);
[15929]544        fbrestore();
[15982]545
[16297]546        operaservice(NULL, 1); //stop play, start live tv
[15982]547
[15985]548        //reset tv pic size
549        status.tvpic = 1;
550        resettvpic();
[15990]551        clearfball();
[15929]552}
553
554void operareceivercb(char* cmd)
555{
556        int count = 0;
557        char* tmpstr = NULL;
558        struct splitstr* ret = NULL;
559
560        debug(788, "cmd=%s", cmd);
561
562        tmpstr = ostrcat(cmd, NULL, 0, 0);
563        ret = strsplit(tmpstr, " ", &count);
564
565        if(ret != NULL && count > 0)
566        {
567                if(ostrcmp("HELLO", (&ret[0])->part) == 0)
568                {
[15959]569                        opera_control_r_fd = open(CONTROL_PIPE_R, O_WRONLY);
570                        if(opera_control_r_fd < 0)
[15929]571                        {
572                                perr("open or create "CONTROL_PIPE_R);
573                        }
574                }
575                else if(ostrcmp("AvSetWin", (&ret[0])->part) == 0)
576                {
577                        int x = 0, y = 0, w = 0, h = 0;
578                        float xw = 720.0 / 1280.0;
579                        float yh = 576.0 / 720.0;
580                        char* position = NULL;
581
582                        if(count > 1) x = atoi((&ret[1])->part) * xw;
583                        if(count > 2) y = atoi((&ret[2])->part) * yh;
584                        if(count > 3) w = atoi((&ret[3])->part) * xw;
585                        if(count > 4) h = atoi((&ret[4])->part) * yh;
586
587                        if(w == 0 && h == 0)
588                        {
589                                w = 720;
590                                h = 576;
591                        }
592
[16309]593                        position = ostrcat(position, oitoax(x), 1, 1);
594                        position = ostrcat(position, " ", 1, 0);
595                        position = ostrcat(position, oitoax(y), 1, 1);
596                        position = ostrcat(position, " ", 1, 0);
597                        position = ostrcat(position, oitoax(w), 1, 1);
598                        position = ostrcat(position, " ", 1, 0);
599                        position = ostrcat(position, oitoax(h), 1, 1);
600
601                        debug(788, "change tv pic to: %s", position);
[15929]602                        writesys("/proc/stb/vmpeg/0/dst_all", position, 0);
603                }
604                else if(ostrcmp("AvGetFullScreen", (&ret[0])->part) == 0)
605                {
606                        char* w = NULL, *h = NULL;
607
608                        w = readsys("/proc/stb/vmpeg/0/dst_width", 1);
609                        h = readsys("/proc/stb/vmpeg/0/dst_height", 1);
610
611                        if(ostrcmp(w, "2d0") == 0 && ostrcmp(h, "240") == 0)
[15959]612                                write(opera_control_r_fd, "AvGetFullScreen 1\n", 18);
[15929]613                        else
[15959]614                                write(opera_control_r_fd, "AvGetFullScreen 0\n", 18);
[15929]615
616                        free(w); w = NULL;
617                        free(h); h = NULL;
618                }
619                else if(ostrcmp("AvGetVisible", (&ret[0])->part) == 0)
620                {
621                        unsigned long val = readsysul("/proc/stb/video/alpha", 1);
622
623                        if(val == 0)
[15959]624                                write(opera_control_r_fd, "AvGetVisible 1\n", 15);
[15929]625                        else
[15959]626                                write(opera_control_r_fd, "AvGetVisible 0\n", 15);
[15929]627                }
628                /*
629                else if(ostrncmp("AvSetVisible", (&ret[0])->part) == 0)
630                {
631                        //if(count > 1 && ostrcmp("1", (&ret[1])->part) == 0)
632                        //{
633                        //      writesys("/proc/stb/video/alpha", "255", 0);
634                        //else
635                        //      writesys("/proc/stb/video/alpha", "0", 0);
636                        //}
637                }
638                */
639                else if(ostrcmp("AvPlay", (&ret[0])->part) == 0)
640                {
641                        if(count > 2)
642                        {
[16297]643                                if(ostrcmp("100", (&ret[2])->part) == 0) //play or continue
[15929]644                                {
[16297]645                                        if(ostrcmp(operaplayurl, (&ret[1])->part) != 0) //different url, so play
[15929]646                                        {
[16297]647                                                operaservice((&ret[1])->part, 0); //stop live tv and play
[15929]648                                        }
649                                        else
[16309]650                                        {
651                                                playercontinue();
652                                                operaservicestate = 1;
[15929]653                                        }
654                                }
[16297]655                                else if(ostrcmp("0", (&ret[2])->part) == 0) //pause
[15929]656                                {
[16309]657                                        playerpause();
658                                        operaservicestate = 0;
[15929]659                                }
660                        }
661                }
662                else if(ostrcmp("AvStop", (&ret[0])->part) == 0)
663                {
[16297]664                        operaservice(NULL, 2); //stop play
[15929]665                }
666                else if(ostrcmp("AvGetPos", (&ret[0])->part) == 0)
667                {
668                        char* tmppos = NULL;
[15959]669                        unsigned long pos = 0;
[15929]670
[16309]671                        pos = playergetpts() / 90000;
672
[15929]673                        tmppos = ostrcat(tmppos, "AvGetPos ", 1, 0);
[15959]674                        tmppos = ostrcat(tmppos, olutoa(pos), 1, 1);
[15929]675                        tmppos = ostrcat(tmppos, "\n", 1, 0);
[16297]676
[15929]677                        if(tmppos != NULL)
[15959]678                                write(opera_control_r_fd, tmppos, strlen(tmppos));
[16297]679
[15929]680                        free(tmppos); tmppos = NULL;
681                }
682                else if(ostrcmp("AvGetDuration", (&ret[0])->part) == 0)
683                {
684                        char* tmplen = NULL;
[15959]685                        unsigned long len = 0;
[15929]686
[16309]687                        len = playergetlength();
688
[15929]689                        tmplen = ostrcat(tmplen, "AvGetDuration ", 1, 0);
[15959]690                        tmplen = ostrcat(tmplen, olutoa(len), 1, 1);
[15929]691                        tmplen = ostrcat(tmplen, "\n", 1, 0);
[16297]692
[15929]693                        if(tmplen != NULL)
[15959]694                                write(opera_control_r_fd, tmplen, strlen(tmplen));
[16297]695
[15929]696                        free(tmplen); tmplen = NULL;
697                }
698                else if(ostrcmp("AvGetState", (&ret[0])->part) == 0)
699                {
700                        char* tmpstate = NULL;
[16297]701
[15929]702                        tmpstate = ostrcat(tmpstate, "AvGetState ", 1, 0);
[16297]703                        if(operaservicestate == 1)
704                                tmpstate = ostrcat(tmpstate, "1", 1, 0);
705                        else
706                                tmpstate = ostrcat(tmpstate, "0", 1, 0);
[15929]707                        tmpstate = ostrcat(tmpstate, "\n", 1, 0);
[16297]708
[15929]709                        if(tmpstate != NULL)
[15959]710                                write(opera_control_r_fd, tmpstate, strlen(tmpstate));
[16297]711
[15929]712                        free(tmpstate); tmpstate = NULL;
713                }
714                else if(ostrcmp("ReleaseHandle", (&ret[0])->part) == 0)
715                {
716                        if(count > 1 && ostrcmp("1", (&ret[1])->part) == 0) //VOD
717                        {
[16297]718                                operaservice(NULL, 1); //stop play, start live tv
[15929]719                        }
720                }
721        }
722
723        free(tmpstr); tmpstr = NULL;
724        free(ret); ret = NULL;
725}
726
[16143]727void screenoperafav()
728{
[16146]729        //int ret = 0;
[16143]730        struct menulist* mlist = NULL, *mbox = NULL, *tmpmbox = NULL;
731        struct hbbtvfav *node = NULL;
732
733        //ret = servicestop(status.aktservice, 1, 0);
734        //if(ret == 1) return;
735        //setfbtransparent(255);
736
737        readhbbtvfav(getconfig("hbbtvfavfile", NULL));
738        node = hbbtvfav;
739
[16148]740        if(status.aktservice->channel != NULL && status.aktservice->channel->hbbtvurl != NULL)
741        {
742                debug(788, "hbbtvurl=%s", status.aktservice->channel->hbbtvurl);
[25932]743                tmpmbox = addmenulist(&mlist, _("Channel HBBTV"), NULL, NULL, 0, 0);
[16148]744                if(tmpmbox != NULL)
745                        tmpmbox->param = ostrcat(status.aktservice->channel->hbbtvurl, NULL, 0, 0);
746        }
[16143]747
748        while(node != NULL)
749        {
750                tmpmbox = addmenulist(&mlist, node->name, NULL, NULL, 0, 0);
751                if(tmpmbox != NULL)
752                        tmpmbox->param = ostrcat(node->addr, NULL, 0, 0);
753
754                node = node->next;
755        }
756
757start:
[16512]758        drawscreen(skin, 0, 0);
[27740]759        mbox = menulistbox(mlist, "menulist", _("HBBTV Favoriten"), _("Choose your HBBTV Favorite from the following list"), NULL, NULL, 0, 0);
[16143]760        if(mbox != NULL)
761        {
762                if(mbox->param != NULL)
763                {
[17093]764                        drawscreen(skin, 0, 0);
[16143]765                        screenopera(mbox->param);
766                }
767                goto start;
768        }
769
770        freemenulist(mlist, 1);
771        freehbbtvfav();
772        //setosdtransparent(getskinconfigint("osdtransparent", NULL));
773        //if(status.lastservice != NULL)
774        //      servicestart(status.lastservice->channel, NULL, NULL, 0);
775        //flushrc(500);
776}
777
[15929]778#endif
Note: See TracBrowser for help on using the repository browser.