Exemplo n.º 1
0
//指定イベントのEPG情報を取得する
//引数:
// originalNetworkID		[IN]取得対象のoriginalNetworkID
// transportStreamID		[IN]取得対象のtransportStreamID
// serviceID				[IN]取得対象のServiceID
// EventID					[IN]取得対象のEventID
// pfOnlyFlag				[IN]p/fからのみ検索するかどうか
// epgInfo					[OUT]EPG情報(DLL内で自動的にdeleteする。次に取得を行うまで有効)
BOOL CEpgDBUtil::SearchEpgInfo(
	WORD originalNetworkID,
	WORD transportStreamID,
	WORD serviceID,
	WORD eventID,
	BYTE pfOnlyFlag,
	EPG_EVENT_INFO** epgInfo_
	)
{
	CBlockLock lock(&this->dbLock);

	this->searchEpgInfo.reset();

	ULONGLONG key = _Create64Key(originalNetworkID, transportStreamID, serviceID);

	map<ULONGLONG, SERVICE_EVENT_INFO>::iterator itr;
	itr = serviceEventMap.find(key);
	if( itr == serviceEventMap.end() ){
		return FALSE;
	}

	if( itr->second.nowEvent != NULL && itr->second.nowEvent->event_id == eventID ){
		this->searchEpgInfo.reset(new EPG_EVENT_INFO);
		CopyEpgInfo(this->searchEpgInfo.get(), itr->second.nowEvent.get());
		*epgInfo_ = this->searchEpgInfo.get();
	}else if( itr->second.nextEvent != NULL && itr->second.nextEvent->event_id == eventID ){
		this->searchEpgInfo.reset(new EPG_EVENT_INFO);
		CopyEpgInfo(this->searchEpgInfo.get(), itr->second.nextEvent.get());
		*epgInfo_ = this->searchEpgInfo.get();
	}
	if( this->searchEpgInfo != NULL ){
		if( (*epgInfo_)->extInfo == NULL && itr->second.eventMap.count(eventID) && itr->second.eventMap[eventID]->extInfo ){
			(*epgInfo_)->extInfo = new EPG_EXTENDED_EVENT_INFO;
			(*epgInfo_)->extInfo->DeepCopy(*itr->second.eventMap[eventID]->extInfo);
		}
		return TRUE;
	}
	if( pfOnlyFlag == 0 ){
		map<WORD, std::unique_ptr<EVENT_INFO>>::iterator itrEvent;
		itrEvent = itr->second.eventMap.find(eventID);
		if( itrEvent != itr->second.eventMap.end() ){
			this->searchEpgInfo.reset(new EPG_EVENT_INFO);
			CopyEpgInfo(this->searchEpgInfo.get(), itrEvent->second.get());
			*epgInfo_ = this->searchEpgInfo.get();
			return TRUE;
		}
	}

	return FALSE;
}
Exemplo n.º 2
0
//指定サービスの現在or次のEPG情報を取得する
//引数:
// originalNetworkID		[IN]取得対象のoriginalNetworkID
// transportStreamID		[IN]取得対象のtransportStreamID
// serviceID				[IN]取得対象のServiceID
// nextFlag					[IN]TRUE(次の番組)、FALSE(現在の番組)
// epgInfo					[OUT]EPG情報(DLL内で自動的にdeleteする。次に取得を行うまで有効)
BOOL CEpgDBUtil::GetEpgInfo(
	WORD originalNetworkID,
	WORD transportStreamID,
	WORD serviceID,
	BOOL nextFlag,
	EPG_EVENT_INFO** epgInfo_
	)
{
	CBlockLock lock(&this->dbLock);

	this->epgInfo.reset();

	ULONGLONG key = _Create64Key(originalNetworkID, transportStreamID, serviceID);

	map<ULONGLONG, SERVICE_EVENT_INFO>::iterator itr;
	itr = serviceEventMap.find(key);
	if( itr == serviceEventMap.end() ){
		return FALSE;
	}

	if( itr->second.nowEvent != NULL && nextFlag == FALSE ){
		this->epgInfo.reset(new EPG_EVENT_INFO);
		CopyEpgInfo(this->epgInfo.get(), itr->second.nowEvent.get());
		*epgInfo_ = this->epgInfo.get();
	}else if( itr->second.nextEvent != NULL && nextFlag == TRUE ){
		this->epgInfo.reset(new EPG_EVENT_INFO);
		CopyEpgInfo(this->epgInfo.get(), itr->second.nextEvent.get());
		*epgInfo_ = this->epgInfo.get();
	}
	if( this->epgInfo != NULL ){
		if( (*epgInfo_)->extInfo == NULL && itr->second.eventMap.count((*epgInfo_)->event_id) && itr->second.eventMap[(*epgInfo_)->event_id]->extInfo ){
			(*epgInfo_)->extInfo = new EPG_EXTENDED_EVENT_INFO;
			(*epgInfo_)->extInfo->DeepCopy(*itr->second.eventMap[(*epgInfo_)->event_id]->extInfo);
		}
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 3
0
bool CTunerBankCtrl::RecStart(const TUNER_RESERVE& reserve, __int64 now) const
{
	if( this->hTunerProcess == NULL ){
		return false;
	}
	if( reserve.recMode == RECMODE_VIEW ){
		return true;
	}
	CSendCtrlCmd ctrlCmd;
	ctrlCmd.SetPipeSetting(CMD2_VIEW_CTRL_WAIT_CONNECT, CMD2_VIEW_CTRL_PIPE, this->tunerPid);
	bool isMainCtrl = true;
	for( int i = 0; i < 2; i++ ){
		if( reserve.ctrlID[i] != 0 ){
			SET_CTRL_REC_PARAM param;
			param.ctrlID = reserve.ctrlID[i];
			//saveFolder[].recFileNameが空でない限りこのフィールドが利用されることはない
			param.fileName = L"padding.ts";
			//同時出力用ファイル名
			param.saveFolder = i == 0 ? reserve.recFolder : reserve.partialRecFolder;
			if( param.saveFolder.empty() ){
				param.saveFolder.resize(1);
				wstring commonIniPath;
				GetCommonIniPath(commonIniPath);
				GetRecFolderPath(param.saveFolder[0].recFolder);
				param.saveFolder[0].writePlugIn = GetPrivateProfileToString(L"SET", L"RecWritePlugIn0", L"", commonIniPath.c_str());
				param.saveFolder[0].recNamePlugIn = this->recNamePlugInFileName;
			}else{
				for( size_t j = 0; j < param.saveFolder.size(); j++ ){
					if( CompareNoCase(param.saveFolder[j].recFolder, L"!Default") == 0 ){
						//注意: この置換は原作にはない
						GetRecFolderPath(param.saveFolder[j].recFolder);
					}
					if( param.saveFolder[j].recNamePlugIn.empty() ){
						param.saveFolder[j].recNamePlugIn = this->recNamePlugInFileName;
					}
				}
			}
			//recNamePlugInを展開して実ファイル名をセット
			for( size_t j = 0; j < param.saveFolder.size(); j++ ){
				param.saveFolder[j].recFileName.clear();
				if( param.saveFolder[j].recNamePlugIn.empty() == false ){
					WORD sid = reserve.sid;
					WORD eid = reserve.eid;
					wstring stationName = reserve.stationName;
					if( i != 0 ){
						FindPartialService(reserve.onid, reserve.tsid, reserve.sid, &sid, &stationName);
						eid = 0xFFFF;
					}
					wstring plugInPath;
					GetModuleFolderPath(plugInPath);
					plugInPath += L"\\RecName\\";
					{
						PLUGIN_RESERVE_INFO info;
						ConvertSystemTime(reserve.startTime, &info.startTime);
						info.durationSec = reserve.durationSecond;
						wcscpy_s(info.eventName, reserve.title.c_str());
						info.ONID = reserve.onid;
						info.TSID = reserve.tsid;
						info.SID = sid;
						info.EventID = eid;
						wcscpy_s(info.serviceName, stationName.c_str());
						wcscpy_s(info.bonDriverName, this->bonFileName.c_str());
						info.bonDriverID = this->tunerID >> 16;
						info.tunerID = this->tunerID & 0xFFFF;
						EPG_EVENT_INFO* epgInfo = NULL;
						if( info.EventID != 0xFFFF ){
							EPGDB_EVENT_INFO epgDBInfo;
							if( this->epgDBManager.SearchEpg(info.ONID, info.TSID, info.SID, info.EventID, &epgDBInfo) != FALSE ){
								epgInfo = new EPG_EVENT_INFO;
								CopyEpgInfo(epgInfo, &epgDBInfo);
							}
						}
						info.reserveID = reserve.reserveID;
						info.epgInfo = epgInfo;
						info.sizeOfStruct = 0;
						WCHAR name[512];
						DWORD size = 512;
						if( CReNamePlugInUtil::ConvertRecName3(&info, param.saveFolder[j].recNamePlugIn.c_str(), plugInPath.c_str(), name, &size) ){
							param.saveFolder[j].recFileName = name;
							CheckFileName(param.saveFolder[j].recFileName, this->recNameNoChkYen);
						}
						delete epgInfo;
					}
					param.saveFolder[j].recNamePlugIn.clear();
				}
				//実ファイル名は空にしない
				if( param.saveFolder[j].recFileName.empty() ){
					SYSTEMTIME st;
					ConvertSystemTime(max(reserve.startTime, now), &st);
					Format(param.saveFolder[j].recFileName, L"%04d%02d%02d%02d%02d%02X%02X%02d-%s.ts",
					       st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute,
					       this->tunerID >> 16, this->tunerID & 0xFFFF, param.ctrlID, reserve.title.c_str());
					CheckFileName(param.saveFolder[j].recFileName);
				}
			}
Exemplo n.º 4
0
//指定サービスの全EPG情報を取得する
// originalNetworkID		[IN]取得対象のoriginalNetworkID
// transportStreamID		[IN]取得対象のtransportStreamID
// serviceID				[IN]取得対象のServiceID
// epgInfoListSize			[OUT]epgInfoListの個数
// epgInfoList				[OUT]EPG情報のリスト(DLL内で自動的にdeleteする。次に取得を行うまで有効)
BOOL CEpgDBUtil::GetEpgInfoList(
	WORD originalNetworkID,
	WORD transportStreamID,
	WORD serviceID,
	DWORD* epgInfoListSize,
	EPG_EVENT_INFO** epgInfoList_
	)
{
	CBlockLock lock(&this->dbLock);

	ULONGLONG key = _Create64Key(originalNetworkID, transportStreamID, serviceID);

	map<ULONGLONG, SERVICE_EVENT_INFO>::iterator itr;
	itr = serviceEventMap.find(key);
	if( itr == serviceEventMap.end() ){
		return FALSE;
	}

	EVENT_INFO* evtPF[2] = {itr->second.nowEvent.get(), itr->second.nextEvent.get()};
	if( evtPF[0] == NULL || evtPF[1] && evtPF[0]->event_id > evtPF[1]->event_id ){
		std::swap(evtPF[0], evtPF[1]);
	}
	size_t listSize = itr->second.eventMap.size() +
		(evtPF[0] && itr->second.eventMap.count(evtPF[0]->event_id) == 0 ? 1 : 0) +
		(evtPF[1] && itr->second.eventMap.count(evtPF[1]->event_id) == 0 ? 1 : 0);
	if( listSize == 0 ){
		return FALSE;
	}
	*epgInfoListSize = (DWORD)listSize;
	this->epgInfoList.reset(new EPG_EVENT_INFO[*epgInfoListSize]);

	map<WORD, std::unique_ptr<EVENT_INFO>>::iterator itrEvt = itr->second.eventMap.begin();
	DWORD count = 0;
	while( evtPF[0] || itrEvt != itr->second.eventMap.end() ){
		EPG_EXTENDED_EVENT_INFO* extInfoSchedule = NULL;
		EVENT_INFO* evt;
		if( itrEvt == itr->second.eventMap.end() || evtPF[0] && evtPF[0]->event_id < itrEvt->first ){
			//[p/f]を出力
			evt = evtPF[0];
			evtPF[0] = evtPF[1];
			evtPF[1] = NULL;
		}else{
			if( evtPF[0] && evtPF[0]->event_id == itrEvt->first ){
				//両方あるときは[p/f]を優先
				evt = evtPF[0];
				evtPF[0] = evtPF[1];
				evtPF[1] = NULL;
				if( evt->extInfo == NULL && itrEvt->second->extInfo ){
					extInfoSchedule = new EPG_EXTENDED_EVENT_INFO;
					extInfoSchedule->DeepCopy(*itrEvt->second->extInfo);
				}
			}else{
				//[schedule]を出力
				evt = itrEvt->second.get();
			}
			itrEvt++;
		}
		CopyEpgInfo(this->epgInfoList.get()+count, evt);
		if( extInfoSchedule ){
			this->epgInfoList[count].extInfo = extInfoSchedule;
		}
		count++;
	}

	*epgInfoList_ = this->epgInfoList.get();

	return TRUE;
}