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