Ejemplo n.º 1
0
void ToolTip::requestToolTip(const DB::FileName &fileName)
{
    if ( fileName.isNull() || fileName == m_currentFileName)
        return;
    m_currentFileName = fileName;
    requestImage( fileName );
}
Ejemplo n.º 2
0
QPixmap SvgElementProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize)
{
	return QPixmap::fromImage(requestImage(id, size, requestedSize));
}
Ejemplo n.º 3
0
QPixmap CameraModel::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
    return QPixmap::fromImage(requestImage(id, size, requestedSize));
}
Ejemplo n.º 4
0
// renyang-TODO - 加入Vedio的部分吧
// renyang - 分析這一個封包是什麼種類的封包
// renyang - 依不同的封包, 做不一樣的事情
bool Receiver::processPacket(Packet *p)
{
#ifdef REN_DEBUG
	qWarning("Receiver::processPacket(Packet *p)");
#endif
	switch (p->getInfo())
	{
		case IHU_INFO_CRYPTED_AUDIO:
			if (blowfish)
			{
				// renyang - 解碼
				p->decrypt(blowfish);
			}
			else
			{
				if (!nodecrypt)
				{
					emitSignal(SIGNAL_KEYREQUEST);
				}
				break;
			}
		case IHU_INFO_AUDIO:
			// renyang - 取出資料, 並且通知有新資料到
			if (p->getDataLen() > MIN_DATA_SIZE)
			{
				emit newAudioData(p->getData(), p->getDataLen());
			}
			connected = true;
			break;
		case IHU_INFO_NEW_KEY:
			if (p->getDataLen() > MIN_DATA_SIZE)
			{
				char *out;
				int len = rsa->decrypt(p->getData(), p->getDataLen(), &out);
				if (blowfish)
					delete blowfish;
				blowfish = new Blowfish(out, len);
				emitSignal(SIGNAL_NEWKEY);
				free(out);
			}
			break;
		case IHU_INFO_KEY_REQUEST:
			if (p->getDataLen() > MIN_DATA_SIZE)
			{
				rsa->setPeerPublicKey(p->getData(), p->getDataLen());
				emitSignal(SIGNAL_SENDNEWKEY);
			}
			break;
		case IHU_INFO_RING:
			if (p->getDataLen() > MIN_DATA_SIZE)
			{
				ihu_reply = true;
				QString tempName = p->getData(); 
				if (!tempName.isEmpty())
					callerName = tempName;
			}
			emit warning(QString("!! CALL from %1 (%2) !!").arg(getIp()).arg(getCallerName()));
			emitSignal(SIGNAL_RING);
			break;
		case IHU_INFO_ANSWER:
			// renyang - 對方答應接應電話啦
			connected = true;
		case IHU_INFO_RING_REPLY:
			// renyang - 對方還沒有要接通電話
			ihu_reply = true;
			if (p->getDataLen() > MIN_DATA_SIZE)
				callerName = p->getData();
			break;
		case IHU_INFO_ERROR:
			ihu_abort = true;
		case IHU_INFO_REFUSE:
			// renyang - 對方拒絕接通電話
			ihu_refuse = true;
		case IHU_INFO_CLOSE:
			emitSignal(SIGNAL_FINISH);
			break;
		case IHU_INFO_INIT:
			emitSignal(SIGNAL_INIT);
		case IHU_INFO_RESET:
			disableDecrypt();
			break;
		// renyang - 對方要求Image(影像)
		case IHU_INFO_VIDEO_REQUEST:
			emit requestImage();
			break;
		// renyang-modify - 要求對方影像失敗
		case IHU_INFO_VIDEO_ERROR:
			emit requestImageFail();
			break;
		case IHU_INFO_VIDEO:
			// renyang-modify - 接收到片斷的image, 把資料放到Call::RecvImage中
			if (p->getDataLen() > MIN_DATA_SIZE)
			{
				emit newVideoData(p->getData(), p->getDataLen());
			}
			connected = true;
			break;
		case IHU_INFO_VIDEO_NEXT:
			emit requestNextImage();
			break;
		case IHU_INFO_VIDEO_END:
			emit completeImage();
			break;
		case IHU_INFO_VIDEO_CONFIRM:
			// renyang-modify - 只是用來確認線路是否是通的
			break;

	}
	return true;
}
Ejemplo n.º 5
0
Call::Call(int callId, QString myName)
{
#ifdef REN_DEBUG
	qWarning(QString("Call::Call(int %1, QString %2)").arg(callId).arg(myName));
#endif
	id = callId;
	sd = -1;

	dec_state = NULL;
	dec_state = speex_decoder_init(&speex_uwb_mode);
	// renyang - Initializes and allocates resources for a SpeexBits struct
	speex_bits_init(&bits);

	int enh = 1;
	speex_decoder_ctl(dec_state, SPEEX_SET_ENH, &enh);
	speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &frame_size);

	if ((outBuffer = (float *) malloc(frame_size*4*sizeof(float)))==NULL)
		throw Error(Error::IHU_ERR_MEMORY);
	if ((soundBuffer = (float *) malloc(MAXBUFSIZE*sizeof(float)))==NULL)
		throw Error(Error::IHU_ERR_MEMORY);
	readyFrames = 0;

	rsa = new Rsa(RSA_STRENGTH);
	transmitter = new Transmitter(rsa);
	receiver = new Receiver(rsa);
	// renyang-modify 建立一個ip handler
	sctpiphandler = new SctpIPHandler();

	// renyang-modify - 當某一個ip沒有一段時間後, 沒有辦法收到data, 要處理
	connect(sctpiphandler,SIGNAL(SigAddressConfrim(QString)),this,SLOT(SlotAddressConfirm(QString)));
	// renyang-modify - 當多次沒有收到資料, 宣告這一個ip失聯
	connect(sctpiphandler,SIGNAL(SigAddressFail(QString)),this,SLOT(SlotAddressFail(QString)));
	// renyang-modify - 某一個ip有收到資料, 宣告這一個ip復活啦
	connect(sctpiphandler,SIGNAL(SigAddressAvailable(QString)),this,SLOT(SlotAddressAvailable(QString)));

	stopTimer = new QTimer(this);

	active = false;
	muteRec = false;
	mutePlay = false;
	callFree = true;
	aborted = false;
	recording = false;

	// renyang-modify - 初始化IPChanging, 表示最近沒有改變primary address
	IPChanging = false;
	// renyang-modify - 建立一個Timer來計數改完primary address後多久要改回IPChanging=false
	IPChangingTimer = new QTimer(this);
	connect(IPChangingTimer,SIGNAL(timeout()),this,SLOT(resetIPChanging()));

	// renyang-modify - 初始化傳送與接收image的index
	recvImage_index = sendImage_index = 0;

	transmitter->setMyName(myName);

	srand(time(NULL));

	connect( receiver, SIGNAL(newSocket(int,int,struct sockaddr_in)), this, SLOT(newConnection(int,int,struct sockaddr_in)) );
	connect( receiver, SIGNAL(keyRequest()), this, SLOT(sendKeyRequest()) );
	connect( receiver, SIGNAL(sendNewKey()), this, SLOT(sendKey()) );
	connect( receiver, SIGNAL(newKey(QString)), this, SLOT(receivedNewKey(QString)) );
	// renyang - 沒有再接收到client端傳送過來的訊息, 結束此Call
	connect( receiver, SIGNAL(finishSignal()), this, SLOT(stopCall()) );
	connect( receiver, SIGNAL(error(QString)), this, SLOT(abortCall(QString)) );
	connect( receiver, SIGNAL(warning(QString)), this, SLOT(warning(QString)) );
	connect( receiver, SIGNAL(message(QString)), this, SLOT(warning(QString)) );
	// renyang - 對方接受通話, 或是本地端接受通話
	connect( receiver, SIGNAL(connectedSignal()), this, SLOT(connected()) );
	connect( receiver, SIGNAL(ringSignal()), this, SLOT(playRing()) );
	connect( receiver, SIGNAL(initSignal()), this, SLOT(playInit()) );
	connect( receiver, SIGNAL(newAudioData(char*, int)), this, SLOT(decodeAudioData(char*, int)) );
	connect( receiver, SIGNAL(ringReplySignal()), transmitter, SLOT(sendRingReplyPacket()) );

	// renyang-modify - 接收由receiver傳送上來的peer address
	connect (receiver,SIGNAL(SignalgetIps(QStringList)),this,SLOT(SlotgetIps(QStringList)));
	// renyang-modify - 當Receiver接收到與之前的primary不同時, 要求改變primary address
	connect (receiver,SIGNAL(setPrimaddrSignal(QString)),this,SLOT(setPrimaddr(QString)));
	// renyang-modify - 當Receiver接收到事件時, 會通知上層的Call, 以便修改CallTab的ip list情況
	connect (receiver,SIGNAL(SigAddressEvent(QString,QString)),this,SLOT(SlotAddressEvent(QString,QString)));
	// renyang-modify - 對方要求影像
	connect (receiver,SIGNAL(requestImage()),this,SLOT(SlotGetImage()));
	// renyang-modify - 由receiver接收到image資料, 並處理這一些資料
	connect (receiver,SIGNAL(newVideoData(char *,int)),this,SLOT(decodeVideoData(char *,int)));
	// renyang-modify - 當收到想要接收目前封包的下一部分時...
	connect (receiver,SIGNAL(requestNextImage()),this,SLOT(sendVideo()));
	// renyang-modify - 接收到完整的image,準備把它放到video_label
	connect (receiver,SIGNAL(completeImage()),this,SLOT(processImage()));
	// renyang-modify - 跟對方要求影像失敗
	connect (receiver,SIGNAL(requestImageFail()),this,SLOT(SlotrequestImageFail()));
	// renyang-modify - end

	connect( transmitter, SIGNAL(ringMessage()), this, SLOT(ringMessage()) );
	connect( transmitter, SIGNAL(finishSignal()), this, SLOT(stopCall()) );
	connect( transmitter, SIGNAL(error(QString)), this, SLOT(abortCall(QString)) );
	connect( transmitter, SIGNAL(message(QString)), this, SLOT(message(QString)) );
	connect( transmitter, SIGNAL(startSignal()), this, SLOT(startRecorder()) );

	connect( stopTimer, SIGNAL(timeout()), this, SLOT(close()) );

	// renyang-modify - 初始化streamno
	streamno = 1;

}
Ejemplo n.º 6
0
int main()
{
    // Objects
    CameraInput *camera = new CameraInput();
    Control *controller = new Control();
    Process *processer = new Process();
    Tracking *tracker = new Tracking();
    Serial_Communication *serial = new Serial_Communication("/dev/ttyUSB0", "/dev/ttyUSB1");
//    Serial_Communication *serial = new Serial_Communication("/dev/ttyUSB0");// #### For testing with only one arduino
    File_Handler *file_Handler = new File_Handler();
    Window_Handler *window_Handler = new Window_Handler();
    Menu *menu = new Menu();


    // Threads
    QThread *t1 = new QThread;
    QThread *t2 = new QThread;
    QThread *t3 = new QThread;
    QThread *t4 = new QThread;
    QThread *t5 = new QThread;

    camera->moveToThread(t1);
    processer->moveToThread(t2);
    tracker->moveToThread(t3);
    serial->moveToThread(t3);
    controller->moveToThread(t4);
    file_Handler->moveToThread(t5);

    // Connect signals to slots. Whenever a signal is emitted in a function, its corresponding (connected) function will run.
    qRegisterMetaType<cv::Mat>("cv::Mat");

    //Signals calling from:
    //Main thread
    QObject::connect(menu, SIGNAL(startRecording(bool)), controller, SLOT(startRecording(bool)));
    QObject::connect(menu, SIGNAL(stopRecording()), controller, SLOT(stopRecording()));
    QObject::connect(menu, SIGNAL(displayMenu(cv::Mat)), window_Handler, SLOT(drawImage(cv::Mat)));
    QObject::connect(menu, SIGNAL(requestDataFromFootController()), serial, SLOT(receiveDataFromFootControllerLoop()));
    QObject::connect(menu, SIGNAL(startHighRep()), controller, SLOT(startDelayMode()));
    QObject::connect(menu, SIGNAL(decreaseDelay()), controller, SLOT(decreaseDelay()));
    QObject::connect(menu, SIGNAL(increaseDelay()), controller, SLOT(increaseDelay()));
    QObject::connect(menu, SIGNAL(modeSwitch()), controller, SLOT(endMode()));
    QObject::connect(menu, SIGNAL(startPlayback()), file_Handler, SLOT(readFromFile()));
    QObject::connect(menu, SIGNAL(stopPlayback()), file_Handler, SLOT(stopVideo()));
    QObject::connect(menu, SIGNAL(toggleSlowMotion()), file_Handler, SLOT(toggleSlowMotion()));
    QObject::connect(menu, SIGNAL(toggleTracking()), controller, SLOT(toggleTracking()));

    //Thread 1
    QObject::connect(t1, SIGNAL(started()), camera, SLOT(captureImage()));
    QObject::connect(camera, SIGNAL(capturedImage(cv::Mat)), controller, SLOT(inputImage(cv::Mat)));

    //Thread 2
    QObject::connect(t2, SIGNAL(started()), controller, SLOT(processerReady()));
    QObject::connect(processer, SIGNAL(posXposY(int,int)), tracker, SLOT(position(int,int)));
    QObject::connect(processer, SIGNAL(readyForWork()), controller, SLOT(processerReady()));

    //Thread 3
    QObject::connect(tracker, SIGNAL(directionAndSpeed(int,int)), serial, SLOT(sendDataToControlUnit(int,int)));
    QObject::connect(serial, SIGNAL(fromFootController(char)), menu, SLOT(giveInput(char)));

    //Thread 4
    QObject::connect(t4, SIGNAL(started()), controller, SLOT(fileHandlerReadyToWrite()));
    QObject::connect(controller, SIGNAL(imageToProcess(cv::Mat)), processer, SLOT(processImage(cv::Mat)));
    QObject::connect(controller, SIGNAL(requestImage()), camera, SLOT(captureImage()));
    QObject::connect(controller, SIGNAL(imageToRecord(cv::Mat)), file_Handler, SLOT(writeImage(cv::Mat)));
//    QObject::connect(controller, SIGNAL(imageToShow(cv::Mat)), window_Handler, SLOT(drawImage(cv::Mat)));
    QObject::connect(processer, SIGNAL(processedImage(cv::Mat)), window_Handler, SLOT(drawImage(cv::Mat)));
    QObject::connect(controller, SIGNAL(stopMotor()), serial, SLOT(stopMotor()));

    //Thread 5
    QObject::connect(file_Handler, SIGNAL(showFrame(cv::Mat)), window_Handler, SLOT(drawImage(cv::Mat)));
    QObject::connect(file_Handler, SIGNAL(readyToWrite()), controller, SLOT(fileHandlerReadyToWrite()));
    QObject::connect(file_Handler, SIGNAL(timeout()), file_Handler, SLOT(playVideo()));
    QObject::connect(file_Handler, SIGNAL(playbackEnded()), menu, SLOT(returnToLowRep()));

    // Starting Threads
    t1->start();
    t2->start();
    t3->start();
    t4->start();
    t5->start();

//    menu->menu();
    menu->inputHandler();
    return 0;
}
Ejemplo n.º 7
0
/**
 * @brief KGuardiantServer::run
 */
void KGuardiantServer::run()
{
    //Bloque de código principal.
    qDebug() << "KGuardiantServer.Run is executing";
    log->log("KGuardiantServer.Run is executing");



    cam = new DeviceMgr(this);
    clock = new QTimer(this);
    clock->setInterval(300);
    clock->setSingleShot(false);

    connect(cam,
            SIGNAL(finished()),
            cam,
            SLOT(deleteLater()));

    connect(clock,
            SIGNAL(timeout()),
            cam,
            SLOT(requestImage()));

    detector = new MovementDetector(this);

    connect(cam,
            SIGNAL(newImage(cv::Mat&)),
            detector,
            SLOT(processImg(cv::Mat&)),
                 Qt::DirectConnection);
    connect(cam,
            SIGNAL(newImage(cv::Mat&,cv::Mat&)),
            detector,
            SLOT(processImg(cv::Mat&,cv::Mat&))
            ,Qt::DirectConnection);

    connect(detector,
            SIGNAL(processedImg(QByteArray)),
            &server,
            SLOT(sendImg(QByteArray)));

    connect(detector,
            SIGNAL(finished()),
            detector,
            SLOT(deleteLater()));


    console = new Console(this);

    connect(console,SIGNAL(finished()),console,SLOT(deleteLater()));
    connect(console,SIGNAL(startServer()),&server,SLOT(startServer()));
    connect(console,SIGNAL(stopServer()),&server,SLOT(stopServer()));
    connect(console,SIGNAL(checkClients()),&server,SLOT(requestClients()));
    connect(&server,
            SIGNAL(clientList(QHash<qintptr,TCPConnection*>*)),
            console,
            SLOT(printClients(QHash<qintptr,TCPConnection*>*)));
    connect(console,SIGNAL(finish()),this,SLOT(quit()));




    cam->start();
    detector->start();
    clock->start();
    server.startServer();
    //console->start();
    //QTimer::singleShot(10,console,SLOT(startC()));
    //Débese chamar a quit() para finalizar o bucle de eventos do sistema.
    //quit();
}