diff --git a/src/driver/aviaext.cpp b/src/driver/aviaext.cpp deleted file mode 100644 index 22a51e7c0..000000000 --- a/src/driver/aviaext.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - LCD-Daemon - DBoxII-Project - - Copyright (C) 2004 Zwen@tuxbox.org - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#if 1 -#include -#include - -#define AVIAEXT_DEV "/dev/dbox/aviaEXT" - -CAViAExt* CAViAExt::getInstance() -{ - static CAViAExt* AViAExt = NULL; - if(AViAExt == NULL) - { - AViAExt = new CAViAExt(); - } - return AViAExt; -} - -void CAViAExt::iecOn() -{ - int res,fd; - - if ((fd = open(AVIAEXT_DEV,O_RDWR))<0) - { - if (errno==ENOENT) - fprintf (stderr,"%s does not exist, did you forget to load the aviaEXT module?\n",AVIAEXT_DEV); - else - perror ("aviaext: error opening /dev/dbox/aviaEXT"); - return; - } - res = ioctl(fd, AVIA_EXT_IEC_SET, 1); - if (res<0) - perror("aviaext: ioctl"); - close(fd); -} - -void CAViAExt::iecOff() -{ - int res,fd; - - if ((fd = open(AVIAEXT_DEV,O_RDWR))<0) - { - if (errno==ENOENT) - fprintf (stderr,"%s does not exist, did you forget to load the aviaEXT module?\n",AVIAEXT_DEV); - else - perror ("aviaext: error opening /dev/dbox/aviaEXT"); - return; - } - res = ioctl(fd, AVIA_EXT_IEC_SET, 0); - if (res<0) - perror("aviaext: ioctl"); - close(fd); -} - -int CAViAExt::iecState() -{ - int res,fd; - unsigned int param; - - if ((fd = open(AVIAEXT_DEV,O_RDWR))<0) - { - if (errno==ENOENT) - fprintf (stderr,"%s does not exist, did you forget to load the aviaEXT module?\n",AVIAEXT_DEV); - else - perror ("aviaext: error opening /dev/dbox/aviaEXT"); - return -1; - } - res = ioctl(fd, AVIA_EXT_IEC_GET, ¶m); - - close(fd); - - if (res<0) - { - perror("aviaext: ioctl"); - return -1; - } - return param; -} - -void CAViAExt::playbackSPTS() -{ - int res,fd; - - if ((fd = open(AVIAEXT_DEV,O_RDWR))<0) - { - if (errno==ENOENT) - fprintf (stderr,"%s does not exist, did you forget to load the aviaEXT module?\n",AVIAEXT_DEV); - else - perror ("aviaext: error opening /dev/dbox/aviaEXT"); - return; - } - res = ioctl(fd, AVIA_EXT_AVIA_PLAYBACK_MODE_SET, 1); - if (res<0) - perror("aviaext: ioctl"); - close(fd); -} - -void CAViAExt::playbackPES() -{ - int res,fd; - - if ((fd = open(AVIAEXT_DEV,O_RDWR))<0) - { - if (errno==ENOENT) - fprintf (stderr,"%s does not exist, did you forget to load the aviaEXT module?\n",AVIAEXT_DEV); - else - perror ("aviaext: error opening /dev/dbox/aviaEXT"); - return; - } - res = ioctl(fd, AVIA_EXT_AVIA_PLAYBACK_MODE_SET, 0); - if (res<0) - perror("aviaext: ioctl"); - close(fd); -} - -int CAViAExt::playbackState() -{ - int res,fd; - unsigned int param; - - if ((fd = open(AVIAEXT_DEV,O_RDWR))<0) - { - if (errno==ENOENT) - fprintf (stderr,"%s does not exist, did you forget to load the aviaEXT module?\n",AVIAEXT_DEV); - else - perror ("aviaext: error opening /dev/dbox/aviaEXT"); - return -1; - } - res = ioctl(fd, AVIA_EXT_AVIA_PLAYBACK_MODE_GET, ¶m); - - close(fd); - - if (res<0) - { - perror("aviaext: ioctl"); - return -1; - } - return param; -} -#endif diff --git a/src/driver/bigclock.cpp b/src/driver/bigclock.cpp deleted file mode 100644 index e5264f59b..000000000 --- a/src/driver/bigclock.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - LCD-Daemon - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#include "bigclock.h" - - -void doppelpunkt(CLCDDisplay* display, int pos) -{ - int i,j; - - for (i=1;i<=4;i++) - for (j=1;j<=4;j++) - display->draw_point(i+10+pos*24-3,j+23,CLCDDisplay::PIXEL_ON); - for (i=1;i<=4;i++) - for (j=1;j<=4;j++) - display->draw_point(i+10+pos*24-3,j+37,CLCDDisplay::PIXEL_ON); -} - - -void balken(CLCDDisplay* display, int pos, int balken) -{ - int i,j; - - if (balken==3||balken==6||balken==7) - { - //horizontaler balken - if (balken == 6) for (i=1;i<=14;i++) for (j=1;j<=4;j++) display->draw_point(i+5+pos*24-3,j+14,CLCDDisplay::PIXEL_ON); - if (balken == 7) for (i=1;i<=8;i++) for (j=1;j<=4;j++) display->draw_point(i+8+pos*24-3,j+30,CLCDDisplay::PIXEL_ON); - } if (balken == 3) for (i=1;i<=14;i++) for (j=1;j<=4;j++) display->draw_point(i+5+pos*24-3,j+46,CLCDDisplay::PIXEL_ON); - else - { - //vertikaler balken - if (balken == 1) for (i=1;i<=4;i++) for (j=1;j<=13;j++) display->draw_point(i+19+pos*24-3,j+18,CLCDDisplay::PIXEL_ON); - if (balken == 2) for (i=1;i<=4;i++) for (j=1;j<=13;j++) display->draw_point(i+19+pos*24-3,j+33,CLCDDisplay::PIXEL_ON); - if (balken == 5) for (i=1;i<=4;i++) for (j=1;j<=13;j++) display->draw_point(i+1+pos*24-3,j+18,CLCDDisplay::PIXEL_ON); - if (balken == 4) for (i=1;i<=4;i++) for (j=1;j<=13;j++) display->draw_point(i+1+pos*24-3,j+33,CLCDDisplay::PIXEL_ON); - - } -} - -void showBigClock(CLCDDisplay* display, int h, int m) -{ - - //stunden einer - if (h==0||h==10||h==20) - { balken(display, 1,1); balken(display, 1,2); balken(display, 1,3); balken(display, 1,4); balken(display, 1,5); balken(display, 1,6);} - if (h==1||h==11||h==21) - { balken(display, 1,1); balken(display, 1,2);} - if (h==2||h==12||h==22) - { balken(display, 1,1); balken(display, 1,7); balken(display, 1,3); balken(display, 1,4); balken(display, 1,6);} - if (h==3||h==13||h==23) - { balken(display, 1,1); balken(display, 1,2); balken(display, 1,3); balken(display, 1,7); balken(display, 1,6);} - if (h==4||h==14) - { balken(display, 1,1); balken(display, 1,2); balken(display, 1,7); balken(display, 1,5);} - if (h==5||h==15) - { balken(display, 1,2); balken(display, 1,3); balken(display, 1,5); balken(display, 1,6); balken(display, 1,7);} - if (h==6||h==16) - { balken(display, 1,7); balken(display, 1,2); balken(display, 1,3); balken(display, 1,4); balken(display, 1,5); balken(display, 1,6);} - if (h==7||h==17) - { balken(display, 1,1); balken(display, 1,2); balken(display, 1,6);} - if (h==8||h==18) - { balken(display, 1,1); balken(display, 1,2); balken(display, 1,3); balken(display, 1,4); balken(display, 1,5); balken(display, 1,6); balken(display, 1,7);} - if (h==9||h==19) - { balken(display, 1,1); balken(display, 1,2); balken(display, 1,3); balken(display, 1,7); balken(display, 1,5); balken(display, 1,6);} - //stunden zehner - if (h>9&&h<20){ balken(display, 0,1); balken(display, 0,2);} - if (h>19) { balken(display, 0,1); balken(display, 0,7); balken(display, 0,3); balken(display, 0,4); balken(display, 0,6);} - - - //minuten einer - if (m==0||m==10||m==20||m==30||m==40||m==50) - { balken(display, 4,1); balken(display, 4,2); balken(display, 4,3); balken(display, 4,4); balken(display, 4,5); balken(display, 4,6);} - if (m==1||m==11||m==21||m==31||m==41||m==51) - { balken(display, 4,1); balken(display, 4,2);} - if (m==2||m==12||m==22||m==32||m==42||m==52) - { balken(display, 4,1); balken(display, 4,7); balken(display, 4,3); balken(display, 4,4); balken(display, 4,6);} - if (m==3||m==13||m==23||m==33||m==43||m==53) - { balken(display, 4,1); balken(display, 4,2); balken(display, 4,3); balken(display, 4,7); balken(display, 4,6);} - if (m==4||m==14||m==24||m==34||m==44||m==54) - { balken(display, 4,1); balken(display, 4,2); balken(display, 4,7); balken(display, 4,5);} - if (m==5||m==15||m==25||m==35||m==45||m==55) - { balken(display, 4,2); balken(display, 4,3); balken(display, 4,5); balken(display, 4,6); balken(display, 4,7);} - if (m==6||m==16||m==26||m==36||m==46||m==56) - { balken(display, 4,7); balken(display, 4,2); balken(display, 4,3); balken(display, 4,4); balken(display, 4,5); balken(display, 4,6);} - if (m==7||m==17||m==27||m==37||m==47||m==57) - { balken(display, 4,1); balken(display, 4,2); balken(display, 4,6);} - if (m==8||m==18||m==28||m==38||m==48||m==58) - { balken(display, 4,1); balken(display, 4,2); balken(display, 4,3); balken(display, 4,4); balken(display, 4,5); balken(display, 4,6); balken(display, 4,7);} - if (m==9||m==19||m==29||m==39||m==49||m==59) - { balken(display, 4,1); balken(display, 4,2); balken(display, 4,3); balken(display, 4,7); balken(display, 4,5); balken(display, 4,6);} - - //minuten zehner - if (m<10) - { balken(display, 3,1); balken(display, 3,2); balken(display, 3,3); balken(display, 3,4); balken(display, 3,5); balken(display, 3,6);} - if (m>9&&m<20){ balken(display, 3,1); balken(display, 3,2);} - if (m>19&&m<30){ balken(display, 3,1); balken(display, 3,7); balken(display, 3,3); balken(display, 3,4); balken(display, 3,6);} - if (m>29&&m<40){ balken(display, 3,1); balken(display, 3,2); balken(display, 3,3); balken(display, 3,7); balken(display, 3,6);} - if (m>39&&m<50){ balken(display, 3,1); balken(display, 3,2); balken(display, 3,7); balken(display, 3,5);} - if (m>=50) { balken(display, 3,2); balken(display, 3,3); balken(display, 3,5); balken(display, 3,6); balken(display, 3,7);} - - doppelpunkt(display, 2); - } diff --git a/src/driver/bigclock.h b/src/driver/bigclock.h deleted file mode 100644 index 91735f93c..000000000 --- a/src/driver/bigclock.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - LCD-Daemon - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __bigclock__ -#define __bigclock__ - -#include - - -void showBigClock(CLCDDisplay* display, int h,int m); - - -#endif diff --git a/src/driver/capture.cpp b/src/driver/capture.cpp deleted file mode 100644 index 35c580b42..000000000 --- a/src/driver/capture.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - - - - -#include -#include -#include -#include -#include -#include -#include - -#include "capture.h" - - -#include -#warning "experimental..." - - -// -// -- TV Picture Capture -// -- This module is a class to provide a capture abstraction layer -// -- -// -- 2003-12 rasc -// - - - -// -// -- Constructor -// - -CCAPTURE::CCAPTURE() -{ - fd = -1; -} - - -CCAPTURE::CCAPTURE(int capture_nr) -{ - fd = -1; - fd = captureopen(capture_nr); -} - - -CCAPTURE::CCAPTURE(int capture_nr, int x, int y, int w, int h) -{ - fd = -1; - fd = captureopen (capture_nr); - set_coord (x,y, w,h); -} - - - - -CCAPTURE::~CCAPTURE() -{ - captureclose (); // cleanup anyway!! -} - - -// -// -- open Capture device -// -- return >=0: ok -// - -int CCAPTURE::captureopen (int cap_nr) -{ - char *capturedevs[] = { - CAPTURE_DEV "0" // CAPTURE device 0 - // CAPTURE_DEV "1", // CAPTURE device 1 - // CAPTURE_DEV "2", // CAPTURE device 2 - // CAPTURE_DEV "3" // CAPTURE device 3 - }; - - - if ( (cap_nr>0) || (cap_nr < (int)(sizeof (capturedevs)/sizeof(char *))) ) { - - if (fd < 0) { - fd = open( capturedevs[cap_nr], O_RDWR ); - if (fd >= 0) { - cx = cy = cw = ch = 0; - out_w = out_h = 0; - stride = 0; - } else perror (capturedevs[cap_nr]); - return fd; - } - - } - - return -1; -} - - -// -// -- close Capture Device -// - -void CCAPTURE::captureclose () -{ - if (fd >=0 ) { - close (fd); - fd = -1; - cx = cy = cw = ch = 0; - out_w = out_h = 0; - stride = 0; - } - return; -} - - - - -/* - -- Coordination routines... - */ - -void CCAPTURE::set_coord (int x, int y, int w, int h) -{ - if (( x != cx ) || ( y != cy )) { - cx = x; - cy = y; - cw = w; - ch = h; - _set_window (cx,cy,cw,ch); - } -} - - -void CCAPTURE::set_xy (int x, int y) -{ - if (( x != cx ) || ( y != cy )) { - cx = x; - cy = y; - _set_window (cx,cy,cw,ch); - } -} - - - -void CCAPTURE::set_size (int w, int h) -{ - if (( w != cw ) || ( h != ch )) { - cw = w; - ch = h; - _set_window (cx,cy,cw,ch); - } -} - - - - -// -// -- set Capture Position -// - -void CCAPTURE::_set_window (int x, int y, int w, int h) -{ -#ifdef __v4l_capture - - struct v4l2_crop crop; - - crop.c.left = x; - crop.c.top = y; - crop.c.width = w; - crop.c.height = h; - if( ioctl(fd, VIDIOC_S_CROP, &crop) < 0) - perror ("error VIDIOC_S_CROP"); - -#else - - capture_set_input_pos(fd, x, y); - capture_set_input_size(fd, w, h); - -#endif -} - - - -void CCAPTURE::set_output_size (int w, int h) -{ -#ifdef __v4l_capture - - struct v4l2_format format; - - out_w = w; - out_h = h; - format.fmt.pix.width = w; - format.fmt.pix.height = h; - - if (ioctl(fd, VIDIOC_S_FMT, &format) < 0) - perror ("error VIDIOC_S_FMT"); - -#else - - out_w = w; - out_h = h; - capture_set_output_size(fd, w, h); - -#endif -} - - -// -// -- capture a frame -// -- if buffer == NULL, routine will alloc memory! -// -- destroy will not free this allocated memory! -// -- otherwise buffer has to be large enough! -// - -u_char *CCAPTURE::readframe (u_char *buf) -{ -#ifdef __v4l_capture - - struct v4l2_format vid; - int n; - u_char *b; - - if (fd >= 0) { - // get capture information - vid.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (ioctl(fd, VIDIOC_G_FMT, &vid) < 0) - perror ("Error getting info with VIDIOC_G_FMT"); - - printf ("reported bytesperline: %d, height: %d, sizeimage: %d\n", - vid.fmt.pix.bytesperline, - vid.fmt.pix.height, - vid.fmt.pix.sizeimage); - - b = (buf != NULL) - ? buf - : (u_char *) malloc (vid.fmt.pix.bytesperline * - vid.fmt.pix.height); - - - n = read (fd, b, vid.fmt.pix.bytesperline*vid.fmt.pix.height); - if (n < 0) { - perror ("Error reading capture buffer"); - if (!buf) free (b); - return (u_char *)NULL; - } - - return b; - } - - return (u_char *) NULL; - - -#else - - u_char *b; - int stride; - int n; - - if (fd >= 0) { - stride = capture_start(fd); - - b = (buf != NULL) - ? buf - : (u_char *) malloc (stride * out_h); - - n = read(fd, b, stride * out_h); - capture_stop(fd); - if (n < 0) { - perror ("Error reading capture buffer"); - if (!buf) free (b); - return (u_char *)NULL; - } - - - return b; - } - - return (u_char *) NULL; - -#endif -} - - - - - - - - - - diff --git a/src/driver/capture.h b/src/driver/capture.h deleted file mode 100644 index 53775739e..000000000 --- a/src/driver/capture.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef __CAPTURE_CONTROL__ -#define __CAPTURE_CONTROL__ - - -#define __v4l_capture - - -using namespace std; - - -// -// -- Picture Capture Control -// -- 2003-12 rasc -// - -#ifdef __v4l_capture - -#include -#define CAPTURE_DEV "/dev/v4l/video" // CaptureNr will be appended! - -#else - -#include -#define CAPTURE_DEV "/dev/dbox/capture" // CaptureNr will be appended! - -#endif - - -class CCAPTURE -{ - public: - CCAPTURE (); - CCAPTURE (int capture_nr); // incl. open - CCAPTURE (int capture_nr, int x, int y, int w, int h); // open + set_coord - ~CCAPTURE (); - - int captureopen (int capture_nr); - void captureclose (void); - void set_coord (int x, int y, int w, int h); - void set_xy (int x, int y); - void set_size (int w, int h); - void set_output_size (int w, int h); - u_char *readframe (u_char *buf); - - private: - void _set_window (int x, int y, int w, int h); - - int fd; // io descriptor - int cx, cy, cw, ch; // capture size - int out_w, out_h; // capture output size - int stride; - -}; - - - -#endif - - diff --git a/src/driver/encoding.cpp b/src/driver/encoding.cpp deleted file mode 100644 index b4c1c238f..000000000 --- a/src/driver/encoding.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/encoding.cpp,v 1.2 2003/09/27 11:48:09 thegoodguy Exp $ - * - * conversion of character encodings - d-box2 linux project - * - * (C) 2003 by thegoodguy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include - -std::string Latin1_to_UTF8(const std::string & s) -{ - std::string r; - - for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) - { - unsigned char c = *it; - if (c < 0x80) - r += c; - else - { - unsigned char d = 0xc0 | (c >> 6); - r += d; - d = 0x80 | (c & 0x3f); - r += d; - } - } - return r; -} diff --git a/src/driver/encoding.h b/src/driver/encoding.h deleted file mode 100644 index 9564a8733..000000000 --- a/src/driver/encoding.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/encoding.h,v 1.2 2003/09/27 11:48:09 thegoodguy Exp $ - * - * conversion of character encodings - d-box2 linux project - * - * (C) 2003 by thegoodguy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef __neutrino__encoding_h__ -#define __neutrino__encoding_h__ - -#include - -std::string Latin1_to_UTF8(const std::string & s); - -#endif /* __neutrino__encoding_h__ */ diff --git a/src/driver/lcdd.cpp b/src/driver/lcdd.cpp deleted file mode 100644 index 2104bf8c8..000000000 --- a/src/driver/lcdd.cpp +++ /dev/null @@ -1,1462 +0,0 @@ -/* - $Id$ - - LCD-Daemon - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Copyright (C) 2008 Novell, Inc. Author: Stefan Seyfried - (C) 2009 Stefan Seyfried - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include -#include -#include - -#include -#include -#include - -#if defined HAVE_DBOX_HARDWARE || defined HAVE_DREAMBOX_HARDWARE || defined HAVE_IPBOX_HARDWARE -#include -#endif -#include -#include -#include -#include -#include - -#include -extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ - -/* from edvbstring.cpp */ -static bool isUTF8(const std::string &string) -{ - unsigned int len=string.size(); - - for (unsigned int i=0; i < len; ++i) - { - if (!(string[i]&0x80)) // normal ASCII - continue; - if ((string[i] & 0xE0) == 0xC0) // one char following. - { - // first, length check: - if (i+1 >= len) - return false; // certainly NOT utf-8 - i++; - if ((string[i]&0xC0) != 0x80) - return false; // no, not UTF-8. - } else if ((string[i] & 0xF0) == 0xE0) - { - if ((i+1) >= len) - return false; - i++; - if ((string[i]&0xC0) != 0x80) - return false; - i++; - if ((string[i]&0xC0) != 0x80) - return false; - } - } - return true; // can be UTF8 (or pure ASCII, at least no non-UTF-8 8bit characters) -} - -CLCD::CLCD() - : configfile('\t') -{ -#ifdef LCD_UPDATE - m_fileList = NULL; - m_fileListPos = 0; - m_fileListHeader = ""; - m_infoBoxText = ""; - m_infoBoxAutoNewline = 0; - m_progressShowEscape = 0; - m_progressHeaderGlobal = ""; - m_progressHeaderLocal = ""; - m_progressGlobal = 0; - m_progressLocal = 0; -#endif // LCD_UPDATE - muted = false; - percentOver = 0; - volume = 0; - timeout_cnt = 0; - /* this is a hack: the only place where this is checked is the menu to decide - * if display settings are to be applied. - * we have nothing to configure anyway, so setting has_lcd = false hides that menu. - */ - has_lcd = false; - clearClock = 0; -} - -CLCD* CLCD::getInstance() -{ - static CLCD* lcdd = NULL; - if(lcdd == NULL) - { - lcdd = new CLCD(); - } - /* HACK */ - g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] = 2; - return lcdd; -} - -void CLCD::count_down() { - if (timeout_cnt > 0) { - timeout_cnt--; - if (timeout_cnt == 0) { - setlcdparameter(); - } - } -} - -void CLCD::wake_up() { - if (atoi(g_settings.lcd_setting_dim_time) > 0) { - timeout_cnt = atoi(g_settings.lcd_setting_dim_time); - setlcdparameter(); - } -} - -#ifndef BOXMODEL_DM500 -void* CLCD::TimeThread(void *) -{ - while(1) - { - sleep(1); - struct stat buf; - if (stat("/tmp/lcd.locked", &buf) == -1) { - CLCD::getInstance()->showTime(); - CLCD::getInstance()->count_down(); - } else - CLCD::getInstance()->wake_up(); - } - return NULL; -} -#else -// there is no LCD on DM500, so let's use the timethread for blinking the LED during record -void* CLCD::TimeThread(void *) -{ - int led = 0; - int old_led = 0; - int led_fd = open("/dev/dbox/fp0", O_RDWR); - - if (led_fd < 0) - { - perror("CLCD::TimeThread: /dev/dbox/fp0"); - return NULL; - } - // printf("CLCD:TimeThread dm500 led_fd: %d\n",led_fd); - while(1) - { - sleep(1); - if (CNeutrinoApp::getInstance()->recordingstatus) - led = !led; - else - led = (CLCD::getInstance()->mode == MODE_STANDBY); - - if (led != old_led) { - //printf("CLCD:TimeThread ioctl(led_fd,11, &%d)\n",led); - ioctl(led_fd, 11, &led); - old_led = led; - } - } - return NULL; -} -#endif - -void CLCD::init(const char * fontfile, const char * fontname, - const char * fontfile2, const char * fontname2, - const char * fontfile3, const char * fontname3) -{ - InitNewClock(); - - if (!lcdInit(fontfile, fontname, fontfile2, fontname2, fontfile3, fontname3 )) - { - printf("[lcdd] LCD-Init failed!\n"); - has_lcd = false; -#ifndef BOXMODEL_DM500 - // on the dm500, we need the timethread for the front LEDs - return; -#endif - } - - if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) - { - perror("[lcdd]: pthread_create(TimeThread)"); - return ; - } -} - -enum backgrounds { - BACKGROUND_SETUP = 0, - BACKGROUND_POWER = 1, - BACKGROUND_LCD2 = 2, - BACKGROUND_LCD3 = 3, - BACKGROUND_LCD = 4 -// BACKGROUND_LCD4 = 5 -}; -const char * const background_name[LCD_NUMBER_OF_BACKGROUNDS] = { - "setup", - "power", - "lcd2", - "lcd3", - "lcd" -}; -#define NUMBER_OF_PATHS 2 -const char * const background_path[NUMBER_OF_PATHS] = { - LCDDIR_VAR , - DATADIR "/lcdd/icons/" -}; - -bool CLCD::lcdInit(const char * fontfile, const char * fontname, - const char * fontfile2, const char * fontname2, - const char * fontfile3, const char * fontname3) -{ - fontRenderer = new LcdFontRenderClass(&display); - const char * style_name = fontRenderer->AddFont(fontfile); - const char * style_name2; - const char * style_name3; - - if (fontfile2 != NULL) - style_name2 = fontRenderer->AddFont(fontfile2); - else - { - style_name2 = style_name; - fontname2 = fontname; - } - - if (fontfile3 != NULL) - style_name3 = fontRenderer->AddFont(fontfile3); - else - { - style_name3 = style_name; - fontname3 = fontname; - } - fontRenderer->InitFontCache(); - - fonts.menu = fontRenderer->getFont(fontname, style_name , 12); - fonts.time = fontRenderer->getFont(fontname2, style_name2, 14); - fonts.channelname = fontRenderer->getFont(fontname3, style_name3, 15); - fonts.menutitle = fonts.channelname; - - setAutoDimm(g_settings.lcd_setting[SNeutrinoSettings::LCD_AUTODIMM]); - - if (!display.isAvailable()) - { - printf("[lcdd] exit...(no lcd-support)\n"); - return false; - } - - for (int i = 0; i < LCD_NUMBER_OF_BACKGROUNDS; i++) - { - for (int j = 0; j < NUMBER_OF_PATHS; j++) - { - std::string file = background_path[j]; - file += background_name[i]; - file += ".png"; - if (display.load_png(file.c_str())) - goto found; - } - printf("[neutrino/lcd] no valid %s background.\n", background_name[i]); - return false; - found: - display.dump_screen(&(background[i])); - } - - setMode(MODE_TVRADIO); - - return true; -} - -void CLCD::displayUpdate() -{ - struct stat buf; - if (stat("/tmp/lcd.locked", &buf) == -1) - display.update(); -} - -#ifndef HAVE_TRIPLEDRAGON -void CLCD::setlcdparameter(int dimm, const int contrast, const int power, const int inverse, const int bias) -{ -#if defined HAVE_DBOX_HARDWARE || defined HAVE_DREAMBOX_HARDWARE || defined HAVE_IPBOX_HARDWARE - if (!display.isAvailable()) - return; - int fd; - if (power == 0) - dimm = 0; - - if ((fd = open("/dev/dbox/fp0", O_RDWR)) == -1) - { - perror("[lcdd] open '/dev/dbox/fp0' failed"); - } - else - { - if (ioctl(fd, FP_IOCTL_LCD_DIMM, &dimm) < 0) - { - perror("[lcdd] set dimm failed!"); - } - - close(fd); - } - - if ((fd = open("/dev/dbox/lcd0", O_RDWR)) == -1) - { - perror("[lcdd] open '/dev/dbox/lcd0' failed"); - } - else - { - if (ioctl(fd, LCD_IOCTL_SRV, &contrast) < 0) - { - perror("[lcdd] set contrast failed!"); - } - - if (ioctl(fd, LCD_IOCTL_ON, &power) < 0) - { - perror("[lcdd] set power failed!"); - } - - if (ioctl(fd, LCD_IOCTL_REVERSE, &inverse) < 0) - { - perror("[lcdd] set invert failed!"); - } - - if (g_info.box_Type == CControld::TUXBOX_MAKER_PHILIPS) - { - if (ioctl(fd, LCD_IOCTL_BIAS, &bias) < 0) - { - perror("[lcdd] set bias failed!"); - } - } - close(fd); - } -#endif -} -#else -void CLCD::setlcdparameter(int /*dimm*/, const int contrast, const int /*power*/, const int inverse, const int /*bias*/) -{ - int fd = open("/dev/" DEVICE_NAME_LCD, O_RDWR); - if (fd < 0) - { - perror("CLCD::setlcdparameter open " DEVICE_NAME_LCD); - return; - } - if (ioctl(fd, IOC_LCD_INVERS, inverse & 1) < 0) - perror("CLCD::setlcdparameter ioctl IOC_LCD_INVERS"); - if (ioctl(fd, IOC_LCD_POTI, contrast) < 0) - perror("CLCD::setlcdparameter ioctl IOC_LCD_POTI"); - - close(fd); -} -#endif - -void CLCD::setlcdparameter(void) -{ - last_toggle_state_power = g_settings.lcd_setting[SNeutrinoSettings::LCD_POWER]; - int dim_time = atoi(g_settings.lcd_setting_dim_time); - int dim_brightness = g_settings.lcd_setting_dim_brightness; - bool timeouted = (dim_time > 0) && (timeout_cnt == 0); - int brightness, power = 0; - - if (timeouted) - brightness = dim_brightness; - else - brightness = g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS]; - - if (last_toggle_state_power && (!timeouted || dim_brightness > 0)) - power = 1; - - if (mode == MODE_STANDBY) - brightness = g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS]; - - setlcdparameter(brightness, - g_settings.lcd_setting[SNeutrinoSettings::LCD_CONTRAST], - power, - g_settings.lcd_setting[SNeutrinoSettings::LCD_INVERSE], - 0 /*g_settings.lcd_setting[SNeutrinoSettings::LCD_BIAS]*/); -} - -static std::string removeLeadingSpaces(const std::string & text) -{ - int pos = text.find_first_not_of(" "); - - if (pos != -1) - return text.substr(pos); - - return text; -} - -static std::string splitString(const std::string & text, const int maxwidth, LcdFont *font, bool dumb, bool utf8) -{ - int pos; - std::string tmp = removeLeadingSpaces(text); - - if (font->getRenderWidth(tmp.c_str(), utf8) > maxwidth) - { - do - { - if (dumb) - tmp = tmp.substr(0, tmp.length()-1); - else - { - pos = tmp.find_last_of("[ .-]+"); // TODO characters might be UTF-encoded! - if (pos != -1) - tmp = tmp.substr(0, pos); - else // does not fit -> fall back to dumb split - tmp = tmp.substr(0, tmp.length()-1); - } - } while (font->getRenderWidth(tmp.c_str(), utf8) > maxwidth); - } - - return tmp; -} - -/* display "big" and "small" text. - TODO: right now, "big" is hardcoded as utf-8, small is not (for EPG) - */ -void CLCD::showTextScreen(const std::string & big, const std::string & small, const int showmode, const bool perform_wakeup, const bool centered) -{ - /* the "showmode" variable is a bit map: - 0x01 show "big" string - 0x02 show "small" string - 0x04 show separator line if big and small are present / shown - 0x08 show only one line of "big" string - */ - - /* draw_fill_rect is braindead: it actually fills _inside_ the described rectangle, - so that you have to give it one pixel additionally in every direction ;-( - this is where the "-1 to 120" intead of "0 to 119" comes from */ - display.draw_fill_rect(-1, 10, LCD_COLS, 51, CLCDDisplay::PIXEL_OFF); - - bool big_utf8 = false; - bool small_utf8 = false; - std::string cname[2]; - std::string event[4]; - int namelines = 0, eventlines = 0, maxnamelines = 2; - if (showmode & 8) - maxnamelines = 1; - - if ((showmode & 1) && !big.empty()) - { - bool dumb = false; - big_utf8 = isUTF8(big); - while (true) - { - namelines = 0; - std::string title = big; - do { // first try "intelligent" splitting - cname[namelines] = splitString(title, LCD_COLS, fonts.channelname, dumb, big_utf8); - title = removeLeadingSpaces(title.substr(cname[namelines].length())); - namelines++; - } while (title.length() > 0 && namelines < maxnamelines); - if (title.length() == 0) - break; - dumb = !dumb; // retry with dumb splitting; - if (!dumb) // second retry -> get out; - break; - } - } - - // one nameline => 2 eventlines, 2 namelines => 1 eventline - int maxeventlines = 4 - (namelines * 3 + 1) / 2; - - if ((showmode & 2) && !small.empty()) - { - bool dumb = false; - small_utf8 = isUTF8(small); - while (true) - { - eventlines = 0; - std::string title = small; - do { // first try "intelligent" splitting - event[eventlines] = splitString(title, LCD_COLS, fonts.menu, dumb, small_utf8); - title = removeLeadingSpaces(title.substr(event[eventlines].length())); - /* DrDish TV appends a 0x0a to the EPG title. We could strip it in sectionsd... - ...instead, strip all control characters at the end of the text for now */ - if (event[eventlines].length() > 0 && event[eventlines].at(event[eventlines].length() - 1) < ' ') - event[eventlines].erase(event[eventlines].length() - 1); - eventlines++; - } while (title.length() >0 && eventlines < maxeventlines); - if (title.length() == 0) - break; - dumb = !dumb; // retry with dumb splitting; - if (!dumb) // second retry -> get out; - break; - } - } - - /* this values were determined empirically */ - int y = 8 + (41 - namelines*14 - eventlines*10)/2; - int x = 1; - for (int i = 0; i < namelines; i++) { - y += 14; - if (centered) - { - int w = fonts.channelname->getRenderWidth(cname[i].c_str(), big_utf8); - x = (LCD_COLS - w) / 2; - } - fonts.channelname->RenderString(x, y, LCD_COLS + 10, cname[i].c_str(), CLCDDisplay::PIXEL_ON, 0, big_utf8); - } - y++; - if (eventlines > 0 && namelines > 0 && showmode & 4) - { - y++; - display.draw_line(0, y, LCD_COLS - 1, y, CLCDDisplay::PIXEL_ON); - } - if (eventlines > 0) - { - for (int i = 0; i < eventlines; i++) { - y += 10; - if (centered) - { - int w = fonts.menu->getRenderWidth(event[i].c_str(), small_utf8); - x = (LCD_COLS - w) / 2; - } - fonts.menu->RenderString(x, y, LCD_COLS + 10, event[i].c_str(), CLCDDisplay::PIXEL_ON, 0, small_utf8); - } - } - - if (perform_wakeup) - wake_up(); - - displayUpdate(); -} - -void CLCD::showServicename(const std::string name, const bool perform_wakeup) -{ - /* - 1 = show servicename - 2 = show epg title - 4 = draw separator line between name and EPG - */ - int showmode = g_settings.lcd_setting[SNeutrinoSettings::LCD_EPGMODE]; - /* HACK */ - showmode = 7; - - //printf("CLCD::showServicename '%s' epg: '%s'\n", name.c_str(), epg_title.c_str()); - - if (!name.empty()) - servicename = name; - - if (mode != MODE_TVRADIO) - return; - - showTextScreen(servicename, epg_title, showmode, perform_wakeup, true); - return; -} - -void CLCD::setEPGTitle(const std::string title) -{ - if (title == epg_title) - { - //fprintf(stderr,"CLCD::setEPGTitle: not changed\n"); - return; - } - epg_title = title; - showServicename("", false); -} - -void CLCD::setMovieInfo(const AUDIOMODES playmode, const std::string big, const std::string small, const bool centered) -{ - int showmode = g_settings.lcd_setting[SNeutrinoSettings::LCD_EPGMODE]; - showmode = 7; - showmode |= 3; // take only the separator line from the config - - movie_playmode = playmode; - movie_big = big; - movie_small = small; - movie_centered = centered; - - if (mode != MODE_MOVIE) - return; - - showAudioPlayMode(movie_playmode); - showTextScreen(movie_big, movie_small, showmode, true, movie_centered); -} - -void CLCD::setMovieAudio(const bool is_ac3) -{ - movie_is_ac3 = is_ac3; - - if (mode != MODE_MOVIE) - return; - - showPercentOver(percentOver, true, MODE_MOVIE); -} - -void CLCD::showTime() -{ - if (showclock) - { - char timestr[21]; - struct timeval tm; - struct tm * t; - - gettimeofday(&tm, NULL); - t = localtime(&tm.tv_sec); - - if (mode == MODE_STANDBY) - { - display.draw_fill_rect(-1, -1, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); // clear lcd - ShowNewClock(&display, t->tm_hour, t->tm_min, t->tm_sec, t->tm_wday, t->tm_mday, t->tm_mon, CNeutrinoApp::getInstance()->recordingstatus); - } - else - { - if (CNeutrinoApp::getInstance ()->recordingstatus && clearClock == 1) - { - strcpy(timestr," : "); - clearClock = 0; - } - else - { - strftime((char*) ×tr, 20, "%H:%M", t); - clearClock = 1; - } - - display.draw_fill_rect (77, 50, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); - - fonts.time->RenderString(122 - fonts.time->getRenderWidth(timestr), 62, 50, timestr, CLCDDisplay::PIXEL_ON); - } - displayUpdate(); - } -} - -void CLCD::showRCLock(int duration) -{ - std::string icon = DATADIR "/lcdd/icons/rclock.raw"; - raw_display_t curr_screen; - - // Saving the whole screen is not really nice since the clock is updated - // every second. Restoring the screen can cause a short travel to the past ;) - display.dump_screen(&curr_screen); - display.draw_fill_rect (-1, 10, LCD_COLS, 50, CLCDDisplay::PIXEL_OFF); - display.paintIcon(icon,44,25,false); - wake_up(); - displayUpdate(); - sleep(duration); - display.load_screen(&curr_screen); - wake_up(); - displayUpdate(); -} - -void CLCD::showVolume(const char vol, const bool perform_update) -{ - volume = vol; - if ( - ((mode == MODE_TVRADIO) && (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME])) || - ((mode == MODE_MOVIE) && (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME])) || - (mode == MODE_SCART) || - (mode == MODE_AUDIO) - ) - { - display.draw_fill_rect (11,53,73,61, CLCDDisplay::PIXEL_OFF); - //strichlin - if ((muted) || (volume==0)) - { - display.draw_line (12,55,72,59, CLCDDisplay::PIXEL_ON); - } - else - { - int dp = vol*61/100+12; - display.draw_fill_rect (11,54,dp,60, CLCDDisplay::PIXEL_ON); - } - if(mode == MODE_AUDIO) - { - display.draw_fill_rect (-1, 51, 10, 62, CLCDDisplay::PIXEL_OFF); - display.draw_rectangle ( 1, 55, 3, 58, CLCDDisplay::PIXEL_ON, CLCDDisplay::PIXEL_OFF); - display.draw_line ( 3, 55, 6, 52, CLCDDisplay::PIXEL_ON); - display.draw_line ( 3, 58, 6, 61, CLCDDisplay::PIXEL_ON); - display.draw_line ( 6, 54, 6, 59, CLCDDisplay::PIXEL_ON); - } - - if (perform_update) - displayUpdate(); - } - wake_up(); -} - -void CLCD::showPercentOver(const unsigned char perc, const bool perform_update, const MODES m) -{ - if (mode != m) - return; - - int left, top, width, height = 5; - bool draw = true; - percentOver = perc; - if (mode == MODE_TVRADIO || mode == MODE_MOVIE) - { - if (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] == 0) - { - left = 12; top = 55; width = 60; - } - else if (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] == 2) - { - left = 12; top = 3; width = 104; - } - else if (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] == 3) - { - left = 12; top = 3; width = 84; - - if ((g_RemoteControl != NULL && mode == MODE_TVRADIO) || mode == MODE_MOVIE) - { - bool is_ac3; - if (mode == MODE_MOVIE) - is_ac3 = movie_is_ac3; - else - { - uint count = g_RemoteControl->current_PIDs.APIDs.size(); - if ((g_RemoteControl->current_PIDs.PIDs.selected_apid < count) && - (g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].is_ac3)) - is_ac3 = true; - else - is_ac3 = false; - } - - const char * icon; - if (is_ac3) - icon = DATADIR "/lcdd/icons/dd.raw"; - else - icon = DATADIR "/lcdd/icons/stereo.raw"; - - display.paintIcon(icon, 101, 1, false); - } - } - else - draw = false; - - if (draw) - { - display.draw_fill_rect (left-1, top-1, left+width+1, top+height, CLCDDisplay::PIXEL_OFF); - if (perc == (unsigned char) -1) - { - display.draw_line (left, top, left+width, top+height-1, CLCDDisplay::PIXEL_ON); - } - else - { - int dp; - if (perc == (unsigned char) -2) - dp = width+1; - else - dp = perc * (width + 1) / 100; - display.draw_fill_rect (left-1, top-1, left+dp, top+height, CLCDDisplay::PIXEL_ON); - - if (perc == (unsigned char) -2) - { - // draw a "+" to show that the event is overdue - display.draw_line(left+width-2, top+1, left+width-2, top+height-2, CLCDDisplay::PIXEL_OFF); - display.draw_line(left+width-1, top+(height/2), left+width-3, top+(height/2), CLCDDisplay::PIXEL_OFF); - } - } - } - - if (perform_update) - displayUpdate(); - } -} - -void CLCD::showMenuText(const int position, const char * text, const int highlight, const bool utf_encoded) -{ - /* hack, to not have to patch too much in movieplayer.cpp */ - if (mode == MODE_MOVIE) { - size_t p; - AUDIOMODES m = movie_playmode; - std::string mytext = text; - if (mytext.find("> ") == 0) { - mytext = mytext.substr(2); - m = AUDIO_MODE_PLAY; - } else if (mytext.find("|| ") == 0) { - mytext = mytext.substr(3); - m = AUDIO_MODE_PAUSE; - } else if ((p = mytext.find("s||> ")) < 3) { - mytext = mytext.substr(p + 5); - m = AUDIO_MODE_PLAY; - } else if ((p = mytext.find("x>> ")) < 3) { - mytext = mytext.substr(p + 4); - m = AUDIO_MODE_FF; - } else if ((p = mytext.find("x<< ")) < 3) { - mytext = mytext.substr(p + 4); - m = AUDIO_MODE_REV; - } - setMovieInfo(m, "", mytext, false); - return; - } - - if (mode != MODE_MENU_UTF8) - return; - - // reload specified line - display.draw_fill_rect(-1, 35+14*position, LCD_COLS, 35+14+14*position, CLCDDisplay::PIXEL_OFF); - fonts.menu->RenderString(0,35+11+14*position, LCD_COLS + 20, text, CLCDDisplay::PIXEL_INV, highlight, utf_encoded); - wake_up(); - displayUpdate(); - -} - -void CLCD::showAudioTrack(const std::string & artist, const std::string & title, const std::string & album) -{ - if (mode != MODE_AUDIO) - { - return; - } - - // reload specified line - display.draw_fill_rect (-1, 10, LCD_COLS, 24, CLCDDisplay::PIXEL_OFF); - display.draw_fill_rect (-1, 20, LCD_COLS, 37, CLCDDisplay::PIXEL_OFF); - display.draw_fill_rect (-1, 33, LCD_COLS, 50, CLCDDisplay::PIXEL_OFF); - fonts.menu->RenderString(0, 22, LCD_COLS + 5, artist.c_str(), CLCDDisplay::PIXEL_ON, 0, isUTF8(artist)); - fonts.menu->RenderString(0, 35, LCD_COLS + 5, album.c_str(), CLCDDisplay::PIXEL_ON, 0, isUTF8(album)); - fonts.menu->RenderString(0, 48, LCD_COLS + 5, title.c_str(), CLCDDisplay::PIXEL_ON, 0, isUTF8(title)); - wake_up(); - displayUpdate(); - -} - -void CLCD::showAudioPlayMode(AUDIOMODES m) -{ - display.draw_fill_rect (-1,51,10,62, CLCDDisplay::PIXEL_OFF); - switch(m) - { - case AUDIO_MODE_PLAY: - { - int x=3,y=53; - display.draw_line(x ,y ,x ,y+8, CLCDDisplay::PIXEL_ON); - display.draw_line(x+1,y+1,x+1,y+7, CLCDDisplay::PIXEL_ON); - display.draw_line(x+2,y+2,x+2,y+6, CLCDDisplay::PIXEL_ON); - display.draw_line(x+3,y+3,x+3,y+5, CLCDDisplay::PIXEL_ON); - display.draw_line(x+4,y+4,x+4,y+4, CLCDDisplay::PIXEL_ON); - break; - } - case AUDIO_MODE_STOP: - display.draw_fill_rect (1, 53, 8 ,61, CLCDDisplay::PIXEL_ON); - break; - case AUDIO_MODE_PAUSE: - display.draw_line(1,54,1,60, CLCDDisplay::PIXEL_ON); - display.draw_line(2,54,2,60, CLCDDisplay::PIXEL_ON); - display.draw_line(6,54,6,60, CLCDDisplay::PIXEL_ON); - display.draw_line(7,54,7,60, CLCDDisplay::PIXEL_ON); - break; - case AUDIO_MODE_FF: - { - int x=2,y=55; - display.draw_line(x ,y , x , y+4, CLCDDisplay::PIXEL_ON); - display.draw_line(x+1 ,y+1 , x+1, y+3, CLCDDisplay::PIXEL_ON); - display.draw_line(x+2 ,y+2 , x+2, y+2, CLCDDisplay::PIXEL_ON); - display.draw_line(x+3 ,y , x+3, y+4, CLCDDisplay::PIXEL_ON); - display.draw_line(x+4 ,y+1 , x+4, y+3, CLCDDisplay::PIXEL_ON); - display.draw_line(x+5 ,y+2 , x+5, y+2, CLCDDisplay::PIXEL_ON); - } - break; - case AUDIO_MODE_REV: - { - int x=2,y=55; - display.draw_line(x ,y+2 , x , y+2, CLCDDisplay::PIXEL_ON); - display.draw_line(x+1 ,y+1 , x+1, y+3, CLCDDisplay::PIXEL_ON); - display.draw_line(x+2 ,y , x+2, y+4, CLCDDisplay::PIXEL_ON); - display.draw_line(x+3 ,y+2 , x+3, y+2, CLCDDisplay::PIXEL_ON); - display.draw_line(x+4 ,y+1 , x+4, y+3, CLCDDisplay::PIXEL_ON); - display.draw_line(x+5 ,y , x+5, y+4, CLCDDisplay::PIXEL_ON); - } - break; - } - wake_up(); - displayUpdate(); -} - -void CLCD::showAudioProgress(const char perc, bool isMuted) -{ - if (mode == MODE_AUDIO) - { - display.draw_fill_rect (11,53,73,61, CLCDDisplay::PIXEL_OFF); - int dp = int( perc/100.0*61.0+12.0); - display.draw_fill_rect (11,54,dp,60, CLCDDisplay::PIXEL_ON); - if(isMuted) - { - if(dp > 12) - { - display.draw_line(12, 56, dp-1, 56, CLCDDisplay::PIXEL_OFF); - display.draw_line(12, 58, dp-1, 58, CLCDDisplay::PIXEL_OFF); - } - else - display.draw_line (12,55,72,59, CLCDDisplay::PIXEL_ON); - } - displayUpdate(); - } -} - -void CLCD::setMode(const MODES m, const char * const title) -{ - mode = m; - menutitle = title; - setlcdparameter(); - - switch (m) - { - case MODE_TVRADIO: - case MODE_MOVIE: - switch (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME]) - { - case 0: - display.load_screen(&(background[BACKGROUND_LCD2])); - showPercentOver(percentOver, false, mode); - break; - case 1: - display.load_screen(&(background[BACKGROUND_LCD])); - showVolume(volume, false); - break; - case 2: - display.load_screen(&(background[BACKGROUND_LCD3])); - showVolume(volume, false); - showPercentOver(percentOver, false, mode); - break; - case 3: - display.load_screen(&(background[BACKGROUND_LCD3])); - showVolume(volume, false); - showPercentOver(percentOver, false, mode); - break; - default: - break; - } - if (mode == MODE_TVRADIO) - showServicename(servicename); - else - { - setMovieInfo(movie_playmode, movie_big, movie_small, movie_centered); - setMovieAudio(movie_is_ac3); - } - showclock = true; - showTime(); /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */ - break; - case MODE_AUDIO: - { - display.load_screen(&(background[BACKGROUND_LCD])); - display.draw_fill_rect(0, 14, LCD_COLS, 48, CLCDDisplay::PIXEL_OFF); - - showAudioPlayMode(AUDIO_MODE_STOP); - showVolume(volume, false); - showclock = true; - showTime(); /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */ - break; - } - case MODE_SCART: - display.load_screen(&(background[BACKGROUND_LCD])); - showVolume(volume, false); - showclock = true; - showTime(); /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */ - break; - case MODE_MENU_UTF8: - showclock = false; - display.load_screen(&(background[BACKGROUND_SETUP])); - fonts.menutitle->RenderString(0, 28, LCD_COLS + 20, title, CLCDDisplay::PIXEL_ON, 0, true); // UTF-8 - displayUpdate(); - break; - case MODE_SHUTDOWN: - showclock = false; - display.load_screen(&(background[BACKGROUND_POWER])); - displayUpdate(); - break; - case MODE_STANDBY: - showclock = true; - showTime(); /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */ - /* "showTime()" clears the whole lcd in MODE_STANDBY */ - break; -#ifdef LCD_UPDATE - case MODE_FILEBROWSER: - showclock = true; - display.draw_fill_rect(-1, -1, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); // clear lcd - showFilelist(); - break; - case MODE_PROGRESSBAR: - showclock = false; - display.load_screen(&(background[BACKGROUND_SETUP])); - showProgressBar(); - break; - case MODE_PROGRESSBAR2: - showclock = false; - display.load_screen(&(background[BACKGROUND_SETUP])); - showProgressBar2(); - break; - case MODE_INFOBOX: - showclock = false; - showInfoBox(); - break; -#endif // LCD_UPDATE - } - wake_up(); -} - - -void CLCD::setBrightness(int bright) -{ - g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS] = bright; - setlcdparameter(); -} - -int CLCD::getBrightness() -{ - return g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS]; -} - -void CLCD::setBrightnessStandby(int bright) -{ - g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] = bright; - setlcdparameter(); -} - -int CLCD::getBrightnessStandby() -{ - return g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS]; -} - -void CLCD::setContrast(int contrast) -{ - g_settings.lcd_setting[SNeutrinoSettings::LCD_CONTRAST] = contrast; - setlcdparameter(); -} - -int CLCD::getContrast() -{ - return g_settings.lcd_setting[SNeutrinoSettings::LCD_CONTRAST]; -} - -void CLCD::setPower(int power) -{ - g_settings.lcd_setting[SNeutrinoSettings::LCD_POWER] = power; - setlcdparameter(); -} - -int CLCD::getPower() -{ - return g_settings.lcd_setting[SNeutrinoSettings::LCD_POWER]; -} - -void CLCD::togglePower(void) -{ - last_toggle_state_power = 1 - last_toggle_state_power; - setlcdparameter((mode == MODE_STANDBY) ? g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] : g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS], - g_settings.lcd_setting[SNeutrinoSettings::LCD_CONTRAST], - last_toggle_state_power, - g_settings.lcd_setting[SNeutrinoSettings::LCD_INVERSE], - 0 /*g_settings.lcd_setting[SNeutrinoSettings::LCD_BIAS]*/); -} - -void CLCD::setInverse(int inverse) -{ - g_settings.lcd_setting[SNeutrinoSettings::LCD_INVERSE] = inverse; - setlcdparameter(); -} - -int CLCD::getInverse() -{ - return g_settings.lcd_setting[SNeutrinoSettings::LCD_INVERSE]; -} - -#ifdef HAVE_DBOX_HARDWARE -void CLCD::setAutoDimm(int autodimm) -{ - int fd; - g_settings.lcd_setting[SNeutrinoSettings::LCD_AUTODIMM] = autodimm; - - if ((fd = open("/dev/dbox/fp0", O_RDWR)) == -1) - { - perror("[lcdd] open '/dev/dbox/fp0' failed"); - } - else - { - if( ioctl(fd, FP_IOCTL_LCD_AUTODIMM, &autodimm) < 0 ) - { - perror("[lcdd] set autodimm failed!"); - } - - close(fd); - } -} -#else -void CLCD::setAutoDimm(int /*autodimm*/) -{ -} -#endif - -int CLCD::getAutoDimm() -{ - return g_settings.lcd_setting[SNeutrinoSettings::LCD_AUTODIMM]; -} - -void CLCD::setMuted(bool mu) -{ - muted = mu; - showVolume(volume); -} - -void CLCD::resume() -{ - display.resume(); -} - -void CLCD::pause() -{ - display.pause(); -} - -void CLCD::ShowIcon(vfd_icon icon, bool show) -{ - fprintf(stderr, "CLCD::ShowIcon(%d, %d)\n", icon, show); -} - -void CLCD::Lock() -{ -/* - if(!has_lcd) return; - creat("/tmp/vfd.locked", 0); -*/ -} - -void CVFD::Unlock() -{ -/* - if(!has_lcd) return; - unlink("/tmp/vfd.locked"); -*/ -} - -void CLCD::Clear() -{ - return; -} - -#ifdef LCD_UPDATE -/*****************************************************************************************/ -// showInfoBox -/*****************************************************************************************/ -#define LCD_WIDTH LCD_COLS -#define LCD_HEIGTH 64 - -#define EPG_INFO_FONT_HEIGHT 9 -#define EPG_INFO_SHADOW_WIDTH 1 -#define EPG_INFO_LINE_WIDTH 1 -#define EPG_INFO_BORDER_WIDTH 2 - -#define EPG_INFO_WINDOW_POS 4 -#define EPG_INFO_LINE_POS EPG_INFO_WINDOW_POS + EPG_INFO_SHADOW_WIDTH -#define EPG_INFO_BORDER_POS EPG_INFO_WINDOW_POS + EPG_INFO_SHADOW_WIDTH + EPG_INFO_LINE_WIDTH -#define EPG_INFO_TEXT_POS EPG_INFO_WINDOW_POS + EPG_INFO_SHADOW_WIDTH + EPG_INFO_LINE_WIDTH + EPG_INFO_BORDER_WIDTH - -#define EPG_INFO_TEXT_WIDTH LCD_WIDTH - (2*EPG_INFO_WINDOW_POS) - -// timer 0: OFF, timer>0 time to show in seconds, timer>=999 endless -void CLCD::showInfoBox(const char * const title, const char * const text ,int autoNewline,int timer) -{ - //printf("[lcdd] Info: \n"); - if(text != NULL) - m_infoBoxText = text; - if(title != NULL) - m_infoBoxTitle = title; - if(timer != -1) - m_infoBoxTimer = timer; - if(autoNewline != -1) - m_infoBoxAutoNewline = autoNewline; - - //printf("[lcdd] Info: %s,%s,%d,%d\n",m_infoBoxTitle.c_str(),m_infoBoxText.c_str(),m_infoBoxAutoNewline,m_infoBoxTimer); - if( mode == MODE_INFOBOX && - !m_infoBoxText.empty()) - { - // paint empty box - display.draw_fill_rect (EPG_INFO_WINDOW_POS, EPG_INFO_WINDOW_POS, LCD_WIDTH-EPG_INFO_WINDOW_POS+1, LCD_HEIGTH-EPG_INFO_WINDOW_POS+1, CLCDDisplay::PIXEL_OFF); - display.draw_fill_rect (EPG_INFO_LINE_POS, EPG_INFO_LINE_POS, LCD_WIDTH-EPG_INFO_LINE_POS-1, LCD_HEIGTH-EPG_INFO_LINE_POS-1, CLCDDisplay::PIXEL_ON); - display.draw_fill_rect (EPG_INFO_BORDER_POS, EPG_INFO_BORDER_POS, LCD_WIDTH-EPG_INFO_BORDER_POS-3, LCD_HEIGTH-EPG_INFO_BORDER_POS-3, CLCDDisplay::PIXEL_OFF); - - // paint title - if(!m_infoBoxTitle.empty()) - { - int width = fonts.menu->getRenderWidth(m_infoBoxTitle.c_str(),true); - if(width > LCD_COLS - 20) - width = LCD_COLS - 20; - int start_pos = (LCD_COLS - width) /2; - display.draw_fill_rect (start_pos, EPG_INFO_WINDOW_POS-4, start_pos+width+5, EPG_INFO_WINDOW_POS+10, CLCDDisplay::PIXEL_OFF); - fonts.menu->RenderString(start_pos+4,EPG_INFO_WINDOW_POS+5, width+5, m_infoBoxTitle.c_str(), CLCDDisplay::PIXEL_ON, 0, true); // UTF-8 - } - - // paint info - std::string text_line; - int line; - int pos = 0; - int length = m_infoBoxText.size(); - for(line = 0; line < 5; line++) - { - text_line.clear(); - while ( m_infoBoxText[pos] != '\n' && - ((fonts.menu->getRenderWidth(text_line.c_str(), true) < EPG_INFO_TEXT_WIDTH-10) || !m_infoBoxAutoNewline )&& - (pos < length)) // UTF-8 - { - if ( m_infoBoxText[pos] >= ' ' && m_infoBoxText[pos] <= '~' ) // any char between ASCII(32) and ASCII (126) - text_line += m_infoBoxText[pos]; - pos++; - } - //printf("[lcdd] line %d:'%s'\r\n",line,text_line.c_str()); - fonts.menu->RenderString(EPG_INFO_TEXT_POS+1,EPG_INFO_TEXT_POS+(line*EPG_INFO_FONT_HEIGHT)+EPG_INFO_FONT_HEIGHT+3, EPG_INFO_TEXT_WIDTH, text_line.c_str(), CLCDDisplay::PIXEL_ON, 0, true); // UTF-8 - if ( m_infoBoxText[pos] == '\n' ) - pos++; // remove new line - } - displayUpdate(); - } -} - -/*****************************************************************************************/ -//showFilelist -/*****************************************************************************************/ -#define BAR_POS_X 114 -#define BAR_POS_Y 10 -#define BAR_POS_WIDTH 6 -#define BAR_POS_HEIGTH 40 - -void CLCD::showFilelist(int flist_pos,CFileList* flist,const char * const mainDir) -{ - //printf("[lcdd] FileList\n"); - if(flist != NULL) - m_fileList = flist; - if(flist_pos != -1) - m_fileListPos = flist_pos; - if(mainDir != NULL) - m_fileListHeader = mainDir; - - if (mode == MODE_FILEBROWSER && - m_fileList != NULL && - m_fileList->size() > 0) - { - - printf("[lcdd] FileList:OK\n"); - int size = m_fileList->size(); - - display.draw_fill_rect(-1, -1, LCD_COLS, 52, CLCDDisplay::PIXEL_OFF); // clear lcd - - if(m_fileListPos > size) - m_fileListPos = size-1; - - int width = fonts.menu->getRenderWidth(m_fileListHeader.c_str(), true); - if(width > LCD_COLS - 10) - width = LCD_COLS - 10; - fonts.menu->RenderString((LCD_COLS - width) / 2, 11, width+5, m_fileListHeader.c_str(), CLCDDisplay::PIXEL_ON); - - //printf("list%d,%d\r\n",m_fileListPos,(*m_fileList)[m_fileListPos].Marked); - std::string text; - int marked; - if(m_fileListPos > 0) - { - if ( (*m_fileList)[m_fileListPos-1].Marked == false ) - { - text =""; - marked = CLCDDisplay::PIXEL_ON; - } - else - { - text ="*"; - marked = CLCDDisplay::PIXEL_INV; - } - text += (*m_fileList)[m_fileListPos-1].getFileName(); - fonts.menu->RenderString(1, 12+12, BAR_POS_X+5, text.c_str(), marked); - } - if(m_fileListPos < size) - { - if ((*m_fileList)[m_fileListPos-0].Marked == false ) - { - text =""; - marked = CLCDDisplay::PIXEL_ON; - } - else - { - text ="*"; - marked = CLCDDisplay::PIXEL_INV; - } - text += (*m_fileList)[m_fileListPos-0].getFileName(); - fonts.time->RenderString(1, 12+12+14, BAR_POS_X+5, text.c_str(), marked); - } - if(m_fileListPos < size-1) - { - if ((*m_fileList)[m_fileListPos+1].Marked == false ) - { - text =""; - marked = CLCDDisplay::PIXEL_ON; - } - else - { - text ="*"; - marked = CLCDDisplay::PIXEL_INV; - } - text += (*m_fileList)[m_fileListPos+1].getFileName(); - fonts.menu->RenderString(1, 12+12+14+12, BAR_POS_X+5, text.c_str(), marked); - } - // paint marker - int pages = (((size-1)/3 )+1); - int marker_length = (BAR_POS_HEIGTH-2) / pages; - if(marker_length <4) - marker_length=4;// not smaller than 4 pixel - int marker_offset = ((BAR_POS_HEIGTH-2-marker_length) * m_fileListPos) /size ; - //printf("%d,%d,%d\r\n",pages,marker_length,marker_offset); - - display.draw_fill_rect (BAR_POS_X, BAR_POS_Y, BAR_POS_X+BAR_POS_WIDTH, BAR_POS_Y+BAR_POS_HEIGTH, CLCDDisplay::PIXEL_ON); - display.draw_fill_rect (BAR_POS_X+1, BAR_POS_Y+1, BAR_POS_X+BAR_POS_WIDTH-1, BAR_POS_Y+BAR_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF); - display.draw_fill_rect (BAR_POS_X+1, BAR_POS_Y+1+marker_offset, BAR_POS_X+BAR_POS_WIDTH-1, BAR_POS_Y+1+marker_offset+marker_length, CLCDDisplay::PIXEL_ON); - - displayUpdate(); - } -} - -/*****************************************************************************************/ -//showProgressBar -/*****************************************************************************************/ -#define PROG_GLOB_POS_X 10 -#define PROG_GLOB_POS_Y 30 -#define PROG_GLOB_POS_WIDTH 100 -#define PROG_GLOB_POS_HEIGTH 20 -void CLCD::showProgressBar(int global, const char * const text,int show_escape,int timer) -{ - if(text != NULL) - m_progressHeaderGlobal = text; - - if(timer != -1) - m_infoBoxTimer = timer; - - if(global >= 0) - { - if(global > 100) - m_progressGlobal =100; - else - m_progressGlobal = global; - } - - if(show_escape != -1) - m_progressShowEscape = show_escape; - - if (mode == MODE_PROGRESSBAR) - { - //printf("[lcdd] prog:%s,%d,%d\n",m_progressHeaderGlobal.c_str(),m_progressGlobal,m_progressShowEscape); - // Clear Display - display.draw_fill_rect (0, 12, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); - - // paint progress header - int width = fonts.menu->getRenderWidth(m_progressHeaderGlobal.c_str(),true); - if(width > 100) - width = 100; - int start_pos = (LCD_COLS - width) /2; - fonts.menu->RenderString(start_pos, 12+12, width+10, m_progressHeaderGlobal.c_str(), CLCDDisplay::PIXEL_ON,0,true); - - // paint global bar - int marker_length = (PROG_GLOB_POS_WIDTH * m_progressGlobal)/100; - - display.draw_fill_rect (PROG_GLOB_POS_X, PROG_GLOB_POS_Y, PROG_GLOB_POS_X+PROG_GLOB_POS_WIDTH, PROG_GLOB_POS_Y+PROG_GLOB_POS_HEIGTH, CLCDDisplay::PIXEL_ON); - display.draw_fill_rect (PROG_GLOB_POS_X+1+marker_length, PROG_GLOB_POS_Y+1, PROG_GLOB_POS_X+PROG_GLOB_POS_WIDTH-1, PROG_GLOB_POS_Y+PROG_GLOB_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF); - - // paint foot - if(m_progressShowEscape == true) - { - fonts.menu->RenderString(90, 64, 40, "Home", CLCDDisplay::PIXEL_ON); - } - displayUpdate(); - } -} - -/*****************************************************************************************/ -// showProgressBar2 -/*****************************************************************************************/ -#define PROG2_GLOB_POS_X 10 -#define PROG2_GLOB_POS_Y 37 -#define PROG2_GLOB_POS_WIDTH 100 -#define PROG2_GLOB_POS_HEIGTH 10 - -#define PROG2_LOCAL_POS_X 10 -#define PROG2_LOCAL_POS_Y 24 -#define PROG2_LOCAL_POS_WIDTH PROG2_GLOB_POS_WIDTH -#define PROG2_LOCAL_POS_HEIGTH PROG2_GLOB_POS_HEIGTH - -void CLCD::showProgressBar2(int local,const char * const text_local ,int global ,const char * const text_global ,int show_escape ) -{ - //printf("[lcdd] prog2\n"); - if(text_local != NULL) - m_progressHeaderLocal = text_local; - - if(text_global != NULL) - m_progressHeaderGlobal = text_global; - - if(global >= 0) - { - if(global > 100) - m_progressGlobal =100; - else - m_progressGlobal = global; - } - - if(local >= 0) - { - if(local > 100) - m_progressLocal =100; - else - m_progressLocal = local; - } - - if(show_escape != -1) - m_progressShowEscape = show_escape; - - if (mode == MODE_PROGRESSBAR2) - { - //printf("[lcdd] prog2:%s,%d,%d\n",m_progressHeaderGlobal.c_str(),m_progressGlobal,m_progressShowEscape); - // Clear Display - display.draw_fill_rect (0, 12, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); - - - // paint global caption - int width = fonts.menu->getRenderWidth(m_progressHeaderGlobal.c_str(),true); - if(width > 100) - width = 100; - int start_pos = (LCD_COLS - width) /2; - fonts.menu->RenderString(start_pos, PROG2_GLOB_POS_Y+20, width+10, m_progressHeaderGlobal.c_str(), CLCDDisplay::PIXEL_ON,0,true); - - // paint global bar - int marker_length = (PROG2_GLOB_POS_WIDTH * m_progressGlobal)/100; - - display.draw_fill_rect (PROG2_GLOB_POS_X, PROG2_GLOB_POS_Y, PROG2_GLOB_POS_X+PROG2_GLOB_POS_WIDTH, PROG2_GLOB_POS_Y+PROG2_GLOB_POS_HEIGTH, CLCDDisplay::PIXEL_ON); - display.draw_fill_rect (PROG2_GLOB_POS_X+1+marker_length, PROG2_GLOB_POS_Y+1, PROG2_GLOB_POS_X+PROG2_GLOB_POS_WIDTH-1, PROG2_GLOB_POS_Y+PROG2_GLOB_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF); - - - // paint local caption - width = fonts.menu->getRenderWidth(m_progressHeaderLocal.c_str(),true); - if(width > 100) - width = 100; - start_pos = (LCD_COLS - width) /2; - fonts.menu->RenderString(start_pos, PROG2_LOCAL_POS_Y -3, width+10, m_progressHeaderLocal.c_str(), CLCDDisplay::PIXEL_ON,0,true); - // paint local bar - marker_length = (PROG2_LOCAL_POS_WIDTH * m_progressLocal)/100; - - display.draw_fill_rect (PROG2_LOCAL_POS_X, PROG2_LOCAL_POS_Y, PROG2_LOCAL_POS_X+PROG2_LOCAL_POS_WIDTH, PROG2_LOCAL_POS_Y+PROG2_LOCAL_POS_HEIGTH, CLCDDisplay::PIXEL_ON); - display.draw_fill_rect (PROG2_LOCAL_POS_X+1+marker_length, PROG2_LOCAL_POS_Y+1, PROG2_LOCAL_POS_X+PROG2_LOCAL_POS_WIDTH-1, PROG2_LOCAL_POS_Y+PROG2_LOCAL_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF); - - - // paint foot - if(m_progressShowEscape == true) - { - fonts.menu->RenderString(90, 64, 40, "Home", CLCDDisplay::PIXEL_ON); - } - displayUpdate(); - } -} -/*****************************************************************************************/ -#endif // LCD_UPDATE diff --git a/src/driver/lcdd.h b/src/driver/lcdd.h deleted file mode 100644 index 1e7e5be15..000000000 --- a/src/driver/lcdd.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - $Id$ - - LCD-Daemon - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef __lcdd__ -#define __lcdd__ - -#ifndef LCD_UPDATE -#define LCD_UPDATE 1 -#endif - -#define LCDDIR_VAR "/var/share/tuxbox/neutrino/lcdd" - -typedef enum -{ - VFD_ICON_BAR8 = 0x00000004, - VFD_ICON_BAR7 = 0x00000008, - VFD_ICON_BAR6 = 0x00000010, - VFD_ICON_BAR5 = 0x00000020, - VFD_ICON_BAR4 = 0x00000040, - VFD_ICON_BAR3 = 0x00000080, - VFD_ICON_BAR2 = 0x00000100, - VFD_ICON_BAR1 = 0x00000200, - VFD_ICON_FRAME = 0x00000400, - VFD_ICON_HDD = 0x00000800, - VFD_ICON_MUTE = 0x00001000, - VFD_ICON_DOLBY = 0x00002000, - VFD_ICON_POWER = 0x00004000, - VFD_ICON_TIMESHIFT = 0x00008000, - VFD_ICON_SIGNAL = 0x00010000, - VFD_ICON_TV = 0x00020000, - VFD_ICON_RADIO = 0x00040000, - VFD_ICON_HD = 0x01000001, - VFD_ICON_1080P = 0x02000001, - VFD_ICON_1080I = 0x03000001, - VFD_ICON_720P = 0x04000001, - VFD_ICON_480P = 0x05000001, - VFD_ICON_480I = 0x06000001, - VFD_ICON_USB = 0x07000001, - VFD_ICON_MP3 = 0x08000001, - VFD_ICON_PLAY = 0x09000001, - VFD_ICON_COL1 = 0x09000002, - VFD_ICON_PAUSE = 0x0A000001, - VFD_ICON_CAM1 = 0x0B000001, - VFD_ICON_COL2 = 0x0B000002, - VFD_ICON_CAM2 = 0x0C000001 -} vfd_icon; - -#ifdef LCD_UPDATE -#ifdef HAVE_CONFIG_H -#include -#endif -// TODO Why is USE_FILE_OFFSET64 not defined, if file.h is included here???? -#ifndef __USE_FILE_OFFSET64 -#define __USE_FILE_OFFSET64 1 -#endif -#include "driver/file.h" -#endif // LCD_UPDATE - -#include -#include - -#include - - -class CLCDPainter; -class LcdFontRenderClass; -class CLCD -{ - public: - - enum MODES - { - MODE_TVRADIO, - MODE_SCART, - MODE_SHUTDOWN, - MODE_STANDBY, - MODE_MENU_UTF8, - MODE_AUDIO, - MODE_MOVIE -#ifdef LCD_UPDATE - , MODE_FILEBROWSER, - MODE_PROGRESSBAR, - MODE_PROGRESSBAR2, - MODE_INFOBOX -#endif // LCD_UPDATE - }; - enum AUDIOMODES - { - AUDIO_MODE_PLAY, - AUDIO_MODE_STOP, - AUDIO_MODE_FF, - AUDIO_MODE_PAUSE, - AUDIO_MODE_REV - }; - - - private: - - class FontsDef - { - public: - LcdFont *channelname; - LcdFont *time; - LcdFont *menutitle; - LcdFont *menu; - }; - - CLCDDisplay display; - LcdFontRenderClass *fontRenderer; - FontsDef fonts; - -#define LCD_NUMBER_OF_BACKGROUNDS 5 - raw_display_t background[LCD_NUMBER_OF_BACKGROUNDS]; - - MODES mode; - AUDIOMODES movie_playmode; - - std::string servicename; - std::string epg_title; - std::string movie_big; - std::string movie_small; - std::string menutitle; - char volume; - unsigned char percentOver; - bool muted; - bool showclock; - bool movie_centered; - bool movie_is_ac3; - CConfigFile configfile; - pthread_t thrTime; - int last_toggle_state_power; - int clearClock; - unsigned int timeout_cnt; - - void count_down(); - - CLCD(); - - static void* TimeThread(void*); - bool lcdInit(const char * fontfile1, const char * fontname1, - const char * fontfile2=NULL, const char * fontname2=NULL, - const char * fontfile3=NULL, const char * fontname3=NULL); - void setlcdparameter(int dimm, int contrast, int power, int inverse, int bias); - void displayUpdate(); - void showTextScreen(const std::string & big, const std::string & small, int showmode, bool perform_wakeup, bool centered = false); - - public: - bool has_lcd; - void wake_up(); - void setled(void) { return; }; - void setlcdparameter(void); - - static CLCD* getInstance(); - void init(const char * fontfile, const char * fontname, - const char * fontfile2=NULL, const char * fontname2=NULL, - const char * fontfile3=NULL, const char * fontname3=NULL); - - void setMode(const MODES m, const char * const title = ""); - MODES getMode() { return mode; }; - - void showServicename(const std::string name, const bool perform_wakeup = true); // UTF-8 - void setEPGTitle(const std::string title); - void setMovieInfo(const AUDIOMODES playmode, const std::string big, const std::string small, const bool centered = false); - void setMovieAudio(const bool is_ac3); - std::string getMenutitle() { return menutitle; }; - void showTime(); - /** blocks for duration seconds */ - void showRCLock(int duration = 2); - void showVolume(const char vol, const bool perform_update = true); - void showPercentOver(const unsigned char perc, const bool perform_update = true, const MODES m = MODE_TVRADIO); - void showMenuText(const int position, const char * text, const int highlight = -1, const bool utf_encoded = false); - void showAudioTrack(const std::string & artist, const std::string & title, const std::string & album); - void showAudioPlayMode(AUDIOMODES m=AUDIO_MODE_PLAY); - void showAudioProgress(const char perc, bool isMuted); - void setBrightness(int); - int getBrightness(); - - void setBrightnessStandby(int); - int getBrightnessStandby(); - - void setContrast(int); - int getContrast(); - - void setPower(int); - int getPower(); - - void togglePower(void); - - void setInverse(int); - int getInverse(); - - void setAutoDimm(int); - int getAutoDimm(); - void setBrightnessDeepStandby(int) { return ; }; - int getBrightnessDeepStandby() { return 0; }; - - void setMuted(bool); - - void resume(); - void pause(); - - void Lock(); - void Unlock(); - void Clear(); - void ShowIcon(vfd_icon icon, bool show); - void ShowText(const char *s) { showServicename(std::string(s)); }; -#ifdef LCD_UPDATE - private: - CFileList* m_fileList; - int m_fileListPos; - std::string m_fileListHeader; - - std::string m_infoBoxText; - std::string m_infoBoxTitle; - int m_infoBoxTimer; // for later use - bool m_infoBoxAutoNewline; - - bool m_progressShowEscape; - std::string m_progressHeaderGlobal; - std::string m_progressHeaderLocal; - int m_progressGlobal; - int m_progressLocal; - public: - void showFilelist(int flist_pos = -1,CFileList* flist = NULL,const char * const mainDir=NULL); - void showInfoBox(const char * const title = NULL,const char * const text = NULL,int autoNewline = -1,int timer = -1); - void showProgressBar(int global = -1,const char * const text = NULL,int show_escape = -1,int timer = -1); - void showProgressBar2(int local = -1,const char * const text_local = NULL,int global = -1,const char * const text_global = NULL,int show_escape = -1); -#endif // LCD_UPDATE -}; - - -#endif diff --git a/src/driver/newclock.cpp b/src/driver/newclock.cpp deleted file mode 100644 index 0a2ab69bc..000000000 --- a/src/driver/newclock.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - LCD-Daemon - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean', - 2003 thegoodguy - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#include -#include -#include - -static bool time_digits[24*32 * 10]; -static bool days[24*16 * 7]; -static bool date_digits[16*16 * 10]; -static bool months[32*16 * 12]; - -static bool signs[] = {1, 1, 1, 1, - 1, 1, 1, 1, - 1, 1, 1, 1, - 1, 1, 1, 1, - - 1, 1, 1, 0, - 1, 1, 1, 0, - 0, 1, 1, 0, - 1, 1, 0, 0, - - 1, 1, 1, 0, - 1, 1, 1, 0, - 1, 1, 1, 0, - 0, 0, 0, 0}; - -void loadSkin(char * const filename, char * const backup_filename, const unsigned int modify_char_filename, const unsigned int modify_char_backup_filename, bool * const dest, const unsigned int count, const unsigned int width, const unsigned int height, const char * const name) -{ - FILE * fd; - int row, bit; - char * file; - unsigned int i ,byte, digit_pos; - unsigned char BMPWidth; - unsigned char BMPHeight; - char line_buffer[4]; - file = filename; - digit_pos = modify_char_filename; - - for (i = 0; i < count; i++) - { - bool retried = false; - retry: - if ((fd = fopen(file, "rb")) == 0) - { - printf("[lcdd] %s-skin not found (%s) -> using default...\n", name, file); - file = backup_filename; - digit_pos = modify_char_backup_filename; - i = 0; - if (!retried) { - retried = true; - goto retry; - } - break; - } - - fseek(fd, 0x12, SEEK_SET); - fread(&BMPWidth, 1, 1, fd); - fseek(fd, 0x16, SEEK_SET); - fread(&BMPHeight, 1, 1, fd); - - if ((BMPWidth > width) || (BMPHeight > height)) - { - printf("[lcdd] %s-skin not supported -> using default...\n", name); - fclose(fd); - file = backup_filename; - digit_pos = modify_char_backup_filename; - i = 0; - if (!retried) { - retried = true; - goto retry; - } - } - - fseek(fd, 0x3E, SEEK_SET); - - for (row = height - 1; row >= 0; row--) - { - fread(&line_buffer, 1, sizeof(line_buffer), fd); /* width must not be greater than 32 */ - - for (byte = 0; byte < (width >> 3); byte++) /* width must be multiple of 8 */ - { - for (bit = 7; bit >= 0; bit--) - { - dest[(7 - bit) + (byte << 3) + (row + i * height) * width] = line_buffer[byte] & (1 << bit); - } - } - } - - fclose(fd); - - file[digit_pos]++; - } -} - -void InitNewClock(void) -{ - char filename_usr[] = CONFIGDIR "/lcdd/clock/t_a.bmp"; - char filename_std[] = DATADIR "/lcdd/clock/t_a.bmp"; - - loadSkin(filename_usr, filename_std, sizeof(filename_usr) - 6, sizeof(filename_std) - 6, time_digits, 10, 24, 32, "time"); - - filename_usr[sizeof(filename_usr) - 8] = 'w'; - filename_std[sizeof(filename_std) - 8] = 'w'; - filename_usr[sizeof(filename_usr) - 6] = 'a'; - filename_std[sizeof(filename_std) - 6] = 'a'; - loadSkin(filename_usr, filename_std, sizeof(filename_usr) - 6, sizeof(filename_std) - 6, days, 7, 24, 16, "weekday"); - - filename_usr[sizeof(filename_usr) - 8] = 'd'; - filename_std[sizeof(filename_std) - 8] = 'd'; - filename_usr[sizeof(filename_usr) - 6] = 'a'; - filename_std[sizeof(filename_std) - 6] = 'a'; - loadSkin(filename_usr, filename_std, sizeof(filename_usr) - 6, sizeof(filename_std) - 6, date_digits, 10, 16, 16, "date"); - - filename_usr[sizeof(filename_usr) - 8] = 'm'; - filename_std[sizeof(filename_std) - 8] = 'm'; - filename_usr[sizeof(filename_usr) - 6] = 'a'; - filename_std[sizeof(filename_std) - 6] = 'a'; - loadSkin(filename_usr, filename_std, sizeof(filename_usr) - 6, sizeof(filename_std) - 6, months, 12, 32, 16, "month"); -} - -void RenderSign(CLCDDisplay* const display, int sign, int x_position, int y_position) -{ - int x, y; - - for(y = 0; y < 4; y++) - { - for(x = 0; x < 4; x++) - { - display->draw_point(x_position + x, y_position + y, signs[x + y*4 + sign*sizeof(signs)/3] ? CLCDDisplay::PIXEL_ON : CLCDDisplay::PIXEL_OFF); - } - } -} - -void RenderTimeDigit(CLCDDisplay* const display, int digit, int position) -{ - int x, y; - - for(y = 0; y < 32; y++) - { - for(x = 0; x < 24; x++) - { - display->draw_point(position + x, 5 + y, time_digits[x + y*24 + digit*sizeof(time_digits)/10] ? CLCDDisplay::PIXEL_ON : CLCDDisplay::PIXEL_OFF); - } - } -} - -void RenderDay(CLCDDisplay* const display, int day) -{ - int x, y; - - for(y = 0; y < 16; y++) - { - for(x = 0; x < 24; x++) - { - display->draw_point(5 + x, 43 + y, days[x + y*24 + day*sizeof(days)/7] ? CLCDDisplay::PIXEL_ON : CLCDDisplay::PIXEL_OFF); - } - } -} - -void RenderDateDigit(CLCDDisplay* const display, int digit, int position) -{ - int x, y; - - for(y = 0; y < 16; y++) - { - for(x = 0; x < 16; x++) - { - display->draw_point(position + x, 43 + y, date_digits[x + y*16 + digit*sizeof(date_digits)/10] ? CLCDDisplay::PIXEL_ON : CLCDDisplay::PIXEL_OFF); - } - } -} - -void RenderMonth(CLCDDisplay* const display, int month) -{ - int x, y; - - for(y = 0; y < 16; y++) - { - for(x = 0; x < 32; x++) - { - display->draw_point(83 + x, 43 + y, months[x + y*32 + month*sizeof(months)/12] ? CLCDDisplay::PIXEL_ON : CLCDDisplay::PIXEL_OFF); - } - } -} - -void ShowNewClock(CLCDDisplay* display, int hour, int minute, int second, int day, int date, int month, bool rec) -{ - RenderTimeDigit(display, hour/10, 5); - RenderTimeDigit(display, hour%10, 32); - RenderTimeDigit(display, minute/10, 64); - RenderTimeDigit(display, minute%10, 91); - - /* blink the date if recording */ - if (!rec || !(second & 1)) - { - RenderDay(display, day); - - RenderDateDigit(display, date/10, 43); - RenderDateDigit(display, date%10, 60); - - RenderMonth(display, month); - - RenderSign(display, 1, 31, 57); - RenderSign(display, 2, 78, 56); - } - if (second % 2 == 0) - { - RenderSign(display, 0, 58, 15); - RenderSign(display, 0, 58, 23); - } -} diff --git a/src/driver/newclock.h b/src/driver/newclock.h deleted file mode 100644 index 08e96c932..000000000 --- a/src/driver/newclock.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - LCD-Daemon - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#include - -void InitNewClock(); -void ShowNewClock(CLCDDisplay* display, int hour, int minute, int second, int day, int date, int month, bool record = false); diff --git a/src/driver/pig.cpp b/src/driver/pig.cpp deleted file mode 100644 index f9c324892..000000000 --- a/src/driver/pig.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - - - -#include -#include -#include -#include -#include -#include -#include - -#include "pig.h" - - - - -// Video4Linux API for PIG -// - -// -// -- Picture in Graphics Control -// -- This module is a Class to provide a PIG abstraction layer -// -- -// -- 2002-11 rasc -// -- 2003-06 rasc V4L Api -// - - - -// -// -- Constructor -// - -CPIG::CPIG() -{ - fd = -1; - status = CLOSED; -} - - -CPIG::CPIG(int pig_nr) -{ - fd = -1; - status = CLOSED; - fd = pigopen (pig_nr); -} - - -CPIG::CPIG(int pig_nr, int x, int y, int w, int h) -{ - fd = -1; - status = CLOSED; - fd = pigopen (pig_nr); - set_coord (x,y, w,h); - -} - -CPIG::~CPIG() -{ - pigclose (); // cleanup anyway!! - -} - - -// -// -- open PIG #nr -// -- return >=0: ok -// - -int CPIG::pigopen (int pig_nr) -{ - - char *pigdevs[] = { - PIG_DEV "0" // PIG device 0 - // PIG_DEV "1", // PIG device 1 - // PIG_DEV "2", // PIG device ... - // PIG_DEV "3" - }; - - - if ( (pig_nr>0) || (pig_nr < (int)(sizeof (pigdevs)/sizeof(char *))) ) { - - if (fd < 0) { - fd = open( pigdevs[pig_nr], O_RDWR ); - if (fd >= 0) { - status = HIDE; - px = py = pw = ph = 0; - } - return fd; - } - - } - - return -1; -} - - -// -// -- close PIG -// - -void CPIG::pigclose () -{ - if (fd >=0 ) { - close (fd); - fd = -1; - status = CLOSED; - px = py = pw = ph = 0; - } - return; -} - - -// -// -- set PIG Position -// -- routines should be self explaining -// - -void CPIG::_set_window (int x, int y, int w, int h) -{ -#if 1 - // -- Modul interne Routine - struct v4l2_crop crop; - struct v4l2_format coord; -// int err; - - crop.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - err = ioctl(fd, VIDIOC_G_CROP, &crop); - - // take whole input frame - crop.c.left = 0; - crop.c.top = 0; - crop.c.width = 720; - crop.c.height = 576; - /*err =*/ ioctl(fd, VIDIOC_S_CROP, &crop); - - coord.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - /*err = */ioctl(fd, VIDIOC_G_FMT, &coord); - - // fit into small window - coord.fmt.win.w.left = x; - coord.fmt.win.w.top = y; - coord.fmt.win.w.width = w; - coord.fmt.win.w.height = h; - - err = ioctl(fd, VIDIOC_S_FMT, &coord); -#if 0 // old - struct v4l2_format coord; - int err; - - ioctl(fd, VIDIOC_G_FMT, &coord); - coord.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; - - coord.fmt.win.w.left = x; - coord.fmt.win.w.top = y; - coord.fmt.win.w.width = w; - coord.fmt.win.w.height = h; - - int pigmode = 0; - /*err =*/ ioctl(fd, VIDIOC_OVERLAY, &pigmode); -printf("pig::window VIDIOC_OVERLAY %d\n", err); - - err = ioctl(fd, VIDIOC_S_FMT, &coord); -printf("pig::window VIDIOC_S_FMT %d\n", err); -#endif -#else - avia_pig_set_pos(fd,x,y); - avia_pig_set_size(fd, w, h); - avia_pig_set_stack(fd,2); -#endif -} - - -void CPIG::set_coord (int x, int y, int w, int h) -{ - - if (( x != px ) || ( y != py )) { - px = x; - py = y; - pw = w; - ph = h; - _set_window (px,py,pw,ph); - } - -} - - -void CPIG::set_xy (int x, int y) -{ - - if (( x != px ) || ( y != py )) { - px = x; - py = y; - _set_window (px,py,pw,ph); - } - -} - - -void CPIG::set_size (int w, int h) -{ - - if (( w != pw ) || ( h != ph )) { - pw = w; - ph = h; - _set_window (px,py,pw,ph); - } - -} - - -// $$$ ???? what this for? - -//void CPIG::set_source (int x, int y) -//{ -// -// if (fd >= 0) { -// -// if (( x != px ) || ( y != py )) { -// // avia_pig_set_source(fd,x,y); -// } -// -// } -// -//} - - -// -// -- routine set's stack position of PIG on display -// - -//void CPIG::set_stackpos (int pos) -// -//{ -// if (fd >= 0) { -// avia_pig_set_stack(fd,pos); -// stackpos = pos; -// } -//} - - -// -// -- Show PIG or hide PIG -// - -void CPIG::show (int x, int y, int w, int h) -{ - set_coord (x,y, w,h); - show (); -} - -void CPIG::show (void) -{ - if ( fd >= 0 ) { -#if 1 - int pigmode = 1; - int err; - err = ioctl(fd, VIDIOC_OVERLAY, &pigmode); -//printf("pig::show err %d\n", err); -#else - avia_pig_show(fd); -#endif - status = SHOW; - } -} - -void CPIG::hide (void) -{ - if ( fd >= 0 ) { -#if 1 - int pigmode = 0; - int err; - err = ioctl(fd, VIDIOC_OVERLAY, &pigmode); -#else - avia_pig_hide(fd); -#endif - status = HIDE; - } -} - - -CPIG::PigStatus CPIG::getStatus(void) -{ - return status; - -} - - - - - -// -// ToDo's: -// -- Capability unavail check/status -// -- Cropping for resizing (possible zoom/scaling?) -// -- Capturing -// - diff --git a/src/driver/pig.h b/src/driver/pig.h deleted file mode 100644 index c88cda236..000000000 --- a/src/driver/pig.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - - -#ifndef __PIG_CONTROL__ -#define __PIG_CONTROL__ -#include -using namespace std; - - -// -// -- Picture in Graphics Control -// -- 2002-11 rasc -// -- 2003-06 rasc V4L API -// - - - -#if 1 -#include - -#define PIG_DEV "/dev/v4l/video" // PigNr will be appended! -#else -#include -#define PIG_DEV "/dev/dbox/pig" -#endif - - -class CPIG -{ - public: - CPIG (); - CPIG (int pig_nr); // incl. open - CPIG (int pig_nr, int x, int y, int w, int h); // open + set_coord - ~CPIG (); - - int pigopen (int pig_nr); - void pigclose (void); - void set_coord (int x, int y, int w, int h); - void set_xy (int x, int y); - void set_size (int w, int h); -// void set_source(int x, int y); -// void set_stackpos (int pos); - void show (void); - void show (int x, int y, int w, int h); - void hide (void); - - enum PigStatus { CLOSED, HIDE, SHOW }; - PigStatus getStatus(void); - - private: - void _set_window (int x, int y, int w, int h); - - int fd; // io descriptor - int px, py, pw, ph; // pig frame - int stackpos; // Order (Framebuffer, PIGs) - PigStatus status; // on display? - - -}; - - -#endif - - diff --git a/src/driver/rfmod.cpp b/src/driver/rfmod.cpp deleted file mode 100644 index 5cbe6f071..000000000 --- a/src/driver/rfmod.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include - -#define RFMOD_DEV "/dev/rfmod0" -#define IOCTL_SET_CHANNEL 0 -#define IOCTL_SET_TESTMODE 1 -#define IOCTL_SET_SOUNDENABLE 2 -#define IOCTL_SET_SOUNDSUBCARRIER 3 -#define IOCTL_SET_FINETUNE 4 -#define IOCTL_SET_STANDBY 5 - -#define C0 3 -#define C1 2 -#define FL 1 -#define FM 0 - -RFmod::RFmod() -{ - rfmodfd=open(RFMOD_DEV, O_RDWR); -} - -void RFmod::init() -{ - soundsubcarrier=g_settings.rf_subcarrier; - soundenable=g_settings.rf_soundenable; - channel = g_settings.rf_channel; - finetune = g_settings.rf_finetune; - standby = g_settings.rf_standby; - - setSoundSubCarrier(soundsubcarrier); - setSoundEnable(soundenable); - setChannel(channel); - setFinetune(finetune); - setStandby(standby); - setTestPattern(0); -} - -RFmod::~RFmod() -{ - if (rfmodfd>=0) - close(rfmodfd); -} - -int RFmod::setSoundEnable(int val) -{ - soundenable = val; -//printf("RF sound: %d\n", val); - if(rfmodfd > 0) - ioctl(rfmodfd,IOCTL_SET_SOUNDENABLE,&soundenable); - - return 0; -} - -int RFmod::setStandby(int val) -{ - standby = val; -//printf("RF standby: %d\n", val); - - if(rfmodfd > 0) - ioctl(rfmodfd,IOCTL_SET_STANDBY,&standby); - - return 0; -} - -int RFmod::setChannel(int val) -{ - channel = val; -//printf("RF channel: %d\n", val); - - if(rfmodfd > 0) - ioctl(rfmodfd,IOCTL_SET_CHANNEL,&channel); - - return 0; -} - -int RFmod::setFinetune(int val) -{ - finetune = val; -//printf("RF finetune: %d\n", val); - - if(rfmodfd > 0) - ioctl(rfmodfd,IOCTL_SET_FINETUNE,&finetune); - - return 0; -} - -int RFmod::setTestPattern(int val) -{ -//printf("RF test: %d\n", val); - if(rfmodfd > 0) - ioctl(rfmodfd,IOCTL_SET_TESTMODE,&val); - - return 0; -} - - -int RFmod::setSoundSubCarrier(int freq) //freq in KHz -{ -//printf("RF carrier: %d\n", freq); - soundsubcarrier=freq; -/* - switch(freq) - { - case 4500: - sfd=0; - break; - case 5500: - sfd=1; - break; - case 6000: - sfd=2; - break; - case 6500: - sfd=3; - break; - default: - return -1; - } -*/ - if(rfmodfd > 0) - ioctl(rfmodfd,IOCTL_SET_SOUNDSUBCARRIER,&soundsubcarrier); - - return 0; -} diff --git a/src/driver/rfmod.h b/src/driver/rfmod.h deleted file mode 100644 index 31b669077..000000000 --- a/src/driver/rfmod.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __erfmod_h -#define __erfmod_h - - -class RFmod -{ - int channel,soundsubcarrier,soundenable,finetune,standby; - -public: - RFmod(); - ~RFmod(); - - int rfmodfd; - void init(); - - int setChannel(int channel); - int setSoundSubCarrier(int val); - int setSoundEnable(int val); - int setStandby(int val); - int setFinetune(int val); - int setTestPattern(int val); -}; -#endif diff --git a/src/driver/showframe.c b/src/driver/showframe.c deleted file mode 100644 index a00afd1b0..000000000 --- a/src/driver/showframe.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define VIDEO_DEV "/dev/dvb/card0/video0" -#define VIDEO_SET_AUTOFLUSH _IOW('o', 2, int) - -void showframe(char * fname) -{ - int file, size; - char *buffer; - - file=open(fname, O_RDONLY); - if (file < 0) - return; - size=lseek(file, 0, SEEK_END); - lseek(file, 0, SEEK_SET); - if (size < 0) - { - close(file); - return; - } - buffer = malloc(size); - read(file, buffer, size); - close(file); - displayIFrame(buffer, size); - free(buffer); - return; -} -static int displayIFrame(const char *frame, int len) -{ - int fdv, fdvideo, i; - fdv=open("/dev/video", O_WRONLY); - if (fdv < 0) { - printf("cant open /dev/video\n"); - return -1; - } - - fdvideo = open(VIDEO_DEV, O_RDWR); - if (fdvideo < 0) { - colose(fdv);//Resource leak: fdv - printf("cant open %s\n", VIDEO_DEV); - return -1; - } - if (ioctl(fdvideo, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY ) <0) - printf("VIDEO_SELECT_SOURCE failed \n"); - if (ioctl(fdvideo, VIDEO_CLEAR_BUFFER) <0 ) - printf("VIDEO_CLEAR_BUFFER failed \n"); - if (ioctl(fdvideo, VIDEO_PLAY) < 0 ) - printf("VIDEO_PLAY failed\n"); - - for (i=0; i < 2; i++ ) - write(fdv, frame, len); - - unsigned char buf[128]; - memset(&buf, 0, 128); - write(fdv, buf, 128); - - if ( ioctl(fdv, VIDEO_SET_AUTOFLUSH, 0) < 0 ) - printf("VIDEO_SET_AUTOFLUSH off failed\n"); - - if (ioctl(fdvideo, VIDEO_SET_BLANK, 0) < 0 ) - printf("VIDEO_SET_BLANK failed\n"); - - close(fdvideo); - if ( ioctl(fdv, VIDEO_SET_AUTOFLUSH, 1) < 0 ) - printf("VIDEO_SET_AUTOFLUSH on failed\n"); - - close(fdv); - return 0; -} - diff --git a/src/driver/slotbuffer.c b/src/driver/slotbuffer.c deleted file mode 100644 index 9b50e6875..000000000 --- a/src/driver/slotbuffer.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/slotbuffer.c,v 1.1 2004/06/03 09:51:54 thegoodguy Exp $ - * - * (C) 2004 by thegoodguy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* Note: this slotbuffer "wastes" one slot */ - -#include "slotbuffer.h" -#include - -slotbuffer_t * slotbuffer_construct(const size_t size) -{ - slotbuffer_t * slotbuffer; - - slotbuffer = malloc(sizeof(slotbuffer_t)); - - slotbuffer->buffer = malloc(size); - slotbuffer->size = size; - slotbuffer->read_pointer = 0; - slotbuffer->write_pointer = 0; - - return slotbuffer; -} - -void slotbuffer_destruct(slotbuffer_t * const slotbuffer) -{ - free(slotbuffer->buffer); - free(slotbuffer); -} - -size_t slotbuffer_remaining_read_space(slotbuffer_t * const slotbuffer) -{ - ssize_t delta; - - delta = slotbuffer->write_pointer; - delta -= slotbuffer->read_pointer; - - return (delta >= 0) ? (size_t)delta : (size_t)(delta + slotbuffer->size); -} - -size_t slotbuffer_remaining_write_space(slotbuffer_t * const slotbuffer) -{ - ssize_t delta; - - delta = slotbuffer->read_pointer; - delta -= slotbuffer->write_pointer; - - return ((delta > 0) ? (size_t)delta : (size_t)(delta + slotbuffer->size)) - 1; -} - -size_t slotbuffer_remaining_continuous_read_space(slotbuffer_t * const slotbuffer) -{ - ssize_t delta; - size_t read_pointer; - - delta = slotbuffer->write_pointer; - read_pointer = slotbuffer->read_pointer; - delta -= read_pointer; - - return (delta >= 0) ? (size_t)delta : (size_t)(slotbuffer->size - read_pointer); -} - -size_t slotbuffer_remaining_continuous_write_space(slotbuffer_t * const slotbuffer) -{ - ssize_t delta; - size_t write_pointer; - - delta = slotbuffer->read_pointer; - - if (delta == 0) - return (slotbuffer->size - slotbuffer->write_pointer - 1); - - write_pointer = slotbuffer->write_pointer; - delta -= write_pointer; - - return (delta > 0) ? (size_t)(delta - 1) : (size_t)(slotbuffer->size - write_pointer); -} - -void slotbuffer_advance_read_pointer(slotbuffer_t * const slotbuffer, const size_t delta) -{ - slotbuffer->read_pointer += delta; - if (slotbuffer->read_pointer >= slotbuffer->size) - slotbuffer->read_pointer = 0; -} - -void slotbuffer_advance_write_pointer(slotbuffer_t * const slotbuffer, const size_t delta) -{ - slotbuffer->write_pointer += delta; - if (slotbuffer->write_pointer >= slotbuffer->size) - slotbuffer->write_pointer = 0; -} diff --git a/src/driver/slotbuffer.h b/src/driver/slotbuffer.h deleted file mode 100644 index 07266f62d..000000000 --- a/src/driver/slotbuffer.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __slotbuffer_h__ -#define __slotbuffer_h__ - -/* - * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/src/driver/slotbuffer.h,v 1.1 2004/06/03 09:51:54 thegoodguy Exp $ - * - * (C) 2004 by thegoodguy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include - -typedef struct -{ - unsigned char * buffer; - size_t size; - volatile size_t read_pointer; - volatile size_t write_pointer; -} slotbuffer_t; - -slotbuffer_t * slotbuffer_construct (size_t const size ); -void slotbuffer_destruct (slotbuffer_t * const slotbuffer ); -size_t slotbuffer_remaining_read_space (slotbuffer_t * const slotbuffer ); -size_t slotbuffer_remaining_write_space (slotbuffer_t * const slotbuffer ); -size_t slotbuffer_remaining_continuous_read_space (slotbuffer_t * const slotbuffer ); -size_t slotbuffer_remaining_continuous_write_space(slotbuffer_t * const slotbuffer ); -void slotbuffer_advance_read_pointer (slotbuffer_t * const slotbuffer, size_t const delta); -void slotbuffer_advance_write_pointer (slotbuffer_t * const slotbuffer, size_t const delta); - -#endif diff --git a/src/driver/stacktrace.h b/src/driver/stacktrace.h deleted file mode 100644 index 49a5e5c0a..000000000 --- a/src/driver/stacktrace.h +++ /dev/null @@ -1,93 +0,0 @@ -// stacktrace.h (c) 2008, Timo Bingmann from http://idlebox.net/ -// published under the WTFPL v2.0 - -#ifndef _STACKTRACE_H_ -#define _STACKTRACE_H_ - -#include -#include -#include -#include - -/** Print a demangled stack backtrace of the caller function to FILE* out. */ -static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63) -{ - fprintf(out, "stack trace:\n"); - - // storage array for stack trace address data - void* addrlist[max_frames+1]; - - // retrieve current stack addresses - int addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void*)); - - if (addrlen == 0) { - fprintf(out, " \n"); - return; - } - - // resolve addresses into strings containing "filename(function+address)", - // this array must be free()-ed - char** symbollist = backtrace_symbols(addrlist, addrlen); - - // allocate string which will be filled with the demangled function name - size_t funcnamesize = 256; - char* funcname = (char*)malloc(funcnamesize); - - // iterate over the returned symbol lines. skip the first, it is the - // address of this function. - for (int i = 1; i < addrlen; i++) - { - char *begin_name = 0, *begin_offset = 0, *end_offset = 0; - - // find parentheses and +address offset surrounding the mangled name: - // ./module(function+0x15c) [0x8048a6d] - for (char *p = symbollist[i]; *p; ++p) - { - if (*p == '(') - begin_name = p; - else if (*p == '+') - begin_offset = p; - else if (*p == ')' && begin_offset) { - end_offset = p; - break; - } - } - - if (begin_name && begin_offset && end_offset - && begin_name < begin_offset) - { - *begin_name++ = '\0'; - *begin_offset++ = '\0'; - *end_offset = '\0'; - - // mangled name is now in [begin_name, begin_offset) and caller - // offset in [begin_offset, end_offset). now apply - // __cxa_demangle(): - - int status; - char* ret = abi::__cxa_demangle(begin_name, - funcname, &funcnamesize, &status); - if (status == 0) { - funcname = ret; // use possibly realloc()-ed string - fprintf(out, " %s : %s+%s\n", - symbollist[i], funcname, begin_offset); - } - else { - // demangling failed. Output function name as a C function with - // no arguments. - fprintf(out, " %s : %s()+%s\n", - symbollist[i], begin_name, begin_offset); - } - } - else - { - // couldn't parse the line? print the whole line. - fprintf(out, " %s\n", symbollist[i]); - } - } - - free(funcname); - free(symbollist); -} - -#endif // _STACKTRACE_H_ diff --git a/src/driver/stream2file.cpp b/src/driver/stream2file.cpp deleted file mode 100644 index c6a836c44..000000000 --- a/src/driver/stream2file.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - * $Id: stream2file.cpp,v 1.19 2005/01/12 20:40:22 chakazulu Exp $ - * - * streaming to file/disc - * - * Copyright (C) 2004 Axel Buehning , - * thegoodguy - * - * based on code which is - * Copyright (C) 2001 TripleDES - * Copyright (C) 2000, 2001 Marcus Metzler - * Copyright (C) 2002 Andreas Oberritter - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * Or, point your browser to http://www.gnu.org/copyleft/gpl.html - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if HAVE_COOL_HARDWARE -#include -#include -#endif -#if HAVE_TRIPLEDRAGON -#include -#include -#endif -#include -#include -#include - -extern "C" { -#include -} - -static cRecord * record = NULL; -extern CZapitChannel *g_current_channel; -extern CCam *cam0; - -extern bool autoshift; -extern bool autoshift_delete; - -#define MAXPIDS 64 -#define FILENAMEBUFFERSIZE 1024 - -static stream2file_status_t exit_flag = STREAM2FILE_STATUS_IDLE; - -char rec_filename[FILENAMEBUFFERSIZE]; - -stream2file_error_msg_t start_recording(const char * const filename, - const char * const info, const unsigned short vpid, const unsigned short * const pids, - const unsigned int numpids) -{ - int fd; - char buf[FILENAMEBUFFERSIZE]; - struct statfs s; - - if(autoshift) - sprintf(rec_filename, "%s_temp", filename); - else - sprintf(rec_filename, "%s", filename); - - // write stream information (should wakeup the disk from standby, too) - sprintf(buf, "%s.xml", rec_filename); - - char * dir = strdup(buf); - int ret = statfs(dirname(dir), &s); - free(dir); - if((ret != 0) || (s.f_type == 0x72b6) || (s.f_type == 0x24051905)) { - return STREAM2FILE_INVALID_DIRECTORY; - } - if ((fd = open(buf, O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) { - write(fd, info, strlen(info)); - fdatasync(fd); - close(fd); - } else { - return STREAM2FILE_INVALID_DIRECTORY; - } - - exit_flag = STREAM2FILE_STATUS_RUNNING; - - sprintf(buf, "%s.ts", rec_filename); - - printf("Record start: file %s vpid %x apid %x\n", buf, vpid, pids[0]); - - fd = open(buf, O_CREAT | O_RDWR | O_LARGEFILE | O_TRUNC , S_IRWXO | S_IRWXG | S_IRWXU); - if(fd < 0) { - perror(buf); - return STREAM2FILE_INVALID_DIRECTORY; - } - genpsi(fd); - - if(!record) - record = new cRecord(2); - - record->Open(numpids); - - if(!record->Start(fd, (unsigned short ) vpid, (unsigned short *) pids, numpids)) { - record->Stop(); - delete record; - record = NULL; - return STREAM2FILE_INVALID_DIRECTORY; - } - if(g_current_channel) { - cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() | DEMUX_DECODE_2 /*5*/, true); // demux 0 + 2, update - - int len; - unsigned char * pmt = g_current_channel->getRawPmt(len); - cCA * ca = cCA::GetInstance(); - ca->SendPMT(DEMUX_SOURCE_2, pmt, len); - } - - CVFD::getInstance()->ShowIcon(VFD_ICON_CAM1, true); - - return STREAM2FILE_OK; -} - -stream2file_error_msg_t stop_recording(const char * const info) -{ - char buf[FILENAMEBUFFERSIZE]; - char buf1[FILENAMEBUFFERSIZE]; - int fd; - stream2file_error_msg_t ret = STREAM2FILE_RECORDING_THREADS_FAILED; - - //if(!autoshift || autoshift_delete) - { - sprintf(buf, "%s.xml", rec_filename); - if ((fd = open(buf, O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) { - write(fd, info, strlen(info)); - fdatasync(fd); - close(fd); - } - } - - if(record) { - record->Stop(); - delete record; - record = NULL; - } - - if (exit_flag == STREAM2FILE_STATUS_RUNNING) { - exit_flag = STREAM2FILE_STATUS_IDLE; - ret = STREAM2FILE_OK; - } - else - ret = STREAM2FILE_RECORDING_THREADS_FAILED; - - if((autoshift && g_settings.auto_delete) || autoshift_delete) { - sprintf(buf, "rm -f %s.ts &", rec_filename); - sprintf(buf1, "%s.xml", rec_filename); - autoshift_delete = false; - system(buf); - unlink(buf1); - } - CVFD::getInstance()->ShowIcon(VFD_ICON_CAM1, false); - - rec_filename[0] = 0; - return ret; -} - -stream2file_error_msg_t update_recording(const char * const info, const unsigned short vpid, - const unsigned short * const pids, const unsigned int numpids) -{ -// stream2file_error_msg_t ret; - char buf[FILENAMEBUFFERSIZE]; - int fd; - - sprintf(buf, "%s.xml", rec_filename); - if ((fd = open(buf, O_SYNC | O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) { - write(fd, info, strlen(info)); - fdatasync(fd); - close(fd); - } - if(record) - record->ChangePids((unsigned short) vpid, (unsigned short *) pids, numpids); - - if(g_current_channel) - cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() | DEMUX_DECODE_0 | DEMUX_DECODE_2, true); - - return STREAM2FILE_OK /*ret*/; -} diff --git a/src/driver/stream2file.h b/src/driver/stream2file.h deleted file mode 100644 index 059bca9d4..000000000 --- a/src/driver/stream2file.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $Id: stream2file.h,v 1.10 2005/01/12 20:40:22 chakazulu Exp $ - * - * (C) 2004 by thegoodguy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef __stream2file_h__ -#define __stream2file_h__ - -enum stream2file_error_msg_t -{ - STREAM2FILE_OK = 0, - STREAM2FILE_BUSY = -1, - STREAM2FILE_INVALID_DIRECTORY = -2, - STREAM2FILE_INVALID_PID = -3, - STREAM2FILE_PES_FILTER_FAILURE = -4, - STREAM2FILE_DVR_OPEN_FAILURE = -5, - STREAM2FILE_RECORDING_THREADS_FAILED = -6 -}; - -enum stream2file_status_t -{ - STREAM2FILE_STATUS_RUNNING = 0, - STREAM2FILE_STATUS_IDLE = 1, - STREAM2FILE_STATUS_BUFFER_OVERFLOW = -1, - STREAM2FILE_STATUS_WRITE_OPEN_FAILURE = -2, - STREAM2FILE_STATUS_WRITE_FAILURE = -3, - STREAM2FILE_STATUS_READ_FAILURE = -4 -}; - -struct stream2file_status2_t -{ - stream2file_status_t status; - char dir[100]; -}; - -stream2file_error_msg_t start_recording(const char * const filename, - const char * const info, - const unsigned short vpid, - const unsigned short * const apids, - const unsigned int numpids); -stream2file_error_msg_t stop_recording(const char * const info); -stream2file_error_msg_t update_recording(const char * const info, - const unsigned short vpid, - const unsigned short * const apids, - const unsigned int numpids); - -#endif diff --git a/src/driver/vcrcontrol.cpp b/src/driver/vcrcontrol.cpp deleted file mode 100644 index d0570cd82..000000000 --- a/src/driver/vcrcontrol.cpp +++ /dev/null @@ -1,963 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ -int was_record = 0; -extern bool autoshift; -extern bool autoshift_delete; - -#define SA struct sockaddr -#define SAI struct sockaddr_in -extern "C" { -#include -} - -extern t_channel_id rec_channel_id; - -static CVCRControl vcrControl; - -CVCRControl * CVCRControl::getInstance() -{ - return &vcrControl; -} - -//------------------------------------------------------------------------- -CVCRControl::CVCRControl() -{ - Device = NULL; -} - -//------------------------------------------------------------------------- -CVCRControl::~CVCRControl() -{ - unregisterDevice(); -} - -//------------------------------------------------------------------------- -void CVCRControl::unregisterDevice() -{ - if (Device) - { - delete Device; - Device = NULL; - } -} - -//------------------------------------------------------------------------- -void CVCRControl::registerDevice(CDevice * const device) -{ - unregisterDevice(); - - Device = device; - if(CNeutrinoApp::getInstance()->recordingstatus) - Device->deviceState = CMD_VCR_RECORD; -} - -//------------------------------------------------------------------------- -bool CVCRControl::Record(const CTimerd::RecordingInfo * const eventinfo) -{ - int mode = g_Zapit->isChannelTVChannel(eventinfo->channel_id) ? NeutrinoMessages::mode_tv : NeutrinoMessages::mode_radio; - - return Device->Record(eventinfo->channel_id, mode, eventinfo->epgID, eventinfo->epgTitle, eventinfo->apids, eventinfo->epg_starttime); -} - -MI_MOVIE_INFO * CVCRControl::GetMovieInfo(void) -{ - if(Device) - return Device->recMovieInfo; - return NULL; -} - -bool CVCRControl::GetPids(unsigned short *vpid, unsigned short *vtype, unsigned short *apid, unsigned short *atype, unsigned short * apidnum, unsigned short * apids, unsigned short * atypes) -{ - if(Device) { - if(vpid) - *vpid = Device->rec_vpid; - if(vtype) - *vtype = Device->rec_vtype; - if(apid) - *apid = Device->rec_currentapid; - if(atype) - *atype = Device->rec_currentac3; - if(apidnum) { - *apidnum = Device->rec_numpida; - for(int i = 0; i < Device->rec_numpida; i++) { - if(apids) - apids[i] = Device->rec_apids[i]; - if(atypes) - atypes[i] = Device->rec_ac3flags[i]; - } - } - return true; - } - return false; -} - -//------------------------------------------------------------------------- -void CVCRControl::CDevice::getAPIDs(const unsigned char _apidmode, APIDList & apid_list) -{ - unsigned char apidmode = _apidmode; - - if (apidmode == TIMERD_APIDS_CONF) - apidmode = g_settings.recording_audio_pids_default; - - apid_list.clear(); - //CZapitClient::responseGetPIDs allpids; - g_Zapit->getPIDS(allpids); - - // assume smallest apid ist std apid - if (apidmode & TIMERD_APIDS_STD) { - uint32_t apid_min=UINT_MAX; - uint32_t apid_min_idx=0; - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if (allpids.APIDs[i].pid < apid_min && !allpids.APIDs[i].is_ac3) { - apid_min = allpids.APIDs[i].pid; - apid_min_idx = i; - } - } - if (apid_min != UINT_MAX) { - APIDDesc a = {apid_min, apid_min_idx, false}; - apid_list.push_back(a); - } - } - if (apidmode & TIMERD_APIDS_ALT) { - uint32_t apid_min=UINT_MAX; - uint32_t apid_min_idx=0; - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if (allpids.APIDs[i].pid < apid_min && !allpids.APIDs[i].is_ac3) { - apid_min = allpids.APIDs[i].pid; - apid_min_idx = i; - } - } - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if (allpids.APIDs[i].pid != apid_min && !allpids.APIDs[i].is_ac3) { - APIDDesc a = {allpids.APIDs[i].pid, i, false}; - apid_list.push_back(a); - } - } - } - if (apidmode & TIMERD_APIDS_AC3) { - bool ac3_found=false; - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if (allpids.APIDs[i].is_ac3) { - APIDDesc a = {allpids.APIDs[i].pid, i, true}; - apid_list.push_back(a); - ac3_found=true; - } - } - // add non ac3 apid if ac3 not found - if (!(apidmode & TIMERD_APIDS_STD) && !ac3_found) { - uint32_t apid_min=UINT_MAX; - uint32_t apid_min_idx=0; - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if (allpids.APIDs[i].pid < apid_min && !allpids.APIDs[i].is_ac3) { - apid_min = allpids.APIDs[i].pid; - apid_min_idx = i; - } - } - if (apid_min != UINT_MAX) { - APIDDesc a = {apid_min, apid_min_idx, false}; - apid_list.push_back(a); - } - } - } - // no apid selected use standard - if (apid_list.empty() && !allpids.APIDs.empty()) { - uint32_t apid_min=UINT_MAX; - uint32_t apid_min_idx=0; - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if (allpids.APIDs[i].pid < apid_min && !allpids.APIDs[i].is_ac3) { - apid_min = allpids.APIDs[i].pid; - apid_min_idx = i; - } - } - if (apid_min != UINT_MAX) { - APIDDesc a = {apid_min, apid_min_idx, false}; - apid_list.push_back(a); - } - for(APIDList::iterator it = apid_list.begin(); it != apid_list.end(); ++it) - printf("Record APID 0x%X %d\n",it->apid, it->ac3); - - } -} - -//------------------------------------------------------------------------- -bool CVCRControl::CVCRDevice::Stop() -{ - deviceState = CMD_VCR_STOP; - - if(last_mode != NeutrinoMessages::mode_scart) - { - g_RCInput->postMsg( NeutrinoMessages::VCR_OFF, 0 ); - g_RCInput->postMsg( NeutrinoMessages::CHANGEMODE , last_mode); - } - return true; -} - -//------------------------------------------------------------------------- -bool CVCRControl::CVCRDevice::Record(const t_channel_id channel_id, int mode, const event_id_t epgid, const std::string& /*epgTitle*/, unsigned char apidmode, const time_t /*epg_time*/) -{ - printf("Record channel_id: " PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS " epg: %llx, apidmode 0x%X mode \n", - channel_id, epgid, apidmode); - - // leave menu (if in any) - g_RCInput->postMsg( CRCInput::RC_timeout, 0 ); - - last_mode = CNeutrinoApp::getInstance()->getMode(); - if(mode != last_mode) - CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , mode | NeutrinoMessages::norezap ); - - if(channel_id != 0) { - if(g_Zapit->getCurrentServiceID() != channel_id) - g_Zapit->zapTo_serviceID(channel_id); - } - if(! (apidmode & TIMERD_APIDS_STD)) { - APIDList apid_list; - getAPIDs(apidmode,apid_list); - if(!apid_list.empty()) { - if(!apid_list.begin()->ac3) - g_Zapit->setAudioChannel(apid_list.begin()->index); - else - g_Zapit->setAudioChannel(0); - } - else - g_Zapit->setAudioChannel(0); - } - else - g_Zapit->setAudioChannel(0); - - if(SwitchToScart) { - // Auf Scart schalten - CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::VCR_ON, 0 ); - // Das ganze nochmal in die queue, da obiges RC_timeout erst in der naechsten ev. loop ausgeführt wird - // und dann das menu widget das display falsch rücksetzt - g_RCInput->postMsg( NeutrinoMessages::VCR_ON, 0 ); - } - - deviceState = CMD_VCR_RECORD; - - return true; -} - -//------------------------------------------------------------------------- -void CVCRControl::CFileAndServerDevice::RestoreNeutrino(void) -{ -//printf("RestoreNeutrino\n");fflush(stdout); - /* after this zapit send EVT_RECORDMODE_DEACTIVATED, so neutrino getting NeutrinoMessages::EVT_RECORDMODE */ - g_Zapit->setRecordMode( false ); - if (!g_Zapit->isPlayBackActive() && (CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_standby)) - g_Zapit->startPlayBack(); - // alten mode wieder herstellen (ausser wen zwischenzeitlich auf oder aus sb geschalten wurde) - if(CNeutrinoApp::getInstance()->getMode() != last_mode && - CNeutrinoApp::getInstance()->getMode() != NeutrinoMessages::mode_standby && - last_mode != NeutrinoMessages::mode_standby) - if(!autoshift) - g_RCInput->postMsg( NeutrinoMessages::CHANGEMODE , last_mode); - - if(last_mode == NeutrinoMessages::mode_standby && - CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby ) - { - //Wenn vorher und jetzt standby, dann die zapit wieder auf sb schalten - //g_Zapit->setStandby(true); - //was_record = 1; - } - if((last_mode != NeutrinoMessages::mode_standby) && StopSectionsd) - g_Sectionsd->setPauseScanning(false); -} - -void CVCRControl::CFileAndServerDevice::CutBackNeutrino(const t_channel_id channel_id, const int mode) -{ - rec_channel_id = channel_id; -//printf("CutBackNeutrino\n");fflush(stdout); - g_Zapit->setStandby(false); - last_mode = CNeutrinoApp::getInstance()->getMode(); - if(last_mode == NeutrinoMessages::mode_standby) - was_record = 1; - if (channel_id != 0) { - if (mode != last_mode && (last_mode != NeutrinoMessages::mode_standby || mode != CNeutrinoApp::getInstance()->getLastMode())) { - CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , mode | NeutrinoMessages::norezap ); - // Wenn wir im Standby waren, dann brauchen wir fürs streamen nicht aufwachen... - if(last_mode == NeutrinoMessages::mode_standby) - CNeutrinoApp::getInstance()->handleMsg( NeutrinoMessages::CHANGEMODE , NeutrinoMessages::mode_standby); - } - if(g_Zapit->getCurrentServiceID() != channel_id) { - g_Zapit->zapTo_serviceID(channel_id); - } - } - if(StopSectionsd) // wenn sectionsd gestoppt werden soll - g_Sectionsd->setPauseScanning(true); // sectionsd stoppen - - /* after this zapit send EVT_RECORDMODE_ACTIVATED, so neutrino getting NeutrinoMessages::EVT_RECORDMODE */ - g_Zapit->setRecordMode( true ); - if((last_mode == NeutrinoMessages::mode_standby) || (StopPlayBack && g_Zapit->isPlayBackActive())) - g_Zapit->stopPlayBack(); -} - -bool sectionsd_getEPGidShort(event_id_t epgID, CShortEPGData * epgdata); -bool sectionsd_getEPGid(const event_id_t epgID, const time_t startzeit, CEPGData * epgdata); - -std::string CVCRControl::CFileAndServerDevice::getCommandString(const CVCRCommand command, const t_channel_id channel_id, const event_id_t epgid, const std::string& epgTitle, unsigned char apidmode) -{ - char tmp[40]; - std::string apids_selected; - const char * extCommand; - std::string info1, info2; - - std::string extMessage = "\n\n\n\t\n" - "\t\t"; - - CZapitClient::responseGetPIDs pids; - g_Zapit->getPIDS (pids); - CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo (); - - APIDList apid_list; - getAPIDs(apidmode,apid_list); - apids_selected=""; - for(APIDList::iterator it = apid_list.begin(); it != apid_list.end(); ++it) - { - if(it != apid_list.begin()) - apids_selected += " "; - sprintf(tmp, "%u", it->apid); - apids_selected += tmp; - } - - std::string tmpstring = g_Zapit->getChannelName(channel_id); - if (tmpstring.empty()) - extMessage += "unknown"; - else - extMessage += ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); - - extMessage += "\n\t\t"; - - tmpstring = "not available"; - if (epgid != 0) - { - CShortEPGData epgdata; - //if (g_Sectionsd->getEPGidShort(epgid, &epgdata)) { - if(sectionsd_getEPGidShort(epgid, &epgdata)) { -//#warning fixme sectionsd should deliver data in UTF-8 format - tmpstring = epgdata.title; - info1 = epgdata.info1; - info2 = epgdata.info2; - } - } else if (!epgTitle.empty()) { - tmpstring = epgTitle; - } - extMessage += ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); - - extMessage += "\n\t\t"; - - sprintf(tmp, PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id); - extMessage += tmp; - - extMessage += "\n\t\t"; - extMessage += ZapitTools::UTF8_to_UTF8XML(info1.c_str()); - extMessage += "\n\t\t"; - extMessage += ZapitTools::UTF8_to_UTF8XML(info2.c_str()); - extMessage += "\n\t\t"; - sprintf(tmp, "%llu", epgid); - extMessage += tmp; - extMessage += "\n\t\t"; - sprintf(tmp, "%d", g_Zapit->getMode()); - extMessage += tmp; - extMessage += "\n\t\t"; - sprintf(tmp, "%u", si.vpid); - extMessage += tmp; - extMessage += "\n\t\t\n"; - // super hack :-), der einfachste weg an die apid descriptions ranzukommen - g_RemoteControl->current_PIDs = pids; - g_RemoteControl->processAPIDnames(); - - for(unsigned int i= 0; i< pids.APIDs.size(); i++) - { - extMessage += "\t\t\t\n" - "\t\t"; - sprintf(tmp, "%u", si.vtxtpid); - extMessage += tmp; - extMessage += - "\n" - "\t\n" - "\n"; - - return extMessage; -} - -bool CVCRControl::CFileDevice::Stop() -{ - std::string extMessage = " "; - time_t end_time = time(0); -//printf("[direct] Stop recording, recMovieInfo %lx\n", recMovieInfo); fflush(stdout); -//FIXME why not save info if shift ? - //if(!autoshift || autoshift_delete) - if(recMovieInfo && cMovieInfo) { - // recMovieInfo->length = (end_time - start_time) / 60; - recMovieInfo->length = (int) round((double) (end_time - start_time) / (double) 60); - cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo); - } - bool return_value = (::stop_recording(extMessage.c_str()) == STREAM2FILE_OK); - - RestoreNeutrino(); - - deviceState = CMD_VCR_STOP; - - if(recMovieInfo) { - recMovieInfo->audioPids.clear(); - delete recMovieInfo; - recMovieInfo = NULL; - } - if(cMovieInfo) { - delete cMovieInfo; - cMovieInfo = NULL; - } - - return return_value; -} - -bool CVCRControl::CFileDevice::Record(const t_channel_id channel_id, int mode, const event_id_t epgid, const std::string& epgTitle, unsigned char apidmode, const time_t epg_time) -{ - std::string ext_channel_name; - unsigned short apids[REC_MAX_PIDS]; - unsigned int numpids = 0; - unsigned int pos; - char filename[512]; // UTF-8 - - printf("Record channel_id: " PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS " epg: %llx, apidmode 0x%X mode %d\n", - channel_id, epgid, apidmode, mode); - - CutBackNeutrino(channel_id, mode); - - apids_mode = apidmode; - - CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo(); - - if (si.vpid != 0) - transfer_pids(si.vpid, si.vtype ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0); - - APIDList apid_list; - getAPIDs(apids_mode, apid_list); - - for(APIDList::iterator it = apid_list.begin(); it != apid_list.end(); ++it) { - apids[numpids++] = it->apid; - transfer_pids(it->apid, EN_TYPE_AUDIO, it->ac3 ? 1 : 0); - } -#if 0 // FIXME : why this needed ? - if(!apid_list.empty()) - g_Zapit->setAudioChannel(apid_list.begin()->index); -#endif -#if 0 - CZapitClient::responseGetPIDs allpids; - g_Zapit->getPIDS(allpids); -#endif - - if ((StreamVTxtPid) && (si.vtxtpid != 0)) { - apids[numpids++] = si.vtxtpid; - } - if ((StreamPmtPid) && (si.pmtpid != 0)) { - apids[numpids++] = si.pmtpid; - } - - // Create filename for recording - pos = Directory.size(); - strcpy(filename, Directory.c_str()); - - if ((pos == 0) || (filename[pos - 1] != '/')) { - filename[pos] = '/'; - pos++; - filename[pos] = '\0'; - } - pos = strlen(filename); -#if 0 - time_t t = time(NULL); - strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t)); - strcat(filename, "_"); - pos = strlen(filename); -#endif - ext_channel_name = g_Zapit->getChannelName(channel_id); - if (!(ext_channel_name.empty())) - { - strcpy(&(filename[pos]), UTF8_TO_FILESYSTEM_ENCODING(ext_channel_name.c_str())); - ZapitTools::replace_char(&filename[pos]); - - if (!autoshift && g_settings.recording_save_in_channeldir) { - struct stat statInfo; - int res = stat(filename,&statInfo); - if (res == -1) { - if (errno == ENOENT) { - res = safe_mkdir(filename); - if (res == 0) { - strcat(filename,"/"); - } else { - perror("[vcrcontrol] mkdir"); - } - - } else { - perror("[vcrcontrol] stat"); - } - } else { - // directory exists - strcat(filename,"/"); - } - - } else - strcat(filename, "_"); - } - - pos = strlen(filename); - if (g_settings.recording_epg_for_filename) { - if(epgid != 0) { - CShortEPGData epgdata; - //if (g_Sectionsd->getEPGidShort(epgid, &epgdata)) - if(sectionsd_getEPGidShort(epgid, &epgdata)) - { - if (!(epgdata.title.empty())) - { - strcpy(&(filename[pos]), epgdata.title.c_str()); - ZapitTools::replace_char(&filename[pos]); - } - } - } else if (!epgTitle.empty()) { - strcpy(&(filename[pos]), epgTitle.c_str()); - ZapitTools::replace_char(&filename[pos]); - } - } -#if 1 - pos = strlen(filename); - time_t t = time(NULL); - strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t)); - //pos = strlen(filename); -#endif - - start_time = time(0); - stream2file_error_msg_t error_msg = ::start_recording(filename, - getMovieInfoString(CMD_VCR_RECORD, channel_id, epgid, epgTitle, apid_list, epg_time).c_str(), - si.vpid, apids, numpids); - - if (error_msg == STREAM2FILE_OK) { - deviceState = CMD_VCR_RECORD; - return true; - } - else { - RestoreNeutrino(); - - printf("[vcrcontrol] stream2file error code: %d\n", error_msg); - //FIXME: Use better error message - DisplayErrorMessage(g_Locale->getText( - error_msg == STREAM2FILE_BUSY ? LOCALE_STREAMING_BUSY : - error_msg == STREAM2FILE_INVALID_DIRECTORY ? LOCALE_STREAMING_DIR_NOT_WRITABLE : - LOCALE_STREAMINGSERVER_NOCONNECT - )); // UTF-8 - - return false; - } -} - -bool CVCRControl::CFileDevice::Update(void) -{ - EPG_AUDIO_PIDS audio_pids; - std::string extMessage; - //unsigned short apids[REC_MAX_PIDS]; - //unsigned int numpids = 0; - APIDList apid_list; - APIDList::iterator it; - bool update = false; - - if(!recMovieInfo || !cMovieInfo) - return false; - - getAPIDs(apids_mode, apid_list); - CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo (); - - g_RemoteControl->current_PIDs = allpids; - g_RemoteControl->processAPIDnames(); - - for(it = apid_list.begin(); it != apid_list.end(); ++it) { - bool found = false; - for(unsigned int i = 0; i < rec_numpida; i++) { - if(rec_apids[i] == it->apid) { - found = true; - break; - } - } - if(!found) { - update = true; - printf("CVCRControl::CFileDevice::Update: apid %x not found in recording pids\n", it->apid); - for(unsigned int i = 0; i < allpids.APIDs.size(); i++) { - if(allpids.APIDs[i].pid == it->apid) { - audio_pids.epgAudioPid = allpids.APIDs[i].pid; - audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc); - audio_pids.atype = allpids.APIDs[i].is_ac3 ? 1 : allpids.APIDs[i].is_aac ? 5 : 0; - audio_pids.selected = (audio_pids.epgAudioPid == (int) rec_currentapid) ? 1 : 0; - recMovieInfo->audioPids.push_back(audio_pids); - - if(allpids.APIDs[i].is_ac3) - rec_ac3flags[rec_numpida] = 1; - if(allpids.APIDs[i].is_aac) - rec_ac3flags[rec_numpida] = 5; - - rec_apids[rec_numpida] = allpids.APIDs[i].pid; - if(rec_apids[rec_numpida] == rec_currentapid) - rec_currentac3 = allpids.APIDs[i].is_ac3 ? 1 : allpids.APIDs[i].is_aac ? 5 : 0; - rec_numpida++; - } - - } - } - } - if(!update) { - printf("CVCRControl::CFileDevice::Update: no update needed\n"); - return false; - } - - cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo); - /* neutrino check if vpid changed, so using 0 to disable vpid restart */ - ::update_recording(extMessage.c_str(), 0 /*si.vpid*/, rec_apids, rec_numpida); - - return true; -} - -bool sectionsd_getActualEPGServiceKey(const t_channel_id uniqueServiceKey, CEPGData * epgdata); - -void CVCRControl::Screenshot(const t_channel_id channel_id, char * fname) -{ - char filename[512]; // UTF-8 - char cmd[512]; - std::string channel_name; - CEPGData epgData; - event_id_t epgid = 0; - unsigned int pos; - - if(!fname) { - if(safe_mkdir((char *) "/hdd/screenshots/")) - return; - - strcpy(filename, "/hdd/screenshots/"); - - pos = strlen(filename); - channel_name = g_Zapit->getChannelName(channel_id); - if (!(channel_name.empty())) { - strcpy(&(filename[pos]), UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str())); - ZapitTools::replace_char(&filename[pos]); - strcat(filename, "_"); - } - pos = strlen(filename); - - //if (g_Sectionsd->getActualEPGServiceKey(channel_id&0xFFFFFFFFFFFFULL, &epgData)) - if(sectionsd_getActualEPGServiceKey(channel_id&0xFFFFFFFFFFFFULL, &epgData)) - {}; - epgid = epgData.eventID; - if(epgid != 0) { - CShortEPGData epgdata; - //if (g_Sectionsd->getEPGidShort(epgid, &epgdata)) { - if(sectionsd_getEPGidShort(epgid, &epgdata)) { - if (!(epgdata.title.empty())) { - strcpy(&(filename[pos]), epgdata.title.c_str()); - ZapitTools::replace_char(&filename[pos]); - } - } - } - pos = strlen(filename); - time_t t = time(NULL); - strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t)); - strcat(filename, ".bmp"); - } else - strcpy(filename, fname); - - sprintf(cmd, "grab -v %s", filename); -printf("Executing %s\n", cmd); - CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Saving screenshot.."); - hintBox->paint(); - system(cmd); - hintBox->hide(); - delete hintBox; -} - -//------------------------------------------------------------------------- -bool CVCRControl::CServerDevice::Stop() -{ - printf("Stop\n"); - - bool return_value = sendCommand(CMD_VCR_STOP); - RestoreNeutrino(); - - return return_value; -} - -//------------------------------------------------------------------------- -bool CVCRControl::CServerDevice::Record(const t_channel_id channel_id, int mode, const event_id_t epgid, const std::string& epgTitle, unsigned char apids, const time_t /*epg_time*/) -{ - printf("Record channel_id: " - PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " epg: %llx, apids 0x%X mode %d\n", - channel_id, - epgid, - apids, - mode); - - CutBackNeutrino(channel_id, mode); - if(!sendCommand(CMD_VCR_RECORD, channel_id, epgid, epgTitle, apids)) - { - RestoreNeutrino(); - - DisplayErrorMessage(g_Locale->getText(LOCALE_STREAMINGSERVER_NOCONNECT)); - - return false; - } - else { - //ext_channel_name = g_Zapit->getChannelName(channel_id); - return true; - } -} - - -//------------------------------------------------------------------------- -void CVCRControl::CServerDevice::serverDisconnect() -{ - close(sock_fd); -} - -//------------------------------------------------------------------------- -bool CVCRControl::CServerDevice::sendCommand(CVCRCommand command, const t_channel_id channel_id, const event_id_t epgid, const std::string& epgTitle, unsigned char apids) -{ - printf("Send command: %d channel_id: " - PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS - " epgid: %llx\n", - command, - channel_id, - epgid); - if(serverConnect()) - { - std::string extMessage = getCommandString(command, channel_id, epgid, epgTitle, apids); - - printf("sending to vcr-client:\n\n%s\n", extMessage.c_str()); - write(sock_fd, extMessage.c_str() , extMessage.length() ); - - serverDisconnect(); - - deviceState = command; - return true; - } - else - return false; - -} - -//------------------------------------------------------------------------- -bool CVCRControl::CServerDevice::serverConnect() -{ - - printf("connect to server: %s:%d\n",ServerAddress.c_str(),ServerPort); - - sock_fd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - SAI servaddr; - memset(&servaddr,0,sizeof(SAI)); - servaddr.sin_family=AF_INET; - servaddr.sin_port=htons(ServerPort); - inet_pton(AF_INET, ServerAddress.c_str(), &servaddr.sin_addr); - - - if(connect(sock_fd, (SA *)&servaddr, sizeof(servaddr))==-1) - { - perror("[cvcr] - cannot connect to streamingserver\n"); - return false; - } - - return true; -} - -//------------------------------------------------------------------------- -std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRCommand /*command*/, const t_channel_id channel_id, const event_id_t epgid, const std::string& epgTitle, APIDList apid_list, const time_t epg_time) -{ - std::string extMessage; - std::string info1, info2; - - if(!cMovieInfo) - cMovieInfo = new CMovieInfo(); - if(!recMovieInfo) - recMovieInfo = new MI_MOVIE_INFO(); - - cMovieInfo->clearMovieInfo(recMovieInfo); -#if 0 - CZapitClient::responseGetPIDs pids; - g_Zapit->getPIDS (pids); -#endif - CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo (); - - std::string tmpstring = g_Zapit->getChannelName(channel_id); - if (tmpstring.empty()) - recMovieInfo->epgChannel = "unknown"; - else - recMovieInfo->epgChannel = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); - - tmpstring = "not available"; - if (epgid != 0) { - CEPGData epgdata; - if (sectionsd_getEPGid(epgid, epg_time, &epgdata)) { - tmpstring = epgdata.title; - info1 = epgdata.info1; - info2 = epgdata.info2; - - recMovieInfo->parentalLockAge = epgdata.fsk; - if(epgdata.contentClassification.size() > 0 ) - recMovieInfo->genreMajor = epgdata.contentClassification[0]; - - recMovieInfo->length = epgdata.epg_times.dauer / 60; - - printf("fsk:%d, Genre:%d, Dauer: %d\r\n",recMovieInfo->parentalLockAge,recMovieInfo->genreMajor,recMovieInfo->length); - } - } else if (!epgTitle.empty()) { - tmpstring = epgTitle; - } - recMovieInfo->epgTitle = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); - recMovieInfo->epgId = channel_id; - recMovieInfo->epgInfo1 = ZapitTools::UTF8_to_UTF8XML(info1.c_str()); - recMovieInfo->epgInfo2 = ZapitTools::UTF8_to_UTF8XML(info2.c_str()); - recMovieInfo->epgEpgId = epgid ; - recMovieInfo->epgMode = g_Zapit->getMode(); - recMovieInfo->epgVideoPid = si.vpid; - recMovieInfo->VideoType = si.vtype; - - rec_vpid = si.vpid; - rec_vtype = si.vtype; - rec_currentapid = si.apid; - memset(rec_apids, 0, sizeof(unsigned short)*REC_MAX_APIDS); - memset(rec_ac3flags, 0, sizeof(unsigned short)*REC_MAX_APIDS); - rec_numpida = 0; - - EPG_AUDIO_PIDS audio_pids; - /* super hack :-), der einfachste weg an die apid descriptions ranzukommen */ - g_RemoteControl->current_PIDs = allpids; - g_RemoteControl->processAPIDnames(); - - APIDList::iterator it; - for(unsigned int i= 0; i< allpids.APIDs.size(); i++) { - for(it = apid_list.begin(); it != apid_list.end(); ++it) { - if(allpids.APIDs[i].pid == it->apid) { - audio_pids.epgAudioPid = allpids.APIDs[i].pid; - audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc); - audio_pids.atype = allpids.APIDs[i].is_ac3 ? 1 : allpids.APIDs[i].is_aac ? 5 : 0; - audio_pids.selected = (audio_pids.epgAudioPid == (int) rec_currentapid) ? 1 : 0; - recMovieInfo->audioPids.push_back(audio_pids); - - if(allpids.APIDs[i].is_ac3) - rec_ac3flags[rec_numpida] = 1; - if(allpids.APIDs[i].is_aac) - rec_ac3flags[rec_numpida] = 5; - - rec_apids[rec_numpida] = allpids.APIDs[i].pid; - if(rec_apids[rec_numpida] == rec_currentapid) - rec_currentac3 = allpids.APIDs[i].is_ac3 ? 1 : allpids.APIDs[i].is_aac ? 5 : 0; - rec_numpida++; - } - } - } - /* FIXME sometimes no apid in xml ?? */ - if(recMovieInfo->audioPids.empty() && allpids.APIDs.size()) { - int i = 0; - audio_pids.epgAudioPid = allpids.APIDs[i].pid; - audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc); - audio_pids.atype = allpids.APIDs[i].is_ac3 ? 1 : allpids.APIDs[i].is_aac ? 5 : 0; - audio_pids.selected = 1; - recMovieInfo->audioPids.push_back(audio_pids); - } - recMovieInfo->epgVTXPID = si.vtxtpid; - - cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo); - - return extMessage; -} diff --git a/src/driver/vcrcontrol.h b/src/driver/vcrcontrol.h deleted file mode 100644 index 088d5ee58..000000000 --- a/src/driver/vcrcontrol.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - - - License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -#ifndef __vcrcontrol__ -#define __vcrcontrol__ - -#include -//#include -#include - -#include -#include - -#include -#include - -#define REC_MAX_APIDS 10 -#define REC_MAX_PIDS 13 - -class CVCRControl -{ - public: - typedef enum CVCRStates - { - CMD_VCR_UNKNOWN = 0, - CMD_VCR_RECORD = 1, - CMD_VCR_STOP = 2, - CMD_VCR_PAUSE = 3, - CMD_VCR_RESUME = 4, - CMD_VCR_AVAILABLE = 5 - } CVCRCommand; - - enum CVCRDevices - { - DEVICE_VCR, - DEVICE_SERVER, - DEVICE_FILE - }; - - class CDevice // basisklasse für die devices - { - public: - int sock_fd; - int last_mode; - time_t start_time; - virtual CVCRDevices getDeviceType(void) const = 0; - CVCRStates deviceState; - virtual bool Stop() = 0; - virtual bool Record(const t_channel_id channel_id = 0, int mode=1, const event_id_t epgid = 0, const std::string& epgTitle = "", unsigned char apidmode = 0, const time_t epg_time=0) = 0; // epg_time added for .xml (MovieBrowser) - virtual bool Pause() = 0; - virtual bool Resume() = 0; - virtual bool Update() = 0; - virtual bool IsAvailable() = 0; - CDevice() { deviceState = CMD_VCR_STOP; cMovieInfo = NULL; recMovieInfo = NULL; rec_numpida = 0; rec_vpid = 0;}; - virtual ~CDevice(){}; - typedef struct { - unsigned short apid; - unsigned int index; - bool ac3; - } APIDDesc; - typedef std::list APIDList; - virtual void getAPIDs(const unsigned char apidmode, APIDList & apid_list); - CMovieInfo * cMovieInfo; - MI_MOVIE_INFO * recMovieInfo; - unsigned short rec_vpid; - unsigned short rec_vtype; - unsigned short rec_apids[REC_MAX_APIDS]; - unsigned short rec_ac3flags[REC_MAX_APIDS]; - unsigned short rec_numpida; - unsigned short rec_currentapid, rec_currentac3; - unsigned char apids_mode; - CZapitClient::responseGetPIDs allpids; - }; - - class CVCRDevice : public CDevice // VCR per IR - { - public: - bool SwitchToScart; - - virtual CVCRDevices getDeviceType(void) const - { - return DEVICE_VCR; - }; - virtual bool Stop(); - virtual bool Record(const t_channel_id channel_id = 0, int mode=1, const event_id_t epgid = 0, const std::string& epgTitle = "", unsigned char apidmode = 0, const time_t epg_time=0); // epg_time added for .xml (MovieBrowser) - virtual bool Pause() { return false; }; - virtual bool Resume() { return false; }; - virtual bool Update() { return false; }; - virtual bool IsAvailable() { return true; }; - CVCRDevice(bool switchtoscart) { SwitchToScart = switchtoscart; }; - virtual ~CVCRDevice(){}; - }; - - class CFileAndServerDevice : public CDevice - { - protected: - void RestoreNeutrino(void); - void CutBackNeutrino(const t_channel_id channel_id, const int mode); - std::string getCommandString(const CVCRCommand command, const t_channel_id channel_id, const event_id_t epgid, const std::string& epgTitle, unsigned char apidmode); - std::string getMovieInfoString(const CVCRCommand command, const t_channel_id channel_id,const event_id_t epgid, const std::string& epgTitle, APIDList apid_list, const time_t epg_time); - - public: - bool StopPlayBack; - bool StopSectionsd; - - virtual bool Pause() { return false; }; - virtual bool Resume() { return false; }; - virtual bool Update() { return false; }; - virtual bool IsAvailable() { return true; }; - }; - - class CFileDevice : public CFileAndServerDevice - { - public: - std::string Directory; - unsigned int SplitSize; - bool Use_O_Sync; - bool Use_Fdatasync; - bool StreamVTxtPid; - bool StreamPmtPid; - unsigned int RingBuffers; - - virtual CVCRDevices getDeviceType(void) const - { - return DEVICE_FILE; - }; - - virtual bool Stop(); - virtual bool Record(const t_channel_id channel_id = 0, int mode=1, const event_id_t epgid = 0, const std::string& epgTitle = "", unsigned char apidmode = 0, const time_t epg_time=0); // epg_time added for .xml (MovieBrowser) - virtual bool Update(void); - - CFileDevice(const bool stopplayback, const bool stopsectionsd, const char * const directory, const unsigned int splitsize, const bool use_o_sync, const bool use_fdatasync, const bool stream_vtxt_pid, const bool stream_pmt_pid, const unsigned int ringbuffers) - { - StopPlayBack = stopplayback; - StopSectionsd = stopsectionsd; - Directory = directory; - SplitSize = splitsize; - Use_O_Sync = use_o_sync; - Use_Fdatasync = use_fdatasync; - StreamVTxtPid = stream_vtxt_pid; - StreamPmtPid = stream_pmt_pid; - RingBuffers = ringbuffers; - }; - virtual ~CFileDevice() - { - }; - }; - - class CServerDevice : public CFileAndServerDevice // externer Streamingserver per tcp - { - private: - bool serverConnect(); - void serverDisconnect(); - - bool sendCommand(CVCRCommand command, const t_channel_id channel_id = 0, const event_id_t epgid = 0, const std::string& epgTitle = "", unsigned char apidmode = 0); - - public: - std::string ServerAddress; - unsigned int ServerPort; - - virtual CVCRDevices getDeviceType(void) const - { - return DEVICE_SERVER; - }; - - virtual bool Stop(); - virtual bool Record(const t_channel_id channel_id = 0, int mode=1, const event_id_t epgid = 0, const std::string& epgTitle = "", unsigned char apidmode = 0, const time_t epg_time=0); // epg_time added for .xml (MovieBrowser) - - CServerDevice(const bool stopplayback, const bool stopsectionsd, const char * const serveraddress, const unsigned int serverport) - { - StopPlayBack = stopplayback; - StopSectionsd = stopsectionsd; - ServerAddress = serveraddress; - ServerPort = serverport; - }; - virtual ~CServerDevice(){}; - }; - - public: - CVCRControl(); - ~CVCRControl(); - static CVCRControl * getInstance(); - - CDevice * Device; - - void registerDevice(CDevice * const device); - void unregisterDevice(); - - inline bool isDeviceRegistered(void) const { return (Device != NULL); }; - - inline CVCRStates getDeviceState(void) const { return Device->deviceState; }; - bool Stop(){return Device->Stop();}; - bool Record(const CTimerd::RecordingInfo * const eventinfo); - bool Pause(){return Device->Pause();}; - bool Resume(){return Device->Resume();}; - bool Update() {return Device->Update();}; - void Screenshot(const t_channel_id channel_id, char * fname = NULL); - MI_MOVIE_INFO * GetMovieInfo(void); - bool GetPids(unsigned short *vpid, unsigned short *vtype, unsigned short *apid, unsigned short *atype, unsigned short * apidnum, unsigned short * apids, unsigned short * atypes); -}; - - -#endif