void shutdownBox() { lcdd.shutdown(); zapit.shutdown(); timerd.shutdown(); saveSettings(); if (execlp("/sbin/halt", "/sbin/halt", 0)<0) { perror("exec failed - halt\n"); } }
int main (int argc, char** argv) { int i; uint32_t j; //uint32_t k; uint64_t ii; int bouquet = -1; unsigned int channel = 0; unsigned int count; int diseqcRepeats = -1; int diseqcType = -1; uint64_t satmask = 0xFFFF; int audio = 0; int mute = -1; int volume = -1; int nvod = -1; int arat = -1; int m43 = -1; int lockrc = -1; const char * channelName = NULL; bool playback = false; bool recordmode = false; bool radio = false; bool reload = false; bool register_neutrino = false; bool savebouquets = false; bool show_satellites = false; bool set_pal = false; int set_hd = 0; bool scan = false; bool rezap = false; bool zapByName = false; bool killzapit = false; bool enterStandby = false; bool leaveStandby = false; bool sendMotorCommand = false; bool quiet = false; bool getchannel = false; bool aspectratio = false; bool mode43 = false; uint8_t motorCmdType = 0; uint8_t motorCmd = 0; uint8_t motorNumParameters = 0; uint8_t motorParam1 = 0; uint8_t motorParam2 = 0; uint8_t motorAddr = 0; uint32_t diseqc[5]; unsigned int tmp; int scan_mode = 1; t_channel_id zapsid = 0; /* command line */ for (i = 1; i < argc; i++) { if (!strncmp(argv[i], "-a", 2)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &audio); continue; } } else if (!strncmp(argv[i], "-dr", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &diseqcRepeats); continue; } } else if (!strncmp(argv[i], "-dt", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &diseqcType); continue; } } else if (!strncmp(argv[i], "-q", 2)) { quiet = true; continue; } else if (!strncmp(argv[i], "-c", 2)) { reload = true; continue; } else if (!strncmp(argv[i], "-esb", 4)) { enterStandby = true; continue; } else if (!strncmp(argv[i], "-kill", 5)) { killzapit = true; continue; } else if (!strncmp(argv[i], "-lsb", 4)) { leaveStandby = true; continue; } else if (!strncmp(argv[i], "-rz", 3)) { rezap = true; continue; } else if (!strncmp(argv[i], "-mute", 5)) { mute = 1; continue; } else if (!strncmp(argv[i], "-m", 2)) { if (i < argc - 6) { sscanf(argv[++i], "%x", &tmp); motorCmdType = tmp; sscanf(argv[++i], "%x", &tmp); motorAddr = tmp; sscanf(argv[++i], "%x", &tmp); motorCmd = tmp; sscanf(argv[++i], "%x", &tmp); motorNumParameters = tmp; sscanf(argv[++i], "%x", &tmp); motorParam1 = tmp; sscanf(argv[++i], "%x", &tmp); motorParam2 = tmp; printf("[pzapit] motor command = %x %x %x %x %x %x\n", motorCmdType, motorAddr, motorCmd, motorNumParameters, motorParam1, motorParam2); sendMotorCommand = true; continue; } } else if (!strncmp(argv[i], "-rn", 3)) { register_neutrino = true; continue; } else if (!strncmp(argv[i], "-nvod", 5)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &nvod); continue; } } else if (!strncmp(argv[i], "-n", 2)) { if (i < argc - 1) { zapByName = true; channelName = argv[++i]; continue; } } else if (!strncmp(argv[i], "-p", 2)) { playback = true; continue; } else if (!strncmp(argv[i], "-ra", 3)) { radio = true; continue; } else if (!strncmp(argv[i], "-re", 3)) { recordmode = true; continue; } else if (!strncmp(argv[i], "-var", 4)) { aspectratio = true; if (i < argc - 1) sscanf(argv[++i], "%d", &arat); continue; } else if (!strncmp(argv[i], "-vm43", 5)) { mode43 = true; if (i < argc - 1) { sscanf(argv[++i], "%d", &m43); continue; } #if 0 //FIXME howto read aspect mode back? continue; #endif } else if (!strncmp(argv[i], "-sb", 3)) { savebouquets = true; continue; } else if (!strncmp(argv[i], "-se", 3)) { if (i < argc - 2) { sscanf(argv[++i], "%" SCNd64 "", &satmask); sscanf(argv[++i], "%d", &diseqc[0]); /* diseqc[0] = strlen(argv[i+1]); for (i++, j = 0; j <= diseqc[0]; j++) { diseqc[j+1] = argv[i][j] - 48; } */ continue; } } else if (!strncmp(argv[i], "-sh", 3)) { show_satellites = true; continue; } else if (!strncmp(argv[i], "-st", 3)) { scan = true; if (i < argc - 1) { sscanf(argv[++i], "%d", &scan_mode); } continue; } else if (!strncmp(argv[i], "--pal", 4)) { set_pal = true; continue; } else if (!strncmp(argv[i], "--1080", 6)) { set_hd = 8; continue; } else if (!strncmp(argv[i], "--1083", 6)) { set_hd = 9; continue; } else if (!strncmp(argv[i], "--1082", 6)) { set_hd = 10; continue; } else if (!strncmp(argv[i], "--720", 5)) { set_hd = 7; continue; } else if (!strncmp(argv[i], "-unmute", 7)) { mute = 0; continue; } else if (!strncmp(argv[i], "-vol", 4)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &volume); continue; } } else if (!strncmp(argv[i], "-gi", 3)) { getchannel = true; continue; } else if (!strncmp(argv[i], "-zi", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%" SCNx64 "", &zapsid); continue; } } else if (!strncmp(argv[i], "-lockrc", 7)) { lockrc = 1; continue; } else if (!strncmp(argv[i], "-unlockrc", 9)) { lockrc = 0; continue; } else if (i < argc - 1) { if ((sscanf(argv[i], "%d", &bouquet) > 0) && (sscanf(argv[++i], "%u", &channel) > 0)) continue; } else if (sscanf(argv[i], "%d", &bouquet) > 0) continue; return usage(argv[0]); } /* create zapit client */ CZapitClient zapit; #if 0 TP_params TP; TP.TP_id = 12345; TP.polarization = 1; TP.feparams.Frequency = 11727000; TP.feparams.u.qpsk.SymbolRate = 27500000; TP.feparams.u.qpsk.FEC_inner = (CodeRate) 3; zapit.scan_TP(TP); exit(0); #endif /* send diseqc 1.2 motor command */ if (sendMotorCommand) { zapit.sendMotorCommand(motorCmdType, motorAddr, motorCmd, motorNumParameters, motorParam1, motorParam2); return 0; } /* kill zapit*/ if (killzapit) { zapit.shutdown(); std::cout << "zapit shot down :)" << std::endl; return 0; } if (enterStandby) { zapit.setStandby(true); return 0; } if (leaveStandby) { zapit.setStandby(false); return 0; } /* audio mute */ if (mute != -1) { std::cout << "mute/unmute" << std::endl; zapit.muteAudio(mute); return 0; } if (volume != -1) { std::cout << "set volume" << std::endl; zapit.setVolume(volume, volume); return 0; } if (lockrc != -1) { zapit.lockRc(lockrc); return 0; } if (rezap) { zapit.Rezap(); return 0; } /* reload services */ if (reload) { std::cout << "reloading channels" << std::endl; zapit.reinitChannels(); return 0; } if (register_neutrino) { #define NEUTRINO_UDS_NAME "/tmp/neutrino.sock" std::cout << "registering neutrino" << std::endl; for (int ic = CZapitClient::FIRST_EVENT_MARKER; ic < CZapitClient::LAST_EVENT_MARKER; ic++) zapit.registerEvent(ic, 222, NEUTRINO_UDS_NAME); return 0; } if (diseqcType != -1) { zapit.setDiseqcType((diseqc_t) diseqcType); if (diseqcRepeats == -1) return 0; } if (diseqcRepeats != -1) { zapit.setDiseqcRepeat(diseqcRepeats); return 0; } if (playback) { if (zapit.isPlayBackActive()) zapit.stopPlayBack(); else zapit.startPlayBack(); if (!recordmode) return 0; } if (recordmode) { zapit.setRecordMode(!zapit.isRecordModeActive()); return 0; } if (aspectratio) { if(arat >= 0) zapit.setAspectRatio(arat); else { zapit.getAspectRatio(&arat); printf("%d\n", arat); } return 0; } if (mode43) { if(m43 >= 0) zapit.setMode43(m43); else { zapit.getMode43(&m43); printf("%d\n",m43); } return 0; } if (savebouquets) { zapit.saveBouquets(); return 0; } if (show_satellites) { std::vector<CZapitClient::responseGetSatelliteList> satelliteList; zapit.getScanSatelliteList(satelliteList); std::vector<CZapitClient::responseGetSatelliteList>::const_iterator rI; for ( ii = 0, rI = satelliteList.begin(); rI != satelliteList.end(); ii++, rI++) printf("%" PRId64 " : %s %d\n", ii, rI->satName, rI->satPosition); //std::cout << (1 << ii) << ": " << rI->satName << std::endl; return 0; } else if (satmask != 0xFFFF) { std::vector<CZapitClient::responseGetSatelliteList> satelliteList; zapit.getScanSatelliteList(satelliteList); std::vector<CZapitClient::commandSetScanSatelliteList> newSatelliteList; CZapitClient::commandSetScanSatelliteList item; for (j = 0; j < satelliteList.size(); j++) { if (satmask == j) { std::cout << "diseqc " << diseqc[0] << ": " << satelliteList[j].satName << std::endl; cstrncpy(item.satName, satelliteList[j].satName, sizeof(item.satName) - 1); item.position = diseqc[0]; newSatelliteList.push_back(item); break; } } zapit.setScanSatelliteList(newSatelliteList); return 0; } /* transponderscan */ if (scan) { unsigned int satellite; unsigned int processed_transponder; unsigned int transponder; unsigned int services; printf("Start scan, mode %d\n", scan_mode); zapit.startScan(scan_mode); while (zapit.isScanReady(satellite, processed_transponder, transponder, services) == false) { std::cout << "satellite: " << satellite << ", transponder: " << processed_transponder <<", of: " << transponder << ", services: " << services << std::endl; sleep(1); } return 0; } if (set_pal) { //zapit.stopPlayBack(); zapit.setVideoSystem(2); //zapit.startPlayBack(); return 0; } if (set_hd) { //zapit.stopPlayBack(); zapit.setVideoSystem(set_hd); //zapit.startPlayBack(); return 0; } if (getchannel) { t_channel_id channelid = zapit.getCurrentServiceID(); printf("%" PRIx64 " (%s)\n", channelid, (zapit.getChannelName(channelid)).c_str()); return 0; } /* choose source mode */ zapit.setMode(radio ? CZapitClient::MODE_RADIO : CZapitClient::MODE_TV); if (zapsid > 0) { printf("Zapping to: %" PRIx64 " (%s) ", zapsid, (zapit.getChannelName(zapsid)).c_str()); tmp = zapit.zapTo_serviceID(zapsid); if (!tmp) printf("failed"); printf("\n"); return tmp; } /* set audio channel */ if (audio) { zapit.setAudioChannel(audio - 1); return 0; } if (nvod != -1) { zapit.zaptoNvodSubService(nvod); return 0; } else { std::vector<CZapitClient::responseGetBouquetChannels> channels; if (zapByName) { zapit.getChannels(channels); std::vector<CZapitClient::responseGetBouquetChannels>::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, ++channel) { if (!strcasecmp(ch_resp->name, channelName)) { std::cout << "found channel number: " << channel << std::endl; goto channel_found; } } std::cout << "channel not found." << std::endl; return 0; } else /* zap by bouquet number and channel number */ { /* read channel list */ if (bouquet != -1) zapit.getBouquetChannels(bouquet - 1, channels, CZapitClient::MODE_CURRENT, true); /* display bouquet list */ else { std::vector<CZapitClient::responseGetBouquets> bouquets; std::vector<CZapitClient::responseGetBouquets>::const_iterator b_resp; zapit.getBouquets(bouquets, false); for (b_resp = bouquets.begin(); b_resp != bouquets.end(); ++b_resp) std::cout << (b_resp->bouquet_nr + 1) << ": " << b_resp->name << std::endl; return 0; } /* display channel list */ if (!channel) { std::vector<CZapitClient::responseGetBouquetChannels>::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, ++channel) //std::cout << channel << ": " << ch_resp->name << ": " << ch_resp->channel_id<< std::endl; printf("%3d: %s (%04x)\n", channel, ch_resp->name, (short) (ch_resp->channel_id &0xFFFF)); return 0; } } /* zap */ if (channel > channels.size()) { std::cout << "Only " << channels.size() << " channels in bouquet " << bouquet << std::endl; return 0; } channel_found: zapit.zapTo(channels[channel-1].nr); std::cout << "zapped to " << channels[channel-1].name << std::endl; } if (!quiet) { CZapitClient::responseGetPIDs pids; zapit.getPIDS(pids); if (pids.PIDs.vpid) std::cout << " video: 0x" << std::hex << pids.PIDs.vpid << std::endl; if (pids.PIDs.vtxtpid) std::cout << "teletext: 0x" << std::hex << pids.PIDs.vtxtpid << std::endl; if (pids.PIDs.pcrpid) std::cout << " pcr: 0x" << std::hex << pids.PIDs.pcrpid << std::endl; for (count = 0; count < pids.APIDs.size(); count++) { std::cout << " audio " << std::dec << count + 1 << ": 0x" << std::hex << pids.APIDs[count].pid << " (" << pids.APIDs[count].desc; if (pids.APIDs[count].is_ac3) std::cout << ", ac3"; else if (pids.APIDs[count].is_aac) std::cout << ", aac"; else std::cout << ", unknown"; std::cout << ")" << std::endl; } } return 0; }
int main (int argc, char** argv) { int i; uint32_t j; uint32_t k; int bouquet = -1; unsigned int channel = 0; unsigned int count; int diseqcRepeats = -1; int diseqcType = -1; int satmask = 0; int audio = 0; int mute = -1; int volume = -1; int nvod = -1; int fastzap = -1; t_channel_id zapsid = 0; const char * channelName = NULL; bool playback = false; bool recordmode = false; bool radio = false; bool reload = false; bool register_neutrino = false; bool savebouquets = false; bool show_satellites = false; bool set_pal = false; bool set_ntsc = false; bool scan = false; bool zapByName = false; bool rezap = false; bool killzapit = false; bool savezapit = false; bool enterStandby = false; bool leaveStandby = false; bool sendMotorCommand = false; #ifdef HAVE_DBOX_HARDWARE bool Iecon = false; bool Iecoff = false; bool Iecstate = false; bool pes = false; bool spts = false; bool decmode = false; #endif #ifdef HAVE_TRIPLEDRAGON bool zoom = false; int zoomlevel = 0; bool pig = false; bool avinfo = false; int pig_x = 0; int pig_y = 0; int pig_w = 0; int pig_h = 0; int pig_a = 0; #endif bool getchannel = false; bool getmode = false; bool getpids = false; bool includeBouquetOthers = false; bool getserviceinfo = false; uint8_t motorCmdType = 0; uint8_t motorCmd = 0; uint8_t motorNumParameters = 0; uint8_t motorParam1 = 0; uint8_t motorParam2 = 0; uint8_t motorAddr = 0; uint32_t diseqc[5]; unsigned int tmp; /* command line */ for (i = 1; i < argc; i++) { if (!strncmp(argv[i], "-a", 2)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &audio); continue; } } else if (!strncmp(argv[i], "-dr", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &diseqcRepeats); continue; } } else if (!strncmp(argv[i], "-dt", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &diseqcType); continue; } } else if (!strncmp(argv[i], "-c", 2)) { reload = true; continue; } else if (!strncmp(argv[i], "-gm", 3)) { getmode = true; continue; } else if (!strncmp(argv[i], "-gi", 3)) { getchannel = true; continue; } else if (!strncmp(argv[i], "-rz", 3)) { rezap = true; continue; } else if (!strncmp(argv[i], "-zi", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%llx", &zapsid); continue; } } else if (!strncmp(argv[i], "-esb", 4)) { enterStandby = true; continue; } else if (!strncmp(argv[i], "-kill", 5)) { killzapit = true; continue; } else if (!strncmp(argv[i], "-lsb", 4)) { leaveStandby = true; continue; } else if (!strncmp(argv[i], "-motor", 6)) { if (i < argc - 6) { sscanf(argv[++i], "%x", &tmp); motorCmdType = tmp; sscanf(argv[++i], "%x", &tmp); motorAddr = tmp; sscanf(argv[++i], "%x", &tmp); motorCmd = tmp; sscanf(argv[++i], "%x", &tmp); motorNumParameters = tmp; sscanf(argv[++i], "%x", &tmp); motorParam1 = tmp; sscanf(argv[++i], "%x", &tmp); motorParam2 = tmp; printf("[pzapit] motor command = %x %x %x %x %x %x\n", motorCmdType, motorAddr, motorCmd, motorNumParameters, motorParam1, motorParam2); sendMotorCommand = true; continue; } } else if (!strncmp(argv[i], "-rn", 3)) { register_neutrino = true; continue; } else if (!strncmp(argv[i], "-mute", 5)) { mute = 1; continue; } else if (!strncmp(argv[i], "-nvod", 5)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &nvod); continue; } } else if (!strncmp(argv[i], "-n", 2)) { if (i < argc - 1) { zapByName = true; channelName = argv[++i]; continue; } } else if (!strncmp(argv[i], "-p", 2)) { playback = true; continue; } else if (!strncmp(argv[i], "-ra", 3)) { radio = true; continue; } else if (!strncmp(argv[i], "-re", 3)) { recordmode = true; continue; } // don't change order with "-sb" or the other will always be found first else if (!strncmp(argv[i], "-sbo", 4)) { savebouquets = true; includeBouquetOthers = true; continue; } else if (!strncmp(argv[i], "-sb", 3)) { savebouquets = true; continue; } else if (!strncmp(argv[i], "-se", 3)) { if (i < argc - 2) { sscanf(argv[++i], "%d", &satmask); diseqc[0] = strlen(argv[i+1]); for (i++, j = 0; j <= diseqc[0]; j++) { diseqc[j+1] = argv[i][j] - 48; } continue; } } else if (!strncmp(argv[i], "-sh", 3)) { show_satellites = true; continue; } else if (!strncmp(argv[i], "-st", 3)) { scan = true; continue; } else if (!strncmp(argv[i], "--pal", 4)) { set_pal = true; continue; } else if (!strncmp(argv[i], "--ntsc", 5)) { set_ntsc = true; continue; } else if (!strncmp(argv[i], "-unmute", 7)) { mute = 0; continue; } #ifdef HAVE_DBOX_HARDWARE else if (!strncmp(argv[i], "--iecon", 7)) { Iecon = true; continue; } else if (!strncmp(argv[i], "--iecoff", 8)) { Iecoff = true; continue; } else if (!strncmp(argv[i], "--iecstate", 10)) { Iecstate = true; continue; } else if (!strncmp(argv[i], "--pes", 5)) { pes = true; continue; } else if (!strncmp(argv[i], "--spts", 6)) { spts = true; continue; } else if (!strncmp(argv[i], "--decmode", 9)) { decmode = true; continue; } #endif #ifdef HAVE_TRIPLEDRAGON else if (!strncmp(argv[i], "--zoom", 6)) { zoom = true; if (i < argc - 1) { sscanf(argv[++i], "%d", &zoomlevel); } continue; } else if (!strncmp(argv[i], "--pig", 5)) { pig = true; if (i < argc - 1) { sscanf(argv[++i], "%d", &pig_x); } if (i < argc - 1) { sscanf(argv[++i], "%d", &pig_y); } if (i < argc - 1) { sscanf(argv[++i], "%d", &pig_w); } if (i < argc - 1) { sscanf(argv[++i], "%d", &pig_h); } if (i < argc - 1) { sscanf(argv[++i], "%d", &pig_a); } continue; } else if (!strncmp(argv[i], "--avinfo", 6)) { avinfo = true; continue; } #endif else if (!strncmp(argv[i], "-vol", 4)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &volume); continue; } } else if (!strncmp(argv[i], "--fastzap", 9)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &fastzap); continue; } } else if (!strncmp(argv[i], "--getpids", 9)) { getpids = true; continue; } else if (!strncmp(argv[i], "-gsi", 4)) { getserviceinfo = true; continue; } else if (!strncmp(argv[i], "-save", 5)) { savezapit = true; continue; } else if (i < argc - 1) { if ((sscanf(argv[i], "%d", &bouquet) > 0) && (sscanf(argv[++i], "%u", &channel) > 0)) continue; } else if (sscanf(argv[i], "%d", &bouquet) > 0) continue; return usage(argv[0]); } /* create zapit client */ CZapitClient zapit; /* send diseqc 1.2 motor command */ if (sendMotorCommand) { zapit.sendMotorCommand(motorCmdType, motorAddr, motorCmd, motorNumParameters, motorParam1, motorParam2); } /* kill zapit*/ if (killzapit) { zapit.shutdown(); std::cout << "zapit shot down :)" << std::endl; return 0; } if (enterStandby) { zapit.setStandby(true); return 0; } if (leaveStandby) { zapit.setStandby(false); return 0; } if (fastzap > -1) { zapit.setFastZap(fastzap != 0); return 0; } if (getmode) { int mode = zapit.getMode(); // 1 = TV, 2 = Radio std::cout << "Mode: " << mode; if (mode == CZapitClient::MODE_TV) std::cout << " (TV)" << std::endl; else if (mode == CZapitClient::MODE_RADIO) std::cout << " (Radio)" << std::endl; else std::cout << " (unknown!)" << std::endl; return mode; } if (getchannel) { int mode = zapit.getMode(); if (mode == CZapitClient::MODE_STANDBY) { std::cerr << "zapit is in standby mode, no channel active." << std::endl; return 1; } t_channel_id c = zapit.getCurrentServiceID(); printf("%llx (%s)\n", c, (zapit.getChannelName(c)).c_str()); return 0; } if (rezap) { zapit.ReZap(); return 0; } /* audio mute */ if (mute != -1) { std::cout << "mute/unmute" << std::endl; zapit.muteAudio(mute); return 0; } if (volume != -1) { std::cout << "set volume" << std::endl; zapit.setVolume(volume, volume); return 0; } #ifdef HAVE_DBOX_HARDWARE if (Iecon) { std::cout << "Iec on" << std::endl; zapit.IecOn(); return 0; } if (Iecoff) { std::cout << "Iec off" << std::endl; zapit.IecOff(); return 0; } if (Iecstate) { std::cout << "Iec state = " << zapit.IecState() << std::endl; return 0; } if (pes) { std::cout << "set decoder to PES mode" << std::endl; zapit.PlaybackPES(); return 0; } if (spts) { std::cout << "set decoder to SPTS mode" << std::endl; zapit.PlaybackSPTS(); return 0; } if (decmode) { std::cout << "decoder mode = " << zapit.PlaybackState() << std::endl; return 0; } #endif #ifdef HAVE_TRIPLEDRAGON if (zoom) { if (zoomlevel > 0) zapit.setZoom(zoomlevel); std::cout << "zoom = " << zapit.getZoom() << "%" << std::endl; return 0; } if (pig) { zapit.setPIG(pig_x, pig_y, pig_w, pig_h, !!pig_a); std::cout << "pig = " << pig_x << "." << pig_y << "." << pig_w << "." << pig_h << ":" << pig_a << std::endl; return 0; } if (avinfo) { AVInfo v = zapit.getAVInfo(); std::cout << "h_size = " << v.vinfo.h_size << " v_size = " << v.vinfo.v_size << " ar = " << v.vinfo.pel_aspect_ratio << " rate = " << v.vinfo.frame_rate << std::endl; printf("atype = %d astatus0 = 0x%08x astatus1 = 0x%08x\n", v.atype, v.astatus.word00, v.astatus.word01); return 0; } #endif /* reload services */ if (reload) { std::cout << "reloading channels" << std::endl; zapit.reinitChannels(); return 0; } if (register_neutrino) { #define NEUTRINO_UDS_NAME "/tmp/neutrino.sock" std::cout << "registering neutrino" << std::endl; for (i = CZapitClient::FIRST_EVENT_MARKER; i < CZapitClient::LAST_EVENT_MARKER; i++) zapit.registerEvent(i, 222, NEUTRINO_UDS_NAME); return 0; } if (diseqcType != -1) { zapit.setDiseqcType((diseqc_t) diseqcType); if (diseqcRepeats == -1) return 0; } if (diseqcRepeats != -1) { zapit.setDiseqcRepeat(diseqcRepeats); return 0; } if (playback) { if (zapit.isPlayBackActive()) zapit.stopPlayBack(); else zapit.startPlayBack(); if (!recordmode) return 0; } if (recordmode) { zapit.setRecordMode(!zapit.isRecordModeActive()); return 0; } if (savebouquets) { zapit.saveBouquets(includeBouquetOthers); return 0; } if (show_satellites) { std::vector<CZapitClient::responseGetSatelliteList> satelliteList; zapit.getScanSatelliteList(satelliteList); std::vector<CZapitClient::responseGetSatelliteList>::const_iterator rI; for (i = 0, rI = satelliteList.begin(); rI != satelliteList.end(); i++, rI++) std::cout << (1 + i) << ": " << rI->satName << std::endl; return 0; } else if (satmask != 0) { std::vector<CZapitClient::responseGetSatelliteList> satelliteList; zapit.getScanSatelliteList(satelliteList); std::vector<CZapitClient::commandSetScanSatelliteList> newSatelliteList; CZapitClient::commandSetScanSatelliteList item; for (i = 1, j = 0, k = 0; j < satelliteList.size(); i = (i << 1), k++) { if (satmask & i) { j++; std::cout << "diseqc " << diseqc[j] << ": " << satelliteList[k].satName << std::endl; strcpy(item.satName, satelliteList[k].satName); item.diseqc = diseqc[j]; newSatelliteList.push_back(item); } if ((j >= diseqc[0]) || (k >= satelliteList.size())) { break; } } zapit.setScanSatelliteList(newSatelliteList); return 0; } /* transponderscan */ if (scan) { unsigned int satellite; unsigned int processed_transponder; unsigned int transponder; unsigned int services; zapit.startScan(1); while (zapit.isScanReady(satellite, processed_transponder, transponder, services) == false) { std::cout << "satellite: " << satellite << ", transponder: " << processed_transponder <<", of: " << transponder << ", services: " << services << std::endl; sleep(1); } return 0; } if (set_pal) { zapit.stopPlayBack(); zapit.setVideoSystem_a(PAL); zapit.startPlayBack(); return 0; } if (set_ntsc) { zapit.stopPlayBack(); zapit.setVideoSystem_a(NTSC); zapit.startPlayBack(); return 0; } /* set audio channel */ if (audio) { zapit.setAudioChannel(audio - 1); return 0; } if (nvod != -1) { zapit.zaptoNvodSubService(nvod); return 0; } if (getpids) { CZapitClient::responseGetPIDs pids; zapit.getPIDS(pids); if (pids.PIDs.vpid) std::cout << " video: 0x" << std::hex << pids.PIDs.vpid << std::endl; if (pids.PIDs.ecmpid) std::cout << " ecmpid: 0x" << std::hex << pids.PIDs.ecmpid << std::endl; if (pids.PIDs.vtxtpid) std::cout << "teletext: 0x" << std::hex << pids.PIDs.vtxtpid << std::endl; if (pids.PIDs.pcrpid) std::cout << " pcr: 0x" << std::hex << pids.PIDs.pcrpid << std::endl; if (pids.PIDs.pmtpid) std::cout << " pmt: 0x" << std::hex << pids.PIDs.pmtpid << std::endl; if (pids.PIDs.privatepid) std::cout << " private: 0x" << std::hex << pids.PIDs.privatepid << std::endl; for (count = 0; count < pids.APIDs.size(); count++) { if (count == pids.PIDs.selected_apid) std::cout << "*"; else std::cout << " "; std::cout << "audio " << std::dec << count + 1 << ": 0x" << std::hex << pids.APIDs[count].pid << " (" << pids.APIDs[count].desc; if (pids.APIDs[count].is_ac3) std::cout << ", ac3"; std::cout << ")" << std::endl; } for (count = 0 ; count < pids.SubPIDs.size() ; count++) { if (pids.SubPIDs[count].pid != pids.PIDs.vtxtpid) { std::cout << "DVB-Sub " << std::dec << count + 1 << ": 0x" << std::hex << pids.SubPIDs[count].pid << " (" << pids.SubPIDs[count].desc << ")" << std::endl; } else { std::cout << "TTX-Sub " << std::dec << count + 1 << ": " << pids.SubPIDs[count].composition_page << " (" << pids.SubPIDs[count].desc << ")" << std::endl; } } return 0; } if (getserviceinfo) { CZapitClient::CCurrentServiceInfo si; si = zapit.getCurrentServiceInfo(); printf("frequency = %d.%d MHz", si.tsfrequency/1000, si.tsfrequency%1000); if (si.polarisation != 2) /* only satellite has polarisation */ { printf(" (%c)\n", (si.polarisation == HORIZONTAL) ? 'h' : 'v'); //satellite printf("diseqc = %d\n", si.diseqc); } else { printf("\n"); } printf("onid = 0x%04x\n", si.onid); printf("sid = 0x%04x\n", si.sid); printf("tsid = 0x%04x\n", si.tsid); printf("pmtpid = 0x%04x\n", si.pmtpid); printf("vpid = 0x%04x\n", si.vpid); printf("apid = 0x%04x\n", si.apid); printf("spid = 0x%04x\n", si.spid); printf("spage = 0x%04x\n", si.spage); printf("pcrpid = 0x%04x\n", si.pcrpid); printf("vtxtpid = 0x%04x\n", si.vtxtpid); return 0; } /* save zapit*/ if (savezapit) { zapit.saveSettings(); std::cout << "zapit settings saved" << std::endl; return 0; } /* if we got here, we want to zap by name, bouquet / number or onidsid */ /* choose source mode */ zapit.setMode(radio ? CZapitClient::MODE_RADIO : CZapitClient::MODE_TV); if (zapsid > 0) { printf("Zapping to: %llx (%s) ", zapsid, (zapit.getChannelName(zapsid)).c_str()); tmp = zapit.zapTo_serviceID(zapsid); if (!tmp) printf("failed"); printf("\n"); return tmp; } std::vector<CZapitClient::responseGetBouquetChannels> channels; if (zapByName) { zapit.getChannels(channels); std::vector<CZapitClient::responseGetBouquetChannels>::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, channel++) { if (!strcasecmp(ch_resp->name, channelName)) { std::cout << "found channel number: " << channel << std::endl; goto channel_found; } } std::cout << "channel not found." << std::endl; return 0; } else /* zap by bouquet number and channel number */ { /* read channel list */ if (bouquet != -1) zapit.getBouquetChannels(bouquet - 1, channels); /* display bouquet list */ else { std::vector<CZapitClient::responseGetBouquets> bouquets; std::vector<CZapitClient::responseGetBouquets>::const_iterator b_resp; zapit.getBouquets(bouquets, false); for (b_resp = bouquets.begin(); b_resp != bouquets.end(); b_resp++) std::cout << (b_resp->bouquet_nr + 1) << ": " << b_resp->name << std::endl; return 0; } /* display channel list */ if (!channel) { std::vector<CZapitClient::responseGetBouquetChannels>::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, channel++) std::cout << channel << ": " << ch_resp->name << std::endl; return 0; } } /* zap */ if (channel > channels.size()) { std::cout << "Only " << channels.size() << " channels in bouquet " << bouquet << std::endl; return 0; } channel_found: zapit.zapTo(channels[channel-1].nr); std::cout << "zapped to " << channels[channel-1].name << std::endl; return 0; }