Esempio n. 1
0
/* 
 * create filename member from channel name and its current EPG data,
 * with added date and time including msecs and suffix for selected format 
 */
void CScreenShot::MakeFileName(const t_channel_id channel_id)
{
	char		fname[512]; // UTF-8
	std::string	channel_name;
	CEPGData	epgData;
	unsigned int	pos = 0;

	snprintf(fname, sizeof(fname), "%s/", g_settings.screenshot_dir.c_str());
	pos = strlen(fname);

	channel_name = CServiceManager::getInstance()->GetServiceName(channel_id);
	if (!(channel_name.empty())) {
		strcpy(&(fname[pos]), UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
		ZapitTools::replace_char(&fname[pos]);
		strcat(fname, "_");
	}
	pos = strlen(fname);

	if(CEitManager::getInstance()->getActualEPGServiceKey(channel_id, &epgData)) {
		CShortEPGData epgdata;
		if(CEitManager::getInstance()->getEPGidShort(epgData.eventID, &epgdata)) {
			if (!(epgdata.title.empty())) {
				strcpy(&(fname[pos]), epgdata.title.c_str());
				ZapitTools::replace_char(&fname[pos]);
			}
		}
	}
	if (g_settings.screenshot_cover != 1) {
	pos = strlen(fname);

	struct timeval tv;
	gettimeofday(&tv, NULL);
	strftime(&(fname[pos]), sizeof(fname) - pos - 1, "_%Y%m%d_%H%M%S", localtime(&tv.tv_sec));
	pos = strlen(fname);
	snprintf(&(fname[pos]), sizeof(fname) - pos - 1, "_%03d", (int) tv.tv_usec/1000);
	}

	switch (format) {
	case FORMAT_PNG:
		strcat(fname, ".png");
		break;
	default:
		printf("CScreenShot::MakeFileName unsupported format %d, using jpeg\n", format);
	case FORMAT_JPG:
		strcat(fname, ".jpg");
		break;
	case FORMAT_BMP:
		strcat(fname, ".bmp");
		break;
	}
	printf("CScreenShot::MakeFileName: [%s]\n", fname);
	filename = std::string(fname);
}
Esempio n. 2
0
void CVCRControl::CFileDevice::appendChannelName(char *buf, unsigned int size, const t_channel_id channel_id) {
	
	if (size > 0)
		buf[0] = '\0';
	std::string ext_channel_name = g_Zapit->getChannelName(channel_id);
	if (ext_channel_name.size() < size)
	{
		strcpy(buf, UTF8_TO_FILESYSTEM_ENCODING(ext_channel_name.c_str()));
		
		char * p_act = buf;
		do {
			p_act += strspn(p_act, FILENAME_ALLOWED_CHARS);
			if (*p_act)
			{
				*p_act++ = '_';
			}
		} while (*p_act);
	}
}
Esempio n. 3
0
void CVCRControl::CFileDevice::appendChannelName(char *buf, unsigned int size, const t_channel_id channel_id) {
	
	if (size > 0)
		buf[0] = '\0';
	std::string ext_channel_name = g_Zapit->getChannelName(channel_id);
	if (!ext_channel_name.empty())
	{
		strncpy(buf, UTF8_TO_FILESYSTEM_ENCODING(ext_channel_name.c_str()), size); // buf already terminated correctly in CFileDevice::Record(...)
		
		char * p_act = buf;
		do {
			p_act += strspn(p_act, FILENAME_ALLOWED_CHARS);
			if (*p_act)
			{
				*p_act++ = '_';
			}
		} while (*p_act);
	}
}
Esempio n. 4
0
void CVCRControl::Screenshot(const t_channel_id channel_id, char * fname) 
{
	char filename[512]; // UTF-8
	char cmd[512];
	std::string channel_name;
	CEPGData                epgData;
	event_id_t epgid = 0;
	unsigned int pos;

	if(!fname) {
		if(safe_mkdir((char *) "/hdd/screenshots/"))
			return;

		strcpy(filename, "/hdd/screenshots/");
	
		pos = strlen(filename);
		channel_name = g_Zapit->getChannelName(channel_id);
		if (!(channel_name.empty())) {
			strcpy(&(filename[pos]), UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str()));
			char * p_act = &(filename[pos]);
			do {
				p_act += strcspn(p_act, "/ \"%&-\t`'´!,:;");
				if (*p_act) {
					*p_act++ = '_';
				}
			} while (*p_act);
			strcat(filename, "_");
		}
		pos = strlen(filename);

		//if (g_Sectionsd->getActualEPGServiceKey(channel_id&0xFFFFFFFFFFFFULL, &epgData))
		if(sectionsd_getActualEPGServiceKey(channel_id&0xFFFFFFFFFFFFULL, &epgData));
			epgid = epgData.eventID;
		if(epgid != 0) {
			CShortEPGData epgdata;
			//if (g_Sectionsd->getEPGidShort(epgid, &epgdata)) {
			if(sectionsd_getEPGidShort(epgid, &epgdata)) {
				if (!(epgdata.title.empty())) {
					strcpy(&(filename[pos]), epgdata.title.c_str());
					char * p_act = &(filename[pos]);
					do {
						p_act +=  strcspn(p_act, "/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|");
						if (*p_act) {
							*p_act++ = '_';
						}
					} while (*p_act);
				}
			}
		}
		pos = strlen(filename);
		time_t t = time(NULL);
		strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t));
		strcat(filename, ".bmp");
	} else
		strcpy(filename, fname);

	sprintf(cmd, "grab -v %s", filename);
printf("Executing %s\n", cmd);
	CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Saving screenshot..");
	hintBox->paint();
	system(cmd);
	hintBox->hide();
	delete hintBox;
}
Esempio n. 5
0
bool CVCRControl::CFileDevice::Record(const t_channel_id channel_id, int mode, const event_id_t epgid, const std::string& epgTitle, unsigned char apids, const time_t epg_time) 
{
printf("Record channel_id: " PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS " epg: %llx, apids 0x%X mode %d\n",
	       channel_id, epgid, apids, mode);

	CutBackNeutrino(channel_id, mode);

#define MAXPIDS		64
	unsigned short pids[MAXPIDS];
	unsigned int numpids;
	unsigned int pos;

	CZapitClient::CCurrentServiceInfo si = g_Zapit->getCurrentServiceInfo();
	numpids = 0;

	if (si.vpid != 0)
		transfer_pids(si.vpid, si.vtype ? EN_TYPE_AVC : EN_TYPE_VIDEO, 0);

        APIDList apid_list;
        getAPIDs(apids,apid_list);
        for(APIDList::iterator it = apid_list.begin(); it != apid_list.end(); it++) {
                pids[numpids++] = it->apid;
		transfer_pids(it->apid, EN_TYPE_AUDIO, it->ac3 ? 1 : 0);
        }
#if 0 // FIXME : why this needed ?
        if(!apid_list.empty())
                g_Zapit->setAudioChannel(apid_list.begin()->index);
#endif
        CZapitClient::responseGetPIDs allpids;
        g_Zapit->getPIDS(allpids);

	if ((StreamVTxtPid) && (si.vtxtpid != 0)) {
		pids[numpids++] = si.vtxtpid;
	}
        if ((StreamPmtPid) && (si.pmtpid != 0)) {
                pids[numpids++] = si.pmtpid;
        }
	char filename[512]; // UTF-8

	// Create filename for recording
	pos = Directory.size();
	strcpy(filename, Directory.c_str());
	
	if ((pos == 0) || (filename[pos - 1] != '/')) {
		filename[pos] = '/';
		pos++;
		filename[pos] = '\0';
	}
	pos = strlen(filename);
#if 0
	time_t t = time(NULL);
	strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t));
	strcat(filename, "_");
	pos = strlen(filename);
#endif
	ext_channel_name = g_Zapit->getChannelName(channel_id);
	if (!(ext_channel_name.empty()))
	{
		strcpy(&(filename[pos]), UTF8_TO_FILESYSTEM_ENCODING(ext_channel_name.c_str()));
		char * p_act = &(filename[pos]);
		do {
			p_act += strcspn(p_act, "/ \"%&-\t`'´!,:;");
			if (*p_act) {
				*p_act++ = '_';
			}
		} while (*p_act);
		if (!autoshift && g_settings.recording_save_in_channeldir) {
			struct stat statInfo;
			int res = stat(filename,&statInfo);
			if (res == -1) {
				if (errno == ENOENT) {
					//res = mkdir(filename,0755);
					res = safe_mkdir(filename);
					if (res == 0) {
						strcat(filename,"/");
					} else {
						perror("[vcrcontrol] mkdir");
					}
						
				} else {
					perror("[vcrcontrol] stat");
				}
			} else {
				// directory exists
				strcat(filename,"/");
			}	
					
		} else
			strcat(filename, "_");
	}

	pos = strlen(filename);
	if (g_settings.recording_epg_for_filename) { 
		if(epgid != 0) {
			CShortEPGData epgdata;
			//if (g_Sectionsd->getEPGidShort(epgid, &epgdata))
			if(sectionsd_getEPGidShort(epgid, &epgdata))
			{
				if (!(epgdata.title.empty()))
				{
					strcpy(&(filename[pos]), epgdata.title.c_str());
					char * p_act = &(filename[pos]);
					do {
						p_act +=  strcspn(p_act, "/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|");
						if (*p_act) {
							*p_act++ = '_';
						}
					} while (*p_act);
				}
			}
		} else if (!epgTitle.empty()) {
			strcpy(&(filename[pos]), epgTitle.c_str());
			char * p_act = &(filename[pos]);
			do {
				p_act +=  strcspn(p_act, "/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|");
				if (*p_act) {
					*p_act++ = '_';
				}
			} while (*p_act);
		}
	}
#if 1
	pos = strlen(filename);
	time_t t = time(NULL);
	strftime(&(filename[pos]), sizeof(filename) - pos - 1, "%Y%m%d_%H%M%S", localtime(&t));
	//pos = strlen(filename);
#endif

	start_time = time(0);
	stream2file_error_msg_t error_msg = ::start_recording(filename,
			      getMovieInfoString(CMD_VCR_RECORD, channel_id, epgid, epgTitle, apid_list, epg_time).c_str(), 
			      si.vpid, pids, numpids);

	if (error_msg == STREAM2FILE_OK) {
		deviceState = CMD_VCR_RECORD;
		return true;
	}
	else {
		RestoreNeutrino();

		printf("[vcrcontrol] stream2file error code: %d\n", error_msg);
#warning FIXME: Use better error message
		DisplayErrorMessage(g_Locale->getText(
				      error_msg == STREAM2FILE_BUSY ? LOCALE_STREAMING_BUSY :
				      error_msg == STREAM2FILE_INVALID_DIRECTORY ? LOCALE_STREAMING_DIR_NOT_WRITABLE :
				      LOCALE_STREAMINGSERVER_NOCONNECT
				      )); // UTF-8

		return false;
	}
}