vcd-0.9/0000755000000000000000000000000010745170053010636 5ustar rootrootvcd-0.9/menucontrol.h0000644000076400001440000000452610743376045013543 0ustar elsausers/* * menucontrol.h: Menu control of VCD replay * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_MENUCONTROL_H #define __VCD_MENUCONTROL_H #include "viewer.h" #include "player.h" // --- cMenuSpiControl ------------------------------------------------------- class cMenuSpiControl : public cVcdViewerControl { private: cSkinDisplayReplay *displayReplay; bool visible, modeOnly; static int spi; static cVcd *vcd; public: cMenuSpiControl(void); virtual ~cMenuSpiControl(); virtual eOSState ProcessKey(eKeys Key); virtual void Hide(void); static void SetItem(int Spi, cVcd *Vcd); }; // --- cMenuVcdControl ------------------------------------------------------- class cMenuVcdControl : public cVcdPlayerControl { private: cSkinDisplayReplay *displayReplay; bool visible, modeOnly, shown, displayFrames; time_t timeoutShow; bool timeSearchActive, timeSearchHide; int timeSearchTime, timeSearchPos; int lastCurrent, lastTotal; bool lastPlay, lastForward; int lastSpeed; static int track; static cVcd *vcd; static char *title; void ShowMode(void); bool ShowProgress(bool Initial); void TimeSearchDisplay(void); void TimeSearchProcess(eKeys Key); void TimeSearch(void); void ShowTimed(int Seconds = 0); public: cMenuVcdControl(void); virtual ~cMenuVcdControl(); virtual eOSState ProcessKey(eKeys Key); virtual void Show(void); virtual void Hide(void); bool Visible(void) { return visible; } static void SetTrack(int Track, cVcd *Vcd); static const int LastReplayed(void); }; #endif //__VCD_MENUCONTROL_H vcd-0.9/vcd.c0000644000076400001440000001511410743374615011741 0ustar elsausers/* * vcd.c: main * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include #include #include #include #include "functions.h" #include "i18n.h" #include "menu.h" #include "menucontrol.h" #include "psdcontrol.h" #include "psd.h" #include "setup.h" static const char *VERSION = "0.9"; static const char *DESCRIPTION = "VideoCD Player"; static const char *MAINMENUENTRY = "VideoCD"; class cPluginVcd : public cPlugin { private: cVcd *vcd; const char *option_vcd; public: cPluginVcd(void); virtual ~cPluginVcd(); virtual const char *Version(void) { return VERSION; } virtual const char *Description(void); virtual const char *CommandLineHelp(void); virtual bool ProcessArgs(int argc, char *argv[]); virtual bool Start(void); virtual void Housekeeping(void); virtual const char *MainMenuEntry(void); virtual cOsdMenu *MainMenuAction(void); virtual cMenuSetupPage *SetupMenu(void); virtual bool SetupParse(const char *Name, const char *Value); }; cPluginVcd::cPluginVcd(void) { vcd = NULL; option_vcd = NULL; } cPluginVcd::~cPluginVcd() { delete vcd; } const char *cPluginVcd::Description(void) { if (option_vcd) { char *buf = NULL; asprintf(&buf, "%s (%s)", DESCRIPTION, option_vcd); return buf; } else return DESCRIPTION; } const char *cPluginVcd::CommandLineHelp(void) { return " -v DEV, --vcd=DEV use DEV as the CD-ROM device (default is /dev/cdrom)\n"; } bool cPluginVcd::ProcessArgs(int argc, char *argv[]) { static struct option long_options[] = { { "vcd", required_argument, NULL, 'v' }, { NULL } }; int c; while ((c = getopt_long(argc, argv, "v:", long_options, NULL)) != -1) { switch (c) { case 'v': option_vcd = optarg; break; default: return false; } } return true; } bool cPluginVcd::Start(void) { RegisterI18n(Phrases); if (option_vcd) vcd = new cVcd(option_vcd); else vcd = new cVcd("/dev/cdrom"); return true; } void cPluginVcd::Housekeeping(void) { } const char *cPluginVcd::MainMenuEntry(void) { if (VcdSetupData.HideMainMenuEntry) return NULL; if (vcd->DriveExists()) { if (option_vcd) { char *buf = NULL; asprintf(&buf, "%s (%s)", tr(MAINMENUENTRY), option_vcd); return buf; } else return tr(MAINMENUENTRY); } else return NULL; } cOsdMenu *cPluginVcd::MainMenuAction(void) { if (vcd->getVCD() && vcd->DiscOk()) { int psd_size = 0; if (vcd->Open()) { vcd->readTOC(CDROM_LBA); vcd->readSectorXA21(INFO_VCD_LBA, &(vcd->vcdInfo)); vcd->readSectorXA21(ENTRIES_VCD_LBA, &(vcd->vcdEntries)); for (int i=0; ireadSectorXA21(LOT_VCD_LBA+i, &(vcd->vcdLot.list_id_offset[i*CD_XA21_DATASIZE/2])); psd_size = max((int)U32_TO_LE(vcd->vcdInfo.psd_size), PSD_VCD_MAX_SIZE*CD_XA21_DATASIZE); for (int i=0; ireadSectorXA21(PSD_VCD_LBA+i, &(vcd->vcdPsd[i*CD_XA21_DATASIZE])); } else psd_size = max((int)U32_TO_LE(vcd->vcdInfo.psd_size), PSD_VCD_MAX_SIZE*CD_XA21_DATASIZE); if (VcdSetupData.AutostartReplay) { if (vcd->isLabel() && vcd->getTracks()>0) { if (VcdSetupData.PlaySequenceReplay && psd_size) { int offs = vcd->vcdInfo.offset_multiplier * U16_TO_LE(vcd->vcdLot.list_id_offset[0]); union psd_vcd *psdVcd = (union psd_vcd*)(&(vcd->vcdPsd[offs])); if (psdVcd->header==PLAY_LIST_HEADER) { __u16 item = U16_TO_LE(psdVcd->play.play_item[0]); if (PLAY_ITEM_TYP(item)==piTrack) cPsdVcdControl::SetTrack(PLAY_ITEM_NO(item), vcd, psdVcd); else if (PLAY_ITEM_TYP(item)==piEntry) cPsdVcdControl::SetEntry(PLAY_ITEM_NO(item), vcd, psdVcd); else if (PLAY_ITEM_TYP(item)==piSpi) cPsdSpiControl::SetItem(PLAY_ITEM_NO(item), vcd, psdVcd); } else if (psdVcd->header==SELECTION_LIST_HEADER) { __u16 item = U16_TO_LE(psdVcd->selection.play_item); if (PLAY_ITEM_TYP(item)==piTrack) cPsdVcdControl::SetTrack(PLAY_ITEM_NO(item), vcd, psdVcd); else if (PLAY_ITEM_TYP(item)==piEntry) cPsdVcdControl::SetEntry(PLAY_ITEM_NO(item), vcd, psdVcd); else if (PLAY_ITEM_TYP(item)==piSpi) cPsdSpiControl::SetItem(PLAY_ITEM_NO(item), vcd, psdVcd); } dsyslog("VCD: Autoplay, PSD"); } else { cMenuVcdControl::SetTrack(1, vcd); dsyslog("VCD: Autoplay, no PSD"); } } else Skins.Message(mtInfo, tr("No VideoCD detected")); } else { if (VcdSetupData.PlaySequenceReplay && psd_size) return new cVcdPsd(vcd); else return new cMenuVcd(vcd); } } else Skins.Message(mtInfo, tr("No disc inserted")); return NULL; } cMenuSetupPage *cPluginVcd::SetupMenu(void) { return new cVcdSetupMenu(vcd); } bool cPluginVcd::SetupParse(const char *Name, const char *Value) { if (!strcasecmp(Name, "DriveSpeed")) VcdSetupData.DriveSpeed = atoi(Value); else if (!strcasecmp(Name, "BrokenMode")) VcdSetupData.BrokenMode = atoi(Value); else if (!strcasecmp(Name, "HideMainMenuEntry")) VcdSetupData.HideMainMenuEntry = atoi(Value); else if (!strcasecmp(Name, "PlayTracksContinuously")) VcdSetupData.PlayTracksContinuously = atoi(Value); else if (!strcasecmp(Name, "AutostartReplay")) VcdSetupData.AutostartReplay = atoi(Value); else if (!strcasecmp(Name, "PlaySequenceReplay")) VcdSetupData.PlaySequenceReplay = atoi(Value); else return false; return true; } VDRPLUGINCREATOR(cPluginVcd); // Don't touch this! vcd-0.9/player.h0000644000076400001440000000402710743375545012472 0ustar elsausers/* * player.h: Player core * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_PLAYER_H #define __VCD_PLAYER_H #include #include #include #include #include "functions.h" #define NO_PICTURE 0 #define PICTURE_SC 0x00 #define USER_DATA_SC 0xB2 #define SEQUENCE_HEADER_SC 0xB3 #define EXTENSION_SC 0xB5 #define GROUP_OF_PICT_SC 0xB8 #define PACK_SC 0xBA #define SYSTEM_HEADER_SC 0xBB #define AUDIO_STREAM_SC 0xC0 #define VIDEO_STREAM_SC 0xE0 #define SC_MASK 0xE0 class cVcdPlayer; class cVcdPlayerControl : public cControl { private: cVcdPlayer *player; public: cVcdPlayerControl(int Track, cVcd *Vcd); cVcdPlayerControl(int Track, cVcd *Vcd, int Lba, int Loop, int AutoWait); virtual ~cVcdPlayerControl(); bool Active(void); int GetTrack(void); void Stop(void); void Pause(void); void Play(void); void Forward(void); void Backward(void); void SkipSeconds(int Seconds); bool SkipTracks(int Tracks); bool SkipEntries(int Entries); void Goto(int Index, bool Still = false); void GotoTrack(int Track); void GotoEntry(int Entry); const char *DeviceName(void); }; #endif //__VCD_PLAYER_H vcd-0.9/psdcontrol.c0000644000076400001440000003360410743374375013363 0ustar elsausers/* * psdcontrol.c: PSD control of VCD replay * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include #include #include #include #include #include "i18n.h" #include "functions.h" #include "setup.h" #include "psdcontrol.h" #define GOTO_SELF (psdVcd->header==PLAY_LIST_HEADER \ ? U16_TO_LE(vcd->vcdLot.list_id_offset[U16_TO_LE(psdVcd->play.list_id)]) \ : psdVcd->header==SELECTION_LIST_HEADER \ ? U16_TO_LE(vcd->vcdLot.list_id_offset[U16_TO_LE(psdVcd->selection.list_id)]) \ : 0xFFFF) #define GOTO_NEXT (psdVcd->header==PLAY_LIST_HEADER \ ? U16_TO_LE(psdVcd->play.next_list_offset) \ : psdVcd->header==SELECTION_LIST_HEADER \ ? U16_TO_LE(psdVcd->selection.next_list_offset) \ : 0xFFFF) #define GOTO_PREVIOUS (psdVcd->header==PLAY_LIST_HEADER \ ? U16_TO_LE(psdVcd->play.previous_list_offset) \ : psdVcd->header==SELECTION_LIST_HEADER \ ? U16_TO_LE(psdVcd->selection.previous_list_offset) \ : 0xFFFF) #define GOTO_RETURN (psdVcd->header==PLAY_LIST_HEADER \ ? U16_TO_LE(psdVcd->play.return_list_offset) \ : psdVcd->header==SELECTION_LIST_HEADER \ ? U16_TO_LE(psdVcd->selection.return_list_offset) \ : 0xFFFF) #define GOTO_DEFAULT (psdVcd->header==SELECTION_LIST_HEADER \ ? U16_TO_LE(psdVcd->selection.default_list_offset) \ : 0xFFFF) #define GOTO_TIMEOUT (psdVcd->header==PLAY_LIST_HEADER \ ? U16_TO_LE(psdVcd->play.next_list_offset) \ : psdVcd->header==SELECTION_LIST_HEADER \ ? U16_TO_LE(psdVcd->selection.timeout_list_offset) \ : 0xFFFF) #define GOTO_NUMERIC(b) (psdVcd->header==SELECTION_LIST_HEADER \ ? psdVcd->selection.nos>(b-1) \ ? U16_TO_LE(psdVcd->selection.selection_offset[(b-1)]) \ : 0xFFFF \ : 0xFFFF) #define LIST_LOOP (psdVcd->header==SELECTION_LIST_HEADER \ ? (PsdVcd->selection.loop_count & 0x7F) \ : -1) #define AUTO_WAIT (psdVcd->header==PLAY_LIST_HEADER \ ? PLAY_ITEM_WAIT(psdVcd->play.auto_pause_wait_time) \ : -1) // --- cPsdSpiControl ----------------------------------------------------------- int cPsdSpiControl::spi = 0; cVcd *cPsdSpiControl::vcd = 0; union psd_vcd *cPsdSpiControl::psdVcd = 0; int cPsdSpiControl::playInit = -1; int cPsdSpiControl::playTime = -1; int cPsdSpiControl::waitInit = -1; int cPsdSpiControl::waitTime = -1; cPsdSpiControl::cPsdSpiControl(void) : cVcdViewerControl(spi, vcd) { } cPsdSpiControl::cPsdSpiControl(int Loop) : cVcdViewerControl(spi, vcd) { } cPsdSpiControl::~cPsdSpiControl() { cStatus::MsgReplaying(this, NULL, NULL, true); } void cPsdSpiControl::SetItem(int Spi, cVcd *Vcd, union psd_vcd *PsdVcd) { cControl *control = cControl::Control(); if (control && typeid(*control)==typeid(cPsdVcdControl)) static_cast(control)->Stop(); psdVcd = PsdVcd; playInit = time(NULL); playTime = (psdVcd->header==PLAY_LIST_HEADER ? U16_TO_LE(psdVcd->play.playing_time) / 15 : -1); waitInit = -1; waitTime = (psdVcd->header==PLAY_LIST_HEADER ? PLAY_ITEM_WAIT(psdVcd->play.play_item_wait_time) : psdVcd->header==SELECTION_LIST_HEADER ? PLAY_ITEM_WAIT(psdVcd->selection.timeout_wait_time) : -1); if (control && typeid(*control)==typeid(cPsdSpiControl) && strcmp(Vcd->DeviceName(),static_cast(control)->DeviceName())==0) { if (static_cast(control)->Active()) { static_cast(control)->GotoItem(Spi); return; } delete static_cast(control); } spi = Spi; vcd = Vcd; cControl::Launch(new cPsdSpiControl(LIST_LOOP)); } bool cPsdSpiControl::GotoListOffset(__u16 Offs) { if (Offs==0xFFFF) return false; int offs = vcd->vcdInfo.offset_multiplier * Offs; union psd_vcd *PsdVcd = (union psd_vcd*)(&(vcd->vcdPsd[offs])); __u16 item; __u16 list_id; if (PsdVcd->header==PLAY_LIST_HEADER) { item = U16_TO_LE(PsdVcd->play.play_item[0]); list_id = U16_TO_LE(PsdVcd->play.list_id); } else if (PsdVcd->header==SELECTION_LIST_HEADER) { item = U16_TO_LE(PsdVcd->selection.play_item); list_id = U16_TO_LE(PsdVcd->selection.list_id); } else return false; dsyslog("VCD: PSD list_id %d", list_id); if (PLAY_ITEM_TYP(item)==piTrack) cPsdVcdControl::SetTrack(PLAY_ITEM_NO(item), vcd, PsdVcd); else if (PLAY_ITEM_TYP(item)==piEntry) cPsdVcdControl::SetEntry(PLAY_ITEM_NO(item), vcd, PsdVcd); else if (PLAY_ITEM_TYP(item)==piSpi) SetItem(PLAY_ITEM_NO(item), vcd, PsdVcd); return true; } eOSState cPsdSpiControl::ProcessKey(eKeys Key) { int playTick = time(NULL) - playInit; if (!Active() || (playTick==playTime)) { if (waitTime>0) { if (waitInit==-1) { waitInit = time(NULL); } else { int waitTick = time(NULL) - waitInit; if (waitTick>=waitTime) { if (!GotoListOffset(GOTO_TIMEOUT)) return osEnd; } } } else if (waitTime==0) { if (!GotoListOffset(GOTO_TIMEOUT)) return osEnd; } else if (waitTime==-1) ; else if (!GotoListOffset(GOTO_NEXT)) return osEnd; } if (Still()) { if (waitTime>0) { int waitTick = time(NULL) - playInit; if (waitTick>=waitTime) { if (!GotoListOffset(GOTO_TIMEOUT)) return osEnd; } } else if (waitTime==0) { if (!GotoListOffset(GOTO_TIMEOUT)) return osEnd; } } switch (Key) { case k1: GotoListOffset(GOTO_NUMERIC(1)); break; case k2: GotoListOffset(GOTO_NUMERIC(2)); break; case k3: GotoListOffset(GOTO_NUMERIC(3)); break; case k4: GotoListOffset(GOTO_NUMERIC(4)); break; case k5: GotoListOffset(GOTO_NUMERIC(5)); break; case k6: GotoListOffset(GOTO_NUMERIC(6)); break; case k7: GotoListOffset(GOTO_NUMERIC(7)); break; case k8: GotoListOffset(GOTO_NUMERIC(8)); break; case k9: GotoListOffset(GOTO_NUMERIC(9)); break; case kOk: GotoListOffset(GOTO_DEFAULT); break; case kLeft: GotoListOffset(GOTO_PREVIOUS); break; case kRight: GotoListOffset(GOTO_NEXT); break; case kBack: GotoListOffset(GOTO_RETURN); break; case kBlue: Hide(); Stop(); vcd->Close(); return osEnd; default: return osUnknown; } return osContinue; } // --- cPsdVcdControl -------------------------------------------------------- int cPsdVcdControl::track = 0; cVcd *cPsdVcdControl::vcd = 0; union psd_vcd *cPsdVcdControl::psdVcd = 0; int cPsdVcdControl::playInit = -1; int cPsdVcdControl::playTime = -1; int cPsdVcdControl::waitInit = -1; int cPsdVcdControl::waitTime = -1; cPsdVcdControl::cPsdVcdControl(void) : cVcdPlayerControl(track, vcd) { } cPsdVcdControl::cPsdVcdControl(int Lba, int Loop, int AutoWait) : cVcdPlayerControl(track, vcd, Lba, Loop, AutoWait) { } cPsdVcdControl::~cPsdVcdControl() { cStatus::MsgReplaying(this, NULL, NULL, true); } void cPsdVcdControl::SetTrack(int Track, cVcd *Vcd, union psd_vcd *PsdVcd) { cControl *control = cControl::Control(); if (control && typeid(*control)==typeid(cPsdSpiControl)) static_cast(control)->Stop(); psdVcd = PsdVcd; playInit = time(NULL); playTime = (psdVcd->header==PLAY_LIST_HEADER ? U16_TO_LE(psdVcd->play.playing_time) / 15 : -1); waitInit = -1; waitTime = (psdVcd->header==PLAY_LIST_HEADER ? PLAY_ITEM_WAIT(psdVcd->play.play_item_wait_time) : psdVcd->header==SELECTION_LIST_HEADER ? PLAY_ITEM_WAIT(psdVcd->selection.timeout_wait_time) : -1); if (control && typeid(*control)==typeid(cPsdVcdControl) && strcmp(Vcd->DeviceName(),static_cast(control)->DeviceName())==0) { if (static_cast(control)->Active()) { static_cast(control)->GotoTrack(Track); return; } delete static_cast(control); } track = Track; vcd = Vcd; cControl::Launch(new cPsdVcdControl( vcd->vcdEntry[Track].cdte_addr.lba, LIST_LOOP, AUTO_WAIT )); } void cPsdVcdControl::SetEntry(int Entry, cVcd *Vcd, union psd_vcd *PsdVcd) { cControl *control = cControl::Control(); if (control && typeid(*control)==typeid(cPsdSpiControl)) static_cast(control)->Stop(); psdVcd = PsdVcd; playInit = time(NULL); playTime = (psdVcd->header==PLAY_LIST_HEADER ? U16_TO_LE(psdVcd->play.playing_time) / 15 : -1); waitInit = -1; waitTime = (psdVcd->header==PLAY_LIST_HEADER ? PLAY_ITEM_WAIT(psdVcd->play.play_item_wait_time) : PsdVcd->header==SELECTION_LIST_HEADER ? PLAY_ITEM_WAIT(psdVcd->selection.timeout_wait_time) : -1); if (control && typeid(*control)==typeid(cPsdVcdControl) && strcmp(Vcd->DeviceName(),static_cast(control)->DeviceName())==0) { if (static_cast(control)->Active()) { static_cast(control)->GotoEntry(Entry); return; } delete static_cast(control); } track = bcd_to_bin(Vcd->vcdEntries.entry[Entry].track_no) - 1; vcd = Vcd; cControl::Launch(new cPsdVcdControl( bcdmsf_to_lba(vcd->vcdEntries.entry[Entry].entry_msf), LIST_LOOP, AUTO_WAIT )); } bool cPsdVcdControl::GotoListOffset(__u16 Offs) { if (Offs==0xFFFF) return false; int offs = vcd->vcdInfo.offset_multiplier * Offs; union psd_vcd *PsdVcd = (union psd_vcd*)(&(vcd->vcdPsd[offs])); __u16 item; __u16 list_id; if (PsdVcd->header==PLAY_LIST_HEADER) { item = U16_TO_LE(PsdVcd->play.play_item[0]); list_id = U16_TO_LE(PsdVcd->play.list_id); } else if (PsdVcd->header==SELECTION_LIST_HEADER) { item = U16_TO_LE(PsdVcd->selection.play_item); list_id = U16_TO_LE(PsdVcd->selection.list_id); } else return false; dsyslog("VCD: PSD item %d", list_id); if (PLAY_ITEM_TYP(item)==piTrack) SetTrack(PLAY_ITEM_NO(item), vcd, PsdVcd); else if (PLAY_ITEM_TYP(item)==piEntry) SetEntry(PLAY_ITEM_NO(item), vcd, PsdVcd); else if (PLAY_ITEM_TYP(item)==piSpi) cPsdSpiControl::SetItem(PLAY_ITEM_NO(item), vcd, PsdVcd); return true; } eOSState cPsdVcdControl::ProcessKey(eKeys Key) { int playTick = time(NULL) - playInit; if (!Active() || (playTick==playTime)) { if (waitTime>0) { if (waitInit==-1) { waitInit = time(NULL); } else { int waitTick = time(NULL) - waitInit; if (waitTick>=waitTime) { if (!GotoListOffset(GOTO_TIMEOUT)) return osEnd; } } } else if (waitTime==0) { if (!GotoListOffset(GOTO_TIMEOUT)) return osEnd; } else if (waitTime==-1) ; else if (!GotoListOffset(GOTO_NEXT)) return osEnd; } switch (Key) { case k1: GotoListOffset(GOTO_NUMERIC(1)); break; case k2: GotoListOffset(GOTO_NUMERIC(2)); break; case k3: GotoListOffset(GOTO_NUMERIC(3)); break; case k4: GotoListOffset(GOTO_NUMERIC(4)); break; case k5: GotoListOffset(GOTO_NUMERIC(5)); break; case k6: GotoListOffset(GOTO_NUMERIC(6)); break; case k7: GotoListOffset(GOTO_NUMERIC(7)); break; case k8: GotoListOffset(GOTO_NUMERIC(8)); break; case k9: GotoListOffset(GOTO_NUMERIC(9)); break; case kOk: GotoListOffset(GOTO_DEFAULT); break; case kLeft: GotoListOffset(GOTO_PREVIOUS); break; case kRight: GotoListOffset(GOTO_NEXT); break; case kBack: GotoListOffset(GOTO_RETURN); break; case kPause: case kDown: Pause(); break; case kGreen|k_Repeat: case kGreen: SkipSeconds(-60); break; case kYellow|k_Repeat: case kYellow: SkipSeconds(60); break; case kBlue: Hide(); Stop(); vcd->Close(); return osEnd; default: return osUnknown; } return osContinue; } vcd-0.9/menu.c0000644000076400001440000001751710744677002012137 0ustar elsausers/* * menu.c: OSD menu * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include #include #include #include #include "i18n.h" #include "menu.h" #include "functions.h" #include "setup.h" #include "menucontrol.h" // --- cMenu ----------------------------------------------------------------- cMenu::cMenu(cVcd *Vcd) : cOsdMenu(tr("VideoCD")) { char *buf = 0; vcd = Vcd; memset(vcdTitle,0,17); validLabel = vcd->isLabel(); if (validLabel) { strncpy(vcdTitle,vcd->vcdInfo.album_id,16); asprintf(&buf, "VCD %d/%d %s", U16_TO_LE(vcd->vcdInfo.album_sequence), U16_TO_LE(vcd->vcdInfo.album_volumes), vcdTitle); SetTitle(buf); dsyslog("VCD: %d/%d Title: %s Tracks: %d Entries: %d Items: %d PSD: %d", U16_TO_LE(vcd->vcdInfo.album_sequence), U16_TO_LE(vcd->vcdInfo.album_volumes), vcdTitle, vcd->getTracks(), U16_TO_LE(vcd->vcdEntries.entries), U16_TO_LE(vcd->vcdInfo.max_segment_number), U32_TO_LE(vcd->vcdInfo.psd_size)); } else if (VcdSetupData.BrokenMode) { validLabel = true; // enable anyway asprintf(&buf, "noVCD"); SetTitle(buf); } else Add(new cOsdItem(tr("No VideoCD detected"))); } cMenu::~cMenu() { } eOSState cMenu::Eject(void) { if (vcd->DiscOk()) { dsyslog("VCD: Eject"); memset(&(vcd->vcdEntries), 0, sizeof(vcd->vcdEntries)); vcd->Eject(); vcd->Close(); return osStopReplay; } return osContinue; } void cMenu::SetHelp(const char *Red, const char *Green, const char *Blue) { cOsdMenu::SetHelp( Red, Green, vcd->DiscOk() ? tr("Eject") : NULL, Blue ); } eOSState cMenu::ProcessKey(eKeys Key) { eOSState state = cOsdMenu::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case kYellow: return Eject(); default: break; } } return state; } // --- cMenuSpiItem ---------------------------------------------------------- class cMenuSpiItem : public cOsdItem { private: int spi; public: cMenuSpiItem(int Spi, int Size, __u8 Contents); int Spi(void) { return spi; } }; cMenuSpiItem::cMenuSpiItem(int Spi, int Size, __u8 Contents) { spi = Spi; char *buffer = NULL; asprintf(&buffer, "Item %04d/%d %s%s%s%s%s%s%s%s%s", Spi, Size, SPI_AUDIO(Contents) == SPI_1CH_AUDIO ? "Audio " : "", SPI_AUDIO(Contents) == SPI_2CH_AUDIO ? "2Ch.Audio " : "", SPI_AUDIO(Contents) == SPI_MUL_AUDIO ? "Multich.Audio " : "", SPI_VIDEO(Contents) == SPI_NTSC_STILL ? "NTSC Image " : "", SPI_VIDEO(Contents) == SPI_NTSC_STILL2 ? "NTSC Image+ " : "", SPI_VIDEO(Contents) == SPI_NTSC_VIDEO ? "NTSC Video " : "", SPI_VIDEO(Contents) == SPI_PAL_STILL ? "PAL Image " : "", SPI_VIDEO(Contents) == SPI_PAL_STILL2 ? "PAL Image+ " : "", SPI_VIDEO(Contents) == SPI_PAL_VIDEO ? "PAL Video " : "" ); SetText(buffer, false); } // --- cMenuSpi -------------------------------------------------------------- cMenuSpi::cMenuSpi(cVcd *Vcd) : cMenu(Vcd) { validItems = validLabel ? ListItems() : false; SetHelp( validItems ? tr("Key$Play") : NULL, NULL, vcd->getTracks() ? tr("Tracks") : NULL ); Display(); } cMenuSpi::~cMenuSpi() { } bool cMenuSpi::ListItems(void) { if (U16_TO_LE(vcd->vcdInfo.max_segment_number)>0) { int size = 1; for (int i=0; ivcdInfo.max_segment_number); i++) { if (vcd->vcdInfo.spi_contents[i+1] & SPI_CONTINUED) size++; else if (size>0) { Add(new cMenuSpiItem(i+1-size, size, vcd->vcdInfo.spi_contents[i+1-size])); size = 1; } } return true; } return false; } eOSState cMenuSpi::Play(void) { if (validItems) { cMenuSpiItem *msi = (cMenuSpiItem *)Get(Current()); if (msi) { cMenuSpiControl::SetItem(msi->Spi(), vcd); dsyslog("VCD: Play Item %d", msi->Spi()); return osEnd; } } return osContinue; } eOSState cMenuSpi::ProcessKey(eKeys Key) { eOSState state = cMenu::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case kOk: case kRed: return Play(); case kBlue: return osBack; default: break; } } return state; } // --- cMenuVcdItem ---------------------------------------------------------- class cMenuVcdItem : public cOsdItem { private: int track; public: cMenuVcdItem(int Track, struct cdrom_msf0 strt, struct cdrom_msf0 len, bool Pal); cMenuVcdItem(int Track, struct cdrom_msf0 strt, struct cdrom_msf0 len); int Track(void) { return track; } }; cMenuVcdItem::cMenuVcdItem(int Track, struct cdrom_msf0 strt, struct cdrom_msf0 len, bool Pal) { track = Track; char *buffer = NULL; asprintf(&buffer, "Track %02d %02d:%02d.%02d %02d:%02d.%02d %s", Track, strt.minute, strt.second, strt.frame, len.minute, len.second, len.frame, Pal ? "PAL" : "NTSC"); SetText(buffer, false); } cMenuVcdItem::cMenuVcdItem(int Track, struct cdrom_msf0 strt, struct cdrom_msf0 len) { track = Track; char *buffer = NULL; asprintf(&buffer, "Track %02d %02d:%02d.%02d %02d:%02d.%02d", Track+1, strt.minute, strt.second, strt.frame, len.minute, len.second, len.frame); SetText(buffer, false); } // --- cMenuVcd -------------------------------------------------------------- cMenuVcd::cMenuVcd(cVcd *Vcd) : cMenu(Vcd) { validTracks = validLabel ? ListTracks() : false; spi = !VcdSetupData.BrokenMode && U16_TO_LE(vcd->vcdInfo.max_segment_number) && validLabel; SetHelp( validTracks ? tr("Key$Play") : NULL, NULL, spi ? tr("SPI") : NULL ); Display(); } cMenuVcd::~cMenuVcd() { } bool cMenuVcd::ListTracks(void) { if (VcdSetupData.BrokenMode) { for (int i=0; i<=vcd->getTracks(); i++) Add(new cMenuVcdItem(i, lba_to_msf(vcd->vcdEntry[i].cdte_addr.lba), lba_to_msf(vcd->vcdEntry[i+1].cdte_addr.lba - vcd->vcdEntry[i].cdte_addr.lba) )); return true; } else if (vcd->getTracks()>0) { for (int i=1; i<=vcd->getTracks(); i++) Add(new cMenuVcdItem(i, lba_to_msf(vcd->vcdEntry[i].cdte_addr.lba - vcd->vcdEntry[1].cdte_addr.lba), lba_to_msf(vcd->vcdEntry[i+1].cdte_addr.lba - vcd->vcdEntry[i].cdte_addr.lba), vcd->vcdInfo.video_type_map[(i-1)/8] & (1 << (i-1)%8) )); return true; } return false; } eOSState cMenuVcd::Play(void) { if (validTracks) { cMenuVcdItem *mvi = (cMenuVcdItem *)Get(Current()); if (mvi) { cMenuVcdControl::SetTrack(mvi->Track(), vcd); dsyslog("VCD: Play Track %d", mvi->Track() + (VcdSetupData.BrokenMode ? 1 : 0)); return osEnd; } } return osContinue; } eOSState cMenuVcd::ProcessKey(eKeys Key) { eOSState state = cMenu::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case kOk: case kRed: return Play(); case kBlue: if (!spi) break; return AddSubMenu(new cMenuSpi(vcd)); case kMenu: return osEnd; default: break; } } return state; } vcd-0.9/setup.c0000644000076400001440000000467210743150360012321 0ustar elsausers/* * setup.c: Setup the plugin * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include #include "setup.h" #include "i18n.h" cVcdSetupData VcdSetupData; // --- cVcdSetupData --------------------------------------------------------- cVcdSetupData::cVcdSetupData(void) { DriveSpeed = 2; BrokenMode = 0; HideMainMenuEntry = 0; PlayTracksContinuously = 1; AutostartReplay = 0; PlaySequenceReplay = 0; } // --- cVcdSetupMenu --------------------------------------------------------- cVcdSetupMenu::cVcdSetupMenu(cVcd *Vcd) { vcd = Vcd; setupData = VcdSetupData; SetSection(tr("VCD")); Add(new cMenuEditIntItem(tr("Setup.VCD$Drive speed"), &setupData.DriveSpeed, 1, 50)); Add(new cMenuEditBoolItem(tr("Setup.VCD$Broken mode"), &setupData.BrokenMode)); Add(new cMenuEditBoolItem(tr("Setup.VCD$Hide main menu entry"), &setupData.HideMainMenuEntry)); Add(new cMenuEditBoolItem(tr("Setup.VCD$Play tracks continuously"), &setupData.PlayTracksContinuously)); Add(new cMenuEditBoolItem(tr("Setup.VCD$Autostart replay"), &setupData.AutostartReplay)); Add(new cMenuEditBoolItem(tr("Setup.VCD$Play sequence replay"), &setupData.PlaySequenceReplay)); } void cVcdSetupMenu::Store(void) { VcdSetupData = setupData; SetupStore("DriveSpeed", VcdSetupData.DriveSpeed); vcd->SetDriveSpeed(VcdSetupData.DriveSpeed); SetupStore("BrokenMode", VcdSetupData.BrokenMode); SetupStore("HideMainMenuEntry", VcdSetupData.HideMainMenuEntry); SetupStore("PlayTracksContinuously", VcdSetupData.PlayTracksContinuously); SetupStore("AutostartReplay", VcdSetupData.AutostartReplay); SetupStore("PlaySequenceReplay", VcdSetupData.PlaySequenceReplay); } vcd-0.9/functions.c0000644000076400001440000001036010743371410013161 0ustar elsausers/* * functions.c: Functions for handling VCDs, SVCDs, ... * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include #include #include #include #include "functions.h" #include "setup.h" __u8 bcd_to_bin(__u8 bcd) { return 10 * (bcd >> 4) + (bcd & 0x0F); } int bcdmsf_to_lba(struct cdrom_msf0 msf0) { return bcd_to_bin(msf0.frame) + CD_FRAMES * ( bcd_to_bin(msf0.second) + CD_SECS * bcd_to_bin(msf0.minute) ) - CD_MSF_OFFSET; } struct cdrom_msf0 lba_to_msf(int lba) { struct cdrom_msf0 msf0; msf0.frame = lba % CD_FRAMES; lba /= CD_FRAMES; msf0.second = lba % CD_SECS; msf0.minute = lba / CD_SECS; return msf0; } // --- cVcd ------------------------------------------------------------------ cVcd *cVcd::getVCD(void) { if (!vcdInstance) new cVcd; return vcdInstance; } cVcd::cVcd(void) { cdrom = 0; vcdInstance = this; deviceName = strdup("/dev/cdrom"); } cVcd::cVcd(const char *DeviceName) { cdrom = 0; vcdInstance = this; deviceName = strdup(DeviceName); } cVcd::~cVcd() { Close(); } int cVcd::Command(int Cmd) { int result = -1; int f; if ((f = open(deviceName, O_RDONLY | O_NONBLOCK)) > 0) { result = ioctl(f, Cmd, 0); close(f); } return result; } bool cVcd::DriveExists(void) { return access(deviceName, F_OK) == 0; } bool cVcd::DiscOk(void) { return Command(CDROM_DRIVE_STATUS) == CDS_DISC_OK; } void cVcd::Eject(void) { if (vcdInstance) vcdInstance->Close(); Command(CDROMEJECT); } bool cVcd::Open(void) { if (!cdrom) { cdrom = open(deviceName, O_RDONLY | O_NONBLOCK); SetDriveSpeed(VcdSetupData.DriveSpeed); return true; } return false; } void cVcd::Close(void) { if (cdrom) { SetDriveSpeed(0); close(cdrom); } cdrom = 0; tracks = 0; for (int i=0; i<100; i++) memset(&vcdEntry[i], 0, sizeof(vcdEntry)); memset(&vcdInfo, 0, sizeof(vcdInfo)); memset(&vcdEntries, 0, sizeof(vcdEntries)); memset(&vcdLot, 0, sizeof(vcdLot)); memset(&vcdPsd, 0, sizeof(vcdPsd)); } void cVcd::SetDriveSpeed(int DriveSpeed) { ioctl(cdrom, CDROM_SELECT_SPEED, DriveSpeed); } int cVcd::readTOC(__u8 format) { struct cdrom_tochdr tochdr; int i; tracks = -1; if (ioctl(cdrom, CDROMREADTOCHDR, &tochdr) == -1) return -1; for (i=tochdr.cdth_trk0; i<=tochdr.cdth_trk1; i++) { vcdEntry[i-1].cdte_track = i; vcdEntry[i-1].cdte_format = format; if (ioctl(cdrom, CDROMREADTOCENTRY, &vcdEntry[i-1]) == -1) return -1; } vcdEntry[tochdr.cdth_trk1].cdte_track = CDROM_LEADOUT; vcdEntry[tochdr.cdth_trk1].cdte_format = format; if (ioctl(cdrom, CDROMREADTOCENTRY, &vcdEntry[tochdr.cdth_trk1]) == -1) return -1; tracks = tochdr.cdth_trk1 - 1; return tochdr.cdth_trk1 - 1; } bool cVcd::readSectorRaw(int lba, void *sect) { struct cdrom_msf0 msf0 = lba_to_msf(lba+CD_MSF_OFFSET); memcpy(sect, &msf0, sizeof(struct cdrom_msf0)); if (ioctl(cdrom, CDROMREADRAW, sect) < 0) return false; return true; } bool cVcd::readSectorXA21(int lba, void *data) { struct cdsector_xa21 sect; if (readSectorRaw(lba, §) == false) return false; memcpy(data, sect.data, sizeof(sect.data)); return true; } bool cVcd::isLabel(void) { if (!vcdInstance) return false; if (strncmp(vcdInfo.system_id,"VIDEO_CD",8)==0) return true; if (strncmp(vcdInfo.system_id,"SUPERVCD",8)==0) return true; if (strncmp(vcdInfo.system_id,"HQ-VCD ",8)==0) return true; return false; } vcd-0.9/i18n.h0000644000076400001440000000176510743375476011766 0ustar elsausers/* * i18n.h: Internationalization * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_I18N_H #define __VCD_I18N_H #include extern const tI18nPhrase Phrases[]; #endif //__VCD_I18N_H vcd-0.9/Makefile0000644000076400001440000000413710743421343012453 0ustar elsausers# # Makefile for a Video Disk Recorder plugin # # $Id$ # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. # By default the main source file also carries this name. # PLUGIN = vcd ### The version number of this plugin (taken from the main source file): VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g') ### The C++ compiler and options: CXX ?= g++ CXXFLAGS ?= -O2 -Wall -Woverloaded-virtual ### The directory environment: VDRDIR = ../../.. LIBDIR = ../../lib TMPDIR = /tmp ### Enable this for debugging the plugin # DEFINES += -DDEBUG_VCD ### Enable this to let the plugin strip the PES headers from stillimage frames # DEFINES += -DSTRIP_STILLIMAGE_PES_HEADER ### Allow user defined options to overwrite defaults: -include $(VDRDIR)/Make.config ### The version number of VDR (taken from VDR's "config.h"): APIVERSION = $(shell grep 'define APIVERSION ' $(VDRDIR)/config.h | awk '{ print $$3 }' | sed -e 's/"//g') ### The name of the distribution archive: ARCHIVE = $(PLUGIN)-$(VERSION) PACKAGE = vdr-$(ARCHIVE) ### Includes and Defines (add further entries here): INCLUDES = -I$(VDRINC) -I$(DVBDIR) DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE ### The object files (add further files here): OBJS = $(PLUGIN).o functions.o i18n.o menu.o player.o viewer.o setup.o menucontrol.o psd.o psdcontrol.o ### Implicit rules: %.o: %.c $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $< # Dependencies: MAKEDEP = $(CXX) -MM -MG DEPFILE = .dependencies $(DEPFILE): Makefile @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@ -include $(DEPFILE) ### Targets: all: libvdr-$(PLUGIN).so libvdr-$(PLUGIN).so: $(OBJS) $(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@ @cp $@ $(LIBDIR)/$@.$(APIVERSION) dist: clean @-rm -rf $(TMPDIR)/$(ARCHIVE) @mkdir $(TMPDIR)/$(ARCHIVE) @cp -a * $(TMPDIR)/$(ARCHIVE) @tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE) @-rm -rf $(TMPDIR)/$(ARCHIVE) @echo Distribution package created as $(PACKAGE).tgz clean: @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ vcd-0.9/menucontrol.c0000644000076400001440000002626710743375773013553 0ustar elsausers/* * menucontrol.c: Menu control of VCD replay * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include #include #include #include #include "i18n.h" #include "menu.h" #include "functions.h" #include "setup.h" #include "menucontrol.h" #define MODETIMEOUT 3 // seconds // --- cMenuSpiControl ------------------------------------------------------- int cMenuSpiControl::spi = 0; cVcd *cMenuSpiControl::vcd = 0; cMenuSpiControl::cMenuSpiControl(void) : cVcdViewerControl(spi, vcd) { displayReplay = NULL; visible = modeOnly = false; } cMenuSpiControl::~cMenuSpiControl() { cStatus::MsgReplaying(this, NULL, NULL, true); Stop(); } void cMenuSpiControl::SetItem(int Spi, cVcd *Vcd) { cControl *control = cControl::Control(); if (control && typeid(*control)==typeid(cMenuVcdControl)) static_cast(control)->Stop(); if (control && typeid(*control)==typeid(cMenuSpiControl) && strcmp(Vcd->DeviceName(),static_cast(control)->DeviceName())==0) { static_cast(control)->GotoItem(Spi); return; } spi = Spi; vcd = Vcd; cControl::Launch(new cMenuSpiControl); } void cMenuSpiControl::Hide(void) { if (visible) { delete displayReplay; #if APIVERSNUM >= 10500 SetNeedsFastResponse(false); #else needsFastResponse = false; #endif visible = false; modeOnly = false; } } eOSState cMenuSpiControl::ProcessKey(eKeys Key) { if (!Active()) return osEnd; switch (Key) { // Positioning: case k4: SkipItems(-1); break; case k5: ToggleStillRes(); break; case k6: SkipItems(1); break; case kBlue: Hide(); Stop(); vcd->Close(); return osEnd; default: { switch (Key) { // Editing: (?) default: { switch (Key) { // Menu control: case kOk: break; case kBack: Hide(); Stop(); vcd->Close(); return osEnd; default: return osUnknown; } } } } } return osContinue; } // --- cMenuVcdControl ------------------------------------------------------ int cMenuVcdControl::track = 0; cVcd *cMenuVcdControl::vcd = 0; char *cMenuVcdControl::title = 0; cMenuVcdControl::cMenuVcdControl(void) : cVcdPlayerControl(track, vcd) { displayReplay = NULL; visible = modeOnly = shown = displayFrames = false; lastCurrent = lastTotal = -1; lastPlay = lastForward = false; lastSpeed = -1; timeoutShow = 0; timeSearchActive = false; cStatus::MsgReplaying(this, "VCD", NULL, true); } cMenuVcdControl::~cMenuVcdControl() { Hide(); cStatus::MsgReplaying(this, NULL, NULL, false); Stop(); } void cMenuVcdControl::SetTrack(int Track, cVcd *Vcd) { cControl *control = cControl::Control(); if (control && typeid(*control)==typeid(cMenuSpiControl)) static_cast(control)->Stop(); if (control && typeid(*control)==typeid(cMenuVcdControl) && strcmp(Vcd->DeviceName(),static_cast(control)->DeviceName())==0) { static_cast(control)->GotoTrack(Track); return; } free(title); track = Track; vcd = Vcd; title = NULL; cControl::Launch(new cMenuVcdControl); } const int cMenuVcdControl::LastReplayed(void) { return track; } void cMenuVcdControl::ShowTimed(int Seconds) { if (modeOnly) Hide(); if (!visible) { shown = ShowProgress(true); timeoutShow = (shown && Seconds > 0) ? time(NULL) + Seconds : 0; } } void cMenuVcdControl::Show(void) { ShowTimed(); } void cMenuVcdControl::Hide(void) { if (visible) { delete displayReplay; #if APIVERSNUM >= 10500 SetNeedsFastResponse(false); #else needsFastResponse = false; #endif visible = false; modeOnly = false; lastPlay = lastForward = false; lastSpeed = -1; timeSearchActive = false; } } void cMenuVcdControl::ShowMode(void) { if (visible || Setup.ShowReplayMode && !cOsd::IsOpen()) { bool Play, Forward; int Speed; if (GetReplayMode(Play, Forward, Speed) && (!visible || Play != lastPlay || Forward != lastForward || Speed != lastSpeed)) { bool NormalPlay = (Play && Speed == -1); if (!visible) { if (NormalPlay) return; // no need to do indicate ">" unless there was a different mode displayed before visible = modeOnly = true; displayReplay = Skins.Current()->DisplayReplay(modeOnly); } if (modeOnly && !timeoutShow && NormalPlay) timeoutShow = time(NULL) + MODETIMEOUT; displayReplay->SetMode(Play, Forward, Speed); lastPlay = Play; lastForward = Forward; lastSpeed = Speed; } } } bool cMenuVcdControl::ShowProgress(bool Initial) { int Current, Total; if (GetIndex(Current, Total) && Total > 0) { if (!visible) { displayReplay = Skins.Current()->DisplayReplay(modeOnly); #if APIVERSNUM >= 10500 SetNeedsFastResponse(false); #else needsFastResponse = false; #endif visible = true; } if (Initial) lastCurrent = lastTotal = -1; if (title) displayReplay->SetTitle(title); if (Total != lastTotal) { displayReplay->SetTotal(IndexToHMSF(Total)); if (!Initial) displayReplay->Flush(); } if (Current != lastCurrent || Total != lastTotal) { displayReplay->SetProgress(Current, Total); if (!Initial) displayReplay->Flush(); displayReplay->SetCurrent(IndexToHMSF(Current, displayFrames)); displayReplay->Flush(); lastCurrent = Current; } lastTotal = Total; ShowMode(); return true; } return false; } void cMenuVcdControl::TimeSearchDisplay(void) { char buf[64]; strcpy(buf, tr("Jump: ")); int len = strlen(buf); char h10 = '0' + (timeSearchTime >> 24); char h1 = '0' + ((timeSearchTime & 0x00FF0000) >> 16); char m10 = '0' + ((timeSearchTime & 0x0000FF00) >> 8); char m1 = '0' + (timeSearchTime & 0x000000FF); char ch10 = timeSearchPos > 3 ? h10 : '-'; char ch1 = timeSearchPos > 2 ? h1 : '-'; char cm10 = timeSearchPos > 1 ? m10 : '-'; char cm1 = timeSearchPos > 0 ? m1 : '-'; sprintf(buf + len, "%c%c:%c%c", ch10, ch1, cm10, cm1); displayReplay->SetJump(buf); } void cMenuVcdControl::TimeSearchProcess(eKeys Key) { #define STAY_SECONDS_OFF_END 10 int Seconds = (timeSearchTime >> 24) * 36000 + ((timeSearchTime & 0x00FF0000) >> 16) * 3600 + ((timeSearchTime & 0x0000FF00) >> 8) * 600 + (timeSearchTime & 0x000000FF) * 60; int Current = (lastCurrent / FRAMESPERSEC); int Total = (lastTotal / FRAMESPERSEC); switch (Key) { case k0 ... k9: if (timeSearchPos < 4) { timeSearchTime <<= 8; timeSearchTime |= Key - k0; timeSearchPos++; TimeSearchDisplay(); } break; case kFastRew: case kLeft: case kFastFwd: case kRight: { int dir = ((Key == kRight || Key == kFastFwd) ? 1 : -1); if (dir > 0) Seconds = min(Total - Current - STAY_SECONDS_OFF_END, Seconds); SkipSeconds(Seconds * dir); timeSearchActive = false; } break; case kPlay: case kUp: case kPause: case kDown: Seconds = min(Total - STAY_SECONDS_OFF_END, Seconds); Goto(Seconds, Key == kDown || Key == kPause); timeSearchActive = false; break; default: timeSearchActive = false; break; } if (!timeSearchActive) { if (timeSearchHide) Hide(); else displayReplay->SetJump(NULL); ShowMode(); } } void cMenuVcdControl::TimeSearch(void) { timeSearchTime = timeSearchPos = 0; timeSearchHide = false; if (modeOnly) Hide(); if (!visible) { Show(); if (visible) timeSearchHide = true; else return; } timeoutShow = 0; TimeSearchDisplay(); timeSearchActive = true; } eOSState cMenuVcdControl::ProcessKey(eKeys Key) { if (!Active()) return osEnd; if (visible) { if (timeoutShow && time(0) > timeoutShow) { Hide(); ShowMode(); timeoutShow = 0; } else if (modeOnly) ShowMode(); else shown = ShowProgress(!shown) || shown; } bool DisplayedFrames = displayFrames; displayFrames = false; if (timeSearchActive && Key != kNone) { TimeSearchProcess(Key); return osContinue; } switch (Key) { case k1: SkipEntries(-1); break; case k3: SkipEntries(1); break; case k4: SkipTracks(-1); break; case k5: SkipTracks(0); break; case k6: SkipTracks(1); break; default: break; } asprintf(&title, "VideoCD Track %02d", GetTrack()); bool DoShowMode = true; switch (Key) { // Positioning: case kPlay: case kUp: Play(); break; case kPause: case kDown: Pause(); break; case kFastRew|k_Release: case kLeft|k_Release: if (Setup.MultiSpeedMode) break; case kFastRew: case kLeft: Backward(); break; case kFastFwd|k_Release: case kRight|k_Release: if (Setup.MultiSpeedMode) break; case kFastFwd: case kRight: Forward(); break; case kRed: TimeSearch(); break; case kGreen|k_Repeat: case kGreen: SkipSeconds(-60); break; case kYellow|k_Repeat: case kYellow: SkipSeconds(60); break; case kStop: case kBlue: Hide(); Stop(); vcd->Close(); return osEnd; default: { DoShowMode = false; switch (Key) { // Editing: (?) default: { displayFrames = DisplayedFrames; switch (Key) { // Menu control: case kOk: if (visible && !modeOnly) { Hide(); DoShowMode = true; } else Show(); break; case kBack: Hide(); Stop(); vcd->Close(); return osEnd; default: return osUnknown; } } } } } if (DoShowMode) ShowMode(); return osContinue; } vcd-0.9/player.c0000644000076400001440000005756110743373776012504 0ustar elsausers/* * player.c: Player core * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include "player.h" #include "setup.h" #define VIDEOBUFSIZE MEGABYTE(1) #define MAX_VIDEO_SLOWMOTION 63 // max. arg to pass to VIDEO_SLOWMOTION // TODO is this value correct? #define NORMAL_SPEED 4 // the index of the '1' entry in the following array #define MAX_SPEEDS 3 // the offset of the maximum speed from normal speed in either direction #define SPEED_MULT 12 // the speed multiplier // --- cVcdPlayer ------------------------------------------------------------ class cVcdPlayer : public cPlayer, cThread { private: enum ePlayModes { pmPlay, pmPause, pmSlow, pmFast, pmStill }; enum ePlayDirs { pdForward, pdBackward }; cVcd *vcd; int readTrack; int readLba, writeLba; bool continuous; bool doskip; uchar audioTrack; bool canToggleAudioTrack; static int Speeds[]; bool active, running, done, stop; ePlayModes playMode; ePlayDirs playDir; int trickSpeed; int loop, autoWait; int autoWaitInit; int startTrack; int trackOffset, trackLast; int lba0, lba1, lba; int seqhdr_size; uchar seqhdr_buf[CD_XA22_DATASIZE]; int prev_i_lba, next_i_lba; __u8 picture_type, last_picture_type; cRingBufferFrame *ringBuffer; cFrame *readFrame; cFrame *playFrame; void TrickSpeed(int Increment); int Resume(void); bool Save(void); void Empty(void); void StripAudioPackets(uchar *b, int Length, uchar Except = 0x00); void TrackInit(int Track); int ReadSector(uchar *buf); protected: virtual void Activate(bool On); virtual void Action(void); cFrame *getNextFrame(void); public: cVcdPlayer(int Track, cVcd *Vcd, int Lba = 0, int Loop = -1, int AutoWait = -1); virtual ~cVcdPlayer(); bool Active(void) { return active; } void Stop(void); void Pause(void); void Play(void); void Forward(void); void Backward(void); void SkipSeconds(int Seconds); bool SkipTracks(int Tracks); bool SkipEntries(int Entries); int GetTrack(void); int GetTrack(int LBA); void Goto(int Position, bool Still = false); void GotoTrack(int Track); void GotoEntry(int Entry); virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false); virtual bool GetReplayMode(bool &Play, bool &Forward, int &Sped); virtual void SetAudioTrack(eTrackType Type, const tTrackId *TrackId); const char *DeviceName(void) { return vcd->DeviceName(); } }; int cVcdPlayer::Speeds[] = { 0, -2, -4, -8, 1, 2, 4, 12, 0 }; cVcdPlayer::cVcdPlayer(int Track, cVcd *Vcd, int Lba, int Loop, int AutoWait) { readTrack = Track; vcd = Vcd; loop = Loop; autoWaitInit = AutoWait; continuous = VcdSetupData.PlayTracksContinuously && !VcdSetupData.PlaySequenceReplay ? true : false; active = true; running = false; done = false; stop = false; autoWait = -1; trickSpeed = NORMAL_SPEED; playMode = pmPlay; playDir = pdForward; readLba = writeLba = -1; readFrame = NULL; playFrame = NULL; ringBuffer = new cRingBufferFrame(VIDEOBUFSIZE); startTrack = VcdSetupData.BrokenMode && !VcdSetupData.PlaySequenceReplay ? 0 : 1; trackOffset = vcd->vcdEntry[startTrack].cdte_addr.lba; trackLast = vcd->vcdEntry[vcd->tracks+1].cdte_addr.lba - trackOffset; TrackInit(readTrack); if (Lba > 0) lba = Lba; } cVcdPlayer::~cVcdPlayer() { readTrack = 0; Detach(); Save(); } void cVcdPlayer::TrickSpeed(int Increment) { int nts = trickSpeed + Increment; if (Speeds[nts] == 1) { trickSpeed = nts; if (playMode == pmFast) Play(); else Pause(); } else if (Speeds[nts]) { trickSpeed = nts; int Mult = (playMode == pmSlow && playDir == pdForward) ? 1 : SPEED_MULT; int sp = (Speeds[nts] > 0) ? Mult / Speeds[nts] : -Speeds[nts] * Mult; if (sp > MAX_VIDEO_SLOWMOTION) sp = MAX_VIDEO_SLOWMOTION; DeviceTrickSpeed(sp); } } int cVcdPlayer::Resume(void) { //TODO: if meaningful and needed return -1; } bool cVcdPlayer::Save(void) { //TODO: if meaningful and needed return false; } void cVcdPlayer::Activate(bool On) { if (On) { if (readTrack > 0) Start(); } else if (active) { running = false; Cancel(3); active = false; } } void cVcdPlayer::Empty(void) { Lock(); readFrame = NULL; playFrame = NULL; ringBuffer->Clear(); DeviceClear(); Unlock(); } void cVcdPlayer::Stop(void) { done = true; stop = true; } void cVcdPlayer::Pause(void) { if (playMode == pmPause || playMode == pmStill) Play(); else { LOCK_THREAD; if (playMode == pmFast || (playMode == pmSlow && playDir == pdBackward)) { done = false; Empty(); } DeviceFreeze(); playMode = pmPause; } } void cVcdPlayer::Play(void) { if (playMode != pmPlay) { LOCK_THREAD; if (playMode == pmPause || playMode == pmStill || playMode == pmFast || (playMode == pmSlow && playDir == pdBackward)) { done = false; Empty(); } DevicePlay(); playMode = pmPlay; playDir = pdForward; } } void cVcdPlayer::Forward(void) { switch (playMode) { case pmFast: if (Setup.MultiSpeedMode) { TrickSpeed(playDir == pdForward ? 1 : -1); break; } else if (playDir == pdForward) { Play(); break; } // run into pmPlay case pmPlay: { LOCK_THREAD; done = false; Empty(); DeviceMute(); playMode = pmFast; playDir = pdForward; trickSpeed = NORMAL_SPEED; TrickSpeed(Setup.MultiSpeedMode ? 1 : MAX_SPEEDS); break; } case pmSlow: if (Setup.MultiSpeedMode) { TrickSpeed(playDir == pdForward ? -1 : 1); break; } else if (playDir == pdForward) { Pause(); break; } // run into pmPause case pmStill: case pmPause: DeviceMute(); playMode = pmSlow; playDir = pdForward; trickSpeed = NORMAL_SPEED; TrickSpeed(Setup.MultiSpeedMode ? -1 : -MAX_SPEEDS); break; default: break; } } void cVcdPlayer::Backward(void) { if (prev_i_lba) switch (playMode) { case pmFast: if (Setup.MultiSpeedMode) { TrickSpeed(playDir == pdBackward ? 1 : -1); break; } else if (playDir == pdBackward) { Play(); break; } // run into pmPlay case pmPlay: { LOCK_THREAD; done = false; Empty(); DeviceMute(); playMode = pmFast; playDir = pdBackward; trickSpeed = NORMAL_SPEED; TrickSpeed(Setup.MultiSpeedMode ? 1 : MAX_SPEEDS); break; } case pmSlow: if (Setup.MultiSpeedMode) { TrickSpeed(playDir == pdBackward ? -1 : 1); break; } else if (playDir == pdBackward) { Pause(); break; } // run into pmPause case pmStill: case pmPause: { LOCK_THREAD; done = false; Empty(); DeviceMute(); playMode = pmSlow; playDir = pdBackward; trickSpeed = NORMAL_SPEED; TrickSpeed(Setup.MultiSpeedMode ? -1 : -MAX_SPEEDS); } break; } } void cVcdPlayer::SkipSeconds(int Seconds) { if ((lba+CD_FRAMES*Seconds)= 0 && Entry < U16_TO_LE(vcd->vcdEntries.entries)) { LOCK_THREAD; done = false; Empty(); TrackInit(bcd_to_bin(vcd->vcdEntries.entry[Entry].track_no) - startTrack); lba = bcdmsf_to_lba(vcd->vcdEntries.entry[Entry].entry_msf); DevicePlay(); playMode = pmPlay; playDir = pdForward; } } bool cVcdPlayer::SkipTracks(int Tracks) { int track = GetTrack(); if (playMode == pmPlay) { LOCK_THREAD; if (Tracks == 0) readTrack = track; else if (track > startTrack && Tracks < 0) readTrack = track - 1; else if (track < vcd->tracks && Tracks > 0) readTrack = track + 1; else return false; done = false; Empty(); TrackInit(readTrack); DevicePlay(); playMode = pmPlay; playDir = pdForward; return true; } return false; } bool cVcdPlayer::SkipEntries(int Entries) { if (playMode == pmPlay) { LOCK_THREAD; if (Entries > 0) { for (int i=0; i < U16_TO_LE(vcd->vcdEntries.entries); i++) { int pos = bcdmsf_to_lba(vcd->vcdEntries.entry[i].entry_msf); if (pos > lba) { int track = bcd_to_bin(vcd->vcdEntries.entry[i].track_no) - startTrack; if (track != GetTrack()) TrackInit(track); lba = pos; readLba = lba; dsyslog("VCD: Track %d Entry %d", bcd_to_bin(vcd->vcdEntries.entry[i].track_no)-startTrack, i+1); done = false; Empty(); DevicePlay(); playMode = pmPlay; playDir = pdForward; return true; } } } if (Entries < 0) { for (int i=U16_TO_LE(vcd->vcdEntries.entries); i>1; i--) { int pos = bcdmsf_to_lba(vcd->vcdEntries.entry[i-1].entry_msf); if (pos < lba) { int track = bcd_to_bin(vcd->vcdEntries.entry[i-1].track_no) - startTrack; if (track != GetTrack()) TrackInit(track); lba = bcdmsf_to_lba(vcd->vcdEntries.entry[i-2].entry_msf); readLba = lba; dsyslog("VCD: Track %d Entry %d", bcd_to_bin(vcd->vcdEntries.entry[i-2].track_no)-startTrack, i-1); done = false; Empty(); DevicePlay(); playMode = pmPlay; playDir = pdForward; return true; } } } } return false; } int cVcdPlayer::GetTrack(void) { return GetTrack(writeLba); } int cVcdPlayer::GetTrack(int Lba) { int i; for (i=startTrack; i<=vcd->tracks; i++) if ((Lba >= vcd->vcdEntry[i].cdte_addr.lba) && (Lba < vcd->vcdEntry[i+1].cdte_addr.lba)) return i; return 0; } bool cVcdPlayer::GetIndex(int &Current, int &Total, bool SnapToIFrame) { Current = max((writeLba - trackOffset - CD_MSF_OFFSET) / 3, 0); Total = trackLast/3; return true; } bool cVcdPlayer::GetReplayMode(bool &Play, bool &Forward, int &Speed) { Play = (playMode == pmPlay || playMode == pmFast); Forward = (playDir == pdForward); if (playMode == pmFast || playMode == pmSlow) Speed = Setup.MultiSpeedMode ? abs(trickSpeed - NORMAL_SPEED) : 0; else Speed = -1; return true; } void cVcdPlayer::Action(void) { dsyslog("VCD: input thread started (pid=%d)", getpid()); int fuse = time(NULL); const uchar *p = NULL; int pc = 0; running = true; while (running) { if (autoWait>=0 && fuse!=time(NULL)) { fuse = time(NULL); autoWait--; } cPoller Poller; if (DevicePoll(Poller, 100)) { LOCK_THREAD; if (!readFrame) readFrame = getNextFrame(); if (readFrame) if (ringBuffer->Put(readFrame)) readFrame = NULL; if (!playFrame) { playFrame = ringBuffer->Get(); if (playFrame) { p = playFrame->Data(); pc = playFrame->Count(); } } if (playFrame && autoWait<0) { StripAudioPackets((uchar *)playFrame->Data(), playFrame->Count(), (playMode == pmFast || playMode == pmSlow) ? 0x00 : audioTrack); int w = PlayPes(p, pc); if (w > 0) { running = true; p += w; pc -= w; if (pc <= 0) { writeLba = playFrame->Index(); ringBuffer->Drop(playFrame); playFrame = NULL; } } else if (w < 0 && FATALERRNO) { LOG_ERROR; break; } } if (done) { if (!stop) sleep(1); running = false; } } else sleep(1); } active = running = false; dsyslog("VCD: input thread ended (pid=%d)", getpid()); } cFrame *cVcdPlayer::getNextFrame(void) { if (done) return 0; uchar buffer[10 * CD_XA22_DATASIZE]; if (seqhdr_size==0 && !VcdSetupData.BrokenMode) { seqhdr_buf[0] = 0x00; seqhdr_buf[1] = 0x00; seqhdr_buf[2] = 0x01; seqhdr_buf[3] = 0xB3; if (strncmp(vcd->vcdInfo.system_id,"VIDEO_CD",8)==0) { if (vcd->vcdInfo.video_type_map[(readTrack-1)/8] & (1 << (readTrack-1)%8)) { seqhdr_buf[4] = 0x16; // PAL VCD 352x288 4:3 25fps seqhdr_buf[5] = 0x01; seqhdr_buf[6] = 0x20; seqhdr_buf[7] = 0x23; } else { seqhdr_buf[4] = 0x16; // NTSC VCD 352x240 4:3 30fps seqhdr_buf[5] = 0x00; seqhdr_buf[6] = 0xF0; seqhdr_buf[7] = 0x24; } } else { if (vcd->vcdInfo.video_type_map[(readTrack-1)/8] & (1 << (readTrack-1)%8)) { seqhdr_buf[4] = 0x1E; // PAL SVCD 480x576 4:3 25fps seqhdr_buf[5] = 0x02; seqhdr_buf[6] = 0x40; seqhdr_buf[7] = 0x23; } else { seqhdr_buf[4] = 0x1E; // NTSC SVCD 480x480 4:3 30fps seqhdr_buf[5] = 0x01; seqhdr_buf[6] = 0xE0; seqhdr_buf[7] = 0x24; } } seqhdr_buf[8] = 0x00; seqhdr_buf[9] = 0x00; seqhdr_buf[10] = 0x20; seqhdr_buf[11] = 0x00; seqhdr_size = 12; } int count = ReadSector(buffer); if (lba >= lba1) { if (loop>=0) lba = lba0; else done = true; } if (count > 0 && buffer[0] == 0x00 && buffer[1] == 0x00 && buffer[2] == 0x01 && buffer[3] == PACK_SC) { int ofs; if (buffer[4] & 0xC0) // MPEG-2 pack header ofs = 14 + (buffer[13] & 0x07); else // MPEG-1 pack header ofs = 12; memcpy(buffer, buffer+ofs, count-ofs); __u8 strt_code = buffer[3]; if ((strt_code & SC_MASK) == VIDEO_STREAM_SC || strt_code == SYSTEM_HEADER_SC) { __u8 last_strt_code = strt_code; int insert_seqhdr = 0; for (int i=0; i < count-ofs-6; i++) { if (buffer[i] == 0x00 && buffer[i+1] == 0x00 && buffer[i+2] == 0x01) { int h,m,s,f; switch (buffer[i+3]) { case SEQUENCE_HEADER_SC: doskip = false; last_strt_code = SEQUENCE_HEADER_SC; for (int j=i+4; j < count-ofs-6; j++) { if (buffer[j] == 0x00 && buffer[j+1] == 0x00 && buffer[j+2] == 0x01) { seqhdr_size = j - i; memcpy(seqhdr_buf, buffer+i, seqhdr_size); break; } } break; case GROUP_OF_PICT_SC: doskip = false; h = (buffer[i+4] >> 2) & 0x1F; m = ((buffer[i+4] << 4) & 0x30) | ((buffer[i+5] >> 4) & 0xF0); s = ((buffer[i+5] << 3) & 0x38) | ((buffer[i+6] >> 5) & 0x07); f = ((buffer[i+6] << 1) & 0x3E) | ((buffer[i+7] >> 7) & 0x01); if (last_strt_code == strt_code && seqhdr_size > 0) insert_seqhdr = i; break; case PICTURE_SC: last_picture_type = picture_type; picture_type = (buffer[i+5] >> 3) & 0x07; if (picture_type == I_FRAME) { for (int j=i+4; j < count-ofs-6; j++) { if (buffer[j] == 0x00 && buffer[j+1] == 0x00 && buffer[j+2] == 0x01 && buffer[j+3] == USER_DATA_SC && buffer[j+4] == 0x10 && buffer[j+5] == 0x0E) { if (buffer[j+6] != 0xFF) prev_i_lba = vcd->vcdEntry[readTrack].cdte_addr.lba + bcd_to_bin(buffer[j+8] & 0x7F) + CD_FRAMES * ( bcd_to_bin(buffer[j+7] & 0x7F) + CD_SECS * bcd_to_bin(buffer[j+6]) ); else prev_i_lba = 0; if (buffer[j+9] != 0xFF) next_i_lba = vcd->vcdEntry[readTrack].cdte_addr.lba + bcd_to_bin(buffer[j+11] & 0x7F) + CD_FRAMES * ( bcd_to_bin(buffer[j+10] & 0x7F) + CD_SECS * bcd_to_bin(buffer[j+9]) ); else next_i_lba = 0; break; } } } break; default: break; } } } if (insert_seqhdr) { uchar tmp_buf[10*CD_XA22_DATASIZE]; int new_pes_len = buffer[4]*256 + buffer[5] + seqhdr_size; memcpy(tmp_buf, buffer+insert_seqhdr, count-ofs-insert_seqhdr); memcpy(buffer+insert_seqhdr, seqhdr_buf, seqhdr_size); memcpy(buffer+insert_seqhdr+seqhdr_size, tmp_buf, count-ofs-insert_seqhdr); buffer[4] = new_pes_len / 256; buffer[5] = new_pes_len % 256; count += seqhdr_size; } } //FIXME: needs to be moved someplace else if (playMode == pmSlow && playDir == pdBackward) { // pending } else if (playMode == pmFast) { if (picture_type != I_FRAME) { doskip = true; if (playDir == pdForward && next_i_lba) lba = next_i_lba; else if (playDir == pdBackward) { if (prev_i_lba) lba = prev_i_lba; else { DevicePlay(); playMode = pmPlay; playDir = pdForward; return 0; } } } } readLba = lba; if (!doskip) { if ((strt_code & SC_MASK) == VIDEO_STREAM_SC || strt_code == SYSTEM_HEADER_SC) return new cFrame(buffer, count-ofs, ftVideo, readLba); if ((strt_code & SC_MASK) == AUDIO_STREAM_SC && playMode == pmPlay) return new cFrame(buffer, count-ofs, ftAudio, readLba); } } return 0; } void cVcdPlayer::StripAudioPackets(uchar *b, int Length, uchar Except) { for (int i=0; i < Length-6; i++) { if (b[i]==0x00 && b[i+1]==0x00 && b[i+2]== 0x01) { uchar strt_code = b[i+3]; int l = b[i+4] * 256 + b[i+5] + 6; switch (strt_code) { case 0xC0 ... 0xC1: if (strt_code==0xC1 && !canToggleAudioTrack) { canToggleAudioTrack = true; DeviceSetAvailableTrack(ttAudio, strt_code & 0x1f, strt_code); } if (!Except || strt_code!=Except) memset(&b[i], 0x00, min(l, Length-i)); break; case 0xE0 ... 0xEF: break; default: l = 0; break; } if (l) i += l - 1; } } } void cVcdPlayer::TrackInit(int track) { dsyslog("VCD: Track %d", track+1-startTrack); audioTrack = 0xC0; canToggleAudioTrack = false; doskip = true; if (continuous) { lba0 = vcd->vcdEntry[startTrack].cdte_addr.lba; lba1 = vcd->vcdEntry[vcd->tracks+1].cdte_addr.lba; } else { lba0 = vcd->vcdEntry[track].cdte_addr.lba; lba1 = vcd->vcdEntry[track+1].cdte_addr.lba; } lba = vcd->vcdEntry[track].cdte_addr.lba; seqhdr_size = 0; prev_i_lba = 0; next_i_lba = 0; picture_type = NO_PICTURE; last_picture_type = NO_PICTURE; } int cVcdPlayer::ReadSector(uchar *buf) { struct cdsector_xa22 sector; if (vcd->readSectorRaw(lba++, §or)) { if (sector.subhead.dw[0]==sector.subhead.dw[1]) { // a (s)vcd sector ?! switch (sector.subhead.b[2] & 0x7e) { case 0x62: case 0x64: memcpy(buf, &(sector.data[0]), CD_XA22_DATASIZE); return CD_XA22_DATASIZE; default: break; } } if ((sector.subhead.b[2] & 0x10) && autoWaitInit>=0) { autoWait = autoWaitInit; dsyslog("VCD: autowait %d sec", autoWait); } } return 0; } void cVcdPlayer::SetAudioTrack(eTrackType Type, const tTrackId *TrackId) { if (IS_AUDIO_TRACK(Type)) { if ((audioTrack == 0xC0) != (Type <= ttAudioFirst)) { audioTrack = (Type > ttAudioFirst) ? 0xC1 : 0xC0; Empty(); } } } // --- cVcdPlayerControl ----------------------------------------------------- cVcdPlayerControl::cVcdPlayerControl(int Track, cVcd *Vcd) : cControl(player = new cVcdPlayer(Track, Vcd)) { } cVcdPlayerControl::cVcdPlayerControl(int Track, cVcd *Vcd, int Lba, int Loop, int AutoWait) : cControl(player = new cVcdPlayer(Track, Vcd, Lba, Loop, AutoWait)) { } cVcdPlayerControl::~cVcdPlayerControl() { Stop(); } bool cVcdPlayerControl::Active(void) { return player && player->Active(); } int cVcdPlayerControl::GetTrack(void) { if (player) return player->GetTrack(); return 0; } void cVcdPlayerControl::Stop(void) { if (player) { player->Stop(); delete player; player = NULL; } } void cVcdPlayerControl::Pause(void) { if (player) player->Pause(); } void cVcdPlayerControl::Play(void) { if (player) player->Play(); } void cVcdPlayerControl::Forward(void) { if (player) player->Forward(); } void cVcdPlayerControl::Backward(void) { if (player) player->Backward(); } void cVcdPlayerControl::SkipSeconds(int Seconds) { if (player) player->SkipSeconds(Seconds); } bool cVcdPlayerControl::SkipTracks(int Tracks) { if (player) return player->SkipTracks(Tracks); return false; } bool cVcdPlayerControl::SkipEntries(int Entries) { if (player) return player->SkipEntries(Entries); return false; } void cVcdPlayerControl::Goto(int Position, bool Still) { if (player) player->Goto(Position, Still); } void cVcdPlayerControl::GotoTrack(int Track) { if (player) player->GotoTrack(Track); } void cVcdPlayerControl::GotoEntry(int Entry) { if (player) player->GotoEntry(Entry); } const char *cVcdPlayerControl::DeviceName(void) { if (player) return player->DeviceName(); return NULL; } vcd-0.9/COPYING0000777000076400001440000000000010745170053013657 2gpl-2.0.txtustar elsausersvcd-0.9/menu.h0000644000076400001440000000321710743375520012133 0ustar elsausers/* * menu.h: OSD menus * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_MENU_H #define __VCD_MENU_H #include #include "functions.h" class cMenu : public cOsdMenu { protected: cVcd *vcd; bool validLabel; char vcdTitle[17]; eOSState Eject(void); void SetHelp(const char *Red, const char *Green, const char *Blue); public: cMenu(cVcd *Vcd); ~cMenu(); virtual eOSState ProcessKey(eKeys Key); }; class cMenuSpi : public cMenu { private: bool validItems; bool ListItems(void); eOSState Play(void); public: cMenuSpi(cVcd *Vcd); ~cMenuSpi(); virtual eOSState ProcessKey(eKeys Key); }; class cMenuVcd : public cMenu { private: bool validTracks; bool spi; bool ListTracks(void); eOSState Play(void); public: cMenuVcd(cVcd *Vcd); ~cMenuVcd(); virtual eOSState ProcessKey(eKeys Key); }; #endif //__VCD_MENU_H vcd-0.9/psd.h0000644000076400001440000000227710743375623011766 0ustar elsausers/* * psd.h: PSD controlled replay * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_PSD_H #define __VCD_PSD_H #include #include "functions.h" class cVcdPsd : public cOsdMenu { protected: cVcd *vcd; bool validList; eOSState Eject(void); eOSState Play(void); public: cVcdPsd(cVcd *Vcd); ~cVcdPsd(); virtual eOSState ProcessKey(eKeys Key); }; #endif //__VCD_PSD_H vcd-0.9/i18n.c0000755000076400001440000000713210744677102011746 0ustar elsausers/* * i18n.c: Internationalization * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * * Italian translations provided by Gringo * */ #include "i18n.h" const tI18nPhrase Phrases[] = { { "VideoCD", "VideoCD", "", "VideoCD", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Tracks", "Tracks", "", "Tracce", "", "", "", "", "", "", "", "", "", "", "", "", }, { "VideoCD SPI", "VideoCD SPI", "", "VideoCD SPI", "", "", "", "", "", "", "", "", "", "", "", "", }, { "SPI", "SPI", "", "SPI", "", "", "", "", "", "", "", "", "", "", "", "", }, { "No disc inserted", "Keine CD eingelegt", "", "Nessun disco inserito", "", "", "", "", "", "", "", "", "", "", "", "", }, { "No VideoCD detected", "Keine VideoCD erkannt", "", "Nessun VideoCD trovato", "", "", "", "", "", "", "", "", "", "", "", "", }, { "VCD", "VCD", "", "VCD", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Setup.VCD$Drive speed", "Laufwerkgeschwindigkeit", "", "Velocità lettore", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Setup.VCD$Broken mode", "Nicht standardkonform", "", "Mod. non standard", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Setup.VCD$Hide main menu entry", "Hauptmenüeintrag ausblenden", "", "Nascondi voce nel menu principale", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Setup.VCD$Play tracks continuously", "Tracks nacheinander abspielen", "", "Riproduci tracce in modo continuo", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Setup.VCD$Autostart replay", "Wiedergabe automatisch starten", "", "Riproduzione automatica all'avvio", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Setup.VCD$Play sequence replay", "Wiedergabe nach Sequenz", "", "Riproduci in sequenza", "", "", "", "", "", "", "", "", "", "", "", "", }, { "Eject", "Auswerfen", "Izvrzi", "Eject", "Eject", "Ejectar", "Ejection", "Eject", "Avaa", "Wyrzucenie", "Expulsar", "Exsagogi", "Mata ut", "Ejecteaza", "Kidobni", "Expulsar", }, { NULL } }; vcd-0.9/viewer.c0000644000076400001440000002522410743375161012466 0ustar elsausers/* * viewer.c: Viewer core * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include "viewer.h" #include "setup.h" #define VIDEOBUFSIZE MEGABYTE(1) // --- cVcdViewer ------------------------------------------------------------ class cVcdViewer : public cPlayer, cThread { private: enum ePlayModes { pmPlay, pmStill, pmAudioOnly }; cVcd *vcd; int spi; bool active, running, done; ePlayModes playMode; uchar videoStill; uchar audioTrack; bool canToggleAudioTrack; bool videoHiRes; int lba; cRingBufferFrame *ringBuffer; cFrame *readItem; cFrame *playItem; void Empty(void); bool Save(void); void ItemInit(int Spi); int ReadSector(uchar *buf); protected: virtual void Activate(bool On); virtual void Action(void); cFrame *GetItem(void); public: cVcdViewer(int Spi, cVcd *Vcd); virtual ~cVcdViewer(); bool Active(void) { return active; } bool Still(void) { return playMode==pmStill; } bool SkipItems(int Items); int GetSpi(void) { return spi; } void GotoItem(int Spi); void ToggleStillRes(void); const char *DeviceName(void) { return vcd->DeviceName(); } }; cVcdViewer::cVcdViewer(int Spi, cVcd *Vcd) { spi = Spi; vcd = Vcd; active = true; running = false; done = false; readItem = NULL; playItem = NULL; ringBuffer = new cRingBufferFrame(SPI_SIZE * CD_XA22_DATASIZE); ItemInit(spi); } cVcdViewer::~cVcdViewer() { spi = -1; Detach(); Save(); } bool cVcdViewer::Save(void) { return false; } void cVcdViewer::Activate(bool On) { if (On) { if (spi >= 0) Start(); } else if (active) { running = false; Cancel(3); active = false; } } void cVcdViewer::Empty(void) { Lock(); readItem = NULL; playItem = NULL; ringBuffer->Clear(); DeviceClear(); Unlock(); } void cVcdViewer::GotoItem(int Spi) { LOCK_THREAD; done = false; Empty(); spi = Spi; ItemInit(Spi); DevicePlay(); } void cVcdViewer::ToggleStillRes(void) { if (playMode==pmStill) { LOCK_THREAD; videoStill = videoStill == 0xE1 ? 0xE2 : 0xE1; done = false; Empty(); DevicePlay(); } } bool cVcdViewer::SkipItems(int Items) { int s = spi; LOCK_THREAD; if (Items < 0) { while (--s>=0) { if ((vcd->vcdInfo.spi_contents[s] & SPI_CONTINUED) == 0) { spi = s; done = false; Empty(); ItemInit(spi); DevicePlay(); return true; } } } else if (Items > 0) { while (++s < U16_TO_LE(vcd->vcdInfo.max_segment_number)) { if ((vcd->vcdInfo.spi_contents[s] & SPI_CONTINUED) == 0) { spi = s; done = false; Empty(); ItemInit(spi); DevicePlay(); return true; } } } return false; } void cVcdViewer::Action(void) { dsyslog("VCD: spi viewer started (pid=%d)", getpid()); const uchar *p = NULL; int pc = 0; running = true; while (running) { cPoller Poller; if (DevicePoll(Poller, 100)) { LOCK_THREAD; if (!readItem) readItem = GetItem(); if (readItem) if (playMode==pmStill) { #ifdef DEBUG_VCD FILE *fp; if ((fp = fopen("/tmp/item.mpg", "w")) != NULL) { fwrite(readItem->Data(), sizeof(char), readItem->Count(), fp); fclose(fp); } #endif //DEBUG_VCD DeviceStillPicture(readItem->Data(), readItem->Count()); readItem = NULL; } else if (ringBuffer->Put(readItem)) readItem = NULL; if (!playItem) { playItem = ringBuffer->Get(); if (playItem) { p = playItem->Data(); pc = playItem->Count(); } } if (done && playMode!=pmStill) running = false; // if (done) { // if (VcdSetupData.PlaySequenceReplay) // running = false; // else if (playMode!=pmStill) // running = false; // } if (playItem) { int w = PlayPes(p, pc); if (w>0) { running = true; p += w; pc -= w; if (pc<=0) { ringBuffer->Drop(playItem); playItem = NULL; } } else if (w<0 && FATALERRNO) { LOG_ERROR; break; } } } else sleep(1); } active = running = false; dsyslog("VCD: spi viewer ended (pid=%d)", getpid()); } cFrame *cVcdViewer::GetItem(void) { if (done) return 0; uchar buffer[SPI_SIZE * CD_XA22_DATASIZE]; int count = 0; lba = bcdmsf_to_lba(vcd->vcdInfo.first_segment_msf) + spi * SPI_SIZE; dsyslog("VCD: Item %d (lba=%d) (%s%s)", spi, lba, SPI_AUDIO(vcd->vcdInfo.spi_contents[spi]) == SPI_1CH_AUDIO ? "Audio" : SPI_AUDIO(vcd->vcdInfo.spi_contents[spi]) == SPI_2CH_AUDIO ? "2Ch.Audio" : SPI_AUDIO(vcd->vcdInfo.spi_contents[spi]) == SPI_MUL_AUDIO ? "Multich.Audio" : SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_NTSC_STILL ? "NTSC Image" : SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_NTSC_STILL2 ? "NTSC Image+" : SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_NTSC_VIDEO ? "NTSC Video" : SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_PAL_STILL ? "PAL Image" : SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_PAL_STILL2 ? "PAL Image+" : SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_PAL_VIDEO ? "PAL Video" : "unknown", SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_NTSC_STILL || SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_NTSC_STILL2 || SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_PAL_STILL || SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_PAL_STILL2 ? (videoStill == 0xE2 ? " HiRes" : " LoRes") : (vcd->vcdInfo.spi_contents[spi] & SPI_CONTINUED ? " continued" : "") ); for (int i=0; i 0 && tmpbuf[0] == 0x00 && tmpbuf[1] == 0x00 && tmpbuf[2] == 0x01 && tmpbuf[3] == PACK_SC) { int ofs; if (tmpbuf[4] & 0xC0) // MPEG-2 pack header ofs = 14 + (tmpbuf[13] & 0x07); else // MPEG-1 pack header ofs = 12; if (tmpbuf[ofs+3]==videoStill) { // still image packet #ifdef STRIP_STILLIMAGE_PES_HEADER int len = 256 * tmpbuf[ofs+4] + tmpbuf[ofs+5]; ofs += 6; // strip PES header while (tmpbuf[ofs] == 0xFF && len > 0) { ofs++; len--; } if ((tmpbuf[ofs] & 0xC0) == 0x40 && len >= 2) { ofs += 2; len -= 2; } if ((tmpbuf[ofs] & 0xF0) == 0x20 && len >= 5) { ofs += 5; len -= 5; } else if ((tmpbuf[ofs] & 0xF0) == 0x30 && len >= 10) { ofs += 10; len -= 10; } else if (tmpbuf[ofs] == 0x0F && len > 0) { ofs++; len--; } memcpy(buffer+count, tmpbuf+ofs, len); count += len; #else memcpy(buffer+count, tmpbuf+ofs, tmpcnt-ofs); count += tmpcnt-ofs; #endif //STRIP_STILLIMAGE_PES_HEADER } else if ((tmpbuf[ofs+3]==audioTrack) || // audio packet (tmpbuf[ofs+3]==0xE0)) { // video packet memcpy(buffer+count, tmpbuf+ofs, tmpcnt-ofs); count += tmpcnt-ofs; } } } if ((vcd->vcdInfo.spi_contents[spi+1] & SPI_CONTINUED)) spi++; else done = true; if (count>0) return new cFrame(buffer, count); else return 0; } void cVcdViewer::ItemInit(int Spi) { canToggleAudioTrack = false; // not yet implemented audioTrack = 0xC0; videoStill = 0xE1; // lores stills if ((SPI_AUDIO(vcd->vcdInfo.spi_contents[spi]) == SPI_1CH_AUDIO) || (SPI_AUDIO(vcd->vcdInfo.spi_contents[spi]) == SPI_2CH_AUDIO) || (SPI_AUDIO(vcd->vcdInfo.spi_contents[spi]) == SPI_MUL_AUDIO)) { playMode = pmAudioOnly; } else if ((SPI_VIDEO(vcd->vcdInfo.spi_contents[Spi]) == SPI_NTSC_VIDEO) || (SPI_VIDEO(vcd->vcdInfo.spi_contents[Spi]) == SPI_PAL_VIDEO)) { playMode = pmPlay; } else if ((SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_PAL_STILL2) || (SPI_VIDEO(vcd->vcdInfo.spi_contents[spi]) == SPI_NTSC_STILL2)) { videoStill = 0xE2; playMode = pmStill; } else { playMode = pmStill; } } int cVcdViewer::ReadSector(uchar *buf) { struct cdsector_xa22 sector; if (vcd->readSectorRaw(lba++, §or)) { if (sector.subhead.dw[0]==sector.subhead.dw[1]) { // a (s)vcd sector ?! switch (sector.subhead.b[2] & 0x7e) { case 0x62: case 0x64: memcpy(buf, &(sector.data[0]), CD_XA22_DATASIZE); return CD_XA22_DATASIZE; default: return 0; } } } return 0; } // --- cVcdViewerControl ----------------------------------------------------- cVcdViewerControl::cVcdViewerControl(int Spi, cVcd *Vcd) :cControl(viewer = new cVcdViewer(Spi, Vcd)) { } cVcdViewerControl::~cVcdViewerControl() { Stop(); } bool cVcdViewerControl::Active(void) { return viewer && viewer->Active(); } bool cVcdViewerControl::Still(void) { return viewer && viewer->Still(); } int cVcdViewerControl::GetSpi(void) { if (viewer) return viewer->GetSpi(); return -1; } void cVcdViewerControl::Stop(void) { delete viewer; viewer = NULL; } bool cVcdViewerControl::SkipItems(int Items) { if (viewer) return viewer->SkipItems(Items); return false; } void cVcdViewerControl::GotoItem(int Spi) { if (viewer) viewer->GotoItem(Spi); } void cVcdViewerControl::ToggleStillRes(void) { if (viewer) viewer->ToggleStillRes(); } const char *cVcdViewerControl::DeviceName(void) { if (viewer) return viewer->DeviceName(); return NULL; } vcd-0.9/setup.h0000644000076400001440000000261410743375636012337 0ustar elsausers/* * setup.h: Setup the plugin * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_SETUP_H #define __VCD_SETUP_H #include #include "functions.h" class cVcdSetupData { public: int DriveSpeed; int BrokenMode; int HideMainMenuEntry; int PlayTracksContinuously; int AutostartReplay; int PlaySequenceReplay; public: cVcdSetupData(void); }; class cVcdSetupMenu : public cMenuSetupPage { private: cVcd *vcd; cVcdSetupData setupData; protected: virtual void Store(void); public: cVcdSetupMenu(cVcd *Vcd); }; extern cVcdSetupData VcdSetupData; #endif //__VCD_SETUP_H vcd-0.9/HISTORY0000644000076400001440000000612510744716152012104 0ustar elsausersVDR Plugin 'vcd' Revision History --------------------------------- 2008-01-20: Version 0.9 - Italian translations contributed by Gringo (see i18n.c). 2007-12-12: Version 0.8 - Upgraded code to compile under VDR 1.4.7 and later. Patches were provided by * Thomas Schmidt * Habib@vdr-portal.de * Thomas Günther * Tobias Grimm - Updated GPL text. 2005-01-28: Version 0.7 - Simplified plugin numbering based on an idea of Nicolas Huillard :) - This version adjusts the plugin to the latest developer release of VDR (1.3.19). It may not work under older versions any longer. Thanks to the following people, who provided patches and ideas: * S. Ullrich * C.Y.M. * Sergei Haller * Helmut Auer - Fixed missing audio video sync after pausing replay. - Fixed a bug in time search under 'classic' control mode. - Added green/yellow and pause replay control under PSD mode. 2003-11-24: Version 0.0.6c - Sascha Volkenandt provided a patch which 'normalizes' an odd struct declaration. The code should now compile flawlessly also with gcc version <=2.95 2003-11-19: Version 0.0.6b - bug fix in PSD menu (checks if CD is really a (S)VCD) 2003-11-17: Version 0.0.6 - introduced PSD replay control - player/viewer code bugfixes 2003-10-12: Version 0.0.5b - included stripping of still image PES headers into plugin code, plugin will now work with unpatched VDR-1.2.5 2003-10-10: Version 0.0.5 - improved replay of (S)VCD still images, best resolution will automatically be selected by default - added patch for VDR-1.2.5 to allow replay of MPEG-1 encoded still images with its new StillPicture function 2003-04-29: Version 0.0.4h - adapted to dropped const flag in VDR 1.1.29 2003-04-21: Version 0.0.4g - minor bugfixes and code reviews - CD drive explicitely close after replay (patch by Sascha Volkenandt) 2003-02-02: Version 0.0.4f - bugfixes in 'Broken mode' - new setup parameter 'Hide main menu entry' (idea by Sascha Volkenandt) 2003-02-01: Version 0.0.4e - Implemented setup menu: * adjusting of CD speed * 'Broken mode' to replay non standard compliant (S)VCDs 2003-01-26: Version 0.0.4d - Implemented command line option '-v/--vcd' to alternatively/addiionally define other drives as 'The VideoCD Drive' (idea by Matthias Raus) - Switching CD speed back to 'auto' when releasing drive 2003-01-19: Version 0.0.4c - Switching CD speed to 2x when opening (S)VCDs (contributed by Rolf Groppe) - Implemented "Viewer" to play/view segment play items on (S)VCDs 2003-01-05: Version 0.0.4b - bugfix in jumping functions 2003-01-03: Version 0.0.4 - Complete code cleanup of VCD control to achieve better reliability - Updated to VDR version 1.1.20 - Added audio channel selection 2002-09-01: Version 0.0.3 - First official release after a few more tests and coding... 2002-08-30: Version 0.0.2 - Merging of the 0.0.1 versions, first bugfixes 2002-08-26: Version 0.0.1 - Initial revision: first menu implementations by Thomas Heiligenmann player code by Andreas Schultz based on DVD plugin vcd-0.9/functions.h0000644000076400001440000001550110743375453013203 0ustar elsausers/* * functions.h: Functions for handling VCDs, SVCDs, ... * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_FUNCTIONS_H #define __VCD_FUNCTIONS_H #include #include #define CD_XA21_DATASIZE (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE-CD_SUBHEAD_SIZE-CD_EDC_SIZE-CD_ECC_SIZE) #define CD_XA22_DATASIZE (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE-CD_SUBHEAD_SIZE-CD_EDC_SIZE) struct cdsector_xa21 { __u8 sync [CD_SYNC_SIZE]; __u8 head [CD_HEAD_SIZE]; union { __u8 b [CD_SUBHEAD_SIZE]; __u32 dw [CD_SUBHEAD_SIZE/4]; } subhead; __u8 data [CD_XA21_DATASIZE]; __u8 edc [CD_EDC_SIZE]; __u8 ecc [CD_ECC_SIZE]; }; struct cdsector_xa22 { __u8 sync [CD_SYNC_SIZE]; __u8 head [CD_HEAD_SIZE]; union { __u8 b [CD_SUBHEAD_SIZE]; __u32 dw [CD_SUBHEAD_SIZE/4]; } subhead; __u8 data [CD_XA22_DATASIZE]; __u8 edc [CD_EDC_SIZE]; }; #if __BYTE_ORDER == __BIG_ENDIAN #define U16_TO_LE(w) ((__u16)(w)) #define U32_TO_LE(dw) ((__u32)(dw)) #else #define U16_TO_LE(w) ((__u16)( \ (((__u16)(w) & 0xFF00U) >> 8) | \ (((__u16)(w) & 0x00FFU) << 8)) ) #define U32_TO_LE(dw) ((__u32)( \ (((__u32)(dw) & 0xFF000000U) >> 24) | \ (((__u32)(dw) & 0x00FF0000U) >> 8) | \ (((__u32)(dw) & 0x0000FF00U) << 8) | \ (((__u32)(dw) & 0x000000FFU) << 24)) ) #endif enum ePlayItem { piNothing, piTrack, piEntry, piSpi, piReserved }; #define PLAY_ITEM_TYP(w) ( w<2 ? (piNothing) \ : w<100 ? (piTrack) \ : w<600 ? (piEntry) \ : w<1000 ? (piReserved) \ : w<2980 ? (piSpi) \ : (piReserved) ) #define PLAY_ITEM_STR(w) ( w<2 ? ("Play nothing") \ : w<100 ? ("Track") \ : w<600 ? ("Entry") \ : w<1000 ? ("Reserved") \ : w<2980 ? ("SPI") \ : ("Reserved") ) #define PLAY_ITEM_NO(w) ( w<2 ? (0) \ : w<100 ? (w - 1) \ : w<600 ? (w - 100) \ : w<1000 ? (0) \ : w<2980 ? (w - 1000) \ : (0) ) #define PLAY_ITEM_WAIT(b) ( b<61 ? (b) \ : b<255 ? ((b-60) * 10 + 60) \ : (-1) ) #define INFO_VCD_LBA 150 #define ENTRIES_VCD_LBA 151 #define LOT_VCD_LBA 152 #define LOT_VCD_SIZE 32 #define PSD_VCD_LBA 184 #define PSD_VCD_MAX_SIZE 256 #define TRACKS_SVD_LBA 185 #define SEARCH_DAT_LBA 186 #define VCD_SEGMENTS 1980 #define VCD_ENTRIES 500 #define SPI_SIZE 150 #define SPI_NODATA 0x00 #define SPI_1CH_AUDIO 0x01 #define SPI_2CH_AUDIO 0x02 #define SPI_MUL_AUDIO 0x03 #define SPI_NTSC_STILL 0x04 #define SPI_NTSC_STILL2 0x08 #define SPI_NTSC_VIDEO 0x0c #define SPI_RESERVED 0x10 #define SPI_PAL_STILL 0x14 #define SPI_PAL_STILL2 0x18 #define SPI_PAL_VIDEO 0x1c #define SPI_CONTINUED 0x20 #define SPI_AUDIO(b) (b & 0x07) #define SPI_VIDEO(b) (b & 0x1c) #define PLAY_LIST_HEADER 0x10 #define SELECTION_LIST_HEADER 0x18 #define END_LIST_HEADER 0x1F struct info_vcd { char system_id[8]; __u8 version; __u8 system_profile_tag; char album_id[16]; __u16 album_volumes; __u16 album_sequence; __u8 video_type_map[13]; __u8 status_flags; __u32 psd_size; struct cdrom_msf0 first_segment_msf; __u8 offset_multiplier; __u16 max_list_id; __u16 max_segment_number; __u8 spi_contents[VCD_SEGMENTS]; __u8 reserved[12]; }; struct entries_vcd { char file_id[8]; __u8 version; __u8 reserved_byte; __u16 entries; struct { __u8 track_no; struct cdrom_msf0 entry_msf; } entry[VCD_ENTRIES]; __u8 reserved[36]; }; struct lot_vcd { __u16 list_id_offset[CD_XA21_DATASIZE*LOT_VCD_SIZE/2]; }; union psd_vcd { __u8 header; struct { __u8 header; __u8 number_of_items; __u16 list_id; __u16 previous_list_offset; __u16 next_list_offset; __u16 return_list_offset; __u16 playing_time; __u8 play_item_wait_time; __u8 auto_pause_wait_time; __u16 play_item[]; } play; struct { __u8 header; __u8 selection_list_flags; __u8 nos; __u8 bsn; __u16 list_id; __u16 previous_list_offset; __u16 next_list_offset; __u16 return_list_offset; __u16 default_list_offset; __u16 timeout_list_offset; __u8 timeout_wait_time; __u8 loop_count; __u16 play_item; __u16 selection_offset[]; } selection; }; __u8 bcd_to_bin(__u8 bcd); int bcdmsf_to_lba(cdrom_msf0 msf0); struct cdrom_msf0 lba_to_msf(int lba); class cVcd { private: cVcd *vcdInstance; const char *deviceName; int cdrom; int Command(int Cmd); public: cVcd(void); cVcd(const char *DeviceName); ~cVcd(); bool DriveExists(void); bool DiscOk(void); void Eject(void); bool Open(void); void Close(void); void SetDriveSpeed(int DriveSpeed); int getTracks(void) { return tracks; } int readTOC(__u8 format); bool readSectorRaw(int lba, void *sect); bool readSectorXA21(int lba, void *data); bool isLabel(void); cVcd *getVCD(void); const char *DeviceName(void) { return deviceName; } struct cdrom_tocentry vcdEntry[100]; int tracks; struct info_vcd vcdInfo; struct entries_vcd vcdEntries; struct lot_vcd vcdLot; __u8 vcdPsd[CD_XA21_DATASIZE*PSD_VCD_MAX_SIZE]; }; #endif //__VCD_FUNCTIONS_H vcd-0.9/psdcontrol.h0000644000076400001440000000435010743375605013361 0ustar elsausers/* * psdcontrol.h: PSD control of VCD replay * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_PSDCONTROL_H #define __VCD_PSDCONTROL_H #include "functions.h" #include "viewer.h" #include "player.h" // --- cPsdSpiControl ----------------------------------------------------------- class cPsdSpiControl : public cVcdViewerControl { private: static int spi; static cVcd *vcd; static union psd_vcd *psdVcd; static int playInit; static int playTime; static int waitInit; static int waitTime; bool GotoListOffset(__u16 Offs); public: cPsdSpiControl(void); cPsdSpiControl(int Loop); virtual ~cPsdSpiControl(); virtual eOSState ProcessKey(eKeys Key); virtual void Hide(void) {} static void SetItem(int Spi, cVcd *Vcd, union psd_vcd *PsdVcd); }; // --- cPsdVcdControl -------------------------------------------------------- class cPsdVcdControl : public cVcdPlayerControl { private: static int track; static cVcd *vcd; static union psd_vcd *psdVcd; static int playInit; static int playTime; static int waitInit; static int waitTime; bool GotoListOffset(__u16 Offs); public: cPsdVcdControl(void); cPsdVcdControl(int Lba, int Loop, int AutoWait); virtual ~cPsdVcdControl(); virtual eOSState ProcessKey(eKeys Key); virtual void Hide(void) {} static void SetTrack(int Track, cVcd *Vcd, union psd_vcd *PsdVcd); static void SetEntry(int Entry, cVcd *Vcd, union psd_vcd *PsdVcd); }; #endif //__VCD_PSDCONTROL_H vcd-0.9/README0000644000076400001440000002235210745170047011676 0ustar elsausersThis is a "plugin" for the Video Disk Recorder (VDR). Written by: Thomas Heiligenmann Andreas Schultz Project's homepage: http://www.heiligenmann.de/vdr/ Latest version available at: http://www.heiligenmann.de/vdr/download/ See the file ''gpl-2.0.txt'' for license information. Description: This plugin enables VideoCD playback for VDR ------------------------------------------------------------------------------ This plugin adds the functionality to replay VideoCDs (and Super VideoCDs) from within VDR (by Klaus Schmidinger). No additional software packages are required. You'll need at least one physical CD-ROM drive however ;-) (Since data is read by making ioctl calls to /dev/cdrom it should be possible to emulate the physical drive by redirecting this calls to an image on harddisk. It is however out of the scope of the VCD plugin to implement this 'pseudo driver' functionality.) The plugin will add a new entry "VideoCD" into the main menu, if you have installed a CD-ROM drive and created a symbolic link /dev/cdrom . It should also work alongside other plugins using the CD-ROM/DVD drive. ------------------------------------------------------------------------------ Installation: ------------------------------------------------------------------------------ You should have received the file vcd-#.#.tar.gz or vcd-#.#.tar.bz2 where the #s are replaced by the version numbers, eg. vcd-0.7.tar.gz This plugin version was upgraded to to work with VDR Version 1.4.7 and later. Extract the file in VDRs plugins source directory and create a symlink: cd /path/to/vdr-#.#/PLUGINS/src tar xzf vdr-vcd-#.#.tgz ln -s vcd-#.# vcd Cd into VDRs source directory and type 'make plugins' to compile your plugin(s). To load the plugin add the parameter '-Pvcd' when starting VDR. See VDRs plugin documentation for more information. ------------------------------------------------------------------------------ Invocation: ------------------------------------------------------------------------------ Simply call /path/to/vdr -P"vcd" [...] to load the plugin. A command line option ''-v/--vcd'' has been introduced to select another drive than the default ''/dev/cdrom'' for VideoCD replay; e.g. to select your DVD device ''/dev/dvd'' call /path/to/vdr -P"vcd -v /dev/dvd" [...] or /path/to/vdr -P"vcd --vcd=/dev/dvd" [...] Hence the drive will be displayed in VDR's main menu accordingly, e.g.: 4 Recordings 5 VideoCD (/dev/dvd) 6 Setup It's also possible to invoke the plugin more than once with diferent drives: /path/to/vdr -P"vcd" -P"vcd --vcd=/dev/dvd" This will create a second replay device and main menu entry: 4 Recordings 5 VideoCD 6 VideoCD (/dev/dvd) 7 Setup ------------------------------------------------------------------------------ About VideoCDs and Super VideoCDs: ------------------------------------------------------------------------------ VideoCDs/VCDs (White Book) and Super VideoCDs/SVCDs (SVCD Spec.) are build on Green Book CD-ROMs containing at least two tracks: Track 1 is an ISO9660 data track which contains navigation information and may hold addtional data files or MPEG still images etc. Album description is read for display and entry points for navigation. A submenu has been introduced to allow display/replay of segment play items. Version 0.0.6 of the plugin implements processing of the "Play Sequence Descriptor" to automate replay of (S)VCDs. Track 2 up to track 99 are CD-ROM XA mode 2 tracks and hold the MPEG data, which is read by the VideoCD plugin. Playing time = track size is only true for VCDs, which are encoded using constant bit rate (CBR). SVCDs are encoded at a higher quality using variable bit rate (VBR) thus track size won't reflect true playing time. A correct display of true playing time will be implemented in a future release of the VideoCD plugin. There's a couple of web pages, where you'll find more information about VCDs and SVCDs. A good starting point may be http://www.vcdhelper.com For creation of your own (S)VCDs and further information and downloads you should also take a look at http://www.vcdimager.org ------------------------------------------------------------------------------ Navigation: ------------------------------------------------------------------------------ [ the following information only applies when running the plugin in the "classic" replay mode (see below) ] Invoke the "VideoCD" entry in the main menu to get a list of all MPEG tracks displayed as "Track 1" etc. plus track position and track lenght in units of CD-ROM MSF (minutes/seconds/frames). The starting position of Track 1 (= CD track 2 !) is defined as 00:00.00 . Select a track using the 'Up' and 'Down' keys and start replay with 'Red' or 'Ok'. 'Blue' will stop replay. You can control replay with the following keys: Down: Pause Left: Fast backward when in 'Play' mode (ISO62107 SVCDs only) Slow motion undefined yet (should fall back into slow fwd) Right: Slow motion when in 'Pause' mode Fast forward when in 'Play' mode 1: Skip to previous VCD entry 3: Skip to next VCD entry 4: Skip to previous VCD track 5: Skip to beginning of current track 6: Skip to next VCD track Ok: Turn progress bar on/off Red: Time search in units of CD-ROM MSF (see above) Green: Skip -60s Yellow: Skip +60s SVCDs may contain MPEG data with two audio channels. If a second audio channel is available, VDR's toggle mechanism for audio channels will be enabled. The 'Yellow' key in the VideoCD menu will eject the disc loaded in ''/dev/cdrom''. The ''Blue'' key in the VideoCD menu will be enabled if the (S)VCD contains also ''segment play items''. These can be up to 1980 still images or audio/video clips placed in the (S)VCD's data track. The viewer can be controlled with the following keys: 4: Skip to previous item. Skip to first segment of multisegment items. 5: Toggle between low and high resolution of still images. 6: Skip to next item. Version 0.0.6 of the plugin introduces PSD controlled replay mode. This can be enabled in the setup and defines yet the following keys for replay control as required by the PSD menus: 1..9: Goto NUMERIC selection. Ok: Goto DEFAULT selection. Left: Goto PREVIOUS selection. Right: Goto NEXT selection. Back: Goto RETURN selection. Blue: Stop (S)VCD replay. Down: Pause Green: Skip -60s (within current MPEG track) Yellow: Skip +60s (within current MPEG track) Further replay control as defined in "classic" control mode hasn't defined yet under PSD controlled replay! There's also no progress bar available. ------------------------------------------------------------------------------ Setup menu: ------------------------------------------------------------------------------ Drive speed: Adjusts the CD-ROM drive speed in a range of 2..50. Broken mode: May allow playback of (S)VCDs, which aren't fully standard compliant. Enables _ANY_ track to be selected for replay, including the first track on the CD, which normally holds an ISO9660 file system, describes the (S)VCD capabilities, and can hold additional data. Since a validation of the (S)VCD is impossible in this mode, you'll use it on your own risk. Hide main menu entry: This hides - of course - the plugin's entry in VDR's main menu. Play tracks continuously: This is set by default and will continue replay of all tracks. Disabling will stop replay after replay has reached a track's end. Autostart replay: Setting this will start replay of the first available track automagically when invoking the plugin. Under PSD control replay will start with the first PSD entry. Play sequence replay: This will enable PSD controlled replay if "Play Sequence Descriptors" have been defined on the (S)VCD. The last two setup item will give you the following combinations of replay control: Autostart replay = off, Play sequence replay = off This gives you the "classic" replay control of the past versions of the plugin. Tracks or Segment Play Items can be selected individually from a menu. Autostart replay = on, Play sequence replay = off Menus are disabled and replay will start with the first available track when the plugin is invoked. This may be similar to the behaviour of (S)VCD replay on most standard DVD players. Autostart replay = off, Play sequence replay = on PSD entries are displayed in a menu and replay can be started from an individually selected entry. This can be useful for "debugging" your self created (S)VCDs. Autostart replay = on, Play sequence replay = on Menus are disabled and replay will start with the first PSD entry when the plugin is invoked. This may be interesting in conjunction with the VDRCD plugin and work similar to a deluxe standalone DVD player ;-) vcd-0.9/viewer.h0000644000076400001440000000270510743375675012504 0ustar elsausers/* * viewer.h: Viewer core * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #ifndef __VCD_VIEWER_H #define __VCD_VIEWER_H #include #include #include #include #include "functions.h" #define PACK_SC 0xBA class cVcdViewer; class cVcdViewerControl : public cControl { private: cVcdViewer *viewer; public: cVcdViewerControl(int Spi, cVcd *Vcd); virtual ~cVcdViewerControl(); bool Active(void); bool Still(void); int GetSpi(void); void Stop(void); bool SkipItems(int Items); void GotoItem(int Spi); void ToggleStillRes(void); const char *DeviceName(void); }; #endif //__VCD_VIEWER_H vcd-0.9/gpl-2.0.txt0000644000076400001440000004310310740152062012623 0ustar elsausers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. vcd-0.9/psd.c0000644000076400001440000001151210744677017011754 0ustar elsausers/* * psd.c: PSD controlled replay * * VCD Player plugin for VDR (the Video Disk Recorder) * Copyright (C) 2002 Thomas Heiligenmann * * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA * */ #include "i18n.h" #include "psd.h" #include "psdcontrol.h" // --- cVcdPsdItem ----------------------------------------------------------- class cVcdPsdItem : public cOsdItem { private: int lot; union psd_vcd *psdVcd; public: cVcdPsdItem(int Lot, union psd_vcd* PsdVcd); int Lot(void) { return lot; } union psd_vcd* PsdVcd(void) { return psdVcd; } }; cVcdPsdItem::cVcdPsdItem(int Lot, union psd_vcd* PsdVcd) { lot = Lot; psdVcd = PsdVcd; char *buffer = NULL; asprintf(&buffer, "%s %d %s %d", PsdVcd->header==PLAY_LIST_HEADER ? "Play List" : PsdVcd->header==SELECTION_LIST_HEADER ? "Selection List" : "Unknown", PsdVcd->header==PLAY_LIST_HEADER ? U16_TO_LE(PsdVcd->play.list_id) : PsdVcd->header==SELECTION_LIST_HEADER ? U16_TO_LE(PsdVcd->selection.list_id) : 0, PsdVcd->header==PLAY_LIST_HEADER ? PLAY_ITEM_STR(U16_TO_LE(PsdVcd->play.play_item[0])) : PsdVcd->header==SELECTION_LIST_HEADER ? PLAY_ITEM_STR(U16_TO_LE(PsdVcd->selection.play_item)) : "?", PsdVcd->header==PLAY_LIST_HEADER ? PLAY_ITEM_NO(U16_TO_LE(PsdVcd->play.play_item[0])) : PsdVcd->header==SELECTION_LIST_HEADER ? PLAY_ITEM_NO(U16_TO_LE(PsdVcd->selection.play_item)) : 0 ); SetText(buffer, false); } // --- cVcdPsd --------------------------------------------------------------- cVcdPsd::cVcdPsd(cVcd *Vcd) : cOsdMenu(tr("VideoCD")) { vcd = Vcd; validList = false; if (vcd->isLabel()) { for (int i=1; i<=U16_TO_LE(vcd->vcdInfo.max_list_id); i++) { int offs = vcd->vcdInfo.offset_multiplier * U16_TO_LE(vcd->vcdLot.list_id_offset[i]); union psd_vcd *psdVcd = (union psd_vcd*)(&(vcd->vcdPsd[offs])); if (psdVcd->header==END_LIST_HEADER) break; else { Add(new cVcdPsdItem(i, psdVcd)); validList = true; } } } else Add(new cOsdItem(tr("No VideoCD detected"))); SetHelp( validList ? tr("Key$Play") : NULL, NULL, vcd->DiscOk() ? tr("Eject") : NULL, NULL ); Display(); } cVcdPsd::~cVcdPsd() { } eOSState cVcdPsd::Eject(void) { if (vcd->DiscOk()) { dsyslog("VCD: Eject"); memset(&(vcd->vcdEntries), 0, sizeof(vcd->vcdEntries)); vcd->Eject(); vcd->Close(); return osStopReplay; } return osContinue; } eOSState cVcdPsd::Play(void) { if (validList) { cVcdPsdItem *vpi = (cVcdPsdItem*)Get(Current()); if (vpi) { if (vpi->PsdVcd()->header==PLAY_LIST_HEADER) { __u16 item = U16_TO_LE(vpi->PsdVcd()->play.play_item[0]); if (PLAY_ITEM_TYP(item)==piTrack) cPsdVcdControl::SetTrack(PLAY_ITEM_NO(item), vcd, vpi->PsdVcd()); else if (PLAY_ITEM_TYP(item)==piEntry) cPsdVcdControl::SetEntry(PLAY_ITEM_NO(item), vcd, vpi->PsdVcd()); else if (PLAY_ITEM_TYP(item)==piSpi) cPsdSpiControl::SetItem(PLAY_ITEM_NO(item), vcd, vpi->PsdVcd()); dsyslog("VCD: Lot %d Play list", vpi->Lot()); } else if (vpi->PsdVcd()->header==SELECTION_LIST_HEADER) { __u16 item = U16_TO_LE(vpi->PsdVcd()->selection.play_item); if (PLAY_ITEM_TYP(item)==piTrack) cPsdVcdControl::SetTrack(PLAY_ITEM_NO(item) , vcd, vpi->PsdVcd()); else if (PLAY_ITEM_TYP(item)==piEntry) cPsdVcdControl::SetEntry(PLAY_ITEM_NO(item), vcd, vpi->PsdVcd()); else if (PLAY_ITEM_TYP(item)==piSpi) cPsdSpiControl::SetItem(PLAY_ITEM_NO(item), vcd, vpi->PsdVcd()); dsyslog("VCD: Lot %d Selection list", vpi->Lot()); } else dsyslog("VCD: Lot %d Unknown", vpi->Lot()); return osEnd; } } return osContinue; } eOSState cVcdPsd::ProcessKey(eKeys Key) { eOSState state = cOsdMenu::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case kOk: case kRed: return Play(); case kYellow: return Eject(); default: break; } } return state; }