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