Ejemplo n.º 1
0
void MainWindow::lose(){
    timer.stop();
    QString msg;
    if (lives <0)
        msg = "You lost, I'm sorry...\n\nWould you like to restart the game?";
    else
        msg = "YOU WON, congratulations!\n\nWould you like to restart the game?";
    QMessageBox::StandardButton reply;
      reply = QMessageBox::question(this, "Rematch", msg,
                                    QMessageBox::Yes|QMessageBox::No);
      if (reply == QMessageBox::Yes) {
          restart();
      } else {
          closeVideoStream();
          close();
          exit(0);
      }
}
Ejemplo n.º 2
0
// Kezeli a billentyűlenyomást
void MainWindow::keyPressEvent(QKeyEvent *event){
    switch (event->key())
    {
        case Qt::Key_N:
                myRoad->moveCar(1); //turn right;
            break;
        case Qt::Key_B:
                myRoad->moveCar(-1); //turn left;
            break;
        case Qt::Key_Escape:
            closeVideoStream();
            close();
            exit(0);
            break;
        default:
            break;
    }   
}
Ejemplo n.º 3
0
/*Send OK Function
  Variable Definition:
  -- url: the request url except domain name and port number
  -- method: the request method
  -- cseq: cseq number
  -- client_socket: socket connected to the client
  Return Value: NULL
*/
void sendOK(char *url, const char *method, u_int32 cseq, int client_socket){
	//Handle the SETUP method
	if (methodIsSetup(method)){
		char	*entity_body = (char*)malloc(sizeof(char) * (HALFBUF_SIZE + 1));	//entity body
		char	*transport = (char*)malloc(sizeof(char) * (STRING_SIZE + 1));		//transport information

		//Set the transport information
		sprintf(transport, "%s; %s; client_port=%d; server_port=%d; mode=PLAY", protocol_type,
																				protocol_method,
																				client_rtp_port,
																				server_rtp_port);
		//Set the entity_body
		sprintf(entity_body, "frame_number=%u", getVideoInfo(url));
		//SETUP method Response Message
		constructResponseMessage(	client_socket,
									NULL,
									200,
									"OK",
									cseq,
									transport,
									convertTimeFormat(getTimeInGMTFormat(url, 2), 1),
									strlen(entity_body) + 1,
									"text/plain",
									entity_body);
		//Set the status
		status = READY;
	}
	else if (methodIsPlay(method)){
		//PLAY method Response Message
		constructResponseMessage(	client_socket,
									NULL,
									200,
									"OK",
									cseq,
									NULL,
									convertTimeFormat(getTimeInGMTFormat(url, 2), 1),
									0,
									NULL,
									NULL);
		//Set the status
		status = PLAYING;
		//Start RTP progress
		startRTPProgress();
	}
	else if (methodIsPause(method)){
		//PAUSE method Response Message
		constructResponseMessage(	client_socket,
									NULL,
									200,
									"OK",
									cseq,
									NULL,
									convertTimeFormat(getTimeInGMTFormat(url, 2), 1),
									0,
									NULL,
									NULL);
		//Set the status
		status = READY;
		//Stop RTP Progress
		stopRTPProgress();
	}
	else if (methodIsTeardown(method)){
		//PAUSE method Response Message
		constructResponseMessage(	client_socket,
									NULL,
									200,
									"OK",
									cseq,
									NULL,
									convertTimeFormat(getTimeInGMTFormat(url, 2), 1),
									0,
									NULL,
									NULL);
		//Close stream for video file
		closeVideoStream();
		//Set the status
		status = INIT;
	}

	return;
}
Ejemplo n.º 4
0
// Handle the close window event
void MainWindow::closeEvent (QCloseEvent *event)
{
    closeVideoStream();
    event->accept();
}