void *handleClientConnection(void *clientData) {
	RTSPClient* clientInfo = (RTSPClient*) clientData;
	while (1) {
		RTSPmsg msg;
		char* buf = (char*) calloc(1024, sizeof(char));
		if (recvRTSPRequest(clientInfo, &msg, buf, 1024) != 0) {
			printf("Client connection failed \n");
			pausePlayback(clientInfo->playback_timer);
			free(buf);
			break;
		}
		else
		{
			printf("successfully received\n");
			respToRTSPRequest(clientInfo, msg);
			free(buf);
		}
	}
	close(clientInfo->socket);
	free(clientInfo->playback_timer);
	pthread_mutex_destroy(&clientInfo->clientLock);
	//cvReleaseCapture(&clientInfo->video);
	free(clientInfo);
	return NULL;
}
bool AllocationRenderController::renderTrace()
{
    m_port = -1;

    m_controllerSceneMap.clear();

    m_controllerStatus = STATUS_IDLE;

    m_traceController = new TraceControllerDialog(this, m_renderPeriod);

    if (!m_traceController)
        return false;

    QObject::connect(m_traceController, SIGNAL(renderPaceChanged(int)), this, SLOT(changeRenderPace(int)));
    QObject::connect(m_traceController, SIGNAL(pausePlayback()), this, SLOT(pauseTraceRendering()));
    QObject::connect(m_traceController, SIGNAL(resumePlayback()), this, SLOT(resumeTraceRendering()));
    QObject::connect(m_traceController, SIGNAL(timeLineTracking(int)), this, SLOT(timeLineTracking(int)));
    QObject::connect(m_traceController, SIGNAL(timeLineReleased(int)), this, SLOT(timeLineReleased(int)));

    m_traceController->show();

    m_trackingTraceOffset = -1;

    m_isPaused = true;
    m_isTracking = false;

    return true;
}
void processTeardown(RTSPClient *clientInfo, RTSPmsg msg) {

//	//pause
	printf("teardown1\n");
	pausePlayback(clientInfo->playback_timer);
	//set video to NULL if it's been allocated
	clientInfo->session_id = 0;	
	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
	printf("teardown6\n");
}
Beispiel #4
0
void ReplayController::willDispatchInput(const EventLoopInputBase&)
{
    ASSERT(m_sessionState == SessionState::Replaying);
    ASSERT(m_segmentState == SegmentState::Dispatching);

    m_currentPosition.inputOffset++;

    InspectorInstrumentation::playbackHitPosition(m_page, m_currentPosition);

    if (m_currentPosition == m_targetPosition)
        pausePlayback();
}
Beispiel #5
0
void ReplayController::cancelPlayback()
{
    ASSERT(m_sessionState == SessionState::Replaying);
    ASSERT(m_segmentState != SegmentState::Appending);

    if (m_segmentState == SegmentState::Unloaded)
        return;

    if (m_segmentState == SegmentState::Dispatching)
        pausePlayback();

    ASSERT(m_segmentState == SegmentState::Loaded);
    unloadSegment();
    m_sessionState = SessionState::Inactive;
    setForceDeterministicSettings(false);
    InspectorInstrumentation::playbackFinished(m_page);
}
void processSetup(RTSPClient *clientInfo, RTSPmsg msg)
{
	if (clientInfo->session_id)
	{
		pausePlayback(clientInfo->playback_timer);
	}
	if (clientInfo->current_file_path)
	{
		free(clientInfo->current_file_path);
	}
	int path_length = strlen(msg.file_path + 8);
	clientInfo->current_file_path = (char* ) calloc(path_length, sizeof(char));
	strcpy(clientInfo->current_file_path, msg.file_path + 8);
	clientInfo->current_frame_index = 0;
	if (!clientInfo->session_id)
	{
		int session_id = generateSessionId();
		clientInfo->session_id = session_id;
	}
	msg.session_id = clientInfo->session_id;
	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
}
Beispiel #7
0
// This is the basic program loop.
// When the program launches, or when a game ends, you end up here.
// If the player has already said what he wants to do next
// (by storing it in rogue.nextGame -- possibilities listed in enum NGCommands),
// we'll do it. The path (rogue.nextGamePath) is essentially a parameter for this command, and
// tells NG_VIEW_RECORDING and NG_OPEN_GAME which file to open. If there is a command but no
// accompanying path, and it's a command that should take a path, then pop up a dialog to have
// the player specify a path. If there is no command (i.e. if rogue.nextGame contains NG_NOTHING),
// then we'll display the title screen so the player can choose.
void mainBrogueJunction() {
	rogueEvent theEvent;
	char path[BROGUE_FILENAME_MAX], buf[100], seedDefault[100];
	char maxSeed[20];
	short i, j, k;
	boolean seedTooBig;
	
	// clear screen and display buffer
	for (i=0; i<COLS; i++) {
		for (j=0; j<ROWS; j++) {
			displayBuffer[i][j].character = 0;
			displayBuffer[i][j].needsUpdate = false;
			displayBuffer[i][j].opacity = 100;
			for (k=0; k<3; k++) {
				displayBuffer[i][j].foreColorComponents[k] = 0;
				displayBuffer[i][j].backColorComponents[k] = 0;
			}
			plotCharWithColor(' ', i, j, &black, &black);
		}
	}
	
	initializeLaunchArguments(&rogue.nextGame, rogue.nextGamePath, &rogue.nextGameSeed);
	
	do {
        rogue.gameHasEnded = false;
        rogue.playbackFastForward = false;
        rogue.playbackMode = false;
		switch (rogue.nextGame) {
			case NG_NOTHING:
				// Run the main menu to get a decision out of the player.
                // Seth: Added
                setBrogueGameEvent(BrogueGameEventShowTitle);
				titleMenu();
				break;
			case NG_NEW_GAME:
			case NG_NEW_GAME_WITH_SEED:
				rogue.nextGamePath[0] = '\0';
				randomNumbersGenerated = 0;
				
				rogue.playbackMode = false;
				rogue.playbackFastForward = false;
				rogue.playbackBetweenTurns = false;
                
                getAvailableFilePath(path, LAST_GAME_NAME, GAME_SUFFIX);
                strcat(path, GAME_SUFFIX);
				strcpy(currentFilePath, path);
				
				if (rogue.nextGame == NG_NEW_GAME_WITH_SEED) {
					if (rogue.nextGameSeed == 0) { // Prompt for seed; default is the previous game's seed.
						sprintf(maxSeed, "%lu", ULONG_MAX);
						if (previousGameSeed == 0) {
							seedDefault[0] = '\0';
						} else {
							sprintf(seedDefault, "%lu", previousGameSeed);
						}
						if (getInputTextString(buf, "Generate dungeon with seed number:",
											   log10(ULONG_MAX) + 1,
											   seedDefault,
											   "",
											   TEXT_INPUT_NUMBERS,
											   true)
							&& buf[0] != '\0') {
							seedTooBig = false;
							if (strlen(buf) > strlen(maxSeed)) {
								seedTooBig = true;
							} else if (strlen(buf) == strlen(maxSeed)) {
								for (i=0; maxSeed[i]; i++) {
									if (maxSeed[i] > buf[i]) {
										break; // we're good
									} else if (maxSeed[i] < buf[i]) {
										seedTooBig = true;
										break;
									}
								}
							}
							if (seedTooBig) {
								rogue.nextGameSeed = ULONG_MAX;
							} else {
								sscanf(buf, "%lu", &rogue.nextGameSeed);
							}
						} else {
							rogue.nextGame = NG_NOTHING;
							break; // Don't start a new game after all.
						}
					}
				} else {
					rogue.nextGameSeed = 0; // Seed based on clock.
				}
				// Seth: Added
                setBrogueGameEvent(BrogueGameEventStartNewGame);
				rogue.nextGame = NG_NOTHING;
				initializeRogue(rogue.nextGameSeed);
				startLevel(rogue.depthLevel, 1); // descending into level 1
				
				mainInputLoop();
				freeEverything();
				break;
			case NG_OPEN_GAME:
				rogue.nextGame = NG_NOTHING;
                // Seth: Added
                setBrogueGameEvent(BrogueGameEventBeginOpenGame);
				path[0] = '\0';
				if (rogue.nextGamePath[0]) {
					strcpy(path, rogue.nextGamePath);
					rogue.nextGamePath[0] = '\0';
				} else {
					dialogChooseFile(path, GAME_SUFFIX, "Open saved game:");
					//chooseFile(path, "Open saved game: ", "Saved game", GAME_SUFFIX);
				}
                
				if (openFile(path)) {
					loadSavedGame();
                    // Seth: Added
                    setBrogueGameEvent(BrogueGameEventOpenGame);
					mainInputLoop();
					freeEverything();
				} else {
					//dialogAlert("File not found.");
				}
				rogue.playbackMode = false;
				rogue.playbackOOS = false;
				// Seth: Added
                setBrogueGameEvent(BrogueGameEventOpenGameFinished);
				break;
			case NG_VIEW_RECORDING:
				rogue.nextGame = NG_NOTHING;
				// Seth: Added
                setBrogueGameEvent(BrogueGameEventBeginOpenGame);
				path[0] = '\0';
				if (rogue.nextGamePath[0]) {
					strcpy(path, rogue.nextGamePath);
					rogue.nextGamePath[0] = '\0';
				} else {
					dialogChooseFile(path, RECORDING_SUFFIX, "View recording:");
					//chooseFile(path, "View recording: ", "Recording", RECORDING_SUFFIX);
				}
				
				if (openFile(path)) {
                    // Seth: Added
                    setBrogueGameEvent(BrogueGameEventPlayRecording);
					randomNumbersGenerated = 0;
					rogue.playbackMode = true;
					initializeRogue(0); // Seed argument is ignored because we're in playback.
					if (!rogue.gameHasEnded) {
						startLevel(rogue.depthLevel, 1);
						pausePlayback();
						displayAnnotation(); // in case there's an annotation for turn 0
					}
					
					while(!rogue.gameHasEnded && rogue.playbackMode) {
						rogue.RNG = RNG_COSMETIC; // dancing terrain colors can't influence recordings
						rogue.playbackBetweenTurns = true;
						nextBrogueEvent(&theEvent, false, true, false);
						rogue.RNG = RNG_SUBSTANTIVE;
						
						executeEvent(&theEvent);
					}
					
					freeEverything();
				} else {
					// announce file not found
				}
				rogue.playbackMode = false;
				rogue.playbackOOS = false;
				
				break;
			case NG_HIGH_SCORES:
				rogue.nextGame = NG_NOTHING;
                // Seth: Added
                setBrogueGameEvent(BrogueGameEventShowHighScores);
				printHighScores(false);
				break;
            case NG_SCUM:
                rogue.nextGame = NG_NOTHING;
                scum(1, 1000, 5);
                break;
			case NG_QUIT:
				// No need to do anything.
				break;
			default:
				break;
		}
	} while (rogue.nextGame != NG_QUIT);
}
Beispiel #8
0
// This is the basic program loop.
// When the program launches, or when a game ends, you end up here.
// If the player has already said what he wants to do next
// (by storing it in rogue.nextGame -- possibilities listed in enum NGCommands),
// we'll do it. The path (rogue.nextGamePath) is essentially a parameter for this command, and
// tells NG_VIEW_RECORDING and NG_OPEN_GAME which file to open. If there is a command but no
// accompanying path, and it's a command that should take a path, then pop up a dialog to have
// the player specify a path. If there is no command (i.e. if rogue.nextGame contains NG_NOTHING),
// then we'll display the title screen so the player can choose.
void mainBrogueJunction() {
	rogueEvent theEvent;
	char path[BROGUE_FILENAME_MAX], buf[100], seedDefault[100];
	char maxSeed[64];
	short i;
	boolean seedTooBig;

	if (ioInitialize() != 0) {
		printf("Failure to initialize display\n");
		exit(1);
	}
	
	initializeLaunchArguments(&rogue.nextGame, rogue.nextGamePath, &rogue.nextGameSeed);
	
	do {
        rogue.gameHasEnded = false;
        rogue.playbackFastForward = false;
        rogue.playbackMode = false;
		switch (rogue.nextGame) {
			case NG_NOTHING:
				// Run the main menu to get a decision out of the player.
				titleMenu();
				break;
			case NG_NEW_GAME:
			case NG_NEW_GAME_WITH_SEED:
				rogue.nextGamePath[0] = '\0';
				randomNumbersGenerated = 0;
				
				rogue.playbackMode = false;
				rogue.playbackFastForward = false;
				rogue.playbackBetweenTurns = false;
                
                getAvailableFilePath(path, LAST_GAME_NAME, GAME_SUFFIX);
                strcat(path, GAME_SUFFIX);
				strcpy(currentFilePath, path);
				
				if (rogue.nextGame == NG_NEW_GAME_WITH_SEED) {
					if (rogue.nextGameSeed == 0) { // Prompt for seed; default is the previous game's seed.
						sprintf(maxSeed, "%lu", ULONG_MAX);
						if (previousGameSeed == 0) {
							seedDefault[0] = '\0';
						} else {
							sprintf(seedDefault, "%lu", previousGameSeed);
						}
						if (getInputTextString(buf, "输入随机数种子生成地下城:",
											   log10(ULONG_MAX) + 1 + 6, // pad for header text
											   seedDefault,
											   "",
											   TEXT_INPUT_NUMBERS,
											   true)
							&& buf[0] != '\0') {
							seedTooBig = false;
							if (strlen(buf) > strlen(maxSeed)) {
								seedTooBig = true;
							} else if (strlen(buf) == strlen(maxSeed)) {
								for (i=0; maxSeed[i]; i++) {
									if (maxSeed[i] > buf[i]) {
										break; // we're good
									} else if (maxSeed[i] < buf[i]) {
										seedTooBig = true;
										break;
									}
								}
							}
							if (seedTooBig) {
								rogue.nextGameSeed = ULONG_MAX;
							} else {
								sscanf(buf, "%lu", &rogue.nextGameSeed);
							}
						} else {
							rogue.nextGame = NG_NOTHING;
							break; // Don't start a new game after all.
						}
					}
				} else {
					rogue.nextGameSeed = 0; // Seed based on clock.
				}
				
				rogue.nextGame = NG_NOTHING;
				initializeRogue(rogue.nextGameSeed);
				startLevel(rogue.depthLevel, 1); // descending into level 1
				
				mainInputLoop();
				freeEverything();
				break;
			case NG_OPEN_GAME:
				rogue.nextGame = NG_NOTHING;
				path[0] = '\0';
				if (rogue.nextGamePath[0]) {
					strcpy(path, rogue.nextGamePath);
					rogue.nextGamePath[0] = '\0';
				} else {
					dialogChooseFile(path, GAME_SUFFIX, "选择中断存档进行读取:");
					//chooseFile(path, "Open saved game: ", "Saved game", GAME_SUFFIX);
				}
					
				if (openFile(path)) {
					loadSavedGame();
					mainInputLoop();
					freeEverything();
				} else {
					//dialogAlert("File not found.");
				}
				rogue.playbackMode = false;
				rogue.playbackOOS = false;
				
				break;
			case NG_VIEW_RECORDING:
				rogue.nextGame = NG_NOTHING;
				
				path[0] = '\0';
				if (rogue.nextGamePath[0]) {
					strcpy(path, rogue.nextGamePath);
					rogue.nextGamePath[0] = '\0';
				} else {
					dialogChooseFile(path, RECORDING_SUFFIX, "选择录像文件进行回放:");
					//chooseFile(path, "View recording: ", "Recording", RECORDING_SUFFIX);
				}
				
				if (openFile(path)) {
					randomNumbersGenerated = 0;
					rogue.playbackMode = true;
					initializeRogue(0); // Seed argument is ignored because we're in playback.
					if (!rogue.gameHasEnded) {
						startLevel(rogue.depthLevel, 1);
						pausePlayback();
						displayAnnotation(); // in case there's an annotation for turn 0
					}
					
					while(!rogue.gameHasEnded && rogue.playbackMode) {
						rogue.RNG = RNG_COSMETIC; // dancing terrain colors can't influence recordings
						rogue.playbackBetweenTurns = true;
						nextBrogueEvent(&theEvent, false, true, false);
						rogue.RNG = RNG_SUBSTANTIVE;
						
						executeEvent(&theEvent);
					}
					
					freeEverything();
				} else {
					// announce file not found
				}
				rogue.playbackMode = false;
				rogue.playbackOOS = false;
				
				break;
			case NG_HIGH_SCORES:
				rogue.nextGame = NG_NOTHING;
				printHighScores(false);
				break;
            case NG_SCUM:
                rogue.nextGame = NG_NOTHING;
                scum(1, 1000, 5);
                break;
			case NG_QUIT:
				// No need to do anything.
				break;
			default:
				break;
		}
	} while (rogue.nextGame != NG_QUIT);
}
Beispiel #9
0
VideoWindow::VideoWindow(Context *context, const QDir &home)  :
    GcWindow(context), home(home), context(context), m_MediaChanged(false)
{
    setControls(NULL);
    setInstanceName("Video Window");
    setProperty("color", Qt::black);

    QHBoxLayout *layout = new QHBoxLayout();
    setLayout(layout);

    // config paramaters to libvlc
    const char * const vlc_args[] = {
                    "-I", "dummy", /* Don't use any interface */
                    "--ignore-config", /* Don't use VLC's config */
                    "--disable-screensaver", /* disable screensaver during playback */
#ifdef Q_OS_LINUX
                    "--no-xlib", // avoid xlib thread error messages
#endif
                    "--verbose=-1", // -1 = no output at all
                    "--quiet"
                };

    /* create an exception handler */
    //libvlc_exception_init(&exceptions);
    //vlc_exceptions(&exceptions);

    /* Load the VLC engine */
    inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
    //vlc_exceptions(&exceptions);

    /* Create a new item */

    m = NULL;
    //vlc_exceptions(&exceptions);
        
    /* Create a media player playing environement */
    mp = libvlc_media_player_new (inst);
    //vlc_exceptions(&exceptions);

    //vlc_exceptions(&exceptions);

 
    /* This is a non working code that show how to hooks into a window,
     * if we have a window around */
#ifdef Q_OS_LINUX
     x11Container = new QX11EmbedContainer(this);
     layout->addWidget(x11Container);
     libvlc_media_player_set_xwindow (mp, x11Container->winId());
#endif
#ifdef WIN32
     container = new QWidget(this);
     layout->addWidget(container);
     libvlc_media_player_set_hwnd (mp, container->winId());
#endif

    connect(context, SIGNAL(stop()), this, SLOT(stopPlayback()));
    connect(context, SIGNAL(start()), this, SLOT(startPlayback()));
    connect(context, SIGNAL(pause()), this, SLOT(pausePlayback()));
    connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long)));
    connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback()));
    connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString)));

}
Beispiel #10
0
void GLRenderWidget::togglePause()
{
	pausePlayback(mPauseAction->isChecked());
}
void processPause(RTSPClient *clientInfo, RTSPmsg msg){

	sendSuccessResponse(clientInfo->socket, msg.seq, msg.session_id);
	pausePlayback(clientInfo->playback_timer);
}
Beispiel #12
0
VideoWindow::VideoWindow(Context *context, const QDir &home)  :
    GcWindow(context), home(home), context(context), m_MediaChanged(false)
{
    setControls(NULL);
    setProperty("color", QColor(Qt::black));

    QHBoxLayout *layout = new QHBoxLayout();
    setLayout(layout);

    init = true; // assume initialisation was ok ...

#ifdef GC_VIDEO_VLC
    //
    // USE VLC VIDEOPLAYER
    //
#if QT_VERSION >= 0x050000
#warning "WARNING: Please ensure the VLC QT4 plugin (gui/libqt4_plugin) is NOT available as it will cause GC to crash."
#endif

    // config paramaters to libvlc
    const char * const vlc_args[] = {
                    "-I", "dummy", /* Don't use any interface */
                    "--ignore-config", /* Don't use VLC's config */
                    "--disable-screensaver", /* disable screensaver during playback */
#ifdef Q_OS_LINUX
                    "--no-xlib", // avoid xlib thread error messages
#endif
                    //"--verbose=-1", // -1 = no output at all
                    //"--quiet"
                };

    /* create an exception handler */
    //libvlc_exception_init(&exceptions);
    //vlc_exceptions(&exceptions);

    /* Load the VLC engine */
    inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
    //vlc_exceptions(&exceptions);

    /* Create a new item */

    if (inst) { // if vlc doesn't initialise don't even try!

        m = NULL;
        //vlc_exceptions(&exceptions);
        
        /* Create a media player playing environement */
        mp = libvlc_media_player_new (inst);
        //vlc_exceptions(&exceptions);

        //vlc_exceptions(&exceptions);

 
    /* This is a non working code that show how to hooks into a window,
     * if we have a window around */
#ifdef Q_OS_LINUX
#if QT_VERSION > 0x50000
        x11Container = new QWidget(this); //XXX PORT TO 5.1 BROKEN CODE XXX
#else
        x11Container = new QX11EmbedContainer(this);
#endif
        layout->addWidget(x11Container);
        libvlc_media_player_set_xwindow (mp, x11Container->winId());
#endif

#ifdef WIN32
        container = new QWidget(this);
        layout->addWidget(container);
        libvlc_media_player_set_hwnd (mp, (HWND)(container->winId()));
#endif
    } else {

        // something went wrong !
        init = false;
    }
#endif

#ifdef GC_VIDEO_QT5
    // USE QT VIDEO PLAYER
    wd = new QVideoWidget(this);
    wd->show();

    mp = new QMediaPlayer(this);
    mp->setVideoOutput(wd);

    layout->addWidget(wd);
#endif

    if (init) {
        connect(context, SIGNAL(stop()), this, SLOT(stopPlayback()));
        connect(context, SIGNAL(start()), this, SLOT(startPlayback()));
        connect(context, SIGNAL(pause()), this, SLOT(pausePlayback()));
        connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long)));
        connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback()));
        connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString)));
    }
}