// Run a Lua command. // This function is currently used by luaUqm_debug_interactive, but should // also be suitable if we have some graphical console, when different // callback functions than luaUqm_debug_outputCallback() and // luaUqm_debug_errorCallback are used. void luaUqm_debug_runLine(const char *exprBuf, void (*outputCallback)(void *extra, const char *format, ...), void (*errorCallback)(void *extra, const char *format, ...), void *extra) { int resultType; const char *resultStr; const char *resultTypeStr; // Compile the string to a Lua function. { if (luaL_loadstring (luaUqm_debugState, exprBuf) != LUA_OK) { // An error occurred during parsing. errorCallback(extra, "Syntax error: %s\n", lua_tostring (luaUqm_debugState, -1)); lua_pop(luaUqm_debugState, 1); // Pop the error. return; } } // Call the Lua function. if (lua_pcall (luaUqm_debugState, 0, 1, 0) != 0) { // An error occurred during execution. errorCallback(extra, "Runtime error: %s\n", lua_tostring (luaUqm_debugState, -1)); lua_pop(luaUqm_debugState, 1); // Pop the error. return; } // Success. Result is on the stack. // Convert the result to a string. resultType = lua_type(luaUqm_debugState, -1); resultTypeStr = lua_typename(luaUqm_debugState, resultType); resultStr = lua_tolstring (luaUqm_debugState, -1, NULL); // Memory for 'resultStr' lasts until the lua_pop(). if (resultStr == NULL) { // Not a string and not convertable to a string. // The command was executed ok though, and we treat this as such. outputCallback(extra, "(%s)\n", resultTypeStr); } else { outputCallback(extra, "(%s) %s\n", resultTypeStr, resultStr); } // Pop the result from the stack. lua_pop (luaUqm_debugState, 1); }
bool Server::openNewPutty() { if(!this->isOn()) { emit error(tr("The machine is not connected. " \ "It's not possible execute any command !")); return false; } if(this->putty != NULL) { emit error(tr("A command has already been launched on this machine ! "\ "Please wait !")); return false; } this->putty = new Putty(this->getIp(), this->getUser(), this->getPassword(), this->os); QObject::connect(this->putty, SIGNAL(error(QString)), this, SLOT(errorCallback(QString))); QObject::connect(this->putty, SIGNAL(output(QString)), this, SLOT(outputCallback(QString))); QObject::connect(this->putty, SIGNAL(finished()), this, SLOT(deletePutty())); return true; }
void NuppelWriter::writeFrame(unsigned char *frameBuffer, csTicks& encodeTime, csTicks& writeTime) { rtframeheader frameh; lzo_uint lzoSize; unsigned char *currentBuffer; unsigned int currentBufferSize; writeTime = 0; encodeTime = 0; /* Do we need to write a keyframe? */ if ((frameofgop % keyframeFreq) == 0) { writeTime = csGetTicks(); memset(&frameh, 'j', sizeof(frameh)); frameh.frametype = 'R'; frameh.comptype = 'T'; outputCallback(&frameh, sizeof(frameh), callbackExtra); memset(&frameh, 0, sizeof(frameh)); frameofgop = 0; frameh.frametype = 'S'; frameh.comptype = 'V'; frameh.timecode = frameNumber; outputCallback(&frameh, sizeof(frameh), callbackExtra); writeTime = csGetTicks() - writeTime; } encodeTime = csGetTicks(); /* Set up a video frame with RTJpeg and LZO compression */ memset(&frameh, 0, sizeof(frameh)); frameh.frametype = 'V'; frameh.keyframe = frameofgop; frameh.timecode = (int) (frameNumber / frameRate * 1000.0); if (rgb) { /* Nonstandard: uncompressed bottom-up RGB24 */ frameh.comptype = 'R'; #if 0 uint8 *rawRgb = frameBuffer; int bufPitch = width * 3; uint8 *destLine = rgbBuffer + (height - 1) * bufPitch; int x, y; y = height; while (y--) { x = width; while (x--) { *destLine++ = *rawRgb++; *destLine++ = *rawRgb++; *destLine++ = *rawRgb++; rawRgb++; } destLine -= bufPitch * 2; } currentBuffer = rgbBuffer; currentBufferSize = bufferSize; #else currentBuffer = frameBuffer; currentBufferSize = bufferSize; #endif } else { /* Convert from RGB to YUV420. This routine has also * been modified to flip the video vertically. */ RGB2YUV420(width, height, frameBuffer, yuvBuffer); currentBuffer = yuvBuffer; currentBufferSize = width*height+(width*height/2); frameh.comptype = '0'; } if (rtjpeg) { /* Compress the frame using RTJpeg (lossy) */ currentBufferSize = RTjpeg_mcompressYUV420((int8*) compressBuffer, yuvBuffer, 1, 1); currentBuffer = compressBuffer; frameh.comptype = '1'; } if (lzo) { /* Compress it again using LZO (lossless) */ lzo1x_1_compress(currentBuffer, currentBufferSize, frameBuffer, &lzoSize, lzoTmp); currentBufferSize = lzoSize; currentBuffer = frameBuffer; if (rtjpeg) frameh.comptype = '2'; else { if (rgb) frameh.comptype = 'r'; /* Nonstandard: LZO'ed bottom-up RGB24 */ else frameh.comptype = '3'; } } csTicks ticks = csGetTicks(); encodeTime = ticks - encodeTime; writeTime = ticks - writeTime; /* Write the frame */ frameh.packetlength = currentBufferSize; outputCallback(&frameh, sizeof(frameh), callbackExtra); outputCallback(currentBuffer, currentBufferSize, callbackExtra); writeTime = csGetTicks() - writeTime; frameNumber++; frameofgop++; }