Example #1
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 #2
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 #3
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 #4
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;
}