Exemple #1
0
void VidCamAdd::SlotNewCam()
{
	VidCamera pCam;
	UUIDGenerator uuidCreator;
	astring strId  = uuidCreator.createRandom().toString();
	pCam.set_strid(strId);
	pCam.set_strname("New Camera");
	pCam.set_strip("192.168.0.1");
	pCam.set_strport("80");
	pCam.set_struser("admin");
	pCam.set_strpasswd("admin");
	pCam.set_ntype(VID_ONVIF_S);
	pCam.set_stronvifaddress("/onvif/device_service");
	pCam.set_bmotionjpeg(false);


	pCam.set_strrtspurl("rtsp://192.168.0.1:554/Streaming");
	astring filePath = "camera.mp4";
	pCam.set_strfile(filePath.c_str());
	astring *pSched = pCam.add_crecsched();
	*pSched = REC_SCHED_ALL_DAY;
	
	int insertRow = ui.tableWidget->rowCount();
	ui.tableWidget->insertRow(insertRow);
	QTableWidgetItem *firstCheck = new VidCamTableItem(pCam, false);
	firstCheck->setCheckState(Qt::Checked);
	ui.tableWidget->setItem(insertRow, 0, firstCheck);
	ui.tableWidget->setItem(insertRow, 1, new QTableWidgetItem(pCam.strname().c_str()));
	ui.tableWidget->setItem(insertRow, 2, new QTableWidgetItem(pCam.strip().c_str()));
	ui.tableWidget->setItem(insertRow, 3, new QTableWidgetItem(pCam.struser().c_str()));

	ui.tableWidget->selectRow(insertRow);

	emit(SignalSectionClicked(insertRow, 0));
}
Exemple #2
0
void VidStorAdd::SlotNewStor()
{
	VidStor pStor;
	UUIDGenerator uuidCreator;
	astring strId  = uuidCreator.createRandom().toString();
	pStor.set_strid(strId);
	pStor.set_strname("New Stor");
	pStor.set_strip("192.168.0.1");
	pStor.set_strport("9080");
	pStor.set_struser("admin");
	pStor.set_strpasswd("admin");
	
	int insertRow = ui.tableWidget->rowCount();
	ui.tableWidget->insertRow(insertRow);
	QTableWidgetItem *firstCheck = new VidStorTableItem(pStor, false);
	firstCheck->setCheckState(Qt::Checked);
	ui.tableWidget->setItem(insertRow, 0, firstCheck);
	ui.tableWidget->setItem(insertRow, 1, new QTableWidgetItem(pStor.strname().c_str()));
	ui.tableWidget->setItem(insertRow, 2, new QTableWidgetItem(pStor.strip().c_str()));
	ui.tableWidget->setItem(insertRow, 3, new QTableWidgetItem(pStor.struser().c_str()));

	ui.tableWidget->selectRow(insertRow);

	emit(SignalSectionClicked(insertRow, 0));
}
Exemple #3
0
OAPIServer::OAPIServer(XRef<XSocket> pSocket, Factory &pFactory)
:m_pFactory(pFactory), m_pSocket(pSocket), m_cnt(0), 
m_bLogin(FALSE)
{
	UUIDGenerator uuidCreator;
	
	m_seesionId  = uuidCreator.createRandom().toString();
}
int main( )
{
	AbsRandomGenerator *randomGen = new SSLRandomGenerator( );
	UUIDGenerator uuidGen = UUIDGenerator( randomGen );
	std::vector<byte> uuid = uuidGen.getUUID_V4() ;
	std::cout.fill( '0' );
	for( int i =0 ; i< AbsUUID::MAX_BYE_LEN ; i++ )
	{
		std::cout << std::setw(8) << std::hex << (int)uuid[i] ;
		std::cout<< "-" ;
	}

	std::cout << std::endl;
}
Exemple #5
0
void VidCamAdd::SlotAddAll()
{
	int insertRow = ui.tableSearch->rowCount();
    	VDC_DEBUG( "[ONVIF]: Searched %d", insertRow);
	StorSyncInf syncInf(m_sStor, 5 * 1000);

	VSCLoading loading(NULL);
	loading.show();
	QDesktopWidget *desktop = QApplication::desktop();
	QRect rect = desktop->screenGeometry(0);
	loading.setGeometry(rect.width()/2, rect.height()/2, 64, 64);
	QCoreApplication::processEvents();

	if (syncInf.Connect() == false)
	{
		return;
	}

	/* Loop to add device */
	for (int i = 0; i < insertRow; i ++)
	{
		if (ui.tableSearch->item(i, 0)->checkState() != Qt::Checked)
		{
			continue;
		}
		
		VidCamera pCam;
		UUIDGenerator uuidCreator;
		astring strId  = uuidCreator.createRandom().toString();
		pCam.set_strid(strId);
		pCam.set_strname(ui.tableSearch->item(i, 5)->text().toStdString());
		pCam.set_strip(ui.tableSearch->item(i, 1)->text().toStdString());
		pCam.set_strport(ui.tableSearch->item(i, 2)->text().toStdString());
		pCam.set_struser(ui.tableSearch->item(i, 6)->text().toStdString());
		pCam.set_strpasswd(ui.tableSearch->item(i, 7)->text().toStdString());
		pCam.set_ntype(VID_ONVIF_S);
		pCam.set_stronvifaddress(ui.tableSearch->item(i, 4)->text().toStdString());


		pCam.set_strrtspurl("/streamaddress");
		astring filePath = "/camera.mp4";
		pCam.set_strfile(filePath.c_str());
		astring *pSched = pCam.add_crecsched();
		*pSched = REC_SCHED_ALL_DAY;
		syncInf.AddCam(pCam);
		//m_pFactory.GetStorFactory().AddCam(m_sStor.strid(), pCam);
	}

	TreeWidgetUpdate();
}
Exemple #6
0
void VSCView::ViewClicked()
{
	VideoWallLayoutMode nMode;
	m_pVideo->GetLayoutMode(nMode);	
       VSCViewConf view;
	view.SetName(m_ViewItem.strname());
       view.show();
       QDesktopWidget *desktop = QApplication::desktop();
	QRect rect = desktop->screenGeometry(0);
	view.setGeometry(rect.width()/2 -view.width()/2 , 
					rect.height()/2 - view.height()/2, 
					view.width(), view.height());
       view.exec();


	VSCViewConfType type = view.GetType();
	if (type == VSC_VIEW_CONF_LAST)
	{
		return;
	}
	VidView NewView;
	NewView.set_clayout((VidLayout)nMode);
	string strName = "View";
	view.GetName(strName);

	std::map<int, VidViewWindow> playMap;
	m_pVideo->GetPlayMap(playMap);
	std::map<int, VidViewWindow>::iterator it = playMap.begin(); 
	for(; it!=playMap.end(); ++it)
	{
		VidViewWindow * pWinNew = NewView.add_cview();
		*pWinNew = (*it).second;
	}
	
	NewView.set_strname(strName);
	if (type == VSC_VIEW_CONF_MODIFY && m_ViewItem.strid() != VVID_UUID_NULL)
	{
		m_pFactory.DelView(m_ViewItem.strid());
		NewView.set_strid(m_ViewItem.strid());
	}else
	{
		UUIDGenerator uuidCreator;
		astring strId  = uuidCreator.createRandom().toString();
		NewView.set_strid(strName);
	}
	m_pFactory.AddView(NewView);
	m_ViewItem = NewView;
}
Exemple #7
0
int Plugin::replaceWithLink(std::string filepath)
{
    std::cout << "Replacing with link " << filepath.c_str() << std::endl;

    std::ifstream fstr(filepath.c_str());
    MD5Engine md5;
    DigestOutputStream ostr(md5);
    Poco::StreamCopier::copyStream(fstr, ostr);
    ostr.flush();
    const DigestEngine::Digest& digest = md5.digest();
    std::string sourceMd5 = DigestEngine::digestToHex(digest);
    std::cout << "File contents MD5 sum: " << sourceMd5.c_str() << std::endl;

    // Generate new file name
    UUIDGenerator gen;
    UUID tmpUuid = gen.createRandom();
    std::string uuid = tmpUuid.toString(); 
    std::string newFile(Plugin::GIT_CACHE_DIR);
    newFile.append("/");
    newFile.append(uuid);

    Process::Args args;
    args.push_back(filepath);
    args.push_back(newFile);
    Poco::ProcessHandle ph = Process::launch("mv", args, 0, 0, 0);

    // Failback with sudo
    if (ph.wait() != 0)
    {
        args.clear();
        args.push_back("mv");
        args.push_back(filepath);
        args.push_back(newFile);
        ph = Process::launch("sudo", args, 0, 0, 0);
    }

    // Check if file was moved
    File originalFile(filepath);
    if (originalFile.exists())
    {
        std::cout << "Failed to move original file" << std::endl;
        return -1;
    }

    return 1;
}
Exemple #8
0
CameraParam::CameraParam()
{
	UUIDGenerator uuidCreator;
	
	astring strId  = uuidCreator.createRandom().toString();
	m_Conf.set_ntype(VID_ONVIF_S);
	m_Conf.set_strid(strId);
	m_Conf.set_strname("Camera");

	m_Conf.set_strip("192.168.0.1");
	m_Conf.set_strport("80");
	m_Conf.set_struser("admin");
	m_Conf.set_strpasswd("admin");

	m_Conf.set_strrtspurl("rtsp://192.168.0.1:554/Streaming");

	astring filePath = GetProgramDir() +  "camera.mp4";

	m_Conf.set_strfile(filePath.c_str());

	m_Conf.set_stronvifaddress("/onvif/device_service");

	m_Conf.set_bprofiletoken(false);
	m_Conf.set_bhwaccel(false);

	m_Conf.set_strprofiletoken1("quality_h264");
	m_Conf.set_strprofiletoken1("second_h264");
	m_Conf.set_bhdfsrecord(false);
	astring *pSched = m_Conf.add_crecsched();
	*pSched = REC_SCHED_ALL_DAY;
	
	m_bOnvifUrlGetted = false;
	m_bHasSubStream = false;

	m_Conf.set_nconnecttype(VID_CONNECT_TCP);

	m_Online = false;
	m_OnlineUrl = false;

	astring IP = m_Conf.strip();
	m_strUrl = "rtsp://" + IP + ":" + "554" + "/Streaming";
	m_strUrlSubStream = "rtsp://" + IP + ":" + "554" + "/Streaming";

}
Exemple #9
0
void Plugin::addFile(const std::string filepath)
{
    logger().debug("Adding file");
    // Check if file exists and it's not a directory
    File file(filepath);
    if (!file.exists())
    {
        std::cout << "Failed to add file " << filepath.c_str() << ": file does not exist" << std::endl;
        return;
    }
    if (file.isDirectory())
    {
        std::cout << "Failed to add file " << filepath.c_str() << ": file is a directory" << std::endl;
        return;

    }
    File index(Plugin::GIT_BIN_INDEX);
    if (!index.exists())
    {
        index.createFile();
    }
    // Find this file in the index
    if (isFileIndexed(filepath) && file.isLink())
    {
        logger().debug("File already in cache");
        auto entry = getIndexEntry(filepath);
        if (entry == nullptr)
        {
            std::cout << "Failed to retrieve index meta data for " << filepath << std::endl;
            return;
        }
        // Not fresh. Update existing index file
        // Remove file from index before recalculating everything
        for (auto it = _index.begin(); it != _index.end();) 
        {
            if ((*it).filepath == filepath)
            {
                // Remove link
                std::cout << "Replacing link with original file" << std::endl; 
                file.remove();
                Process::Args restoreArgs;
                std::string restorePath(Plugin::GIT_CACHE_DIR);
                restorePath.append("/wf/");
                restorePath.append((*it).uuid);
                restoreArgs.push_back(restorePath);
                restoreArgs.push_back(filepath);
                Process::launch("mv", restoreArgs, 0, 0, 0);
                it = _index.erase(it); 
            } else {
                it++;
            }
        } 

    }
    // Add new file into index
    UUIDGenerator gen;
    IndexEntry e;
    e.filepath = filepath;
    e.md5 = getFileMd5(filepath);
    e.uuid = gen.createRandom().toString();
    do 
    {
        e.uuid = gen.createRandom().toString();
    }
    while (!isUuidUnique(e.uuid));
    _index.push_back(e);
    writeIndex();

    // Place two copies of this file into cache
    // One copy is original file and don't tracked in any way
    // Second copy is a file we will create link to

    Process::Args args;
    args.push_back(filepath);
    std::string origPath(Plugin::GIT_CACHE_DIR);
    origPath.append("/of/").append(e.uuid);
    args.push_back(origPath);
    Poco::ProcessHandle copyProcess = Process::launch("cp", args, 0, 0, 0);
    if (copyProcess.wait() != 0)
    {
        std::cout << "Failed to move file into git-bin cache" << std::endl;
        return;
    }
    // Second stage copy
    args.clear();
    args.push_back(filepath);
    std::string workPath(Plugin::GIT_CACHE_DIR);
    workPath.append("/wf/").append(e.uuid);
    args.push_back(workPath);
    copyProcess = Process::launch("mv", args, 0, 0, 0);
    if (copyProcess.wait() != 0)
    {
        std::cout << "Failed to move file on stage 2" << std::endl;
        return;
    }

    // Make a link
    args.clear();
    args.push_back("-s");
    Path rel(filepath);
    std::string relPath;
    for (int i = 0; i < rel.depth(); i++)
    {
        relPath.append("../");
    }
    relPath.append(workPath);
    args.push_back(relPath);
    args.push_back(filepath);
    Poco::ProcessHandle linkProcess = Process::launch("ln", args, 0, 0, 0); 
    if (linkProcess.wait() != 0)
    {
        std::cout << "Failed to create link to file" << std::endl;
        return;
    }

    args.clear();
    args.push_back("add");
    args.push_back(filepath);
    Poco::ProcessHandle gitAddProcess = Process::launch("git", args, 0, 0, 0);
    if (gitAddProcess.wait() != 0)
    {
        std::cout << "Failed to add file into git index (git add)" << std::endl;
        return;
    }
}