diff --git a/lib/libcoolstream/dmx_cs.h b/lib/libcoolstream/dmx_cs.h index 7734de5b1..7561ffbe5 100644 --- a/lib/libcoolstream/dmx_cs.h +++ b/lib/libcoolstream/dmx_cs.h @@ -61,7 +61,8 @@ public: unsigned short GetPID(void) { return pid; } const unsigned char *GetFilterTID(u8 FilterIndex = 0); const unsigned char *GetFilterMask(u8 FilterIndex = 0); - unsigned int GetFilterLength(u8 FilterIndex = 0); + const unsigned int GetFilterLength(u8 FilterIndex = 0); + unsigned int GetFilterCount(void); bool AddSectionFilter(unsigned short Pid, const unsigned char * const Filter, const unsigned char * const Mask, int len, const unsigned char * const nMask = NULL); bool sectionFilter(unsigned short Pid, const unsigned char * const Tid, const unsigned char * const Mask, int len, int Timeout = DEMUX_POLL_TIMEOUT, const unsigned char * const nMask = NULL); bool pesFilter(const unsigned short Pid); diff --git a/lib/libcoolstream/record_cs.h b/lib/libcoolstream/record_cs.h index cf1110e73..044d2661a 100644 --- a/lib/libcoolstream/record_cs.h +++ b/lib/libcoolstream/record_cs.h @@ -29,9 +29,11 @@ public: bool Open(int numpids); void Close(void); - bool Start(int fd, unsigned short vpid, unsigned short * apids, int numpids); + bool Start(int fd, unsigned short vpid, unsigned short * apids, int numapids); bool Stop(void); void RecordNotify(int Event, void *pData); + /* not tested */ + bool ChangePids(unsigned short vpid, unsigned short * apids, int numapids); }; #endif // __RECORD_CS_H_ diff --git a/lib/libtuxtxt/libtuxtxt.cpp b/lib/libtuxtxt/libtuxtxt.cpp index 14b5b4758..b559f5967 100644 --- a/lib/libtuxtxt/libtuxtxt.cpp +++ b/lib/libtuxtxt/libtuxtxt.cpp @@ -55,7 +55,7 @@ int tuxtxt_stop() return tuxtxt_stop_thread(); } -void tuxtxt_start(int tpid) +void tuxtxt_start(int tpid, int source) { if (tuxtxt_cache.vtxtpid != tpid) { @@ -63,11 +63,11 @@ void tuxtxt_start(int tpid) tuxtxt_clear_cache(); tuxtxt_cache.page = 0x100; tuxtxt_cache.vtxtpid = tpid; - tuxtxt_start_thread(); + tuxtxt_start_thread(source); } else if (!tuxtxt_cache.thread_starting && !tuxtxt_cache.receiving) { - tuxtxt_start_thread(); + tuxtxt_start_thread(source); } } diff --git a/lib/libtuxtxt/teletext.h b/lib/libtuxtxt/teletext.h index a7191297d..6bc3dc590 100644 --- a/lib/libtuxtxt/teletext.h +++ b/lib/libtuxtxt/teletext.h @@ -1,11 +1,11 @@ #ifndef __teletext_h__ #define __teletext_h__ -extern int tuxtxt_init(); -extern void tuxtxt_close(); -extern void tuxtxt_start(int tpid); // Start caching -extern int tuxtxt_stop(); // Stop caching -extern int tuxtx_main(int _rc, int pid, int page = 0); +int tuxtxt_init(); +void tuxtxt_close(); +void tuxtxt_start(int tpid, int source = 0); // Start caching +int tuxtxt_stop(); // Stop caching +int tuxtx_main(int _rc, int pid, int page = 0, int source = 0); void tuxtx_stop_subtitle(); int tuxtx_subtitle_running(int *pid, int *page, int *running); void tuxtx_pause_subtitle(bool pause = 1); diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index 416561faf..14208ae77 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -13,9 +13,9 @@ * * ******************************************************************************/ +#include "teletext.h" #include "tuxtxt.h" #include "driver/framebuffer.h" -#include "teletext.h" #include #include @@ -1596,7 +1596,7 @@ int tuxtx_subtitle_running(int *pid, int *page, int *running) return ret; } -int tuxtx_main(int _rc, int pid, int page) +int tuxtx_main(int _rc, int pid, int page, int source) { char cvs_revision[] = "$Revision: 1.95 $"; @@ -1677,7 +1677,7 @@ int tuxtx_main(int _rc, int pid, int page) /* initialisations */ transpmode = 0; - if (Init() == 0) + if (Init(source) == 0) return 0; if(!use_gui) { @@ -1860,7 +1860,7 @@ FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library plibrary, FT_Pointer /*r ******************************************************************************/ extern std::string ttx_font_file; static bool ft_init_done = false; -int Init() +int Init(int source) { int error, i; unsigned char magazine; @@ -2182,7 +2182,7 @@ int Init() tuxtxt_init_demuxer(); tuxtxt_start_thread(); #else - tuxtxt_start(tuxtxt_cache.vtxtpid); + tuxtxt_start(tuxtxt_cache.vtxtpid, source); #endif fcntl(rc, F_SETFL, O_NONBLOCK); gethotlist(); diff --git a/lib/libtuxtxt/tuxtxt.h b/lib/libtuxtxt/tuxtxt.h index aba73e6a8..685b77db9 100644 --- a/lib/libtuxtxt/tuxtxt.h +++ b/lib/libtuxtxt/tuxtxt.h @@ -50,10 +50,6 @@ #else /* variables and functions from libtuxtxt */ extern tuxtxt_cache_struct tuxtxt_cache; -extern int tuxtxt_init(); -extern void tuxtxt_close(); -extern void tuxtxt_start(int tpid); // Start caching -extern int tuxtxt_stop(); // Stop caching extern void tuxtxt_next_dec(int *i); /* skip to next decimal */ extern void tuxtxt_prev_dec(int *i); /* counting down */ extern int tuxtxt_is_dec(int i); @@ -1729,7 +1725,7 @@ void RenderMessage(int Message); void RenderPage(); void DecodePage(); void UpdateLCD(); -int Init(); +int Init(int source); int GetNationalSubset(const char *country_code); int GetTeletextPIDs(); int GetRCCode(); diff --git a/lib/libtuxtxt/tuxtxt_common.h b/lib/libtuxtxt/tuxtxt_common.h index 4a9130325..837212934 100644 --- a/lib/libtuxtxt/tuxtxt_common.h +++ b/lib/libtuxtxt/tuxtxt_common.h @@ -417,12 +417,15 @@ void tuxtxt_clear_cache() * init_demuxer * ******************************************************************************/ static cDemux * dmx = NULL; -int tuxtxt_init_demuxer() +int tuxtxt_init_demuxer(int source = 0); + +int tuxtxt_init_demuxer(int source) { if(dmx == NULL) { - dmx = new cDemux(0); + dmx = new cDemux(source); dmx->Open(DMX_PES_CHANNEL, NULL, 2* 3008 * 62 /*64*1024*/); + printf("TuxTxt: source demux %d\n", source); } #if TUXTXT_DEBUG printf("TuxTxt: initialized\n"); @@ -1029,13 +1032,14 @@ void *tuxtxt_CacheThread(void * /*arg*/) /****************************************************************************** * start_thread * ******************************************************************************/ -int tuxtxt_start_thread() +int tuxtxt_start_thread(int source = 0); +int tuxtxt_start_thread(int source) { if (tuxtxt_cache.vtxtpid == -1) return 0; tuxtxt_cache.thread_starting = 1; - tuxtxt_init_demuxer(); + tuxtxt_init_demuxer(source); dmx->pesFilter(tuxtxt_cache.vtxtpid); dmx->Start(); diff --git a/src/driver/pictureviewer/crw.cpp b/src/driver/pictureviewer/crw.cpp index 0c217cdf0..667c58a23 100644 --- a/src/driver/pictureviewer/crw.cpp +++ b/src/driver/pictureviewer/crw.cpp @@ -1,19 +1,21 @@ #include "pv_config.h" #include #include + #ifdef FBV_SUPPORT_CRW - #include - #include - #include +#include +#include +#include #include #include +#include +#include "pictureviewer.h" + +#undef HAVE_STDLIB_H // -Werror complain extern "C" { #include } - #include - #include "pictureviewer.h" - /* Get a 2-byte integer, making no assumptions about CPU byte order. Nor should we assume that the compiler evaluates left-to-right. diff --git a/src/driver/pictureviewer/jpeg.cpp b/src/driver/pictureviewer/jpeg.cpp index 69ac998a2..da8bcd0e1 100644 --- a/src/driver/pictureviewer/jpeg.cpp +++ b/src/driver/pictureviewer/jpeg.cpp @@ -17,10 +17,6 @@ #include #include #include - -extern "C" { -#include -} #include @@ -28,6 +24,11 @@ extern "C" { #include "pictureviewer.h" #include "picv_client_server.h" +#undef HAVE_STDLIB_H // -Werror complain +extern "C" { +#include +} + #define MIN(a,b) ((a)>(b)?(b):(a)) struct r_jpeg_error_mgr diff --git a/src/driver/stream2file.cpp b/src/driver/stream2file.cpp index 53454cfc7..3c9e79407 100644 --- a/src/driver/stream2file.cpp +++ b/src/driver/stream2file.cpp @@ -57,6 +57,7 @@ #if HAVE_COOL_HARDWARE #include #include +#include #endif #if HAVE_TRIPLEDRAGON #include @@ -137,9 +138,14 @@ stream2file_error_msg_t start_recording(const char * const filename, 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 - if(g_current_channel) - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 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); diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index bee42ab5d..914d43521 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -29,14 +29,12 @@ #include #include -extern CZapitChannel *g_current_channel; -extern CCam *cam0; #define TS_SIZE 188 -//#define IN_SIZE (2048 * TS_SIZE) -#define IN_SIZE (TS_SIZE * 362) +#define IN_SIZE (2048 * TS_SIZE) +//#define IN_SIZE (TS_SIZE * 362) -#define DMX_BUFFER_SIZE (3008 * 62) +#define DMX_BUFFER_SIZE (2 * 3008 * 62) /* maximum number of pes pids */ #define MAXPIDS 64 @@ -47,14 +45,17 @@ extern CCam *cam0; //unsigned char * buf; -int demuxfd[MAXPIDS]; +extern CZapitChannel *g_current_channel; +extern CCam *cam0; + +//int demuxfd[MAXPIDS]; static unsigned char exit_flag = 0; static unsigned int writebuf_size = 0; static unsigned char writebuf[PACKET_SIZE]; -static int -sync_byte_offset (const unsigned char * buf, const unsigned int len) +#ifdef SYNC_TS +static int sync_byte_offset (const unsigned char * buf, const unsigned int len) { unsigned int i; @@ -65,6 +66,7 @@ sync_byte_offset (const unsigned char * buf, const unsigned int len) return -1; } +#endif void packet_stdout (int fd, unsigned char * buf, int count, void * /*p*/) { @@ -178,7 +180,7 @@ int open_incoming_port (int port) void * streamts_live_thread(void *data); int streamts_stop; -void streamts_main_thread(void */*data*/) +void streamts_main_thread(void * /*data*/) { struct sockaddr_in servaddr; int clilen; @@ -348,14 +350,22 @@ void * streamts_live_thread(void *data) dmx->Start(); if(g_current_channel) - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 3, true); // demux 0 + 1, update + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() | DEMUX_DECODE_1 /*3*/, true); // demux 0 + 1, update - size_t pos; ssize_t r; +#if 0 + size_t pos; ssize_t todo; - int offset; +#endif +#ifdef SYNC_TS + int offset = 0; +#endif while (!exit_flag) { + r = dmx->Read(buf, IN_SIZE, 100); + if(r > 0) + packet_stdout(fd, buf, r, NULL); +#if 0 todo = IN_SIZE; pos = 0; @@ -369,7 +379,9 @@ void * streamts_live_thread(void *data) usleep(1000); } if(!exit_flag) { - //packet_stdout(fd, buf, IN_SIZE, NULL); +#ifndef SYNC_TS + packet_stdout(fd, buf, IN_SIZE, NULL); +#else /* make sure to start with a ts header */ offset = sync_byte_offset(buf, IN_SIZE); @@ -377,12 +389,14 @@ void * streamts_live_thread(void *data) continue; packet_stdout(fd, buf + offset, IN_SIZE - offset, NULL); +#endif } +#endif } printf("Exiting LIVE STREAM thread, fd %d\n", fd); if(g_current_channel) - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 1, true); // demux 0, update + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() & ~DEMUX_DECODE_1 /* 1 */, true); // demux 0, update delete dmx; free(buf); diff --git a/src/driver/vcrcontrol.cpp b/src/driver/vcrcontrol.cpp index 8af7cd947..eedd9002d 100644 --- a/src/driver/vcrcontrol.cpp +++ b/src/driver/vcrcontrol.cpp @@ -28,32 +28,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include - #ifdef HAVE_CONFIG_H #include #endif -#include - -#include - - -#include -#include - -#include -#include -#include -#include - #include #include #include - -#include -#include - #include #include #include @@ -62,10 +43,22 @@ #include #include #include +#include +#include #include #include +#include +#include +#include +#include + +#include +//#include +#include +#include + #include #include @@ -80,8 +73,6 @@ extern "C" { #include } -static CMovieInfo * g_cMovieInfo; -static MI_MOVIE_INFO * g_movieInfo; t_channel_id rec_channel_id; static CVCRControl vcrControl; @@ -131,6 +122,30 @@ bool CVCRControl::Record(const CTimerd::RecordingInfo * const eventinfo) 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) { + *vpid = Device->rec_vpid; + *vtype = Device->rec_vtype; + *apid = Device->rec_currentapid; + *atype = Device->rec_currentac3; + *apidnum = Device->rec_numpida; + for(int i = 0; i < Device->rec_numpida; i++) { + apids[i] = Device->rec_apids[i]; + atypes[i] = Device->rec_ac3flags[i]; + } + return true; + } + return false; +} + //------------------------------------------------------------------------- void CVCRControl::CDevice::getAPIDs(const unsigned char ap, APIDList & apid_list) { @@ -496,14 +511,14 @@ bool CVCRControl::CFileDevice::Stop() { std::string extMessage = " "; time_t end_time = time(0); -//printf("[direct] Stop recording, g_movieInfo %lx\n", g_movieInfo); fflush(stdout); +//printf("[direct] Stop recording, recMovieInfo %lx\n", recMovieInfo); fflush(stdout); //FIXME why not save info if shift ? //if(!autoshift || autoshift_delete) - if(g_movieInfo && g_cMovieInfo) { - // g_movieInfo->length = (end_time - start_time) / 60; - g_movieInfo->length = (int) round((double) (end_time - start_time) / (double) 60); + if(recMovieInfo && cMovieInfo) { + // recMovieInfo->length = (end_time - start_time) / 60; + recMovieInfo->length = (int) round((double) (end_time - start_time) / (double) 60); //printf("[direct] stop recording 1\n"); fflush(stdout); - g_cMovieInfo->encodeMovieInfoXml(&extMessage, g_movieInfo); + cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo); //printf("[direct] stop recording 2\n"); fflush(stdout); } bool return_value = (::stop_recording(extMessage.c_str()) == STREAM2FILE_OK); @@ -513,14 +528,14 @@ bool CVCRControl::CFileDevice::Stop() deviceState = CMD_VCR_STOP; - if(g_movieInfo) { - g_movieInfo->audioPids.clear(); - delete g_movieInfo; - g_movieInfo = NULL; + if(recMovieInfo) { + recMovieInfo->audioPids.clear(); + delete recMovieInfo; + recMovieInfo = NULL; } - if(g_cMovieInfo) { - delete g_cMovieInfo; - g_cMovieInfo = NULL; + if(cMovieInfo) { + delete cMovieInfo; + cMovieInfo = NULL; } return return_value; @@ -811,25 +826,18 @@ bool CVCRControl::CServerDevice::serverConnect() return true; } -unsigned short rec_vpid; -unsigned short rec_vtype; -unsigned short rec_apids[10]; -unsigned short rec_ac3flags[10]; -unsigned short rec_numpida; -unsigned int rec_currentapid, rec_currentac3; - //------------------------------------------------------------------------- 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 apids10; std::string info1, info2; - if(!g_cMovieInfo) - g_cMovieInfo = new CMovieInfo(); - if(!g_movieInfo) - g_movieInfo = new MI_MOVIE_INFO(); + if(!cMovieInfo) + cMovieInfo = new CMovieInfo(); + if(!recMovieInfo) + recMovieInfo = new MI_MOVIE_INFO(); - g_cMovieInfo->clearMovieInfo(g_movieInfo); + cMovieInfo->clearMovieInfo(recMovieInfo); CZapitClient::responseGetPIDs pids; g_Zapit->getPIDS (pids); @@ -837,9 +845,9 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm std::string tmpstring = g_Zapit->getChannelName(channel_id); if (tmpstring.empty()) - g_movieInfo->epgChannel = "unknown"; + recMovieInfo->epgChannel = "unknown"; else - g_movieInfo->epgChannel = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); + recMovieInfo->epgChannel = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); tmpstring = "not available"; if (epgid != 0) { @@ -850,31 +858,31 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm info1 = epgdata.info1; info2 = epgdata.info2; - g_movieInfo->parentalLockAge = epgdata.fsk; + recMovieInfo->parentalLockAge = epgdata.fsk; if(epgdata.contentClassification.size() > 0 ) - g_movieInfo->genreMajor = epgdata.contentClassification[0]; + recMovieInfo->genreMajor = epgdata.contentClassification[0]; - g_movieInfo->length = epgdata.epg_times.dauer / 60; + recMovieInfo->length = epgdata.epg_times.dauer / 60; - printf("fsk:%d, Genre:%d, Dauer: %d\r\n",g_movieInfo->parentalLockAge,g_movieInfo->genreMajor,g_movieInfo->length); + printf("fsk:%d, Genre:%d, Dauer: %d\r\n",recMovieInfo->parentalLockAge,recMovieInfo->genreMajor,recMovieInfo->length); } } else if (!epgTitle.empty()) { tmpstring = epgTitle; } - g_movieInfo->epgTitle = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str()); - g_movieInfo->epgId = channel_id; - g_movieInfo->epgInfo1 = ZapitTools::UTF8_to_UTF8XML(info1.c_str()); - g_movieInfo->epgInfo2 = ZapitTools::UTF8_to_UTF8XML(info2.c_str()); - g_movieInfo->epgEpgId = epgid ; - g_movieInfo->epgMode = g_Zapit->getMode(); - g_movieInfo->epgVideoPid = si.vpid; - g_movieInfo->VideoType = si.vtype; + 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)*10); - memset(rec_ac3flags, 0, sizeof(unsigned short)*10); + 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; @@ -890,7 +898,7 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc); audio_pids.atype = pids.APIDs[i].is_ac3 ? 1 : pids.APIDs[i].is_aac ? 5 : 0; audio_pids.selected = (audio_pids.epgAudioPid == (int) rec_currentapid) ? 1 : 0; - g_movieInfo->audioPids.push_back(audio_pids); + recMovieInfo->audioPids.push_back(audio_pids); if(pids.APIDs[i].is_ac3) rec_ac3flags[i] = 1; @@ -905,19 +913,19 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm } } //FIXME sometimes no apid in xml ?? - if(g_movieInfo->audioPids.empty() && pids.APIDs.size()) { + if(recMovieInfo->audioPids.empty() && pids.APIDs.size()) { int i = 0; audio_pids.epgAudioPid = pids.APIDs[i].pid; audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc); audio_pids.atype = pids.APIDs[i].is_ac3 ? 1 : pids.APIDs[i].is_aac ? 5 : 0; audio_pids.selected = 1; - g_movieInfo->audioPids.push_back(audio_pids); + recMovieInfo->audioPids.push_back(audio_pids); } - g_movieInfo->epgVTXPID = si.vtxtpid; + recMovieInfo->epgVTXPID = si.vtxtpid; - g_cMovieInfo->encodeMovieInfoXml(&extMessage, g_movieInfo); + cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo); - //g_movieInfo->audioPids.clear(); + //recMovieInfo->audioPids.clear(); return extMessage; } diff --git a/src/driver/vcrcontrol.h b/src/driver/vcrcontrol.h index 8b219f70c..e6b003835 100644 --- a/src/driver/vcrcontrol.h +++ b/src/driver/vcrcontrol.h @@ -39,7 +39,9 @@ #include #include +#include +#define REC_MAX_APIDS 10 class CVCRControl { @@ -74,7 +76,7 @@ class CVCRControl virtual bool Pause() = 0; virtual bool Resume() = 0; virtual bool IsAvailable() = 0; - CDevice() { deviceState = CMD_VCR_STOP; }; + CDevice() { deviceState = CMD_VCR_STOP; cMovieInfo = NULL; recMovieInfo = NULL; rec_numpida = 0; rec_vpid = 0;}; virtual ~CDevice(){}; typedef struct { unsigned short apid; @@ -83,6 +85,14 @@ class CVCRControl } APIDDesc; typedef std::list APIDList; virtual void getAPIDs(const unsigned char apids, 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; }; class CVCRDevice : public CDevice // VCR per IR @@ -215,6 +225,8 @@ class CVCRControl bool Pause(){return Device->Pause();}; bool Resume(){return Device->Resume();}; 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); }; diff --git a/src/driver/vfd.cpp b/src/driver/vfd.cpp index 63adb33ca..9cb2103f7 100644 --- a/src/driver/vfd.cpp +++ b/src/driver/vfd.cpp @@ -40,6 +40,7 @@ #include #include +#include extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ CVFD::CVFD() @@ -165,6 +166,7 @@ void CVFD::setlcdparameter(void) setlcdparameter((mode == MODE_STANDBY) ? g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] : (mode == MODE_SHUTDOWN) ? g_settings.lcd_setting[SNeutrinoSettings::LCD_DEEPSTANDBY_BRIGHTNESS] : g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS], last_toggle_state_power); } + void CVFD::setled(int led1, int led2){ int ret = ioctl(fd, IOC_VFD_LED_CTRL, led1); if(ret < 0) @@ -173,6 +175,7 @@ void CVFD::setled(int led1, int led2){ if(ret < 0) perror("IOC_VFD_LED_CTRL"); } + void CVFD::setled(void) { if(!has_lcd) return; @@ -219,13 +222,17 @@ printf("CVFD::showServicename: %s\n", name.c_str()); void CVFD::showTime(bool force) { + //unsigned int system_rev = cs_get_revision(); + static int recstatus = 0; +#if 0 if(!has_lcd) return; - if(mode == MODE_SHUTDOWN) { +#endif + if(has_lcd && mode == MODE_SHUTDOWN) { ShowIcon(VFD_ICON_CAM1, false); return; } - if (showclock) { + if (has_lcd && showclock) { if (mode == MODE_STANDBY) { char timestr[21]; struct timeb tm; @@ -246,15 +253,22 @@ void CVFD::showTime(bool force) if (CNeutrinoApp::getInstance ()->recordingstatus) { if(clearClock) { clearClock = 0; - ShowIcon(VFD_ICON_CAM1, false); + if(has_lcd) + ShowIcon(VFD_ICON_CAM1, false); + setled(VFD_LED_1_OFF, VFD_LED_2_OFF); } else { clearClock = 1; - ShowIcon(VFD_ICON_CAM1, true); + if(has_lcd) + ShowIcon(VFD_ICON_CAM1, true); + setled(VFD_LED_1_ON, VFD_LED_2_ON); } - } else if(clearClock) { // in case icon ON after record stopped + } else if(recstatus != CNeutrinoApp::getInstance ()->recordingstatus) { // in case icon ON after record stopped clearClock = 0; - ShowIcon(VFD_ICON_CAM1, false); + if(has_lcd) + ShowIcon(VFD_ICON_CAM1, false); + setled(); } + recstatus = CNeutrinoApp::getInstance ()->recordingstatus; } void CVFD::showRCLock(int /*duration*/) @@ -601,6 +615,7 @@ void CVFD::Clear() void CVFD::ShowIcon(vfd_icon icon, bool show) { + if(!has_lcd) return; //printf("CVFD::ShowIcon %s %x\n", show ? "show" : "hide", (int) icon); int ret = ioctl(fd, show ? IOC_VFD_SET_ICON : IOC_VFD_CLEAR_ICON, icon); if(ret < 0) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 330e4f472..c474b4a4d 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -76,6 +76,7 @@ #include #include +#include "libtuxtxt/teletext.h" int dvbsub_start(int pid); int dvbsub_pause(); @@ -100,21 +101,13 @@ extern int glob_splits; #error not using 64 bit file offsets #endif /* __USE_FILE__OFFSET64 */ -static unsigned short g_apids[10]; -static unsigned short g_ac3flags[10]; +static unsigned short g_apids[REC_MAX_APIDS]; +static unsigned short g_ac3flags[REC_MAX_APIDS]; static unsigned short g_numpida = 0; static unsigned short g_vpid = 0; static unsigned short g_vtype = 0; -static std::string g_language[10]; - -extern unsigned short rec_vpid; -extern unsigned short rec_vtype; -extern unsigned short rec_apids[10]; -extern unsigned short rec_ac3flags[10]; -extern unsigned short rec_numpida; -extern unsigned int rec_currentapid, rec_currentac3; - -static unsigned int g_currentapid = 0, g_currentac3 = 0, apidchanged = 0; +static std::string g_language[REC_MAX_APIDS]; +static unsigned short g_currentapid = 0, g_currentac3 = 0, apidchanged = 0; std::string g_file_epg; std::string g_file_epg1; @@ -437,24 +430,17 @@ void CMoviePlayerGui::PlayFile(void) bool time_forced = false; playstate = CMoviePlayerGui::STOPPED; bool is_file_player = false; + timeb current_time; + CMovieInfo cMovieInfo; // funktions to save and load movie info + MI_MOVIE_INFO *p_movie_info = NULL; // movie info handle which comes from the MovieBrowser, if not NULL MoviePla yer is able to save new bookmarks if (has_hdd) system("(rm /hdd/.wakeup; touch /hdd/.wakeup; sync) > /dev/null 2> /dev/null &"); if (timeshift) { - g_vpid = rec_vpid; - g_vtype = rec_vtype; - g_numpida = rec_numpida; - g_currentapid = rec_currentapid; - g_currentac3 = rec_currentac3; - for (int i = 0; i < g_numpida; i++) { - g_apids[i] = rec_apids[i]; - g_ac3flags[i] = rec_ac3flags[i]; - } + CVCRControl::getInstance()->GetPids(&g_vpid, &g_vtype, &g_currentapid, &g_currentac3, &g_numpida, g_apids, g_ac3flags); + p_movie_info = CVCRControl::getInstance()->GetMovieInfo(); } - timeb current_time; - CMovieInfo cMovieInfo; // funktions to save and load movie info - MI_MOVIE_INFO *p_movie_info = NULL; // movie info handle which comes from the MovieBrowser, if not NULL MoviePla yer is able to save new bookmarks int width = 280; int height = 65; @@ -1212,6 +1198,27 @@ void CMoviePlayerGui::PlayFile(void) else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { //FIXME do nothing ? } + else if(timeshift && (msg == CRCInput::RC_text || msg == CRCInput::RC_epg)) { + bool restore = FileTime.IsVisible(); + FileTime.hide(); + if (g_settings.mode_clock) + InfoClock->StopClock(); + + if( msg == CRCInput::RC_epg ) + g_EventList->exec(CNeutrinoApp::getInstance()->channelList->getActiveChannel_ChannelID(), CNeutrinoApp::getInstance()->channelList->getActiveChannelName()); + else { + if(g_settings.cacheTXT) + tuxtxt_stop(); + tuxtx_main(g_RCInput->getFileHandle(), g_RemoteControl->current_PIDs.PIDs.vtxtpid, 0, 2); + frameBuffer->paintBackground(); + } + if (g_settings.mode_clock) + InfoClock->StartClock(); + if(restore) { + FileTime.show(position / 1000); + FileTime.updatePos(file_prozent); + } + } else if (msg == CRCInput::RC_timeout) { // nothing } else if ( msg == NeutrinoMessages::ANNOUNCE_RECORD || diff --git a/src/zapit/include/zapit/cam.h b/src/zapit/include/zapit/cam.h index e39d6efdb..ba8d42ef0 100644 --- a/src/zapit/include/zapit/cam.h +++ b/src/zapit/include/zapit/cam.h @@ -26,15 +26,27 @@ #include "ci.h" #include +#define DEMUX_DECODE_0 1 +#define DEMUX_DECODE_1 2 +#define DEMUX_DECODE_2 4 + +#define DEMUX_SOURCE_0 0 +#define DEMUX_SOURCE_1 1 +#define DEMUX_SOURCE_2 2 + class CCam : public CBasicClient { private: virtual unsigned char getVersion(void) const; virtual const char *getSocketName(void) const; + int camask, demux; public: + CCam(); bool sendMessage(const char * const data, const size_t length, bool update = false); - bool setCaPmt(CCaPmt * const caPmt, int demux = 0, int camask = 1, bool update = false); + bool setCaPmt(CCaPmt * const caPmt, int _demux = 0, int _camask = 1, bool update = false); + int getCaMask(void) { return camask; }; + int getDemux(void) { return demux; }; }; #endif /* __cam_h__ */ diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index 37245025f..65fd88eda 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -145,6 +145,8 @@ class CZapitChannel /* the conditional access program map table of this channel */ CCaPmt * caPmt; + unsigned char * rawPmt; + int pmtLen; /* from neutrino CChannel class */ uint64_t last_unlocked_EPGid; @@ -190,6 +192,7 @@ class CZapitChannel unsigned short getPreAudioPid(void) { return audioPid; } bool getPidsFlag(void) { return pidsFlag; } CCaPmt * getCaPmt(void) { return caPmt; } + unsigned char * getRawPmt(int &len) { len = pmtLen; return rawPmt; }; CZapitAudioChannel * getAudioChannel(unsigned char index = 0xFF); unsigned short getAudioPid(unsigned char index = 0xFF); @@ -209,7 +212,8 @@ class CZapitChannel void setAudioPid(unsigned short pAudioPid) { audioPid = pAudioPid; } void setPrivatePid(unsigned short pPrivatePid) { privatePid = pPrivatePid; } void setPidsFlag(void) { pidsFlag = true; } - void setCaPmt(CCaPmt *pCaPmt) { caPmt = pCaPmt; } + void setCaPmt(CCaPmt *pCaPmt); + void setRawPmt(unsigned char * pmt, int len = 0); /* cleanup methods */ void resetPids(void); /* subtitling related methods */ diff --git a/src/zapit/src/cam.cpp b/src/zapit/src/cam.cpp index 1c4b578eb..eda3fa4cf 100644 --- a/src/zapit/src/cam.cpp +++ b/src/zapit/src/cam.cpp @@ -20,11 +20,17 @@ * */ +#include /* zapit */ #include #include /* CAMD_UDS_NAME */ #include /* get_length_field_size */ +CCam::CCam() +{ + camask = 1; + demux = 0; +} unsigned char CCam::getVersion(void) const { @@ -50,22 +56,29 @@ bool CCam::sendMessage(const char * const data, const size_t length, bool update close_connection(); - if(!length) return false; + if(!data || !length) { + camask = 1; + demux = 0; + return false; + } if (!open_connection()) return false; return send_data(data, length); } -bool CCam::setCaPmt(CCaPmt * const caPmt, int demux, int camask, bool update) +bool CCam::setCaPmt(CCaPmt * const caPmt, int _demux, int _camask, bool update) { + camask = _camask; + demux = _demux; + if (!caPmt) return true; -//printf("CCam::setCaPmt cam %x dmx %d camask %d update %s\n", this, demux, camask, update ? "yes" : "no" ); + + printf("CCam::setCaPmt cam %x source %d camask %d update %s\n", (int) this, demux, camask, update ? "yes" : "no" ); unsigned int size = caPmt->getLength(); unsigned char buffer[3 + get_length_field_size(size) + size]; size_t pos = caPmt->writeToBuffer(buffer, demux, camask); return sendMessage((char *)buffer, pos, update); } - diff --git a/src/zapit/src/channel.cpp b/src/zapit/src/channel.cpp index d7c27ce4a..bfdf6a844 100644 --- a/src/zapit/src/channel.cpp +++ b/src/zapit/src/channel.cpp @@ -34,6 +34,7 @@ CZapitChannel::CZapitChannel(const std::string & p_name, t_service_id p_sid, t_t freq = p_freq; channel_id = CREATE_CHANNEL_ID64; caPmt = NULL; + rawPmt = NULL; type = 0; number = 0; scrambled = 0; @@ -49,11 +50,11 @@ CZapitChannel::~CZapitChannel(void) { //printf("DEL CHANNEL %s %x subs %d\n", name.c_str(), (int) this, getSubtitleCount()); resetPids(); + setCaPmt(NULL); + setRawPmt(NULL); //if(currentEvent) // delete currentEvent; - if (caPmt) - delete caPmt; } CZapitAudioChannel *CZapitChannel::getAudioChannel(unsigned char index) @@ -262,3 +263,18 @@ int CZapitChannel::getChannelSubIndex(void) { return currentSub < getSubtitleCount() ? currentSub : -1; } + +void CZapitChannel::setCaPmt(CCaPmt *pCaPmt) +{ + if(caPmt) + delete caPmt; + caPmt = pCaPmt; +} + +void CZapitChannel::setRawPmt(unsigned char * pmt, int len) +{ + if(rawPmt) + delete[] rawPmt; + rawPmt = pmt; + pmtLen = len; +} diff --git a/src/zapit/src/pmt.cpp b/src/zapit/src/pmt.cpp index bc2c78a9c..40790769e 100644 --- a/src/zapit/src/pmt.cpp +++ b/src/zapit/src/pmt.cpp @@ -452,17 +452,13 @@ int parse_pmt(CZapitChannel * const channel) delete dmx; return -1; } - unsigned int dmxUnit = dmx->getUnit(); - delete dmx; - cCA *ca = cCA::GetInstance(); curservice_id = channel->getServiceId(); curpmtpid = channel->getPmtPid(); pmtlen= ((buffer[1]&0xf)<<8) + buffer[2] +3; if(!(currentMode & RECORD_MODE) && !scan_runs) { - ca->SendPMT(dmxUnit, buffer, pmtlen); fout = fopen("/tmp/pmt.tmp","wb"); if(fout != NULL) { if ((int) fwrite(buffer, sizeof(unsigned char), pmtlen, fout) != pmtlen) { @@ -569,14 +565,14 @@ int parse_pmt(CZapitChannel * const channel) ES_info_length = parse_ES_info(buffer + i, channel, caPmt); if(scan_runs) { - if(channel->getCaPmt() != 0) - delete channel->getCaPmt(); channel->setCaPmt(NULL); + channel->setRawPmt(NULL); delete caPmt; } else { - if(channel->getCaPmt() != 0) - delete channel->getCaPmt(); channel->setCaPmt(caPmt); + unsigned char * p = new unsigned char[pmtlen]; + memcpy(p, buffer, pmtlen); + channel->setRawPmt(p, pmtlen); } #if 0 //Quick&Dirty Hack to support Premiere's EPG not only on the portal but on the subchannels as well @@ -722,7 +718,7 @@ int pmt_set_update_filter(CZapitChannel * const channel, int * fd) int pmt_stop_update_filter(int * fd) { -printf("[pmt] stop update filter\n"); + printf("[pmt] stop update filter\n"); if(pmtDemux) pmtDemux->Stop(); diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index c23faf099..531c5de54 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -350,6 +350,12 @@ CZapitClient::responseGetLastChannel load_settings(void) return lastchannel; } +/* currently, recording always starts after zap to channel. + * if we not in record mode, we just send new pmt over cam0, + * if mode is recording, we zapping from or back to recording channel. + * if we zap from, we start cam1 for new live and update cam0 with camask for rec. + * if to recording channel, we must stop cam1 and update cam0 with live+rec camask. + */ static int camask = 1; // demux 0 void start_camd(bool forupdate = false) { @@ -360,20 +366,25 @@ void start_camd(bool forupdate = false) if(rec_channel_id != live_channel_id) { /* zap from rec. channel */ camask = 1; - cam1->setCaPmt(g_current_channel->getCaPmt(), 0, 1); // demux 0 + cam1->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, DEMUX_DECODE_0 /*1*/); // demux 0 } else if(forupdate) { //FIXME broken! - /* forupdate means pmt update for live channel, using old camask */ - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, camask, true);// update + /* forupdate means pmt update for live channel, using old camask. + * TODO what if forupdate comes while live == rec ? + */ + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask(), true);// update } else { /* zap back to rec. channel */ camask = 5; // demux 0 + 2 - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, camask, true); // update + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() | DEMUX_DECODE_2 /*camask*/, true); // update cam1->sendMessage(0,0); // stop/close } } else { camask = 1; - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, camask); + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, DEMUX_DECODE_0 /*camask*/); } + int len; + unsigned char * pmt = g_current_channel->getRawPmt(len); + ca->SendPMT(DEMUX_SOURCE_0, pmt, len); } static int pmt_update_fd = -1; @@ -434,11 +445,11 @@ printf("[zapit] saving channel, apid %x sub pid %x mode %d volume %d\n", g_curre pmt_stop_update_filter(&pmt_update_fd); stopPlayBack(true); - ca->SendPMT(0, (unsigned char*) "", 0); + if(!forupdate && g_current_channel && g_current_channel->getCaPmt()) { g_current_channel->resetPids(); - delete g_current_channel->getCaPmt(); g_current_channel->setCaPmt(NULL); + g_current_channel->setRawPmt(NULL); } /* store the new channel */ @@ -586,37 +597,10 @@ printf("[zapit] saving channel, apid %x sub pid %x mode %d volume %d\n", g_curre printf("[zapit] sending capmt....\n"); - /* currently, recording always starts after zap to channel. - * if we not in record mode, we just send new pmt over cam0, - * if mode is recording, we zapping from or back to recording channel. - * if we zap from, we start cam1 for new live and update cam0 with camask for rec. - * if to recording channel, we must stop cam1 and update cam0 with live+rec camask. - */ - start_camd(forupdate); -#if 0 - static int camask = 1; // demux 0 - if(currentMode & RECORD_MODE) { - if(rec_channel_id != live_channel_id) { - /* zap from rec. channel */ - camask = 1; - cam1->setCaPmt(g_current_channel->getCaPmt(), 0, 1); // demux 0 - } else if(forupdate) { //FIXME broken! - /* forupdate means pmt update for live channel, using old camask */ - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, camask, true);// update - } else { - /* zap back to rec. channel */ - camask = 5; // demux 0 + 2 - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, camask, true); // update - cam1->sendMessage(0,0); // stop/close - } - } else { - camask = 1; - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, camask); - } -#endif //play: send_ca_id(1); + if (update_pmt) pmt_set_update_filter(g_current_channel, &pmt_update_fd); @@ -715,9 +699,9 @@ void setRecordMode(void) currentMode |= RECORD_MODE; if(event_mode) eventServer->sendEvent(CZapitClient::EVT_RECORDMODE_ACTIVATED, CEventServer::INITID_ZAPIT ); rec_channel_id = live_channel_id; -#if 0 +#if 0 // this is done in stream2file.cpp if(g_current_channel) - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 5, true); // demux 0 + 2, update + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, 5, true); // demux 0 + 2, update #endif } @@ -727,18 +711,19 @@ void unsetRecordMode(void) currentMode &= ~RECORD_MODE; if(event_mode) eventServer->sendEvent(CZapitClient::EVT_RECORDMODE_DEACTIVATED, CEventServer::INITID_ZAPIT ); -/* if we on rec. channel, just update pmt with new camask, - * else we must stop cam1 and start cam0 for current live channel - * in standby should be no cam1 running. - */ + /* if we on rec. channel, just update pmt with new camask, + * else we must stop cam1 and start cam0 for current live channel + * in standby should be no cam1 running. + */ if(standby) cam0->sendMessage(0,0); // stop else if(live_channel_id == rec_channel_id) { - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 1, true); // demux 0, update + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() & ~DEMUX_DECODE_2 /*1*/, true); // demux 0, update } else { cam1->sendMessage(0,0); // stop - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 1); // start + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() & ~DEMUX_DECODE_2 /*1*/); // start } + ca->SendPMT(DEMUX_SOURCE_2, (unsigned char*) "", 0); rec_channel_id = 0; } @@ -1994,21 +1979,19 @@ int startPlayBack(CZapitChannel *thisChannel) int stopPlayBack(bool stop_camd) { -/* -in record mode we stop onle cam1, while cam continue to decrypt recording channel -*/ if(stop_camd) { if(currentMode & RECORD_MODE) { /* if we recording and rec == live, only update camask on cam0, * else stop cam1 */ - if(live_channel_id == rec_channel_id) - cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 4, true); // demux 2, update - else + if(live_channel_id == rec_channel_id) { + cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, DEMUX_DECODE_2 /*4*/, true); // demux 2, update + } else cam1->sendMessage(0,0); } else { cam0->sendMessage(0,0); unlink("/tmp/pmt.tmp"); } + ca->SendPMT(0, (unsigned char*) "", 0); } printf("stopPlayBack: standby %d forced %d\n", standby, playbackStopForced);