Example #1
0
 BOOL Device::StopHdfsRecord()
{
	if (m_param.m_Conf.data.conf.HdfsRecording == 1)
	{
	    return FALSE;
	}

	VDC_DEBUG( "%s Stop Record\n",__FUNCTION__);
	StopData();
	Lock();
	if (m_pHdfsRecord)
	{
		m_pVHdfsdb.FinishRecord(m_pHdfsRecord);
		delete m_pHdfsRecord;
		m_pHdfsRecord = NULL;
	}
	
	UnLock();
	return TRUE;
}
Example #2
0
void VSCPlayback::ShowPlayControl()
{
    if (m_bPlayControl == FALSE)
    {
        m_bPlayControl = TRUE;
        m_pPlayControl->show();
        int x, y, w, h;
        x = this->x();
        y = this->y();
        w = width();
        h = height(); 
        VDC_DEBUG( "%s rect x:%d y:%d w:%d h:%d \n",__FUNCTION__, x, y, w, h);
        //m_pPlayControl->move(x + w/2 - 200, y + h - 60);
    }else
    {
        m_bPlayControl = FALSE;
        m_pPlayControl->hide();
    }

}
Example #3
0
void VSCSearch::SearchReceiveData(const QHash<QString, QString> &data)
{
    astring ip = "192.168.0.1";
    astring port = "80";
    astring hdModel = "unknown";
    astring OnvifAddr = "/onvif/device_service";
    astring Manufacturer = "";
    astring FirmwareVersion = "";
    astring type = data["types"].toStdString();
    transform(	type.begin(), type.end(),type.begin(),(int(*)(int))tolower); 
    size_t pos1 = type.find("networkvideotransmitter");
    VDC_DEBUG( "[ONVIF]: Searched ip %s\n", data["device_service_address"].toStdString().c_str());
    if (pos1 == string::npos)
    {
        return;
    }
	
    GetIPAndPort(data["device_service_address"].toStdString(), 
		ip, port, OnvifAddr);
    GetHardwareModel(data["device_ip"].toStdString(), hdModel);

    astring OnvifDeviceService = "http://" + ip + ":" + port + OnvifAddr;
#if 0
    DeviceManagement *pDm = new DeviceManagement(OnvifDeviceService.c_str(), 
                            "admin", "12345");
    if (pDm)
    {
    	QHash<QString, QString> deviceInfo = pDm->getDeviceInformation();
       Manufacturer = deviceInfo["mf"].toStdString();
	FirmwareVersion = deviceInfo["firmware_version"].toStdString();
    }
#endif
    
    AddItem(ip, port, Manufacturer, hdModel, FirmwareVersion, OnvifAddr);
    m_nSearchProcess += 2;
    if (m_nSearchProcess == 100)
    {
        m_nSearchProcess = 0;
    }
    ui.progressBar->setValue(m_nSearchProcess);
}
Example #4
0
void VSCSearch::SelectAll()
{
	int insertRow = ui.tableWidget->rowCount();
    VDC_DEBUG( "[ONVIF]: Searched %d", insertRow);

	if (m_bSelectedAll == TRUE)
	{
		for (int i = 0; i < insertRow; i ++)
		{
			ui.tableWidget->item(i, 0)->setCheckState(Qt::Unchecked);
		}
		m_bSelectedAll = FALSE;
	}else
	{
		for (int i = 0; i < insertRow; i ++)
		{
			ui.tableWidget->item(i, 0)->setCheckState(Qt::Checked);
		}	
		m_bSelectedAll = TRUE;
	}
}
Example #5
0
inline BOOL Factory::DelVIPC(s32 nIndex)
{
    FactoryDeviceChangeData change;
    VDC_DEBUG( "%s DelDevice %d\n",__FUNCTION__, nIndex);
    if (nIndex <=0 || nIndex >= FACTORY_DEVICE_ID_MAX)
    {
        return FALSE;
    }

    change.id = nIndex;
    change.type = FACTORY_VIPC_DEL;
    CallDeviceChange(change);
	
    Lock();
    m_VIPCDeviceParamMap.erase(nIndex);
    m_Conf.DelVIPC(nIndex);
    ReleaseVIPCID(nIndex);
    UnLock();
	

    return TRUE;
}
Example #6
0
  BOOL Device::StartHdfsRecord()
{
	if (m_param.m_Conf.data.conf.HdfsRecording == 0)
	{
	    return FALSE;
	}
	VDC_DEBUG( "%s Start Record\n",__FUNCTION__);
	StartData();

	Lock();
	if (m_pHdfsRecord == NULL)
	{
		m_pHdfsRecord = m_pVHdfsdb.StartRecord(
			m_param.m_Conf.data.conf.nId, m_param.m_Conf.data.conf.Name);
		m_pHdfsRecord->RegSeqCallback((HDFSDataHandler)Device::SeqHandler, (void *)this);

	}

	

	UnLock();
    	return TRUE;
}
Example #7
0
 BOOL Device::StopRecord()
{
	if (m_param.m_Conf.data.conf.Recording == 1)
	{
	    return FALSE;
	}
	VDC_DEBUG( "%s Stop Record\n",__FUNCTION__);
	StopData();
	Lock();
	if (m_pRecord)
	{
	    u32 endTime = m_pRecord->GetEndTime();
	    if (endTime != 0)
	    {
	    	 m_pVdb.FinishRecord(m_pRecord);
	    }
	    delete m_pRecord;
	    m_pRecord = NULL;
	}
	UnLock();

    return TRUE;
}
Example #8
0
BOOL CameraParam::UpdateUrl()
{
    //TODO RTSP ONVIF call onvif sdk to get a Stream URL
    if (m_Conf.ntype()== VID_FILE )
    {
        m_strUrl = m_Conf.strfile();
	 m_bHasSubStream = FALSE;
    }

    if (m_Conf.ntype()== VID_RTSP
	|| m_Conf.ntype()== VID_MJPEG)
    {
#if 0
        char url[512];
        sprintf(url, "rtsp://%s:%s%s",
                m_Conf.data.conf.IP,
                m_Conf.data.conf.Port, m_Conf.data.conf.RtspLocation);
#endif
	Poco::URI rtspUrl(m_Conf.strrtspurl());
	astring strRtsp;
	if (rtspUrl.empty() != true)
	{
		strRtsp = rtspUrl.getScheme() + "://" + rtspUrl.getHost() + ":" + std::to_string(rtspUrl.getPort()) + rtspUrl.getPathAndQuery();
	}

	m_strUrl = strRtsp;
	m_bHasSubStream = FALSE;

    }

    if (m_Conf.ntype()== VID_ONVIF_S)
    {
        return UpdateUrlOnvif();
    }
    VDC_DEBUG( "%s url %s\n",__FUNCTION__, m_strUrl.c_str());
    return TRUE;
}
Example #9
0
inline void OnvifLog(char * str)
{
    VDC_DEBUG( "%s\n", str);
    return;
}
Example #10
0
inline BOOL Factory::Init()
{
	astring strPath;
	if (m_SysPath.GetSystemPath(strPath) == FALSE)
	{
	    return FALSE;
	}
	printf("Sys path %s\n", strPath.c_str());
#ifdef WIN32
#ifndef _WIN64
	astring strPathConf = strPath + "vidstor\\config";
#else
	astring strPathConf = strPath + "vidstor64\\config";
#endif
#else
	astring strPathConf = strPath + "vidstor/config";
#endif
	m_Conf.Open(strPathConf);

#ifndef _WIN64
	astring strPathDb = strPath + "vidstor";
#else
	astring strPathDb = strPath + "vidstor64";
#endif
	m_pVdb = new VDB(strPathDb);

	VidHDFSConf HdfsConf;
	m_Conf.GetHdfsRecordConf(HdfsConf);
	astring strNameNode = HdfsConf.strnamenode();
	astring strPort = HdfsConf.strport();
	astring strUser = HdfsConf.struser();
	m_pVHdfsdb = new VHdfsDB(strNameNode, strPort, strUser);

#if 1 //add camera for test
	{	
		VidCameraList cameraList;
		CameraParam Param;
		Param.m_Conf.set_strip("192.168.0.123");
		Param.m_Conf.set_strport("80");
		Param.m_Conf.set_struser("admin");
		Param.m_Conf.set_strpasswd("12345");
		VidCamera *pAddCam = cameraList.add_cvidcamera();
		*pAddCam = Param.m_Conf;
		m_Conf.UpdateCameraListConf(cameraList);
		
	}
#endif

	VidCameraList cameraList;
	m_Conf.GetCameraListConf(cameraList);
	int cameraSize = cameraList.cvidcamera_size();

	for (s32 i = 0; i < cameraList.cvidcamera_size(); i ++)
	{
		VidCamera cam = cameraList.cvidcamera(i);
		CameraParam pParam(cam);
		InitAddCamera(pParam, cam.strid());
	}

#if 0
	VSCConfData sysData;
	m_Conf.GetSysData(sysData);
	for (s32 i = 1; i < CONF_MAP_MAX; i ++)
	{
	    if (sysData.data.conf.CameraMap[i] != CONF_MAP_INVALID_MIN 
			&& sysData.data.conf.CameraMap[i] != 0)
	    {
	        VDC_DEBUG( "%s Init Camera %d\n",__FUNCTION__, i);
	        VSCCameraData Data;
	        m_Conf.GetCameraData(i, Data);
	        CameraParam mParam(Data);
	        LockCameraID(Data.data.conf.nId);
	        InitAddCamera(mParam, Data.data.conf.nId);
	        VDC_DEBUG( "%s Id %d\n",__FUNCTION__, Data.data.conf.nId);
	    }
	}
#endif

	InitLicense();
	//m_pThread = new thread(Factory::Run, (void *)this);
	//start();
	m_HddTask = new FactoryHddTask(*this);
	m_HddTask->start();

	//if (sysData.data.conf.OAPIPort == 0)
	{
		//sysData.data.conf.OAPIPort = 9080;
	}
	//m_pHttpServer = new CmnHttpServer(sysData.data.conf.OAPIPort);
	//m_pHttpServer->start();

	/* Init export path */
	astring strExportPath;
	GetExportPath(strExportPath);
	return TRUE;
}
Example #11
0
void VSCDeviceTree::mousePressEvent(QMouseEvent *event)
{
	VDC_DEBUG( "%s \n",__FUNCTION__);
	// Get current selection
	QTreeWidgetItem *selectedItem = currentItem();
	
    if (event->buttons() & Qt::RightButton)
    {
        return;
    }
	// If the selected Item exists
	if (selectedItem)
	{
		VSCDeviceIPC *pIpc = dynamic_cast<VSCDeviceIPC * >(selectedItem);
	    //VSCDeviceIPC *pIpc = (VSCDeviceIPC * )(selectedItem);
        // Create data
		if (pIpc)
		{
		    u32 nId = pIpc->GetDeviceId();
		    VDC_DEBUG( "%s id %d\n",__FUNCTION__, nId);
			QMimeData *mimeData = new QMimeData();
			mimeData->setText(QString::number(nId));
			
			// Create drag
			QPixmap pixmap(":/device/resources/camera1.png");
			QPainter painter(&pixmap);

			QDrag *drag = new QDrag(this);
			drag->setMimeData(mimeData);
			drag->setPixmap(pixmap);
                      drag->setHotSpot(QPoint(drag->pixmap().width()/2,
                             drag->pixmap().height()/2));
			drag->exec();
			QTreeWidget::mousePressEvent(event);
			return ;
		}
		VSCZbTreeItemIPC *pSiteIpc = dynamic_cast<VSCZbTreeItemIPC * >(selectedItem);
	    //VSCDeviceIPC *pIpc = (VSCDeviceIPC * )(selectedItem);
        // Create data
		if (pSiteIpc)
		{
			VSCQMimeDataIPC *pMimeIpc = new VSCQMimeDataIPC();
			
			// Create drag
			QPixmap pixmap(":/device/resources/camera1.png");
			QPainter painter(&pixmap);

			QDrag *drag = new QDrag(this);
			drag->setMimeData(pMimeIpc);
			drag->setPixmap(pixmap);
                      drag->setHotSpot(QPoint(drag->pixmap().width()/2,
                             drag->pixmap().height()/2));
			drag->exec();
			QTreeWidget::mousePressEvent(event);
			return ;
		}

	}
	
	QTreeWidget::mousePressEvent(event);
}
Example #12
0
BOOL VSCVWidget::SetPlayId(u32 nPlayId)
{
    m_nPlayId = nPlayId;
    VDC_DEBUG( "%s Set Player ID %d\n",__FUNCTION__, m_nPlayId);
    return true;
}
Example #13
0
 BOOL Device::UpdatePTZConf()
{
    if (m_param.m_Conf.data.conf.nSubType != VSC_SUB_DEVICE_ONVIF)
    {
    	return TRUE;
    }
    QString strToken;
    astring IP = m_param.m_Conf.data.conf.IP;
    astring Port = m_param.m_Conf.data.conf.Port;
    astring User = m_param.m_Conf.data.conf.User;
    astring Password = m_param.m_Conf.data.conf.Password;
    astring OnvifAddress = m_param.m_Conf.data.conf.OnvifAddress;

    astring OnvifDeviceService = "http://" + IP + ":" + Port + OnvifAddress;

    DeviceManagement *pDm = new DeviceManagement(OnvifDeviceService.c_str(), 
                            User.c_str(), Password.c_str());
    
    if (pDm  == NULL)
    {
        VDC_DEBUG( "%s new DeviceManagement error \n",__FUNCTION__);
        return FALSE;
    }

    Capabilities * pMediaCap = pDm->getCapabilitiesMedia();
    if (pMediaCap == NULL)
    {
        VDC_DEBUG( "%s getCapabilitiesPtz error \n",__FUNCTION__);
        delete pDm;
        return FALSE;
    }

    MediaManagement *pMedia = new MediaManagement(pMediaCap->mediaXAddr(), 
                                User.c_str(), Password.c_str());
    if (pMedia == NULL)
    {
        VDC_DEBUG( "%s new MediaManagement error \n",__FUNCTION__);
        delete pDm;
        delete pMediaCap;
        return FALSE;
    }

    Profiles *pProfileS = pMedia->getProfiles();
    if (pProfileS == NULL)
    {
        VDC_DEBUG( "%s new getProfiles error \n",__FUNCTION__);
        delete pDm;
        delete pMediaCap;
        delete pMedia;
        return FALSE;
    }
    if (pProfileS->m_toKenPro.size() > 0)
    {
        	VDC_DEBUG( "%s m_toKenPro size %d \n",__FUNCTION__, pProfileS->m_toKenPro.size());
		
		if (m_param.m_Conf.data.conf.UseProfileToken == 1)
		{
			strToken = m_param.m_Conf.data.conf.OnvifProfileToken;
		}else
		{
			strToken = pProfileS->m_toKenPro[0];		
		}
        
    }else
    {
    	return FALSE;
    }

    Capabilities * pPtz = pDm->getCapabilitiesPtz();
    if (pPtz == NULL)
    {
        VDC_DEBUG( "%s getCapabilitiesPtz error \n",__FUNCTION__);
        delete pDm;
        delete pMediaCap;
        delete pMedia;
        return FALSE;
    }

    string strPtz = pPtz->ptzXAddr().toStdString();
    m_ptz  = new PtzManagement(pPtz->ptzXAddr(), 
                                User.c_str(), Password.c_str());
    if (m_ptz == NULL)
    {
        VDC_DEBUG( "%s getCapabilitiesPtz error \n",__FUNCTION__);
        delete pDm;
        delete pMediaCap;
        delete pMedia;
		delete pPtz;
        return FALSE;
    }

    m_continuousMove.setProfileToken(strToken);
    m_stop.setProfileToken(strToken);
    m_ptzInited = TRUE;
}
Example #14
0
inline void VEventServerDbTask::UpdateDBSession(bool bIsFirst)
{
	std::time_t pTime = time(NULL);

	/* Get the Event Server Conf */
	VidEventDBConf cDBConf;
	m_Factory.GetEventDBConf(cDBConf);

	Poco::Timestamp pTimeStamp = Poco::Timestamp::fromEpochTime(pTime);

	/* Use next sec to check  */
	Poco::DateTime pTimeTime(pTimeStamp);

	int nYear = pTimeTime.year();
	int nMonth = pTimeTime.month();
	int nHour = pTimeTime.hour();

	if (bIsFirst != true)
	{

		/* Every day check if need new database */
		if (pTime%3600 != 0 || nHour != 0)
		{
			return;
		}

		if (nYear == m_nYear && nMonth == m_nMonth)
		{
			return;
		}
	}

	m_nYear = nYear;
	m_nMonth = nMonth;

	char strPlus[1024];
	sprintf(strPlus, "%d_%d", m_nYear, nMonth);
	
	if (cDBConf.ntype() == VID_DB_SQLITE)
	{
		if (m_pSqlSession != NULL)
		{
			delete m_pSqlSession;
			m_pSqlSession = NULL;
		}
		try
		{	
			Poco::Path path(cDBConf.strdbpath());
			Poco::File file(path);
			file.createDirectories();
			SQLite::Connector::registerConnector();
			VDC_DEBUG("Create the Event DB path %s\n", path.toString().c_str());
			
			Poco::Path filePath("eventdb.db");
			path.append(filePath);
			path.makeFile();
			VDC_DEBUG("Create the Event DB file %s\n", path.toString().c_str());

			m_pSqlSession = new Poco::Data::Session("SQLite", path.toString());
			*m_pSqlSession << "CREATE TABLE IF NOT EXISTS events "
				"(id INTEGER PRIMARY KEY, strId TEXT, strDevice TEXT, "
				"strDeviceName TEXT, strType TEXT, nTime INTEGER, strEvttime DATE, strDesc TEXT)", now;
		}
		catch (exception const &e)		
		{			
			VDC_DEBUG("%s Create SQLITE session failed \n", __FUNCTION__);
		}

	}else
	{
		VDC_DEBUG( "%s Do not support the DB TYPE \n",__FUNCTION__);
		ve_sleep(1000);
	}	
}
Example #15
0
 BOOL Camera::UpdatePTZConf()
{
	if (m_param.m_Conf.ntype()!= VID_ONVIF_S)
	{
		return TRUE;
	}
	QString strToken;

	astring IP = m_param.m_Conf.strip();
	astring Port = m_param.m_Conf.strport();
	astring User = m_param.m_Conf.struser();
	astring Password = m_param.m_Conf.strpasswd();
	astring OnvifAddress = m_param.m_Conf.stronvifaddress();

	astring OnvifCameraService = "http://" + IP + ":" + Port + OnvifAddress;

	DeviceManagement *pDm = new DeviceManagement(OnvifCameraService.c_str(), 
	                        User.c_str(), Password.c_str());
    
	if (pDm  == NULL)
	{
	    VDC_DEBUG( "%s new DeviceManagement error \n",__FUNCTION__);
	    return FALSE;
	}

	Capabilities * pMediaCap = pDm->getCapabilitiesMedia();
	if (pMediaCap == NULL)
	{
	    VDC_DEBUG( "%s getCapabilitiesPtz error \n",__FUNCTION__);
	    delete pDm;
	    return FALSE;
	}

	MediaManagement *pMedia = new MediaManagement(pMediaCap->mediaXAddr(), 
	                            User.c_str(), Password.c_str());
	if (pMedia == NULL)
	{
	    VDC_DEBUG( "%s new MediaManagement error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    return FALSE;
	}

	Profiles *pProfileS = pMedia->getProfiles();
	if (pProfileS == NULL)
	{
	    VDC_DEBUG( "%s new getProfiles error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    delete pMedia;
	    return FALSE;
	}
	if (pProfileS->m_toKenPro.size() > 0)
	{
	    	VDC_DEBUG( "%s m_toKenPro size %d \n",__FUNCTION__, pProfileS->m_toKenPro.size());
		
		if (m_param.m_Conf.bprofiletoken() == true)
		{
			strToken = m_param.m_Conf.strprofiletoken1().c_str();
		}else
		{
			strToken = pProfileS->m_toKenPro[0];		
		}
	    
	}else
	{
		return FALSE;
	}

	Capabilities * pPtz = pDm->getCapabilitiesPtz();
	if (pPtz == NULL)
	{
	    VDC_DEBUG( "%s getCapabilitiesPtz error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    delete pMedia;
	    return FALSE;
	}

	string strPtz = pPtz->ptzXAddr().toStdString();
	m_ptz  = new PtzManagement(pPtz->ptzXAddr(), 
	                            User.c_str(), Password.c_str());
	if (m_ptz == NULL)
	{
	    VDC_DEBUG( "%s getCapabilitiesPtz error \n",__FUNCTION__);
	delete pDm;
	delete pMediaCap;
	delete pMedia;
	delete pPtz;
	return FALSE;
	}

	m_continuousMove.setProfileToken(strToken);
	m_stop.setProfileToken(strToken);
	m_ptzInited = TRUE;
}
Example #16
0
CameraStatus Camera::CheckCamera(astring strUrl, astring strUrlSubStream, 
		BOOL bHasSubStream, BOOL bOnline, BOOL bOnlineUrl)
{
    if (bOnline == TRUE)
    {
        /* Camera from offline to online */
        if (m_param.m_OnlineUrl == FALSE)
        {
        	BOOL HWAccel = FALSE;
		if (m_param.m_Conf.bhwaccel()== TRUE)
		{
			HWAccel = TRUE;
		}
		if (bOnlineUrl == FALSE)
		{
		    return  DEV_NO_CHANGE;
		}
		m_param.m_strUrl = strUrl;
		m_param.m_strUrlSubStream = strUrlSubStream;
		m_param.m_bHasSubStream = bHasSubStream;
		if (m_param.m_Conf.ntype()== VID_FILE)
		{
			m_vPlay.Init(m_param.m_strUrl, false, "fake", "fake", HWAccel);
		}else if (m_param.m_Conf.bmotionjpeg()== true
		  || m_param.m_Conf.ntype()== VID_MJPEG)
		{
			/* Motion JPEG */
			m_vPlay.Init(m_param.m_strUrl, true, m_param.m_Conf.struser(),
				m_param.m_Conf.strpasswd(), HWAccel);
		}
		else
		{
			m_vPlay.Init(TRUE, m_param.m_strUrl, m_param.m_Conf.struser(),
				m_param.m_Conf.strpasswd(), HWAccel, 
				(VSCConnectType)(m_param.m_Conf.nconnecttype()));
			VDC_DEBUG( "%s url %s\n",__FUNCTION__, m_param.m_strUrl.c_str());
			if (m_param.m_bHasSubStream == TRUE)
			{
				m_vPlaySubStream.Init(TRUE, m_param.m_strUrlSubStream, m_param.m_Conf.struser(),
					m_param.m_Conf.strpasswd(), HWAccel,
					(VSCConnectType)(m_param.m_Conf.nconnecttype()));
				VDC_DEBUG( "%s url %s\n",__FUNCTION__, m_param.m_strUrlSubStream.c_str());
			}
		}
		VDC_DEBUG( "%s url %s\n",__FUNCTION__, m_param.m_strUrl.c_str());
		
		m_param.m_OnlineUrl = TRUE;
		UpdatePTZConf();
		/* Always start data */
		StartData();
        }
        if (m_param.m_Online == FALSE)
        {
            m_param.m_Online = TRUE;
            return DEV_OFF2ON;
        }
    }else
    {
        if (m_param.m_Online == TRUE)
        {
            m_param.m_Online = FALSE;
            return DEV_ON2OFF;
        }
    }

    return DEV_NO_CHANGE;
    
}
Example #17
0
BOOL CameraParam::UpdateUrlOnvif()
{
	BOOL bGotUrl = FALSE;
	astring IP = m_Conf.strip();
	astring Port = m_Conf.strport();
	astring User = m_Conf.struser();
	astring Password = m_Conf.strpasswd();
	astring OnvifAddress = m_Conf.stronvifaddress();

	astring OnvifCameraService = "http://" + IP + ":" + Port + OnvifAddress;
	astring url = "rtsp://" + IP + ":" + "554" + "/";
	astring urlSubStream = "rtsp://" + IP + ":" + "554" + "/";

	DeviceManagement *pDm = new DeviceManagement(OnvifCameraService.c_str(), 
	                        User.c_str(), Password.c_str());

	if (pDm  == NULL)
	{
	    VDC_DEBUG( "%s new DeviceManagement error \n",__FUNCTION__);
	    return FALSE;
	}

	Capabilities * pMediaCap = pDm->getCapabilitiesMedia();
	if (pMediaCap == NULL)
	{
	    VDC_DEBUG( "%s getCapabilitiesMedia error \n",__FUNCTION__);
	    delete pDm;
	    return FALSE;
	}

	MediaManagement *pMedia = new MediaManagement(pMediaCap->mediaXAddr(), 
	                            User.c_str(), Password.c_str());
	if (pMedia == NULL)
	{
	    VDC_DEBUG( "%s new MediaManagement error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    return FALSE;
	}

	Profiles *pProfileS = pMedia->getProfiles();
	if (pProfileS == NULL)
	{
	    VDC_DEBUG( "%s new getProfiles error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    delete pMedia;
	    return FALSE;
	}

	if (pProfileS != NULL && pProfileS->m_toKenPro.size() <= 0)
	{
	    VDC_DEBUG( "%s new getProfiles error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    delete pMedia;
	    return FALSE;
	}
	
	if (pProfileS->m_toKenPro.size() > 0)
	{
	    VDC_DEBUG( "%s m_toKenPro size %d \n",__FUNCTION__, pProfileS->m_toKenPro.size());
		QString strToken;
		if (m_Conf.bprofiletoken() == true)
		{
			strToken = m_Conf.strprofiletoken1().c_str();
			//Find which token is in the OnvifProfileToken, and then use the token
		}else
		{
			strToken = pProfileS->m_toKenPro[0];
			m_Conf.set_strprofiletoken1(pProfileS->m_toKenPro[0].toStdString().c_str());
		}
		StreamUri *pUri = pMedia->getStreamUri(strToken);
		if (pUri)
		{
			m_strUrl = pUri->uri().toStdString();
			if (m_strUrl.length() <= 0)
			{
				bGotUrl = FALSE;
			}else
			{
				bGotUrl = TRUE;
			}
			delete pUri;
		}
	}
	if (pProfileS->m_toKenPro.size() > 1)
	{
		VDC_DEBUG( "%s m_toKenPro SubStream size %d \n",__FUNCTION__, pProfileS->m_toKenPro.size());
		QString strToken;
		if (m_Conf.bprofiletoken() == true)
		{
			strToken = m_Conf.strprofiletoken2().c_str();
		}else
		{
			strToken = pProfileS->m_toKenPro[1];
			m_Conf.set_strprofiletoken2(pProfileS->m_toKenPro[1].toStdString().c_str());
		}
		StreamUri *pUri = pMedia->getStreamUri(strToken);
		if (pUri)
		{
			m_strUrlSubStream = pUri->uri().toStdString();
			
			if (m_strUrl.length() <= 0)
			{
				bGotUrl = FALSE;
			}else
			{
				m_bHasSubStream = TRUE;
				bGotUrl = TRUE;
			}
			delete pUri;
		}
	}

	/* rtsp://admin:[email protected]:554/Streaming/Channels/1\
	?transportmode=unicast&profile=Profile_1 */
	//astring urlWithUser = "******" + User + ":" + Password + "@";
	//Replace(strUrl, "rtsp://", urlWithUser.c_str());

	if (bGotUrl == TRUE)
	{
		m_bOnvifUrlGetted = TRUE;
	}

	delete pDm;
	delete pMediaCap;
	delete pMedia;
	delete pProfileS;
	
	return bGotUrl;
}
Example #18
0
inline BOOL MFramework::Init()
{
    /* Get all the modules list and init  */
    std::string dir;

    //dir = Path::current();
    std::string pluginPath = GetPluginPath() + "/mplugins/";

    dir = pluginPath;

    try
    {
        DirectoryIterator it(dir);
        DirectoryIterator end;
        while (it != end)
        {
            /* loop for each dir */
            if (it->isDirectory() == true)
            {
                astring strName = it->path();
                try
                {
                    DirectoryIterator it2(it->path());
                    DirectoryIterator end2;

                    while (it2 != end2)
                    {
                        astring strName2 = it2->path();
                        if (it2->path().find("mplugin") != std::string::npos)
                        {
                            /* Find a plugin and call mmodule to add */
                            astring strPluginName = it2->path();
                            MiningModule * pModule =
                                new MiningModule(strPluginName, m_pFactory);
                            if (pModule && pModule->Valid() == TRUE)
                            {
                                pModule->Init();
                                m_MModules[strPluginName] = pModule;
                            }

                        }
                        ++it2;
                    }
                }
                catch (Poco::Exception& exc)
                {
                    continue;
                }
            }

            ++it;
        }
    }
    catch (Poco::Exception& exc)
    {
        std::cerr << exc.displayText() << std::endl;
        VDC_DEBUG( "Plugin init error \n");

        return FALSE;
    }

    return TRUE;
}
Example #19
0
void VSCDeviceTree::SiteAddClick()
{
    VDC_DEBUG( "%s \n",__FUNCTION__);
    emit SiteAddClicked();
    return;
}
Example #20
0
inline BOOL Factory::Init()
{

	s32 i = 0;

	for (i = 0; i < FACTORY_DEVICE_ID_MAX; i ++)
	{
	    m_strDeviceMap[i] = 'n';
	}
	for (i = 0; i < FACTORY_DEVICE_ID_MAX; i ++)
	{
	    m_strVIPCMap[i] = 'n';
	}



	astring strPath;
	if (m_SysPath.GetSystemPath(strPath) == FALSE)
	{
	    return FALSE;
	}
	printf("Sys path %s\n", strPath.c_str());
#ifdef WIN32
#ifndef _WIN64
	astring strPathConf = strPath + "videodb\\config";
#else
	astring strPathConf = strPath + "videodb64\\config";
#endif
#else
	astring strPathConf = strPath + "videodb/config";
#endif
	m_Conf.Open(strPathConf);

#ifndef _WIN64
	astring strPathDb = strPath + "videodb";
#else
	astring strPathDb = strPath + "videodb64";
#endif
	m_pVdb = new VDB(strPathDb);

	VSCHdfsRecordData HdfsConf;
	m_Conf.GetHdfsRecordConf(HdfsConf);
	astring strNameNode = HdfsConf.data.conf.NameNode;
	astring strPort = HdfsConf.data.conf.Port;
	astring strUser = HdfsConf.data.conf.User;
	m_pVHdfsdb = new VHdfsDB(strNameNode, strPort, strUser);

	VSCConfData sysData;
	m_Conf.GetSysData(sysData);
	for (s32 i = 1; i < CONF_MAP_MAX; i ++)
	{
	    if (sysData.data.conf.DeviceMap[i] != CONF_MAP_INVALID_MIN 
			&& sysData.data.conf.DeviceMap[i] != 0)
	    {
	        VDC_DEBUG( "%s Init Device %d\n",__FUNCTION__, i);
	        VSCDeviceData Data;
	        m_Conf.GetDeviceData(i, Data);
	        DeviceParam mParam(Data);
	        LockDeviceID(Data.data.conf.nId);
	        InitAddDevice(mParam, Data.data.conf.nId);
	        VDC_DEBUG( "%s Id %d\n",__FUNCTION__, Data.data.conf.nId);
	    }
	}

	for (s32 i = 1; i < CONF_MAP_MAX; i ++)
	{
	    if (sysData.data.conf.VIPCMap[i] != CONF_MAP_INVALID_MIN 
			&& sysData.data.conf.VIPCMap[i] != 0)
	    {
	        VDC_DEBUG( "%s Init VIPC %d\n",__FUNCTION__, i);
	        VSCVIPCData Data;
	        m_Conf.GetVIPCData(i, Data);
	        VIPCDeviceParam mParam(Data);
	        LockVIPCID(Data.data.conf.nId);
	        m_VIPCDeviceParamMap[i] = mParam;
	        VDC_DEBUG( "%s Id %d\n",__FUNCTION__, Data.data.conf.nId);
	    }
	}

	InitLicense();
	//m_pThread = new thread(Factory::Run, (void *)this);
	//start();
	m_HddTask = new FactoryHddTask(*this);
	m_HddTask->start();

	if (sysData.data.conf.OAPIPort == 0)
	{
		sysData.data.conf.OAPIPort = 9080;
	}
	//m_pHttpServer = new CmnHttpServer(sysData.data.conf.OAPIPort);
	//m_pHttpServer->start();
	return TRUE;
}
Example #21
0
BOOL DeviceParam::UpdateUrlOnvif()
{
	astring IP = m_Conf.data.conf.IP;
	astring Port = m_Conf.data.conf.Port;
	astring User = m_Conf.data.conf.User;
	astring Password = m_Conf.data.conf.Password;
	astring OnvifAddress = m_Conf.data.conf.OnvifAddress;

	astring OnvifDeviceService = "http://" + IP + ":" + Port + OnvifAddress;
	astring url = "rtsp://" + IP + ":" + "554" + "/";
	astring urlSubStream = "rtsp://" + IP + ":" + "554" + "/";

	DeviceManagement *pDm = new DeviceManagement(OnvifDeviceService.c_str(), 
	                        User.c_str(), Password.c_str());

	if (pDm  == NULL)
	{
	    VDC_DEBUG( "%s new DeviceManagement error \n",__FUNCTION__);
	    return FALSE;
	}

	Capabilities * pMediaCap = pDm->getCapabilitiesMedia();
	if (pMediaCap == NULL)
	{
	    VDC_DEBUG( "%s getCapabilitiesMedia error \n",__FUNCTION__);
	    delete pDm;
	    return FALSE;
	}

	MediaManagement *pMedia = new MediaManagement(pMediaCap->mediaXAddr(), 
	                            User.c_str(), Password.c_str());
	if (pMedia == NULL)
	{
	    VDC_DEBUG( "%s new MediaManagement error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    return FALSE;
	}

	Profiles *pProfileS = pMedia->getProfiles();
	if (pProfileS == NULL)
	{
	    VDC_DEBUG( "%s new getProfiles error \n",__FUNCTION__);
	    delete pDm;
	    delete pMediaCap;
	    delete pMedia;
	    return FALSE;
	}
	if (pProfileS->m_toKenPro.size() > 0)
	{
	    VDC_DEBUG( "%s m_toKenPro size %d \n",__FUNCTION__, pProfileS->m_toKenPro.size());
		QString strToken;
		if (m_Conf.data.conf.UseProfileToken == 1)
		{
			strToken = m_Conf.data.conf.OnvifProfileToken;
		}else
		{
			strToken = pProfileS->m_toKenPro[0];
			strcpy(m_Conf.data.conf.OnvifProfileToken, pProfileS->m_toKenPro[0].toStdString().c_str());
		}
		StreamUri *pUri = pMedia->getStreamUri(strToken);
		if (pUri)
		{
			m_strUrl = pUri->uri().toStdString();
			delete pUri;
		}
	}
	if (pProfileS->m_toKenPro.size() > 1)
	{
		VDC_DEBUG( "%s m_toKenPro SubStream size %d \n",__FUNCTION__, pProfileS->m_toKenPro.size());
		QString strToken;
		if (m_Conf.data.conf.UseProfileToken == 1)
		{
			strToken = m_Conf.data.conf.OnvifProfileToken2;
		}else
		{
			strToken = pProfileS->m_toKenPro[1];
			strcpy(m_Conf.data.conf.OnvifProfileToken2, pProfileS->m_toKenPro[1].toStdString().c_str());
		}
		StreamUri *pUri = pMedia->getStreamUri(strToken);
		if (pUri)
		{
			m_strUrlSubStream = pUri->uri().toStdString();
			m_bHasSubStream = TRUE;
			delete pUri;
		}
	}

	/* rtsp://admin:[email protected]:554/Streaming/Channels/1\
	?transportmode=unicast&profile=Profile_1 */
	//astring urlWithUser = "******" + User + ":" + Password + "@";
	//Replace(strUrl, "rtsp://", urlWithUser.c_str());

	m_bOnvifUrlGetted = TRUE;

	delete pDm;
	delete pMediaCap;
	delete pMedia;
	delete pProfileS;
	
	return TRUE;
}
Example #22
0
BOOL OAPIServer::ProcessGetSysDisk(s32 len)
{
	if (len == 0)
	{
		return FALSE;
	}
	char *pRecv = new char[len + 1];
	s32 nRetBody = m_pSocket->Recv((void *)pRecv, len);
	oapi::OAPISysDiskListReq req;
	if (nRetBody == len)
	{
		autojsoncxx::ParsingResult result;
		if (!autojsoncxx::from_json_string(pRecv, req, result)) 
		{
			std::cerr << result << '\n';
			delete [] pRecv;
			return FALSE;
		}
	}

	oapi::OAPISysDiskListRsp dataList;
	QList<QStorageInfo> hdd = QStorageInfo::mountedVolumes();
	QListIterator<QStorageInfo> it(hdd);
	while(it.hasNext())
	{
		QStorageInfo  disk = it.next();
		astring strHdd = disk.rootPath().toStdString();
		
		VDC_DEBUG( "%s strHdd %s \n",__FUNCTION__, strHdd.c_str());
		s64 totalSize = disk.bytesTotal() / (1024 * 1024);
		s64 leftSize = disk.bytesFree()/ (1024 * 1024);
		
		VDC_DEBUG( "%s Total %lld M Left %lld M \n",__FUNCTION__, totalSize, leftSize);  
		QString strQtHdd = disk.rootPath();
		HddDriveType diskType = HddGetDriveType(strQtHdd);
		
		VDC_DEBUG( "%s Type %d \n",__FUNCTION__,  diskType);
		
		if (totalSize/1024 < 4 || leftSize/1024 < 2) /* In G */
		{
			continue;
		}
		
		if (diskType == HddInternalDrive 
			|| diskType == HddRemovableDrive || diskType == HddRemoteDrive)
		{
			oapi::OAPIDisk oapiDisk;
			oapiDisk.strId = disk.device().toStdString();
			oapiDisk.strPath = disk.rootPath().toStdString();
			oapiDisk.nTotalSize = disk.bytesTotal();
			oapiDisk.nFreeSize = disk.bytesFree();
			oapiDisk.nStorSize = 0;
			dataList.list.push_back(oapiDisk);
		}
	}

	std::string strJson = autojsoncxx::to_pretty_json_string(dataList);
	s32 nJsonLen = strJson.length();
	if (nJsonLen <= 0)
	{
		return FALSE;
	}
	
	OAPIHeader header;
	header.cmd = htonl(OAPI_CMD_SYS_DISK_LIST_RSP);
	header.length = htonl(nJsonLen + 1);

	m_pSocket->Send((void *)&header, sizeof(header));
	m_pSocket->Send((void *)strJson.c_str(), nJsonLen + 1);

	return TRUE;
}
Example #23
0
 BOOL Device::PtzAction(FPtzAction action, float speed)
{
	if (m_param.m_Online == FALSE || m_ptzInited == FALSE)
	{
		VDC_DEBUG( "%s PTZ Camera is Offline\n",__FUNCTION__);
		return TRUE;
	}
	switch (action)
	{
		case F_PTZ_UP:	
		{
			m_continuousMove.setPanTiltX(0);
			m_continuousMove.setPanTiltY(speed);
			m_continuousMove.setZoomX(0);
			m_continuousMove.setTimeout("PT0H0M3.600S");
			m_ptz->continuousMove(&m_continuousMove);
			break;
		}
		case F_PTZ_DOWN:	
		{
			m_continuousMove.setPanTiltX(0);
			m_continuousMove.setPanTiltY(0 - speed);
			m_continuousMove.setZoomX(0);
			m_continuousMove.setTimeout("PT0H0M3.600S");
			m_ptz->continuousMove(&m_continuousMove);
			break;
		}
		case F_PTZ_LEFT:	
		{
			m_continuousMove.setPanTiltX(0 - speed);
			m_continuousMove.setPanTiltY(0);
			m_continuousMove.setZoomX(0);
			m_continuousMove.setTimeout("PT0H0M3.600S");
			m_ptz->continuousMove(&m_continuousMove);
			break;
		}
		case F_PTZ_RIGHT:	
		{
			m_continuousMove.setPanTiltX(speed);
			m_continuousMove.setPanTiltY(0);
			m_continuousMove.setZoomX(0);
			m_continuousMove.setTimeout("PT0H0M3.600S");
			m_ptz->continuousMove(&m_continuousMove);
			break;
		}
		case F_PTZ_ZOOM_IN:	
		{
			m_continuousMove.setPanTiltX(0);
			m_continuousMove.setPanTiltY(0);
			m_continuousMove.setZoomX(speed);
			m_continuousMove.setTimeout("PT0H0M3.600S");
			m_ptz->continuousMove(&m_continuousMove);
			break;
		}
		case F_PTZ_ZOOM_OUT:	
		{
			m_continuousMove.setPanTiltX(0);
			m_continuousMove.setPanTiltY(0);
			m_continuousMove.setZoomX(0 - speed);
			m_continuousMove.setTimeout("PT0H0M3.600S");
			m_ptz->continuousMove(&m_continuousMove);
			break;
		}
		case F_PTZ_STOP:	
		{
			m_stop.setPanTilt(true);
			m_stop.setZoom(false);
			m_ptz->stop(&m_stop);
			break;
		}
		default:
			break;
	}
}
Example #24
0
void VSCSearch::intTest(int a)
{
	VDC_DEBUG( " intTest %d\n", a);
}
Example #25
0
void VSCVWidget::TimeLineLengthChanged(int index)
{
    VDC_DEBUG( "%s  index Changed %d\n",__FUNCTION__,
            index);
    ui.widgetTimeline->SetTimeLineLength((VscTimelineLength)index);
}
Example #26
0
void VSCVGroupMap::dragMoveEvent(QDragMoveEvent *event)
{
    VDC_DEBUG( "%s Enter in dropEvent id %d\n",__FUNCTION__, m_pParam.nId);
    event->accept();
}
Example #27
0
void VSCDeviceIPC::mousePressEvent(QMouseEvent *event)
{
	VDC_DEBUG( "%s \n",__FUNCTION__);
}
Example #28
0
void VideoWidget::resizeEvent( QResizeEvent * event )
{    
	VDC_DEBUG( "%s Resize\n",__FUNCTION__);   
	QWidget::resizeEvent(event);    
	emit videoResize();
}
Example #29
0
void VSCCameraAdd::applyConfig()
{
	VDC_DEBUG( "%s  ID %d\n",__FUNCTION__, m_nId);
	/* Update m_Param from UI  */
	updateParamValue(ui.lineEditName, m_Param.m_Conf.data.conf.Name);

	updateParamValue(ui.lineEditIP, m_Param.m_Conf.data.conf.IP);
	updateParamValue(ui.lineEditPort, m_Param.m_Conf.data.conf.Port);
	updateParamValue(ui.lineEditUser, m_Param.m_Conf.data.conf.User);
	updateParamValue(ui.lineEditPassword, m_Param.m_Conf.data.conf.Password);


	updateParamValue(ui.lineEditRtspLoc, m_Param.m_Conf.data.conf.RtspLocation);
	//updateParamValue(ui.lineFileLoc, m_Param.m_Conf.data.conf.FileLocation);
	/* Update the File location */
	strcpy(m_Param.m_Conf.data.conf.FileLocation, ui.fileLoc->text().toStdString().c_str());
	updateParamValue(ui.lineOnvifAddr, m_Param.m_Conf.data.conf.OnvifAddress);
	updateParamValue(ui.lineEditProfileToken, m_Param.m_Conf.data.conf.OnvifProfileToken);
	updateParamValue(ui.lineEditProfileToken2, m_Param.m_Conf.data.conf.OnvifProfileToken2);
	m_Param.m_Conf.data.conf.nType = VSC_DEVICE_CAM;
	if (ui.radioButtonRtsp->isChecked() == true)
	{
	    m_Param.m_Conf.data.conf.nSubType = VSC_SUB_DEVICE_RTSP;
	}else if (ui.radioButtonOnvif->isChecked() == true)
	{
	    m_Param.m_Conf.data.conf.nSubType = VSC_SUB_DEVICE_ONVIF;
	}else if (ui.radioButtonFile->isChecked() == true)
	{
	    m_Param.m_Conf.data.conf.nSubType = VSC_SUB_DEVICE_FILE;
	}

	if (ui.checkBoxProfileToken->isChecked() == true)
	{
	    m_Param.m_Conf.data.conf.UseProfileToken = 1;
	}else
	{
	    m_Param.m_Conf.data.conf.UseProfileToken = 0;
	}

	/* HWAccel */
	if (ui.checkBoxHWAccel->isChecked() == true)
	{
	    m_Param.m_Conf.data.conf.HWAccel = 1;
	}else
	{
	    m_Param.m_Conf.data.conf.HWAccel = 0;
	}

	/* Mining */
	if (ui.checkBoxDataMining->isChecked() == true)
	{
	    m_Param.m_Conf.data.conf.Mining = 1;
	}else
	{
	    m_Param.m_Conf.data.conf.Mining = 0;
	}


	if (m_nId > 0)
	{
	    gFactory->DelDevice(m_nId);
	}
	VDC_DEBUG( "%s  Line %d\n",__FUNCTION__, __LINE__);
	/* m_nId <= 0 is Add Camera Device */
	m_nId = gFactory->AddDevice(m_Param);

	VDC_DEBUG( "%s  ID %d\n",__FUNCTION__, m_nId);
	//PreView();
	VDC_DEBUG( "%s  Line %d\n",__FUNCTION__, __LINE__);
	//emit CameraTreeUpdated();
}
Example #30
0
VSCVideoWall::~VSCVideoWall()
{
    VDC_DEBUG( "%s ~VSCVideoWall\n",__FUNCTION__);
}